diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d83dd61 --- /dev/null +++ b/LICENSE @@ -0,0 +1,33 @@ +BSD 3-Clause License + +Copyright © 2020, Intel Corporation +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..70efbd2 --- /dev/null +++ b/Makefile @@ -0,0 +1,62 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +.PHONY: clean \ + build \ + docker-rm \ + clean-docker \ + run-portainer \ + run \ + down \ + build-image \ + +DOCKERS= \ + docker-build-image \ + as-vending \ + as-controller-board-status \ + ds-card-reader \ + ds-controller-board \ + ds-inference-mock \ + ms-authentication \ + ms-inventory \ + ms-ledger + +.PHONY: $(DOCKERS) + +docker-rm: + -docker rm $$(docker ps -aq) + +clean-docker: docker-rm + docker volume prune -f && \ + docker network prune -f + +run-portainer: + docker-compose -f docker-compose.portainer.yml up -d + +run: + docker-compose -f docker-compose.yml up -d + +run-physical: + docker-compose -f docker-compose.yml -f docker-compose.physical.card-reader.yml -f docker-compose.physical.controller-board.yml up -d + +run-physical-card-reader: + docker-compose -f docker-compose.yml -f docker-compose.physical.card-reader.yml up -d + +run-physical-controller-board: + docker-compose -f docker-compose.yml -f docker-compose.physical.controller-board.yml up -d + +down: + -docker-compose -f docker-compose.yml stop -t 1 + -docker-compose -f docker-compose.yml down + +clean: down docker-rm + docker rmi -f $$(docker images | grep '' | awk '{print $$3}') && \ + docker rmi -f $$(docker images | grep automated-checkout | awk '{print $$3}') && \ + docker volume prune -f && \ + docker network prune -f + +$(DOCKERS): + cd $@; \ + make build + +build : $(DOCKERS) diff --git a/README.md b/README.md index 8b13789..28b0f15 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ +# Automated Checkout +For complete documentation on the Automated Checkout Reference Design, please visit **[this repository's GitHub Pages site](https://intel-iot-devkit.github.io/automated-checkout/index.html)**. diff --git a/as-controller-board-status/.gitignore b/as-controller-board-status/.gitignore new file mode 100644 index 0000000..5044058 --- /dev/null +++ b/as-controller-board-status/.gitignore @@ -0,0 +1,22 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, build with `go test -c` +*.test +main +as-controller-board-status +test.txt +go.sum +.vscode/* + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# created during testing +functions/test.log +functions/test_*.log +logs/* diff --git a/as-controller-board-status/.golangci.yml b/as-controller-board-status/.golangci.yml new file mode 100644 index 0000000..00ec54e --- /dev/null +++ b/as-controller-board-status/.golangci.yml @@ -0,0 +1,28 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +run: + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 5m +linters-settings: + misspell: + locale: US +linters: + enable: + - bodyclose + - errcheck + - goconst + - golint + - govet + - gosimple + - ineffassign + - misspell + - staticcheck + - structcheck + - typecheck + - unused + - unconvert + - unparam + - varcheck + disable-all: true + fast: true diff --git a/as-controller-board-status/Dockerfile b/as-controller-board-status/Dockerfile new file mode 100644 index 0000000..3a4daee --- /dev/null +++ b/as-controller-board-status/Dockerfile @@ -0,0 +1,26 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +FROM automated-checkout/build:latest AS builder + +LABEL license='SPDX-License-Identifier: BSD-3-Clause' \ + copyright='Copyright (c) 2020: Intel' + +RUN mkdir as-controller-board-status +WORKDIR /usr/local/bin/as-controller-board-status/ +COPY . . + +# Compile the code +RUN make gobuild + +# Next image - Copy built Go binary into new workspace +FROM alpine + +LABEL license='SPDX-License-Identifier: BSD-3-Clause' \ + copyright='Copyright (c) 2020: Intel' + +RUN apk --no-cache add zeromq +COPY --from=builder /usr/local/bin/as-controller-board-status/res/docker/configuration.toml /res/docker/configuration.toml +COPY --from=builder /usr/local/bin/as-controller-board-status/main /as-controller-board-status + +CMD [ "/as-controller-board-status","--profile=docker","--confdir=/res", "-r"] diff --git a/as-controller-board-status/LICENSE b/as-controller-board-status/LICENSE new file mode 100644 index 0000000..dbff156 --- /dev/null +++ b/as-controller-board-status/LICENSE @@ -0,0 +1,31 @@ +BSD 3-Clause License + +Copyright © 2020, Intel Corporation +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/as-controller-board-status/Makefile b/as-controller-board-status/Makefile new file mode 100644 index 0000000..e23c24b --- /dev/null +++ b/as-controller-board-status/Makefile @@ -0,0 +1,45 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +.PHONY: build gobuild run gorun stop test lint + +MICROSERVICE=automated-checkout/as-controller-board-status + +build: + docker build --rm \ + --build-arg http_proxy \ + --build-arg https_proxy \ + -f Dockerfile \ + -t $(MICROSERVICE):dev \ + . + +gobuild: + CGO_ENABLED=1 GOOS=linux go build -ldflags='-s -w' -a -installsuffix cgo main.go + +run: + docker run \ + --rm \ + -p 48094:48094 \ + $(MICROSERVICE):dev + +gorun: + ./main + +stop: + docker rm -f $(MICROSERVICE):dev + +test: + go test -test.v -cover ./... + +testHTML: + go test -test.v -coverprofile=test_coverage.out ./... && \ + go tool cover -html=test_coverage.out + +GOLANGCI_VERSION := $(shell golangci-lint --version 2>/dev/null) + +lint: +ifdef GOLANGCI_VERSION + golangci-lint run +else + @echo "golangci-lint not found. Please refer to the README documentation for proper installation" +endif diff --git a/as-controller-board-status/functions/common.go b/as-controller-board-status/functions/common.go new file mode 100644 index 0000000..2ba7fcd --- /dev/null +++ b/as-controller-board-status/functions/common.go @@ -0,0 +1,62 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package functions + +import ( + "bytes" + "fmt" + "net/http" + + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +const ( + // RESTPost is a const used for REST commands using the specified method. + RESTPost = "POST" + // RESTPut is a const used for REST commands using the specified method. + RESTPut = "PUT" + // RESTGet is a const used for REST commands using the specified method. + RESTGet = "GET" + // ApplicationJSONContentType is a const holding the common HTTP + // Content-Type header value, "application/json" + ApplicationJSONContentType = "application/json" +) + +// RESTCommandJSON submits a REST API call a specified restURL using the +// specified restMethod, and will serialize the inputInterface into JSON +// and submit it as part of the outbound REST request. +func (edgexconfig *ControllerBoardStatusAppSettings) RESTCommandJSON(restURL string, restMethod string, inputInterface interface{}) (err error) { + // Serialize the inputInterface + inputInterfaceJSON, err := utilities.GetAsJSON(inputInterface) + if err != nil { + return fmt.Errorf("Failed to serialize the input interface as JSON: %v", err.Error()) + } + + // Build out the request + req, err := http.NewRequest(restMethod, restURL, bytes.NewBuffer([]byte(inputInterfaceJSON))) + if err != nil { + return fmt.Errorf("Failed to build the REST %v request for the URL %v due to error: %v", restMethod, restURL, err.Error()) + } + client := &http.Client{ + Timeout: edgexconfig.RESTCommandTimeout, + } + + resp, err := client.Do(req) + if err != nil { + return fmt.Errorf("Failed to submit REST %v request due to error: %v", restMethod, err.Error()) + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + // Convert the response body into a string so that it can be returned as part of the error + buf := new(bytes.Buffer) + _, err := buf.ReadFrom(resp.Body) + if err != nil { + return fmt.Errorf("Did not receive an HTTP 200 status OK response from %v, instead got a response code of %v, and the response body could not be serialized", restURL, resp.StatusCode) + } + return fmt.Errorf("Did not receive an HTTP 200 status OK response from %v, instead got a response code of %v, and the response body was: %v", restURL, resp.StatusCode, buf.String()) + } + + return nil +} diff --git a/as-controller-board-status/functions/common_test.go b/as-controller-board-status/functions/common_test.go new file mode 100644 index 0000000..c949019 --- /dev/null +++ b/as-controller-board-status/functions/common_test.go @@ -0,0 +1,157 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package functions + +import ( + "fmt" + "net/http" + "net/http/httptest" + "testing" + "time" + + assert "github.com/stretchr/testify/assert" +) + +// GetHTTPTestServer returns a basic HTTP test server that does nothing more than respond with +// a desired status code +func GetHTTPTestServer(statusCodeResponse int, response string) *httptest.Server { + return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(statusCodeResponse) + _, err := w.Write([]byte(response)) + if err != nil { + panic(err) + } + + })) +} + +// GetErrorHTTPTestServer returns a basic HTTP test server that produces a guaranteed error condition +// by simply closing client connections +func GetErrorHTTPTestServer() *httptest.Server { + var testServerThrowError *httptest.Server + testServerThrowError = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + testServerThrowError.CloseClientConnections() + })) + return testServerThrowError +} + +type testTableRESTCommandJSONStruct struct { + TestCaseName string + Config ControllerBoardStatusAppSettings + InputRESTMethod string + InputInterface interface{} + HTTPTestServer *httptest.Server + Output error +} + +func prepRESTCommandJSONTest() ([]testTableRESTCommandJSONStruct, []*httptest.Server) { + output := []testTableRESTCommandJSONStruct{} + + // This server returns 200 OK + testServerStatusOK := GetHTTPTestServer(http.StatusOK, "") + + // This server throws HTTP 500 as part of a non-error response + testServer500 := GetHTTPTestServer(http.StatusInternalServerError, "test response body") + + // This server throws errors when it receives a connection + testServerThrowError := GetErrorHTTPTestServer() + + edgexconfig := ControllerBoardStatusAppSettings{ + RESTCommandTimeout: time.Second * 15, + } + + invalidRestMethod := "invalid rest method" + + output = append(output, + testTableRESTCommandJSONStruct{ + TestCaseName: "Success GET", + Config: edgexconfig, + InputRESTMethod: RESTGet, + InputInterface: "", + HTTPTestServer: testServerStatusOK, + Output: nil, + }) + + output = append(output, + testTableRESTCommandJSONStruct{ + TestCaseName: "Success POST", + Config: edgexconfig, + InputRESTMethod: RESTPost, + InputInterface: "simple test string", + HTTPTestServer: testServerStatusOK, + Output: nil, + }) + output = append(output, + testTableRESTCommandJSONStruct{ + TestCaseName: "Success PUT", + Config: edgexconfig, + InputRESTMethod: RESTPut, + InputInterface: "simple test string", + HTTPTestServer: testServerStatusOK, + Output: nil, + }) + output = append(output, + testTableRESTCommandJSONStruct{ + TestCaseName: "Unsuccessful GET due to undesired status code", + Config: edgexconfig, + InputRESTMethod: RESTGet, + InputInterface: "", + HTTPTestServer: testServer500, + Output: fmt.Errorf("Did not receive an HTTP 200 status OK response from %v, instead got a response code of %v, and the response body was: %v", testServer500.URL, http.StatusInternalServerError, "test response body"), + }) + output = append(output, + testTableRESTCommandJSONStruct{ + TestCaseName: "Unsuccessful GET due to connection closure", + Config: edgexconfig, + InputRESTMethod: RESTGet, + InputInterface: "", + HTTPTestServer: testServerThrowError, + Output: fmt.Errorf("Failed to submit REST %v request due to error: %v %v: %v", RESTGet, "Get", testServerThrowError.URL, "EOF"), + }) + output = append(output, + testTableRESTCommandJSONStruct{ + TestCaseName: "Unsuccessful GET due to unserializable JSON input", + Config: edgexconfig, + InputRESTMethod: RESTGet, + InputInterface: map[string](chan bool){ + "test": make(chan bool), + }, + HTTPTestServer: testServerStatusOK, + Output: fmt.Errorf("Failed to serialize the input interface as JSON: Failed to marshal into JSON string: json: unsupported type: chan bool"), + }) + output = append(output, + testTableRESTCommandJSONStruct{ + TestCaseName: "Unsuccessful call due to invalid REST Method", + Config: edgexconfig, + InputRESTMethod: invalidRestMethod, + InputInterface: "", + HTTPTestServer: testServerStatusOK, + Output: fmt.Errorf("Failed to build the REST %v request for the URL %v due to error: net/http: invalid method \"%v\"", invalidRestMethod, testServerStatusOK.URL, invalidRestMethod), // https://github.com/golang/go/blob/7d2473dc81c659fba3f3b83bc6e93ca5fe37a898/src/net/http/request.go#L846 + }) + return output, []*httptest.Server{ + testServerStatusOK, + testServer500, + testServerThrowError, + } +} + +// TestRESTCommandJSON validates that the RESTCommandJSON works in all +// possible error conditions & success conditions +func TestRESTCommandJSON(t *testing.T) { + testTable, testServers := prepRESTCommandJSONTest() + // We are responsible for closing the test servers + for _, testServer := range testServers { + defer testServer.Close() + } + + for _, testCase := range testTable { + ct := testCase // pinning to avoid concurrency issues + t.Run(ct.TestCaseName, func(t *testing.T) { + assert := assert.New(t) + err := testCase.Config.RESTCommandJSON(testCase.HTTPTestServer.URL, testCase.InputRESTMethod, testCase.InputInterface) + assert.Equal(err, ct.Output, "Expected output to be the same") + }) + } + +} diff --git a/as-controller-board-status/functions/config.go b/as-controller-board-status/functions/config.go new file mode 100644 index 0000000..efc1a86 --- /dev/null +++ b/as-controller-board-status/functions/config.go @@ -0,0 +1,124 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package functions + +import ( + "encoding/json" + "fmt" + "reflect" + "strconv" + "strings" + "time" +) + +// ControllerBoardStatusAppSettings is a data structure that holds the +// validated application settings (loaded from configuration.toml). +type ControllerBoardStatusAppSettings struct { + AverageTemperatureMeasurementDuration time.Duration + DeviceName string + MaxTemperatureThreshold float64 + MinTemperatureThreshold float64 + MQTTEndpoint string + NotificationCategory string + NotificationEmailAddresses []string + NotificationHost string + NotificationLabels []string + NotificationReceiver string + NotificationSender string + NotificationSeverity string + NotificationSlug string + NotificationSlugPrefix string + NotificationSubscriptionMaxRESTRetries int + NotificationSubscriptionRESTRetryInterval time.Duration + NotificationThrottleDuration time.Duration + RESTCommandTimeout time.Duration + SubscriptionHost string + VendingEndpoint string +} + +// GetGenericError helps keep the ProcessApplicationSettings slim by enabling +// re-use of a common error format that should be returned to the user when +// the user fails to specify a configuration item. +func GetGenericError(confKey string, confItemType reflect.Type) error { + return fmt.Errorf("The \"%v\" application setting has not been set. Please set this to an acceptable %v value in configuration.toml", confKey, confItemType) +} + +// GetGenericParseError helps keep the ProcessApplicationSettings slim by enabling +// re-use of a common error format that should be returned to the user when +// the user fails to specify a parseable configuration item. +func GetGenericParseError(confKey string, confValue interface{}, confItemType reflect.Type) error { + return fmt.Errorf("The \"%v\" application setting been set, but failed to parse the value \"%v\". Please set this to an acceptable %v value in configuration.toml", confKey, confValue, confItemType) +} + +// ProcessApplicationSettings returns a configuration containing all of the +// EdgeX settings. This function should be called every time a function +// in the EdgeX pipeline is processed. +func ProcessApplicationSettings(applicationSettings map[string]string) (config ControllerBoardStatusAppSettings, err error) { + // Iterate over all of the fields of the config + reflectedValueOfConfig := reflect.ValueOf(config) + reflectedFieldsOfConfig := reflectedValueOfConfig.Type() + numberOfFieldsInStruct := reflectedValueOfConfig.NumField() + configValues := make([]interface{}, numberOfFieldsInStruct) + configFields := make([]string, numberOfFieldsInStruct) + configTypes := make([]reflect.Type, numberOfFieldsInStruct) + + configAsMap := make(map[string]interface{}) + + // For each field in the ControllerBoardStatusAppSettings struct, + // attempt to locate that corresponding field in the applicationSettings + // map + for i := 0; i < reflectedValueOfConfig.NumField(); i++ { + configValues[i] = reflectedValueOfConfig.Field(i).Interface() + configFields[i] = reflectedFieldsOfConfig.Field(i).Name + configTypes[i] = reflectedValueOfConfig.Field(i).Type() + + // Fetch the current field from the application settings map + applicationSettingsValue, ok := applicationSettings[configFields[i]] + if !ok { + return config, GetGenericError(configFields[i], configTypes[i]) + } + + // Parse the field according to the application settings map + if applicationSettingsValue != "" { + switch configValues[i].(type) { + case float64: + configAsMap[configFields[i]], err = strconv.ParseFloat(applicationSettingsValue, 64) + if err != nil { + return config, GetGenericParseError(configFields[i], applicationSettingsValue, configTypes[i]) + } + case string: + configAsMap[configFields[i]] = applicationSettingsValue + case []string: + configAsMap[configFields[i]] = strings.Split(applicationSettingsValue, ",") + case time.Duration: + configAsMap[configFields[i]], err = time.ParseDuration(applicationSettingsValue) + if err != nil { + return config, GetGenericParseError(configFields[i], applicationSettingsValue, configTypes[i]) + } + case int: + configAsMap[configFields[i]], err = strconv.Atoi(applicationSettingsValue) + if err != nil { + return config, GetGenericParseError(configFields[i], applicationSettingsValue, configTypes[i]) + } + default: + return config, GetGenericParseError(configFields[i], applicationSettingsValue, configTypes[i]) + } + } + } + + // Encode into JSON, then unmarshal into the + // ControllerBoardStatusAppSettings struct + configJSON, err := json.Marshal(configAsMap) + if err != nil { + return config, fmt.Errorf("Failed to convert the config map into a JSON byte slice: %v", err.Error()) + } + + // Unmarshal into the config struct + err = json.Unmarshal(configJSON, &config) + if err != nil { + return config, fmt.Errorf("Failed to unmarshal the config map JSON into the config struct: %v", err.Error()) + } + + return config, nil +} diff --git a/as-controller-board-status/functions/config_test.go b/as-controller-board-status/functions/config_test.go new file mode 100644 index 0000000..ee595b5 --- /dev/null +++ b/as-controller-board-status/functions/config_test.go @@ -0,0 +1,361 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package functions + +import ( + "fmt" + "reflect" + "testing" + "time" + + assert "github.com/stretchr/testify/assert" + require "github.com/stretchr/testify/require" +) + +// These constants are used to simplify code repetition when working with the +// config map/struct +const ( + AverageTemperatureMeasurementDuration = "AverageTemperatureMeasurementDuration" + DeviceName = "DeviceName" + MaxTemperatureThreshold = "MaxTemperatureThreshold" + MinTemperatureThreshold = "MinTemperatureThreshold" + MQTTEndpoint = "MQTTEndpoint" + NotificationCategory = "NotificationCategory" + NotificationEmailAddresses = "NotificationEmailAddresses" + NotificationHost = "NotificationHost" + NotificationLabels = "NotificationLabels" + NotificationReceiver = "NotificationReceiver" + NotificationSender = "NotificationSender" + NotificationSeverity = "NotificationSeverity" + NotificationSlug = "NotificationSlug" + NotificationSlugPrefix = "NotificationSlugPrefix" + NotificationSubscriptionMaxRESTRetries = "NotificationSubscriptionMaxRESTRetries" + NotificationSubscriptionRESTRetryInterval = "NotificationSubscriptionRESTRetryInterval" + NotificationThrottleDuration = "NotificationThrottleDuration" + RESTCommandTimeout = "RESTCommandTimeout" + SubscriptionHost = "SubscriptionHost" + VendingEndpoint = "VendingEndpoint" +) + +// GetCommonSuccessConfig is used in test cases to quickly build out +// an example of a successful ControllerBoardStatusAppSettings configuration +func GetCommonSuccessConfig() ControllerBoardStatusAppSettings { + return ControllerBoardStatusAppSettings{ + AverageTemperatureMeasurementDuration: -15 * time.Second, + DeviceName: "ds-controller-board", + MaxTemperatureThreshold: 83.0, + MinTemperatureThreshold: 10.0, + MQTTEndpoint: "http://localhost:48082/api/v1/device/name/Inference-MQTT-device/command/vendingDoorStatus", + NotificationCategory: "HW_HEALTH", + NotificationEmailAddresses: []string{"test@site.com", "test@site.com"}, + NotificationHost: "http://localhost:48060/api/v1/notification", + NotificationLabels: []string{"HW_HEALTH"}, + NotificationReceiver: "System Administrator", + NotificationSender: "Automated Checkout Maintenance Notification", + NotificationSeverity: "CRITICAL", + NotificationSlug: "sys-admin", + NotificationSlugPrefix: "maintenance-notification", + NotificationSubscriptionMaxRESTRetries: 10, + NotificationSubscriptionRESTRetryInterval: 10 * time.Second, + NotificationThrottleDuration: 1 * time.Minute, + RESTCommandTimeout: 15 * time.Second, + SubscriptionHost: "http://localhost:48060/api/v1/subscription", + VendingEndpoint: "http://localhost:48099/boardStatus", + } +} + +type testTableGetGenericErrorStruct struct { + TestCaseName string + Output string + InputConfKey string + InputConfItemType reflect.Type +} + +func prepGetGenericErrorTest() ([]testTableGetGenericErrorStruct, error) { + testTimeDuration, err := time.ParseDuration("1s") + if err != nil { + return []testTableGetGenericErrorStruct{}, fmt.Errorf("Failed to set up time duration test value: %v", err.Error()) + } + testTableGetGenericError := []testTableGetGenericErrorStruct{ + { + TestCaseName: "Time duration string input", + Output: fmt.Sprintf("The \"%v\" application setting has not been set. Please set this to an acceptable %v value in configuration.toml", "AverageTemperatureMeasurementDuration", "time.Duration"), + InputConfKey: "AverageTemperatureMeasurementDuration", + InputConfItemType: reflect.TypeOf(testTimeDuration), + }, + { + TestCaseName: "String slice input", + Output: fmt.Sprintf("The \"%v\" application setting has not been set. Please set this to an acceptable %v value in configuration.toml", "NotificationEmailAddresses", "[]string"), + InputConfKey: "NotificationEmailAddresses", + InputConfItemType: reflect.TypeOf([]string{}), + }, + { + TestCaseName: "Integer input", + Output: fmt.Sprintf("The \"%v\" application setting has not been set. Please set this to an acceptable %v value in configuration.toml", "NotificationSubscriptionMaxRESTRetries", "int"), + InputConfKey: "NotificationSubscriptionMaxRESTRetries", + InputConfItemType: reflect.TypeOf(10), + }, + } + return testTableGetGenericError, nil +} + +// TestGetGenericError validates that the GetGenericError function +// returns an error message with a particular format +func TestGetGenericError(t *testing.T) { + testTable := []testTableGetGenericErrorStruct{} + err := fmt.Errorf("") + t.Run("GetGenericError set up test", func(t *testing.T) { + testTable, err = prepGetGenericErrorTest() + require.NoError(t, err) + }) + // Test the function + for _, testCase := range testTable { + ct := testCase // pinning "current test" solves concurrency issues + t.Run(ct.TestCaseName, func(t *testing.T) { + output := GetGenericError(ct.InputConfKey, ct.InputConfItemType) + assert.EqualError(t, output, ct.Output) + }) + } +} + +type testTableGetGenericParseErrorStruct struct { + TestCaseName string + Output string + InputConfKey string + InputConfValue string + InputConfItemType reflect.Type +} + +func prepGetGenericParseErrorTest() ([]testTableGetGenericParseErrorStruct, error) { + testTimeDuration, err := time.ParseDuration("1s") + if err != nil { + return []testTableGetGenericParseErrorStruct{}, fmt.Errorf("Failed to set up time duration test value: %v", err.Error()) + } + testTableGetGenericParseError := []testTableGetGenericParseErrorStruct{ + { + TestCaseName: "Time duration input", + Output: fmt.Sprintf("The \"%v\" application setting been set, but failed to parse the value \"%v\". Please set this to an acceptable %v value in configuration.toml", "AverageTemperatureMeasurementDuration", "-15s", "time.Duration"), + InputConfKey: "AverageTemperatureMeasurementDuration", + InputConfValue: "-15s", + InputConfItemType: reflect.TypeOf(testTimeDuration), + }, + { + TestCaseName: "String slice input", + Output: fmt.Sprintf("The \"%v\" application setting been set, but failed to parse the value \"%v\". Please set this to an acceptable %v value in configuration.toml", "NotificationEmailAddresses", "test@site.com,test2@site.com", "[]string"), + InputConfKey: "NotificationEmailAddresses", + InputConfValue: "test@site.com,test2@site.com", + InputConfItemType: reflect.TypeOf([]string{}), + }, + { + TestCaseName: "Integer input", + Output: fmt.Sprintf("The \"%v\" application setting been set, but failed to parse the value \"%v\". Please set this to an acceptable %v value in configuration.toml", "NotificationSubscriptionMaxRESTRetries", "10", "int"), + InputConfKey: "NotificationSubscriptionMaxRESTRetries", + InputConfValue: "10", + InputConfItemType: reflect.TypeOf(10), + }, + } + return testTableGetGenericParseError, nil +} + +// TestGetGenericParseError validates that the GetGenericParseError function +// returns an error message with a particular format +func TestGetGenericParseError(t *testing.T) { + testTable := []testTableGetGenericParseErrorStruct{} + err := fmt.Errorf("") + t.Run("GetGenericParseError set up test", func(t *testing.T) { + testTable, err = prepGetGenericParseErrorTest() + require.NoError(t, err) + }) + // Test the function + for _, testCase := range testTable { + ct := testCase // pinning "current test" solves concurrency issues + t.Run(ct.TestCaseName, func(t *testing.T) { + output := GetGenericParseError(ct.InputConfKey, ct.InputConfValue, ct.InputConfItemType) + assert.EqualError(t, output, ct.Output) + }) + } +} + +type testTableProcessApplicationSettingsStruct struct { + TestCaseName string + Error error + Input map[string]string + Output ControllerBoardStatusAppSettings +} + +func prepProcessApplicationSettingsTest() []testTableProcessApplicationSettingsStruct { + return []testTableProcessApplicationSettingsStruct{ + { + TestCaseName: "Successful Test Case", + Error: nil, + Input: map[string]string{ + AverageTemperatureMeasurementDuration: "-15s", + DeviceName: "ds-controller-board", + MaxTemperatureThreshold: "83", + MinTemperatureThreshold: "10", + MQTTEndpoint: "http://localhost:48082/api/v1/device/name/Inference-MQTT-device/command/vendingDoorStatus", + NotificationCategory: "HW_HEALTH", + NotificationEmailAddresses: "test@site.com,test@site.com", + NotificationHost: "http://localhost:48060/api/v1/notification", + NotificationLabels: "HW_HEALTH", + NotificationReceiver: "System Administrator", + NotificationSender: "Automated Checkout Maintenance Notification", + NotificationSeverity: "CRITICAL", + NotificationSlug: "sys-admin", + NotificationSlugPrefix: "maintenance-notification", + NotificationSubscriptionMaxRESTRetries: "10", + NotificationSubscriptionRESTRetryInterval: "10s", + NotificationThrottleDuration: "1m", + RESTCommandTimeout: "15s", + SubscriptionHost: "http://localhost:48060/api/v1/subscription", + VendingEndpoint: "http://localhost:48099/boardStatus", + }, + Output: ControllerBoardStatusAppSettings{ + AverageTemperatureMeasurementDuration: -15 * time.Second, + DeviceName: "ds-controller-board", + MaxTemperatureThreshold: 83.0, + MinTemperatureThreshold: 10.0, + MQTTEndpoint: "http://localhost:48082/api/v1/device/name/Inference-MQTT-device/command/vendingDoorStatus", + NotificationCategory: "HW_HEALTH", + NotificationEmailAddresses: []string{"test@site.com", "test@site.com"}, + NotificationHost: "http://localhost:48060/api/v1/notification", + NotificationLabels: []string{"HW_HEALTH"}, + NotificationReceiver: "System Administrator", + NotificationSender: "Automated Checkout Maintenance Notification", + NotificationSeverity: "CRITICAL", + NotificationSlug: "sys-admin", + NotificationSlugPrefix: "maintenance-notification", + NotificationSubscriptionMaxRESTRetries: 10, + NotificationSubscriptionRESTRetryInterval: 10 * time.Second, + NotificationThrottleDuration: 1 * time.Minute, + RESTCommandTimeout: 15 * time.Second, + SubscriptionHost: "http://localhost:48060/api/v1/subscription", + VendingEndpoint: "http://localhost:48099/boardStatus", + }, + }, + { + TestCaseName: "Item Not Specified Case", + Error: GetGenericError("AverageTemperatureMeasurementDuration", reflect.TypeOf(1*time.Second)), + Input: map[string]string{ + // AverageTemperatureMeasurementDuration: "-15s", + DeviceName: "ds-controller-board", + MaxTemperatureThreshold: "83", + MinTemperatureThreshold: "10", + MQTTEndpoint: "http://localhost:48082/api/v1/device/name/Inference-MQTT-device/command/vendingDoorStatus", + NotificationCategory: "HW_HEALTH", + NotificationEmailAddresses: "test@site.com,test@site.com", + NotificationHost: "http://localhost:48060/api/v1/notification", + NotificationLabels: "HW_HEALTH", + NotificationReceiver: "System Administrator", + NotificationSender: "Automated Checkout Maintenance Notification", + NotificationSeverity: "CRITICAL", + NotificationSlug: "sys-admin", + NotificationSlugPrefix: "maintenance-notification", + NotificationSubscriptionMaxRESTRetries: "10", + NotificationSubscriptionRESTRetryInterval: "10s", + NotificationThrottleDuration: "1m", + RESTCommandTimeout: "15s", + SubscriptionHost: "http://localhost:48060/api/v1/subscription", + VendingEndpoint: "http://localhost:48099/boardStatus", + }, + Output: ControllerBoardStatusAppSettings{}, + }, + { + TestCaseName: "Invalid Time Duration Parse Case", + Error: GetGenericParseError("AverageTemperatureMeasurementDuration", "invalid time.ParseDuration string", reflect.TypeOf(1*time.Second)), + Input: map[string]string{ + AverageTemperatureMeasurementDuration: "invalid time.ParseDuration string", + DeviceName: "ds-controller-board", + MaxTemperatureThreshold: "83", + MinTemperatureThreshold: "10", + MQTTEndpoint: "http://localhost:48082/api/v1/device/name/Inference-MQTT-device/command/vendingDoorStatus", + NotificationCategory: "HW_HEALTH", + NotificationEmailAddresses: "test@site.com,test@site.com", + NotificationHost: "http://localhost:48060/api/v1/notification", + NotificationLabels: "HW_HEALTH", + NotificationReceiver: "System Administrator", + NotificationSender: "Automated Checkout Maintenance Notification", + NotificationSeverity: "CRITICAL", + NotificationSlug: "sys-admin", + NotificationSlugPrefix: "maintenance-notification", + NotificationSubscriptionMaxRESTRetries: "10", + NotificationSubscriptionRESTRetryInterval: "10s", + NotificationThrottleDuration: "1m", + RESTCommandTimeout: "15s", + SubscriptionHost: "http://localhost:48060/api/v1/subscription", + VendingEndpoint: "http://localhost:48099/boardStatus", + }, + Output: ControllerBoardStatusAppSettings{}, + }, + { + TestCaseName: "Invalid float64 Parse Case", + Error: GetGenericParseError("MaxTemperatureThreshold", "invalid float64 value", reflect.TypeOf(83.0)), + Input: map[string]string{ + AverageTemperatureMeasurementDuration: "-15s", + DeviceName: "ds-controller-board", + MaxTemperatureThreshold: "invalid float64 value", + MinTemperatureThreshold: "10", + MQTTEndpoint: "http://localhost:48082/api/v1/device/name/Inference-MQTT-device/command/vendingDoorStatus", + NotificationCategory: "HW_HEALTH", + NotificationEmailAddresses: "test@site.com,test@site.com", + NotificationHost: "http://localhost:48060/api/v1/notification", + NotificationLabels: "HW_HEALTH", + NotificationReceiver: "System Administrator", + NotificationSender: "Automated Checkout Maintenance Notification", + NotificationSeverity: "CRITICAL", + NotificationSlug: "sys-admin", + NotificationSlugPrefix: "maintenance-notification", + NotificationSubscriptionMaxRESTRetries: "10", + NotificationSubscriptionRESTRetryInterval: "10s", + NotificationThrottleDuration: "1m", + RESTCommandTimeout: "15s", + SubscriptionHost: "http://localhost:48060/api/v1/subscription", + VendingEndpoint: "http://localhost:48099/boardStatus", + }, + Output: ControllerBoardStatusAppSettings{}, + }, + { + TestCaseName: "Invalid int Parse Case", + Error: GetGenericParseError("NotificationSubscriptionMaxRESTRetries", "invalid int value", reflect.TypeOf(10)), + Input: map[string]string{ + AverageTemperatureMeasurementDuration: "-15s", + DeviceName: "ds-controller-board", + MaxTemperatureThreshold: "83", + MinTemperatureThreshold: "10", + MQTTEndpoint: "http://localhost:48082/api/v1/device/name/Inference-MQTT-device/command/vendingDoorStatus", + NotificationCategory: "HW_HEALTH", + NotificationEmailAddresses: "test@site.com,test@site.com", + NotificationHost: "http://localhost:48060/api/v1/notification", + NotificationLabels: "HW_HEALTH", + NotificationReceiver: "System Administrator", + NotificationSender: "Automated Checkout Maintenance Notification", + NotificationSeverity: "CRITICAL", + NotificationSlug: "sys-admin", + NotificationSlugPrefix: "maintenance-notification", + NotificationSubscriptionMaxRESTRetries: "invalid int value", + NotificationSubscriptionRESTRetryInterval: "10s", + NotificationThrottleDuration: "1m", + RESTCommandTimeout: "15s", + SubscriptionHost: "http://localhost:48060/api/v1/subscription", + VendingEndpoint: "http://localhost:48099/boardStatus", + }, + Output: ControllerBoardStatusAppSettings{}, + }, + } +} + +// TestProcessApplicationSettings validates that the ProcessApplicationSettings +// function converts a map from the EdgeX SDK into a +// ControllerBoardStatusAppSettings struct with properly parsed fields +func TestProcessApplicationSettings(t *testing.T) { + testTable := prepProcessApplicationSettingsTest() + for _, testCase := range testTable { + ct := testCase // pinning "current test" solves concurrency issues + t.Run("ProcessApplicationSettings test table", func(t *testing.T) { + output, err := ProcessApplicationSettings(testCase.Input) + assert.Equal(t, err, ct.Error) + assert.Equal(t, output, ct.Output) + }) + } +} diff --git a/as-controller-board-status/functions/models.go b/as-controller-board-status/functions/models.go new file mode 100644 index 0000000..6b2f730 --- /dev/null +++ b/as-controller-board-status/functions/models.go @@ -0,0 +1,49 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package functions + +import "time" + +// ControllerBoardStatus is used to hold the data that will be passed to +// the as-vending application service, and it is marshaled into JSON when +// someone hits the GetStatus API endpoint. +type ControllerBoardStatus struct { + Lock1 int `json:"lock1_status"` + Lock2 int `json:"lock2_status"` + DoorClosed bool `json:"door_closed"` // true means the door is closed and false means the door is open + Temperature float64 `json:"temperature"` + Humidity float64 `json:"humidity"` + MinTemperatureStatus bool `json:"minTemperatureStatus"` + MaxTemperatureStatus bool `json:"maxTemperatureStatus"` +} + +// TempMeasurement is a simple data structure that is meant to plug temperature +// measurements and their associated timestamps into the AvgTemp function. +type TempMeasurement struct { + Timestamp time.Time // used to store the time that this measurement came in + Measurement float64 // used to store the actual temperature measurement +} + +// CheckBoardStatus is the primary data state holder for this application service. +// It is similar to ControllerBoardStatus, but different in that it does not +// get passed around outside of this application service. It is used to assist +// with the delivery of ControllerBoardStatus to the as-vending service. +type CheckBoardStatus struct { + MinTemperatureThreshold float64 + MaxTemperatureThreshold float64 + MinHumidityThreshold float64 + MaxHumidityThreshold float64 + DoorClosed bool // true means the door is closed and false means the door is open + Measurements []TempMeasurement // used to store temperature readings over time. + LastNotified time.Time // used to store last time a notification was sent out so we don't spam the maintenance person +} + +// VendingDoorStatus is a string representation of a boolean whose state corresponds +// to the whether the doorClosed state is true or false. This data is sent +// to the MQTT device service for processing by the Automated Checkout inference +// algorithm, which will act if the door state flips from open (false) to +// closed (true). +type VendingDoorStatus struct { + VendingDoorStatus string `json:"inferenceDoorStatus"` // TODO: remove inference and rename to vendingDoorStatus +} diff --git a/as-controller-board-status/functions/notify.go b/as-controller-board-status/functions/notify.go new file mode 100644 index 0000000..594d9f4 --- /dev/null +++ b/as-controller-board-status/functions/notify.go @@ -0,0 +1,125 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package functions + +import ( + "bytes" + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "time" +) + +// buildSubscriptionMessage returns a map containing all of the fields required +// by EdgeX's notification service in order to send an email. +// For reference please visit: +// https://nexus.edgexfoundry.org/content/sites/docs/staging/master/docs/_build/html/support-notifications.html +func buildSubscriptionMessage(edgexconfig ControllerBoardStatusAppSettings) (result map[string]interface{}) { + // Build out the subscription message + result = map[string]interface{}{ + "slug": edgexconfig.NotificationSlug, + "receiver": edgexconfig.NotificationReceiver, + "subscribedCategories": []string{ + edgexconfig.NotificationCategory, + }, + "subscribedLabels": []string{ + edgexconfig.NotificationCategory, + }, + "channels": []map[string]interface{}{ + { + "type": "EMAIL", + "mailAddresses": edgexconfig.NotificationEmailAddresses, + }, + }, + } + + return result +} + +// PostSubscriptionToAPI attempts to perform an HTTP POST REST API call to the +// EdgeX notifications service. It will retry up to a specified number of times +// if there is an error. It considers the subscription successful if +// the API response is http.StatusCreated or http.StatusConflict. +func PostSubscriptionToAPI(edgexconfig ControllerBoardStatusAppSettings, subscriptionMessage map[string]interface{}) (err error) { + // Serialize the subscriptionMessage so that it can be sent as part of a + // REST request + subscriptionMessageBytes, err := json.Marshal(subscriptionMessage) + if err != nil { + return fmt.Errorf("Failed to serialize the subscription message: %v", err.Error()) + } + + var resp *http.Response + + // Try no more than maxRetries times to post to the EdgeX notification service API. + for i := 0; i < edgexconfig.NotificationSubscriptionMaxRESTRetries; i++ { + resp, err = http.Post(edgexconfig.SubscriptionHost, ApplicationJSONContentType, bytes.NewBuffer(subscriptionMessageBytes)) + if err != nil { + return fmt.Errorf("Failed to submit REST request to subscription API endpoint: %v", err.Error()) + } + defer resp.Body.Close() + + // if the response has succeeded, it's either StatusCreated or StatusConflict + isResponseSuccessful := (resp.StatusCode == http.StatusCreated || resp.StatusCode == http.StatusConflict) + if isResponseSuccessful { + return nil + } + + // Wait before doing another REST call + time.Sleep(edgexconfig.NotificationSubscriptionRESTRetryInterval) + } + + // Read the response body so we can return the API response info + // to the end user. We don't really care about error checking at this point, + // since we're going to throw an error next anyway. + respBody, _ := ioutil.ReadAll(resp.Body) + + return fmt.Errorf("REST request to subscribe to the notification service failed after %v attempts. The last API response returned a %v status code, and the response body was: %v", edgexconfig.NotificationSubscriptionMaxRESTRetries, resp.StatusCode, string(respBody)) +} + +// SubscribeToNotificationService configures an email notification and submits +// it to the EdgeX notification service +func SubscribeToNotificationService(edgexconfig ControllerBoardStatusAppSettings) error { + // Build out the subscription message based on the validated app settings + subscriptionMessage := buildSubscriptionMessage(edgexconfig) + + // Try to make the API call a few times until it works. + err := PostSubscriptionToAPI(edgexconfig, subscriptionMessage) + + if err != nil { + return fmt.Errorf("Failed to subscribe to the EdgeX notification service due to an error thrown while performing the HTTP POST subscription to the notification service: %v", err.Error()) + } + + return nil +} + +// SendNotification performs a REST API call to the EdgeX notification service +// that will trigger the service to send a notification. +func SendNotification(edgexconfig ControllerBoardStatusAppSettings, message interface{}) error { + notificationMessage := map[string]interface{}{ + "slug": edgexconfig.NotificationSlugPrefix + time.Now().String(), + "sender": edgexconfig.NotificationSender, + "category": edgexconfig.NotificationCategory, + "severity": edgexconfig.NotificationSeverity, + "content": message, + "labels": edgexconfig.NotificationLabels, + } + + notificationMessageBytes, err := json.Marshal(notificationMessage) + if err != nil { + return fmt.Errorf("Failed to marshal the notification message into a JSON byte array: %v", err.Error()) + } + + resp, err := http.Post(edgexconfig.NotificationHost, ApplicationJSONContentType, bytes.NewBuffer(notificationMessageBytes)) + if err != nil { + return fmt.Errorf("Failed to perform REST POST API call to send a notification to \"%v\", error: %v", edgexconfig.NotificationHost, err.Error()) + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusAccepted { + return fmt.Errorf("The REST API HTTP status code response from the server when attempting to send a notification was not %v, instead got: %v", http.StatusAccepted, resp.StatusCode) + } + + return nil +} diff --git a/as-controller-board-status/functions/notify_test.go b/as-controller-board-status/functions/notify_test.go new file mode 100644 index 0000000..b016225 --- /dev/null +++ b/as-controller-board-status/functions/notify_test.go @@ -0,0 +1,240 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package functions + +import ( + "fmt" + "net/http" + "net/http/httptest" + "testing" + + assert "github.com/stretchr/testify/assert" +) + +type testTableBuildSubscriptionMessageStruct struct { + TestCaseName string + Config ControllerBoardStatusAppSettings + Output map[string]interface{} +} + +func prepBuildSubscriptionMessage() []testTableBuildSubscriptionMessageStruct { + commonSuccessConfig := GetCommonSuccessConfig() + return []testTableBuildSubscriptionMessageStruct{ + { + TestCaseName: "Success", + Config: commonSuccessConfig, + Output: map[string]interface{}{ + "slug": commonSuccessConfig.NotificationSlug, + "receiver": commonSuccessConfig.NotificationReceiver, + "subscribedCategories": []string{ + commonSuccessConfig.NotificationCategory, + }, + "subscribedLabels": []string{ + commonSuccessConfig.NotificationCategory, + }, + "channels": []map[string]interface{}{ + { + "type": "EMAIL", + "mailAddresses": commonSuccessConfig.NotificationEmailAddresses, + }, + }, + }, + }, + } +} + +// TestBuildSubscriptionMessage validates that the BuildSubscriptionMessage function +// returns a subscription message in the proper format +func TestBuildSubscriptionMessage(t *testing.T) { + testTable := prepBuildSubscriptionMessage() + for _, testCase := range testTable { + ct := testCase // pinning solves concurrency issues + t.Run(ct.TestCaseName, func(t *testing.T) { + output := buildSubscriptionMessage(testCase.Config) + assert.Equal(t, output, ct.Output, "Expected output to match") + }) + } +} + +type testTablePostSubscriptionToAPIStruct struct { + TestCaseName string + Config ControllerBoardStatusAppSettings + SubscriptionMessage map[string]interface{} + Output error + HTTPTestServer *httptest.Server +} + +func prepPostSubscriptionToAPITest() ([]testTablePostSubscriptionToAPIStruct, []*httptest.Server) { + output := []testTablePostSubscriptionToAPIStruct{} + + // This server returns 200 OK + testServerStatusOK := GetHTTPTestServer(http.StatusOK, "") + + // This server throws HTTP 500 as part of a non-error response + testServer500 := GetHTTPTestServer(http.StatusInternalServerError, "test response body") + + // This server throws HTTP status conflict as part of a non-error response + testServerConflict := GetHTTPTestServer(http.StatusConflict, "") + + // This server throws HTTP status created as part of a non-error response + testServerCreated := GetHTTPTestServer(http.StatusConflict, "") + + // This server throws errors when it receives a connection + testServerThrowError := GetErrorHTTPTestServer() + + // Assemble a typical set of configs + edgexconfig := GetCommonSuccessConfig() + edgexconfigCreatedServer := GetCommonSuccessConfig() + edgexconfigConflictServer := GetCommonSuccessConfig() + edgexconfigThrowErrorServer := GetCommonSuccessConfig() + edgexconfigConflictServer.SubscriptionHost = testServerConflict.URL + edgexconfigCreatedServer.SubscriptionHost = testServerCreated.URL + edgexconfigThrowErrorServer.SubscriptionHost = testServerThrowError.URL + + // Assemble a configuration that doesn't want to try very many times at all + edgexconfigImpatient := GetCommonSuccessConfig() + edgexconfigImpatient.NotificationSubscriptionMaxRESTRetries = 2 + edgexconfigImpatient.NotificationSubscriptionRESTRetryInterval = 1 + edgexconfigImpatient.SubscriptionHost = testServer500.URL + + // Assemble a common subscription message + commonSubscriptionMessage := buildSubscriptionMessage(edgexconfig) + + output = append(output, + testTablePostSubscriptionToAPIStruct{ + TestCaseName: "Success Created", + Config: edgexconfigCreatedServer, + SubscriptionMessage: commonSubscriptionMessage, + Output: nil, + HTTPTestServer: testServerCreated, + }, + testTablePostSubscriptionToAPIStruct{ + TestCaseName: "Success Conflict", + Config: edgexconfigConflictServer, + SubscriptionMessage: commonSubscriptionMessage, + Output: nil, + HTTPTestServer: testServerConflict, + }, + testTablePostSubscriptionToAPIStruct{ + TestCaseName: "Unsuccessful due to HTTP connection closed error", + Config: edgexconfigThrowErrorServer, + SubscriptionMessage: commonSubscriptionMessage, + Output: fmt.Errorf("Failed to submit REST request to subscription API endpoint: %v %v: %v", "Post", testServerThrowError.URL, "EOF"), + HTTPTestServer: testServerThrowError, + }, + testTablePostSubscriptionToAPIStruct{ + TestCaseName: "Unsuccessful due to unserializable input interface", + Config: edgexconfig, + SubscriptionMessage: map[string]interface{}{ + "test": make(chan bool), + }, + Output: fmt.Errorf("Failed to serialize the subscription message: %v", "json: unsupported type: chan bool"), + HTTPTestServer: testServerStatusOK, + }, + testTablePostSubscriptionToAPIStruct{ + TestCaseName: "Unsuccessful due to always receiving 500", + Config: edgexconfigImpatient, + SubscriptionMessage: commonSubscriptionMessage, + Output: fmt.Errorf("REST request to subscribe to the notification service failed after %v attempts. The last API response returned a %v status code, and the response body was: %v", edgexconfigImpatient.NotificationSubscriptionMaxRESTRetries, 500, "test response body"), + HTTPTestServer: testServer500, + }, + ) + + return output, []*httptest.Server{ + testServer500, + testServerConflict, + testServerCreated, + testServerStatusOK, + testServerThrowError, + } +} + +// TestPostSubscriptionToAPI validates that the PostSubscriptionToAPI function +// properly handles all error and success scenarios +func TestPostSubscriptionToAPI(t *testing.T) { + testTable, testServers := prepPostSubscriptionToAPITest() + // We are responsible for closing the test servers + for _, testServer := range testServers { + defer testServer.Close() + } + for _, testCase := range testTable { + ct := testCase // pinning solves concurrency issues + t.Run(ct.TestCaseName, func(t *testing.T) { + err := PostSubscriptionToAPI(ct.Config, ct.SubscriptionMessage) + assert.Equal(t, err, ct.Output, "Expected output to match") + }) + } +} + +type testTableSubscribeToNotificationServiceStruct struct { + TestCaseName string + Config ControllerBoardStatusAppSettings + Output error + HTTPTestServer *httptest.Server +} + +func prepSubscribeToNotificationServiceTest() ([]testTableSubscribeToNotificationServiceStruct, []*httptest.Server) { + output := []testTableSubscribeToNotificationServiceStruct{} + + // This server throws errors when it receives a connection + testServerThrowError := GetErrorHTTPTestServer() + + // This server throws HTTP status created as part of a non-error response + testServerCreated := GetHTTPTestServer(http.StatusConflict, "") + + // Assemble a typical set of configs + edgexconfigCreatedServer := GetCommonSuccessConfig() + edgexconfigThrowErrorServer := GetCommonSuccessConfig() + + edgexconfigCreatedServer.SubscriptionHost = testServerCreated.URL + edgexconfigThrowErrorServer.SubscriptionHost = testServerThrowError.URL + + output = append(output, + testTableSubscribeToNotificationServiceStruct{ + TestCaseName: "Success", + Config: edgexconfigCreatedServer, + Output: nil, + HTTPTestServer: testServerCreated, + }, + testTableSubscribeToNotificationServiceStruct{ + TestCaseName: "Failure", + Config: edgexconfigThrowErrorServer, + Output: fmt.Errorf("Failed to subscribe to the EdgeX notification service due to an error thrown while performing the HTTP POST subscription to the notification service: Failed to submit REST request to subscription API endpoint: %v %v: %v", "Post", testServerThrowError.URL, "EOF"), + HTTPTestServer: testServerThrowError, + }, + ) + + return output, []*httptest.Server{ + testServerThrowError, + testServerCreated, + } +} + +// TestSubscribeToNotificationService validates that the +// SubscribeToNotificationService function handles its success/failure cases +// as expected +func TestSubscribeToNotificationService(t *testing.T) { + testTable, testServers := prepSubscribeToNotificationServiceTest() + // We are responsible for closing the test servers + for _, testServer := range testServers { + defer testServer.Close() + } + + for _, testCase := range testTable { + ct := testCase // pinning solves concurrency issues + t.Run(ct.TestCaseName, func(t *testing.T) { + err := SubscribeToNotificationService(testCase.Config) + assert.Equal(t, err, ct.Output, "Expected error to match output") + }) + } +} + +// TestSendNotification validates that the edge cases that aren't handled +// elsewhere are covered +func TestSendNotification(t *testing.T) { + edgexconfig := GetCommonSuccessConfig() + err := SendNotification(edgexconfig, make(chan bool)) + + assert.EqualError(t, err, "Failed to marshal the notification message into a JSON byte array: json: unsupported type: chan bool") +} diff --git a/as-controller-board-status/functions/output.go b/as-controller-board-status/functions/output.go new file mode 100644 index 0000000..5cbc5f2 --- /dev/null +++ b/as-controller-board-status/functions/output.go @@ -0,0 +1,280 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package functions + +import ( + "encoding/json" + "fmt" + "net/http" + "sort" + "strconv" + "time" + + "github.com/edgexfoundry/app-functions-sdk-go/appcontext" + "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/models" + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +var controllerBoardStatus = ControllerBoardStatus{} + +const ( + minimum = "minimum" + maximum = "maximum" + // ControllerBoardDeviceServiceDeviceName is the name of the EdgeX device + // corresponding to our upstream event source. + ControllerBoardDeviceServiceDeviceName = "ds-controller-board" +) + +// CheckControllerBoardStatus is an EdgeX function that is passed into the EdgeX SDK's function pipeline. +// It is a decision function that allows for multiple devices to have their events processed +// correctly by this application service. In this case, only one unique type of EdgeX device will come +// through to this function, but in general this is basically a template function that is also followed +// in other services in the Automated Checkout project. +func (boardStatus *CheckBoardStatus) CheckControllerBoardStatus(edgexcontext *appcontext.Context, params ...interface{}) (bool, interface{}) { + if len(params) < 1 { + // We didn't receive a result + return false, nil + } + + // Declare shorthand for the LoggingClient + lc := edgexcontext.LoggingClient + + event := params[0].(models.Event) + + // Process the EdgeX configuration + edgexconfig, err := ProcessApplicationSettings(edgexcontext.Configuration.ApplicationSettings) + if err != nil { + lc.Error(fmt.Sprintf("Failed to load the EdgeX application settings configuration. Please make sure that the values in configuration.toml are set correctly. The error is: \"%v\", and the event is: %v", err.Error(), event)) + return false, nil + } + + if event.Device == ControllerBoardDeviceServiceDeviceName { + for _, eventReading := range event.Readings { + lc.Debug(fmt.Sprintf("Received event reading value: %v", eventReading.Value)) + + // Unmarshal the event reading data into the global controllerBoardStatus variable + err := json.Unmarshal([]byte(eventReading.Value), &controllerBoardStatus) + if err != nil { + lc.Error(fmt.Sprintf("Failed to unmarshal controller board data, the event data is: %v", eventReading)) + return false, nil + } + + // Check if the temperature thresholds have been exceeded + err = boardStatus.processTemperature(lc, edgexconfig, controllerBoardStatus.Temperature) + if err != nil { + lc.Error(fmt.Sprintf("Encountered error while checking temperature thresholds: %v", err.Error())) + } + + // Check if the door open/closed state requires action + err = boardStatus.processVendingDoorState(lc, edgexconfig, controllerBoardStatus.DoorClosed) + if err != nil { + lc.Error(fmt.Sprintf("Encountered error while checking the open/closed state of the door: %v", err.Error())) + } + } + } + + return true, event // Continues the functions pipeline execution with the current event +} + +// processTemperatureMeasurements takes a single temperature measurement (which +// presumably is coming straight from an EdgeX reading) and adds it to the +// boardStatus.Measurements slice +func (boardStatus *CheckBoardStatus) processTemperatureMeasurements(edgexconfig ControllerBoardStatusAppSettings, temperature float64) float64 { + // Start by storing the latest data from the controller board as a + // temperature & time measurement + newMeasurement := TempMeasurement{ + Timestamp: time.Now(), + Measurement: temperature, + } + + // Update the list of measurements to include the new measurement from + // EdgeX + boardStatus.Measurements = append(boardStatus.Measurements, newMeasurement) + + avgTemp, cutIndex := AvgTemp(edgexconfig, boardStatus.Measurements) + + // Only keep track of the measurements used to calculate the latest average + // temperature + boardStatus.Measurements = boardStatus.Measurements[:cutIndex] + + return avgTemp +} + +func (controllerBoardStatus *ControllerBoardStatus) updateThresholdsFromAverageTemperature(edgexconfig ControllerBoardStatusAppSettings, avgTemp float64) { + // If the average temperature over the last X duration exceeds + // the maximum threshold temperature as configured in the application + // settings, switch the state accordingly + if avgTemp >= edgexconfig.MaxTemperatureThreshold { + controllerBoardStatus.MaxTemperatureStatus = true + } else { + controllerBoardStatus.MaxTemperatureStatus = false + } + + // Similarly, switch the state accordingly if the minimum threshold + // as defined in the settings is greater than the average temperature + if avgTemp <= edgexconfig.MinTemperatureThreshold { + controllerBoardStatus.MinTemperatureStatus = true + } else { + controllerBoardStatus.MinTemperatureStatus = false + } +} + +// getTempThresholdExceededMessage builds out a "max/min temperature threshold +// exceeded" message string and returns it +func getTempThresholdExceededMessage(minOrMax string, avgTemp float64, tempThreshold float64) (string, error) { + if minOrMax != maximum && minOrMax != minimum { + return "", fmt.Errorf("Please specify minOrMax as \"%v\" or \"%v\", the value given was \"%v\"", maximum, minimum, minOrMax) + } + resultMessage := fmt.Sprintf("The internal automated checkout's temperature is currently %.2f, and this temperature exceeds the configured %v temperature threshold of %v degrees. The automated checkout needs maintenance as of: %s", avgTemp, minOrMax, tempThreshold, time.Now().Format("_2 Jan, Mon | 3:04PM MST")) + return resultMessage, nil +} + +// sendTempThresholdExceededNotification leverages the SendNotification +// function to submit an EdgeX REST call to send a notification to a user. +// It does not check if a notification needs to be sent, it simply sends it +func (boardStatus *CheckBoardStatus) sendTempThresholdExceededNotification(edgexconfig ControllerBoardStatusAppSettings, message interface{}) error { + err := SendNotification(edgexconfig, message) + if err != nil { + return fmt.Errorf("Encountered error sending notification for exceeding temperature threshold: %v", err.Error()) + } + boardStatus.LastNotified = time.Now() + return nil +} + +// sendTempThresholdExceededNotifications reviews the state of +// controllerBoardStatus and sends notifications accordingly +func (boardStatus *CheckBoardStatus) sendTempThresholdExceededNotifications(edgexconfig ControllerBoardStatusAppSettings, avgTemp float64) error { + // For efficient coding, build out a simple map that contains keys + // only if there is a message that needs to be sent when the + // min/max thresholds are exceeded, then loop over that map + messages := make(map[string]float64) + if controllerBoardStatus.MaxTemperatureStatus { + messages[maximum] = edgexconfig.MaxTemperatureThreshold + } + if controllerBoardStatus.MinTemperatureStatus { + messages[minimum] = edgexconfig.MinTemperatureThreshold + } + for minMaxStr, tempThresholdValueFloat := range messages { + // Build the message out + tempThresholdMessage, err := getTempThresholdExceededMessage(minMaxStr, avgTemp, tempThresholdValueFloat) + if err != nil { + return fmt.Errorf("Encountered error building out the %v temperature threshold message: %v", minMaxStr, err.Error()) + } + // Send the notification + err = boardStatus.sendTempThresholdExceededNotification(edgexconfig, tempThresholdMessage) + if err != nil { + return fmt.Errorf("Encountered error sending the %v temperature threshold message: %v", minMaxStr, err.Error()) + } + } + return nil +} + +// processTemperature checks to see if we've exceeded any temperature thresholds +// and submits EdgeX REST commands accordingly +func (boardStatus *CheckBoardStatus) processTemperature(lc logger.LoggingClient, edgexconfig ControllerBoardStatusAppSettings, temperature float64) error { + avgTemp := boardStatus.processTemperatureMeasurements(edgexconfig, temperature) + + // Update the min/max temperature status readout for the global controller + // board status according to the how the average temperature compares to + // the configured min/max temperature threshold values + controllerBoardStatus.updateThresholdsFromAverageTemperature(edgexconfig, avgTemp) + + // Take note of whether or not we've sent a notification within a duration + // not allowable by the user's configuration + notificationSentRecently := (edgexconfig.NotificationThrottleDuration > time.Since(boardStatus.LastNotified)) + + // Send a notification if the temperature has exceeded thresholds, + // and if we have not sent a notification recently + if !notificationSentRecently { + err := boardStatus.sendTempThresholdExceededNotifications(edgexconfig, avgTemp) + if err != nil { + return fmt.Errorf("Failed to send temperature threshold exceeded notification(s) due to error: %v", err.Error()) + } + } + + // If either the minimum or maximum temperature thresholds have been + // exceeded, send the current state to the central service so it can + // react accordingly + if controllerBoardStatus.MinTemperatureStatus || controllerBoardStatus.MaxTemperatureStatus { + lc.Info("Pushing controller board status to central vending service due to a temperature threshold being exceeded") + err := edgexconfig.RESTCommandJSON(edgexconfig.VendingEndpoint, RESTPost, controllerBoardStatus) + if err != nil { + return fmt.Errorf("Encountered error sending the controller board's status to the central vending endpoint: %v", err.Error()) + } + } + return nil +} + +// AvgTemp takes a slice of temperature measurements and returns a proper +// average value of the values in the slice. +func AvgTemp(edgexconfig ControllerBoardStatusAppSettings, measurements []TempMeasurement) (float64, int) { + var z int = 0 + var mCount float64 + var tempSum, avgTemp float64 = 0.00, 0.00 + + // Sort the slice so that correct number of measurements can be averaged + sort.Slice(measurements, func(x, y int) bool { + return measurements[x].Timestamp.After(measurements[y].Timestamp) + }) + + for z < len(measurements) { + if measurements[z].Timestamp.Before(measurements[0].Timestamp.Add(edgexconfig.AverageTemperatureMeasurementDuration)) { + mCount = float64(z) + avgTemp = tempSum / mCount + break + } + tempSum = tempSum + measurements[z].Measurement + avgTemp = (tempSum) / float64(z+1) + z = z + 1 + } + return avgTemp, z +} + +// processVendingDoorState checks to see if the vending door state has changed +// and if it has changed, it will then submit EdgeX commands (REST calls) +// to the MQTT device service and the central vending state endpoint. +func (boardStatus *CheckBoardStatus) processVendingDoorState(lc logger.LoggingClient, edgexconfig ControllerBoardStatusAppSettings, doorClosed bool) error { + if boardStatus.DoorClosed != doorClosed { + // Set the boardStatus's DoorClosed value to the new value + boardStatus.DoorClosed = doorClosed + lc.Info(fmt.Sprintf("The door closed status has changed to: %v", doorClosed)) + + // Set the door closed state and make sure MinTemp and MaxTemp status + // are false to avoid triggering a false temperature event + err := edgexconfig.RESTCommandJSON(edgexconfig.VendingEndpoint, RESTPost, ControllerBoardStatus{ + DoorClosed: doorClosed, + MinTemperatureStatus: false, + MaxTemperatureStatus: false, + }) + if err != nil { + return fmt.Errorf("Failed to submit the controller board's status to the central vending state service: %v", err.Error()) + } + + // Prepare a message to be sent to the MQTT bus. Depending on the state + // of the door, this message may trigger a CV inference + err = edgexconfig.RESTCommandJSON(edgexconfig.MQTTEndpoint, RESTPut, VendingDoorStatus{ + VendingDoorStatus: strconv.FormatBool(doorClosed), + }) + if err != nil { + return fmt.Errorf("Failed to submit the vending door state to the MQTT device service: %v", err.Error()) + } + } + + return nil +} + +// GetStatus is a REST API endpoint that enables a web UI or some other downstream +// service to inquire about the status of the upstream Automated Checkout hardware interface(s). +func GetStatus(writer http.ResponseWriter, req *http.Request) { + utilities.ProcessCORS(writer, req, func(writer http.ResponseWriter, req *http.Request) { + controllerBoardStatusJSON, err := utilities.GetAsJSON(controllerBoardStatus) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to serialize the controller board's current state.", true) + return + } + + utilities.WriteJSONHTTPResponse(writer, req, http.StatusOK, controllerBoardStatusJSON, false) + }) +} diff --git a/as-controller-board-status/functions/output_test.go b/as-controller-board-status/functions/output_test.go new file mode 100644 index 0000000..477382d --- /dev/null +++ b/as-controller-board-status/functions/output_test.go @@ -0,0 +1,554 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package functions + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "net/http/httptest" + "os" + "testing" + "time" + + "github.com/edgexfoundry/app-functions-sdk-go/appcontext" + "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/models" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +var now = time.Now() + +type testGetStatusStruct struct { + TestCaseName string + ControllerBoardStatus ControllerBoardStatus + OutputHTTPResponse utilities.HTTPResponse + RESTMethod string + RESTURL string +} + +func prepGetStatusTest() ([]testGetStatusStruct, error) { + testControllerBoardStatus := ControllerBoardStatus{} + controllerBoardStatusJSON, err := utilities.GetAsJSON(testControllerBoardStatus) + if err != nil { + return []testGetStatusStruct{}, err + } + return []testGetStatusStruct{ + { + TestCaseName: "Success", + ControllerBoardStatus: testControllerBoardStatus, + OutputHTTPResponse: utilities.HTTPResponse{ + Content: controllerBoardStatusJSON, + ContentType: "json", + StatusCode: 200, + Error: false, + }, + RESTMethod: "GET", + RESTURL: "/status", + }, + }, nil +} + +// TestGetStatus validates that the GetStatus function +// properly handles all error and success scenarios +func TestGetStatus(t *testing.T) { + testTable := []testGetStatusStruct{} + err := fmt.Errorf("") + t.Run("GetStatus test setup", func(t *testing.T) { + assert := assert.New(t) + testTable, err = prepGetStatusTest() + + assert.NoError(err, "Failed to set up test") + }) + for _, testCase := range testTable { + ct := testCase // pinning to avoid concurrency issues + t.Run(ct.TestCaseName, func(t *testing.T) { + assert := assert.New(t) + + req := httptest.NewRequest(ct.RESTMethod, ct.RESTURL, nil) + w := httptest.NewRecorder() + GetStatus(w, req) + resp := w.Result() + defer resp.Body.Close() + + body, err := ioutil.ReadAll(resp.Body) + assert.NoError(err, "Failed to read response body") + + // Prepare to unmarshal the response body into the helpers struct + responseContent := utilities.HTTPResponse{} + err = json.Unmarshal(body, &responseContent) + + assert.NoError(err, "Failed to unmarshal response body into HTTPResponse struct") + assert.Equal(ct.OutputHTTPResponse, responseContent) + }) + } +} + +func getCommonApplicationSettings() map[string]string { + return map[string]string{ + AverageTemperatureMeasurementDuration: "-15s", + DeviceName: "ds-controller-board", + MaxTemperatureThreshold: temp51s, + MinTemperatureThreshold: temp49s, + MQTTEndpoint: "http://localhost:48082/api/v1/device/name/Inference-MQTT-device/command/vendingDoorStatus", + NotificationCategory: "HW_HEALTH", + NotificationEmailAddresses: "test@site.com,test@site.com", + NotificationHost: "http://localhost:48060/api/v1/notification", + NotificationLabels: "HW_HEALTH", + NotificationReceiver: "System Administrator", + NotificationSender: "Automated Checkout Maintenance Notification", + NotificationSeverity: "CRITICAL", + NotificationSlug: "sys-admin", + NotificationSlugPrefix: "maintenance-notification", + NotificationSubscriptionMaxRESTRetries: "10", + NotificationSubscriptionRESTRetryInterval: "10s", + NotificationThrottleDuration: "1m", + RESTCommandTimeout: "15s", + SubscriptionHost: "http://localhost:48060/api/v1/subscription", + VendingEndpoint: "http://localhost:48099/boardStatus", + } +} + +type testTableCheckControllerBoardStatusStruct struct { + TestCaseName string + InputEdgexContext *appcontext.Context + InputParams []interface{} + InputCheckBoardStatus CheckBoardStatus + OutputCheckBoardStatus CheckBoardStatus + OutputBool bool + OutputInterface interface{} + OutputLogs string + ShouldLastNotifiedBeDifferent bool + ExpectedTemperatureMeasurementSliceLength int + HTTPTestServer *httptest.Server +} + +const ( + checkControllerBoardStatusLogFileName = "./test_CheckControllerBoardStatus.log" + temp49 = 49.0 + temp50 = 50.0 + temp51 = 51.0 + temp52 = 52.0 + temp49s = "49.0" + // temp50s = "50.0" + temp51s = "51.0" + // temp52s = "52.0" +) + +// The CheckControllerBoardStatus function is the main entrypoint from EdgeX +// into this entire application service. It effectively calls every function +// written, so we can rely on this prepTest function to have curated +// success/error conditions that not only satisfy all of the test cases +// for the CheckControllerBoardStatus function itself, but also +// functions nested deep inside the flow of the function, if possible. +// +// Top-level cases: +// Success case requires: +// - http server that returns 200 for edgexconfig MQTTEndpoint,VendingEndpoint +// - http server that returns Accepted edgexconfig NotificationHost +// +// Error conditions: +// x len(params) == 0 +// x failure to run ProcessApplicationSettings due to missing config option +// x failure to unmarshal ControllerBoardStatus from event reading +// x failure to call processTemperature, which can be created by sending a +// status other than "Accepted" via the NotificationHost +// x failure to call processVendingDoorState, which can be created by +// sending a status other than status OK to the MQTTEndpoint +// +// = 6 test cases total, 3 httptest servers +// +// Nested functions will require more curation: +// x minimum temperature threshold exceeded +// x VendingEndpoint not responding with 200 OK on door close status changes +// x NotificationHost endpoint responding (without error) with non-Accepted +// +// = 11 test cases total +func prepCheckControllerBoardStatusTest() ([]testTableCheckControllerBoardStatusStruct, []*httptest.Server) { + // This server returns 200 OK when hit with a request + testServerStatusOK := GetHTTPTestServer(http.StatusOK, "") + + // This server throws HTTP status accepted as part of a non-error response + testServerAccepted := GetHTTPTestServer(http.StatusAccepted, "") + + // This server throws HTTP status 500 as part of a non-error response + testServer500 := GetHTTPTestServer(http.StatusInternalServerError, "") + + // This server throws errors when it receives a connection + testServerThrowError := GetErrorHTTPTestServer() + + // Set up a generic EdgeX logger + lc := logger.NewClient("output_test", false, checkControllerBoardStatusLogFileName, "DEBUG") + + // The success condition is ideal, and is configured to use URL's that all + // respond with responses that correspond to successful scenarios. + edgexcontextSuccess := &appcontext.Context{ + LoggingClient: lc, + } + edgexcontextSuccess.Configuration.ApplicationSettings = getCommonApplicationSettings() + edgexcontextSuccess.Configuration.ApplicationSettings[MQTTEndpoint] = testServerStatusOK.URL + edgexcontextSuccess.Configuration.ApplicationSettings[VendingEndpoint] = testServerStatusOK.URL + edgexcontextSuccess.Configuration.ApplicationSettings[NotificationHost] = testServerAccepted.URL + edgexcontextSuccess.Configuration.ApplicationSettings[MinTemperatureThreshold] = temp51s + edgexcontextSuccess.Configuration.ApplicationSettings[MaxTemperatureThreshold] = temp49s + + // Create the condition of exceeding the minimum temperature threshold, + // and make everything else successful. Additionally, use a controller + // board state that has more measurements than the cutoff + edgexcontextSuccessMinThresholdExceeded := &appcontext.Context{ + LoggingClient: lc, + } + edgexcontextSuccessMinThresholdExceeded.Configuration.ApplicationSettings = getCommonApplicationSettings() + edgexcontextSuccessMinThresholdExceeded.Configuration.ApplicationSettings[MQTTEndpoint] = testServerStatusOK.URL + edgexcontextSuccessMinThresholdExceeded.Configuration.ApplicationSettings[VendingEndpoint] = testServerStatusOK.URL + edgexcontextSuccessMinThresholdExceeded.Configuration.ApplicationSettings[NotificationHost] = testServerAccepted.URL + edgexcontextSuccessMinThresholdExceeded.Configuration.ApplicationSettings[MinTemperatureThreshold] = temp51s + + // Create the condition of exceeding the maximum temperature threshold, + // and make the VendingEndpoint throw an error. + edgexcontextBadVendingEndpointMaxThresholdExceeded := &appcontext.Context{ + LoggingClient: lc, + } + edgexcontextBadVendingEndpointMaxThresholdExceeded.Configuration.ApplicationSettings = getCommonApplicationSettings() + edgexcontextBadVendingEndpointMaxThresholdExceeded.Configuration.ApplicationSettings[MQTTEndpoint] = testServerStatusOK.URL + edgexcontextBadVendingEndpointMaxThresholdExceeded.Configuration.ApplicationSettings[VendingEndpoint] = testServerThrowError.URL + edgexcontextBadVendingEndpointMaxThresholdExceeded.Configuration.ApplicationSettings[NotificationHost] = testServerAccepted.URL + edgexcontextBadVendingEndpointMaxThresholdExceeded.Configuration.ApplicationSettings[MaxTemperatureThreshold] = temp49s + + // Create the condition of exceeding the maximum temperature threshold, + // and make the NotificationHost endpoint throw something other than what + // we want. We want Accepted, but we're going to get 500 + edgexcontextUnacceptingNotificationHostMaxThresholdExceeded := &appcontext.Context{ + LoggingClient: lc, + } + edgexcontextUnacceptingNotificationHostMaxThresholdExceeded.Configuration.ApplicationSettings = getCommonApplicationSettings() + edgexcontextUnacceptingNotificationHostMaxThresholdExceeded.Configuration.ApplicationSettings[MQTTEndpoint] = testServerStatusOK.URL + edgexcontextUnacceptingNotificationHostMaxThresholdExceeded.Configuration.ApplicationSettings[VendingEndpoint] = testServerStatusOK.URL + edgexcontextUnacceptingNotificationHostMaxThresholdExceeded.Configuration.ApplicationSettings[NotificationHost] = testServer500.URL + edgexcontextUnacceptingNotificationHostMaxThresholdExceeded.Configuration.ApplicationSettings[MaxTemperatureThreshold] = temp49s + + // Create the condition of exceeding the maximum threshold, but also + // create the condition where the NotificationHost is unreachable, + // which creates an error condition when attempting to send a "max + // temperature exceeded" notification + edgexcontextBadNotificationHostThresholdsExceeded := &appcontext.Context{ + LoggingClient: lc, + } + edgexcontextBadNotificationHostThresholdsExceeded.Configuration.ApplicationSettings = getCommonApplicationSettings() + edgexcontextBadNotificationHostThresholdsExceeded.Configuration.ApplicationSettings[NotificationHost] = testServerThrowError.URL + edgexcontextBadNotificationHostThresholdsExceeded.Configuration.ApplicationSettings[MaxTemperatureThreshold] = temp49s + + // Set bad MQTT and Vending endpoints to produce specific error conditions + // in processTemperature, which first sends a request to MQTT, then + // another request to the vending endpoint + edgexcontextBadMQTTEndpoint := &appcontext.Context{ + LoggingClient: lc, + } + edgexcontextBadMQTTEndpoint.Configuration.ApplicationSettings = getCommonApplicationSettings() + edgexcontextBadMQTTEndpoint.Configuration.ApplicationSettings[MQTTEndpoint] = testServerThrowError.URL + + // As described above, in order to produce the error condition for + // processTemperature failing to hit the VendingEndpoint, we have to hit + // the MQTTEndpoint successfully first + edgexcontextBadVendingEndpoint := &appcontext.Context{ + LoggingClient: lc, + } + edgexcontextBadVendingEndpoint.Configuration.ApplicationSettings = getCommonApplicationSettings() + edgexcontextBadVendingEndpoint.Configuration.ApplicationSettings[MQTTEndpoint] = testServerStatusOK.URL + edgexcontextBadVendingEndpoint.Configuration.ApplicationSettings[VendingEndpoint] = testServerThrowError.URL + + // By not properly specifying valid application settings values, we create + // the error condition in ProcessApplicationSettings that claims + // the passed-in configuration is invalid + edgexcontextBadApplicationSettings := &appcontext.Context{ + LoggingClient: lc, + } + edgexcontextBadApplicationSettings.Configuration.ApplicationSettings = map[string]string{} + + // The expected incoming event reading from the controller board device + // service looks like this. Humidity and lock values don't matter at this + // time, since there's no business logic to handle them + controllerBoardStatusSuccessReadingValue := `{"door_closed":true,"temperature":50.0,"minTemperatureStatus":true,"maxTemperatureStatus":true}` + controllerBoardStatusSuccessReadingSerialValue := `{\"door_closed\":true,\"temperature\":50.0,\"minTemperatureStatus\":true,\"maxTemperatureStatus\":true}` + + // Following up from the previous 2 lines, the actual event itself (which + // contains the reading from above) looks like this in the ideal case + controllerBoardStatusEventSuccess := models.Event{ + Device: ControllerBoardDeviceServiceDeviceName, + Readings: []models.Reading{ + { + Value: controllerBoardStatusSuccessReadingValue, + }, + }, + } + + // We have to put the event into a slice, because the + // CheckControllerBoardStatus expects variadic interface parameters + controllerBoardStatusEventSuccessSlice := []interface{}{ + controllerBoardStatusEventSuccess, + } + + // Similar to above, create an event that contains a reading with an + // unmarshalable value + controllerBoardStatusEventUnsuccessfulJSON := models.Event{ + Device: ControllerBoardDeviceServiceDeviceName, + Readings: []models.Reading{ + { + Value: `invalid json value`, + }, + }, + } + + // Similar to above, put the event into a slice because it is a + // variadic interface parameter to CheckControllerBoardStatus + controllerBoardStatusEventUnsuccessfulJSONSlice := []interface{}{ + controllerBoardStatusEventUnsuccessfulJSON, + } + + // The empty input parameters slice creates the error condition in + // CheckControllerBoardStatus that intentionally fails if there is no + // event contained in the input interface slice + emptyInputParamsSlice := []interface{}{} + + // The initial state of the board needs to be controlled. In order to + // test the nested functions that will send notifications, we have to + // set a specific minimum amount of time in the past for the value of + // LastNotified + checkBoardStatusInitial := CheckBoardStatus{ + LastNotified: time.Now().Add(time.Minute * -3), + } + + return []testTableCheckControllerBoardStatusStruct{ + { + TestCaseName: "Success, no pre-existing measurements, no recent notifications sent", + InputEdgexContext: edgexcontextSuccess, + InputParams: controllerBoardStatusEventSuccessSlice, + InputCheckBoardStatus: CheckBoardStatus{ + MinTemperatureThreshold: temp49, + MaxTemperatureThreshold: temp51, + DoorClosed: true, + Measurements: []TempMeasurement{}, + LastNotified: time.Now().Add(time.Minute * -3), + }, + OutputBool: true, + OutputInterface: controllerBoardStatusEventSuccess, + OutputLogs: fmt.Sprintf("Received event reading value: %v", controllerBoardStatusSuccessReadingSerialValue), + ShouldLastNotifiedBeDifferent: true, + ExpectedTemperatureMeasurementSliceLength: 1, + }, + { + TestCaseName: "Success, minimum temperature threshold exceeded, no recent notifications sent", + InputEdgexContext: edgexcontextSuccessMinThresholdExceeded, + InputParams: controllerBoardStatusEventSuccessSlice, + InputCheckBoardStatus: CheckBoardStatus{ + MinTemperatureThreshold: temp51, + MaxTemperatureThreshold: temp52, + DoorClosed: true, + Measurements: []TempMeasurement{ + {Timestamp: now.Add(time.Second * time.Duration(-1)), Measurement: temp50}, + {Timestamp: now.Add(time.Second * time.Duration(-2)), Measurement: temp50}, + {Timestamp: now.Add(time.Second * time.Duration(-3)), Measurement: temp50}, + {Timestamp: now.Add(time.Second * time.Duration(-4)), Measurement: temp50}, + {Timestamp: now.Add(time.Second * time.Duration(-5)), Measurement: temp50}, + {Timestamp: now.Add(time.Second * time.Duration(-17)), Measurement: temp50}, + }, + LastNotified: time.Now().Add(time.Minute * -3), + }, + OutputBool: true, + OutputInterface: controllerBoardStatusEventSuccess, + OutputLogs: fmt.Sprintf("Received event reading value: %v", controllerBoardStatusSuccessReadingSerialValue), + ShouldLastNotifiedBeDifferent: true, + ExpectedTemperatureMeasurementSliceLength: 6, + }, + { + TestCaseName: "Unsuccessful due to maximum temperature threshold exceeded, no recent notifications sent, NotificationHost not sending HTTP status Accepted", + InputEdgexContext: edgexcontextUnacceptingNotificationHostMaxThresholdExceeded, + InputParams: controllerBoardStatusEventSuccessSlice, + InputCheckBoardStatus: CheckBoardStatus{ + MinTemperatureThreshold: temp51, + MaxTemperatureThreshold: temp49, + DoorClosed: true, + Measurements: []TempMeasurement{ + {Timestamp: now.Add(time.Second * time.Duration(-1)), Measurement: temp50}, + {Timestamp: now.Add(time.Second * time.Duration(-2)), Measurement: temp50}, + {Timestamp: now.Add(time.Second * time.Duration(-3)), Measurement: temp50}, + {Timestamp: now.Add(time.Second * time.Duration(-4)), Measurement: temp50}, + {Timestamp: now.Add(time.Second * time.Duration(-5)), Measurement: temp50}, + {Timestamp: now.Add(time.Second * time.Duration(-17)), Measurement: temp50}, + }, + LastNotified: time.Now().Add(time.Minute * -3), + }, + OutputBool: true, + OutputInterface: controllerBoardStatusEventSuccess, + OutputLogs: fmt.Sprintf("Encountered error while checking temperature thresholds: Failed to send temperature threshold exceeded notification(s) due to error: Encountered error sending the %v temperature threshold message: Encountered error sending notification for exceeding temperature threshold: The REST API HTTP status code response from the server when attempting to send a notification was not %v, instead got: %v", maximum, http.StatusAccepted, http.StatusInternalServerError), + ShouldLastNotifiedBeDifferent: false, + ExpectedTemperatureMeasurementSliceLength: 6, + }, + { + TestCaseName: "Unsuccessful due to empty params", + InputEdgexContext: edgexcontextSuccess, + InputParams: emptyInputParamsSlice, + OutputBool: false, + OutputInterface: nil, + OutputLogs: "", + }, + { + TestCaseName: "Unsuccessful due to unset config item", + InputEdgexContext: edgexcontextBadApplicationSettings, + InputParams: controllerBoardStatusEventSuccessSlice, + OutputBool: false, + OutputInterface: nil, + OutputLogs: `Failed to load the EdgeX application settings configuration. Please make sure that the values in configuration.toml are set correctly. The error is: \"The \"AverageTemperatureMeasurementDuration\" application setting has not been set. Please set this to an acceptable time.Duration value in configuration.toml\", and the event is: {\"device\":\"ds-controller-board\",\"readings\":[{\"value\":\"{\\\"door_closed\\\":true,\\\"temperature\\\":50.0,\\\"minTemperatureStatus\\\":true,\\\"maxTemperatureStatus\\\":true}\"}]}`, + }, + { + TestCaseName: "Unsuccessful due to unserializable controller board status data", + InputEdgexContext: edgexcontextSuccess, + InputParams: controllerBoardStatusEventUnsuccessfulJSONSlice, + OutputBool: false, + OutputInterface: nil, + OutputLogs: `Failed to unmarshal controller board data, the event data is: {\"value\":\"invalid json value\"}`, + }, + { + TestCaseName: "Unsuccessful due to NotificationHost not responding with HTTP Accepted", + InputEdgexContext: edgexcontextBadNotificationHostThresholdsExceeded, + InputParams: controllerBoardStatusEventSuccessSlice, + InputCheckBoardStatus: CheckBoardStatus{ + LastNotified: time.Now().Add(time.Minute * -3), + }, + OutputBool: true, + OutputInterface: controllerBoardStatusEventSuccess, + OutputLogs: fmt.Sprintf( + `Encountered error while checking temperature thresholds: Failed to send temperature threshold exceeded notification(s) due to error: Encountered error sending the maximum temperature threshold message: Encountered error sending notification for exceeding temperature threshold: Failed to perform REST POST API call to send a notification to \"%v\", error: %v %v: %v`, edgexcontextBadNotificationHostThresholdsExceeded.Configuration.ApplicationSettings[NotificationHost], "Post", edgexcontextBadNotificationHostThresholdsExceeded.Configuration.ApplicationSettings[NotificationHost], "EOF"), + ShouldLastNotifiedBeDifferent: false, + ExpectedTemperatureMeasurementSliceLength: 1, + }, + { + TestCaseName: "Unsuccessful due to MQTTEndpoint not responding with HTTP 200 OK, no temperature notification sent", + InputEdgexContext: edgexcontextBadMQTTEndpoint, + InputParams: controllerBoardStatusEventSuccessSlice, + InputCheckBoardStatus: checkBoardStatusInitial, + OutputBool: true, + OutputInterface: controllerBoardStatusEventSuccess, + OutputLogs: fmt.Sprintf("Encountered error while checking the open/closed state of the door: Failed to submit the vending door state to the MQTT device service: Failed to submit REST PUT request due to error: %v %v: %v", "Put", edgexcontextBadMQTTEndpoint.Configuration.ApplicationSettings[MQTTEndpoint], "EOF"), + ShouldLastNotifiedBeDifferent: false, + ExpectedTemperatureMeasurementSliceLength: 1, + }, + { + TestCaseName: "Unsuccessful due to VendingEndpoint not responding with HTTP 200 OK, no temperature notification sent", + InputEdgexContext: edgexcontextBadVendingEndpoint, + InputParams: controllerBoardStatusEventSuccessSlice, + InputCheckBoardStatus: checkBoardStatusInitial, + OutputBool: true, + OutputInterface: controllerBoardStatusEventSuccess, + OutputLogs: fmt.Sprintf("Encountered error while checking the open/closed state of the door: Failed to submit the controller board's status to the central vending state service: Failed to submit REST POST request due to error: %v %v: %v", "Post", edgexcontextBadVendingEndpoint.Configuration.ApplicationSettings[VendingEndpoint], "EOF"), + ShouldLastNotifiedBeDifferent: false, + ExpectedTemperatureMeasurementSliceLength: 1, + }, + { + TestCaseName: "Unsuccessful due to VendingEndpoint not responding with HTTP 200 OK, max temperature threshold exceeded", + InputEdgexContext: edgexcontextBadVendingEndpointMaxThresholdExceeded, + InputParams: controllerBoardStatusEventSuccessSlice, + InputCheckBoardStatus: CheckBoardStatus{ + MinTemperatureThreshold: temp51, + MaxTemperatureThreshold: temp49, + DoorClosed: true, + Measurements: []TempMeasurement{ + {Timestamp: now.Add(time.Second * time.Duration(-1)), Measurement: temp50}, + {Timestamp: now.Add(time.Second * time.Duration(-2)), Measurement: temp50}, + {Timestamp: now.Add(time.Second * time.Duration(-3)), Measurement: temp50}, + {Timestamp: now.Add(time.Second * time.Duration(-4)), Measurement: temp50}, + {Timestamp: now.Add(time.Second * time.Duration(-5)), Measurement: temp50}, + {Timestamp: now.Add(time.Second * time.Duration(-17)), Measurement: temp50}, + }, + LastNotified: time.Now().Add(time.Minute * -3), + }, + OutputBool: true, + OutputInterface: controllerBoardStatusEventSuccess, + OutputLogs: fmt.Sprintf("Encountered error while checking temperature thresholds: Encountered error sending the controller board's status to the central vending endpoint: Failed to submit REST POST request due to error: %v %v: %v", "Post", edgexcontextBadVendingEndpoint.Configuration.ApplicationSettings[VendingEndpoint], "EOF"), + ShouldLastNotifiedBeDifferent: true, + ExpectedTemperatureMeasurementSliceLength: 6, + }, + }, []*httptest.Server{ + testServerStatusOK, + testServerThrowError, + testServerAccepted, + testServer500, + } +} + +// TestCheckControllerBoardStatus validates that the +// CheckControllerBoardStatus function behaves as expected +func TestCheckControllerBoardStatus(t *testing.T) { + logFileName := checkControllerBoardStatusLogFileName + testTable, testServers := prepCheckControllerBoardStatusTest() + for _, testCase := range testTable { + ct := testCase // pinning "current test" solves concurrency issues + t.Run(testCase.TestCaseName, func(t *testing.T) { + // Set up the test assert/require functions + assert := assert.New(t) + require := require.New(t) + // Attempt to create the log file + file, err := os.Create(logFileName) + require.NoError(err, "Failed to set up log file") + + // Clear the contents of the log file + _, err = file.WriteString("") + require.NoError(err, "Failed to clear contents of log file") + + // Pin the test's checkBoardStatus to prevent concurrency issues + cbs := ct.InputCheckBoardStatus + + // Run the function that needs to be tested + testBool, testInterface := cbs.CheckControllerBoardStatus(ct.InputEdgexContext, ct.InputParams...) + + // Validate the output + assert.Equal(ct.OutputBool, testBool, "Expected output boolean to match test boolean") + assert.Equal(ct.OutputInterface, testInterface, "Expected output interface to match test interface") + assert.Equal(ct.ExpectedTemperatureMeasurementSliceLength, len(cbs.Measurements), "The number of temperature measurements contained in CheckBoardStatus should match expected, since the AvgTemp function should be purging old values") + if ct.ShouldLastNotifiedBeDifferent { + assert.NotEqual(cbs.LastNotified, ct.InputCheckBoardStatus.LastNotified, "Expected the CheckBoardStatus.LastNotified value to be different") + } + + // Review the logs + fileContentsAsBytes, err := ioutil.ReadFile(logFileName) + require.NoError(err, "Failed to read from log file") + fileContents := string(fileContentsAsBytes) + + // ignore the contents of logs if the expected string is empty + if ct.OutputLogs != "" { + assert.Contains(fileContents, ct.OutputLogs, "Expected logs to contain expected test case log output") + } + + // For each test, reset the contents of the log file to nothing + err = os.Remove(logFileName) + require.NoError(err, "Failed to clear contents of log file before ending test") + err = file.Close() + assert.NoError(err, "Failed to close file descriptor for log file") + + }) + } + // We are responsible for closing the test servers + for _, testServer := range testServers { + testServer.Close() + } +} + +// Finish by testing the remaining edge cases that were not covered by +// the above test table + +// TestGetTempThresholdExceededMessage tests that the edge case for +// getTempThresholdExceededMessage returns an error when passed in a value +// other than "maximum" or "minimum" +func TestGetTempThresholdExceededMessage(t *testing.T) { + assert := assert.New(t) + + tval := "neither min nor max" + result, err := getTempThresholdExceededMessage(tval, temp50, temp50) + + assert.EqualError(err, fmt.Sprintf("Please specify minOrMax as \"%v\" or \"%v\", the value given was \"%v\"", maximum, minimum, tval)) + assert.Empty(result, "Expected error result to be an empty string") +} diff --git a/as-controller-board-status/go.mod b/as-controller-board-status/go.mod new file mode 100644 index 0000000..6b366ef --- /dev/null +++ b/as-controller-board-status/go.mod @@ -0,0 +1,13 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +module as-controller-board-status + +go 1.12 + +require ( + github.com/edgexfoundry/app-functions-sdk-go v1.0.0 + github.com/edgexfoundry/go-mod-core-contracts v0.1.25 + github.com/intel-iot-devkit/automated-checkout-utilities v1.0.0 + github.com/stretchr/testify v1.5.1 +) diff --git a/as-controller-board-status/main.go b/as-controller-board-status/main.go new file mode 100644 index 0000000..d7f8a78 --- /dev/null +++ b/as-controller-board-status/main.go @@ -0,0 +1,81 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package main + +import ( + "as-controller-board-status/functions" + "fmt" + "os" + + "github.com/edgexfoundry/app-functions-sdk-go/appsdk" + "github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms" +) + +const ( + serviceKey = "as-controller-board-status" +) + +func main() { + // Create an instance of the EdgeX SDK and initialize it + edgexSdk := &appsdk.AppFunctionsSDK{ServiceKey: serviceKey} + err := edgexSdk.Initialize() + if err != nil { + edgexSdk.LoggingClient.Error(fmt.Sprintf("SDK initialization failed: %v", err.Error())) + os.Exit(-1) + } + + // Get the application's settings from the configuration.toml file + appSettings := edgexSdk.ApplicationSettings() + if appSettings == nil { + edgexSdk.LoggingClient.Error("No application settings found") + os.Exit(-1) + } + + // Retrieve & parse the required application settings into a proper + // configuration struct + edgexconfig, err := functions.ProcessApplicationSettings(appSettings) + if err != nil { + edgexSdk.LoggingClient.Error(fmt.Sprintf("Application settings could not be processed: %v", err.Error())) + os.Exit(-1) + } + + boardStatus := functions.CheckBoardStatus{ + MaxTemperatureThreshold: edgexconfig.MaxTemperatureThreshold, + MinTemperatureThreshold: edgexconfig.MinTemperatureThreshold, + DoorClosed: true, // Set default door state to closed + } + + // Create the function pipeline to run when an event is read on the device channels + err = edgexSdk.SetFunctionsPipeline( + transforms.NewFilter([]string{edgexconfig.DeviceName}).FilterByDeviceName, + boardStatus.CheckControllerBoardStatus, + ) + if err != nil { + edgexSdk.LoggingClient.Error(fmt.Sprintf("SDK initialization failed: %v", err.Error())) + os.Exit(-1) + } + + // Subscribe to the EdgeX notification service + err = functions.SubscribeToNotificationService(edgexconfig) + if err != nil { + edgexSdk.LoggingClient.Info(fmt.Sprintf("Error subscribing to edgex notification service %s", err.Error())) + os.Exit(-1) + } + + // Add the "status" REST API route + err = edgexSdk.AddRoute("/status", functions.GetStatus, "GET", "OPTIONS") + if err != nil { + edgexSdk.LoggingClient.Error("Error adding route: %v", err.Error()) + os.Exit(-1) + } + + // Tell the SDK to "start" and begin listening for events to trigger the pipeline + err = edgexSdk.MakeItRun() + if err != nil { + edgexSdk.LoggingClient.Error(fmt.Sprintf("MakeItRun returned error: %v", err.Error())) + os.Exit(-1) + } + + os.Exit(0) +} diff --git a/as-controller-board-status/res/configuration.toml b/as-controller-board-status/res/configuration.toml new file mode 100644 index 0000000..9d9c4ad --- /dev/null +++ b/as-controller-board-status/res/configuration.toml @@ -0,0 +1,65 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +[Writable] +LogLevel = 'INFO' + +[Service] +BootTimeout = '30s' +ClientMonitor = '15s' +CheckInterval = '10s' +Host = 'localhost' +Port = 8080 +Protocol = 'http' +ReadMaxLimit = 100 +StartupMsg = 'This EdgeX application service reads events from a controller board device service and propagates the information from the controller board to other services and API endpoints' +Timeout = '30s' + +[Registry] +Host = 'localhost' +Port = 8500 +Type = 'consul' + +[MessageBus] +Type = 'zero' + [MessageBus.PublishHost] + Host = '*' + Port = 5564 + Protocol = 'tcp' + [MessageBus.SubscribeHost] + Host = 'localhost' + Port = 5563 + Protocol = 'tcp' + +[Logging] +EnableRemote = false +File = './logs/app-ds-card-reader-publish.log' + +# This example depends on events generated by Device-Virtual-Go, so must use MessageBus trigger. +# It will publish back to the bus on the "converted" topic +[Binding] +Type="messagebus" +SubscribeTopic="" +PublishTopic="" + +[ApplicationSettings] + AverageTemperatureMeasurementDuration = "-15s" + DeviceName = "ds-controller-board" + MaxTemperatureThreshold = "83" + MinTemperatureThreshold = "10" + MQTTEndpoint = "http://localhost:48082/api/v1/device/name/Inference-MQTT-device/command/inferenceDoorStatus" + NotificationCategory = "HW_HEALTH" + NotificationEmailAddresses = "your-email@site.com" + NotificationHost = "http://localhost:48060/api/v1/notification" + NotificationLabels = "HW_HEALTH" + NotificationReceiver = "System Administrator" + NotificationSender = "Automated Checkout Maintenance Notification" + NotificationSeverity = "CRITICAL" + NotificationSlug = "sys-admin" + NotificationSlugPrefix = "maintenance-notification" + NotificationSubscriptionMaxRESTRetries = "10" + NotificationSubscriptionRESTRetryInterval = "10s" + NotificationThrottleDuration = "1m" + RESTCommandTimeout = "15s" + SubscriptionHost = "http://localhost:48060/api/v1/subscription" + VendingEndpoint = "http://localhost:48099/boardStatus" diff --git a/as-controller-board-status/res/docker/configuration.toml b/as-controller-board-status/res/docker/configuration.toml new file mode 100644 index 0000000..bd7dce7 --- /dev/null +++ b/as-controller-board-status/res/docker/configuration.toml @@ -0,0 +1,70 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +[Writable] +LogLevel = 'INFO' + +[Service] +BootTimeout = '30s' +ClientMonitor = '15s' +CheckInterval = '10s' +Host = 'as-controller-board-status' +Port = 48094 +Protocol = 'http' +ReadMaxLimit = 100 +StartupMsg = 'This EdgeX application service reads events from a controller board device service and propagates the information from the controller board to other services and API endpoints' +Timeout = '30s' + +[Clients] + [Clients.Logging] + Host = "edgex-support-logging" + Protocol = "http" + Port = 48061 + +[Registry] +Host = 'edgex-core-consul' +Port = 8500 +Type = 'consul' + +[MessageBus] +Type = 'zero' + [MessageBus.PublishHost] + Host = '*' + Port = 5564 + Protocol = 'tcp' + [MessageBus.SubscribeHost] + Host = 'edgex-core-data' + Port = 5563 + Protocol = 'tcp' + +[Logging] +EnableRemote = true + +# This example depends on events generated by Device-Virtual-Go, so must use MessageBus trigger. +# It will publish back to the bus on the "converted" topic +[Binding] +Type="messagebus" +SubscribeTopic="" +PublishTopic="" + +[ApplicationSettings] + AverageTemperatureMeasurementDuration = "-15s" + DeviceName = "ds-controller-board" + MaxTemperatureThreshold = "83" + MinTemperatureThreshold = "10" + MQTTEndpoint = "http://edgex-core-command:48082/api/v1/device/name/Inference-MQTT-device/command/inferenceDoorStatus" + NotificationCategory = "HW_HEALTH" + NotificationEmailAddresses = "your-email@site.com" + NotificationHost = "http://edgex-support-notifications:48060/api/v1/notification" + NotificationLabels = "HW_HEALTH" + NotificationReceiver = "System Administrator" + NotificationSender = "Automated Checkout Maintenance Notification" + NotificationSeverity = "CRITICAL" + NotificationSlug = "sys-admin" + NotificationSlugPrefix = "maintenance-notification" + NotificationSubscriptionMaxRESTRetries = "10" + NotificationSubscriptionRESTRetryInterval = "10s" + NotificationThrottleDuration = "1m" + RESTCommandTimeout = "15s" + SubscriptionHost = "http://edgex-support-notifications:48060/api/v1/subscription" + VendingEndpoint = "http://as-vending:48099/boardStatus" diff --git a/as-vending/.gitignore b/as-vending/.gitignore new file mode 100644 index 0000000..cfa5214 --- /dev/null +++ b/as-vending/.gitignore @@ -0,0 +1,17 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, build with `go test -c` +*.test +main +as-vending +test.txt +go.sum +.vscode/* + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out diff --git a/as-vending/.golangci.yml b/as-vending/.golangci.yml new file mode 100644 index 0000000..5be4558 --- /dev/null +++ b/as-vending/.golangci.yml @@ -0,0 +1,27 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause +run: + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 5m +linters-settings: + misspell: + locale: US +linters: + enable: + - bodyclose + - errcheck + - goconst + - golint + - govet + - gosimple + - ineffassign + - misspell + - staticcheck + - structcheck + - typecheck + - unused + - unconvert + - unparam + - varcheck + disable-all: true + fast: true diff --git a/as-vending/Dockerfile b/as-vending/Dockerfile new file mode 100644 index 0000000..661198e --- /dev/null +++ b/as-vending/Dockerfile @@ -0,0 +1,26 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +FROM automated-checkout/build:latest AS builder + +LABEL license='SPDX-License-Identifier: BSD-3-Clause' \ + copyright='Copyright (c) 2020: Intel' + +RUN mkdir as-vending +WORKDIR /usr/local/bin/as-vending/ +COPY . . + +# Compile the code +RUN make gobuild + +# Next image - Copy built Go binary into new workspace +FROM alpine + +LABEL license='SPDX-License-Identifier: BSD-3-Clause' \ + copyright='Copyright (c) 2020: Intel' + +RUN apk --no-cache add zeromq +COPY --from=builder /usr/local/bin/as-vending/res/docker/configuration.toml /res/docker/configuration.toml +COPY --from=builder /usr/local/bin/as-vending/main /as-vending + +CMD [ "/as-vending","--profile=docker","--confdir=/res", "-r"] diff --git a/as-vending/LICENSE b/as-vending/LICENSE new file mode 100644 index 0000000..105f619 --- /dev/null +++ b/as-vending/LICENSE @@ -0,0 +1,31 @@ +BSD 3-Clause License + +Copyright © 2020, Intel Corporation +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/as-vending/Makefile b/as-vending/Makefile new file mode 100644 index 0000000..d28ef1b --- /dev/null +++ b/as-vending/Makefile @@ -0,0 +1,45 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +.PHONY: build gobuild run gorun stop test lint + +MICROSERVICE=automated-checkout/as-vending + +build: + docker build --rm \ + --build-arg http_proxy \ + --build-arg https_proxy \ + -f Dockerfile \ + -t $(MICROSERVICE):dev \ + . + +gobuild: + CGO_ENABLED=1 GOOS=linux go build -ldflags='-s -w' -a -installsuffix cgo main.go + +run: + docker run \ + --rm \ + -p 48099:48099 \ + $(MICROSERVICE):dev + +gorun: + ./main + +stop: + docker rm -f $(MICROSERVICE):latest + +test: + go test -test.v -cover ./... + +testHTML: + go test -coverprofile=test_coverage.out ./... && \ + go tool cover -html=test_coverage.out + +GOLANGCI_VERSION := $(shell golangci-lint --version 2>/dev/null) + +lint: +ifdef GOLANGCI_VERSION + golangci-lint run +else + @echo "golangci-lint not found. Please refer to the README documentation for proper installation" +endif diff --git a/as-vending/functions/models.go b/as-vending/functions/models.go new file mode 100644 index 0000000..3578e83 --- /dev/null +++ b/as-vending/functions/models.go @@ -0,0 +1,107 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package functions + +// VendingState is a representation of the entire state of vending workflow. +// The information stored in this is shared across this application service. +// Information about the state of the vending workflow should generally +// be stored in this struct. +type VendingState struct { + CVWorkflowStarted bool `json:"cvWorkflowStarted"` + MaintenanceMode bool `json:"MaintenanceMode"` + CurrentUserData OutputData `json:"personID"` + DoorClosed bool `json:"doorClosed"` + // global stop channel for threads + ThreadStopChannel chan int `json:"threadStopChannel"` + // door open event + DoorOpenedDuringCVWorkflow bool `json:"doorOpenedDuringCVWorkflow "` + DoorOpenWaitThreadStopChannel chan int `json:"doorOpenWaitThreadStopChannel"` + DoorOpenStateTimeout int `json:"doorOpenStateTimeout"` + //door close event + DoorClosedDuringCVWorkflow bool `json:"doorClosedDuringCVWorkflow "` + DoorCloseWaitThreadStopChannel chan int `json:"doorCloseWaitThreadStopChannel"` + DoorCloseStateTimeout int `json:"doorCloseStateTimeout"` + // inference event + InferenceDataReceived bool `json:"inferenceDataReceived"` + InferenceWaitThreadStopChannel chan int `json:"inferenceWaitThreadStopChannel"` + InferenceTimeout int `json:"inferenceTimeout"` +} + +// MaintenanceMode is a simple structure used to return the state of +// maintenance mode to REST API consumers. +type MaintenanceMode struct { + MaintenanceMode bool `json:"maintenanceMode"` +} + +// ControllerBoardStatus represents the status of the controller board, +// which is pushed into this application service from the +// as-controller-board-status service as a REST request. +type ControllerBoardStatus struct { + Lock1 int `json:"lock1_status"` + Lock2 int `json:"lock2_status"` + DoorClosed bool `json:"door_closed"` // true means the door is closed and false means the door is open + Temperature float64 `json:"temperature"` + Humidity float64 `json:"humidity"` + MinTemperatureStatus bool `json:"minTemperatureStatus"` + MaxTemperatureStatus bool `json:"maxTemperatureStatus"` +} + +// Ledger is the data structure that represents financial ledger transactions, +// and comes from the ledger service. +type Ledger struct { + TransactionID int64 `json:"transactionID,string"` + TxTimeStamp int64 `json:"txTimeStamp,string"` + LineTotal float64 `json:"lineTotal"` + CreatedAt int64 `json:"createdAt,string"` + UpdatedAt int64 `json:"updatedAt,string"` + IsPaid bool `json:"isPaid"` + LineItems []LineItem `json:"lineItems"` +} + +// LineItem is a single item contained in the Ledger. +type LineItem struct { + SKU string `json:"sku"` + ProductName string `json:"productName"` + ItemPrice float64 `json:"itemPrice"` + ItemCount int `json:"itemCount"` +} + +// deltaLedger is a representation of a set of deltaSKUs from an upstream +// inference service. +type deltaLedger struct { + AccountID int `json:"accountId"` + DeltaSKUs []deltaSKU `json:"deltaSKUs"` +} + +// deltaSKU is a single representation of an integer quantity change of a +// specific SKU in inventory. An inference will produce a list of deltaSKUs +// when someone removes items from inventory. +type deltaSKU struct { + SKU string `json:"SKU"` + Delta int `json:"delta"` +} + +// OutputData represents the authentication information associated with +// a person that has been authenticated to open the vending machine and +// remove items from inventory for purchase. This information is pushed to +// the vending state and shared throughout this application service. +type OutputData struct { + AccountID int `json:"accountID"` + PersonID int `json:"personID"` + RoleID int `json:"roleID"` + CardID string `json:"cardID"` +} + +// AuditLogEntry is the representation of an inventory transaction that +// occurs when someone opens the vending machine. Regardless of how many +// items have been taken, an audit log transaction will always be created. +type AuditLogEntry struct { + CardID string `json:"cardId"` + AccountID int `json:"accountId"` + RoleID int `json:"roleId"` + PersonID int `json:"personId"` + InventoryDelta []deltaSKU `json:"inventoryDelta"` + CreatedAt int64 `json:"createdAt,string"` + AuditEntryID string `json:"auditEntryId"` +} diff --git a/as-vending/functions/output.go b/as-vending/functions/output.go new file mode 100644 index 0000000..2a56717 --- /dev/null +++ b/as-vending/functions/output.go @@ -0,0 +1,700 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package functions + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "net/http" + "strconv" + "time" + + "github.com/edgexfoundry/app-functions-sdk-go/appcontext" + "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/models" + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +const ( + InferenceMQTTDevice = "Inference-MQTT-device" + DefaultTimeOuts = 15 +) + +// DeviceHelper is an EdgeX function that is passed into the EdgeX SDK's function pipeline. +// It is a decision function that allows for multiple devices to have their events processed +// correctly by this application service. +func (vendingState *VendingState) DeviceHelper(edgexcontext *appcontext.Context, params ...interface{}) (bool, interface{}) { + if len(params) < 1 { + // We didn't receive a result + return false, nil + } + + event := params[0].(models.Event) + + switch event.Device { + case "ds-card-reader": + { + return vendingState.VerifyDoorAccess(edgexcontext, event) + } + case InferenceMQTTDevice: + { + return vendingState.HandleMqttDeviceReading(edgexcontext, event) + } + default: + { + return false, nil + } + } +} + +// HandleMqttDeviceReading is an EdgeX function that simply handles events coming from +// the MQTT device service. +func (vendingState *VendingState) HandleMqttDeviceReading(edgexcontext *appcontext.Context, event models.Event) (bool, interface{}) { + if event.Device == InferenceMQTTDevice { + for _, eventReading := range event.Readings { + fmt.Println(eventReading.Value) + } + edgexcontext.LoggingClient.Debug("Inference mqtt device", + "workflow:", vendingState.CVWorkflowStarted, + "maintenance mode:", vendingState.MaintenanceMode, + "open:", vendingState.DoorOpenedDuringCVWorkflow, + "closed:", vendingState.DoorClosedDuringCVWorkflow, + "Inference:", vendingState.InferenceDataReceived, + "door:", vendingState.DoorClosed, + ) + + edgexcontext.LoggingClient.Debug("Processing reading from MQTT device service") + for _, eventReading := range event.Readings { + switch eventReading.Name { + case "inferenceSkuDelta": + { + fmt.Println("Inference Started") + var skuDelta []deltaSKU + if err := json.Unmarshal([]byte(eventReading.Value), &skuDelta); err != nil { + edgexcontext.LoggingClient.Error("HandleMqttDeviceReading failed to unmarshal skuDelta message") + fmt.Println("Inference Failed") + return false, err + } + + // do some things with the skuDelta + // example: + // [{"SKU": "HXI86WHU", "delta": -2}] + deltaLedger := deltaLedger{ + AccountID: vendingState.CurrentUserData.AccountID, + DeltaSKUs: skuDelta, + } + + vendingState.InferenceDataReceived = true + // Stop the open wait thread since the door is now opened + close(vendingState.InferenceWaitThreadStopChannel) + vendingState.InferenceWaitThreadStopChannel = make(chan int) + + if vendingState.CurrentUserData.RoleID == 1 { + // POST the deltaLedger json string to the ledger endpoint + ledgerCommandURL, ok := edgexcontext.Configuration.ApplicationSettings["LedgerService"] + if !ok { + return false, fmt.Errorf("LedgerService application API endpoint setting not found") + } + + outputBytes, err := json.Marshal(deltaLedger) + if err != nil { + edgexcontext.LoggingClient.Error("HandleMqttDeviceReading failed to marshal deltaLedger") + return false, err + } + + edgexcontext.LoggingClient.Info("Sending SKU delta to ledger service") + + // send SKU delta to ledger service and get back current ledger information + resp, err := sendCommand(edgexcontext, "POST", ledgerCommandURL, outputBytes) + if err != nil { + edgexcontext.LoggingClient.Error("Ledger service failed: %v", err.Error()) + return false, err + } + + defer resp.Body.Close() + + edgexcontext.LoggingClient.Info("Successfully updated the user's ledger") + + var currentLedger Ledger + _, err = utilities.ParseJSONHTTPResponseContent(resp.Body, ¤tLedger) + if err != nil { + return false, fmt.Errorf("Unable to unmarshal ledger response") + } + + // Display Ledger Total on LCD + if displayErr := displayLedger(edgexcontext, currentLedger); displayErr != nil { + return false, displayErr + } + + } + + // POST the deltaLedger json string to the inventory endpoint + inventoryCommandURL, ok := edgexcontext.Configuration.ApplicationSettings["InventoryService"] + if !ok { + return false, fmt.Errorf("InventoryService application API endpoint setting not found") + } + + outputBytes, err := json.Marshal(deltaLedger.DeltaSKUs) + if err != nil { + return false, fmt.Errorf("HandleMqttDeviceReading failed to marshal deltaLedger.DeltaSKUs") + } + + edgexcontext.LoggingClient.Info("Sending SKU delta to inventory service") + inventoryResp, err := sendCommand(edgexcontext, "POST", inventoryCommandURL, outputBytes) + if err != nil { + return false, err + } + defer inventoryResp.Body.Close() + // Post an audit log entry for this transaction, regardless of ledger or not + auditLogEntry := AuditLogEntry{ + AccountID: vendingState.CurrentUserData.AccountID, + CardID: vendingState.CurrentUserData.CardID, + RoleID: vendingState.CurrentUserData.RoleID, + PersonID: vendingState.CurrentUserData.PersonID, + InventoryDelta: deltaLedger.DeltaSKUs, + CreatedAt: time.Now().UnixNano(), + } + + auditLogCommandURL, ok := edgexcontext.Configuration.ApplicationSettings["InventoryAuditLogService"] + if !ok { + return false, fmt.Errorf("InventoryAuditLogService application API endpoint setting not found") + } + + outputBytes, err = json.Marshal(auditLogEntry) + if err != nil { + return false, err + } + + edgexcontext.LoggingClient.Info("Sending audit log entry to inventory service") + auditResp, err := sendCommand(edgexcontext, "POST", auditLogCommandURL, outputBytes) + if err != nil { + return false, err + } + defer auditResp.Body.Close() + vendingState.CurrentUserData = OutputData{} + vendingState.CVWorkflowStarted = false + edgexcontext.LoggingClient.Info("Inference complete and workflow status reset") + // Close all thread to ensure all threads are cleaned up before the next card is scanned. + close(vendingState.ThreadStopChannel) + vendingState.ThreadStopChannel = make(chan int) + } + default: + { + edgexcontext.LoggingClient.Info("Received an event with an unknown name") + return false, nil + } + } + } + } + + return false, nil +} + +// VerifyDoorAccess will take the card reader events and verify the read card id against the white list +// If the card is valid the function will send the unlock message to the device-controller-board device service +func (vendingState *VendingState) VerifyDoorAccess(edgexcontext *appcontext.Context, event models.Event) (bool, interface{}) { + edgexcontext.LoggingClient.Info("new card scanned", "workflow:", vendingState.CVWorkflowStarted, "maintenance mode:", vendingState.MaintenanceMode, "open:", vendingState.DoorOpenedDuringCVWorkflow, "closed:", vendingState.DoorClosedDuringCVWorkflow, "Inference:", vendingState.InferenceDataReceived, "door:", vendingState.DoorClosed) + + if event.Device == "ds-card-reader" && !vendingState.CVWorkflowStarted { + edgexcontext.LoggingClient.Info("Verify the card reader input against the white list") + + edgexcontext.LoggingClient.Info("Card Scanned", "workflow:", vendingState.CVWorkflowStarted, "maintenance mode:", vendingState.MaintenanceMode, "open:", vendingState.DoorOpenedDuringCVWorkflow, "closed:", vendingState.DoorClosedDuringCVWorkflow, "Inference:", vendingState.InferenceDataReceived, "door:", vendingState.DoorClosed) + // check to see if inference is running and set maintenance mode accordingly + if !vendingState.MaintenanceMode { + inferenceHeartbeatEndpoint, ok := edgexcontext.Configuration.ApplicationSettings["InferenceHeartbeat"] + if !ok { + return false, fmt.Errorf("inferenceHeartbeatEndpoint Application setting not found") + } + vendingState.MaintenanceMode = !checkInferenceStatus(edgexcontext, inferenceHeartbeatEndpoint) + } + + // Retrieve & Hit auth endpoint + authEndpoint, ok := edgexcontext.Configuration.ApplicationSettings["AuthenticationEndpoint"] + if !ok { + return false, fmt.Errorf("AuthenticationEndpoint Application setting not found") + } + + for _, eventReading := range event.Readings { + vendingState.getCardAuthInfo(edgexcontext, authEndpoint, eventReading.Value) + + switch vendingState.CurrentUserData.RoleID { + // Check the role of the card scanned. Role 1 = customer and Role 2 = item stocker + case 1, 2: + { + if !vendingState.MaintenanceMode { + edgexcontext.LoggingClient.Info(eventReading.Name + " readable value from " + event.Device + " is " + eventReading.Value) + // Display row 2 command URL + commandURL, ok := edgexcontext.Configuration.ApplicationSettings["DeviceControllerBoarddisplayRow2"] + if !ok { + return false, fmt.Errorf("DeviceControllerBoard Application setting not found") + } + // Send lock command + resp, err := sendCommand(edgexcontext, "PUT", commandURL, []byte("{\"displayRow2\":\"hello\"}")) + if err != nil { + return false, err + } + defer resp.Body.Close() + + // Display row 3 command URL + commandURL, ok = edgexcontext.Configuration.ApplicationSettings["DeviceControllerBoarddisplayRow3"] + if !ok { + return false, fmt.Errorf("DeviceControllerBoard Application setting not found") + } + // Send lock command + respRow3, err := sendCommand(edgexcontext, "PUT", commandURL, []byte("{\"displayRow3\":\""+eventReading.Value+"\"}")) + if err != nil { + return false, err + } + defer respRow3.Body.Close() + + // Lock command URL + commandURL, ok = edgexcontext.Configuration.ApplicationSettings["DeviceControllerBoardLock1"] + if !ok { + return false, fmt.Errorf("DeviceControllerBoard Application setting not found") + } + // Send lock command + respLock, err := sendCommand(edgexcontext, "PUT", commandURL, []byte("{\"lock1\":\"true\"}")) + if err != nil { + return false, err + } + defer respLock.Body.Close() + + // Start the workflow state and set all of the thread states to false + vendingState.CVWorkflowStarted = true + vendingState.DoorClosedDuringCVWorkflow = false + vendingState.DoorOpenedDuringCVWorkflow = false + vendingState.InferenceDataReceived = false + // Get the latest timeouts from the toml configuration + SetDefaultTimeouts(vendingState, edgexcontext.Configuration.ApplicationSettings, edgexcontext.LoggingClient) + + // Wait for the door open event to be received. If we don't receive the door open event within the timeout + // then leave the workflow state and remove all user data + go func() { + for { + select { + case <-time.After(time.Duration(vendingState.DoorOpenStateTimeout) * time.Second): + if !vendingState.DoorOpenedDuringCVWorkflow { + edgexcontext.LoggingClient.Info("door wasn't opened so we reset") + vendingState.CVWorkflowStarted = false + vendingState.CurrentUserData = OutputData{} + } + edgexcontext.LoggingClient.Info("Card scan: Waiting for open event", "workflow:", vendingState.CVWorkflowStarted, "maintenance mode:", vendingState.MaintenanceMode, "open:", vendingState.DoorOpenedDuringCVWorkflow, "closed:", vendingState.DoorClosedDuringCVWorkflow, "Inference:", vendingState.InferenceDataReceived, "door:", vendingState.DoorClosed) + return + + case <-vendingState.DoorOpenWaitThreadStopChannel: + edgexcontext.LoggingClient.Info("Stopped the door open wait thread") + return + + case <-vendingState.ThreadStopChannel: + edgexcontext.LoggingClient.Info("Globally stopped the door open wait thread") + return + } + } + }() + } else { + // Display row 1 command URL + commandURL, ok := edgexcontext.Configuration.ApplicationSettings["DeviceControllerBoarddisplayRow1"] + if !ok { + return false, fmt.Errorf("DeviceControllerBoard Application setting not found") + } + // Display out of order when door waiting state is set to false + resp, err := sendCommand(edgexcontext, "PUT", commandURL, []byte("{\"displayRow1\":\"Out of Order\"}")) + if err != nil { + return false, err + } + defer resp.Body.Close() + } + + } + // Check the role of the card scanned. Role 3 = maintainer + case 3: + { + close(vendingState.ThreadStopChannel) + vendingState.ThreadStopChannel = make(chan int) + + edgexcontext.LoggingClient.Info(eventReading.Name + " readable value from " + event.Device + " is " + eventReading.Value) + // Display row 2 command URL + commandURL, ok := edgexcontext.Configuration.ApplicationSettings["DeviceControllerBoarddisplayRow2"] + if !ok { + return false, fmt.Errorf("DeviceControllerBoard Application setting not found") + } + // Send lock command + respRow2, err := sendCommand(edgexcontext, "PUT", commandURL, []byte("{\"displayRow2\":\"Maintenance Mode\"}")) + if err != nil { + return false, err + } + defer respRow2.Body.Close() + + // Display row 3 command URL + commandURL, ok = edgexcontext.Configuration.ApplicationSettings["DeviceControllerBoarddisplayRow3"] + if !ok { + return false, fmt.Errorf("DeviceControllerBoard Application setting not found") + } + // Send lock command + respRow3, err := sendCommand(edgexcontext, "PUT", commandURL, []byte("{\"displayRow3\":\""+eventReading.Value+"\"}")) + if err != nil { + return false, err + } + defer respRow3.Body.Close() + + // Lock command URL + commandURL, ok = edgexcontext.Configuration.ApplicationSettings["DeviceControllerBoardLock1"] + if !ok { + return false, fmt.Errorf("DeviceControllerBoard Application setting not found") + } + // Send lock command + respLock, err := sendCommand(edgexcontext, "PUT", commandURL, []byte("{\"lock1\":\"true\"}")) + if err != nil { + return false, err + } + defer respLock.Body.Close() + + vendingState.MaintenanceMode = false + vendingState.CVWorkflowStarted = false + vendingState.DoorClosedDuringCVWorkflow = false + vendingState.DoorOpenedDuringCVWorkflow = false + vendingState.InferenceDataReceived = false + edgexcontext.LoggingClient.Info("Maintenance Scan: ", "workflow:", vendingState.CVWorkflowStarted, "maintenance mode:", vendingState.MaintenanceMode, "open:", vendingState.DoorOpenedDuringCVWorkflow, "closed:", vendingState.DoorClosedDuringCVWorkflow, "Inference:", vendingState.InferenceDataReceived, "door:", vendingState.DoorClosed) + } + default: + // Display row 2 command URL + commandURL, ok := edgexcontext.Configuration.ApplicationSettings["DeviceControllerBoarddisplayRow2"] + if !ok { + return false, fmt.Errorf("DeviceControllerBoard Application setting not found") + } + resp, err := sendCommand(edgexcontext, "PUT", commandURL, []byte("{\"displayRow2\":\"Unauthorized\"}")) + defer resp.Body.Close() + if err != nil { + return false, err + } + edgexcontext.LoggingClient.Info("Invalid card: " + eventReading.Value) + } + } + } + return true, event // Continues the functions pipeline execution with the current event +} + +func checkInferenceStatus(edgexcontext *appcontext.Context, heartbeatEndPoint string) bool { + resp, err := sendCommand(edgexcontext, "GET", heartbeatEndPoint, []byte("")) + if err != nil { + return false + } + defer resp.Body.Close() + + return true +} + +func (vendingState *VendingState) getCardAuthInfo(edgexcontext *appcontext.Context, authEndpoint string, cardID string) { + // Push the authenticated user info to the current vendingState + // First, reset it, then populate it at the end of the function + vendingState.CurrentUserData = OutputData{} + + resp, err := sendCommand(edgexcontext, "GET", authEndpoint+"/"+cardID, []byte("")) + if err != nil { + edgexcontext.LoggingClient.Info("Unauthorized card: " + cardID) + return + } + + defer resp.Body.Close() + + var auth OutputData + _, err = utilities.ParseJSONHTTPResponseContent(resp.Body, &auth) + if err != nil { + edgexcontext.LoggingClient.Error("Could not read response body from AuthenticationEndpoint") + return + } + + // Set the door waiting state to false while processing a use + vendingState.CurrentUserData = auth + edgexcontext.LoggingClient.Info("Successfully found user data for card " + cardID) +} + +func displayLedger(edgexcontext *appcontext.Context, ledger Ledger) error { + // string conversion error + var strToIntErr error + // Get LCDRowLength value + LCDRowLength, strToIntErr := strconv.Atoi(edgexcontext.Configuration.ApplicationSettings["LCDRowLength"]) + if strToIntErr != nil { + LCDRowLength = 19 + edgexcontext.LoggingClient.Error("LCD Row Length not set in configuration. Using default value of %v", LCDRowLength) + } + + // Get commandURL to reset LCD + displayResetCommandURL, ok := edgexcontext.Configuration.ApplicationSettings["DeviceControllerBoarddisplayReset"] + if !ok { + return fmt.Errorf("DeviceControllerBoarddisplayReset setting not found") + } + // reset LCD + resp, err := sendCommand(edgexcontext, "PUT", displayResetCommandURL, []byte("{\"displayReset\":\"\"}")) + if err != nil { + return fmt.Errorf("sendCommand returned error for %v : %v", displayResetCommandURL, err.Error()) + } + defer resp.Body.Close() + + // Get command url for LCD Row 1 + row1CommandURL, ok := edgexcontext.Configuration.ApplicationSettings["DeviceControllerBoarddisplayRow1"] + if !ok { + return fmt.Errorf("DeviceControllerBoard Application setting not found") + } + // Loop through lineItems in Ledger and display on LCD + for _, lineItem := range ledger.LineItems { + // Line Item is item count and product name, and truncated or padded with whitespaces so it is same length as LCD Row + displayLineItem := fmt.Sprintf("%-[1]*.[1]*s", LCDRowLength, strconv.Itoa(lineItem.ItemCount)+" "+lineItem.ProductName) + // push line item to LCD and pause three seconds before displaying next line item + resp, err := sendCommand(edgexcontext, "PUT", row1CommandURL, []byte("{\"displayRow1\":\""+displayLineItem+"\"}")) + if err != nil { + return fmt.Errorf("sendCommand returned nil for %v : %v", row1CommandURL, err.Error()) + } + defer resp.Body.Close() + + time.Sleep(3 * time.Second) + } + + //reset the LCD + respDisplayReset, err := sendCommand(edgexcontext, "PUT", displayResetCommandURL, []byte("{\"displayReset\":\"\"}")) + if err != nil { + return fmt.Errorf("sendCommand returned nil for %v : %v", displayResetCommandURL, err.Error()) + } + defer respDisplayReset.Body.Close() + + //display ledger.LineTotal from in currency format + displayLedgerTotal := "Total: $" + fmt.Sprintf("%3.2f", ledger.LineTotal) + respDisplayRow, err := sendCommand(edgexcontext, "PUT", row1CommandURL, []byte("{\"displayRow1\":\""+displayLedgerTotal+"\"}")) + if err != nil { + return fmt.Errorf("sendCommand returned nil for %v : %v", row1CommandURL, err.Error()) + } + defer respDisplayRow.Body.Close() + + return nil +} + +// sendCommand will make a http request based on the input parameters +func sendCommand(edgexcontext *appcontext.Context, method string, commandURL string, inputBytes []byte) (*http.Response, error) { + edgexcontext.LoggingClient.Debug("SendCommand") + + connectionTimeout := 15 + // Create the http request based on the parameters + request, _ := http.NewRequest(method, commandURL, bytes.NewBuffer(inputBytes)) + timeout := time.Duration(connectionTimeout) * time.Second + client := &http.Client{ + Timeout: timeout, + } + + // Execute the http request + resp, err := client.Do(request) + if err != nil { + return resp, fmt.Errorf("Error sending DeviceControllerBoard: %v", err.Error()) + } + + // Check the status code and return any errors + if resp.StatusCode != http.StatusOK { + return resp, fmt.Errorf("Error sending DeviceControllerBoard: Received status code %v", resp.Status) + } + + return resp, nil +} + +// BoardStatus endpoint that handles board status events from the controller board status application service +func (vendingState *VendingState) BoardStatus(writer http.ResponseWriter, req *http.Request) { + writer.Header().Set("Content-Type", "text/plain") + var status int + + // Read request body + body := make([]byte, req.ContentLength) + _, err := io.ReadFull(req.Body, body) + if err != nil { + fmt.Printf("Failed to read request data\n") + } + + // Unmarshal the string contents of request into a proper structure + var boardStatus ControllerBoardStatus + if err := json.Unmarshal(body, &boardStatus); err != nil { + fmt.Printf("Failed to read request data\n") + } + returnval := "Board status received but maintenance mode was not set" + status = http.StatusOK + + // Check controller board MinTemperatureStatus state. If it's true then a minimum temperature event has happened + if boardStatus.MinTemperatureStatus { + returnval = string("Temperature status received and maintenance mode was set") + status = http.StatusOK + fmt.Println("Cooler temperature exceeds the minimum temperature threshold. The cooler needs maintenance.") + vendingState.MaintenanceMode = true + } + // Check controller board MaxTemperatureStatus state. If it's true then a maximum temperature event has happened + if boardStatus.MaxTemperatureStatus { + returnval = string("Temperature status received and maintenance mode was set") + status = http.StatusOK + fmt.Println("Cooler temperature exceeds the maximum temperature threshold. The cooler needs maintenance.") + vendingState.MaintenanceMode = true + } + + // Check to see if the board closed state is different than the previous state. If it is we need to update the state and + // set the related properties. + if vendingState.DoorClosed != boardStatus.DoorClosed { + fmt.Println("Successfully updated the door event. Door closed:", boardStatus.DoorClosed) + returnval = string("Door closed change event was received ") + status = http.StatusOK //FIXME: This is an issue + vendingState.DoorClosed = boardStatus.DoorClosed + if vendingState.CVWorkflowStarted { + // If the door was opened then we want to wait for the door closed event + if !boardStatus.DoorClosed { + vendingState.DoorOpenedDuringCVWorkflow = true + // Stop the open wait thread since the door is now opened + close(vendingState.DoorOpenWaitThreadStopChannel) + vendingState.DoorOpenWaitThreadStopChannel = make(chan int) + + // Wait for door closed event. If the door isn't closed within the timeout + // then leave the workflow, remove the user data, and enter maintenance mode + go func() { + fmt.Println("Door Opened: wait for ", vendingState.DoorCloseStateTimeout, " seconds") + for { + select { + case <-time.After(time.Duration(vendingState.DoorCloseStateTimeout) * time.Second): + { + if !vendingState.DoorClosedDuringCVWorkflow { + fmt.Println("Door Opened: Failed") + vendingState.CVWorkflowStarted = false + vendingState.CurrentUserData = OutputData{} + vendingState.MaintenanceMode = true + } + // TODO: remove print + fmt.Println("Door Opened: waiting for door closed event", "workflow:", vendingState.CVWorkflowStarted, "maintenance mode:", vendingState.MaintenanceMode, "open:", vendingState.DoorOpenedDuringCVWorkflow, "closed:", vendingState.DoorClosedDuringCVWorkflow, "Inference:", vendingState.InferenceDataReceived, "door:", vendingState.DoorClosed) + return + } + case <-vendingState.DoorCloseWaitThreadStopChannel: + fmt.Println("Stopped the door closed wait thread") + return + + case <-vendingState.ThreadStopChannel: + fmt.Println("Globally stopped the door closed wait thread") + return + } + } + }() + } + // If the door was closed we want to wait for the inference event + if boardStatus.DoorClosed { + vendingState.DoorClosedDuringCVWorkflow = true + // Stop the open wait thread since the door is now opened + close(vendingState.DoorCloseWaitThreadStopChannel) + vendingState.DoorCloseWaitThreadStopChannel = make(chan int) + + // Wait for the inference data to be received. If we don't receive any inference data with the timeout + // then leave the workflow, remove the user data, and enter maintenance mode + go func() { + fmt.Println("Door Closed: wait for ", vendingState.InferenceTimeout, " seconds") + for { + select { + case <-time.After(time.Duration(vendingState.InferenceTimeout) * time.Second): + + { + if !vendingState.InferenceDataReceived { + fmt.Println("Door Closed: Failed") + vendingState.CVWorkflowStarted = false + vendingState.CurrentUserData = OutputData{} + vendingState.MaintenanceMode = true + } + // TODO: remove print + fmt.Println("Door Closed: waiting for door closed event", "workflow:", vendingState.CVWorkflowStarted, "maintenance mode:", vendingState.MaintenanceMode, "open:", vendingState.DoorOpenedDuringCVWorkflow, "closed:", vendingState.DoorClosedDuringCVWorkflow, "Inference:", vendingState.InferenceDataReceived, "door:", vendingState.DoorClosed) + return + } + case <-vendingState.InferenceWaitThreadStopChannel: + fmt.Println("Stopped the inference wait thread") + return + + case <-vendingState.ThreadStopChannel: + fmt.Println("Globally stopped the inference wait thread") + return + } + } + }() + } + } + } + + // Write the HTTP status header + writer.WriteHeader(status) + + _, writeErr := writer.Write([]byte(returnval)) + if writeErr != nil { + fmt.Printf("Failed to write item data back to caller\n") + } +} + +// ResetDoorLock endpoint to reset all door lock states +func (vendingState *VendingState) ResetDoorLock(writer http.ResponseWriter, req *http.Request) { + writer.Header().Set("Content-Type", "text/plain") + // Check the HTTP Request's form values + returnval := "reset the door lock" + + close(vendingState.ThreadStopChannel) + vendingState.ThreadStopChannel = make(chan int) + + vendingState.MaintenanceMode = false + vendingState.CVWorkflowStarted = false + vendingState.DoorClosed = false + vendingState.DoorClosedDuringCVWorkflow = false + vendingState.DoorOpenedDuringCVWorkflow = false + vendingState.InferenceDataReceived = false + + fmt.Println("Maintenance card scanned: reset everything", + "workflow:", vendingState.CVWorkflowStarted, + "maintenance mode:", vendingState.MaintenanceMode, + "open:", vendingState.DoorOpenedDuringCVWorkflow, + "closed:", vendingState.DoorClosedDuringCVWorkflow, + "Inference:", vendingState.InferenceDataReceived, + "door:", vendingState.DoorClosed, + ) + + // Write the HTTP status header + writer.WriteHeader(http.StatusOK) + + _, writeErr := writer.Write([]byte(returnval)) + if writeErr != nil { + fmt.Printf("Failed to write item data back to caller\n") + } + +} + +// SetDefaultTimeouts set the timeout values based on the toml configuration. If the value is not found use a default value +func SetDefaultTimeouts(vendingState *VendingState, appSettings map[string]string, loggingClient logger.LoggingClient) { + // string conversion error + var strToIntErr error + + // door open event + openTimeout, strToIntErr := strconv.Atoi(appSettings["DoorOpenStateTimeout"]) + if strToIntErr != nil { + openTimeout = DefaultTimeOuts + loggingClient.Error(fmt.Sprintf("Door Open event timeout not set in configuration. Using default value of %v", openTimeout)) + } + vendingState.DoorOpenStateTimeout = openTimeout + + // door close event + closeTimeout, strToIntErr := strconv.Atoi(appSettings["DoorCloseStateTimeout"]) + if strToIntErr != nil { + closeTimeout = DefaultTimeOuts + loggingClient.Error(fmt.Sprintf("Door close event timeout not set in configuration. Using default value of %v", closeTimeout)) + } + vendingState.DoorCloseStateTimeout = closeTimeout + + // inference event + inferenceTimeout, strToIntErr := strconv.Atoi(appSettings["InferenceTimeout"]) + if strToIntErr != nil { + inferenceTimeout = DefaultTimeOuts + loggingClient.Error(fmt.Sprintf("Door close event timeout not set in configuration. Using default value of %v", inferenceTimeout)) + } + vendingState.InferenceTimeout = inferenceTimeout +} + +// GetMaintenanceMode will return a JSON response containing the boolean state +// of the vendingState's maintenance mode. +func (vendingState *VendingState) GetMaintenanceMode(writer http.ResponseWriter, req *http.Request) { + utilities.ProcessCORS(writer, req, func(writer http.ResponseWriter, req *http.Request) { + mm, _ := utilities.GetAsJSON(MaintenanceMode{MaintenanceMode: vendingState.MaintenanceMode}) + utilities.WriteJSONHTTPResponse(writer, req, http.StatusOK, mm, false) + }) +} diff --git a/as-vending/functions/output_test.go b/as-vending/functions/output_test.go new file mode 100644 index 0000000..a68d28c --- /dev/null +++ b/as-vending/functions/output_test.go @@ -0,0 +1,413 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package functions + +import ( + "bytes" + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "net/http/httptest" + "os" + "testing" + + "github.com/edgexfoundry/app-functions-sdk-go/appcontext" + "github.com/edgexfoundry/go-mod-core-contracts/clients/coredata" + "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/models" + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +var eventClient coredata.EventClient + +var edgexcontext appcontext.Context + +func TestMain(m *testing.M) { + edgexcontext.CorrelationID = "correlationId" + edgexcontext.EventClient = eventClient + edgexcontext.LoggingClient = logger.NewClient("output_test", false, "", "DEBUG") + err := m.Run() + os.Exit(err) +} + +// TestGetMaintenanceMode tests the HTTP GET endpoint '/maintenanceMode' to +// verify that it reports the correct value of MaintenanceMode in its instance +// of VendingState. +func TestGetMaintenanceMode(t *testing.T) { + maintModeTrue := MaintenanceMode{ + MaintenanceMode: true, + } + maintModeFalse := MaintenanceMode{ + MaintenanceMode: false, + } + t.Run("TestGetMaintenanceMode MaintenanceMode=True", func(t *testing.T) { + var vendingState VendingState + var maintModeAPIResponse MaintenanceMode + + // set the vendingState's MaintenanceMode boolean accordingly + vendingState.MaintenanceMode = true + + req := httptest.NewRequest("GET", "/maintenanceMode", nil) + w := httptest.NewRecorder() + + // run the actual function in question + vendingState.GetMaintenanceMode(w, req) + + // parse the response + resp := w.Result() + _, err := utilities.ParseJSONHTTPResponseContent(resp.Body, &maintModeAPIResponse) + require.NoError(t, err) + + defer resp.Body.Close() + assert.Equal(t, maintModeAPIResponse, maintModeTrue, "Received a maintenance mode response that was different than anticipated") + }) + t.Run("TestGetMaintenanceMode MaintenanceMode=False", func(t *testing.T) { + var vendingState VendingState + var maintModeAPIResponse MaintenanceMode + + // set the vendingState's MaintenanceMode boolean accordingly + vendingState.MaintenanceMode = false + + req := httptest.NewRequest("GET", "/maintenanceMode", nil) + w := httptest.NewRecorder() + + // run the actual function in question + vendingState.GetMaintenanceMode(w, req) + + // parse the response + resp := w.Result() + _, err := utilities.ParseJSONHTTPResponseContent(resp.Body, &maintModeAPIResponse) + require.NoError(t, err) + + defer resp.Body.Close() + assert.Equal(t, maintModeAPIResponse, maintModeFalse, "Received a maintenance mode response that was different than anticipated") + }) + t.Run("TestGetMaintenanceMode OPTIONS", func(t *testing.T) { + var vendingState VendingState + + req := httptest.NewRequest("OPTIONS", "/maintenanceMode", nil) + w := httptest.NewRecorder() + + vendingState.GetMaintenanceMode(w, req) + + // parse the response + resp := w.Result() + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + require.NoError(t, err, "Parsing response body threw error") + assert.Equal(t, string(body), "", "Response body was not an empty string, expected it to be empty for a pre-flight CORS OPTIONS response") + assert.Equal(t, resp.Status, "200 OK", "OPTIONS request did not return 200") + }) +} + +func TestSetDefaultTimeouts(t *testing.T) { + testCases := []struct { + TestCaseName string + Settings map[string]string + Expected error + }{ + {"Success", map[string]string{"DoorOpenStateTimeout": "20", "DoorCloseStateTimeout": "20", "InferenceTimeout": "20"}, nil}, + + {"DoorOpenStateTimeout error", map[string]string{"DoorOpenStateTimeout": "somestring", "DoorCloseStateTimeout": "20", "InferenceTimeout": "20"}, + fmt.Errorf("Door Open event timeout not set in configuration. Using default value of %v", DefaultTimeOuts)}, + + {"DoorCloseStateTimeout error", map[string]string{"DoorOpenStateTimeout": "20", "DoorCloseStateTimeout": "somestring", "InferenceTimeout": "20"}, + fmt.Errorf("Door close event timeout not set in configuration. Using default value of %v", DefaultTimeOuts)}, + + {"InferenceTimeout error", map[string]string{"DoorOpenStateTimeout": "20", "DoorCloseStateTimeout": "20", "InferenceTimeout": "somestring"}, + fmt.Errorf("Door close event timeout not set in configuration. Using default value of %v", DefaultTimeOuts)}, + } + + for _, tc := range testCases { + t.Run(tc.TestCaseName, func(t *testing.T) { + SetDefaultTimeouts(&VendingState{}, tc.Settings, edgexcontext.LoggingClient) + }) + } +} + +func TestCheckInferenceStatus(t *testing.T) { + testCases := []struct { + TestCaseName string + statusCode int + Expected bool + }{ + {"Successful case", http.StatusOK, true}, + {"Negative case", http.StatusInternalServerError, false}, + } + + for _, tc := range testCases { + + t.Run(tc.TestCaseName, func(t *testing.T) { + + testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(tc.statusCode) + _, err := w.Write([]byte{}) + if err != nil { + t.Fatal(err.Error()) + } + })) + defer testServer.Close() + assert.Equal(t, tc.Expected, checkInferenceStatus(&edgexcontext, testServer.URL), "Expected value to match output") + }) + } + +} + +func TestGetCardAuthInfo(t *testing.T) { + testCases := []struct { + TestCaseName string + statusCode int + cardID string + Expected string + }{ + {"Successful case", http.StatusOK, "1234567890", "1234567890"}, + {"Internal error case", http.StatusInternalServerError, "1234567890", ""}, + } + + var vendingState VendingState + + for _, tc := range testCases { + + t.Run(tc.TestCaseName, func(t *testing.T) { + + testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + + output := OutputData{ + CardID: tc.cardID, + } + authDataJSON, _ := utilities.GetAsJSON(output) + utilities.WriteJSONHTTPResponse(w, r, tc.statusCode, authDataJSON, false) + })) + + defer testServer.Close() + vendingState.getCardAuthInfo(&edgexcontext, testServer.URL, tc.cardID) + assert.Equal(t, tc.Expected, vendingState.CurrentUserData.CardID, "Expected value to match output") + }) + } +} + +func TestResetDoorLock(t *testing.T) { + stopChannel := make(chan int) + var vendingState VendingState + vendingState.ThreadStopChannel = stopChannel + + request, _ := http.NewRequest("POST", "", nil) + recorder := httptest.NewRecorder() + handler := http.HandlerFunc(vendingState.ResetDoorLock) + handler.ServeHTTP(recorder, request) + + assert.Equal(t, false, vendingState.MaintenanceMode, "MaintanceMode should be false") + assert.Equal(t, false, vendingState.CVWorkflowStarted, "CVWorkflowStarted should be false") + assert.Equal(t, false, vendingState.DoorClosed, "DoorClosed should be false") + assert.Equal(t, false, vendingState.DoorClosedDuringCVWorkflow, "DoorClosedDuringCVWorkflow should be false") + assert.Equal(t, false, vendingState.DoorOpenedDuringCVWorkflow, "DoorOpenedDuringCVWorkflow should be false") + assert.Equal(t, false, vendingState.InferenceDataReceived, "InferenceDataReceived should be false") +} + +func TestDisplayLedger(t *testing.T) { + edgexcontext.Configuration.ApplicationSettings = make(map[string]string) + edgexcontext.Configuration.ApplicationSettings["LCDRowLength"] = "20" + // Http test servers + testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + _, err := w.Write([]byte{}) + if err != nil { + t.Fatal(err.Error()) + } + })) + + edgexcontext.Configuration.ApplicationSettings["DeviceControllerBoarddisplayReset"] = testServer.URL + edgexcontext.Configuration.ApplicationSettings["DeviceControllerBoarddisplayRow1"] = testServer.URL + + ledger := Ledger{ + LineItems: []LineItem{{ProductName: "itemX", ItemCount: 2, ItemPrice: 1.50, SKU: "1234"}}, + } + err := displayLedger(&edgexcontext, ledger) + assert.NoError(t, err) +} + +// TODO: BoardStatus handler needs to return proper http status code for unit tests +func TestBoardStatus(t *testing.T) { + doorOpenStopChannel := make(chan int) + doorCloseStopChannel := make(chan int) + + vendingState := VendingState{ + DoorClosed: false, + CVWorkflowStarted: true, + DoorOpenWaitThreadStopChannel: doorOpenStopChannel, + DoorCloseWaitThreadStopChannel: doorCloseStopChannel, + } + boardStatus := ControllerBoardStatus{ + MaxTemperatureStatus: true, + MinTemperatureStatus: true, + DoorClosed: true, + } + + b, _ := json.Marshal(boardStatus) + + request, _ := http.NewRequest("POST", "", bytes.NewBuffer(b)) + recorder := httptest.NewRecorder() + handler := http.HandlerFunc(vendingState.BoardStatus) + handler.ServeHTTP(recorder, request) +} + +func TestHandleMqttDeviceReading(t *testing.T) { + testCases := []struct { + TestCaseName string + statusCode int + Expected error + }{ + {"Successful case", http.StatusOK, nil}, + {"Internal error case", http.StatusInternalServerError, fmt.Errorf("Error sending DeviceControllerBoard: Received status code 500 Internal Server Error")}, + {"Bad request case", http.StatusBadRequest, fmt.Errorf("Error sending DeviceControllerBoard: Received status code 400 Bad Request")}, + } + + // edgexContext initialization + edgexctx := appcontext.Context{ + CorrelationID: "correlationId", + EventClient: eventClient, + LoggingClient: logger.NewClient("output_test", false, "", "DEBUG"), + } + edgexctx.Configuration.ApplicationSettings = make(map[string]string) + + // VendingState initialization + inferenceStopChannel := make(chan int) + stopChannel := make(chan int) + + vendingState := VendingState{ + InferenceWaitThreadStopChannel: inferenceStopChannel, + ThreadStopChannel: stopChannel, + CurrentUserData: OutputData{RoleID: 1}, + } + + event := models.Event{ + Device: InferenceMQTTDevice, + Readings: []models.Reading{{Name: "inferenceSkuDelta", Value: `[{"SKU": "HXI86WHU", "delta": -2}]`}}, + } + + for _, tc := range testCases { + + t.Run(tc.TestCaseName, func(t *testing.T) { + + testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + output := Ledger{ + IsPaid: false, + LineItems: []LineItem{}, + TransactionID: 123, + LineTotal: 20.5, + } + + outputJSON, _ := utilities.GetAsJSON(output) + + writeError := false + writeContentType := "json" + if tc.Expected != nil { + writeError = true + writeContentType = "string" + } + + httpResponse := utilities.HTTPResponse{ + Content: outputJSON, + ContentType: writeContentType, + StatusCode: tc.statusCode, + Error: writeError, + } + + httpResponse.WriteHTTPResponse(w, r) + })) + + edgexctx.Configuration.ApplicationSettings["InventoryService"] = testServer.URL + edgexctx.Configuration.ApplicationSettings["InventoryAuditLogService"] = testServer.URL + edgexctx.Configuration.ApplicationSettings["DeviceControllerBoarddisplayReset"] = testServer.URL + edgexctx.Configuration.ApplicationSettings["DeviceControllerBoarddisplayRow1"] = testServer.URL + edgexctx.Configuration.ApplicationSettings["LedgerService"] = testServer.URL + + _, err := vendingState.HandleMqttDeviceReading(&edgexctx, event) + + e, ok := err.(error) + if ok { + assert.Equal(t, tc.Expected, e) + } + + }) + } +} + +func TestVerifyDoorAccess(t *testing.T) { + testCases := []struct { + TestCaseName string + StatusCode int + MaintenanceMode bool + RoleID int + }{ + {"Successful case", http.StatusOK, false, 1}, + {"MaintanceMode on", http.StatusOK, true, 1}, + {"Role 3", http.StatusOK, false, 3}, + } + + // edgexContext initialization + edgexctx := appcontext.Context{ + CorrelationID: "correlationId", + EventClient: eventClient, + LoggingClient: logger.NewClient("output_test", false, "", "DEBUG"), + } + edgexctx.Configuration.ApplicationSettings = make(map[string]string) + + // VendingState initialization + inferenceStopChannel := make(chan int) + stopChannel := make(chan int) + + event := models.Event{ + Device: "ds-card-reader", + Readings: []models.Reading{{Name: "ds-card-reader", Value: `[{"SKU": "HXI86WHU", "delta": -2}]`}}, + } + + testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + _, err := w.Write(nil) + assert.NoError(t, err) + })) + + for _, tc := range testCases { + + t.Run(tc.TestCaseName, func(t *testing.T) { + + authServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + output := OutputData{ + RoleID: tc.RoleID, + } + authDataJSON, _ := utilities.GetAsJSON(output) + utilities.WriteJSONHTTPResponse(w, r, http.StatusOK, authDataJSON, false) + })) + + edgexctx.Configuration.ApplicationSettings["InferenceHeartbeat"] = testServer.URL + edgexctx.Configuration.ApplicationSettings["DeviceControllerBoarddisplayRow1"] = testServer.URL + edgexctx.Configuration.ApplicationSettings["DeviceControllerBoarddisplayRow2"] = testServer.URL + edgexctx.Configuration.ApplicationSettings["DeviceControllerBoarddisplayRow3"] = testServer.URL + edgexctx.Configuration.ApplicationSettings["DeviceControllerBoardLock1"] = testServer.URL + + edgexctx.Configuration.ApplicationSettings["AuthenticationEndpoint"] = authServer.URL + + vendingState := VendingState{ + InferenceWaitThreadStopChannel: inferenceStopChannel, + ThreadStopChannel: stopChannel, + CurrentUserData: OutputData{RoleID: 1}, + CVWorkflowStarted: false, + MaintenanceMode: tc.MaintenanceMode, + } + + _, err := vendingState.VerifyDoorAccess(&edgexctx, event) + + e, ok := err.(error) + if ok { + assert.NoError(t, e) + } + }) + } +} diff --git a/as-vending/go.mod b/as-vending/go.mod new file mode 100644 index 0000000..1c74fc5 --- /dev/null +++ b/as-vending/go.mod @@ -0,0 +1,13 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +module as-vending + +go 1.12 + +require ( + github.com/edgexfoundry/app-functions-sdk-go v1.0.0 + github.com/edgexfoundry/go-mod-core-contracts v0.1.25 + github.com/intel-iot-devkit/automated-checkout-utilities v1.0.0 + github.com/stretchr/testify v1.5.1 +) diff --git a/as-vending/main.go b/as-vending/main.go new file mode 100644 index 0000000..24f0f96 --- /dev/null +++ b/as-vending/main.go @@ -0,0 +1,112 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package main + +import ( + "fmt" + "os" + "strings" + + "as-vending/functions" + + "github.com/edgexfoundry/app-functions-sdk-go/appsdk" + "github.com/edgexfoundry/app-functions-sdk-go/pkg/transforms" +) + +const ( + serviceKey = "as-vending" +) + +func main() { + // Create an instance of the EdgeX SDK and initialize it. + edgexSdk := &appsdk.AppFunctionsSDK{ServiceKey: serviceKey} + if err := edgexSdk.Initialize(); err != nil { + edgexSdk.LoggingClient.Error(fmt.Sprintf("SDK initialization failed: %v\n", err)) + os.Exit(-1) + } + + // How to access the application's specific configuration settings. + appSettings := edgexSdk.ApplicationSettings() + if appSettings == nil { + edgexSdk.LoggingClient.Error("No application settings found") + os.Exit(-1) + } + + // Get the device name from the app settings. This could have multiple devices to listen to. + deviceNameList, ok := appSettings["DeviceName"] + if !ok { + edgexSdk.LoggingClient.Error("DeviceName application setting not found") + os.Exit(-1) + } + + // Clean up the device list from the toml file and put them in a string array + deviceNameList = strings.Replace(deviceNameList, " ", "", -1) + deviceName := strings.Split(deviceNameList, ",") + edgexSdk.LoggingClient.Info(fmt.Sprintf("Running the application functions for %v devices...", deviceName)) + + // Create stop channels for each of the wait threads + stopChannel := make(chan int) + doorOpenStopChannel := make(chan int) + doorCloseStopChannel := make(chan int) + inferenceStopChannel := make(chan int) + + // Set default values for vending state + var vendingState functions.VendingState + vendingState.CVWorkflowStarted = false + vendingState.MaintenanceMode = false + vendingState.CurrentUserData = functions.OutputData{} + vendingState.DoorClosed = true + // global stop channel for threads + vendingState.ThreadStopChannel = stopChannel + // open event thread + vendingState.DoorOpenedDuringCVWorkflow = false + vendingState.DoorOpenWaitThreadStopChannel = doorOpenStopChannel + // close event thread + vendingState.DoorClosedDuringCVWorkflow = false + vendingState.DoorCloseWaitThreadStopChannel = doorCloseStopChannel + // inference thread + vendingState.InferenceDataReceived = false + vendingState.InferenceWaitThreadStopChannel = inferenceStopChannel + + functions.SetDefaultTimeouts(&vendingState, appSettings, edgexSdk.LoggingClient) + + var err error + + err = edgexSdk.AddRoute("/boardStatus", vendingState.BoardStatus, "POST") + errorAddRouteHandler(edgexSdk, err) + + err = edgexSdk.AddRoute("/resetDoorLock", vendingState.ResetDoorLock, "POST") + errorAddRouteHandler(edgexSdk, err) + + err = edgexSdk.AddRoute("/maintenanceMode", vendingState.GetMaintenanceMode, "GET", "OPTIONS") + errorAddRouteHandler(edgexSdk, err) + + // Create the function pipeline to run when an event is read on the device channels + err = edgexSdk.SetFunctionsPipeline( + transforms.NewFilter(deviceName).FilterByDeviceName, + vendingState.DeviceHelper, + ) + if err != nil { + edgexSdk.LoggingClient.Error("SDK initialization failed: " + err.Error()) + os.Exit(-1) + } + + // Tell the SDK to "start" and begin listening for events to trigger the pipeline. + err = edgexSdk.MakeItRun() + if err != nil { + edgexSdk.LoggingClient.Error("MakeItRun returned error: ", err.Error()) + os.Exit(-1) + } + + // Do any required cleanup here + + os.Exit(0) +} + +func errorAddRouteHandler(edgexSdk *appsdk.AppFunctionsSDK, err error) { + if err != nil { + edgexSdk.LoggingClient.Error("Error adding route: %v", err.Error()) + os.Exit(-1) + } +} diff --git a/as-vending/res/configuration.toml b/as-vending/res/configuration.toml new file mode 100644 index 0000000..98c7292 --- /dev/null +++ b/as-vending/res/configuration.toml @@ -0,0 +1,63 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +[Writable] +LogLevel = 'INFO' + +[Service] +BootTimeout = '30s' +ClientMonitor = '15s' +CheckInterval = '10s' +Host = 'localhost' +Port = 8080 +Protocol = 'http' +ReadMaxLimit = 100 +StartupMsg = 'This is an Application Service which reads card inputs and publishes lock status back to message bus' +Timeout = '30s' + +[Registry] +Host = 'localhost' +Port = 8500 +Type = 'consul' + +[MessageBus] +Type = 'zero' + [MessageBus.PublishHost] + Host = '*' + Port = 5564 + Protocol = 'tcp' + [MessageBus.SubscribeHost] + Host = 'localhost' + Port = 5563 + Protocol = 'tcp' + +[Logging] +EnableRemote = false +File = './logs/app-ds-card-reader-publish.log' + +# This example depends on events generated by Device-Virtual-Go, so must use MessageBus trigger. +# It will publish back to the bus on the "converted" topic +[Binding] +Type="messagebus" +SubscribeTopic="" +PublishTopic="" + +[ApplicationSettings] + DeviceName = "ds-card-reader,Inference-MQTT-device" + DeviceControllerBoardLock1 = "http://localhost:48082/api/v1/device/name/device-controller-board/command/lock1" + DeviceControllerBoardLock2 = "http://localhost:48082/api/v1/device/name/device-controller-board/command/lock2" + DeviceControllerBoarddisplayRow0 = "http://localhost:48082/api/v1/device/name/device-controller-board/command/displayRow0" + DeviceControllerBoarddisplayRow1 = "http://localhost:48082/api/v1/device/name/device-controller-board/command/displayRow1" + DeviceControllerBoarddisplayRow2 = "http://localhost:48082/api/v1/device/name/device-controller-board/command/displayRow2" + DeviceControllerBoarddisplayRow3 = "http://localhost:48082/api/v1/device/name/device-controller-board/command/displayRow3" + DeviceControllerBoarddisplayReset = "http://localhost:48082/api/v1/device/name/ds-controller-board/command/displayReset" + AuthenticationEndpoint = "http://localhost:8080/authentication" + InferenceHeartbeat = "http://localhost:48082/api/v1/device/name/Inference-MQTT-device/command/inferenceHeartbeat" + InferenceDoorStatus = "http://localhost:48082/api/v1/device/name/Inference-MQTT-device/command/inferenceDoorStatus" + LedgerService = "http://localhost:48093/ledger" + InventoryService = "http://localhost:48095/inventory/delta" + InventoryAuditLogService = "http://localhost:48095/auditlog" + DoorOpenStateTimeout = "15" + DoorCloseStateTimeout = "20" + InferenceTimeout = "20" + LCDRowLength = "19" diff --git a/as-vending/res/docker/configuration.toml b/as-vending/res/docker/configuration.toml new file mode 100644 index 0000000..b9d5c07 --- /dev/null +++ b/as-vending/res/docker/configuration.toml @@ -0,0 +1,68 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +[Writable] +LogLevel = 'INFO' + +[Service] +BootTimeout = '30s' +ClientMonitor = '15s' +CheckInterval = '10s' +Host = 'as-vending' +Port = 48099 +Protocol = 'http' +ReadMaxLimit = 100 +StartupMsg = 'This is an Application Service which reads card inputs and publishes lock status back to message bus' +Timeout = '30s' + +[Clients] + [Clients.Logging] + Host = "edgex-support-logging" + Protocol = "http" + Port = 48061 + +[Registry] +Host = 'edgex-core-consul' +Port = 8500 +Type = 'consul' + +[MessageBus] +Type = 'zero' + [MessageBus.PublishHost] + Host = '*' + Port = 5564 + Protocol = 'tcp' + [MessageBus.SubscribeHost] + Host = 'edgex-core-data' + Port = 5563 + Protocol = 'tcp' + +[Logging] +EnableRemote = true + +# This example depends on events generated by Device-Virtual-Go, so must use MessageBus trigger. +# It will publish back to the bus on the "converted" topic +[Binding] +Type="messagebus" +SubscribeTopic="" +PublishTopic="" + +[ApplicationSettings] + DeviceName = "ds-card-reader,Inference-MQTT-device" + DeviceControllerBoardLock1 = "http://edgex-core-command:48082/api/v1/device/name/ds-controller-board/command/lock1" + DeviceControllerBoardLock2 = "http://edgex-core-command:48082/api/v1/device/name/ds-controller-board/command/lock2" + DeviceControllerBoarddisplayRow0 = "http://edgex-core-command:48082/api/v1/device/name/ds-controller-board/command/displayRow0" + DeviceControllerBoarddisplayRow1 = "http://edgex-core-command:48082/api/v1/device/name/ds-controller-board/command/displayRow1" + DeviceControllerBoarddisplayRow2 = "http://edgex-core-command:48082/api/v1/device/name/ds-controller-board/command/displayRow2" + DeviceControllerBoarddisplayRow3 = "http://edgex-core-command:48082/api/v1/device/name/ds-controller-board/command/displayRow3" + DeviceControllerBoarddisplayReset = "http://edgex-core-command:48082/api/v1/device/name/ds-controller-board/command/displayReset" + AuthenticationEndpoint = "http://ms-authentication:48096/authentication" + InferenceHeartbeat = "http://edgex-core-command:48082/api/v1/device/name/Inference-MQTT-device/command/inferenceHeartbeat" + InferenceDoorStatus = "http://edgex-core-command:48082/api/v1/device/name/Inference-MQTT-device/command/inferenceDoorStatus" + LedgerService = "http://ms-ledger:48093/ledger" + InventoryService = "http://ms-inventory:48095/inventory/delta" + InventoryAuditLogService = "http://ms-inventory:48095/auditlog" + DoorOpenStateTimeout = "15" + DoorCloseStateTimeout = "20" + InferenceTimeout = "20" + LCDRowLength = "19" diff --git a/docker-build-image/.gitignore b/docker-build-image/.gitignore new file mode 100644 index 0000000..fb6b7e0 --- /dev/null +++ b/docker-build-image/.gitignore @@ -0,0 +1,14 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, build with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +go.sum diff --git a/docker-build-image/Dockerfile b/docker-build-image/Dockerfile new file mode 100644 index 0000000..d5e9a21 --- /dev/null +++ b/docker-build-image/Dockerfile @@ -0,0 +1,22 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +FROM golang:1.12-alpine + +LABEL license='SPDX-License-Identifier: BSD-3-Clause' \ + copyright='Copyright (c) 2020: Intel' + + +# add git for go modules +RUN apk update && apk add --no-cache make git gcc libc-dev zeromq-dev linux-headers + +ENV GO111MODULE=on +WORKDIR /usr/local/bin/ + +# This caches the packages for use when building the other services. +# Update the go.mod file in this repo when a new package is added to one of the services. +# This will be obvious when building a service and the un-cached package it loaded every build. +COPY go.mod . +RUN go mod download + +CMD ["/bin/ash"] diff --git a/docker-build-image/LICENSE b/docker-build-image/LICENSE new file mode 100644 index 0000000..dbff156 --- /dev/null +++ b/docker-build-image/LICENSE @@ -0,0 +1,31 @@ +BSD 3-Clause License + +Copyright © 2020, Intel Corporation +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/docker-build-image/Makefile b/docker-build-image/Makefile new file mode 100644 index 0000000..6c29a57 --- /dev/null +++ b/docker-build-image/Makefile @@ -0,0 +1,16 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +SHELL := /bin/bash + +.PHONY: build + +MICROSERVICE= automated-checkout/build + +build: + docker build \ + --build-arg http_proxy \ + --build-arg https_proxy \ + -f Dockerfile \ + -t $(MICROSERVICE):latest \ + .; \ diff --git a/docker-build-image/go.mod b/docker-build-image/go.mod new file mode 100644 index 0000000..a23d874 --- /dev/null +++ b/docker-build-image/go.mod @@ -0,0 +1,31 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +module automated-checkout/build + +go 1.12 + +require ( + bitbucket.org/bertimus9/systemstat v0.0.0-20180207000608-0eeff89b0690 + github.com/BurntSushi/toml v0.3.1 + github.com/cenkalti/backoff v2.2.1+incompatible + + github.com/creack/goselect v0.1.0 + github.com/eclipse/paho.mqtt.golang v1.2.0 + // common + github.com/edgexfoundry/app-functions-sdk-go v1.0.0 + + // ds-card-reader + github.com/edgexfoundry/device-sdk-go v1.0.0 + github.com/edgexfoundry/go-mod-core-contracts v0.1.25 + github.com/edgexfoundry/go-mod-messaging v0.1.11 + github.com/edgexfoundry/go-mod-registry v0.1.11 + github.com/google/uuid v1.1.1 + github.com/gorilla/mux v1.7.2 + github.com/gvalkov/golang-evdev v0.0.0-20180516222720-b6f418b1fe5a + github.com/hashicorp/consul v1.4.2 + github.com/hashicorp/go-cleanhttp v0.5.1 + github.com/intel-iot-devkit/automated-checkout-utilities v1.0.0 + github.com/stretchr/testify v1.5.1 + github.com/ugorji/go v1.1.4 +) diff --git a/docker-compose.physical.card-reader.yml b/docker-compose.physical.card-reader.yml new file mode 100644 index 0000000..183ab49 --- /dev/null +++ b/docker-compose.physical.card-reader.yml @@ -0,0 +1,22 @@ +--- + +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +version: '3.4' + +services: + +################################################################# +# Automated Checkout Microservices +################################################################# + + # this device service must be run as root to mount the device + ds-card-reader: + user: "0:0" + devices: + - /dev/input:/dev/input + environment: + Driver_SimulateDevice: "false" + +... diff --git a/docker-compose.physical.controller-board.yml b/docker-compose.physical.controller-board.yml new file mode 100644 index 0000000..e757c0c --- /dev/null +++ b/docker-compose.physical.controller-board.yml @@ -0,0 +1,21 @@ +--- + +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +version: '3.4' + +services: + +################################################################# +# Automated Checkout Microservices +################################################################# + + # this device service must be run as root to mount the device + ds-controller-board: + user: "0:0" + devices: + - /dev/ttyACM0:/dev/ttyACM0 + environment: + Driver_VirtualControllerBoard: "false" +... diff --git a/docker-compose.portainer.yml b/docker-compose.portainer.yml new file mode 100644 index 0000000..38293d0 --- /dev/null +++ b/docker-compose.portainer.yml @@ -0,0 +1,18 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause +version: '3.4' + +volumes: + portainer_data: + +services: + portainer: + image: portainer/portainer + container_name: portainer + ports: + - "127.0.0.1:9000:9000" + command: -H unix:///var/run/docker.sock + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - portainer_data:/data + restart: "on-failure:5" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4213d21 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,316 @@ +--- + +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +version: '3.4' + +# all common shared environment variables defined here: +x-common-env-variables: &common-variables + EDGEX_SECURITY_SECRET_STORE: "false" + edgex_registry: consul://edgex-core-consul:8500 + Clients_CoreData_Host: edgex-core-data + Clients_Logging_Host: edgex-support-logging + +x-logging: &logging + logging: + options: {max-file: '5', max-size: 100m} + +volumes: + db-data: + log-data: + consul-config: + consul-data: + portainer_data: + +services: + volume: + image: edgexfoundry/docker-edgex-volume:1.1.0 + container_name: edgex-files + volumes: + - db-data:/data/db:z + - log-data:/edgex/logs:z + - consul-config:/consul/config:z + - consul-data:/consul/data:z + restart: always + + consul: + image: consul:1.3.1 + container_name: edgex-core-consul + hostname: edgex-core-consul + volumes: + # The consul-config volume offers more security features like Kong, but + # this reference implementation does not use it. To prevent Kong service + # health checks from flooding DNS, the consul-config mount has been + # commented out. + # - consul-config:/consul/config:z + - consul-data:/consul/data:z + depends_on: + - volume + restart: always + ports: + - "127.0.0.1:8400:8400" + - "127.0.0.1:8500:8500" + - "127.0.0.1:8600:8600" + + config-seed: + image: edgexfoundry/docker-core-config-seed-go:1.1.0 + container_name: edgex-config-seed + hostname: edgex-core-config-seed + volumes: + - log-data:/edgex/logs:z + depends_on: + - volume + - consul + environment: + <<: *common-variables + Logging_EnableRemote: "true" + Smtp_Username: "your-email@site.com" + Smtp_Password: "SomePassword00000!" + Smtp_Sender: "your-email@site.com" + Smtp_Subject: "Automated Checkout Maintenance Alert" + + mongo: + image: edgexfoundry/docker-edgex-mongo:1.1.0 + container_name: edgex-mongo + hostname: edgex-mongo + environment: + <<: *common-variables + volumes: + - db-data:/data/db:z + depends_on: + - volume + restart: always + ports: + - "127.0.0.1:27017:27017" + + logging: + image: edgexfoundry/docker-support-logging-go:1.1.0 + container_name: edgex-support-logging + hostname: edgex-support-logging + environment: + <<: *common-variables + volumes: + - log-data:/edgex/logs:z + depends_on: + - config-seed + - mongo + - volume + restart: always + ports: + - "127.0.0.1:48061:48061" + + notifications: + image: edgexfoundry/docker-support-notifications-go:1.1.0 + container_name: edgex-support-notifications + hostname: edgex-support-notifications + environment: + <<: *common-variables + depends_on: + - logging + restart: always + ports: + - "127.0.0.1:48060:48060" + + metadata: + image: edgexfoundry/docker-core-metadata-go:1.1.0 + container_name: edgex-core-metadata + hostname: edgex-core-metadata + environment: + <<: *common-variables + depends_on: + - logging + restart: always + ports: + - "127.0.0.1:48081:48081" + + data: + image: edgexfoundry/docker-core-data-go:1.1.0 + container_name: edgex-core-data + hostname: edgex-core-data + environment: + <<: *common-variables + depends_on: + - logging + restart: always + ports: + - "127.0.0.1:48080:48080" + - "127.0.0.1:5563:5563" + + command: + image: edgexfoundry/docker-core-command-go:1.1.0 + container_name: edgex-core-command + hostname: edgex-core-command + environment: + <<: *common-variables + depends_on: + - metadata + restart: always + ports: + - "127.0.0.1:48082:48082" + +################################################################# +# Automated Checkout Microservices +################################################################# + + ds-card-reader: + user: "2000:2000" + image: "automated-checkout/ds-card-reader:dev" + container_name: automated-checkout_ds-card-reader + environment: + <<: *common-variables + <<: *logging + depends_on: + - data + - command + restart: always + ipc: none + ports: + - "127.0.0.1:48098:48098" + + as-vending: + user: "2000:2000" + image: "automated-checkout/as-vending:dev" + container_name: automated-checkout_as-vending + environment: + <<: *common-variables + <<: *logging + depends_on: + - data + - command + restart: always + ipc: none + ports: + - "127.0.0.1:48099:48099" + + ds-controller-board: + user: "2000:2000" + image: "automated-checkout/ds-controller-board:dev" + container_name: automated-checkout_ds-controller-board + environment: + <<: *common-variables + <<: *logging + depends_on: + - data + - command + restart: always + ipc: none + ports: + - "127.0.0.1:48097:48097" + + ms-authentication: + user: "2000:2000" + image: "automated-checkout/ms-authentication:dev" + container_name: automated-checkout_ms-authentication + environment: + <<: *common-variables + <<: *logging + depends_on: + - data + - command + restart: always + ipc: none + ports: + - "127.0.0.1:48096:48096" + + ms-ledger: + user: "2000:2000" + image: "automated-checkout/ms-ledger:dev" + container_name: automated-checkout_ms-ledger + environment: + <<: *common-variables + <<: *logging + depends_on: + - data + - command + restart: always + ipc: none + ports: + - "127.0.0.1:48093:48093" + + ms-inventory: + user: "2000:2000" + image: "automated-checkout/ms-inventory:dev" + container_name: automated-checkout_ms-inventory + depends_on: + - data + - command + environment: + <<: *common-variables + <<: *logging + restart: always + ipc: none + ports: + - "127.0.0.1:48095:48095" + + as-controller-board-status: + user: "2000:2000" + image: "automated-checkout/as-controller-board-status:dev" + container_name: automated-checkout_as-controller-board-status + environment: + <<: *common-variables + <<: *logging + depends_on: + - data + - command + restart: always + ipc: none + ports: + - "127.0.0.1:48094:48094" + + ds-inference-mock: + user: "2000:2000" + image: "automated-checkout/ds-inference-mock:dev" + container_name: automated-checkout_ds-inference-mock + environment: + <<: *common-variables + volumes: + - ./ds-inference-mock/sku_delta_sequence.json:/sku_delta_sequence.json:ro + command: --broker mqtt-broker --port 1883 --test_sequence sku_delta_sequence.json + <<: *logging + restart: always + ipc: none + ports: + - "127.0.0.1:1884:1883" + + + device-mqtt: + user: "2000:2000" + image: edgexfoundry/docker-device-mqtt-go:1.1.0 + container_name: edgex-device-mqtt + hostname: edgex-device-mqtt + environment: + <<: *common-variables + entrypoint: + - /device-mqtt + - --profile=docker + - --confdir=/res + <<: *logging + volumes: + - ./res/device-mqtt:/res:ro + depends_on: + - data + - command + restart: always + ipc: none + ports: + - "127.0.0.1:48100:48100" + + mqtt-broker: + image: eclipse-mosquitto:1.6.3 + container_name: mqtt-broker + volumes: + - ./res/mqtt/mosquitto.conf:/mosquitto/config/mosquitto.conf:ro + <<: *logging + depends_on: + - data + restart: always + ipc: none + ports: + - "127.0.0.1:1883:1883" + - "127.0.0.1:9001:9001" + +networks: + default: + +... diff --git a/docs/404.html b/docs/404.html new file mode 100644 index 0000000..e72aefe --- /dev/null +++ b/docs/404.html @@ -0,0 +1,421 @@ + + + + + + + + + + + + + + + + + + Automated Checkout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +
+ +
+ +
+ + + + + + +
+
+ + +
+
+
+ +
+
+
+ + + +
+
+ +

404 - Not found

+ + + + + + +
+
+
+
+ + + + +
+ + + + + + + + + + + \ No newline at end of file diff --git a/docs/assets/images/favicon.png b/docs/assets/images/favicon.png new file mode 100644 index 0000000..1cf13b9 Binary files /dev/null and b/docs/assets/images/favicon.png differ diff --git a/docs/assets/javascripts/bundle.eaaa3931.min.js b/docs/assets/javascripts/bundle.eaaa3931.min.js new file mode 100644 index 0000000..1f07cb3 --- /dev/null +++ b/docs/assets/javascripts/bundle.eaaa3931.min.js @@ -0,0 +1,2 @@ +!function(t,e){for(var n in e)t[n]=e[n]}(window,function(t){function e(e){for(var r,o,i=e[0],u=e[1],b=e[2],s=0,O=[];s0}function H(){return new _.a(new URL(location.href))}var R=n(111);function P(t,e){return e.location$.pipe(Object(R.a)(1),Object(j.a)((function(e){var n=e.href;return new URL(t,n).toString().replace(/\/$/,"")})),Object(p.a)(1))}function q(){return location.hash.substring(1)}function U(t){var e=s("a");e.href=t,e.addEventListener("click",(function(t){return t.stopPropagation()})),e.click()}function N(){return Object(c.a)(window,"hashchange").pipe(Object(j.a)(q),Object(d.a)(q()),Object(S.a)((function(t){return t.length>0})),Object(T.a)())}function I(t){var e=matchMedia(t);return Object(x.a)((function(t){return e.addListener((function(){return t(e.matches)}))})).pipe(Object(d.a)(e.matches),Object(p.a)(1))}var z={drawer:u("[data-md-toggle=drawer]"),search:u("[data-md-toggle=search]")};function V(t){return z[t].checked}function B(t,e){z[t].checked!==e&&z[t].click()}function D(t){var e=z[t];return Object(c.a)(e,"change").pipe(Object(j.a)((function(){return e.checked})),Object(d.a)(e.checked))}var J=n(58),K=n(86);function Y(){return{x:Math.max(0,pageXOffset),y:Math.max(0,pageYOffset)}}function F(t){var e=t.x,n=t.y;window.scrollTo(e||0,n||0)}function Q(){return{width:innerWidth,height:innerHeight}}function W(){return Object(J.a)([Object(l.a)(Object(c.a)(window,"scroll",{passive:!0}),Object(c.a)(window,"resize",{passive:!0})).pipe(Object(j.a)(Y),Object(d.a)(Y())),Object(c.a)(window,"resize",{passive:!0}).pipe(Object(j.a)(Q),Object(d.a)(Q()))]).pipe(Object(j.a)((function(t){var e=Object(w.h)(t,2);return{offset:e[0],size:e[1]}})),Object(p.a)(1))}function X(t,e){var n=e.header$,r=e.viewport$,c=r.pipe(Object(K.a)("size")),a=Object(J.a)([c,n]).pipe(Object(j.a)((function(){return{x:t.offsetLeft,y:t.offsetTop}})));return Object(J.a)([n,r,a]).pipe(Object(j.a)((function(t){var e=Object(w.h)(t,3),n=e[0].height,r=e[1],c=r.offset,a=r.size,o=e[2],i=o.x,u=o.y;return{offset:{x:c.x-i,y:c.y-u+n},size:a}})),Object(p.a)(1))}var Z=n(97),G=n(98),tt=n(78),et=n(99);function nt(t,e){var n=e.tx$,r=Object(x.a)((function(e){return t.addEventListener("message",e)})).pipe(Object(Z.a)("data"));return n.pipe(Object(G.a)((function(){return r}),{leading:!0,trailing:!0}),Object(tt.a)((function(e){return t.postMessage(e)})),Object(et.a)(r),Object(T.a)())}},,,function(t,e,n){"use strict";function r(t){return"object"==typeof t&&"string"==typeof t.base&&"object"==typeof t.features&&"object"==typeof t.search}n.d(e,"d",(function(){return r})),n.d(e,"b",(function(){return b})),n.d(e,"a",(function(){return O})),n.d(e,"f",(function(){return d})),n.d(e,"g",(function(){return p})),n.d(e,"e",(function(){return h})),n.d(e,"c",(function(){return v}));var c=n(0),a=n(77);function o(t){switch(t){case"svg":case"path":return document.createElementNS("http://www.w3.org/2000/svg",t);default:return document.createElement(t)}}function i(t,e,n){switch(e){case"xmlns":break;case"viewBox":case"d":"boolean"!=typeof n?t.setAttributeNS(null,e,n):n&&t.setAttributeNS(null,e,"");break;default:"boolean"!=typeof n?t.setAttribute(e,n):n&&t.setAttribute(e,"")}}function u(t,e){var n,r;if("string"==typeof e||"number"==typeof e)t.innerHTML+=e.toString();else if(e instanceof Node)t.appendChild(e);else if(Array.isArray(e))try{for(var a=Object(c.k)(e),o=a.next();!o.done;o=a.next()){u(t,o.value)}}catch(t){n={error:t}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}function b(t,e){for(var n,r,b,f,s=[],O=2;On){for(;" "!==t[n]&&--n>0;);return t.substring(0,n)+"..."}return t}function h(t){return t>999?((t+1e-6)/1e3).toFixed(+((t-950)%1e3>99))+"k":t.toString()}function v(t){for(var e=0,n=0,r=t.length;n code").forEach((function(t,e){var n=t.parentElement;n.id="__code_"+e,n.insertBefore(Object(f.a)(n.id),t)}))}));var O=Object(a.a)((function(t){new r(".md-clipboard").on("success",t)})).pipe(Object(o.a)());return O.pipe(Object(i.a)((function(t){return t.clearSelection()})),Object(u.a)(Object(s.f)("clipboard.copied"))).subscribe(n),O}var l=n(27),j=n(39),d=n(81),p=n(33),h=n(9),v=n(55),m=n(110);function y(t){var e=(void 0===t?{}:t).duration,n=new l.a,r=Object(b.a)("div");return r.classList.add("md-dialog","md-typeset"),n.pipe(Object(p.a)((function(t){return Object(j.a)(document.body).pipe(Object(h.a)((function(t){return t.appendChild(r)})),Object(v.b)(d.a),Object(m.a)(1),Object(i.a)((function(e){e.innerHTML=t,e.setAttribute("data-md-state","open")})),Object(m.a)(e||2e3),Object(i.a)((function(t){return t.removeAttribute("data-md-state")})),Object(m.a)(400),Object(i.a)((function(t){t.innerHTML="",t.remove()})))}))).subscribe(),n}var g=n(0),w=n(91),$=n(93),x=n(109),k=n(95),S=n(45),T=n(97),C=n(86),A=n(101),_=n(102),E=n(103),L=n(87),M=n(104),H=n(88);function R(t){var e=t.document$,n=t.viewport$,r=t.location$;"scrollRestoration"in history&&(history.scrollRestoration="manual"),Object(w.a)(window,"beforeunload").subscribe((function(){history.scrollRestoration="auto"}));var a=Object(b.c)('link[rel="shortcut icon"]');void 0!==a&&(a.href=a.href);var i=Object(w.a)(document.body,"click").pipe(Object(k.a)((function(t){return!(t.metaKey||t.ctrlKey)})),Object(p.a)((function(t){if(t.target instanceof HTMLElement){var e=t.target.closest("a");if(e&&!e.target&&Object(b.h)(e))return Object(b.g)(e)||t.preventDefault(),Object(j.a)(e)}return c.a})),Object(h.a)((function(t){return{url:new URL(t.href)}})),Object(o.a)());i.subscribe((function(){Object(b.o)("search",!1)}));var u=i.pipe(Object(k.a)((function(t){var e=t.url;return!Object(b.g)(e)})),Object(o.a)()),f=Object(w.a)(window,"popstate").pipe(Object(k.a)((function(t){return null!==t.state})),Object(h.a)((function(t){return{url:new URL(location.href),offset:t.state}})),Object(o.a)());Object($.a)(u,f).pipe(Object(S.a)((function(t,e){return t.url.href===e.url.href})),Object(T.a)("url")).subscribe(r);var s=r.pipe(Object(C.a)("pathname"),Object(A.a)(1),Object(p.a)((function(t){return Object(x.a)({url:t.href,responseType:"text",withCredentials:!0}).pipe(Object(_.a)((function(){return Object(b.m)(t),c.a})))})));u.pipe(Object(E.a)(s)).subscribe((function(t){var e=t.url;history.pushState({},"",e.toString())}));var O=new DOMParser;s.pipe(Object(h.a)((function(t){var e=t.response;return O.parseFromString(e,"text/html")}))).subscribe(e);var l=Object($.a)(u,f).pipe(Object(E.a)(e));l.subscribe((function(t){var e=t.url,n=t.offset;e.hash&&!n?Object(b.n)(e.hash):Object(b.p)(n||{y:0})})),l.pipe(Object(L.a)(e)).subscribe((function(t){var e,n,r=Object(g.h)(t,2)[1],c=r.title,a=r.head;document.dispatchEvent(new CustomEvent("DOMContentSwitch")),document.title=c;try{for(var o=Object(g.k)(['link[rel="canonical"]','meta[name="author"]','meta[name="description"]']),i=o.next();!i.done;i=o.next()){var u=i.value,f=Object(b.c)(u,a),s=Object(b.c)(u,document.head);void 0!==f&&void 0!==s&&Object(b.j)(s,f)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}})),n.pipe(Object(M.a)(250),Object(C.a)("offset")).subscribe((function(t){var e=t.offset;history.replaceState(e,"")})),Object($.a)(i,f).pipe(Object(H.a)(2,1),Object(k.a)((function(t){var e=Object(g.h)(t,2),n=e[0],r=e[1];return n.url.pathname===r.url.pathname&&!Object(b.g)(r.url)})),Object(h.a)((function(t){return Object(g.h)(t,2)[1]}))).subscribe((function(t){var e=t.offset;Object(b.p)(e||{y:0})}))}var P=n(7);function q(){var t=Object(b.u)().pipe(Object(h.a)((function(t){return Object(g.a)({mode:Object(b.f)("search")?"search":"global"},t)})),Object(k.a)((function(t){if("global"===t.mode){var e=Object(b.b)();if(void 0!==e)return!Object(b.i)(e)}return!0})),Object(o.a)());return t.pipe(Object(k.a)((function(t){return"search"===t.mode})),Object(L.a)(Object(P.useComponent)("search-query"),Object(P.useComponent)("search-result"))).subscribe((function(t){var e=Object(g.h)(t,3),n=e[0],r=e[1],c=e[2],a=Object(b.b)();switch(n.type){case"Enter":a===r&&n.claim();break;case"Escape":case"Tab":Object(b.o)("search",!1),Object(b.k)(r,!1);break;case"ArrowUp":case"ArrowDown":if(void 0===a)Object(b.k)(r);else{var o=Object(g.i)([r],Object(b.e)("[href]",c)),i=Math.max(0,(Math.max(0,o.indexOf(a))+o.length+("ArrowUp"===n.type?-1:1))%o.length);Object(b.k)(o[i])}n.claim();break;default:r!==Object(b.b)()&&Object(b.k)(r)}})),t.pipe(Object(k.a)((function(t){return"global"===t.mode})),Object(L.a)(Object(P.useComponent)("search-query"))).subscribe((function(t){var e=Object(g.h)(t,2),n=e[0],r=e[1];switch(n.type){case"f":case"s":case"/":Object(b.k)(r),Object(b.l)(r),n.claim();break;case"p":case",":var c=Object(b.c)("[href][rel=prev]");void 0!==c&&c.click();break;case"n":case".":var a=Object(b.c)("[href][rel=next]");void 0!==a&&a.click()}})),t}var U=n(75);!function(){function t(t){var e=t.config,n=t.docs,r=t.pipeline,c=t.index;this.documents=function(t){var e,n,r=new Map;try{for(var c=Object(g.k)(t),a=c.next();!a.done;a=c.next()){var o=a.value,i=Object(g.h)(o.location.split("#"),2),u=i[0],b=i[1],f=o.location,s=o.title,O=U(o.text).replace(/\s+(?=[,.:;!?])/g,"").replace(/\s+/g," ");if(b){var l=r.get(u);l.linked?r.set(f,{location:f,title:s,text:O,parent:l}):(l.title=o.title,l.text=O,l.linked=!0)}else r.set(f,{location:f,title:s,text:O,linked:!1})}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=c.return)&&n.call(c)}finally{if(e)throw e.error}}return r}(n),this.highlight=function(t){var e=new RegExp(t.separator,"img"),n=function(t,e,n){return e+""+n+""};return function(r){r=r.replace(/[\s*+-:~^]+/g," ").trim();var c=new RegExp("(^|"+t.separator+")("+r.replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&").replace(e,"|")+")","img");return function(t){return Object(g.a)(Object(g.a)({},t),{title:t.title.replace(c,n),text:t.text.replace(c,n)})}}}(e),this.index=void 0===c?lunr((function(){var t,c,a,o,i;r=r||["trimmer","stopWordFilter"],this.pipeline.reset();try{for(var u=Object(g.k)(r),b=u.next();!b.done;b=u.next()){var f=b.value;this.pipeline.add(lunr[f])}}catch(e){t={error:e}}finally{try{b&&!b.done&&(c=u.return)&&c.call(u)}finally{if(t)throw t.error}}1===e.lang.length&&"en"!==e.lang[0]?this.use(lunr[e.lang[0]]):e.lang.length>1&&this.use((a=lunr).multiLanguage.apply(a,Object(g.i)(e.lang))),this.field("title",{boost:1e3}),this.field("text"),this.ref("location");try{for(var s=Object(g.k)(n),O=s.next();!O.done;O=s.next()){var l=O.value;this.add(l)}}catch(t){o={error:t}}finally{try{O&&!O.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}})):lunr.Index.load("string"==typeof c?JSON.parse(c):c)}t.prototype.query=function(t){var e=this;if(t)try{var n=this.index.search(t).reduce((function(t,n){var r=e.documents.get(n.ref);if(void 0!==r)if("parent"in r){var c=r.parent.location;t.set(c,Object(g.i)(t.get(c)||[],[n]))}else{c=r.location;t.set(c,t.get(c)||[])}return t}),new Map),r=this.highlight(t);return Object(g.i)(n).map((function(t){var n=Object(g.h)(t,2),c=n[0],a=n[1];return{article:r(e.documents.get(c)),sections:a.map((function(t){return r(e.documents.get(t.ref))}))}}))}catch(e){console.warn("Invalid query: "+t+" – see https://bit.ly/2s3ChXG")}return[]}}();function N(t){return t.replace(/(?:^|\s+)[*+-:^~]+(?=\s+|$)/g,"").trim().replace(/\s+|\b$/g,"* ")}var I,z=n(108),V=n(52),B=n(85);function D(t){return t.type===I.RESULT}function J(t){var e=t.config,n=t.docs,r=t.index;return 1===e.lang.length&&"en"===e.lang[0]&&(e.lang=[Object(s.f)("search.config.lang")]),"[s-]+"===e.separator&&(e.separator=Object(s.f)("search.config.separator")),{config:e,docs:n,index:r,pipeline:Object(s.f)("search.config.pipeline").split(/\s*,\s*/).filter(z.a)}}function K(t,e){var n=e.index$,r=e.base$,c=new Worker(t),a=new l.a,o=Object(b.C)(c,{tx$:a}).pipe(Object(L.a)(r),Object(h.a)((function(t){var e,n,r,c,a=Object(g.h)(t,2),o=a[0],i=a[1];if(D(o))try{for(var u=Object(g.k)(o.data),b=u.next();!b.done;b=u.next()){var f=b.value,s=f.article,O=f.sections;s.location=i+"/"+s.location;try{for(var l=(r=void 0,Object(g.k)(O)),j=l.next();!j.done;j=l.next()){var d=j.value;d.location=i+"/"+d.location}}catch(t){r={error:t}}finally{try{j&&!j.done&&(c=l.return)&&c.call(l)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{b&&!b.done&&(n=u.return)&&n.call(u)}finally{if(e)throw e.error}}return o})),Object(B.a)(1));return n.pipe(Object(h.a)((function(t){return{type:I.SETUP,data:J(t)}})),Object(v.b)(V.a)).subscribe(a.next.bind(a)),{tx$:a,rx$:o}}!function(t){t[t.SETUP=0]="SETUP",t[t.READY=1]="READY",t[t.QUERY=2]="QUERY",t[t.RESULT=3]="RESULT"}(I||(I={}))},,,,,,function(t,e,n){"use strict";function r(t,e){t.style.top=e+"px"}function c(t){t.style.top=""}function a(t,e){t.style.height=e+"px"}function o(t){t.style.height=""}function i(t,e){t.setAttribute("data-md-state",e?"lock":"")}function u(t){t.removeAttribute("data-md-state")}n.d(e,"f",(function(){return r})),n.d(e,"c",(function(){return c})),n.d(e,"d",(function(){return a})),n.d(e,"a",(function(){return o})),n.d(e,"e",(function(){return i})),n.d(e,"b",(function(){return u}))},function(t,e,n){"use strict";n.d(e,"a",(function(){return l})),n.d(e,"b",(function(){return j}));var r,c=n(0),a=n(39),o=n(18),i=n(9),u=n(79),b=n(85),f=n(33),s=n(45),O=n(1);function l(t,e){var n=e.document$;r=n.pipe(Object(i.a)((function(e){return t.reduce((function(t,n){var r,a=Object(O.c)("[data-md-component="+n+"]",e);return Object(c.a)(Object(c.a)({},t),void 0!==a?((r={})[n]=a,r):{})}),{})})),Object(u.a)((function(e,n){var r,a;try{for(var o=Object(c.k)(t),i=o.next();!i.done;i=o.next()){var u=i.value;switch(u){case"announce":case"header-title":case"container":case"skip":u in e&&void 0!==e[u]&&(Object(O.j)(e[u],n[u]),e[u]=n[u]);break;default:void 0!==n[u]?e[u]=Object(O.c)("[data-md-component="+u+"]"):delete e[u]}}}catch(t){r={error:t}}finally{try{i&&!i.done&&(a=o.return)&&a.call(o)}finally{if(r)throw r.error}}return e})),Object(b.a)(1))}function j(t){return r.pipe(Object(f.a)((function(e){return void 0!==e[t]?Object(a.a)(e[t]):o.a})),Object(s.a)())}},,,function(t,e,n){"use strict";function r(t,e){t.setAttribute("data-md-state",e?"blur":"")}function c(t){t.removeAttribute("data-md-state")}function a(t,e){t.classList.toggle("md-nav__link--active",e)}function o(t){t.classList.remove("md-nav__link--active")}n.d(e,"d",(function(){return r})),n.d(e,"b",(function(){return c})),n.d(e,"c",(function(){return a})),n.d(e,"a",(function(){return o}))},,,,,,function(t,e,n){"use strict";var r=n(60);n.o(r,"applySidebar")&&n.d(e,"applySidebar",(function(){return r.applySidebar})),n.o(r,"mountTableOfContents")&&n.d(e,"mountTableOfContents",(function(){return r.mountTableOfContents})),n.o(r,"mountTabs")&&n.d(e,"mountTabs",(function(){return r.mountTabs})),n.o(r,"watchSidebar")&&n.d(e,"watchSidebar",(function(){return r.watchSidebar}))},function(t,e,n){"use strict";n.d(e,"a",(function(){return a})),n.d(e,"b",(function(){return l})),n.d(e,"c",(function(){return p})),n.d(e,"d",(function(){return m}));var r=n(4),c="md-clipboard md-icon";function a(t){return Object(r.b)("button",{class:c,title:Object(r.f)("clipboard.copy"),"data-clipboard-target":"#"+t+" > code"},Object(r.b)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(r.b)("path",{d:"M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"})))}var o=n(0),i="md-search-result__item",u="md-search-result__link",b="md-search-result__article md-search-result__article--document",f="md-search-result__article",s="md-search-result__title",O="md-search-result__teaser";function l(t){var e=t.article,n=t.sections,c=Object(r.b)("div",{class:"md-search-result__icon md-icon"},Object(r.b)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(r.b)("path",{d:"M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H13C12.59,21.75 12.2,21.44 11.86,21.1C11.53,20.77 11.25,20.4 11,20H6V4H13V9H18V10.18C18.71,10.34 19.39,10.61 20,11V8L14,2M20.31,18.9C21.64,16.79 21,14 18.91,12.68C16.8,11.35 14,12 12.69,14.08C11.35,16.19 12,18.97 14.09,20.3C15.55,21.23 17.41,21.23 18.88,20.32L22,23.39L23.39,22L20.31,18.9M16.5,19A2.5,2.5 0 0,1 14,16.5A2.5,2.5 0 0,1 16.5,14A2.5,2.5 0 0,1 19,16.5A2.5,2.5 0 0,1 16.5,19Z"}))),a=Object(o.i)([e],n).map((function(t){var e=t.location,n=t.title,a=t.text;return Object(r.b)("a",{href:e,class:u,tabIndex:-1},Object(r.b)("article",{class:"parent"in t?f:b},!("parent"in t)&&c,Object(r.b)("h1",{class:s},n),a.length>0&&Object(r.b)("p",{class:O},Object(r.g)(a,320))))}));return Object(r.b)("li",{class:i},a)}var j="md-source__facts",d="md-source__fact";function p(t){var e=t.map((function(t){return Object(r.b)("li",{class:d},t)}));return Object(r.b)("ul",{class:j},e)}var h="md-typeset__scrollwrap",v="md-typeset__table";function m(t){return Object(r.b)("div",{class:h},Object(r.b)("div",{class:v},t))}},,,,,,,,,,,,function(t,e,n){"use strict";var r=n(65);n.o(r,"applyAnchorList")&&n.d(e,"applyAnchorList",(function(){return r.applyAnchorList})),n.o(r,"watchAnchorList")&&n.d(e,"watchAnchorList",(function(){return r.watchAnchorList}));var c=n(66);n.d(e,"applyAnchorList",(function(){return c.a})),n.d(e,"watchAnchorList",(function(){return c.b}));n(24)},,,,,,,,,,,,,,,,,function(t,e,n){"use strict";var r=n(61);n.o(r,"applySidebar")&&n.d(e,"applySidebar",(function(){return r.applySidebar})),n.o(r,"mountTableOfContents")&&n.d(e,"mountTableOfContents",(function(){return r.mountTableOfContents})),n.o(r,"mountTabs")&&n.d(e,"mountTabs",(function(){return r.mountTabs})),n.o(r,"watchSidebar")&&n.d(e,"watchSidebar",(function(){return r.watchSidebar}));var c=n(62);n.d(e,"applySidebar",(function(){return c.a})),n.d(e,"watchSidebar",(function(){return c.b}));n(20)},function(t,e){},function(t,e,n){"use strict";n.d(e,"b",(function(){return j})),n.d(e,"a",(function(){return d}));var r=n(0),c=n(58),a=n(44),o=n(81),i=n(9),u=n(45),b=n(55),f=n(87),s=n(78),O=n(80),l=n(20);function j(t,e){var n=e.main$,a=e.viewport$,o=t.parentElement.offsetTop-t.parentElement.parentElement.offsetTop;return Object(c.a)([n,a]).pipe(Object(i.a)((function(t){var e=Object(r.h)(t,2),n=e[0],c=n.offset,a=n.height,i=e[1].offset.y;return{height:a=a+Math.min(o,Math.max(0,i-c))-o,lock:i>=c+o}})),Object(u.a)((function(t,e){return t.height===e.height&&t.lock===e.lock})))}function d(t,e){var n=e.header$;return Object(a.a)(Object(b.b)(o.a),Object(f.a)(n),Object(s.a)((function(e){var n=Object(r.h)(e,2),c=n[0],a=c.height,o=c.lock,i=n[1].height;Object(l.d)(t,a),Object(l.e)(t,o),o?Object(l.f)(t,i):Object(l.c)(t)})),Object(i.a)((function(t){return Object(r.h)(t,1)[0]})),Object(O.a)((function(){Object(l.c)(t),Object(l.a)(t),Object(l.b)(t)})))}},function(t,e,n){"use strict";var r=n(64);n.d(e,"mountTableOfContents",(function(){return r.a}));n(43)},function(t,e,n){"use strict";n.d(e,"a",(function(){return O}));var r=n(0),c=n(44),a=n(58),o=n(39),i=n(33),u=n(9),b=n(1),f=n(30),s=n(43);function O(t){var e=t.header$,n=t.main$,O=t.viewport$,l=t.tablet$;return Object(c.a)(Object(i.a)((function(t){return l.pipe(Object(i.a)((function(c){if(c){var i=Object(b.e)(".md-nav__link",t),l=Object(f.watchSidebar)(t,{main$:n,viewport$:O}).pipe(Object(f.applySidebar)(t,{header$:e})),j=Object(s.watchAnchorList)(i,{header$:e,viewport$:O}).pipe(Object(s.applyAnchorList)(i));return Object(a.a)([l,j]).pipe(Object(u.a)((function(t){var e=Object(r.h)(t,2);return{sidebar:e[0],anchors:e[1]}})))}return Object(o.a)({})})))})))}},function(t,e){},function(t,e,n){"use strict";n.d(e,"b",(function(){return y})),n.d(e,"a",(function(){return g}));var r=n(0),c=n(90),a=n(58),o=n(44),i=n(81),u=n(9),b=n(86),f=n(33),s=n(79),O=n(45),l=n(89),j=n(88),d=n(55),p=n(78),h=n(80),v=n(1),m=n(24);function y(t,e){var n,o,i=e.header$,d=e.viewport$,p=new Map;try{for(var h=Object(r.k)(t),m=h.next();!m.done;m=h.next()){var y=m.value,g=decodeURIComponent(y.hash.substring(1)),w=Object(v.c)('[id="'+g+'"]');void 0!==w&&p.set(y,w)}}catch(t){n={error:t}}finally{try{m&&!m.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}var $=i.pipe(Object(u.a)((function(t){return 18+t.height})));return Object(v.t)(document.body).pipe(Object(b.a)("height"),Object(u.a)((function(){var t=[];return Object(r.i)(p).reduce((function(e,n){for(var a=Object(r.h)(n,2),o=a[0],i=a[1];t.length;){if(!(p.get(t[t.length-1]).tagName>=i.tagName))break;t.pop()}for(var u=i.offsetTop;!u&&i.parentElement;)u=(i=i.parentElement).offsetTop;return e.set(Object(c.a)(t=Object(r.i)(t,[o])),u)}),new Map)})),Object(f.a)((function(t){return Object(a.a)([$,d]).pipe(Object(s.a)((function(t,e){for(var n=Object(r.h)(t,2),c=n[0],a=n[1],o=Object(r.h)(e,2),i=o[0],u=o[1].offset.y;a.length;){if(!(Object(r.h)(a[0],2)[1]-i=u))break;a=Object(r.i)([c.pop()],a)}return[c,a]}),[[],Object(r.i)(t)]),Object(O.a)((function(t,e){return t[0]===e[0]&&t[1]===e[1]})))}))).pipe(Object(u.a)((function(t){var e=Object(r.h)(t,2),n=e[0],c=e[1];return{prev:n.map((function(t){return Object(r.h)(t,1)[0]})),next:c.map((function(t){return Object(r.h)(t,1)[0]}))}})),Object(l.a)({prev:[],next:[]}),Object(j.a)(2,1),Object(u.a)((function(t){var e=Object(r.h)(t,2),n=e[0],c=e[1];return n.prev.length16)););return n}),0),Object(y.a)(e),Object(_.a)((function(){!function(t){t.innerHTML=""}(u)})))})))}function R(t,e){var n=t.rx$,r=e.query$;return Object(c.a)(Object(o.a)((function(t){var e=t.parentElement,c=Object(f.s)(e).pipe(Object(i.a)((function(t){return t.y>=e.scrollHeight-e.offsetHeight-16})),Object(p.a)(),Object(x.a)($.a));return n.pipe(Object(x.a)(s.c),Object(k.a)("data"),H(t,{query$:r,fetch$:c}))})))}},function(t,e,n){"use strict";n.d(e,"a",(function(){return O}));var r=n(44),c=n(33),a=n(9),o=n(86),i=n(1),u=n(81),b=n(55),f=n(78),s=n(80);function O(t){var e=t.header$,n=t.viewport$;return Object(r.a)(Object(c.a)((function(t){return Object(i.B)(t,{header$:e,viewport$:n}).pipe(Object(a.a)((function(t){return{hidden:t.offset.y>=20}})),Object(o.a)("hidden"),function(t){return Object(r.a)(Object(b.b)(u.a),Object(f.a)((function(e){var n=e.hidden;!function(t,e){t.setAttribute("data-md-state",e?"hidden":"")}(t,n)})),Object(s.a)((function(){!function(t){t.removeAttribute("data-md-state")}(t)})))}(t))})))}},function(t,e,n){"use strict";n.d(e,"a",(function(){return m}));var r=n(27),c=n(44),a=n(33),o=n(86),i=n(78),u=n(21),b=n(0),f=n(58),s=n(81),O=n(97),l=n(45),j=n(85),d=n(9),p=n(55),h=n(80),v=n(1);function m(t){var e=t.header$,n=t.viewport$,m=new r.a;return Object(u.b)("header").pipe(Object(a.a)((function(t){return m.pipe(Object(o.a)("active"),(e=t,Object(c.a)(Object(p.b)(s.a),Object(i.a)((function(t){var n=t.active;!function(t,e){t.setAttribute("data-md-state",e?"shadow":"")}(e,n)})),Object(h.a)((function(){!function(t){t.removeAttribute("data-md-state")}(e)})))));var e}))).subscribe(),Object(c.a)(Object(a.a)((function(t){return function(t,e){var n=e.header$,r=e.viewport$,c=n.pipe(Object(O.a)("height"),Object(l.a)(),Object(j.a)(1)),i=c.pipe(Object(a.a)((function(){return Object(v.t)(t).pipe(Object(d.a)((function(e){var n=e.height;return{top:t.offsetTop,bottom:t.offsetTop+n}})))})),Object(o.a)("bottom"),Object(j.a)(1));return Object(f.a)([c,i,r]).pipe(Object(d.a)((function(t){var e=Object(b.h)(t,3),n=e[0],r=e[1],c=r.top,a=r.bottom,o=e[2],i=o.offset.y,u=o.size.height;return{offset:c-n,height:u=Math.max(0,u-Math.max(0,c-i,n)-Math.max(0,u+i-a)),active:c-n<=i}})),Object(l.a)((function(t,e){return t.offset===e.offset&&t.height===e.height&&t.active===e.active})))}(t,{header$:e,viewport$:n})})),Object(i.a)((function(t){return m.next(t)})))}},function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(44),c=n(39),a=n(33),o=n(9),i=n(86),u=n(1),b=n(81),f=n(55),s=n(78),O=n(80);function l(t){var e=t.header$,n=t.viewport$,l=t.screen$;return Object(r.a)(Object(a.a)((function(t){return l.pipe(Object(a.a)((function(a){return a?Object(u.B)(t,{header$:e,viewport$:n}).pipe(Object(o.a)((function(t){return{hidden:t.offset.y>=10}})),Object(i.a)("hidden"),function(t){return Object(r.a)(Object(f.b)(b.a),Object(s.a)((function(e){var n=e.hidden;!function(t,e){t.setAttribute("data-md-state",e?"hidden":"")}(t,n)})),Object(O.a)((function(){!function(t){t.removeAttribute("data-md-state")}(t)})))}(t)):Object(c.a)({hidden:!0})})))})))}},function(t,e,n){"use strict";n.d(e,"a",(function(){return y}));var r=n(0),c=n(44),a=n(58),o=n(33),i=n(9),u=n(95),b=n(87),f=n(45),s=n(89),O=n(85),l=n(1),j=n(21),d=n(39),p=n(81),h=n(55),v=n(78),m=n(80);function y(t){var e=t.document$,n=t.viewport$;return Object(c.a)(Object(o.a)((function(t){var y=function(t,e){return e.document$.pipe(Object(i.a)((function(){var e=getComputedStyle(t);return["sticky","-webkit-sticky"].includes(e.position)})),Object(f.a)(),Object(o.a)((function(e){return e?Object(l.t)(t).pipe(Object(i.a)((function(t){return{sticky:!0,height:t.height}}))):Object(d.a)({sticky:!1,height:0})})),Object(O.a)(1))}(t,{document$:e}),g=Object(j.b)("main").pipe(Object(i.a)((function(t){return Object(l.c)("h1, h2, h3, h4, h5, h6",t)})),Object(u.a)((function(t){return void 0!==t})),Object(b.a)(Object(j.b)("header-title")),Object(o.a)((function(t){var e=Object(r.h)(t,2),a=e[0],o=e[1];return Object(l.B)(a,{header$:y,viewport$:n}).pipe(Object(i.a)((function(t){return t.offset.y>=a.offsetHeight?"page":"site"})),Object(f.a)(),function(t){return Object(c.a)(Object(h.b)(p.a),Object(v.a)((function(e){!function(t,e){t.setAttribute("data-md-state",e?"active":"")}(t,"page"===e)})),Object(m.a)((function(){!function(t){t.removeAttribute("data-md-state")}(t)})))}(o))})),Object(s.a)("site"));return Object(a.a)([y,g]).pipe(Object(i.a)((function(t){var e=Object(r.h)(t,2),n=e[0],c=e[1];return Object(r.a)({type:c},n)})),Object(O.a)(1))})))}},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(44),c=n(39),a=n(33),o=n(9),i=n(30);function u(t){var e=t.header$,n=t.main$,u=t.viewport$,b=t.screen$;return Object(r.a)(Object(a.a)((function(t){return b.pipe(Object(a.a)((function(r){return r?Object(i.watchSidebar)(t,{main$:n,viewport$:u}).pipe(Object(i.applySidebar)(t,{header$:e}),Object(o.a)((function(t){return{sidebar:t}}))):Object(c.a)({})})))})))}},,,,,,,,,,,,function(t,e,n){"use strict";n.r(e),n.d(e,"setScrollLock",(function(){return P})),n.d(e,"resetScrollLock",(function(){return q})),n.d(e,"initialize",(function(){return U}));var r=n(0),c=n(106),a=n(36),o=n(58),i=n(81),u=n(91),b=n(93),f=n(109),s=n(85),O=n(33),l=n(97),j=n(78),d=n(110),p=n(87),h=n(55),v=n(95),m=n(111),y=n(1),g=n(7),w=n(14),$=n(108),x=n(9),k=n(99);var S=n(101);var T=n(105),C=n(100),A=n(92);function _(){return/(iPad|iPhone|iPod)/.test(navigator.userAgent)}var E=n(102),L=n(31),M=n(4),H=n(39);function R(t){switch(Object(r.h)(t.match(/(git(?:hub|lab))/i)||[],1)[0].toLowerCase()){case"github":var e=Object(r.h)(t.match(/^.+github\.com\/([^\/]+)\/?([^\/]+)/i),3);return function(t,e){return Object(f.a)({url:void 0!==e?"https://api.github.com/repos/"+t+"/"+e:"https://api.github.com/users/"+t,responseType:"json"}).pipe(Object(v.a)((function(t){return 200===t.status})),Object(l.a)("response"),Object(O.a)((function(t){if(void 0!==e){var n=t.stargazers_count,r=t.forks_count;return Object(H.a)([Object(M.e)(n||0)+" Stars",Object(M.e)(r||0)+" Forks"])}var c=t.public_repos;return Object(H.a)([Object(M.e)(c||0)+" Repositories"])})))}(e[1],e[2]);case"gitlab":var n=Object(r.h)(t.match(/^.+?([^\/]*gitlab[^\/]+)\/(.+?)\/?$/i),3);return function(t,e){return Object(f.a)({url:"https://"+t+"/api/v4/projects/"+encodeURIComponent(e),responseType:"json"}).pipe(Object(v.a)((function(t){return 200===t.status})),Object(l.a)("response"),Object(x.a)((function(t){var e=t.star_count,n=t.forks_count;return[Object(M.e)(e)+" Stars",Object(M.e)(n)+" Forks"]})))}(n[1],n[2]);default:return C.a}}function P(t,e){t.setAttribute("data-md-state","lock"),t.style.top="-"+e+"px"}function q(t){var e=-1*parseInt(t.style.top,10);t.removeAttribute("data-md-state"),t.style.top="",e&&window.scrollTo(0,e)}function U(t){if(!Object(M.d)(t))throw new SyntaxError("Invalid configuration: "+JSON.stringify(t));var e=Object(y.q)(),n=Object(y.v)(),H=Object(y.w)(t.base,{location$:n}),U=Object(y.x)(),N=Object(y.A)(),I=Object(y.y)("(min-width: 960px)"),z=Object(y.y)("(min-width: 1220px)");Object(g.setupComponents)(["announce","container","header","header-title","hero","main","navigation","search","search-query","search-reset","search-result","skip","tabs","toc"],{document$:e});var V=Object(w.g)();!function(t){var e=t.document$,n=t.hash$,c=e.pipe(Object(x.a)((function(){return Object(y.e)("details")})));Object(b.a)(Object(y.y)("print").pipe(Object(v.a)($.a)),Object(u.a)(window,"beforeprint")).pipe(Object(k.a)(c)).subscribe((function(t){var e,n;try{for(var c=Object(r.k)(t),a=c.next();!a.done;a=c.next()){a.value.setAttribute("open","")}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=c.return)&&n.call(c)}finally{if(e)throw e.error}}})),n.pipe(Object(x.a)((function(t){return Object(y.c)('[id="'+t+'"]')})),Object(v.a)((function(t){return void 0!==t})),Object(j.a)((function(t){var e=t.closest("details");e&&!e.open&&e.setAttribute("open","")}))).subscribe((function(t){return t.scrollIntoView()}))}({document$:e,hash$:U}),{document$:e}.document$.pipe(Object(S.a)(1),Object(p.a)(Object(g.useComponent)("container")),Object(x.a)((function(t){var e=Object(r.h)(t,2)[1];return Object(y.e)("script",e)}))).subscribe((function(t){var e,n;try{for(var c=Object(r.k)(t),a=c.next();!a.done;a=c.next()){var o=a.value;if(o.src||/(^|\/javascript)$/i.test(o.type)){var i=Object(y.a)("script"),u=o.src?"src":"textContent";i[u]=o[u],Object(y.j)(o,i)}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=c.return)&&n.call(c)}finally{if(e)throw e.error}}})),function(t){t.document$.pipe(Object(x.a)((function(){return Object(y.d)(".md-source[href]")})),Object(O.a)((function(t){var e=t.href;return Object(M.a)(""+Object(M.c)(e),(function(){return R(e)}))})),Object(E.a)((function(){return C.a}))).subscribe((function(t){var e,n;try{for(var c=Object(r.k)(Object(y.e)(".md-source__repository")),a=c.next();!a.done;a=c.next()){var o=a.value;o.hasAttribute("data-md-state")||(o.setAttribute("data-md-state","done"),o.appendChild(Object(L.c)(t)))}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=c.return)&&n.call(c)}finally{if(e)throw e.error}}}))}({document$:e}),function(t){var e=t.document$,n=Object(y.a)("table");e.pipe(Object(x.a)((function(){return Object(y.e)("table:not([class])")}))).subscribe((function(t){var e,c;try{for(var a=Object(r.k)(t),o=a.next();!o.done;o=a.next()){var i=o.value;Object(y.j)(i,n),Object(y.j)(n,Object(L.d)(i))}}catch(t){e={error:t}}finally{try{o&&!o.done&&(c=a.return)&&c.call(a)}finally{if(e)throw e.error}}}))}({document$:e}),function(t){var e=t.document$.pipe(Object(x.a)((function(){return Object(y.e)("[data-md-scrollfix]")})),Object(s.a)(1));e.subscribe((function(t){var e,n;try{for(var c=Object(r.k)(t),a=c.next();!a.done;a=c.next()){a.value.removeAttribute("data-md-scrollfix")}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=c.return)&&n.call(c)}finally{if(e)throw e.error}}})),Object(T.a)(_,e,C.a).pipe(Object(O.a)((function(t){return b.a.apply(void 0,Object(r.i)(t.map((function(t){return Object(u.a)(t,"touchstart",{passive:!0}).pipe(Object(A.a)(t))}))))}))).subscribe((function(t){var e=t.scrollTop;0===e?t.scrollTop=1:e+t.offsetHeight===t.scrollHeight&&(t.scrollTop=e-1)}))}({document$:e});var B=Object(w.e)(),D=Object(w.d)({document$:e,dialog$:B}),J=Object(g.useComponent)("header").pipe(Object(g.mountHeader)({document$:e,viewport$:N}),Object(s.a)(1)),K=Object(g.useComponent)("main").pipe(Object(g.mountMain)({header$:J,viewport$:N}),Object(s.a)(1)),Y=Object(g.useComponent)("navigation").pipe(Object(g.mountNavigation)({header$:J,main$:K,viewport$:N,screen$:z}),Object(s.a)(1)),F=Object(g.useComponent)("toc").pipe(Object(g.mountTableOfContents)({header$:J,main$:K,viewport$:N,tablet$:I}),Object(s.a)(1)),Q=Object(g.useComponent)("tabs").pipe(Object(g.mountTabs)({header$:J,viewport$:N,screen$:z}),Object(s.a)(1)),W=Object(g.useComponent)("hero").pipe(Object(g.mountHero)({header$:J,viewport$:N}),Object(s.a)(1)),X=t.search&&t.search.index?t.search.index:void 0,Z=void 0!==X?Object(a.a)(X):H.pipe(Object(O.a)((function(t){return Object(f.a)({url:t+"/search/search_index.json",responseType:"json",withCredentials:!0}).pipe(Object(l.a)("response"))}))),G=Object(w.h)(t.search.worker,{base$:H,index$:Z}),tt=Object(g.useComponent)("search-query").pipe(Object(g.mountSearchQuery)(G,{transform:t.search.transform}),Object(s.a)(1)),et=Object(g.useComponent)("search-reset").pipe(Object(g.mountSearchReset)(),Object(s.a)(1)),nt=Object(g.useComponent)("search-result").pipe(Object(g.mountSearchResult)(G,{query$:tt}),Object(s.a)(1)),rt=Object(g.useComponent)("search").pipe(Object(g.mountSearch)({query$:tt,reset$:et,result$:nt}),Object(s.a)(1));U.pipe(Object(j.a)((function(){return Object(y.o)("search",!1)})),Object(d.a)(125)).subscribe((function(t){return Object(y.n)("#"+t)})),Object(o.a)([Object(y.z)("search"),I]).pipe(Object(p.a)(N),Object(O.a)((function(t){var n=Object(r.h)(t,2),c=Object(r.h)(n[0],2),a=c[0],o=c[1],u=n[1].offset.y,b=a&&!o;return e.pipe(Object(d.a)(b?400:100),Object(h.b)(i.a),Object(j.a)((function(t){var e=t.body;return b?P(e,u):q(e)})))}))).subscribe(),Object(u.a)(document.body,"click").pipe(Object(v.a)((function(t){return!(t.metaKey||t.ctrlKey)})),Object(v.a)((function(t){if(t.target instanceof HTMLElement){var e=t.target.closest("a");if(e&&Object(y.h)(e))return!0}return!1}))).subscribe((function(){Object(y.o)("drawer",!1)})),t.features.includes("instant")&&"file:"!==location.protocol&&Object(w.f)({document$:e,location$:n,viewport$:N}),V.pipe(Object(v.a)((function(t){return"global"===t.mode&&"Tab"===t.type})),Object(m.a)(1)).subscribe((function(){var t,e;try{for(var n=Object(r.k)(Object(y.e)(".headerlink")),c=n.next();!c.done;c=n.next()){c.value.style.visibility="visible"}}catch(e){t={error:e}}finally{try{c&&!c.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}}));var ct={document$:e,location$:n,viewport$:N,header$:J,hero$:W,main$:K,navigation$:Y,search$:rt,tabs$:Q,toc$:F,clipboard$:D,keyboard$:V,dialog$:B};return b.a.apply(void 0,Object(r.i)(Object(c.a)(ct))).subscribe(),ct}document.documentElement.classList.remove("no-js"),document.documentElement.classList.add("js"),navigator.userAgent.match(/(iPad|iPhone|iPod)/g)&&document.documentElement.classList.add("ios")}])); +//# sourceMappingURL=bundle.eaaa3931.min.js.map \ No newline at end of file diff --git a/docs/assets/javascripts/bundle.eaaa3931.min.js.map b/docs/assets/javascripts/bundle.eaaa3931.min.js.map new file mode 100644 index 0000000..289d635 --- /dev/null +++ b/docs/assets/javascripts/bundle.eaaa3931.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/assets/javascripts/browser/document/index.ts","webpack:///./src/assets/javascripts/browser/element/_/index.ts","webpack:///./src/assets/javascripts/browser/element/focus/index.ts","webpack:///./src/assets/javascripts/browser/element/offset/index.ts","webpack:///./src/assets/javascripts/browser/element/select/index.ts","webpack:///./src/assets/javascripts/browser/element/size/index.ts","webpack:///./src/assets/javascripts/browser/keyboard/index.ts","webpack:///./src/assets/javascripts/browser/location/_/index.ts","webpack:///./src/assets/javascripts/browser/location/base/index.ts","webpack:///./src/assets/javascripts/browser/location/hash/index.ts","webpack:///./src/assets/javascripts/browser/media/index.ts","webpack:///./src/assets/javascripts/browser/toggle/index.ts","webpack:///./src/assets/javascripts/browser/viewport/offset/index.ts","webpack:///./src/assets/javascripts/browser/viewport/size/index.ts","webpack:///./src/assets/javascripts/browser/viewport/_/index.ts","webpack:///./src/assets/javascripts/browser/worker/index.ts","webpack:///./src/assets/javascripts/utilities/config/index.ts","webpack:///./src/assets/javascripts/utilities/jsx/index.ts","webpack:///./src/assets/javascripts/utilities/rxjs/index.ts","webpack:///./src/assets/javascripts/utilities/string/index.ts","webpack:///./src/assets/javascripts/components/index.ts","webpack:///./src/assets/javascripts/integrations/clipboard/index.ts","webpack:///./src/assets/javascripts/integrations/dialog/index.ts","webpack:///./src/assets/javascripts/integrations/instant/index.ts","webpack:///./src/assets/javascripts/integrations/keyboard/index.ts","webpack:///./src/assets/javascripts/integrations/search/_/index.ts","webpack:///./src/assets/javascripts/integrations/search/document/index.ts","webpack:///./src/assets/javascripts/integrations/search/highlighter/index.ts","webpack:///./src/assets/javascripts/integrations/search/transform/index.ts","webpack:///./src/assets/javascripts/integrations/search/worker/message/index.ts","webpack:///./src/assets/javascripts/integrations/search/worker/_/index.ts","webpack:///./src/assets/javascripts/components/shared/sidebar/set/index.ts","webpack:///./src/assets/javascripts/components/_/index.ts","webpack:///./src/assets/javascripts/components/toc/anchor/set/index.ts","webpack:///./src/assets/javascripts/components/shared/index.ts","webpack:///./src/assets/javascripts/templates/clipboard/index.tsx","webpack:///./src/assets/javascripts/templates/search/index.tsx","webpack:///./src/assets/javascripts/templates/source/index.tsx","webpack:///./src/assets/javascripts/templates/table/index.tsx","webpack:///./src/assets/javascripts/components/toc/anchor/index.ts","webpack:///./src/assets/javascripts/components/shared/sidebar/index.ts","webpack:///./src/assets/javascripts/components/shared/sidebar/react/index.ts","webpack:///./src/assets/javascripts/components/toc/index.ts","webpack:///./src/assets/javascripts/components/toc/_/index.ts","webpack:///./src/assets/javascripts/components/toc/anchor/react/index.ts","webpack:///./src/assets/javascripts/components/search/_/index.ts","webpack:///./src/assets/javascripts/components/search/query/_/index.ts","webpack:///./src/assets/javascripts/components/search/query/react/index.ts","webpack:///./src/assets/javascripts/components/search/reset/_/index.ts","webpack:///./src/assets/javascripts/components/search/reset/react/index.ts","webpack:///./src/assets/javascripts/components/search/result/set/index.ts","webpack:///./src/assets/javascripts/components/search/result/react/index.ts","webpack:///./src/assets/javascripts/components/search/result/_/index.ts","webpack:///./src/assets/javascripts/components/hero/_/index.ts","webpack:///./src/assets/javascripts/components/hero/react/index.ts","webpack:///./src/assets/javascripts/components/hero/set/index.ts","webpack:///./src/assets/javascripts/components/main/_/index.ts","webpack:///./src/assets/javascripts/components/main/react/index.ts","webpack:///./src/assets/javascripts/components/main/set/index.ts","webpack:///./src/assets/javascripts/components/tabs/_/index.ts","webpack:///./src/assets/javascripts/components/tabs/react/index.ts","webpack:///./src/assets/javascripts/components/tabs/set/index.ts","webpack:///./src/assets/javascripts/components/header/_/index.ts","webpack:///./src/assets/javascripts/components/header/react/index.ts","webpack:///./src/assets/javascripts/components/header/set/index.ts","webpack:///./src/assets/javascripts/components/navigation/_/index.ts","webpack:///./src/assets/javascripts/patches/scrollfix/index.ts","webpack:///./src/assets/javascripts/patches/source/index.ts","webpack:///./src/assets/javascripts/patches/source/github/index.ts","webpack:///./src/assets/javascripts/patches/source/gitlab/index.ts","webpack:///./src/assets/javascripts/index.ts","webpack:///./src/assets/javascripts/patches/details/index.ts","webpack:///./src/assets/javascripts/patches/script/index.ts","webpack:///./src/assets/javascripts/patches/table/index.ts"],"names":["webpackJsonpCallback","data","moduleId","chunkId","chunkIds","moreModules","executeModules","i","resolves","length","Object","prototype","hasOwnProperty","call","installedChunks","push","modules","parentJsonpFunction","shift","deferredModules","apply","checkDeferredModules","result","deferredModule","fulfilled","j","depId","splice","__webpack_require__","s","installedModules","0","exports","module","l","m","c","d","name","getter","o","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","p","jsonpArray","window","oldJsonpFunction","slice","watchDocument","document$","ReplaySubject","fromEvent","document","pipe","mapTo","subscribe","getElement","selector","node","querySelector","undefined","getElementOrThrow","el","ReferenceError","getActiveElement","activeElement","HTMLElement","getElements","Array","from","querySelectorAll","createElement","tagName","replaceElement","source","target","replaceWith","setElementFocus","focus","blur","watchElementFocus","merge","map","type","startWith","shareReplay","getElementOffset","x","scrollLeft","y","scrollTop","watchElementOffset","setElementSelection","HTMLInputElement","Error","select","watchElementSize","fromEventPattern","next","contentRect","width","Math","round","height","observe","offsetWidth","offsetHeight","getElementSize","isSusceptibleToKeyboard","isContentEditable","watchKeyboard","filter","ev","metaKey","ctrlKey","claim","preventDefault","stopPropagation","share","setLocation","url","location","href","isLocalLocation","ref","host","test","pathname","isAnchorLocation","hash","watchLocation","BehaviorSubject","URL","watchLocationBase","base","location$","take","toString","replace","getLocationHash","substring","setLocationHash","addEventListener","click","watchLocationHash","watchMedia","query","media","matchMedia","addListener","matches","toggles","drawer","search","getToggle","checked","setToggle","watchToggle","getViewportOffset","max","pageXOffset","pageYOffset","setViewportOffset","scrollTo","getViewportSize","innerWidth","innerHeight","watchViewport","combineLatest","passive","offset","size","watchViewportAt","header$","viewport$","size$","distinctUntilKeyChanged","offset$","offsetLeft","offsetTop","watchWorker","worker","tx$","rx$","pluck","throttle","leading","trailing","tap","message","postMessage","switchMapTo","isConfig","config","features","createElementNS","setAttribute","setAttributeNS","appendChild","child","innerHTML","Node","isArray","h","attributes","keys","attr","children","cache","factory","defer","sessionStorage","getItem","of","JSON","parse","value$","setItem","stringify","err","lang","translate","textContent","truncate","toFixed","len","charCodeAt","setupClipboard","dialog$","forEach","block","index","parent","parentElement","id","insertBefore","clipboard$","on","clearSelection","setupDialog","duration","Subject","dialog","classList","add","switchMap","text","body","container","observeOn","animationFrame","delay","removeAttribute","remove","setupInstantLoading","history","scrollRestoration","favicon","state$","closest","push$","pop$","state","distinctUntilChanged","prev","ajax$","skip","ajax","responseType","withCredentials","catchError","sample","pushState","dom","DOMParser","response","parseFromString","instant$","withLatestFrom","title","head","dispatchEvent","CustomEvent","debounceTime","replaceState","bufferCount","setupKeyboard","keyboard$","active","els","indexOf","docs","pipeline","this","documents","Map","doc","path","linked","set","setupSearchDocumentMap","highlight","separator","RegExp","_","term","trim","match","setupSearchHighlighter","lunr","reset","fn","use","multiLanguage","field","boost","Index","load","groups","reduce","results","sections","article","section","console","warn","defaultTransform","SearchMessageType","isSearchResultMessage","RESULT","setupSearchIndex","split","identity","setupSearchWorker","index$","base$","Worker","SETUP","setSidebarOffset","style","top","resetSidebarOffset","setSidebarHeight","resetSidebarHeight","setSidebarLock","resetSidebarLock","components$","setupComponents","names","components","useComponent","setAnchorBlur","resetAnchorBlur","setAnchorActive","toggle","resetAnchorActive","css","renderClipboardButton","class","xmlns","viewBox","renderSearchResult","icon","tabIndex","renderSource","facts","fact","renderTable","table","watchSidebar","main$","adjust","min","lock","a","b","applySidebar","mountTableOfContents","tablet$","tablet","sidebar$","anchors$","sidebar","anchors","watchAnchorList","decodeURIComponent","adjust$","header","anchor","pop","applyAnchorList","mountSearch","query$","reset$","result$","mountSearchQuery","options","transform","focus$","watchSearchQuery","QUERY","mountSearchReset","watchSearchReset","addToSearchResultList","applySearchResult","fetch$","list","meta","setSearchResultMeta","resetSearchResultMeta","scan","scrollHeight","finalize","resetSearchResultList","mountSearchResult","mountHero","hidden","setHeroHidden","resetHeroHidden","applyHero","mountMain","setHeaderShadow","resetHeaderShadow","border$","bottom","watchMain","main","mountTabs","screen$","screen","setTabsHidden","resetTabsHidden","applyTabs","mountHeader","styles","getComputedStyle","includes","position","sticky","watchHeader","type$","hx","setHeaderTitleActive","resetHeaderTitleActive","applyHeaderType","mountNavigation","isAppleDevice","navigator","userAgent","fetchSourceFacts","toLowerCase","user","repo","status","stargazers_count","forks_count","public_repos","fetchSourceFactsFromGitHub","project","encodeURIComponent","star_count","fetchSourceFactsFromGitLab","setScrollLock","resetScrollLock","parseInt","initialize","SyntaxError","hash$","els$","details","open","scrollIntoView","patchDetails","src","script","hasAttribute","patchSource","sentinel","patchTables","iif","patchScrollfix","navigation$","toc$","tabs$","hero$","search$","protocol","visibility","values","documentElement"],"mappings":"4DACE,SAASA,EAAqBC,GAQ7B,IAPA,IAMIC,EAAUC,EANVC,EAAWH,EAAK,GAChBI,EAAcJ,EAAK,GACnBK,EAAiBL,EAAK,GAIHM,EAAI,EAAGC,EAAW,GACpCD,EAAIH,EAASK,OAAQF,IACzBJ,EAAUC,EAASG,GAChBG,OAAOC,UAAUC,eAAeC,KAAKC,EAAiBX,IAAYW,EAAgBX,IACpFK,EAASO,KAAKD,EAAgBX,GAAS,IAExCW,EAAgBX,GAAW,EAE5B,IAAID,KAAYG,EACZK,OAAOC,UAAUC,eAAeC,KAAKR,EAAaH,KACpDc,EAAQd,GAAYG,EAAYH,IAKlC,IAFGe,GAAqBA,EAAoBhB,GAEtCO,EAASC,QACdD,EAASU,OAATV,GAOD,OAHAW,EAAgBJ,KAAKK,MAAMD,EAAiBb,GAAkB,IAGvDe,IAER,SAASA,IAER,IADA,IAAIC,EACIf,EAAI,EAAGA,EAAIY,EAAgBV,OAAQF,IAAK,CAG/C,IAFA,IAAIgB,EAAiBJ,EAAgBZ,GACjCiB,GAAY,EACRC,EAAI,EAAGA,EAAIF,EAAed,OAAQgB,IAAK,CAC9C,IAAIC,EAAQH,EAAeE,GACG,IAA3BX,EAAgBY,KAAcF,GAAY,GAE3CA,IACFL,EAAgBQ,OAAOpB,IAAK,GAC5Be,EAASM,EAAoBA,EAAoBC,EAAIN,EAAe,KAItE,OAAOD,EAIR,IAAIQ,EAAmB,GAKnBhB,EAAkB,CACrBiB,EAAG,GAGAZ,EA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1CzM,SAASqb,gBAAgBtP,UAAUC,IAAI,MAGnC2M,UAAUC,UAAU7I,MAAM,wBAC5B/P,SAASqb,gBAAgBtP,UAAUC,IAAI","file":"assets/javascripts/bundle.eaaa3931.min.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tfunction webpackJsonpCallback(data) {\n \t\tvar chunkIds = data[0];\n \t\tvar moreModules = data[1];\n \t\tvar executeModules = data[2];\n\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(data);\n\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n\n \t\t// add entry modules from loaded chunk to deferred list\n \t\tdeferredModules.push.apply(deferredModules, executeModules || []);\n\n \t\t// run deferred modules when all chunks ready\n \t\treturn checkDeferredModules();\n \t};\n \tfunction checkDeferredModules() {\n \t\tvar result;\n \t\tfor(var i = 0; i < deferredModules.length; i++) {\n \t\t\tvar deferredModule = deferredModules[i];\n \t\t\tvar fulfilled = true;\n \t\t\tfor(var j = 1; j < deferredModule.length; j++) {\n \t\t\t\tvar depId = deferredModule[j];\n \t\t\t\tif(installedChunks[depId] !== 0) fulfilled = false;\n \t\t\t}\n \t\t\tif(fulfilled) {\n \t\t\t\tdeferredModules.splice(i--, 1);\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = deferredModule[0]);\n \t\t\t}\n \t\t}\n\n \t\treturn result;\n \t}\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// undefined = chunk not loaded, null = chunk preloaded/prefetched\n \t// Promise = chunk loading, 0 = chunk loaded\n \tvar installedChunks = {\n \t\t0: 0\n \t};\n\n \tvar deferredModules = [];\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \tvar jsonpArray = window[\"webpackJsonp\"] = window[\"webpackJsonp\"] || [];\n \tvar oldJsonpFunction = jsonpArray.push.bind(jsonpArray);\n \tjsonpArray.push = webpackJsonpCallback;\n \tjsonpArray = jsonpArray.slice();\n \tfor(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);\n \tvar parentJsonpFunction = oldJsonpFunction;\n\n\n \t// add entry module to deferred list\n \tdeferredModules.push([84,1]);\n \t// run deferred modules when ready\n \treturn checkDeferredModules();\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { ReplaySubject, Subject, fromEvent } from \"rxjs\"\nimport { mapTo } from \"rxjs/operators\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch document\n *\n * Documents must be implemented as subjects, so all downstream observables are\n * automatically updated when a new document is emitted. This enabled features\n * like instant loading.\n *\n * @return Document subject\n */\nexport function watchDocument(): Subject {\n const document$ = new ReplaySubject()\n fromEvent(document, \"DOMContentLoaded\")\n .pipe(\n mapTo(document)\n )\n .subscribe(document$)\n\n /* Return document */\n return document$\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve an element matching the query selector\n *\n * @template T - Element type\n *\n * @param selector - Query selector\n * @param node - Node of reference\n *\n * @return Element or nothing\n */\nexport function getElement(\n selector: string, node: ParentNode = document\n): T | undefined {\n return node.querySelector(selector) || undefined\n}\n\n/**\n * Retrieve an element matching a query selector or throw a reference error\n *\n * @template T - Element type\n *\n * @param selector - Query selector\n * @param node - Node of reference\n *\n * @return Element\n */\nexport function getElementOrThrow(\n selector: string, node: ParentNode = document\n): T {\n const el = getElement(selector, node)\n if (typeof el === \"undefined\")\n throw new ReferenceError(\n `Missing element: expected \"${selector}\" to be present`\n )\n return el\n}\n\n/**\n * Retrieve the currently active element\n *\n * @return Element or nothing\n */\nexport function getActiveElement(): HTMLElement | undefined {\n return document.activeElement instanceof HTMLElement\n ? document.activeElement\n : undefined\n}\n\n/**\n * Retrieve all elements matching the query selector\n *\n * @template T - Element type\n *\n * @param selector - Query selector\n * @param node - Node of reference\n *\n * @return Elements\n */\nexport function getElements(\n selector: string, node: ParentNode = document\n): T[] {\n return Array.from(node.querySelectorAll(selector))\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Create an element\n *\n * @template T - Tag name type\n *\n * @param tagName - Tag name\n *\n * @return Element\n */\nexport function createElement<\n T extends keyof HTMLElementTagNameMap\n>(tagName: T): HTMLElementTagNameMap[T] {\n return document.createElement(tagName)\n}\n\n/**\n * Replace an element with another element\n *\n * @param source - Source element\n * @param target - Target element\n */\nexport function replaceElement(\n source: HTMLElement, target: Node\n): void {\n source.replaceWith(target)\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, fromEvent, merge } from \"rxjs\"\nimport { map, shareReplay, startWith } from \"rxjs/operators\"\n\nimport { getActiveElement } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set element focus\n *\n * @param el - Element\n * @param value - Whether the element should be focused\n */\nexport function setElementFocus(\nel: HTMLElement, value: boolean = true\n): void {\n if (value)\n el.focus()\n else\n el.blur()\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch element focus\n *\n * @param el - Element\n *\n * @return Element focus observable\n */\nexport function watchElementFocus(\n el: HTMLElement\n): Observable {\n return merge(\n fromEvent(el, \"focus\"),\n fromEvent(el, \"blur\")\n )\n .pipe(\n map(({ type }) => type === \"focus\"),\n startWith(el === getActiveElement()),\n shareReplay(1)\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, fromEvent, merge } from \"rxjs\"\nimport { map, shareReplay, startWith } from \"rxjs/operators\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Element offset\n */\nexport interface ElementOffset {\n x: number /* Horizontal offset */\n y: number /* Vertical offset */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve element offset\n *\n * @param el - Element\n *\n * @return Element offset\n */\nexport function getElementOffset(el: HTMLElement): ElementOffset {\n return {\n x: el.scrollLeft,\n y: el.scrollTop\n }\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch element offset\n *\n * @param el - Element\n *\n * @return Element offset observable\n */\nexport function watchElementOffset(\n el: HTMLElement\n): Observable {\n return merge(\n fromEvent(el, \"scroll\"),\n fromEvent(window, \"resize\")\n )\n .pipe(\n map(() => getElementOffset(el)),\n startWith(getElementOffset(el)),\n shareReplay(1)\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set element text selection\n *\n * @param el - Element\n */\nexport function setElementSelection(\n el: HTMLElement\n): void {\n if (el instanceof HTMLInputElement)\n el.select()\n else\n throw new Error(\"Not implemented\")\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport ResizeObserver from \"resize-observer-polyfill\"\nimport { Observable, fromEventPattern } from \"rxjs\"\nimport { shareReplay, startWith } from \"rxjs/operators\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Element offset\n */\nexport interface ElementSize {\n width: number /* Element width */\n height: number /* Element height */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve element size\n *\n * @param el - Element\n *\n * @return Element size\n */\nexport function getElementSize(el: HTMLElement): ElementSize {\n return {\n width: el.offsetWidth,\n height: el.offsetHeight\n }\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch element size\n *\n * @param el - Element\n *\n * @return Element size observable\n */\nexport function watchElementSize(\n el: HTMLElement\n): Observable {\n return fromEventPattern(next => {\n new ResizeObserver(([{ contentRect }]) => next({\n width: Math.round(contentRect.width),\n height: Math.round(contentRect.height)\n }))\n .observe(el)\n })\n .pipe(\n startWith(getElementSize(el)),\n shareReplay(1)\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, fromEvent } from \"rxjs\"\nimport { filter, map, share } from \"rxjs/operators\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Key\n */\nexport interface Key {\n type: string /* Key type */\n claim(): void /* Key claim */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Check whether an element may receive keyboard input\n *\n * @param el - Element\n *\n * @return Test result\n */\nexport function isSusceptibleToKeyboard(el: HTMLElement): boolean {\n switch (el.tagName) {\n\n /* Form elements */\n case \"INPUT\":\n case \"SELECT\":\n case \"TEXTAREA\":\n return true\n\n /* Everything else */\n default:\n return el.isContentEditable\n }\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch keyboard\n *\n * @return Keyboard observable\n */\nexport function watchKeyboard(): Observable {\n return fromEvent(window, \"keydown\")\n .pipe(\n filter(ev => !(ev.metaKey || ev.ctrlKey)),\n map(ev => ({\n type: ev.key,\n claim() {\n ev.preventDefault()\n ev.stopPropagation()\n }\n })),\n share()\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { BehaviorSubject, Subject } from \"rxjs\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve location\n *\n * This function will return a `URL` object (and not `Location`) in order to\n * normalize typings across the application. Furthermore, locations need to be\n * tracked without setting them and `Location` is a singleton which represents\n * the current location.\n *\n * @return URL\n */\nexport function getLocation(): URL {\n return new URL(location.href)\n}\n\n/**\n * Set location\n *\n * @param url - URL to change to\n */\nexport function setLocation(url: URL): void {\n location.href = url.href\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Check whether a URL is a local link or a file (except `.html`)\n *\n * @param url - URL or HTML anchor element\n * @param ref - Reference URL\n *\n * @return Test result\n */\nexport function isLocalLocation(\n url: URL | HTMLAnchorElement,\n ref: URL | Location = location\n): boolean {\n return url.host === ref.host\n && /^(?:\\/[\\w-]+)*(?:\\/?|\\.html)$/i.test(url.pathname)\n}\n\n/**\n * Check whether a URL is an anchor link on the current page\n *\n * @param url - URL or HTML anchor element\n * @param ref - Reference URL\n *\n * @return Test result\n */\nexport function isAnchorLocation(\n url: URL | HTMLAnchorElement,\n ref: URL | Location = location\n): boolean {\n return url.pathname === ref.pathname\n && url.hash.length > 0\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch location\n *\n * @return Location subject\n */\nexport function watchLocation(): Subject {\n return new BehaviorSubject(getLocation())\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable } from \"rxjs\"\nimport { map, shareReplay, take } from \"rxjs/operators\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n location$: Observable /* Location observable */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch location base\n *\n * @return Location base observable\n */\nexport function watchLocationBase(\n base: string, { location$ }: WatchOptions\n): Observable {\n return location$\n .pipe(\n take(1),\n map(({ href }) => new URL(base, href)\n .toString()\n .replace(/\\/$/, \"\")\n ),\n shareReplay(1)\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, fromEvent } from \"rxjs\"\nimport { filter, map, share, startWith } from \"rxjs/operators\"\n\nimport { createElement } from \"browser\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve location hash\n *\n * @return Location hash\n */\nexport function getLocationHash(): string {\n return location.hash.substring(1)\n}\n\n/**\n * Set location hash\n *\n * Setting a new fragment identifier via `location.hash` will have no effect\n * if the value doesn't change. When a new fragment identifier is set, we want\n * the browser to target the respective element at all times, which is why we\n * use this dirty little trick.\n *\n * @param hash - Location hash\n */\nexport function setLocationHash(hash: string): void {\n const el = createElement(\"a\")\n el.href = hash\n el.addEventListener(\"click\", ev => ev.stopPropagation())\n el.click()\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch location hash\n *\n * @return Location hash observable\n */\nexport function watchLocationHash(): Observable {\n return fromEvent(window, \"hashchange\")\n .pipe(\n map(getLocationHash),\n startWith(getLocationHash()),\n filter(hash => hash.length > 0),\n share()\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, fromEventPattern } from \"rxjs\"\nimport { shareReplay, startWith } from \"rxjs/operators\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch media query\n *\n * @param query - Media query\n *\n * @return Media observable\n */\nexport function watchMedia(query: string): Observable {\n const media = matchMedia(query)\n return fromEventPattern(next =>\n media.addListener(() => next(media.matches))\n )\n .pipe(\n startWith(media.matches),\n shareReplay(1)\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, fromEvent } from \"rxjs\"\nimport { map, startWith } from \"rxjs/operators\"\n\nimport { getElementOrThrow } from \"../element\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Toggle\n */\nexport type Toggle =\n | \"drawer\" /* Toggle for drawer */\n | \"search\" /* Toggle for search */\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * Toggle map\n */\nconst toggles: Record = {\n drawer: getElementOrThrow(`[data-md-toggle=drawer]`),\n search: getElementOrThrow(`[data-md-toggle=search]`)\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve the value of a toggle\n *\n * @param name - Toggle\n *\n * @return Toggle value\n */\nexport function getToggle(name: Toggle): boolean {\n return toggles[name].checked\n}\n\n/**\n * Set toggle\n *\n * Simulating a click event seems to be the most cross-browser compatible way\n * of changing the value while also emitting a `change` event. Before, Material\n * used `CustomEvent` to programmatically change the value of a toggle, but this\n * is a much simpler and cleaner solution which doesn't require a polyfill.\n *\n * @param name - Toggle\n * @param value - Toggle value\n */\nexport function setToggle(name: Toggle, value: boolean): void {\n if (toggles[name].checked !== value)\n toggles[name].click()\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch toggle\n *\n * @param name - Toggle\n *\n * @return Toggle value observable\n */\nexport function watchToggle(name: Toggle): Observable {\n const el = toggles[name]\n return fromEvent(el, \"change\")\n .pipe(\n map(() => el.checked),\n startWith(el.checked)\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, fromEvent, merge } from \"rxjs\"\nimport { map, startWith } from \"rxjs/operators\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Viewport offset\n */\nexport interface ViewportOffset {\n x: number /* Horizontal offset */\n y: number /* Vertical offset */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve viewport offset\n *\n * On iOS Safari, viewport offset can be negative due to overflow scrolling.\n * As this may induce strange behaviors downstream, we'll just limit it to 0.\n *\n * @return Viewport offset\n */\nexport function getViewportOffset(): ViewportOffset {\n return {\n x: Math.max(0, pageXOffset),\n y: Math.max(0, pageYOffset)\n }\n}\n\n/**\n * Set viewport offset\n *\n * @param offset - Viewport offset\n */\nexport function setViewportOffset(\n { x, y }: Partial\n): void {\n window.scrollTo(x || 0, y || 0)\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch viewport offset\n *\n * @return Viewport offset observable\n */\nexport function watchViewportOffset(): Observable {\n return merge(\n fromEvent(window, \"scroll\", { passive: true }),\n fromEvent(window, \"resize\", { passive: true })\n )\n .pipe(\n map(getViewportOffset),\n startWith(getViewportOffset())\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, fromEvent } from \"rxjs\"\nimport { map, startWith } from \"rxjs/operators\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Viewport size\n */\nexport interface ViewportSize {\n width: number /* Viewport width */\n height: number /* Viewport height */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Retrieve viewport size\n *\n * @return Viewport size\n */\nexport function getViewportSize(): ViewportSize {\n return {\n width: innerWidth,\n height: innerHeight\n }\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Watch viewport size\n *\n * @return Viewport size observable\n */\nexport function watchViewportSize(): Observable {\n return fromEvent(window, \"resize\", { passive: true })\n .pipe(\n map(getViewportSize),\n startWith(getViewportSize())\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, combineLatest } from \"rxjs\"\nimport {\n distinctUntilKeyChanged,\n map,\n shareReplay\n} from \"rxjs/operators\"\n\nimport { Header } from \"components\"\n\nimport {\n ViewportOffset,\n watchViewportOffset\n} from \"../offset\"\nimport {\n ViewportSize,\n watchViewportSize\n} from \"../size\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Viewport\n */\nexport interface Viewport {\n offset: ViewportOffset /* Viewport offset */\n size: ViewportSize /* Viewport size */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch at options\n */\ninterface WatchAtOptions {\n header$: Observable
/* Header observable */\n viewport$: Observable /* Viewport observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch viewport\n *\n * @return Viewport observable\n */\nexport function watchViewport(): Observable {\n return combineLatest([\n watchViewportOffset(),\n watchViewportSize()\n ])\n .pipe(\n map(([offset, size]) => ({ offset, size })),\n shareReplay(1)\n )\n}\n\n/**\n * Watch viewport relative to element\n *\n * @param el - Element\n * @param options - Options\n *\n * @return Viewport observable\n */\nexport function watchViewportAt(\n el: HTMLElement, { header$, viewport$ }: WatchAtOptions\n): Observable {\n const size$ = viewport$\n .pipe(\n distinctUntilKeyChanged(\"size\")\n )\n\n /* Compute element offset */\n const offset$ = combineLatest([size$, header$])\n .pipe(\n map((): ViewportOffset => ({\n x: el.offsetLeft,\n y: el.offsetTop\n }))\n )\n\n /* Compute relative viewport, return hot observable */\n return combineLatest([header$, viewport$, offset$])\n .pipe(\n map(([{ height }, { offset, size }, { x, y }]) => ({\n offset: {\n x: offset.x - x,\n y: offset.y - y + height\n },\n size\n })),\n shareReplay(1)\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, Subject, fromEventPattern } from \"rxjs\"\nimport {\n pluck,\n share,\n switchMapTo,\n tap,\n throttle\n} from \"rxjs/operators\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Worker message\n */\nexport interface WorkerMessage {\n type: unknown /* Message type */\n data?: unknown /* Message data */\n}\n\n/**\n * Worker handler\n *\n * @template T - Message type\n */\nexport interface WorkerHandler<\n T extends WorkerMessage\n> {\n tx$: Subject /* Message transmission subject */\n rx$: Observable /* Message receive observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n *\n * @template T - Worker message type\n */\ninterface WatchOptions {\n tx$: Observable /* Message transmission observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch a web worker\n *\n * This function returns an observable that will send all values emitted by the\n * message observable to the web worker. Web worker communication is expected\n * to be bidirectional (request-response) and synchronous. Messages that are\n * emitted during a pending request are throttled, the last one is emitted.\n *\n * @param worker - Web worker\n * @param options - Options\n *\n * @return Worker message observable\n */\nexport function watchWorker(\n worker: Worker, { tx$ }: WatchOptions\n): Observable {\n\n /* Intercept messages from worker-like objects */\n const rx$ = fromEventPattern(next =>\n worker.addEventListener(\"message\", next)\n )\n .pipe(\n pluck(\"data\")\n )\n\n /* Send and receive messages, return hot observable */\n return tx$\n .pipe(\n throttle(() => rx$, { leading: true, trailing: true }),\n tap(message => worker.postMessage(message)),\n switchMapTo(rx$),\n share()\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { SearchIndex, SearchTransformFn } from \"integrations\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Feature flags\n */\nexport type Feature =\n | \"tabs\" /* Tabs navigation */\n | \"instant\" /* Instant loading\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Configuration\n */\nexport interface Config {\n base: string /* Base URL */\n features: Feature[] /* Feature flags */\n search: {\n worker: string /* Worker URL */\n index?: Promise /* Promise resolving with index */\n transform?: SearchTransformFn /* Transformation function */\n }\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Ensure that the given value is a valid configuration\n *\n * We could use `jsonschema` or any other schema validation framework, but that\n * would just add more bloat to the bundle, so we'll keep it plain and simple.\n *\n * @param config - Configuration\n *\n * @return Test result\n */\nexport function isConfig(config: any): config is Config {\n return typeof config === \"object\"\n && typeof config.base === \"string\"\n && typeof config.features === \"object\"\n && typeof config.search === \"object\"\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n// tslint:disable no-null-keyword\n\nimport { JSX as JSXInternal } from \"preact\"\nimport { keys } from \"ramda\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * HTML and SVG attributes\n */\ntype Attributes =\n & JSXInternal.HTMLAttributes\n & JSXInternal.SVGAttributes\n & Record\n\n/**\n * Child element\n */\ntype Child =\n | HTMLElement\n | SVGElement\n | Text\n | string\n | number\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Create an element\n *\n * @param tagName - HTML or SVG tag\n *\n * @return Element\n */\nfunction createElement(tagName: string): HTMLElement | SVGElement {\n switch (tagName) {\n\n /* SVG elements */\n case \"svg\":\n case \"path\":\n return document.createElementNS(\"http://www.w3.org/2000/svg\", tagName)\n\n /* HTML elements */\n default:\n return document.createElement(tagName)\n }\n}\n\n/**\n * Set an attribute\n *\n * @param el - Element\n * @param name - Attribute name\n * @param value - Attribute value\n */\nfunction setAttribute(\n el: HTMLElement | SVGElement, name: string, value: string) {\n switch (name) {\n\n /* Attributes to be ignored */\n case \"xmlns\":\n break\n\n /* Attributes of SVG elements */\n case \"viewBox\":\n case \"d\":\n if (typeof value !== \"boolean\")\n el.setAttributeNS(null, name, value)\n else if (value)\n el.setAttributeNS(null, name, \"\")\n break\n\n /* Attributes of HTML elements */\n default:\n if (typeof value !== \"boolean\")\n el.setAttribute(name, value)\n else if (value)\n el.setAttribute(name, \"\")\n }\n}\n\n/**\n * Append a child node to an element\n *\n * @param el - Element\n * @param child - Child node(s)\n */\nfunction appendChild(\n el: HTMLElement | SVGElement, child: Child | Child[]\n): void {\n\n /* Handle primitive types (including raw HTML) */\n if (typeof child === \"string\" || typeof child === \"number\") {\n el.innerHTML += child.toString()\n\n /* Handle nodes */\n } else if (child instanceof Node) {\n el.appendChild(child)\n\n /* Handle nested children */\n } else if (Array.isArray(child)) {\n for (const node of child)\n appendChild(el, node)\n }\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * JSX factory\n *\n * @param tagName - HTML or SVG tag\n * @param attributes - HTML attributes\n * @param children - Child elements\n *\n * @return Element\n */\nexport function h(\n tagName: string, attributes: Attributes | null, ...children: Child[]\n): HTMLElement | SVGElement {\n const el = createElement(tagName)\n\n /* Set attributes, if any */\n if (attributes)\n for (const attr of keys(attributes))\n setAttribute(el, attr, attributes[attr])\n\n /* Append child nodes */\n for (const child of children)\n appendChild(el, child)\n\n /* Return element */\n return el\n}\n\n/* ----------------------------------------------------------------------------\n * Namespace\n * ------------------------------------------------------------------------- */\n\nexport declare namespace h {\n namespace JSX {\n type Element = HTMLElement | SVGElement\n type IntrinsicElements = JSXInternal.IntrinsicElements\n }\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, defer, of } from \"rxjs\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Cache the last value emitted by an observable in session storage\n *\n * If the key is not found in session storage, the factory is executed and the\n * latest value emitted will automatically be persisted to sessions storage.\n * Note that the values emitted by the returned observable must be serializable\n * as `JSON`, or data will be lost.\n *\n * @template T - Value type\n *\n * @param key - Cache key\n * @param factory - Observable factory\n *\n * @return Value observable\n */\nexport function cache(\n key: string, factory: () => Observable\n): Observable {\n return defer(() => {\n const data = sessionStorage.getItem(key)\n if (data) {\n return of(JSON.parse(data) as T)\n\n /* Retrieve value from observable factory and write to storage */\n } else {\n const value$ = factory()\n value$.subscribe(value => {\n try {\n sessionStorage.setItem(key, JSON.stringify(value))\n } catch (err) {\n /* Uncritical, just swallow */\n }\n })\n\n /* Return value */\n return value$\n }\n })\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { getElementOrThrow } from \"browser\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Translation keys\n */\ntype TranslateKey =\n | \"clipboard.copy\" /* Copy to clipboard */\n | \"clipboard.copied\" /* Copied to clipboard */\n | \"search.config.lang\" /* Search language */\n | \"search.config.pipeline\" /* Search pipeline */\n | \"search.config.separator\" /* Search separator */\n | \"search.result.placeholder\" /* Type to start searching */\n | \"search.result.none\" /* No matching documents */\n | \"search.result.one\" /* 1 matching document */\n | \"search.result.other\" /* # matching documents */\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * Translations\n */\nlet lang: Record\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Translate the given key\n *\n * @param key - Key to be translated\n * @param value - Value to be replaced\n *\n * @return Translation\n */\nexport function translate(key: TranslateKey, value?: string): string {\n if (typeof lang === \"undefined\") {\n const el = getElementOrThrow(\"#__lang\")\n lang = JSON.parse(el.textContent!)\n }\n if (typeof lang[key] === \"undefined\") {\n throw new ReferenceError(`Invalid translation: ${key}`)\n }\n return typeof value !== \"undefined\"\n ? lang[key].replace(\"#\", value)\n : lang[key]\n}\n\n/**\n * Truncate a string after the given number of characters\n *\n * This is not a very reasonable approach, since the summaries kind of suck.\n * It would be better to create something more intelligent, highlighting the\n * search occurrences and making a better summary out of it, but this note was\n * written three years ago, so who knows if we'll ever fix it.\n *\n * @param value - Value to be truncated\n * @param n - Number of characters\n *\n * @return Truncated value\n */\nexport function truncate(value: string, n: number): string {\n let i = n\n if (value.length > i) {\n while (value[i] !== \" \" && --i > 0); // tslint:disable-line\n return `${value.substring(0, i)}...`\n }\n return value\n}\n\n/**\n * Round a number for display with source facts\n *\n * This is a reverse engineered version of GitHub's weird rounding algorithm\n * for stars, forks and all other numbers. While all numbers below `1,000` are\n * returned as-is, bigger numbers are converted to fixed numbers:\n *\n * - `1,049` => `1k`\n * - `1,050` => `1.1k`\n * - `1,949` => `1.9k`\n * - `1,950` => `2k`\n *\n * @param value - Original value\n *\n * @return Rounded value\n */\nexport function round(value: number): string {\n if (value > 999) {\n const digits = +((value - 950) % 1000 > 99)\n return `${((value + 0.000001) / 1000).toFixed(digits)}k`\n } else {\n return value.toString()\n }\n}\n\n/**\n * Simple hash function\n *\n * @see https://bit.ly/2wsVjJ4 - Original source\n *\n * @param value - Value to be hashed\n *\n * @return Hash as 32bit integer\n */\nexport function hash(value: string): number {\n let h = 0\n for (let i = 0, len = value.length; i < len; i++) {\n h = ((h << 5) - h) + value.charCodeAt(i)\n h |= 0 // Convert to 32bit integer\n }\n return h\n }\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nexport * from \"./_\"\nexport * from \"./header\"\nexport * from \"./hero\"\nexport * from \"./main\"\nexport * from \"./navigation\"\nexport * from \"./search\"\nexport * from \"./shared\"\nexport * from \"./tabs\"\nexport * from \"./toc\"\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport * as ClipboardJS from \"clipboard\"\nimport { NEVER, Observable, Subject, fromEventPattern } from \"rxjs\"\nimport { mapTo, share, tap } from \"rxjs/operators\"\n\nimport { getElements } from \"browser\"\nimport { renderClipboardButton } from \"templates\"\nimport { translate } from \"utilities\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Setup options\n */\ninterface SetupOptions {\n document$: Observable /* Document observable */\n dialog$: Subject /* Dialog subject */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set up clipboard\n *\n * This function implements the Clipboard.js integration and injects a button\n * into all code blocks when the document changes.\n *\n * @param options - Options\n *\n * @return Clipboard observable\n */\nexport function setupClipboard(\n { document$, dialog$ }: SetupOptions\n): Observable {\n if (!ClipboardJS.isSupported())\n return NEVER\n\n /* Inject 'copy-to-clipboard' buttons */\n document$.subscribe(() => {\n const blocks = getElements(\"pre > code\")\n blocks.forEach((block, index) => {\n const parent = block.parentElement!\n parent.id = `__code_${index}`\n parent.insertBefore(renderClipboardButton(parent.id), block)\n })\n })\n\n /* Initialize clipboard */\n const clipboard$ = fromEventPattern(next => {\n new ClipboardJS(\".md-clipboard\").on(\"success\", next)\n })\n .pipe(\n share()\n )\n\n /* Display notification for clipboard event */\n clipboard$\n .pipe(\n tap(ev => ev.clearSelection()),\n mapTo(translate(\"clipboard.copied\"))\n )\n .subscribe(dialog$)\n\n /* Return clipboard */\n return clipboard$\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Subject, animationFrameScheduler, of } from \"rxjs\"\nimport {\n delay,\n map,\n observeOn,\n switchMap,\n tap\n} from \"rxjs/operators\"\n\nimport { createElement } from \"browser\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Setup options\n */\ninterface SetupOptions {\n duration?: number /* Display duration (default: 2s) */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set up dialog\n *\n * @param options - Options\n *\n * @return Dialog observable\n */\nexport function setupDialog(\n { duration }: SetupOptions = {}\n): Subject {\n const dialog$ = new Subject()\n\n /* Create dialog */\n const dialog = createElement(\"div\") // TODO: improve scoping\n dialog.classList.add(\"md-dialog\", \"md-typeset\")\n\n /* Display dialog */\n dialog$\n .pipe(\n switchMap(text => of(document.body) // useComponent(\"container\")\n .pipe(\n map(container => container.appendChild(dialog)),\n observeOn(animationFrameScheduler),\n delay(1), // Strangley it doesnt work when we push things to the new animation frame...\n tap(el => {\n el.innerHTML = text\n el.setAttribute(\"data-md-state\", \"open\")\n }),\n delay(duration || 2000),\n tap(el => el.removeAttribute(\"data-md-state\")),\n delay(400),\n tap(el => {\n el.innerHTML = \"\"\n el.remove()\n })\n )\n )\n )\n .subscribe()\n\n /* Return dialog */\n return dialog$\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { NEVER, Observable, Subject, fromEvent, merge, of } from \"rxjs\"\nimport { ajax } from \"rxjs//ajax\"\nimport {\n bufferCount,\n catchError,\n debounceTime,\n distinctUntilChanged,\n distinctUntilKeyChanged,\n filter,\n map,\n pluck,\n sample,\n share,\n skip,\n switchMap,\n withLatestFrom\n} from \"rxjs/operators\"\n\nimport {\n Viewport,\n ViewportOffset,\n getElement,\n isAnchorLocation,\n isLocalLocation,\n replaceElement,\n setLocation,\n setLocationHash,\n setToggle,\n setViewportOffset\n} from \"browser\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * History state\n */\ninterface State {\n url: URL /* State URL */\n offset?: ViewportOffset /* State viewport offset */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Setup options\n */\ninterface SetupOptions {\n document$: Subject /* Document subject */\n location$: Subject /* Location subject */\n viewport$: Observable /* Viewport observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set up instant loading\n *\n * When fetching, theoretically, we could use `responseType: \"document\"`, but\n * since all MkDocs links are relative, we need to make sure that the current\n * location matches the document we just loaded. Otherwise any relative links\n * in the document could use the old location.\n *\n * This is the reason why we need to synchronize history events and the process\n * of fetching the document for navigation changes (except `popstate` events):\n *\n * 1. Fetch document via `XMLHTTPRequest`\n * 2. Set new location via `history.pushState`\n * 3. Parse and emit fetched document\n *\n * For `popstate` events, we must not use `history.pushState`, or the forward\n * history will be irreversibly overwritten. In case the request fails, the\n * location change is dispatched regularly.\n *\n * @param options - Options\n */\nexport function setupInstantLoading(\n { document$, viewport$, location$ }: SetupOptions\n): void {\n\n /* Disable automatic scroll restoration */\n if (\"scrollRestoration\" in history)\n history.scrollRestoration = \"manual\"\n\n /* Hack: ensure that reloads restore viewport offset */\n fromEvent(window, \"beforeunload\")\n .subscribe(() => {\n history.scrollRestoration = \"auto\"\n })\n\n /* Hack: ensure absolute favicon link to omit 404s on document switch */\n const favicon = getElement(`link[rel=\"shortcut icon\"]`)\n if (typeof favicon !== \"undefined\")\n favicon.href = favicon.href // tslint:disable-line no-self-assignment\n\n /* Intercept link clicks and convert to state change */\n const state$ = fromEvent(document.body, \"click\")\n .pipe(\n filter(ev => !(ev.metaKey || ev.ctrlKey)),\n switchMap(ev => {\n if (ev.target instanceof HTMLElement) {\n const el = ev.target.closest(\"a\")\n if (el && !el.target && isLocalLocation(el)) {\n if (!isAnchorLocation(el))\n ev.preventDefault()\n return of(el)\n }\n }\n return NEVER\n }),\n map(el => ({ url: new URL(el.href) })),\n share()\n )\n\n /* Always close search on link click */\n state$.subscribe(() => {\n setToggle(\"search\", false)\n })\n\n /* Filter state changes to dispatch */\n const push$ = state$\n .pipe(\n filter(({ url }) => !isAnchorLocation(url)),\n share()\n )\n\n /* Intercept popstate events (history back and forward) */\n const pop$ = fromEvent(window, \"popstate\")\n .pipe(\n filter(ev => ev.state !== null),\n map(ev => ({\n url: new URL(location.href),\n offset: ev.state\n })),\n share()\n )\n\n /* Emit location change */\n merge(push$, pop$)\n .pipe(\n distinctUntilChanged((prev, next) => prev.url.href === next.url.href),\n pluck(\"url\")\n )\n .subscribe(location$)\n\n /* Fetch document on location change */\n const ajax$ = location$\n .pipe(\n distinctUntilKeyChanged(\"pathname\"),\n skip(1),\n switchMap(url => ajax({\n url: url.href,\n responseType: \"text\",\n withCredentials: true\n })\n .pipe(\n catchError(() => {\n setLocation(url)\n return NEVER\n })\n )\n )\n )\n\n /* Set new location as soon as the document was fetched */\n push$\n .pipe(\n sample(ajax$)\n )\n .subscribe(({ url }) => {\n history.pushState({}, \"\", url.toString())\n })\n\n /* Parse and emit document */\n const dom = new DOMParser()\n ajax$\n .pipe(\n map(({ response }) => dom.parseFromString(response, \"text/html\"))\n )\n .subscribe(document$)\n\n /* Intercept instant loading */\n const instant$ = merge(push$, pop$)\n .pipe(\n sample(document$)\n )\n\n // TODO: this must be combined with search scroll restoration on mobile\n instant$.subscribe(({ url, offset }) => {\n if (url.hash && !offset) {\n setLocationHash(url.hash)\n } else {\n setViewportOffset(offset || { y: 0 })\n }\n })\n\n /* Replace document metadata */\n instant$\n .pipe(\n withLatestFrom(document$)\n )\n .subscribe(([, { title, head }]) => {\n document.dispatchEvent(new CustomEvent(\"DOMContentSwitch\"))\n document.title = title\n\n /* Replace meta tags */\n for (const selector of [\n `link[rel=\"canonical\"]`,\n `meta[name=\"author\"]`,\n `meta[name=\"description\"]`\n ]) {\n const next = getElement(selector, head)\n const prev = getElement(selector, document.head)\n if (\n typeof next !== \"undefined\" &&\n typeof prev !== \"undefined\"\n ) {\n replaceElement(prev, next)\n }\n }\n })\n\n /* Debounce update of viewport offset */\n viewport$\n .pipe(\n debounceTime(250),\n distinctUntilKeyChanged(\"offset\")\n )\n .subscribe(({ offset }) => {\n history.replaceState(offset, \"\")\n })\n\n /* Set viewport offset from history */\n merge(state$, pop$)\n .pipe(\n bufferCount(2, 1),\n filter(([prev, next]) => {\n return prev.url.pathname === next.url.pathname\n && !isAnchorLocation(next.url)\n }),\n map(([, state]) => state)\n )\n .subscribe(({ offset }) => {\n setViewportOffset(offset || { y: 0 })\n })\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable } from \"rxjs\"\nimport {\n filter,\n map,\n share,\n withLatestFrom\n} from \"rxjs/operators\"\n\nimport {\n Key,\n getActiveElement,\n getElement,\n getElements,\n getToggle,\n isSusceptibleToKeyboard,\n setElementFocus,\n setElementSelection,\n setToggle,\n watchKeyboard\n} from \"browser\"\nimport { useComponent } from \"components\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Keyboard mode\n */\nexport type KeyboardMode =\n | \"global\" /* Global */\n | \"search\" /* Search is open */\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Keyboard\n */\nexport interface Keyboard extends Key {\n mode: KeyboardMode /* Keyboard mode */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set up keyboard\n *\n * This function will set up the keyboard handlers and ensure that keys are\n * correctly propagated. Currently there are two modes:\n *\n * - `global`: This mode is active when the search is closed. It is intended\n * to assign hotkeys to specific functions of the site. Currently the search,\n * previous and next page can be triggered.\n *\n * - `search`: This mode is active when the search is open. It maps certain\n * navigational keys to offer search results that can be entirely navigated\n * through keyboard input.\n *\n * The keyboard observable is returned and can be used to monitor the keyboard\n * in order toassign further hotkeys to custom functions.\n *\n * @return Keyboard observable\n */\nexport function setupKeyboard(): Observable {\n const keyboard$ = watchKeyboard()\n .pipe(\n map(key => ({\n mode: getToggle(\"search\") ? \"search\" : \"global\",\n ...key\n })),\n filter(({ mode }) => {\n if (mode === \"global\") {\n const active = getActiveElement()\n if (typeof active !== \"undefined\")\n return !isSusceptibleToKeyboard(active)\n }\n return true\n }),\n share()\n )\n\n /* Set up search keyboard handlers */\n keyboard$\n .pipe(\n filter(({ mode }) => mode === \"search\"),\n withLatestFrom(\n useComponent(\"search-query\"),\n useComponent(\"search-result\")\n )\n )\n .subscribe(([key, query, result]) => {\n const active = getActiveElement()\n switch (key.type) {\n\n /* Enter: prevent form submission */\n case \"Enter\":\n if (active === query)\n key.claim()\n break\n\n /* Escape or Tab: close search */\n case \"Escape\":\n case \"Tab\":\n setToggle(\"search\", false)\n setElementFocus(query, false)\n break\n\n /* Vertical arrows: select previous or next search result */\n case \"ArrowUp\":\n case \"ArrowDown\":\n if (typeof active === \"undefined\") {\n setElementFocus(query)\n } else {\n const els = [query, ...getElements(\"[href]\", result)]\n const i = Math.max(0, (\n Math.max(0, els.indexOf(active)) + els.length + (\n key.type === \"ArrowUp\" ? -1 : +1\n )\n ) % els.length)\n setElementFocus(els[i])\n }\n\n /* Prevent scrolling of page */\n key.claim()\n break\n\n /* All other keys: hand to search query */\n default:\n if (query !== getActiveElement())\n setElementFocus(query)\n }\n })\n\n /* Set up global keyboard handlers */\n keyboard$\n .pipe(\n filter(({ mode }) => mode === \"global\"),\n withLatestFrom(useComponent(\"search-query\"))\n )\n .subscribe(([key, query]) => {\n switch (key.type) {\n\n /* Open search and select query */\n case \"f\":\n case \"s\":\n case \"/\":\n setElementFocus(query)\n setElementSelection(query)\n key.claim()\n break\n\n /* Go to previous page */\n case \"p\":\n case \",\":\n const prev = getElement(\"[href][rel=prev]\")\n if (typeof prev !== \"undefined\")\n prev.click()\n break\n\n /* Go to next page */\n case \"n\":\n case \".\":\n const next = getElement(\"[href][rel=next]\")\n if (typeof next !== \"undefined\")\n next.click()\n break\n }\n })\n\n /* Return keyboard */\n return keyboard$\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n ArticleDocument,\n SearchDocumentMap,\n SectionDocument,\n setupSearchDocumentMap\n} from \"../document\"\nimport {\n SearchHighlightFactoryFn,\n setupSearchHighlighter\n} from \"../highlighter\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search index configuration\n */\nexport interface SearchIndexConfig {\n lang: string[] /* Search languages */\n separator: string /* Search separator */\n}\n\n/**\n * Search index document\n */\nexport interface SearchIndexDocument {\n location: string /* Document location */\n title: string /* Document title */\n text: string /* Document text */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Search index pipeline function\n */\nexport type SearchIndexPipelineFn =\n | \"stemmer\" /* Stemmer */\n | \"stopWordFilter\" /* Stop word filter */\n | \"trimmer\" /* Trimmer */\n\n/**\n * Search index pipeline\n */\nexport type SearchIndexPipeline = SearchIndexPipelineFn[]\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Search index\n *\n * This interfaces describes the format of the `search_index.json` file which\n * is automatically built by the MkDocs search plugin.\n */\nexport interface SearchIndex {\n config: SearchIndexConfig /* Search index configuration */\n docs: SearchIndexDocument[] /* Search index documents */\n index?: object | string /* Prebuilt or serialized index */\n pipeline?: SearchIndexPipeline /* Search index pipeline */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Search result\n */\nexport interface SearchResult {\n article: ArticleDocument /* Article document */\n sections: SectionDocument[] /* Section documents */\n}\n\n/* ----------------------------------------------------------------------------\n * Class\n * ------------------------------------------------------------------------- */\n\n/**\n * Search\n *\n * Note that `lunr` is injected via Webpack, as it will otherwise also be\n * bundled in the application bundle.\n */\nexport class Search {\n\n /**\n * Search document mapping\n *\n * A mapping of URLs (including hash fragments) to the actual articles and\n * sections of the documentation. The search document mapping must be created\n * regardless of whether the index was prebuilt or not, as `lunr` itself will\n * only store the actual index.\n */\n protected documents: SearchDocumentMap\n\n /**\n * Search highlight factory function\n */\n protected highlight: SearchHighlightFactoryFn\n\n /**\n * The `lunr` search index\n */\n protected index: lunr.Index\n\n /**\n * Create the search integration\n *\n * @param data - Search index\n */\n public constructor({ config, docs, pipeline, index }: SearchIndex) {\n this.documents = setupSearchDocumentMap(docs)\n this.highlight = setupSearchHighlighter(config)\n\n /* If no index was given, create it */\n if (typeof index === \"undefined\") {\n this.index = lunr(function() {\n pipeline = pipeline || [\"trimmer\", \"stopWordFilter\"]\n\n /* Set up pipeline according to configuration */\n this.pipeline.reset()\n for (const fn of pipeline)\n this.pipeline.add(lunr[fn])\n\n /* Set up alternate search languages */\n if (config.lang.length === 1 && config.lang[0] !== \"en\") {\n this.use((lunr as any)[config.lang[0]])\n } else if (config.lang.length > 1) {\n this.use((lunr as any).multiLanguage(...config.lang))\n }\n\n /* Set up fields and reference */\n this.field(\"title\", { boost: 1000 })\n this.field(\"text\")\n this.ref(\"location\")\n\n /* Index documents */\n for (const doc of docs)\n this.add(doc)\n })\n\n /* Prebuilt or serialized index */\n } else {\n this.index = lunr.Index.load(\n typeof index === \"string\"\n ? JSON.parse(index)\n : index\n )\n }\n }\n\n /**\n * Search for matching documents\n *\n * The search index which MkDocs provides is divided up into articles, which\n * contain the whole content of the individual pages, and sections, which only\n * contain the contents of the subsections obtained by breaking the individual\n * pages up at `h1` ... `h6`. As there may be many sections on different pages\n * with identical titles (for example within this very project, e.g. \"Usage\"\n * or \"Installation\"), they need to be put into the context of the containing\n * page. For this reason, section results are grouped within their respective\n * articles which are the top-level results that are returned.\n *\n * @param value - Query value\n *\n * @return Search results\n */\n public query(value: string): SearchResult[] {\n if (value) {\n try {\n\n /* Group sections by containing article */\n const groups = this.index.search(value)\n .reduce((results, result) => {\n const document = this.documents.get(result.ref)\n if (typeof document !== \"undefined\") {\n if (\"parent\" in document) {\n const ref = document.parent.location\n results.set(ref, [...results.get(ref) || [], result])\n } else {\n const ref = document.location\n results.set(ref, results.get(ref) || [])\n }\n }\n return results\n }, new Map())\n\n /* Create highlighter for query */\n const fn = this.highlight(value)\n\n /* Map groups to search documents */\n return [...groups].map(([ref, sections]) => ({\n article: fn(this.documents.get(ref) as ArticleDocument),\n sections: sections.map(section => {\n return fn(this.documents.get(section.ref) as SectionDocument)\n })\n }))\n\n /* Log errors to console (for now) */\n } catch (err) {\n // tslint:disable-next-line no-console\n console.warn(`Invalid query: ${value} – see https://bit.ly/2s3ChXG`)\n }\n }\n\n /* Return nothing in case of error or empty query */\n return []\n }\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport * as escapeHTML from \"escape-html\"\n\nimport { SearchIndexDocument } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * A top-level article\n */\nexport interface ArticleDocument extends SearchIndexDocument {\n linked: boolean /* Whether the section was linked */\n}\n\n/**\n * A section of an article\n */\nexport interface SectionDocument extends SearchIndexDocument {\n parent: ArticleDocument /* Parent article */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Search document\n */\nexport type SearchDocument =\n | ArticleDocument\n | SectionDocument\n\n/**\n * Search document mapping\n */\nexport type SearchDocumentMap = Map\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Create a search document mapping\n *\n * @param docs - Search index documents\n *\n * @return Search document map\n */\nexport function setupSearchDocumentMap(\n docs: SearchIndexDocument[]\n): SearchDocumentMap {\n const documents = new Map()\n for (const doc of docs) {\n const [path, hash] = doc.location.split(\"#\")\n\n /* Extract location and title */\n const location = doc.location\n const title = doc.title\n\n /* Escape and cleanup text */\n const text = escapeHTML(doc.text)\n .replace(/\\s+(?=[,.:;!?])/g, \"\")\n .replace(/\\s+/g, \" \")\n\n /* Handle section */\n if (hash) {\n const parent = documents.get(path) as ArticleDocument\n\n /* Ignore first section, override article */\n if (!parent.linked) {\n parent.title = doc.title\n parent.text = text\n parent.linked = true\n\n /* Add subsequent section */\n } else {\n documents.set(location, {\n location,\n title,\n text,\n parent\n })\n }\n\n /* Add article */\n } else {\n documents.set(location, {\n location,\n title,\n text,\n linked: false\n })\n }\n }\n return documents\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { SearchIndexConfig } from \"../_\"\nimport { SearchDocument } from \"../document\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search highlight function\n *\n * @template T - Search document type\n *\n * @param document - Search document\n *\n * @return Highlighted document\n */\nexport type SearchHighlightFn = <\n T extends SearchDocument\n>(document: Readonly) => T\n\n/**\n * Search highlight factory function\n *\n * @param value - Query value\n *\n * @return Search highlight function\n */\nexport type SearchHighlightFactoryFn = (value: string) => SearchHighlightFn\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Create a search highlighter\n *\n * @param config - Search index configuration\n *\n * @return Search highlight factory function\n */\nexport function setupSearchHighlighter(\n config: SearchIndexConfig\n): SearchHighlightFactoryFn {\n const separator = new RegExp(config.separator, \"img\")\n const highlight = (_: unknown, data: string, term: string) => {\n return `${data}${term}`\n }\n\n /* Return factory function */\n return (value: string) => {\n value = value\n .replace(/[\\s*+-:~^]+/g, \" \")\n .trim()\n\n /* Create search term match expression */\n const match = new RegExp(`(^|${config.separator})(${\n value\n .replace(/[|\\\\{}()[\\]^$+*?.-]/g, \"\\\\$&\")\n .replace(separator, \"|\")\n })`, \"img\")\n\n /* Highlight document */\n return document => ({\n ...document,\n title: document.title.replace(match, highlight),\n text: document.text.replace(match, highlight)\n })\n }\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search transformation function\n *\n * @param value - Query value\n *\n * @return Transformed query value\n */\nexport type SearchTransformFn = (value: string) => string\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Default transformation function\n *\n * Rogue control characters are filtered before handing the query to the\n * search index, as `lunr` will throw otherwise.\n *\n * @param value - Query value\n *\n * @return Transformed query value\n */\nexport function defaultTransform(value: string): string {\n return value\n .replace(/(?:^|\\s+)[*+-:^~]+(?=\\s+|$)/g, \"\")\n .trim()\n .replace(/\\s+|\\b$/g, \"* \")\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A RTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { SearchIndex, SearchResult } from \"../../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search message type\n */\nexport const enum SearchMessageType {\n SETUP, /* Search index setup */\n READY, /* Search index ready */\n QUERY, /* Search query */\n RESULT /* Search results */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * A message containing the data necessary to setup the search index\n */\nexport interface SearchSetupMessage {\n type: SearchMessageType.SETUP /* Message type */\n data: SearchIndex /* Message data */\n}\n\n/**\n * A message indicating the search index is ready\n */\nexport interface SearchReadyMessage {\n type: SearchMessageType.READY /* Message type */\n}\n\n/**\n * A message containing a search query\n */\nexport interface SearchQueryMessage {\n type: SearchMessageType.QUERY /* Message type */\n data: string /* Message data */\n}\n\n/**\n * A message containing results for a search query\n */\nexport interface SearchResultMessage {\n type: SearchMessageType.RESULT /* Message type */\n data: SearchResult[] /* Message data */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * A message exchanged with the search worker\n */\nexport type SearchMessage =\n | SearchSetupMessage\n | SearchReadyMessage\n | SearchQueryMessage\n | SearchResultMessage\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Type guard for search setup messages\n *\n * @param message - Search worker message\n *\n * @return Test result\n */\nexport function isSearchSetupMessage(\n message: SearchMessage\n): message is SearchSetupMessage {\n return message.type === SearchMessageType.SETUP\n}\n\n/**\n * Type guard for search ready messages\n *\n * @param message - Search worker message\n *\n * @return Test result\n */\nexport function isSearchReadyMessage(\n message: SearchMessage\n): message is SearchReadyMessage {\n return message.type === SearchMessageType.READY\n}\n\n/**\n * Type guard for search query messages\n *\n * @param message - Search worker message\n *\n * @return Test result\n */\nexport function isSearchQueryMessage(\n message: SearchMessage\n): message is SearchQueryMessage {\n return message.type === SearchMessageType.QUERY\n}\n\n/**\n * Type guard for search result messages\n *\n * @param message - Search worker message\n *\n * @return Test result\n */\nexport function isSearchResultMessage(\n message: SearchMessage\n): message is SearchResultMessage {\n return message.type === SearchMessageType.RESULT\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A RTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { identity } from \"ramda\"\nimport { Observable, Subject, asyncScheduler } from \"rxjs\"\nimport {\n map,\n observeOn,\n shareReplay,\n withLatestFrom\n} from \"rxjs/operators\"\n\nimport { WorkerHandler, watchWorker } from \"browser\"\nimport { translate } from \"utilities\"\n\nimport { SearchIndex, SearchIndexPipeline } from \"../../_\"\nimport {\n SearchMessage,\n SearchMessageType,\n SearchSetupMessage,\n isSearchResultMessage\n} from \"../message\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Setup options\n */\ninterface SetupOptions {\n index$: Observable /* Search index observable */\n base$: Observable /* Location base observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set up search index\n *\n * @param data - Search index\n *\n * @return Search index\n */\nfunction setupSearchIndex(\n { config, docs, index }: SearchIndex\n): SearchIndex {\n\n /* Override default language with value from translation */\n if (config.lang.length === 1 && config.lang[0] === \"en\")\n config.lang = [translate(\"search.config.lang\")]\n\n /* Override default separator with value from translation */\n if (config.separator === \"[\\s\\-]+\")\n config.separator = translate(\"search.config.separator\")\n\n /* Set pipeline from translation */\n const pipeline = translate(\"search.config.pipeline\")\n .split(/\\s*,\\s*/)\n .filter(identity) as SearchIndexPipeline\n\n /* Return search index after defaulting */\n return { config, docs, index, pipeline }\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set up search web worker\n *\n * This function will create a web worker to set up and query the search index\n * which is done using `lunr`. The index must be passed as an observable to\n * enable hacks like _localsearch_ via search index embedding as JSON.\n *\n * @param url - Worker URL\n * @param options - Options\n *\n * @return Worker handler\n */\nexport function setupSearchWorker(\n url: string, { index$, base$ }: SetupOptions\n): WorkerHandler {\n const worker = new Worker(url)\n\n /* Create communication channels and resolve relative links */\n const tx$ = new Subject()\n const rx$ = watchWorker(worker, { tx$ })\n .pipe(\n withLatestFrom(base$),\n map(([message, base]) => {\n if (isSearchResultMessage(message)) {\n for (const { article, sections } of message.data) {\n article.location = `${base}/${article.location}`\n for (const section of sections)\n section.location = `${base}/${section.location}`\n }\n }\n return message\n }),\n shareReplay(1)\n )\n\n /* Set up search index */\n index$\n .pipe(\n map(index => ({\n type: SearchMessageType.SETUP,\n data: setupSearchIndex(index)\n })),\n observeOn(asyncScheduler)\n )\n .subscribe(tx$.next.bind(tx$))\n\n /* Return worker handler */\n return { tx$, rx$ }\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set sidebar offset\n *\n * @param el - Sidebar element\n * @param value - Sidebar offset\n */\nexport function setSidebarOffset(\n el: HTMLElement, value: number\n): void {\n el.style.top = `${value}px`\n}\n\n/**\n * Reset sidebar offset\n *\n * @param el - Sidebar element\n */\nexport function resetSidebarOffset(\n el: HTMLElement\n): void {\n el.style.top = \"\"\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Set sidebar height\n *\n * @param el - Sidebar element\n * @param value - Sidebar height\n */\nexport function setSidebarHeight(\n el: HTMLElement, value: number\n): void {\n el.style.height = `${value}px`\n}\n\n/**\n * Reset sidebar height\n *\n * @param el - Sidebar element\n */\nexport function resetSidebarHeight(\n el: HTMLElement\n): void {\n el.style.height = \"\"\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Set sidebar lock\n *\n * @param el - Sidebar element\n * @param value - Whether the sidebar is locked\n */\nexport function setSidebarLock(\n el: HTMLElement, value: boolean\n): void {\n el.setAttribute(\"data-md-state\", value ? \"lock\" : \"\")\n}\n\n/**\n * Reset sidebar lock\n *\n * @param el - Sidebar element\n */\nexport function resetSidebarLock(\n el: HTMLElement\n): void {\n el.removeAttribute(\"data-md-state\")\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { EMPTY, Observable, of } from \"rxjs\"\nimport {\n distinctUntilChanged,\n map,\n scan,\n shareReplay,\n switchMap\n} from \"rxjs/operators\"\n\nimport { getElement, replaceElement } from \"browser\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Component\n */\nexport type Component =\n | \"announce\" /* Announcement bar */\n | \"container\" /* Container */\n | \"header\" /* Header */\n | \"header-title\" /* Header title */\n | \"hero\" /* Hero */\n | \"main\" /* Main area */\n | \"navigation\" /* Navigation */\n | \"search\" /* Search */\n | \"search-query\" /* Search input */\n | \"search-reset\" /* Search reset */\n | \"search-result\" /* Search results */\n | \"skip\" /* Skip link */\n | \"tabs\" /* Tabs */\n | \"toc\" /* Table of contents */\n\n/**\n * Component map\n */\nexport type ComponentMap = {\n [P in Component]?: HTMLElement\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n document$: Observable /* Document observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * Component map observable\n */\nlet components$: Observable\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set up bindings to components with given names\n *\n * This function will maintain bindings to the elements identified by the given\n * names in-between document switches and update the elements in-place.\n *\n * @param names - Component names\n * @param options - Options\n */\nexport function setupComponents(\n names: Component[], { document$ }: WatchOptions\n): void {\n components$ = document$\n .pipe(\n\n /* Build component map */\n map(document => names.reduce((components, name) => {\n const el = getElement(`[data-md-component=${name}]`, document)\n return {\n ...components,\n ...typeof el !== \"undefined\" ? { [name]: el } : {}\n }\n }, {})),\n\n /* Re-compute component map on document switch */\n scan((prev, next) => {\n for (const name of names) {\n switch (name) {\n\n /* Top-level components: update */\n case \"announce\":\n case \"header-title\":\n case \"container\":\n case \"skip\":\n if (name in prev && typeof prev[name] !== \"undefined\") {\n replaceElement(prev[name]!, next[name]!)\n prev[name] = next[name]\n }\n break\n\n /* All other components: rebind */\n default:\n if (typeof next[name] !== \"undefined\")\n prev[name] = getElement(`[data-md-component=${name}]`)\n else\n delete prev[name]\n }\n }\n return prev\n }),\n\n /* Convert to hot observable */\n shareReplay(1)\n )\n}\n\n/**\n * Retrieve a component\n *\n * The returned observable will only re-emit if the element changed, i.e. if\n * it was replaced from a document which was switched to.\n *\n * @template T - Element type\n *\n * @param name - Component name\n *\n * @return Component observable\n */\nexport function useComponent(\n name: \"search-query\"\n): Observable\nexport function useComponent(\n name: Component\n): Observable\nexport function useComponent(\n name: Component\n): Observable {\n return components$\n .pipe(\n switchMap(components => (\n typeof components[name] !== \"undefined\"\n ? of(components[name] as T)\n : EMPTY\n )),\n distinctUntilChanged()\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set anchor blur\n *\n * @param el - Anchor element\n * @param value - Whether the anchor is blurred\n */\nexport function setAnchorBlur(\n el: HTMLElement, value: boolean\n): void {\n el.setAttribute(\"data-md-state\", value ? \"blur\" : \"\")\n}\n\n/**\n * Reset anchor blur\n *\n * @param el - Anchor element\n */\nexport function resetAnchorBlur(\n el: HTMLElement\n): void {\n el.removeAttribute(\"data-md-state\")\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Set anchor active\n *\n * @param el - Anchor element\n * @param value - Whether the anchor is active\n */\nexport function setAnchorActive(\n el: HTMLElement, value: boolean\n): void {\n el.classList.toggle(\"md-nav__link--active\", value)\n}\n\n/**\n * Reset anchor active\n *\n * @param el - Anchor element\n */\nexport function resetAnchorActive(\n el: HTMLElement\n): void {\n el.classList.remove(\"md-nav__link--active\")\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nexport * from \"./sidebar\"\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { h, translate } from \"utilities\"\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * CSS classes\n */\nconst css = {\n container: \"md-clipboard md-icon\"\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Path of `file-search-outline` icon\n */\nconst path =\n \"M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 \" +\n \"21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render a 'copy-to-clipboard' button\n *\n * @param id - Unique identifier\n *\n * @return Element\n */\nexport function renderClipboardButton(\n id: string\n) {\n return (\n code`}\n >\n \n \n \n \n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { SearchResult } from \"integrations/search\"\nimport { h, truncate } from \"utilities\"\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * CSS classes\n */\nconst css = {\n item: \"md-search-result__item\",\n link: \"md-search-result__link\",\n article: \"md-search-result__article md-search-result__article--document\",\n section: \"md-search-result__article\",\n title: \"md-search-result__title\",\n teaser: \"md-search-result__teaser\"\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Path of `content-copy` icon\n */\nconst path =\n \"M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H13C12.59,21.75 12.2,21.44 \" +\n \"11.86,21.1C11.53,20.77 11.25,20.4 11,20H6V4H13V9H18V10.18C18.71,10.34 \" +\n \"19.39,10.61 20,11V8L14,2M20.31,18.9C21.64,16.79 21,14 \" +\n \"18.91,12.68C16.8,11.35 14,12 12.69,14.08C11.35,16.19 12,18.97 \" +\n \"14.09,20.3C15.55,21.23 17.41,21.23 \" +\n \"18.88,20.32L22,23.39L23.39,22L20.31,18.9M16.5,19A2.5,2.5 0 0,1 \" +\n \"14,16.5A2.5,2.5 0 0,1 16.5,14A2.5,2.5 0 0,1 19,16.5A2.5,2.5 0 0,1 16.5,19Z\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render a search result\n *\n * @param result - Search result\n *\n * @return Element\n */\nexport function renderSearchResult(\n { article, sections }: SearchResult\n) {\n\n /* Render icon */\n const icon = (\n
\n \n \n \n
\n )\n\n /* Render article and sections */\n const children = [article, ...sections].map(document => {\n const { location, title, text } = document\n return (\n \n
\n {!(\"parent\" in document) && icon}\n

{title}

\n {text.length > 0 &&

{truncate(text, 320)}

}\n
\n
\n )\n })\n\n /* Render search result */\n return (\n
  • \n {children}\n
  • \n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { SourceFacts } from \"patches/source\"\nimport { h } from \"utilities\"\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * CSS classes\n */\nconst css = {\n facts: \"md-source__facts\",\n fact: \"md-source__fact\"\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render source facts\n *\n * @param facts - Source facts\n *\n * @return Element\n */\nexport function renderSource(\n facts: SourceFacts\n) {\n const children = facts.map(fact => (\n
  • {fact}
  • \n ))\n return (\n
      \n {children}\n
    \n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { h } from \"utilities\"\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * CSS classes\n */\nconst css = {\n wrapper: \"md-typeset__scrollwrap\",\n table: \"md-typeset__table\"\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Render a table inside a wrapper to improve scrolling on mobile\n *\n * @param table - Table element\n *\n * @return Element\n */\nexport function renderTable(\n table: HTMLTableElement\n) {\n return (\n
    \n
    \n {table}\n
    \n
    \n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nexport * from \"./_\"\nexport * from \"./react\"\nexport * from \"./set\"\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nexport * from \"./_\"\nexport * from \"./react\"\nexport * from \"./set\"\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n MonoTypeOperatorFunction,\n Observable,\n animationFrameScheduler,\n combineLatest,\n pipe\n} from \"rxjs\"\nimport {\n distinctUntilChanged,\n finalize,\n map,\n observeOn,\n tap,\n withLatestFrom\n} from \"rxjs/operators\"\n\nimport { Viewport } from \"browser\"\n\nimport { Header } from \"../../../header\"\nimport { Main } from \"../../../main\"\nimport { Sidebar } from \"../_\"\nimport {\n resetSidebarHeight,\n resetSidebarLock,\n resetSidebarOffset,\n setSidebarHeight,\n setSidebarLock,\n setSidebarOffset\n} from \"../set\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n main$: Observable
    /* Main area observable */\n viewport$: Observable /* Viewport observable */\n}\n\n/**\n * Apply options\n */\ninterface ApplyOptions {\n header$: Observable
    /* Header observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch sidebar\n *\n * This function returns an observable that computes the visual parameters of\n * the sidebar which depends on the vertical viewport offset, as well as the\n * height of the main area. When the page is scrolled beyond the header, the\n * sidebar is locked and fills the remaining space.\n *\n * @param el - Sidebar element\n * @param options - Options\n *\n * @return Sidebar observable\n */\nexport function watchSidebar(\n el: HTMLElement, { main$, viewport$ }: WatchOptions\n): Observable {\n const adjust = el.parentElement!.offsetTop\n - el.parentElement!.parentElement!.offsetTop\n\n /* Compute the sidebar's available height and if it should be locked */\n return combineLatest([main$, viewport$])\n .pipe(\n map(([{ offset, height }, { offset: { y } }]) => {\n height = height\n + Math.min(adjust, Math.max(0, y - offset))\n - adjust\n return {\n height,\n lock: y >= offset + adjust\n }\n }),\n distinctUntilChanged((a, b) => {\n return a.height === b.height\n && a.lock === b.lock\n })\n )\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Apply sidebar\n *\n * @param el - Sidebar element\n * @param options - Options\n *\n * @return Operator function\n */\nexport function applySidebar(\n el: HTMLElement, { header$ }: ApplyOptions\n): MonoTypeOperatorFunction {\n return pipe(\n\n /* Defer repaint to next animation frame */\n observeOn(animationFrameScheduler),\n withLatestFrom(header$),\n tap(([{ height, lock }, { height: offset }]) => {\n setSidebarHeight(el, height)\n setSidebarLock(el, lock)\n\n /* Set offset in locked state depending on header height */\n if (lock)\n setSidebarOffset(el, offset)\n else\n resetSidebarOffset(el)\n }),\n\n /* Re-map to sidebar */\n map(([sidebar]) => sidebar),\n\n /* Reset on complete or error */\n finalize(() => {\n resetSidebarOffset(el)\n resetSidebarHeight(el)\n resetSidebarLock(el)\n })\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nexport * from \"./_\"\nexport * from \"./anchor\"\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n Observable,\n OperatorFunction,\n combineLatest,\n of,\n pipe\n} from \"rxjs\"\nimport { map, switchMap } from \"rxjs/operators\"\n\nimport { Viewport, getElements } from \"browser\"\n\nimport { Header } from \"../../header\"\nimport { Main } from \"../../main\"\nimport {\n Sidebar,\n applySidebar,\n watchSidebar\n} from \"../../shared\"\nimport {\n AnchorList,\n applyAnchorList,\n watchAnchorList\n} from \"../anchor\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Table of contents for [tablet -]\n */\ninterface TableOfContentsBelowTablet {} // tslint:disable-line\n\n/**\n * Table of contents for [tablet +]\n */\ninterface TableOfContentsAboveTablet {\n sidebar: Sidebar /* Sidebar */\n anchors: AnchorList /* Anchor list */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Table of contents\n */\nexport type TableOfContents =\n | TableOfContentsBelowTablet\n | TableOfContentsAboveTablet\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n header$: Observable
    /* Header observable */\n main$: Observable
    /* Main area observable */\n viewport$: Observable /* Viewport observable */\n tablet$: Observable /* Tablet media observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount table of contents from source observable\n *\n * @param options - Options\n *\n * @return Operator function\n */\nexport function mountTableOfContents(\n { header$, main$, viewport$, tablet$ }: MountOptions\n): OperatorFunction {\n return pipe(\n switchMap(el => tablet$\n .pipe(\n switchMap(tablet => {\n\n /* [tablet +]: Mount table of contents in sidebar */\n if (tablet) {\n const els = getElements(\".md-nav__link\", el)\n\n /* Watch and apply sidebar */\n const sidebar$ = watchSidebar(el, { main$, viewport$ })\n .pipe(\n applySidebar(el, { header$ })\n )\n\n /* Watch and apply anchor list (scroll spy) */\n const anchors$ = watchAnchorList(els, { header$, viewport$ })\n .pipe(\n applyAnchorList(els)\n )\n\n /* Combine into a single hot observable */\n return combineLatest([sidebar$, anchors$])\n .pipe(\n map(([sidebar, anchors]) => ({ sidebar, anchors }))\n )\n\n /* [tablet -]: Unmount table of contents */\n } else {\n return of({})\n }\n })\n )\n )\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { reverse } from \"ramda\"\nimport {\n MonoTypeOperatorFunction,\n Observable,\n animationFrameScheduler,\n combineLatest,\n pipe\n} from \"rxjs\"\nimport {\n bufferCount,\n distinctUntilChanged,\n distinctUntilKeyChanged,\n finalize,\n map,\n observeOn,\n scan,\n startWith,\n switchMap,\n tap\n} from \"rxjs/operators\"\n\nimport { Viewport, getElement, watchElementSize } from \"browser\"\n\nimport { Header } from \"../../../header\"\nimport { AnchorList } from \"../_\"\nimport {\n resetAnchorActive,\n resetAnchorBlur,\n setAnchorActive,\n setAnchorBlur\n} from \"../set\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n header$: Observable
    /* Header observable */\n viewport$: Observable /* Viewport observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch anchor list\n *\n * This is effectively a scroll-spy implementation which will account for the\n * fixed header and automatically re-calculate anchor offsets when the viewport\n * is resized. The returned observable will only emit if the anchor list needs\n * to be repainted.\n *\n * This implementation tracks an anchor element's entire path starting from its\n * level up to the top-most anchor element, e.g. `[h3, h2, h1]`. Although the\n * Material theme currently doesn't make use of this information, it enables\n * the styling of the entire hierarchy through customization.\n *\n * Note that the current anchor is the last item of the `prev` anchor list.\n *\n * @param els - Anchor elements\n * @param options - Options\n *\n * @return Anchor list observable\n */\nexport function watchAnchorList(\n els: HTMLAnchorElement[], { header$, viewport$ }: WatchOptions\n): Observable {\n const table = new Map()\n for (const el of els) {\n const id = decodeURIComponent(el.hash.substring(1))\n const target = getElement(`[id=\"${id}\"]`)\n if (typeof target !== \"undefined\")\n table.set(el, target)\n }\n\n /* Compute necessary adjustment for header */\n const adjust$ = header$\n .pipe(\n map(header => 18 + header.height)\n )\n\n /* Compute partition of previous and next anchors */\n const partition$ = watchElementSize(document.body)\n .pipe(\n distinctUntilKeyChanged(\"height\"),\n\n /* Build index to map anchor paths to vertical offsets */\n map(() => {\n let path: HTMLAnchorElement[] = []\n return [...table].reduce((index, [anchor, target]) => {\n while (path.length) {\n const last = table.get(path[path.length - 1])!\n if (last.tagName >= target.tagName) {\n path.pop()\n } else {\n break\n }\n }\n\n /* If the current anchor is hidden, continue with its parent */\n let offset = target.offsetTop\n while (!offset && target.parentElement) {\n target = target.parentElement\n offset = target.offsetTop\n }\n\n /* Map reversed anchor path to vertical offset */\n return index.set(\n reverse(path = [...path, anchor]),\n offset\n )\n }, new Map())\n }),\n\n /* Re-compute partition when viewport offset changes */\n switchMap(index => combineLatest([adjust$, viewport$])\n .pipe(\n scan(([prev, next], [adjust, { offset: { y } }]) => {\n\n /* Look forward */\n while (next.length) {\n const [, offset] = next[0]\n if (offset - adjust < y) {\n prev = [...prev, next.shift()!]\n } else {\n break\n }\n }\n\n /* Look backward */\n while (prev.length) {\n const [, offset] = prev[prev.length - 1]\n if (offset - adjust >= y) {\n next = [prev.pop()!, ...next]\n } else {\n break\n }\n }\n\n /* Return partition */\n return [prev, next]\n }, [[], [...index]]),\n distinctUntilChanged((a, b) => {\n return a[0] === b[0]\n && a[1] === b[1]\n })\n )\n )\n )\n\n /* Compute and return anchor list migrations */\n return partition$\n .pipe(\n map(([prev, next]) => ({\n prev: prev.map(([path]) => path),\n next: next.map(([path]) => path)\n })),\n\n /* Extract anchor list migrations */\n startWith({ prev: [], next: [] }),\n bufferCount(2, 1),\n map(([a, b]) => {\n\n /* Moving down */\n if (a.prev.length < b.prev.length) {\n return {\n prev: b.prev.slice(Math.max(0, a.prev.length - 1), b.prev.length),\n next: []\n }\n\n /* Moving up */\n } else {\n return {\n prev: b.prev.slice(-1),\n next: b.next.slice(0, b.next.length - a.next.length)\n }\n }\n })\n )\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Apply anchor list\n *\n * @param els - Anchor elements\n *\n * @return Operator function\n */\nexport function applyAnchorList(\n els: HTMLAnchorElement[]\n): MonoTypeOperatorFunction {\n return pipe(\n\n /* Defer repaint to next animation frame */\n observeOn(animationFrameScheduler),\n tap(({ prev, next }) => {\n\n /* Look forward */\n for (const [el] of next) {\n resetAnchorActive(el)\n resetAnchorBlur(el)\n }\n\n /* Look backward */\n prev.forEach(([el], index) => {\n setAnchorActive(el, index === prev.length - 1)\n setAnchorBlur(el, true)\n })\n }),\n\n /* Reset on complete or error */\n finalize(() => {\n for (const el of els) {\n resetAnchorActive(el)\n resetAnchorBlur(el)\n }\n })\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, OperatorFunction, combineLatest, pipe } from \"rxjs\"\nimport { map, switchMap } from \"rxjs/operators\"\n\nimport { SearchResult } from \"integrations/search\"\n\nimport { SearchQuery } from \"../query\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search\n */\nexport interface Search {\n query: SearchQuery /* Search query */\n result: SearchResult[] /* Search result list */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n query$: Observable /* Search query observable */\n reset$: Observable /* Search reset observable */\n result$: Observable /* Search result observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount search from source observable\n *\n * @param options - Options\n *\n * @return Operator function\n */\nexport function mountSearch(\n { query$, reset$, result$ }: MountOptions\n): OperatorFunction {\n return pipe(\n switchMap(() => combineLatest([query$, result$, reset$])\n .pipe(\n map(([query, result]) => ({ query, result }))\n )\n )\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { OperatorFunction, pipe } from \"rxjs\"\nimport {\n distinctUntilKeyChanged,\n map,\n switchMap\n} from \"rxjs/operators\"\n\nimport { WorkerHandler, setToggle } from \"browser\"\nimport {\n SearchMessage,\n SearchMessageType,\n SearchQueryMessage,\n SearchTransformFn\n} from \"integrations\"\n\nimport { watchSearchQuery } from \"../react\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search query\n */\nexport interface SearchQuery {\n value: string /* Query value */\n focus: boolean /* Query focus */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n transform?: SearchTransformFn /* Transformation function */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount search query from source observable\n *\n * @param handler - Worker handler\n * @param options - Options\n *\n * @return Operator function\n */\nexport function mountSearchQuery(\n { tx$ }: WorkerHandler, options: MountOptions = {}\n): OperatorFunction {\n return pipe(\n switchMap(el => {\n const query$ = watchSearchQuery(el, options)\n\n /* Subscribe worker to search query */\n query$\n .pipe(\n distinctUntilKeyChanged(\"value\"),\n map(({ value }): SearchQueryMessage => ({\n type: SearchMessageType.QUERY,\n data: value\n }))\n )\n .subscribe(tx$.next.bind(tx$))\n\n /* Toggle search on focus */\n query$\n .pipe(\n distinctUntilKeyChanged(\"focus\")\n )\n .subscribe(({ focus }) => {\n if (focus)\n setToggle(\"search\", focus)\n })\n\n /* Return search query */\n return query$\n })\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, combineLatest, fromEvent, merge } from \"rxjs\"\nimport {\n delay,\n distinctUntilChanged,\n map,\n startWith\n} from \"rxjs/operators\"\n\nimport { watchElementFocus } from \"browser\"\nimport { SearchTransformFn, defaultTransform } from \"integrations\"\n\nimport { SearchQuery } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n transform?: SearchTransformFn /* Transformation function */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch search query\n *\n * Note that the focus event which triggers re-reading the current query value\n * is delayed by `1ms` so the input's empty state is allowed to propagate.\n *\n * @param el - Search query element\n * @param options - Options\n *\n * @return Search query observable\n */\nexport function watchSearchQuery(\n el: HTMLInputElement, { transform }: WatchOptions = {}\n): Observable {\n const fn = transform || defaultTransform\n\n /* Intercept keyboard events */\n const value$ = merge(\n fromEvent(el, \"keyup\"),\n fromEvent(el, \"focus\").pipe(delay(1))\n )\n .pipe(\n map(() => fn(el.value)),\n startWith(fn(el.value)),\n distinctUntilChanged()\n )\n\n /* Intercept focus events */\n const focus$ = watchElementFocus(el)\n\n /* Combine into a single observable */\n return combineLatest([value$, focus$])\n .pipe(\n map(([value, focus]) => ({ value, focus }))\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { OperatorFunction, pipe } from \"rxjs\"\nimport {\n mapTo,\n startWith,\n switchMap,\n switchMapTo,\n tap\n} from \"rxjs/operators\"\n\nimport { setElementFocus } from \"browser\"\n\nimport { useComponent } from \"../../../_\"\nimport { watchSearchReset } from \"../react\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount search reset from source observable\n *\n * @return Operator function\n */\nexport function mountSearchReset(): OperatorFunction {\n return pipe(\n switchMap(el => watchSearchReset(el)\n .pipe(\n switchMapTo(useComponent(\"search-query\")),\n tap(setElementFocus),\n mapTo(undefined)\n )\n ),\n startWith(undefined)\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, fromEvent } from \"rxjs\"\nimport { mapTo } from \"rxjs/operators\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch search reset\n *\n * @param el - Search reset element\n *\n * @return Search reset observable\n */\nexport function watchSearchReset(\n el: HTMLElement\n): Observable {\n return fromEvent(el, \"click\")\n .pipe(\n mapTo(undefined)\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { translate } from \"utilities\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set number of search results\n *\n * @param el - Search result metadata element\n * @param value - Number of results\n */\nexport function setSearchResultMeta(\n el: HTMLElement, value: number\n): void {\n switch (value) {\n\n /* No results */\n case 0:\n el.textContent = translate(\"search.result.none\")\n break\n\n /* One result */\n case 1:\n el.textContent = translate(\"search.result.one\")\n break\n\n /* Multiple result */\n default:\n el.textContent = translate(\"search.result.other\", value.toString())\n }\n}\n\n/**\n * Reset number of search results\n *\n * @param el - Search result metadata element\n */\nexport function resetSearchResultMeta(\n el: HTMLElement\n): void {\n el.textContent = translate(\"search.result.placeholder\")\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Add an element to the search result list\n *\n * @param el - Search result list element\n * @param child - Search result element\n */\nexport function addToSearchResultList(\n el: HTMLElement, child: Element\n): void {\n el.appendChild(child)\n}\n\n/**\n * Reset search result list\n *\n * @param el - Search result list element\n */\nexport function resetSearchResultList(\n el: HTMLElement\n): void {\n el.innerHTML = \"\"\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n MonoTypeOperatorFunction,\n Observable,\n animationFrameScheduler,\n pipe\n} from \"rxjs\"\nimport {\n finalize,\n map,\n mapTo,\n observeOn,\n scan,\n switchMap,\n withLatestFrom\n} from \"rxjs/operators\"\n\nimport { getElementOrThrow } from \"browser\"\nimport { SearchResult } from \"integrations/search\"\nimport { renderSearchResult } from \"templates\"\n\nimport { SearchQuery } from \"../../query\"\nimport {\n addToSearchResultList,\n resetSearchResultList,\n resetSearchResultMeta,\n setSearchResultMeta\n} from \"../set\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Apply options\n */\ninterface ApplyOptions {\n query$: Observable /* Search query observable */\n fetch$: Observable /* Result fetch observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Apply search results\n *\n * This function will perform a lazy rendering of the search results, depending\n * on the vertical offset of the search result container. When the scroll offset\n * reaches the bottom of the element, more results are fetched and rendered.\n *\n * @param el - Search result element\n * @param options - Options\n *\n * @return Operator function\n */\nexport function applySearchResult(\n el: HTMLElement, { query$, fetch$ }: ApplyOptions\n): MonoTypeOperatorFunction {\n const list = getElementOrThrow(\".md-search-result__list\", el)\n const meta = getElementOrThrow(\".md-search-result__meta\", el)\n return pipe(\n\n /* Apply search result metadata */\n withLatestFrom(query$),\n map(([result, query]) => {\n if (query.value) {\n setSearchResultMeta(meta, result.length)\n } else {\n resetSearchResultMeta(meta)\n }\n return result\n }),\n\n /* Apply search result list */\n switchMap(result => fetch$\n .pipe(\n\n /* Defer repaint to next animation frame */\n observeOn(animationFrameScheduler),\n scan(index => {\n const container = el.parentElement!\n while (index < result.length) {\n addToSearchResultList(list, renderSearchResult(result[index++]))\n if (container.scrollHeight - container.offsetHeight > 16)\n break\n }\n return index\n }, 0),\n\n /* Re-map to search result */\n mapTo(result),\n\n /* Reset on complete or error */\n finalize(() => {\n resetSearchResultList(list)\n })\n )\n )\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { identity } from \"ramda\"\nimport { Observable, OperatorFunction, pipe } from \"rxjs\"\nimport {\n distinctUntilChanged,\n filter,\n map,\n pluck,\n switchMap\n} from \"rxjs/operators\"\n\nimport { WorkerHandler, watchElementOffset } from \"browser\"\nimport {\n SearchMessage,\n SearchResult,\n isSearchResultMessage\n} from \"integrations\"\n\nimport { SearchQuery } from \"../../query\"\nimport { applySearchResult } from \"../react\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n query$: Observable /* Search query observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount search result from source observable\n *\n * @param handler - Worker handler\n * @param options - Options\n *\n * @return Operator function\n */\nexport function mountSearchResult(\n { rx$ }: WorkerHandler, { query$ }: MountOptions\n): OperatorFunction {\n return pipe(\n switchMap(el => {\n const container = el.parentElement!\n\n /* Compute whether there are more search results to fetch */\n const fetch$ = watchElementOffset(container)\n .pipe(\n map(({ y }) => {\n return y >= container.scrollHeight - container.offsetHeight - 16\n }),\n distinctUntilChanged(),\n filter(identity)\n )\n\n /* Apply search results */\n return rx$\n .pipe(\n filter(isSearchResultMessage),\n pluck(\"data\"),\n applySearchResult(el, { query$, fetch$ })\n )\n })\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, OperatorFunction, pipe } from \"rxjs\"\nimport {\n distinctUntilKeyChanged,\n map,\n switchMap\n} from \"rxjs/operators\"\n\nimport { Viewport, watchViewportAt } from \"browser\"\n\nimport { Header } from \"../../header\"\nimport { applyHero } from \"../react\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Hero\n */\nexport interface Hero {\n hidden: boolean /* Whether the hero is hidden */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n header$: Observable
    /* Header observable */\n viewport$: Observable /* Viewport observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount hero from source observable\n *\n * @param options - Options\n *\n * @return Operator function\n */\nexport function mountHero(\n { header$, viewport$ }: MountOptions\n): OperatorFunction {\n return pipe(\n switchMap(el => watchViewportAt(el, { header$, viewport$ })\n .pipe(\n map(({ offset: { y } }) => ({ hidden: y >= 20 })),\n distinctUntilKeyChanged(\"hidden\"),\n applyHero(el)\n )\n )\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n MonoTypeOperatorFunction,\n animationFrameScheduler,\n pipe\n} from \"rxjs\"\nimport { finalize, observeOn, tap } from \"rxjs/operators\"\n\nimport { Hero } from \"../_\"\nimport {\n resetHeroHidden,\n setHeroHidden\n} from \"../set\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Apply hero\n *\n * @param el - Hero element\n *\n * @return Operator function\n */\nexport function applyHero(\n el: HTMLElement\n): MonoTypeOperatorFunction {\n return pipe(\n\n /* Defer repaint to next animation frame */\n observeOn(animationFrameScheduler),\n tap(({ hidden }) => {\n setHeroHidden(el, hidden)\n }),\n\n /* Reset on complete or error */\n finalize(() => {\n resetHeroHidden(el)\n })\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set hero hidden\n *\n * @param el - Hero element\n * @param value - Whether the element is hidden\n */\nexport function setHeroHidden(\n el: HTMLElement, value: boolean\n): void {\n el.setAttribute(\"data-md-state\", value ? \"hidden\" : \"\")\n}\n\n/**\n * Reset hero hidden\n *\n * @param el - Hero element\n */\nexport function resetHeroHidden(\n el: HTMLElement\n): void {\n el.removeAttribute(\"data-md-state\")\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, OperatorFunction, Subject, pipe } from \"rxjs\"\nimport { distinctUntilKeyChanged, switchMap, tap } from \"rxjs/operators\"\n\nimport { Viewport } from \"browser\"\n\nimport { useComponent } from \"../../_\"\nimport { Header } from \"../../header\"\nimport {\n applyHeaderShadow,\n watchMain\n} from \"../react\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Main area\n */\nexport interface Main {\n offset: number /* Main area top offset */\n height: number /* Main area visible height */\n active: boolean /* Scrolled past top offset */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n header$: Observable
    /* Header observable */\n viewport$: Observable /* Viewport observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount main area from source observable\n *\n * The header must be connected to the main area observable outside of the\n * operator function, as the header will persist in-between document switches\n * while the main area is replaced. However, the header observable must be\n * passed to this function, so we connect both via a long-living subject.\n *\n * @param options - Options\n *\n * @return Operator function\n */\nexport function mountMain(\n { header$, viewport$ }: MountOptions\n): OperatorFunction {\n const main$ = new Subject
    ()\n\n /* Connect to main area observable via long-living subject */\n useComponent(\"header\")\n .pipe(\n switchMap(header => main$\n .pipe(\n distinctUntilKeyChanged(\"active\"),\n applyHeaderShadow(header)\n )\n )\n )\n .subscribe()\n\n /* Return operator */\n return pipe(\n switchMap(el => watchMain(el, { header$, viewport$ })),\n tap(main => main$.next(main))\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n MonoTypeOperatorFunction,\n Observable,\n animationFrameScheduler,\n combineLatest,\n pipe\n} from \"rxjs\"\nimport {\n distinctUntilChanged,\n distinctUntilKeyChanged,\n finalize,\n map,\n observeOn,\n pluck,\n shareReplay,\n switchMap,\n tap\n} from \"rxjs/operators\"\n\nimport { Viewport, watchElementSize } from \"browser\"\n\nimport { Header } from \"../../header\"\nimport { Main } from \"../_\"\nimport {\n resetHeaderShadow,\n setHeaderShadow\n} from \"../set\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n header$: Observable
    /* Header observable */\n viewport$: Observable /* Viewport observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch main area\n *\n * This function returns an observable that computes the visual parameters of\n * the main area which depends on the viewport vertical offset and height, as\n * well as the height of the header element, if the header is fixed.\n *\n * @param el - Main area element\n * @param options - Options\n *\n * @return Main area observable\n */\nexport function watchMain(\n el: HTMLElement, { header$, viewport$ }: WatchOptions\n): Observable
    {\n\n /* Compute necessary adjustment for header */\n const adjust$ = header$\n .pipe(\n pluck(\"height\"),\n distinctUntilChanged(),\n shareReplay(1)\n )\n\n /* Compute the main area's top and bottom borders */\n const border$ = adjust$\n .pipe(\n switchMap(() => watchElementSize(el)\n .pipe(\n map(({ height }) => ({\n top: el.offsetTop,\n bottom: el.offsetTop + height\n }))\n )\n ),\n distinctUntilKeyChanged(\"bottom\"),\n shareReplay(1)\n )\n\n /* Compute the main area's offset, visible height and if we scrolled past */\n return combineLatest([adjust$, border$, viewport$])\n .pipe(\n map(([header, { top, bottom }, { offset: { y }, size: { height } }]) => {\n height = Math.max(0, height\n - Math.max(0, top - y, header)\n - Math.max(0, height + y - bottom)\n )\n return {\n offset: top - header,\n height,\n active: top - header <= y\n }\n }),\n distinctUntilChanged
    ((a, b) => {\n return a.offset === b.offset\n && a.height === b.height\n && a.active === b.active\n })\n )\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Apply header shadow\n *\n * @param el - Header element\n *\n * @return Operator function\n */\nexport function applyHeaderShadow(\n el: HTMLElement\n): MonoTypeOperatorFunction
    {\n return pipe(\n\n /* Defer repaint to next animation frame */\n observeOn(animationFrameScheduler),\n tap(({ active }) => {\n setHeaderShadow(el, active)\n }),\n\n /* Reset on complete or error */\n finalize(() => {\n resetHeaderShadow(el)\n })\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set header shadow\n *\n * @param el - Header element\n * @param value - Whether the shadow is shown\n */\nexport function setHeaderShadow(\n el: HTMLElement, value: boolean\n): void {\n el.setAttribute(\"data-md-state\", value ? \"shadow\" : \"\")\n}\n\n/**\n * Reset header shadow\n *\n * @param el - Header element\n */\nexport function resetHeaderShadow(\n el: HTMLElement\n): void {\n el.removeAttribute(\"data-md-state\")\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, OperatorFunction, of, pipe } from \"rxjs\"\nimport {\n distinctUntilKeyChanged,\n map,\n switchMap\n} from \"rxjs/operators\"\n\nimport { Viewport, watchViewportAt } from \"browser\"\n\nimport { Header } from \"../../header\"\nimport { applyTabs } from \"../react\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Tabs\n */\nexport interface Tabs {\n hidden: boolean /* Whether the tabs are hidden */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n header$: Observable
    /* Header observable */\n viewport$: Observable /* Viewport observable */\n screen$: Observable /* Media screen observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount tabs from source observable\n *\n * @param options - Options\n *\n * @return Operator function\n */\nexport function mountTabs(\n { header$, viewport$, screen$ }: MountOptions\n): OperatorFunction {\n return pipe(\n switchMap(el => screen$\n .pipe(\n switchMap(screen => {\n\n /* [screen +]: Mount tabs above screen breakpoint */\n if (screen) {\n return watchViewportAt(el, { header$, viewport$ })\n .pipe(\n map(({ offset: { y } }) => ({ hidden: y >= 10 })),\n distinctUntilKeyChanged(\"hidden\"),\n applyTabs(el)\n )\n\n /* [screen -]: Unmount tabs below screen breakpoint */\n } else {\n return of({ hidden: true })\n }\n })\n )\n )\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n MonoTypeOperatorFunction,\n animationFrameScheduler,\n pipe\n} from \"rxjs\"\nimport { finalize, observeOn, tap } from \"rxjs/operators\"\n\nimport { Tabs } from \"../_\"\nimport {\n resetTabsHidden,\n setTabsHidden\n} from \"../set\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Apply tabs\n *\n * @param el - Tabs element\n *\n * @return Operator function\n */\nexport function applyTabs(\n el: HTMLElement\n): MonoTypeOperatorFunction {\n return pipe(\n\n /* Defer repaint to next animation frame */\n observeOn(animationFrameScheduler),\n tap(({ hidden }) => {\n setTabsHidden(el, hidden)\n }),\n\n /* Reset on complete or error */\n finalize(() => {\n resetTabsHidden(el)\n })\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set tabs hidden\n *\n * @param el - Tabs element\n * @param value - Whether the element is hidden\n */\nexport function setTabsHidden(\n el: HTMLElement, value: boolean\n): void {\n el.setAttribute(\"data-md-state\", value ? \"hidden\" : \"\")\n}\n\n/**\n * Reset tabs hidden\n *\n * @param el - Tabs element\n */\nexport function resetTabsHidden(\n el: HTMLElement\n): void {\n el.removeAttribute(\"data-md-state\")\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, OperatorFunction, combineLatest, pipe } from \"rxjs\"\nimport {\n distinctUntilChanged,\n filter,\n map,\n shareReplay,\n startWith,\n switchMap,\n withLatestFrom\n} from \"rxjs/operators\"\n\nimport {\n Viewport,\n getElement,\n watchViewportAt\n} from \"browser\"\n\nimport { useComponent } from \"../../_\"\nimport {\n applyHeaderType,\n watchHeader\n} from \"../react\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Header type\n */\nexport type HeaderType =\n | \"site\" /* Header shows site title */\n | \"page\" /* Header shows page title */\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Header\n */\nexport interface Header {\n type: HeaderType /* Header type */\n sticky: boolean /* Header stickyness */\n height: number /* Header visible height */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n document$: Observable /* Document observable */\n viewport$: Observable /* Viewport observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount header from source observable\n *\n * @param options - Options\n *\n * @return Operator function\n */\nexport function mountHeader(\n { document$, viewport$ }: MountOptions\n): OperatorFunction {\n return pipe(\n switchMap(el => {\n const header$ = watchHeader(el, { document$ })\n\n /* Compute whether the header should switch to page header */\n const type$ = useComponent(\"main\")\n .pipe(\n map(main => getElement(\"h1, h2, h3, h4, h5, h6\", main)!),\n filter(hx => typeof hx !== \"undefined\"),\n withLatestFrom(useComponent(\"header-title\")),\n switchMap(([hx, title]) => watchViewportAt(hx, { header$, viewport$ })\n .pipe(\n map(({ offset: { y } }) => {\n return y >= hx.offsetHeight ? \"page\" : \"site\"\n }),\n distinctUntilChanged(),\n applyHeaderType(title)\n )\n ),\n startWith(\"site\")\n )\n\n /* Combine into single observable */\n return combineLatest([header$, type$])\n .pipe(\n map(([header, type]): Header => ({ type, ...header })),\n shareReplay(1)\n )\n })\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n MonoTypeOperatorFunction,\n Observable,\n animationFrameScheduler,\n of,\n pipe\n} from \"rxjs\"\nimport {\n distinctUntilChanged,\n finalize,\n map,\n observeOn,\n shareReplay,\n switchMap,\n tap\n} from \"rxjs/operators\"\n\nimport { watchElementSize } from \"browser\"\n\nimport { Header, HeaderType } from \"../_\"\nimport {\n resetHeaderTitleActive,\n setHeaderTitleActive\n} from \"../set\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch options\n */\ninterface WatchOptions {\n document$: Observable /* Document observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Watch header\n *\n * @param el - Header element\n *\n * @return Header observable\n */\nexport function watchHeader(\n el: HTMLElement, { document$ }: WatchOptions\n): Observable> {\n return document$\n .pipe(\n map(() => {\n const styles = getComputedStyle(el)\n return [\n \"sticky\", /* Modern browsers */\n \"-webkit-sticky\" /* Safari */\n ].includes(styles.position)\n }),\n distinctUntilChanged(),\n switchMap(sticky => {\n if (sticky) {\n return watchElementSize(el)\n .pipe(\n map(({ height }) => ({\n sticky: true,\n height\n }))\n )\n } else {\n return of({\n sticky: false,\n height: 0\n })\n }\n }),\n shareReplay(1)\n )\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Apply header title type\n *\n * @param el - Header title element\n *\n * @return Operator function\n */\nexport function applyHeaderType(\n el: HTMLElement\n): MonoTypeOperatorFunction {\n return pipe(\n\n /* Defer repaint to next animation frame */\n observeOn(animationFrameScheduler),\n tap(type => {\n setHeaderTitleActive(el, type === \"page\")\n }),\n\n /* Reset on complete or error */\n finalize(() => {\n resetHeaderTitleActive(el)\n })\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set header title active\n *\n * @param el - Header title element\n * @param value - Whether the title is shown\n */\nexport function setHeaderTitleActive(\n el: HTMLElement, value: boolean\n): void {\n el.setAttribute(\"data-md-state\", value ? \"active\" : \"\")\n}\n\n/**\n * Reset header title active\n *\n * @param el - Header title element\n */\nexport function resetHeaderTitleActive(\n el: HTMLElement\n): void {\n el.removeAttribute(\"data-md-state\")\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable, OperatorFunction, of, pipe } from \"rxjs\"\nimport { map, switchMap } from \"rxjs/operators\"\n\nimport { Viewport } from \"browser\"\n\nimport { Header } from \"../../header\"\nimport { Main } from \"../../main\"\nimport {\n Sidebar,\n applySidebar,\n watchSidebar\n} from \"../../shared\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Navigation for [screen -]\n */\ninterface NavigationBelowScreen {} // tslint:disable-line\n\n/**\n * Navigation for [screen +]\n */\ninterface NavigationAboveScreen {\n sidebar: Sidebar /* Sidebar */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Navigation\n */\nexport type Navigation =\n | NavigationBelowScreen\n | NavigationAboveScreen\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n header$: Observable
    /* Header observable */\n main$: Observable
    /* Main area observable */\n viewport$: Observable /* Viewport observable */\n screen$: Observable /* Screen media observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount navigation from source observable\n *\n * @param options - Options\n *\n * @return Operator function\n */\nexport function mountNavigation(\n { header$, main$, viewport$, screen$ }: MountOptions\n): OperatorFunction {\n return pipe(\n switchMap(el => screen$\n .pipe(\n switchMap(screen => {\n\n /* [screen +]: Mount navigation in sidebar */\n if (screen) {\n return watchSidebar(el, { main$, viewport$ })\n .pipe(\n applySidebar(el, { header$ }),\n map(sidebar => ({ sidebar }))\n )\n\n /* [screen -]: Mount navigation in drawer */\n } else {\n return of({})\n }\n })\n )\n )\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { NEVER, Observable, fromEvent, iif, merge } from \"rxjs\"\nimport { map, mapTo, shareReplay, switchMap } from \"rxjs/operators\"\n\nimport { getElements } from \"browser\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Patch options\n */\ninterface PatchOptions {\n document$: Observable /* Document observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Check whether the given device is an Apple device\n *\n * @return Test result\n */\nfunction isAppleDevice(): boolean {\n return /(iPad|iPhone|iPod)/.test(navigator.userAgent)\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Patch all elements with `data-md-scrollfix` attributes\n *\n * This is a year-old patch which ensures that overflow scrolling works at the\n * top and bottom of containers on iOS by ensuring a `1px` scroll offset upon\n * the start of a touch event.\n *\n * @see https://bit.ly/2SCtAOO - Original source\n *\n * @param options - Options\n */\nexport function patchScrollfix(\n { document$ }: PatchOptions\n): void {\n const els$ = document$\n .pipe(\n map(() => getElements(\"[data-md-scrollfix]\")),\n shareReplay(1)\n )\n\n /* Remove marker attribute, so we'll only add the fix once */\n els$.subscribe(els => {\n for (const el of els)\n el.removeAttribute(\"data-md-scrollfix\")\n })\n\n /* Patch overflow scrolling on touch start */\n iif(isAppleDevice, els$, NEVER)\n .pipe(\n switchMap(els => merge(...els.map(el => (\n fromEvent(el, \"touchstart\", { passive: true })\n .pipe(\n mapTo(el)\n )\n ))))\n )\n .subscribe(el => {\n const top = el.scrollTop\n\n /* We're at the top of the container */\n if (top === 0) {\n el.scrollTop = 1\n\n /* We're at the bottom of the container */\n } else if (top + el.offsetHeight === el.scrollHeight) {\n el.scrollTop = top - 1\n }\n })\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { NEVER, Observable } from \"rxjs\"\nimport { catchError, map, switchMap } from \"rxjs/operators\"\n\nimport { getElementOrThrow, getElements } from \"browser\"\nimport { renderSource } from \"templates\"\nimport { cache, hash } from \"utilities\"\n\nimport { fetchSourceFactsFromGitHub } from \"./github\"\nimport { fetchSourceFactsFromGitLab } from \"./gitlab\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Source facts\n */\nexport type SourceFacts = string[]\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Patch options\n */\ninterface PatchOptions {\n document$: Observable /* Document observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Fetch source facts\n *\n * @param url - Source repository URL\n *\n * @return Source facts observable\n */\nfunction fetchSourceFacts(\n url: string\n): Observable {\n const [type] = url.match(/(git(?:hub|lab))/i) || []\n switch (type.toLowerCase()) {\n\n /* GitHub repository */\n case \"github\":\n const [, user, repo] = url.match(/^.+github\\.com\\/([^\\/]+)\\/?([^\\/]+)/i)\n return fetchSourceFactsFromGitHub(user, repo)\n\n /* GitLab repository */\n case \"gitlab\":\n const [, base, slug] = url.match(/^.+?([^\\/]*gitlab[^\\/]+)\\/(.+?)\\/?$/i)\n return fetchSourceFactsFromGitLab(base, slug)\n\n /* Everything else */\n default:\n return NEVER\n }\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Patch elements containing repository information\n *\n * This function will retrieve the URL from the repository link and try to\n * query data from integrated source code platforms like GitHub or GitLab.\n *\n * @param options - Options\n */\nexport function patchSource(\n { document$ }: PatchOptions\n): void {\n document$\n .pipe(\n map(() => getElementOrThrow(\".md-source[href]\")),\n switchMap(({ href }) => (\n cache(`${hash(href)}`, () => fetchSourceFacts(href))\n )),\n catchError(() => NEVER)\n )\n .subscribe(facts => {\n for (const el of getElements(\".md-source__repository\")) {\n if (!el.hasAttribute(\"data-md-state\")) {\n el.setAttribute(\"data-md-state\", \"done\")\n el.appendChild(renderSource(facts))\n }\n }\n })\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Repo, User } from \"github-types\"\nimport { Observable, of } from \"rxjs\"\nimport { ajax } from \"rxjs/ajax\"\nimport { filter, pluck, switchMap } from \"rxjs/operators\"\n\nimport { round } from \"utilities\"\n\nimport { SourceFacts } from \"..\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Fetch GitHub source facts\n *\n * @param user - GitHub user\n * @param repo - GitHub repository\n *\n * @return Source facts observable\n */\nexport function fetchSourceFactsFromGitHub(\n user: string, repo?: string\n): Observable {\n return ajax({\n url: typeof repo !== \"undefined\"\n ? `https://api.github.com/repos/${user}/${repo}`\n : `https://api.github.com/users/${user}`,\n responseType: \"json\"\n })\n .pipe(\n filter(({ status }) => status === 200),\n pluck(\"response\"),\n switchMap(data => {\n\n /* GitHub repository */\n if (typeof repo !== \"undefined\") {\n const { stargazers_count, forks_count }: Repo = data\n return of([\n `${round(stargazers_count || 0)} Stars`,\n `${round(forks_count || 0)} Forks`\n ])\n\n /* GitHub user/organization */\n } else {\n const { public_repos }: User = data\n return of([\n `${round(public_repos || 0)} Repositories`\n ])\n }\n })\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { ProjectSchema } from \"gitlab\"\nimport { Observable } from \"rxjs\"\nimport { ajax } from \"rxjs/ajax\"\nimport { filter, map, pluck } from \"rxjs/operators\"\n\nimport { round } from \"utilities\"\n\nimport { SourceFacts } from \"..\"\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Fetch GitLab source facts\n *\n * @param base - GitLab base\n * @param project - GitLab project\n *\n * @return Source facts observable\n */\nexport function fetchSourceFactsFromGitLab(\n base: string, project: string\n): Observable {\n return ajax({\n url: `https://${base}/api/v4/projects/${encodeURIComponent(project)}`,\n responseType: \"json\"\n })\n .pipe(\n filter(({ status }) => status === 200),\n pluck(\"response\"),\n map(({ star_count, forks_count }: ProjectSchema) => ([\n `${round(star_count)} Stars`,\n `${round(forks_count)} Forks`\n ]))\n )\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n// DISCLAIMER: this file is still WIP. There're some refactoring opportunities\n// which must be tackled after we gathered some feedback on v5.\n// tslint:disable\n\nimport { values } from \"ramda\"\nimport {\n merge,\n combineLatest,\n animationFrameScheduler,\n fromEvent,\n from\n} from \"rxjs\"\nimport { ajax } from \"rxjs/ajax\"\nimport {\n delay,\n switchMap,\n tap,\n filter,\n withLatestFrom,\n observeOn,\n take,\n shareReplay,\n pluck\n} from \"rxjs/operators\"\n\nimport {\n watchToggle,\n setToggle,\n getElements,\n watchMedia,\n watchDocument,\n watchLocation,\n watchLocationHash,\n watchViewport,\n isLocalLocation,\n setLocationHash,\n watchLocationBase\n} from \"browser\"\nimport {\n mountHeader,\n mountHero,\n mountMain,\n mountNavigation,\n mountSearch,\n mountTableOfContents,\n mountTabs,\n useComponent,\n setupComponents,\n mountSearchQuery,\n mountSearchReset,\n mountSearchResult\n} from \"components\"\nimport {\n setupClipboard,\n setupDialog,\n setupKeyboard,\n setupInstantLoading,\n setupSearchWorker,\n SearchIndex\n} from \"integrations\"\nimport {\n patchTables,\n patchDetails,\n patchScrollfix,\n patchSource,\n patchScripts\n} from \"patches\"\nimport { isConfig } from \"utilities\"\n\n/* ------------------------------------------------------------------------- */\n\n/* Denote that JavaScript is available */\ndocument.documentElement.classList.remove(\"no-js\")\ndocument.documentElement.classList.add(\"js\")\n\n/* Test for iOS */\nif (navigator.userAgent.match(/(iPad|iPhone|iPod)/g))\n document.documentElement.classList.add(\"ios\")\n\n/**\n * Set scroll lock\n *\n * @param el - Scrollable element\n * @param value - Vertical offset\n */\nexport function setScrollLock(\n el: HTMLElement, value: number\n): void {\n el.setAttribute(\"data-md-state\", \"lock\")\n el.style.top = `-${value}px`\n}\n\n/**\n * Reset scroll lock\n *\n * @param el - Scrollable element\n */\nexport function resetScrollLock(\n el: HTMLElement\n): void {\n const value = -1 * parseInt(el.style.top, 10)\n el.removeAttribute(\"data-md-state\")\n el.style.top = \"\"\n if (value)\n window.scrollTo(0, value)\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Initialize Material for MkDocs\n *\n * @param config - Configuration\n */\nexport function initialize(config: unknown) {\n if (!isConfig(config))\n throw new SyntaxError(`Invalid configuration: ${JSON.stringify(config)}`)\n\n /* Set up subjects */\n const document$ = watchDocument()\n const location$ = watchLocation()\n\n /* Set up user interface observables */\n const base$ = watchLocationBase(config.base, { location$ })\n const hash$ = watchLocationHash()\n const viewport$ = watchViewport()\n const tablet$ = watchMedia(\"(min-width: 960px)\")\n const screen$ = watchMedia(\"(min-width: 1220px)\")\n\n /* ----------------------------------------------------------------------- */\n\n /* Set up component bindings */\n setupComponents([\n \"announce\", /* Announcement bar */\n \"container\", /* Container */\n \"header\", /* Header */\n \"header-title\", /* Header title */\n \"hero\", /* Hero */\n \"main\", /* Main area */\n \"navigation\", /* Navigation */\n \"search\", /* Search */\n \"search-query\", /* Search input */\n \"search-reset\", /* Search reset */\n \"search-result\", /* Search results */\n \"skip\", /* Skip link */\n \"tabs\", /* Tabs */\n \"toc\" /* Table of contents */\n ], { document$ })\n\n const keyboard$ = setupKeyboard()\n\n patchDetails({ document$, hash$ })\n patchScripts({ document$ })\n patchSource({ document$ })\n patchTables({ document$ })\n\n /* Force 1px scroll offset to trigger overflow scrolling */\n patchScrollfix({ document$ })\n\n /* Set up clipboard and dialog */\n const dialog$ = setupDialog()\n const clipboard$ = setupClipboard({ document$, dialog$ })\n\n /* ----------------------------------------------------------------------- */\n\n /* Create header observable */\n const header$ = useComponent(\"header\")\n .pipe(\n mountHeader({ document$, viewport$ }),\n shareReplay(1)\n )\n\n const main$ = useComponent(\"main\")\n .pipe(\n mountMain({ header$, viewport$ }),\n shareReplay(1)\n )\n\n /* ----------------------------------------------------------------------- */\n\n const navigation$ = useComponent(\"navigation\")\n .pipe(\n mountNavigation({ header$, main$, viewport$, screen$ }),\n shareReplay(1) // shareReplay because there might be late subscribers\n )\n\n const toc$ = useComponent(\"toc\")\n .pipe(\n mountTableOfContents({ header$, main$, viewport$, tablet$ }),\n shareReplay(1)\n )\n\n const tabs$ = useComponent(\"tabs\")\n .pipe(\n mountTabs({ header$, viewport$, screen$ }),\n shareReplay(1)\n )\n\n const hero$ = useComponent(\"hero\")\n .pipe(\n mountHero({ header$, viewport$ }),\n shareReplay(1)\n )\n\n /* ----------------------------------------------------------------------- */\n\n // External index\n const index = config.search && config.search.index\n ? config.search.index\n : undefined\n\n /* Fetch index if it wasn't passed explicitly */\n const index$ = typeof index !== \"undefined\"\n ? from(index)\n : base$\n .pipe(\n switchMap(base => ajax({\n url: `${base}/search/search_index.json`,\n responseType: \"json\",\n withCredentials: true\n })\n .pipe(\n pluck(\"response\")\n )\n )\n )\n\n const worker = setupSearchWorker(config.search.worker, {\n base$, index$\n })\n\n /* ----------------------------------------------------------------------- */\n\n /* Mount search query */\n const query$ = useComponent(\"search-query\")\n .pipe(\n mountSearchQuery(worker, { transform: config.search.transform }),\n shareReplay(1)\n )\n\n /* Mount search reset */\n const reset$ = useComponent(\"search-reset\")\n .pipe(\n mountSearchReset(),\n shareReplay(1)\n )\n\n /* Mount search result */\n const result$ = useComponent(\"search-result\")\n .pipe(\n mountSearchResult(worker, { query$ }),\n shareReplay(1)\n )\n\n /* ----------------------------------------------------------------------- */\n\n const search$ = useComponent(\"search\")\n .pipe(\n mountSearch({ query$, reset$, result$ }),\n shareReplay(1)\n )\n\n /* ----------------------------------------------------------------------- */\n\n // // put into search...\n hash$\n .pipe(\n tap(() => setToggle(\"search\", false)),\n delay(125), // ensure that it runs after the body scroll reset...\n )\n .subscribe(hash => setLocationHash(`#${hash}`))\n\n // TODO: scroll restoration must be centralized\n combineLatest([\n watchToggle(\"search\"),\n tablet$,\n ])\n .pipe(\n withLatestFrom(viewport$),\n switchMap(([[toggle, tablet], { offset: { y }}]) => {\n const active = toggle && !tablet\n return document$\n .pipe(\n delay(active ? 400 : 100),\n observeOn(animationFrameScheduler),\n tap(({ body }) => active\n ? setScrollLock(body, y)\n : resetScrollLock(body)\n )\n )\n })\n )\n .subscribe()\n\n /* ----------------------------------------------------------------------- */\n\n /* Always close drawer on click */\n fromEvent(document.body, \"click\")\n .pipe(\n filter(ev => !(ev.metaKey || ev.ctrlKey)),\n filter(ev => {\n if (ev.target instanceof HTMLElement) {\n const el = ev.target.closest(\"a\") // TODO: abstract as link click?\n if (el && isLocalLocation(el)) {\n return true\n }\n }\n return false\n })\n )\n .subscribe(() => {\n setToggle(\"drawer\", false)\n })\n\n /* Enable instant loading, if not on file:// protocol */\n if (config.features.includes(\"instant\") && location.protocol !== \"file:\")\n setupInstantLoading({ document$, location$, viewport$ })\n\n /* ----------------------------------------------------------------------- */\n\n /* Unhide permalinks on first tab */\n keyboard$\n .pipe(\n filter(key => key.mode === \"global\" && key.type === \"Tab\"),\n take(1)\n )\n .subscribe(() => {\n for (const link of getElements(\".headerlink\"))\n link.style.visibility = \"visible\"\n })\n\n /* ----------------------------------------------------------------------- */\n\n const state = {\n\n /* Browser observables */\n document$,\n location$,\n viewport$,\n\n /* Component observables */\n header$,\n hero$,\n main$,\n navigation$,\n search$,\n tabs$,\n toc$,\n\n /* Integration observables */\n clipboard$,\n keyboard$,\n dialog$\n }\n\n /* Subscribe to all observables */\n merge(...values(state))\n .subscribe()\n return state\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { identity } from \"ramda\"\nimport { Observable, fromEvent, merge } from \"rxjs\"\nimport {\n filter,\n map,\n switchMapTo,\n tap\n} from \"rxjs/operators\"\n\nimport {\n getElement,\n getElements,\n watchMedia\n} from \"browser\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Patch options\n */\ninterface PatchOptions {\n document$: Observable /* Document observable */\n hash$: Observable /* Location hash observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Patch all `details` elements\n *\n * This function will ensure that all `details` tags are opened prior to\n * printing, so the whole content of the page is included, and on anchor jumps.\n *\n * @param options - Options\n */\nexport function patchDetails(\n { document$, hash$ }: PatchOptions\n): void {\n const els$ = document$\n .pipe(\n map(() => getElements(\"details\"))\n )\n\n /* Open all details before printing */\n merge(\n watchMedia(\"print\").pipe(filter(identity)), /* Webkit */\n fromEvent(window, \"beforeprint\") /* IE, FF */\n )\n .pipe(\n switchMapTo(els$)\n )\n .subscribe(els => {\n for (const el of els)\n el.setAttribute(\"open\", \"\")\n })\n\n /* Open parent details and fix anchor jump */\n hash$\n .pipe(\n map(id => getElement(`[id=\"${id}\"]`)!),\n filter(el => typeof el !== \"undefined\"),\n tap(el => {\n const details = el.closest(\"details\")\n if (details && !details.open)\n details.setAttribute(\"open\", \"\")\n })\n )\n .subscribe(el => el.scrollIntoView())\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable } from \"rxjs\"\nimport { map, skip, withLatestFrom } from \"rxjs/operators\"\n\nimport {\n createElement,\n getElements,\n replaceElement\n} from \"browser\"\nimport { useComponent } from \"components\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Patch options\n */\ninterface PatchOptions {\n document$: Observable /* Document observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Patch all `script` elements\n *\n * This function must be run after a document switch, which means the first\n * emission must be ignored.\n *\n * @param options - Options\n */\nexport function patchScripts(\n { document$ }: PatchOptions\n): void {\n const els$ = document$\n .pipe(\n skip(1),\n withLatestFrom(useComponent(\"container\")),\n map(([, el]) => getElements(\"script\", el))\n )\n\n /* Evaluate all scripts via replacement */\n els$.subscribe(els => {\n for (const el of els) {\n if (el.src || /(^|\\/javascript)$/i.test(el.type)) {\n const script = createElement(\"script\")\n const key = el.src ? \"src\" : \"textContent\"\n script[key] = el[key]!\n replaceElement(el, script)\n }\n }\n })\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { Observable } from \"rxjs\"\nimport { map } from \"rxjs/operators\"\n\nimport {\n createElement,\n getElements,\n replaceElement\n} from \"browser\"\nimport { renderTable } from \"templates\"\n\n/* ----------------------------------------------------------------------------\n * Helper types\n * ------------------------------------------------------------------------- */\n\n/**\n * Mount options\n */\ninterface MountOptions {\n document$: Observable /* Document observable */\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Patch all `table` elements\n *\n * This function will re-render all tables by wrapping them to improve overflow\n * scrolling on smaller screen sizes.\n *\n * @param options - Options\n */\nexport function patchTables(\n { document$ }: MountOptions\n): void {\n const sentinel = createElement(\"table\")\n document$\n .pipe(\n map(() => getElements(\"table:not([class])\"))\n )\n .subscribe(els => {\n for (const el of els) {\n replaceElement(el, sentinel)\n replaceElement(sentinel, renderTable(el))\n }\n })\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/docs/assets/javascripts/lunr/min/lunr.ar.min.js b/docs/assets/javascripts/lunr/min/lunr.ar.min.js new file mode 100644 index 0000000..248ddc5 --- /dev/null +++ b/docs/assets/javascripts/lunr/min/lunr.ar.min.js @@ -0,0 +1 @@ +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.ar=function(){this.pipeline.reset(),this.pipeline.add(e.ar.trimmer,e.ar.stopWordFilter,e.ar.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.ar.stemmer))},e.ar.wordCharacters="ء-ٛٱـ",e.ar.trimmer=e.trimmerSupport.generateTrimmer(e.ar.wordCharacters),e.Pipeline.registerFunction(e.ar.trimmer,"trimmer-ar"),e.ar.stemmer=function(){var e=this;return e.result=!1,e.preRemoved=!1,e.sufRemoved=!1,e.pre={pre1:"ف ك ب و س ل ن ا ي ت",pre2:"ال لل",pre3:"بال وال فال تال كال ولل",pre4:"فبال كبال وبال وكال"},e.suf={suf1:"ه ك ت ن ا ي",suf2:"نك نه ها وك يا اه ون ين تن تم نا وا ان كم كن ني نن ما هم هن تك ته ات يه",suf3:"تين كهم نيه نهم ونه وها يهم ونا ونك وني وهم تكم تنا تها تني تهم كما كها ناه نكم هنا تان يها",suf4:"كموه ناها ونني ونهم تكما تموه تكاه كماه ناكم ناهم نيها وننا"},e.patterns=JSON.parse('{"pt43":[{"pt":[{"c":"ا","l":1}]},{"pt":[{"c":"ا,ت,ن,ي","l":0}],"mPt":[{"c":"ف","l":0,"m":1},{"c":"ع","l":1,"m":2},{"c":"ل","l":2,"m":3}]},{"pt":[{"c":"و","l":2}],"mPt":[{"c":"ف","l":0,"m":0},{"c":"ع","l":1,"m":1},{"c":"ل","l":2,"m":3}]},{"pt":[{"c":"ا","l":2}]},{"pt":[{"c":"ي","l":2}],"mPt":[{"c":"ف","l":0,"m":0},{"c":"ع","l":1,"m":1},{"c":"ا","l":2},{"c":"ل","l":3,"m":3}]},{"pt":[{"c":"م","l":0}]}],"pt53":[{"pt":[{"c":"ت","l":0},{"c":"ا","l":2}]},{"pt":[{"c":"ا,ن,ت,ي","l":0},{"c":"ت","l":2}],"mPt":[{"c":"ا","l":0},{"c":"ف","l":1,"m":1},{"c":"ت","l":2},{"c":"ع","l":3,"m":3},{"c":"ا","l":4},{"c":"ل","l":5,"m":4}]},{"pt":[{"c":"ا","l":0},{"c":"ا","l":2}],"mPt":[{"c":"ا","l":0},{"c":"ف","l":1,"m":1},{"c":"ع","l":2,"m":3},{"c":"ل","l":3,"m":4},{"c":"ا","l":4},{"c":"ل","l":5,"m":4}]},{"pt":[{"c":"ا","l":0},{"c":"ا","l":3}],"mPt":[{"c":"ف","l":0,"m":1},{"c":"ع","l":1,"m":2},{"c":"ل","l":2,"m":4}]},{"pt":[{"c":"ا","l":3},{"c":"ن","l":4}]},{"pt":[{"c":"ت","l":0},{"c":"ي","l":3}]},{"pt":[{"c":"م","l":0},{"c":"و","l":3}]},{"pt":[{"c":"ا","l":1},{"c":"و","l":3}]},{"pt":[{"c":"و","l":1},{"c":"ا","l":2}]},{"pt":[{"c":"م","l":0},{"c":"ا","l":3}]},{"pt":[{"c":"م","l":0},{"c":"ي","l":3}]},{"pt":[{"c":"ا","l":2},{"c":"ن","l":3}]},{"pt":[{"c":"م","l":0},{"c":"ن","l":1}],"mPt":[{"c":"ا","l":0},{"c":"ن","l":1},{"c":"ف","l":2,"m":2},{"c":"ع","l":3,"m":3},{"c":"ا","l":4},{"c":"ل","l":5,"m":4}]},{"pt":[{"c":"م","l":0},{"c":"ت","l":2}],"mPt":[{"c":"ا","l":0},{"c":"ف","l":1,"m":1},{"c":"ت","l":2},{"c":"ع","l":3,"m":3},{"c":"ا","l":4},{"c":"ل","l":5,"m":4}]},{"pt":[{"c":"م","l":0},{"c":"ا","l":2}]},{"pt":[{"c":"م","l":1},{"c":"ا","l":3}]},{"pt":[{"c":"ي,ت,ا,ن","l":0},{"c":"ت","l":1}],"mPt":[{"c":"ف","l":0,"m":2},{"c":"ع","l":1,"m":3},{"c":"ا","l":2},{"c":"ل","l":3,"m":4}]},{"pt":[{"c":"ت,ي,ا,ن","l":0},{"c":"ت","l":2}],"mPt":[{"c":"ا","l":0},{"c":"ف","l":1,"m":1},{"c":"ت","l":2},{"c":"ع","l":3,"m":3},{"c":"ا","l":4},{"c":"ل","l":5,"m":4}]},{"pt":[{"c":"ا","l":2},{"c":"ي","l":3}]},{"pt":[{"c":"ا,ي,ت,ن","l":0},{"c":"ن","l":1}],"mPt":[{"c":"ا","l":0},{"c":"ن","l":1},{"c":"ف","l":2,"m":2},{"c":"ع","l":3,"m":3},{"c":"ا","l":4},{"c":"ل","l":5,"m":4}]},{"pt":[{"c":"ا","l":3},{"c":"ء","l":4}]}],"pt63":[{"pt":[{"c":"ا","l":0},{"c":"ت","l":2},{"c":"ا","l":4}]},{"pt":[{"c":"ا,ت,ن,ي","l":0},{"c":"س","l":1},{"c":"ت","l":2}],"mPt":[{"c":"ا","l":0},{"c":"س","l":1},{"c":"ت","l":2},{"c":"ف","l":3,"m":3},{"c":"ع","l":4,"m":4},{"c":"ا","l":5},{"c":"ل","l":6,"m":5}]},{"pt":[{"c":"ا,ن,ت,ي","l":0},{"c":"و","l":3}]},{"pt":[{"c":"م","l":0},{"c":"س","l":1},{"c":"ت","l":2}],"mPt":[{"c":"ا","l":0},{"c":"س","l":1},{"c":"ت","l":2},{"c":"ف","l":3,"m":3},{"c":"ع","l":4,"m":4},{"c":"ا","l":5},{"c":"ل","l":6,"m":5}]},{"pt":[{"c":"ي","l":1},{"c":"ي","l":3},{"c":"ا","l":4},{"c":"ء","l":5}]},{"pt":[{"c":"ا","l":0},{"c":"ن","l":1},{"c":"ا","l":4}]}],"pt54":[{"pt":[{"c":"ت","l":0}]},{"pt":[{"c":"ا,ي,ت,ن","l":0}],"mPt":[{"c":"ا","l":0},{"c":"ف","l":1,"m":1},{"c":"ع","l":2,"m":2},{"c":"ل","l":3,"m":3},{"c":"ر","l":4,"m":4},{"c":"ا","l":5},{"c":"ر","l":6,"m":4}]},{"pt":[{"c":"م","l":0}],"mPt":[{"c":"ا","l":0},{"c":"ف","l":1,"m":1},{"c":"ع","l":2,"m":2},{"c":"ل","l":3,"m":3},{"c":"ر","l":4,"m":4},{"c":"ا","l":5},{"c":"ر","l":6,"m":4}]},{"pt":[{"c":"ا","l":2}]},{"pt":[{"c":"ا","l":0},{"c":"ن","l":2}]}],"pt64":[{"pt":[{"c":"ا","l":0},{"c":"ا","l":4}]},{"pt":[{"c":"م","l":0},{"c":"ت","l":1}]}],"pt73":[{"pt":[{"c":"ا","l":0},{"c":"س","l":1},{"c":"ت","l":2},{"c":"ا","l":5}]}],"pt75":[{"pt":[{"c":"ا","l":0},{"c":"ا","l":5}]}]}'),e.execArray=["cleanWord","removeDiacritics","cleanAlef","removeStopWords","normalizeHamzaAndAlef","removeStartWaw","removePre432","removeEndTaa","wordCheck"],e.stem=function(){var r=0;for(e.result=!1,e.preRemoved=!1,e.sufRemoved=!1;r=0)return!0},e.normalizeHamzaAndAlef=function(){return e.word=e.word.replace("ؤ","ء"),e.word=e.word.replace("ئ","ء"),e.word=e.word.replace(/([\u0627])\1+/gi,"ا"),!1},e.removeEndTaa=function(){return!(e.word.length>2)||(e.word=e.word.replace(/[\u0627]$/,""),e.word=e.word.replace("ة",""),!1)},e.removeStartWaw=function(){return e.word.length>3&&"و"==e.word[0]&&"و"==e.word[1]&&(e.word=e.word.slice(1)),!1},e.removePre432=function(){var r=e.word;if(e.word.length>=7){var t=new RegExp("^("+e.pre.pre4.split(" ").join("|")+")");e.word=e.word.replace(t,"")}if(e.word==r&&e.word.length>=6){var c=new RegExp("^("+e.pre.pre3.split(" ").join("|")+")");e.word=e.word.replace(c,"")}if(e.word==r&&e.word.length>=5){var l=new RegExp("^("+e.pre.pre2.split(" ").join("|")+")");e.word=e.word.replace(l,"")}return r!=e.word&&(e.preRemoved=!0),!1},e.patternCheck=function(r){for(var t=0;t3){var t=new RegExp("^("+e.pre.pre1.split(" ").join("|")+")");e.word=e.word.replace(t,"")}return r!=e.word&&(e.preRemoved=!0),!1},e.removeSuf1=function(){var r=e.word;if(0==e.sufRemoved&&e.word.length>3){var t=new RegExp("("+e.suf.suf1.split(" ").join("|")+")$");e.word=e.word.replace(t,"")}return r!=e.word&&(e.sufRemoved=!0),!1},e.removeSuf432=function(){var r=e.word;if(e.word.length>=6){var t=new RegExp("("+e.suf.suf4.split(" ").join("|")+")$");e.word=e.word.replace(t,"")}if(e.word==r&&e.word.length>=5){var c=new RegExp("("+e.suf.suf3.split(" ").join("|")+")$");e.word=e.word.replace(c,"")}if(e.word==r&&e.word.length>=4){var l=new RegExp("("+e.suf.suf2.split(" ").join("|")+")$");e.word=e.word.replace(l,"")}return r!=e.word&&(e.sufRemoved=!0),!1},e.wordCheck=function(){for(var r=(e.word,[e.removeSuf432,e.removeSuf1,e.removePre1]),t=0,c=!1;e.word.length>=7&&!e.result&&t=f.limit)return;f.cursor++}for(;!f.out_grouping(w,97,248);){if(f.cursor>=f.limit)return;f.cursor++}d=f.cursor,d=d&&(r=f.limit_backward,f.limit_backward=d,f.ket=f.cursor,e=f.find_among_b(c,32),f.limit_backward=r,e))switch(f.bra=f.cursor,e){case 1:f.slice_del();break;case 2:f.in_grouping_b(p,97,229)&&f.slice_del()}}function t(){var e,r=f.limit-f.cursor;f.cursor>=d&&(e=f.limit_backward,f.limit_backward=d,f.ket=f.cursor,f.find_among_b(l,4)?(f.bra=f.cursor,f.limit_backward=e,f.cursor=f.limit-r,f.cursor>f.limit_backward&&(f.cursor--,f.bra=f.cursor,f.slice_del())):f.limit_backward=e)}function s(){var e,r,i,n=f.limit-f.cursor;if(f.ket=f.cursor,f.eq_s_b(2,"st")&&(f.bra=f.cursor,f.eq_s_b(2,"ig")&&f.slice_del()),f.cursor=f.limit-n,f.cursor>=d&&(r=f.limit_backward,f.limit_backward=d,f.ket=f.cursor,e=f.find_among_b(m,5),f.limit_backward=r,e))switch(f.bra=f.cursor,e){case 1:f.slice_del(),i=f.limit-f.cursor,t(),f.cursor=f.limit-i;break;case 2:f.slice_from("løs")}}function o(){var e;f.cursor>=d&&(e=f.limit_backward,f.limit_backward=d,f.ket=f.cursor,f.out_grouping_b(w,97,248)?(f.bra=f.cursor,u=f.slice_to(u),f.limit_backward=e,f.eq_v_b(u)&&f.slice_del()):f.limit_backward=e)}var a,d,u,c=[new r("hed",-1,1),new r("ethed",0,1),new r("ered",-1,1),new r("e",-1,1),new r("erede",3,1),new r("ende",3,1),new r("erende",5,1),new r("ene",3,1),new r("erne",3,1),new r("ere",3,1),new r("en",-1,1),new r("heden",10,1),new r("eren",10,1),new r("er",-1,1),new r("heder",13,1),new r("erer",13,1),new r("s",-1,2),new r("heds",16,1),new r("es",16,1),new r("endes",18,1),new r("erendes",19,1),new r("enes",18,1),new r("ernes",18,1),new r("eres",18,1),new r("ens",16,1),new r("hedens",24,1),new r("erens",24,1),new r("ers",16,1),new r("ets",16,1),new r("erets",28,1),new r("et",-1,1),new r("eret",30,1)],l=[new r("gd",-1,-1),new r("dt",-1,-1),new r("gt",-1,-1),new r("kt",-1,-1)],m=[new r("ig",-1,1),new r("lig",0,1),new r("elig",1,1),new r("els",-1,1),new r("løst",-1,2)],w=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,48,0,128],p=[239,254,42,3,0,0,0,0,0,0,0,0,0,0,0,0,16],f=new i;this.setCurrent=function(e){f.setCurrent(e)},this.getCurrent=function(){return f.getCurrent()},this.stem=function(){var r=f.cursor;return e(),f.limit_backward=r,f.cursor=f.limit,n(),f.cursor=f.limit,t(),f.cursor=f.limit,s(),f.cursor=f.limit,o(),!0}};return function(e){return"function"==typeof e.update?e.update(function(e){return n.setCurrent(e),n.stem(),n.getCurrent()}):(n.setCurrent(e),n.stem(),n.getCurrent())}}(),e.Pipeline.registerFunction(e.da.stemmer,"stemmer-da"),e.da.stopWordFilter=e.generateStopWordFilter("ad af alle alt anden at blev blive bliver da de dem den denne der deres det dette dig din disse dog du efter eller en end er et for fra ham han hans har havde have hende hendes her hos hun hvad hvis hvor i ikke ind jeg jer jo kunne man mange med meget men mig min mine mit mod ned noget nogle nu når og også om op os over på selv sig sin sine sit skal skulle som sådan thi til ud under var vi vil ville vor være været".split(" ")),e.Pipeline.registerFunction(e.da.stopWordFilter,"stopWordFilter-da")}}); \ No newline at end of file diff --git a/docs/assets/javascripts/lunr/min/lunr.de.min.js b/docs/assets/javascripts/lunr/min/lunr.de.min.js new file mode 100644 index 0000000..f3b5c10 --- /dev/null +++ b/docs/assets/javascripts/lunr/min/lunr.de.min.js @@ -0,0 +1,18 @@ +/*! + * Lunr languages, `German` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.de=function(){this.pipeline.reset(),this.pipeline.add(e.de.trimmer,e.de.stopWordFilter,e.de.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.de.stemmer))},e.de.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.de.trimmer=e.trimmerSupport.generateTrimmer(e.de.wordCharacters),e.Pipeline.registerFunction(e.de.trimmer,"trimmer-de"),e.de.stemmer=function(){var r=e.stemmerSupport.Among,n=e.stemmerSupport.SnowballProgram,i=new function(){function e(e,r,n){return!(!v.eq_s(1,e)||(v.ket=v.cursor,!v.in_grouping(p,97,252)))&&(v.slice_from(r),v.cursor=n,!0)}function i(){for(var r,n,i,s,t=v.cursor;;)if(r=v.cursor,v.bra=r,v.eq_s(1,"ß"))v.ket=v.cursor,v.slice_from("ss");else{if(r>=v.limit)break;v.cursor=r+1}for(v.cursor=t;;)for(n=v.cursor;;){if(i=v.cursor,v.in_grouping(p,97,252)){if(s=v.cursor,v.bra=s,e("u","U",i))break;if(v.cursor=s,e("y","Y",i))break}if(i>=v.limit)return void(v.cursor=n);v.cursor=i+1}}function s(){for(;!v.in_grouping(p,97,252);){if(v.cursor>=v.limit)return!0;v.cursor++}for(;!v.out_grouping(p,97,252);){if(v.cursor>=v.limit)return!0;v.cursor++}return!1}function t(){m=v.limit,l=m;var e=v.cursor+3;0<=e&&e<=v.limit&&(d=e,s()||(m=v.cursor,m=v.limit)return;v.cursor++}}}function c(){return m<=v.cursor}function u(){return l<=v.cursor}function a(){var e,r,n,i,s=v.limit-v.cursor;if(v.ket=v.cursor,(e=v.find_among_b(w,7))&&(v.bra=v.cursor,c()))switch(e){case 1:v.slice_del();break;case 2:v.slice_del(),v.ket=v.cursor,v.eq_s_b(1,"s")&&(v.bra=v.cursor,v.eq_s_b(3,"nis")&&v.slice_del());break;case 3:v.in_grouping_b(g,98,116)&&v.slice_del()}if(v.cursor=v.limit-s,v.ket=v.cursor,(e=v.find_among_b(f,4))&&(v.bra=v.cursor,c()))switch(e){case 1:v.slice_del();break;case 2:if(v.in_grouping_b(k,98,116)){var t=v.cursor-3;v.limit_backward<=t&&t<=v.limit&&(v.cursor=t,v.slice_del())}}if(v.cursor=v.limit-s,v.ket=v.cursor,(e=v.find_among_b(_,8))&&(v.bra=v.cursor,u()))switch(e){case 1:v.slice_del(),v.ket=v.cursor,v.eq_s_b(2,"ig")&&(v.bra=v.cursor,r=v.limit-v.cursor,v.eq_s_b(1,"e")||(v.cursor=v.limit-r,u()&&v.slice_del()));break;case 2:n=v.limit-v.cursor,v.eq_s_b(1,"e")||(v.cursor=v.limit-n,v.slice_del());break;case 3:if(v.slice_del(),v.ket=v.cursor,i=v.limit-v.cursor,!v.eq_s_b(2,"er")&&(v.cursor=v.limit-i,!v.eq_s_b(2,"en")))break;v.bra=v.cursor,c()&&v.slice_del();break;case 4:v.slice_del(),v.ket=v.cursor,e=v.find_among_b(b,2),e&&(v.bra=v.cursor,u()&&1==e&&v.slice_del())}}var d,l,m,h=[new r("",-1,6),new r("U",0,2),new r("Y",0,1),new r("ä",0,3),new r("ö",0,4),new r("ü",0,5)],w=[new r("e",-1,2),new r("em",-1,1),new r("en",-1,2),new r("ern",-1,1),new r("er",-1,1),new r("s",-1,3),new r("es",5,2)],f=[new r("en",-1,1),new r("er",-1,1),new r("st",-1,2),new r("est",2,1)],b=[new r("ig",-1,1),new r("lich",-1,1)],_=[new r("end",-1,1),new r("ig",-1,2),new r("ung",-1,1),new r("lich",-1,3),new r("isch",-1,2),new r("ik",-1,2),new r("heit",-1,3),new r("keit",-1,4)],p=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,8,0,32,8],g=[117,30,5],k=[117,30,4],v=new n;this.setCurrent=function(e){v.setCurrent(e)},this.getCurrent=function(){return v.getCurrent()},this.stem=function(){var e=v.cursor;return i(),v.cursor=e,t(),v.limit_backward=e,v.cursor=v.limit,a(),v.cursor=v.limit_backward,o(),!0}};return function(e){return"function"==typeof e.update?e.update(function(e){return i.setCurrent(e),i.stem(),i.getCurrent()}):(i.setCurrent(e),i.stem(),i.getCurrent())}}(),e.Pipeline.registerFunction(e.de.stemmer,"stemmer-de"),e.de.stopWordFilter=e.generateStopWordFilter("aber alle allem allen aller alles als also am an ander andere anderem anderen anderer anderes anderm andern anderr anders auch auf aus bei bin bis bist da damit dann das dasselbe dazu daß dein deine deinem deinen deiner deines dem demselben den denn denselben der derer derselbe derselben des desselben dessen dich die dies diese dieselbe dieselben diesem diesen dieser dieses dir doch dort du durch ein eine einem einen einer eines einig einige einigem einigen einiger einiges einmal er es etwas euch euer eure eurem euren eurer eures für gegen gewesen hab habe haben hat hatte hatten hier hin hinter ich ihm ihn ihnen ihr ihre ihrem ihren ihrer ihres im in indem ins ist jede jedem jeden jeder jedes jene jenem jenen jener jenes jetzt kann kein keine keinem keinen keiner keines können könnte machen man manche manchem manchen mancher manches mein meine meinem meinen meiner meines mich mir mit muss musste nach nicht nichts noch nun nur ob oder ohne sehr sein seine seinem seinen seiner seines selbst sich sie sind so solche solchem solchen solcher solches soll sollte sondern sonst um und uns unse unsem unsen unser unses unter viel vom von vor war waren warst was weg weil weiter welche welchem welchen welcher welches wenn werde werden wie wieder will wir wird wirst wo wollen wollte während würde würden zu zum zur zwar zwischen über".split(" ")),e.Pipeline.registerFunction(e.de.stopWordFilter,"stopWordFilter-de")}}); \ No newline at end of file diff --git a/docs/assets/javascripts/lunr/min/lunr.du.min.js b/docs/assets/javascripts/lunr/min/lunr.du.min.js new file mode 100644 index 0000000..49a0f3f --- /dev/null +++ b/docs/assets/javascripts/lunr/min/lunr.du.min.js @@ -0,0 +1,18 @@ +/*! + * Lunr languages, `Dutch` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");console.warn('[Lunr Languages] Please use the "nl" instead of the "du". The "nl" code is the standard code for Dutch language, and "du" will be removed in the next major versions.'),e.du=function(){this.pipeline.reset(),this.pipeline.add(e.du.trimmer,e.du.stopWordFilter,e.du.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.du.stemmer))},e.du.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.du.trimmer=e.trimmerSupport.generateTrimmer(e.du.wordCharacters),e.Pipeline.registerFunction(e.du.trimmer,"trimmer-du"),e.du.stemmer=function(){var r=e.stemmerSupport.Among,i=e.stemmerSupport.SnowballProgram,n=new function(){function e(){for(var e,r,i,o=C.cursor;;){if(C.bra=C.cursor,e=C.find_among(b,11))switch(C.ket=C.cursor,e){case 1:C.slice_from("a");continue;case 2:C.slice_from("e");continue;case 3:C.slice_from("i");continue;case 4:C.slice_from("o");continue;case 5:C.slice_from("u");continue;case 6:if(C.cursor>=C.limit)break;C.cursor++;continue}break}for(C.cursor=o,C.bra=o,C.eq_s(1,"y")?(C.ket=C.cursor,C.slice_from("Y")):C.cursor=o;;)if(r=C.cursor,C.in_grouping(q,97,232)){if(i=C.cursor,C.bra=i,C.eq_s(1,"i"))C.ket=C.cursor,C.in_grouping(q,97,232)&&(C.slice_from("I"),C.cursor=r);else if(C.cursor=i,C.eq_s(1,"y"))C.ket=C.cursor,C.slice_from("Y"),C.cursor=r;else if(n(r))break}else if(n(r))break}function n(e){return C.cursor=e,e>=C.limit||(C.cursor++,!1)}function o(){_=C.limit,f=_,t()||(_=C.cursor,_<3&&(_=3),t()||(f=C.cursor))}function t(){for(;!C.in_grouping(q,97,232);){if(C.cursor>=C.limit)return!0;C.cursor++}for(;!C.out_grouping(q,97,232);){if(C.cursor>=C.limit)return!0;C.cursor++}return!1}function s(){for(var e;;)if(C.bra=C.cursor,e=C.find_among(p,3))switch(C.ket=C.cursor,e){case 1:C.slice_from("y");break;case 2:C.slice_from("i");break;case 3:if(C.cursor>=C.limit)return;C.cursor++}}function u(){return _<=C.cursor}function c(){return f<=C.cursor}function a(){var e=C.limit-C.cursor;C.find_among_b(g,3)&&(C.cursor=C.limit-e,C.ket=C.cursor,C.cursor>C.limit_backward&&(C.cursor--,C.bra=C.cursor,C.slice_del()))}function l(){var e;w=!1,C.ket=C.cursor,C.eq_s_b(1,"e")&&(C.bra=C.cursor,u()&&(e=C.limit-C.cursor,C.out_grouping_b(q,97,232)&&(C.cursor=C.limit-e,C.slice_del(),w=!0,a())))}function m(){var e;u()&&(e=C.limit-C.cursor,C.out_grouping_b(q,97,232)&&(C.cursor=C.limit-e,C.eq_s_b(3,"gem")||(C.cursor=C.limit-e,C.slice_del(),a())))}function d(){var e,r,i,n,o,t,s=C.limit-C.cursor;if(C.ket=C.cursor,e=C.find_among_b(h,5))switch(C.bra=C.cursor,e){case 1:u()&&C.slice_from("heid");break;case 2:m();break;case 3:u()&&C.out_grouping_b(z,97,232)&&C.slice_del()}if(C.cursor=C.limit-s,l(),C.cursor=C.limit-s,C.ket=C.cursor,C.eq_s_b(4,"heid")&&(C.bra=C.cursor,c()&&(r=C.limit-C.cursor,C.eq_s_b(1,"c")||(C.cursor=C.limit-r,C.slice_del(),C.ket=C.cursor,C.eq_s_b(2,"en")&&(C.bra=C.cursor,m())))),C.cursor=C.limit-s,C.ket=C.cursor,e=C.find_among_b(k,6))switch(C.bra=C.cursor,e){case 1:if(c()){if(C.slice_del(),i=C.limit-C.cursor,C.ket=C.cursor,C.eq_s_b(2,"ig")&&(C.bra=C.cursor,c()&&(n=C.limit-C.cursor,!C.eq_s_b(1,"e")))){C.cursor=C.limit-n,C.slice_del();break}C.cursor=C.limit-i,a()}break;case 2:c()&&(o=C.limit-C.cursor,C.eq_s_b(1,"e")||(C.cursor=C.limit-o,C.slice_del()));break;case 3:c()&&(C.slice_del(),l());break;case 4:c()&&C.slice_del();break;case 5:c()&&w&&C.slice_del()}C.cursor=C.limit-s,C.out_grouping_b(j,73,232)&&(t=C.limit-C.cursor,C.find_among_b(v,4)&&C.out_grouping_b(q,97,232)&&(C.cursor=C.limit-t,C.ket=C.cursor,C.cursor>C.limit_backward&&(C.cursor--,C.bra=C.cursor,C.slice_del())))}var f,_,w,b=[new r("",-1,6),new r("á",0,1),new r("ä",0,1),new r("é",0,2),new r("ë",0,2),new r("í",0,3),new r("ï",0,3),new r("ó",0,4),new r("ö",0,4),new r("ú",0,5),new r("ü",0,5)],p=[new r("",-1,3),new r("I",0,2),new r("Y",0,1)],g=[new r("dd",-1,-1),new r("kk",-1,-1),new r("tt",-1,-1)],h=[new r("ene",-1,2),new r("se",-1,3),new r("en",-1,2),new r("heden",2,1),new r("s",-1,3)],k=[new r("end",-1,1),new r("ig",-1,2),new r("ing",-1,1),new r("lijk",-1,3),new r("baar",-1,4),new r("bar",-1,5)],v=[new r("aa",-1,-1),new r("ee",-1,-1),new r("oo",-1,-1),new r("uu",-1,-1)],q=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,128],j=[1,0,0,17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,128],z=[17,67,16,1,0,0,0,0,0,0,0,0,0,0,0,0,128],C=new i;this.setCurrent=function(e){C.setCurrent(e)},this.getCurrent=function(){return C.getCurrent()},this.stem=function(){var r=C.cursor;return e(),C.cursor=r,o(),C.limit_backward=r,C.cursor=C.limit,d(),C.cursor=C.limit_backward,s(),!0}};return function(e){return"function"==typeof e.update?e.update(function(e){return n.setCurrent(e),n.stem(),n.getCurrent()}):(n.setCurrent(e),n.stem(),n.getCurrent())}}(),e.Pipeline.registerFunction(e.du.stemmer,"stemmer-du"),e.du.stopWordFilter=e.generateStopWordFilter(" aan al alles als altijd andere ben bij daar dan dat de der deze die dit doch doen door dus een eens en er ge geen geweest haar had heb hebben heeft hem het hier hij hoe hun iemand iets ik in is ja je kan kon kunnen maar me meer men met mij mijn moet na naar niet niets nog nu of om omdat onder ons ook op over reeds te tegen toch toen tot u uit uw van veel voor want waren was wat werd wezen wie wil worden wordt zal ze zelf zich zij zijn zo zonder zou".split(" ")),e.Pipeline.registerFunction(e.du.stopWordFilter,"stopWordFilter-du")}}); \ No newline at end of file diff --git a/docs/assets/javascripts/lunr/min/lunr.es.min.js b/docs/assets/javascripts/lunr/min/lunr.es.min.js new file mode 100644 index 0000000..2989d34 --- /dev/null +++ b/docs/assets/javascripts/lunr/min/lunr.es.min.js @@ -0,0 +1,18 @@ +/*! + * Lunr languages, `Spanish` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +!function(e,s){"function"==typeof define&&define.amd?define(s):"object"==typeof exports?module.exports=s():s()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.es=function(){this.pipeline.reset(),this.pipeline.add(e.es.trimmer,e.es.stopWordFilter,e.es.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.es.stemmer))},e.es.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.es.trimmer=e.trimmerSupport.generateTrimmer(e.es.wordCharacters),e.Pipeline.registerFunction(e.es.trimmer,"trimmer-es"),e.es.stemmer=function(){var s=e.stemmerSupport.Among,r=e.stemmerSupport.SnowballProgram,n=new function(){function e(){if(A.out_grouping(x,97,252)){for(;!A.in_grouping(x,97,252);){if(A.cursor>=A.limit)return!0;A.cursor++}return!1}return!0}function n(){if(A.in_grouping(x,97,252)){var s=A.cursor;if(e()){if(A.cursor=s,!A.in_grouping(x,97,252))return!0;for(;!A.out_grouping(x,97,252);){if(A.cursor>=A.limit)return!0;A.cursor++}}return!1}return!0}function i(){var s,r=A.cursor;if(n()){if(A.cursor=r,!A.out_grouping(x,97,252))return;if(s=A.cursor,e()){if(A.cursor=s,!A.in_grouping(x,97,252)||A.cursor>=A.limit)return;A.cursor++}}g=A.cursor}function a(){for(;!A.in_grouping(x,97,252);){if(A.cursor>=A.limit)return!1;A.cursor++}for(;!A.out_grouping(x,97,252);){if(A.cursor>=A.limit)return!1;A.cursor++}return!0}function t(){var e=A.cursor;g=A.limit,p=g,v=g,i(),A.cursor=e,a()&&(p=A.cursor,a()&&(v=A.cursor))}function o(){for(var e;;){if(A.bra=A.cursor,e=A.find_among(k,6))switch(A.ket=A.cursor,e){case 1:A.slice_from("a");continue;case 2:A.slice_from("e");continue;case 3:A.slice_from("i");continue;case 4:A.slice_from("o");continue;case 5:A.slice_from("u");continue;case 6:if(A.cursor>=A.limit)break;A.cursor++;continue}break}}function u(){return g<=A.cursor}function w(){return p<=A.cursor}function c(){return v<=A.cursor}function m(){var e;if(A.ket=A.cursor,A.find_among_b(y,13)&&(A.bra=A.cursor,(e=A.find_among_b(q,11))&&u()))switch(e){case 1:A.bra=A.cursor,A.slice_from("iendo");break;case 2:A.bra=A.cursor,A.slice_from("ando");break;case 3:A.bra=A.cursor,A.slice_from("ar");break;case 4:A.bra=A.cursor,A.slice_from("er");break;case 5:A.bra=A.cursor,A.slice_from("ir");break;case 6:A.slice_del();break;case 7:A.eq_s_b(1,"u")&&A.slice_del()}}function l(e,s){if(!c())return!0;A.slice_del(),A.ket=A.cursor;var r=A.find_among_b(e,s);return r&&(A.bra=A.cursor,1==r&&c()&&A.slice_del()),!1}function d(e){return!c()||(A.slice_del(),A.ket=A.cursor,A.eq_s_b(2,e)&&(A.bra=A.cursor,c()&&A.slice_del()),!1)}function b(){var e;if(A.ket=A.cursor,e=A.find_among_b(S,46)){switch(A.bra=A.cursor,e){case 1:if(!c())return!1;A.slice_del();break;case 2:if(d("ic"))return!1;break;case 3:if(!c())return!1;A.slice_from("log");break;case 4:if(!c())return!1;A.slice_from("u");break;case 5:if(!c())return!1;A.slice_from("ente");break;case 6:if(!w())return!1;A.slice_del(),A.ket=A.cursor,e=A.find_among_b(C,4),e&&(A.bra=A.cursor,c()&&(A.slice_del(),1==e&&(A.ket=A.cursor,A.eq_s_b(2,"at")&&(A.bra=A.cursor,c()&&A.slice_del()))));break;case 7:if(l(P,3))return!1;break;case 8:if(l(F,3))return!1;break;case 9:if(d("at"))return!1}return!0}return!1}function f(){var e,s;if(A.cursor>=g&&(s=A.limit_backward,A.limit_backward=g,A.ket=A.cursor,e=A.find_among_b(W,12),A.limit_backward=s,e)){if(A.bra=A.cursor,1==e){if(!A.eq_s_b(1,"u"))return!1;A.slice_del()}return!0}return!1}function _(){var e,s,r,n;if(A.cursor>=g&&(s=A.limit_backward,A.limit_backward=g,A.ket=A.cursor,e=A.find_among_b(L,96),A.limit_backward=s,e))switch(A.bra=A.cursor,e){case 1:r=A.limit-A.cursor,A.eq_s_b(1,"u")?(n=A.limit-A.cursor,A.eq_s_b(1,"g")?A.cursor=A.limit-n:A.cursor=A.limit-r):A.cursor=A.limit-r,A.bra=A.cursor;case 2:A.slice_del()}}function h(){var e,s;if(A.ket=A.cursor,e=A.find_among_b(z,8))switch(A.bra=A.cursor,e){case 1:u()&&A.slice_del();break;case 2:u()&&(A.slice_del(),A.ket=A.cursor,A.eq_s_b(1,"u")&&(A.bra=A.cursor,s=A.limit-A.cursor,A.eq_s_b(1,"g")&&(A.cursor=A.limit-s,u()&&A.slice_del())))}}var v,p,g,k=[new s("",-1,6),new s("á",0,1),new s("é",0,2),new s("í",0,3),new s("ó",0,4),new s("ú",0,5)],y=[new s("la",-1,-1),new s("sela",0,-1),new s("le",-1,-1),new s("me",-1,-1),new s("se",-1,-1),new s("lo",-1,-1),new s("selo",5,-1),new s("las",-1,-1),new s("selas",7,-1),new s("les",-1,-1),new s("los",-1,-1),new s("selos",10,-1),new s("nos",-1,-1)],q=[new s("ando",-1,6),new s("iendo",-1,6),new s("yendo",-1,7),new s("ándo",-1,2),new s("iéndo",-1,1),new s("ar",-1,6),new s("er",-1,6),new s("ir",-1,6),new s("ár",-1,3),new s("ér",-1,4),new s("ír",-1,5)],C=[new s("ic",-1,-1),new s("ad",-1,-1),new s("os",-1,-1),new s("iv",-1,1)],P=[new s("able",-1,1),new s("ible",-1,1),new s("ante",-1,1)],F=[new s("ic",-1,1),new s("abil",-1,1),new s("iv",-1,1)],S=[new s("ica",-1,1),new s("ancia",-1,2),new s("encia",-1,5),new s("adora",-1,2),new s("osa",-1,1),new s("ista",-1,1),new s("iva",-1,9),new s("anza",-1,1),new s("logía",-1,3),new s("idad",-1,8),new s("able",-1,1),new s("ible",-1,1),new s("ante",-1,2),new s("mente",-1,7),new s("amente",13,6),new s("ación",-1,2),new s("ución",-1,4),new s("ico",-1,1),new s("ismo",-1,1),new s("oso",-1,1),new s("amiento",-1,1),new s("imiento",-1,1),new s("ivo",-1,9),new s("ador",-1,2),new s("icas",-1,1),new s("ancias",-1,2),new s("encias",-1,5),new s("adoras",-1,2),new s("osas",-1,1),new s("istas",-1,1),new s("ivas",-1,9),new s("anzas",-1,1),new s("logías",-1,3),new s("idades",-1,8),new s("ables",-1,1),new s("ibles",-1,1),new s("aciones",-1,2),new s("uciones",-1,4),new s("adores",-1,2),new s("antes",-1,2),new s("icos",-1,1),new s("ismos",-1,1),new s("osos",-1,1),new s("amientos",-1,1),new s("imientos",-1,1),new s("ivos",-1,9)],W=[new s("ya",-1,1),new s("ye",-1,1),new s("yan",-1,1),new s("yen",-1,1),new s("yeron",-1,1),new s("yendo",-1,1),new s("yo",-1,1),new s("yas",-1,1),new s("yes",-1,1),new s("yais",-1,1),new s("yamos",-1,1),new s("yó",-1,1)],L=[new s("aba",-1,2),new s("ada",-1,2),new s("ida",-1,2),new s("ara",-1,2),new s("iera",-1,2),new s("ía",-1,2),new s("aría",5,2),new s("ería",5,2),new s("iría",5,2),new s("ad",-1,2),new s("ed",-1,2),new s("id",-1,2),new s("ase",-1,2),new s("iese",-1,2),new s("aste",-1,2),new s("iste",-1,2),new s("an",-1,2),new s("aban",16,2),new s("aran",16,2),new s("ieran",16,2),new s("ían",16,2),new s("arían",20,2),new s("erían",20,2),new s("irían",20,2),new s("en",-1,1),new s("asen",24,2),new s("iesen",24,2),new s("aron",-1,2),new s("ieron",-1,2),new s("arán",-1,2),new s("erán",-1,2),new s("irán",-1,2),new s("ado",-1,2),new s("ido",-1,2),new s("ando",-1,2),new s("iendo",-1,2),new s("ar",-1,2),new s("er",-1,2),new s("ir",-1,2),new s("as",-1,2),new s("abas",39,2),new s("adas",39,2),new s("idas",39,2),new s("aras",39,2),new s("ieras",39,2),new s("ías",39,2),new s("arías",45,2),new s("erías",45,2),new s("irías",45,2),new s("es",-1,1),new s("ases",49,2),new s("ieses",49,2),new s("abais",-1,2),new s("arais",-1,2),new s("ierais",-1,2),new s("íais",-1,2),new s("aríais",55,2),new s("eríais",55,2),new s("iríais",55,2),new s("aseis",-1,2),new s("ieseis",-1,2),new s("asteis",-1,2),new s("isteis",-1,2),new s("áis",-1,2),new s("éis",-1,1),new s("aréis",64,2),new s("eréis",64,2),new s("iréis",64,2),new s("ados",-1,2),new s("idos",-1,2),new s("amos",-1,2),new s("ábamos",70,2),new s("áramos",70,2),new s("iéramos",70,2),new s("íamos",70,2),new s("aríamos",74,2),new s("eríamos",74,2),new s("iríamos",74,2),new s("emos",-1,1),new s("aremos",78,2),new s("eremos",78,2),new s("iremos",78,2),new s("ásemos",78,2),new s("iésemos",78,2),new s("imos",-1,2),new s("arás",-1,2),new s("erás",-1,2),new s("irás",-1,2),new s("ís",-1,2),new s("ará",-1,2),new s("erá",-1,2),new s("irá",-1,2),new s("aré",-1,2),new s("eré",-1,2),new s("iré",-1,2),new s("ió",-1,2)],z=[new s("a",-1,1),new s("e",-1,2),new s("o",-1,1),new s("os",-1,1),new s("á",-1,1),new s("é",-1,2),new s("í",-1,1),new s("ó",-1,1)],x=[17,65,16,0,0,0,0,0,0,0,0,0,0,0,0,0,1,17,4,10],A=new r;this.setCurrent=function(e){A.setCurrent(e)},this.getCurrent=function(){return A.getCurrent()},this.stem=function(){var e=A.cursor;return t(),A.limit_backward=e,A.cursor=A.limit,m(),A.cursor=A.limit,b()||(A.cursor=A.limit,f()||(A.cursor=A.limit,_())),A.cursor=A.limit,h(),A.cursor=A.limit_backward,o(),!0}};return function(e){return"function"==typeof e.update?e.update(function(e){return n.setCurrent(e),n.stem(),n.getCurrent()}):(n.setCurrent(e),n.stem(),n.getCurrent())}}(),e.Pipeline.registerFunction(e.es.stemmer,"stemmer-es"),e.es.stopWordFilter=e.generateStopWordFilter("a al algo algunas algunos ante antes como con contra cual cuando de del desde donde durante e el ella ellas ellos en entre era erais eran eras eres es esa esas ese eso esos esta estaba estabais estaban estabas estad estada estadas estado estados estamos estando estar estaremos estará estarán estarás estaré estaréis estaría estaríais estaríamos estarían estarías estas este estemos esto estos estoy estuve estuviera estuvierais estuvieran estuvieras estuvieron estuviese estuvieseis estuviesen estuvieses estuvimos estuviste estuvisteis estuviéramos estuviésemos estuvo está estábamos estáis están estás esté estéis estén estés fue fuera fuerais fueran fueras fueron fuese fueseis fuesen fueses fui fuimos fuiste fuisteis fuéramos fuésemos ha habida habidas habido habidos habiendo habremos habrá habrán habrás habré habréis habría habríais habríamos habrían habrías habéis había habíais habíamos habían habías han has hasta hay haya hayamos hayan hayas hayáis he hemos hube hubiera hubierais hubieran hubieras hubieron hubiese hubieseis hubiesen hubieses hubimos hubiste hubisteis hubiéramos hubiésemos hubo la las le les lo los me mi mis mucho muchos muy más mí mía mías mío míos nada ni no nos nosotras nosotros nuestra nuestras nuestro nuestros o os otra otras otro otros para pero poco por porque que quien quienes qué se sea seamos sean seas seremos será serán serás seré seréis sería seríais seríamos serían serías seáis sido siendo sin sobre sois somos son soy su sus suya suyas suyo suyos sí también tanto te tendremos tendrá tendrán tendrás tendré tendréis tendría tendríais tendríamos tendrían tendrías tened tenemos tenga tengamos tengan tengas tengo tengáis tenida tenidas tenido tenidos teniendo tenéis tenía teníais teníamos tenían tenías ti tiene tienen tienes todo todos tu tus tuve tuviera tuvierais tuvieran tuvieras tuvieron tuviese tuvieseis tuviesen tuvieses tuvimos tuviste tuvisteis tuviéramos tuviésemos tuvo tuya tuyas tuyo tuyos tú un una uno unos vosotras vosotros vuestra vuestras vuestro vuestros y ya yo él éramos".split(" ")),e.Pipeline.registerFunction(e.es.stopWordFilter,"stopWordFilter-es")}}); \ No newline at end of file diff --git a/docs/assets/javascripts/lunr/min/lunr.fi.min.js b/docs/assets/javascripts/lunr/min/lunr.fi.min.js new file mode 100644 index 0000000..29f5dfc --- /dev/null +++ b/docs/assets/javascripts/lunr/min/lunr.fi.min.js @@ -0,0 +1,18 @@ +/*! + * Lunr languages, `Finnish` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +!function(i,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():e()(i.lunr)}(this,function(){return function(i){if(void 0===i)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===i.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");i.fi=function(){this.pipeline.reset(),this.pipeline.add(i.fi.trimmer,i.fi.stopWordFilter,i.fi.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(i.fi.stemmer))},i.fi.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",i.fi.trimmer=i.trimmerSupport.generateTrimmer(i.fi.wordCharacters),i.Pipeline.registerFunction(i.fi.trimmer,"trimmer-fi"),i.fi.stemmer=function(){var e=i.stemmerSupport.Among,r=i.stemmerSupport.SnowballProgram,n=new function(){function i(){f=A.limit,d=f,n()||(f=A.cursor,n()||(d=A.cursor))}function n(){for(var i;;){if(i=A.cursor,A.in_grouping(W,97,246))break;if(A.cursor=i,i>=A.limit)return!0;A.cursor++}for(A.cursor=i;!A.out_grouping(W,97,246);){if(A.cursor>=A.limit)return!0;A.cursor++}return!1}function t(){return d<=A.cursor}function s(){var i,e;if(A.cursor>=f)if(e=A.limit_backward,A.limit_backward=f,A.ket=A.cursor,i=A.find_among_b(h,10)){switch(A.bra=A.cursor,A.limit_backward=e,i){case 1:if(!A.in_grouping_b(x,97,246))return;break;case 2:if(!t())return}A.slice_del()}else A.limit_backward=e}function o(){var i,e,r;if(A.cursor>=f)if(e=A.limit_backward,A.limit_backward=f,A.ket=A.cursor,i=A.find_among_b(v,9))switch(A.bra=A.cursor,A.limit_backward=e,i){case 1:r=A.limit-A.cursor,A.eq_s_b(1,"k")||(A.cursor=A.limit-r,A.slice_del());break;case 2:A.slice_del(),A.ket=A.cursor,A.eq_s_b(3,"kse")&&(A.bra=A.cursor,A.slice_from("ksi"));break;case 3:A.slice_del();break;case 4:A.find_among_b(p,6)&&A.slice_del();break;case 5:A.find_among_b(g,6)&&A.slice_del();break;case 6:A.find_among_b(j,2)&&A.slice_del()}else A.limit_backward=e}function l(){return A.find_among_b(q,7)}function a(){return A.eq_s_b(1,"i")&&A.in_grouping_b(L,97,246)}function u(){var i,e,r;if(A.cursor>=f)if(e=A.limit_backward,A.limit_backward=f,A.ket=A.cursor,i=A.find_among_b(C,30)){switch(A.bra=A.cursor,A.limit_backward=e,i){case 1:if(!A.eq_s_b(1,"a"))return;break;case 2:case 9:if(!A.eq_s_b(1,"e"))return;break;case 3:if(!A.eq_s_b(1,"i"))return;break;case 4:if(!A.eq_s_b(1,"o"))return;break;case 5:if(!A.eq_s_b(1,"ä"))return;break;case 6:if(!A.eq_s_b(1,"ö"))return;break;case 7:if(r=A.limit-A.cursor,!l()&&(A.cursor=A.limit-r,!A.eq_s_b(2,"ie"))){A.cursor=A.limit-r;break}if(A.cursor=A.limit-r,A.cursor<=A.limit_backward){A.cursor=A.limit-r;break}A.cursor--,A.bra=A.cursor;break;case 8:if(!A.in_grouping_b(W,97,246)||!A.out_grouping_b(W,97,246))return}A.slice_del(),k=!0}else A.limit_backward=e}function c(){var i,e,r;if(A.cursor>=d)if(e=A.limit_backward,A.limit_backward=d,A.ket=A.cursor,i=A.find_among_b(P,14)){if(A.bra=A.cursor,A.limit_backward=e,1==i){if(r=A.limit-A.cursor,A.eq_s_b(2,"po"))return;A.cursor=A.limit-r}A.slice_del()}else A.limit_backward=e}function m(){var i;A.cursor>=f&&(i=A.limit_backward,A.limit_backward=f,A.ket=A.cursor,A.find_among_b(F,2)?(A.bra=A.cursor,A.limit_backward=i,A.slice_del()):A.limit_backward=i)}function w(){var i,e,r,n,t,s;if(A.cursor>=f){if(e=A.limit_backward,A.limit_backward=f,A.ket=A.cursor,A.eq_s_b(1,"t")&&(A.bra=A.cursor,r=A.limit-A.cursor,A.in_grouping_b(W,97,246)&&(A.cursor=A.limit-r,A.slice_del(),A.limit_backward=e,n=A.limit-A.cursor,A.cursor>=d&&(A.cursor=d,t=A.limit_backward,A.limit_backward=A.cursor,A.cursor=A.limit-n,A.ket=A.cursor,i=A.find_among_b(S,2))))){if(A.bra=A.cursor,A.limit_backward=t,1==i){if(s=A.limit-A.cursor,A.eq_s_b(2,"po"))return;A.cursor=A.limit-s}return void A.slice_del()}A.limit_backward=e}}function _(){var i,e,r,n;if(A.cursor>=f){for(i=A.limit_backward,A.limit_backward=f,e=A.limit-A.cursor,l()&&(A.cursor=A.limit-e,A.ket=A.cursor,A.cursor>A.limit_backward&&(A.cursor--,A.bra=A.cursor,A.slice_del())),A.cursor=A.limit-e,A.ket=A.cursor,A.in_grouping_b(y,97,228)&&(A.bra=A.cursor,A.out_grouping_b(W,97,246)&&A.slice_del()),A.cursor=A.limit-e,A.ket=A.cursor,A.eq_s_b(1,"j")&&(A.bra=A.cursor,r=A.limit-A.cursor,A.eq_s_b(1,"o")?A.slice_del():(A.cursor=A.limit-r,A.eq_s_b(1,"u")&&A.slice_del())),A.cursor=A.limit-e,A.ket=A.cursor,A.eq_s_b(1,"o")&&(A.bra=A.cursor,A.eq_s_b(1,"j")&&A.slice_del()),A.cursor=A.limit-e,A.limit_backward=i;;){if(n=A.limit-A.cursor,A.out_grouping_b(W,97,246)){A.cursor=A.limit-n;break}if(A.cursor=A.limit-n,A.cursor<=A.limit_backward)return;A.cursor--}A.ket=A.cursor,A.cursor>A.limit_backward&&(A.cursor--,A.bra=A.cursor,b=A.slice_to(),A.eq_v_b(b)&&A.slice_del())}}var k,b,d,f,h=[new e("pa",-1,1),new e("sti",-1,2),new e("kaan",-1,1),new e("han",-1,1),new e("kin",-1,1),new e("hän",-1,1),new e("kään",-1,1),new e("ko",-1,1),new e("pä",-1,1),new e("kö",-1,1)],p=[new e("lla",-1,-1),new e("na",-1,-1),new e("ssa",-1,-1),new e("ta",-1,-1),new e("lta",3,-1),new e("sta",3,-1)],g=[new e("llä",-1,-1),new e("nä",-1,-1),new e("ssä",-1,-1),new e("tä",-1,-1),new e("ltä",3,-1),new e("stä",3,-1)],j=[new e("lle",-1,-1),new e("ine",-1,-1)],v=[new e("nsa",-1,3),new e("mme",-1,3),new e("nne",-1,3),new e("ni",-1,2),new e("si",-1,1),new e("an",-1,4),new e("en",-1,6),new e("än",-1,5),new e("nsä",-1,3)],q=[new e("aa",-1,-1),new e("ee",-1,-1),new e("ii",-1,-1),new e("oo",-1,-1),new e("uu",-1,-1),new e("ää",-1,-1),new e("öö",-1,-1)],C=[new e("a",-1,8),new e("lla",0,-1),new e("na",0,-1),new e("ssa",0,-1),new e("ta",0,-1),new e("lta",4,-1),new e("sta",4,-1),new e("tta",4,9),new e("lle",-1,-1),new e("ine",-1,-1),new e("ksi",-1,-1),new e("n",-1,7),new e("han",11,1),new e("den",11,-1,a),new e("seen",11,-1,l),new e("hen",11,2),new e("tten",11,-1,a),new e("hin",11,3),new e("siin",11,-1,a),new e("hon",11,4),new e("hän",11,5),new e("hön",11,6),new e("ä",-1,8),new e("llä",22,-1),new e("nä",22,-1),new e("ssä",22,-1),new e("tä",22,-1),new e("ltä",26,-1),new e("stä",26,-1),new e("ttä",26,9)],P=[new e("eja",-1,-1),new e("mma",-1,1),new e("imma",1,-1),new e("mpa",-1,1),new e("impa",3,-1),new e("mmi",-1,1),new e("immi",5,-1),new e("mpi",-1,1),new e("impi",7,-1),new e("ejä",-1,-1),new e("mmä",-1,1),new e("immä",10,-1),new e("mpä",-1,1),new e("impä",12,-1)],F=[new e("i",-1,-1),new e("j",-1,-1)],S=[new e("mma",-1,1),new e("imma",0,-1)],y=[17,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8],W=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,8,0,32],L=[17,65,16,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,32],x=[17,97,24,1,0,0,0,0,0,0,0,0,0,0,0,0,8,0,32],A=new r;this.setCurrent=function(i){A.setCurrent(i)},this.getCurrent=function(){return A.getCurrent()},this.stem=function(){var e=A.cursor;return i(),k=!1,A.limit_backward=e,A.cursor=A.limit,s(),A.cursor=A.limit,o(),A.cursor=A.limit,u(),A.cursor=A.limit,c(),A.cursor=A.limit,k?(m(),A.cursor=A.limit):(A.cursor=A.limit,w(),A.cursor=A.limit),_(),!0}};return function(i){return"function"==typeof i.update?i.update(function(i){return n.setCurrent(i),n.stem(),n.getCurrent()}):(n.setCurrent(i),n.stem(),n.getCurrent())}}(),i.Pipeline.registerFunction(i.fi.stemmer,"stemmer-fi"),i.fi.stopWordFilter=i.generateStopWordFilter("ei eivät emme en et ette että he heidän heidät heihin heille heillä heiltä heissä heistä heitä hän häneen hänelle hänellä häneltä hänen hänessä hänestä hänet häntä itse ja johon joiden joihin joiksi joilla joille joilta joina joissa joista joita joka joksi jolla jolle jolta jona jonka jos jossa josta jota jotka kanssa keiden keihin keiksi keille keillä keiltä keinä keissä keistä keitä keneen keneksi kenelle kenellä keneltä kenen kenenä kenessä kenestä kenet ketkä ketkä ketä koska kuin kuka kun me meidän meidät meihin meille meillä meiltä meissä meistä meitä mihin miksi mikä mille millä miltä minkä minkä minua minulla minulle minulta minun minussa minusta minut minuun minä minä missä mistä mitkä mitä mukaan mutta ne niiden niihin niiksi niille niillä niiltä niin niin niinä niissä niistä niitä noiden noihin noiksi noilla noille noilta noin noina noissa noista noita nuo nyt näiden näihin näiksi näille näillä näiltä näinä näissä näistä näitä nämä ole olemme olen olet olette oli olimme olin olisi olisimme olisin olisit olisitte olisivat olit olitte olivat olla olleet ollut on ovat poikki se sekä sen siihen siinä siitä siksi sille sillä sillä siltä sinua sinulla sinulle sinulta sinun sinussa sinusta sinut sinuun sinä sinä sitä tai te teidän teidät teihin teille teillä teiltä teissä teistä teitä tuo tuohon tuoksi tuolla tuolle tuolta tuon tuona tuossa tuosta tuota tähän täksi tälle tällä tältä tämä tämän tänä tässä tästä tätä vaan vai vaikka yli".split(" ")),i.Pipeline.registerFunction(i.fi.stopWordFilter,"stopWordFilter-fi")}}); \ No newline at end of file diff --git a/docs/assets/javascripts/lunr/min/lunr.fr.min.js b/docs/assets/javascripts/lunr/min/lunr.fr.min.js new file mode 100644 index 0000000..68cd009 --- /dev/null +++ b/docs/assets/javascripts/lunr/min/lunr.fr.min.js @@ -0,0 +1,18 @@ +/*! + * Lunr languages, `French` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.fr=function(){this.pipeline.reset(),this.pipeline.add(e.fr.trimmer,e.fr.stopWordFilter,e.fr.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.fr.stemmer))},e.fr.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.fr.trimmer=e.trimmerSupport.generateTrimmer(e.fr.wordCharacters),e.Pipeline.registerFunction(e.fr.trimmer,"trimmer-fr"),e.fr.stemmer=function(){var r=e.stemmerSupport.Among,s=e.stemmerSupport.SnowballProgram,i=new function(){function e(e,r,s){return!(!W.eq_s(1,e)||(W.ket=W.cursor,!W.in_grouping(F,97,251)))&&(W.slice_from(r),W.cursor=s,!0)}function i(e,r,s){return!!W.eq_s(1,e)&&(W.ket=W.cursor,W.slice_from(r),W.cursor=s,!0)}function n(){for(var r,s;;){if(r=W.cursor,W.in_grouping(F,97,251)){if(W.bra=W.cursor,s=W.cursor,e("u","U",r))continue;if(W.cursor=s,e("i","I",r))continue;if(W.cursor=s,i("y","Y",r))continue}if(W.cursor=r,W.bra=r,!e("y","Y",r)){if(W.cursor=r,W.eq_s(1,"q")&&(W.bra=W.cursor,i("u","U",r)))continue;if(W.cursor=r,r>=W.limit)return;W.cursor++}}}function t(){for(;!W.in_grouping(F,97,251);){if(W.cursor>=W.limit)return!0;W.cursor++}for(;!W.out_grouping(F,97,251);){if(W.cursor>=W.limit)return!0;W.cursor++}return!1}function u(){var e=W.cursor;if(q=W.limit,g=q,p=q,W.in_grouping(F,97,251)&&W.in_grouping(F,97,251)&&W.cursor=W.limit){W.cursor=q;break}W.cursor++}while(!W.in_grouping(F,97,251))}q=W.cursor,W.cursor=e,t()||(g=W.cursor,t()||(p=W.cursor))}function o(){for(var e,r;;){if(r=W.cursor,W.bra=r,!(e=W.find_among(h,4)))break;switch(W.ket=W.cursor,e){case 1:W.slice_from("i");break;case 2:W.slice_from("u");break;case 3:W.slice_from("y");break;case 4:if(W.cursor>=W.limit)return;W.cursor++}}}function c(){return q<=W.cursor}function a(){return g<=W.cursor}function l(){return p<=W.cursor}function w(){var e,r;if(W.ket=W.cursor,e=W.find_among_b(C,43)){switch(W.bra=W.cursor,e){case 1:if(!l())return!1;W.slice_del();break;case 2:if(!l())return!1;W.slice_del(),W.ket=W.cursor,W.eq_s_b(2,"ic")&&(W.bra=W.cursor,l()?W.slice_del():W.slice_from("iqU"));break;case 3:if(!l())return!1;W.slice_from("log");break;case 4:if(!l())return!1;W.slice_from("u");break;case 5:if(!l())return!1;W.slice_from("ent");break;case 6:if(!c())return!1;if(W.slice_del(),W.ket=W.cursor,e=W.find_among_b(z,6))switch(W.bra=W.cursor,e){case 1:l()&&(W.slice_del(),W.ket=W.cursor,W.eq_s_b(2,"at")&&(W.bra=W.cursor,l()&&W.slice_del()));break;case 2:l()?W.slice_del():a()&&W.slice_from("eux");break;case 3:l()&&W.slice_del();break;case 4:c()&&W.slice_from("i")}break;case 7:if(!l())return!1;if(W.slice_del(),W.ket=W.cursor,e=W.find_among_b(y,3))switch(W.bra=W.cursor,e){case 1:l()?W.slice_del():W.slice_from("abl");break;case 2:l()?W.slice_del():W.slice_from("iqU");break;case 3:l()&&W.slice_del()}break;case 8:if(!l())return!1;if(W.slice_del(),W.ket=W.cursor,W.eq_s_b(2,"at")&&(W.bra=W.cursor,l()&&(W.slice_del(),W.ket=W.cursor,W.eq_s_b(2,"ic")))){W.bra=W.cursor,l()?W.slice_del():W.slice_from("iqU");break}break;case 9:W.slice_from("eau");break;case 10:if(!a())return!1;W.slice_from("al");break;case 11:if(l())W.slice_del();else{if(!a())return!1;W.slice_from("eux")}break;case 12:if(!a()||!W.out_grouping_b(F,97,251))return!1;W.slice_del();break;case 13:return c()&&W.slice_from("ant"),!1;case 14:return c()&&W.slice_from("ent"),!1;case 15:return r=W.limit-W.cursor,W.in_grouping_b(F,97,251)&&c()&&(W.cursor=W.limit-r,W.slice_del()),!1}return!0}return!1}function f(){var e,r;if(W.cursor=q){if(s=W.limit_backward,W.limit_backward=q,W.ket=W.cursor,e=W.find_among_b(P,7))switch(W.bra=W.cursor,e){case 1:if(l()){if(i=W.limit-W.cursor,!W.eq_s_b(1,"s")&&(W.cursor=W.limit-i,!W.eq_s_b(1,"t")))break;W.slice_del()}break;case 2:W.slice_from("i");break;case 3:W.slice_del();break;case 4:W.eq_s_b(2,"gu")&&W.slice_del()}W.limit_backward=s}}function b(){var e=W.limit-W.cursor;W.find_among_b(U,5)&&(W.cursor=W.limit-e,W.ket=W.cursor,W.cursor>W.limit_backward&&(W.cursor--,W.bra=W.cursor,W.slice_del()))}function d(){for(var e,r=1;W.out_grouping_b(F,97,251);)r--;if(r<=0){if(W.ket=W.cursor,e=W.limit-W.cursor,!W.eq_s_b(1,"é")&&(W.cursor=W.limit-e,!W.eq_s_b(1,"è")))return;W.bra=W.cursor,W.slice_from("e")}}function k(){if(!w()&&(W.cursor=W.limit,!f()&&(W.cursor=W.limit,!m())))return W.cursor=W.limit,void _();W.cursor=W.limit,W.ket=W.cursor,W.eq_s_b(1,"Y")?(W.bra=W.cursor,W.slice_from("i")):(W.cursor=W.limit,W.eq_s_b(1,"ç")&&(W.bra=W.cursor,W.slice_from("c")))}var p,g,q,v=[new r("col",-1,-1),new r("par",-1,-1),new r("tap",-1,-1)],h=[new r("",-1,4),new r("I",0,1),new r("U",0,2),new r("Y",0,3)],z=[new r("iqU",-1,3),new r("abl",-1,3),new r("Ièr",-1,4),new r("ièr",-1,4),new r("eus",-1,2),new r("iv",-1,1)],y=[new r("ic",-1,2),new r("abil",-1,1),new r("iv",-1,3)],C=[new r("iqUe",-1,1),new r("atrice",-1,2),new r("ance",-1,1),new r("ence",-1,5),new r("logie",-1,3),new r("able",-1,1),new r("isme",-1,1),new r("euse",-1,11),new r("iste",-1,1),new r("ive",-1,8),new r("if",-1,8),new r("usion",-1,4),new r("ation",-1,2),new r("ution",-1,4),new r("ateur",-1,2),new r("iqUes",-1,1),new r("atrices",-1,2),new r("ances",-1,1),new r("ences",-1,5),new r("logies",-1,3),new r("ables",-1,1),new r("ismes",-1,1),new r("euses",-1,11),new r("istes",-1,1),new r("ives",-1,8),new r("ifs",-1,8),new r("usions",-1,4),new r("ations",-1,2),new r("utions",-1,4),new r("ateurs",-1,2),new r("ments",-1,15),new r("ements",30,6),new r("issements",31,12),new r("ités",-1,7),new r("ment",-1,15),new r("ement",34,6),new r("issement",35,12),new r("amment",34,13),new r("emment",34,14),new r("aux",-1,10),new r("eaux",39,9),new r("eux",-1,1),new r("ité",-1,7)],x=[new r("ira",-1,1),new r("ie",-1,1),new r("isse",-1,1),new r("issante",-1,1),new r("i",-1,1),new r("irai",4,1),new r("ir",-1,1),new r("iras",-1,1),new r("ies",-1,1),new r("îmes",-1,1),new r("isses",-1,1),new r("issantes",-1,1),new r("îtes",-1,1),new r("is",-1,1),new r("irais",13,1),new r("issais",13,1),new r("irions",-1,1),new r("issions",-1,1),new r("irons",-1,1),new r("issons",-1,1),new r("issants",-1,1),new r("it",-1,1),new r("irait",21,1),new r("issait",21,1),new r("issant",-1,1),new r("iraIent",-1,1),new r("issaIent",-1,1),new r("irent",-1,1),new r("issent",-1,1),new r("iront",-1,1),new r("ît",-1,1),new r("iriez",-1,1),new r("issiez",-1,1),new r("irez",-1,1),new r("issez",-1,1)],I=[new r("a",-1,3),new r("era",0,2),new r("asse",-1,3),new r("ante",-1,3),new r("ée",-1,2),new r("ai",-1,3),new r("erai",5,2),new r("er",-1,2),new r("as",-1,3),new r("eras",8,2),new r("âmes",-1,3),new r("asses",-1,3),new r("antes",-1,3),new r("âtes",-1,3),new r("ées",-1,2),new r("ais",-1,3),new r("erais",15,2),new r("ions",-1,1),new r("erions",17,2),new r("assions",17,3),new r("erons",-1,2),new r("ants",-1,3),new r("és",-1,2),new r("ait",-1,3),new r("erait",23,2),new r("ant",-1,3),new r("aIent",-1,3),new r("eraIent",26,2),new r("èrent",-1,2),new r("assent",-1,3),new r("eront",-1,2),new r("ât",-1,3),new r("ez",-1,2),new r("iez",32,2),new r("eriez",33,2),new r("assiez",33,3),new r("erez",32,2),new r("é",-1,2)],P=[new r("e",-1,3),new r("Ière",0,2),new r("ière",0,2),new r("ion",-1,1),new r("Ier",-1,2),new r("ier",-1,2),new r("ë",-1,4)],U=[new r("ell",-1,-1),new r("eill",-1,-1),new r("enn",-1,-1),new r("onn",-1,-1),new r("ett",-1,-1)],F=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,128,130,103,8,5],S=[1,65,20,0,0,0,0,0,0,0,0,0,0,0,0,0,128],W=new s;this.setCurrent=function(e){W.setCurrent(e)},this.getCurrent=function(){return W.getCurrent()},this.stem=function(){var e=W.cursor;return n(),W.cursor=e,u(),W.limit_backward=e,W.cursor=W.limit,k(),W.cursor=W.limit,b(),W.cursor=W.limit,d(),W.cursor=W.limit_backward,o(),!0}};return function(e){return"function"==typeof e.update?e.update(function(e){return i.setCurrent(e),i.stem(),i.getCurrent()}):(i.setCurrent(e),i.stem(),i.getCurrent())}}(),e.Pipeline.registerFunction(e.fr.stemmer,"stemmer-fr"),e.fr.stopWordFilter=e.generateStopWordFilter("ai aie aient aies ait as au aura aurai auraient aurais aurait auras aurez auriez aurions aurons auront aux avaient avais avait avec avez aviez avions avons ayant ayez ayons c ce ceci celà ces cet cette d dans de des du elle en es est et eu eue eues eurent eus eusse eussent eusses eussiez eussions eut eux eûmes eût eûtes furent fus fusse fussent fusses fussiez fussions fut fûmes fût fûtes ici il ils j je l la le les leur leurs lui m ma mais me mes moi mon même n ne nos notre nous on ont ou par pas pour qu que quel quelle quelles quels qui s sa sans se sera serai seraient serais serait seras serez seriez serions serons seront ses soi soient sois soit sommes son sont soyez soyons suis sur t ta te tes toi ton tu un une vos votre vous y à étaient étais était étant étiez étions été étée étées étés êtes".split(" ")),e.Pipeline.registerFunction(e.fr.stopWordFilter,"stopWordFilter-fr")}}); \ No newline at end of file diff --git a/docs/assets/javascripts/lunr/min/lunr.hu.min.js b/docs/assets/javascripts/lunr/min/lunr.hu.min.js new file mode 100644 index 0000000..ed9d909 --- /dev/null +++ b/docs/assets/javascripts/lunr/min/lunr.hu.min.js @@ -0,0 +1,18 @@ +/*! + * Lunr languages, `Hungarian` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +!function(e,n){"function"==typeof define&&define.amd?define(n):"object"==typeof exports?module.exports=n():n()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.hu=function(){this.pipeline.reset(),this.pipeline.add(e.hu.trimmer,e.hu.stopWordFilter,e.hu.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.hu.stemmer))},e.hu.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.hu.trimmer=e.trimmerSupport.generateTrimmer(e.hu.wordCharacters),e.Pipeline.registerFunction(e.hu.trimmer,"trimmer-hu"),e.hu.stemmer=function(){var n=e.stemmerSupport.Among,r=e.stemmerSupport.SnowballProgram,i=new function(){function e(){var e,n=L.cursor;if(d=L.limit,L.in_grouping(W,97,252))for(;;){if(e=L.cursor,L.out_grouping(W,97,252))return L.cursor=e,L.find_among(g,8)||(L.cursor=e,e=L.limit)return void(d=e);L.cursor++}if(L.cursor=n,L.out_grouping(W,97,252)){for(;!L.in_grouping(W,97,252);){if(L.cursor>=L.limit)return;L.cursor++}d=L.cursor}}function i(){return d<=L.cursor}function a(){var e;if(L.ket=L.cursor,(e=L.find_among_b(h,2))&&(L.bra=L.cursor,i()))switch(e){case 1:L.slice_from("a");break;case 2:L.slice_from("e")}}function t(){var e=L.limit-L.cursor;return!!L.find_among_b(p,23)&&(L.cursor=L.limit-e,!0)}function s(){if(L.cursor>L.limit_backward){L.cursor--,L.ket=L.cursor;var e=L.cursor-1;L.limit_backward<=e&&e<=L.limit&&(L.cursor=e,L.bra=e,L.slice_del())}}function c(){var e;if(L.ket=L.cursor,(e=L.find_among_b(_,2))&&(L.bra=L.cursor,i())){if((1==e||2==e)&&!t())return;L.slice_del(),s()}}function o(){L.ket=L.cursor,L.find_among_b(v,44)&&(L.bra=L.cursor,i()&&(L.slice_del(),a()))}function w(){var e;if(L.ket=L.cursor,(e=L.find_among_b(z,3))&&(L.bra=L.cursor,i()))switch(e){case 1:L.slice_from("e");break;case 2:case 3:L.slice_from("a")}}function l(){var e;if(L.ket=L.cursor,(e=L.find_among_b(y,6))&&(L.bra=L.cursor,i()))switch(e){case 1:case 2:L.slice_del();break;case 3:L.slice_from("a");break;case 4:L.slice_from("e")}}function u(){var e;if(L.ket=L.cursor,(e=L.find_among_b(j,2))&&(L.bra=L.cursor,i())){if((1==e||2==e)&&!t())return;L.slice_del(),s()}}function m(){var e;if(L.ket=L.cursor,(e=L.find_among_b(C,7))&&(L.bra=L.cursor,i()))switch(e){case 1:L.slice_from("a");break;case 2:L.slice_from("e");break;case 3:case 4:case 5:case 6:case 7:L.slice_del()}}function k(){var e;if(L.ket=L.cursor,(e=L.find_among_b(P,12))&&(L.bra=L.cursor,i()))switch(e){case 1:case 4:case 7:case 9:L.slice_del();break;case 2:case 5:case 8:L.slice_from("e");break;case 3:case 6:L.slice_from("a")}}function f(){var e;if(L.ket=L.cursor,(e=L.find_among_b(F,31))&&(L.bra=L.cursor,i()))switch(e){case 1:case 4:case 7:case 8:case 9:case 12:case 13:case 16:case 17:case 18:L.slice_del();break;case 2:case 5:case 10:case 14:case 19:L.slice_from("a");break;case 3:case 6:case 11:case 15:case 20:L.slice_from("e")}}function b(){var e;if(L.ket=L.cursor,(e=L.find_among_b(S,42))&&(L.bra=L.cursor,i()))switch(e){case 1:case 4:case 5:case 6:case 9:case 10:case 11:case 14:case 15:case 16:case 17:case 20:case 21:case 24:case 25:case 26:case 29:L.slice_del();break;case 2:case 7:case 12:case 18:case 22:case 27:L.slice_from("a");break;case 3:case 8:case 13:case 19:case 23:case 28:L.slice_from("e")}}var d,g=[new n("cs",-1,-1),new n("dzs",-1,-1),new n("gy",-1,-1),new n("ly",-1,-1),new n("ny",-1,-1),new n("sz",-1,-1),new n("ty",-1,-1),new n("zs",-1,-1)],h=[new n("á",-1,1),new n("é",-1,2)],p=[new n("bb",-1,-1),new n("cc",-1,-1),new n("dd",-1,-1),new n("ff",-1,-1),new n("gg",-1,-1),new n("jj",-1,-1),new n("kk",-1,-1),new n("ll",-1,-1),new n("mm",-1,-1),new n("nn",-1,-1),new n("pp",-1,-1),new n("rr",-1,-1),new n("ccs",-1,-1),new n("ss",-1,-1),new n("zzs",-1,-1),new n("tt",-1,-1),new n("vv",-1,-1),new n("ggy",-1,-1),new n("lly",-1,-1),new n("nny",-1,-1),new n("tty",-1,-1),new n("ssz",-1,-1),new n("zz",-1,-1)],_=[new n("al",-1,1),new n("el",-1,2)],v=[new n("ba",-1,-1),new n("ra",-1,-1),new n("be",-1,-1),new n("re",-1,-1),new n("ig",-1,-1),new n("nak",-1,-1),new n("nek",-1,-1),new n("val",-1,-1),new n("vel",-1,-1),new n("ul",-1,-1),new n("nál",-1,-1),new n("nél",-1,-1),new n("ból",-1,-1),new n("ról",-1,-1),new n("tól",-1,-1),new n("bõl",-1,-1),new n("rõl",-1,-1),new n("tõl",-1,-1),new n("ül",-1,-1),new n("n",-1,-1),new n("an",19,-1),new n("ban",20,-1),new n("en",19,-1),new n("ben",22,-1),new n("képpen",22,-1),new n("on",19,-1),new n("ön",19,-1),new n("képp",-1,-1),new n("kor",-1,-1),new n("t",-1,-1),new n("at",29,-1),new n("et",29,-1),new n("ként",29,-1),new n("anként",32,-1),new n("enként",32,-1),new n("onként",32,-1),new n("ot",29,-1),new n("ért",29,-1),new n("öt",29,-1),new n("hez",-1,-1),new n("hoz",-1,-1),new n("höz",-1,-1),new n("vá",-1,-1),new n("vé",-1,-1)],z=[new n("án",-1,2),new n("én",-1,1),new n("ánként",-1,3)],y=[new n("stul",-1,2),new n("astul",0,1),new n("ástul",0,3),new n("stül",-1,2),new n("estül",3,1),new n("éstül",3,4)],j=[new n("á",-1,1),new n("é",-1,2)],C=[new n("k",-1,7),new n("ak",0,4),new n("ek",0,6),new n("ok",0,5),new n("ák",0,1),new n("ék",0,2),new n("ök",0,3)],P=[new n("éi",-1,7),new n("áéi",0,6),new n("ééi",0,5),new n("é",-1,9),new n("ké",3,4),new n("aké",4,1),new n("eké",4,1),new n("oké",4,1),new n("áké",4,3),new n("éké",4,2),new n("öké",4,1),new n("éé",3,8)],F=[new n("a",-1,18),new n("ja",0,17),new n("d",-1,16),new n("ad",2,13),new n("ed",2,13),new n("od",2,13),new n("ád",2,14),new n("éd",2,15),new n("öd",2,13),new n("e",-1,18),new n("je",9,17),new n("nk",-1,4),new n("unk",11,1),new n("ánk",11,2),new n("énk",11,3),new n("ünk",11,1),new n("uk",-1,8),new n("juk",16,7),new n("ájuk",17,5),new n("ük",-1,8),new n("jük",19,7),new n("éjük",20,6),new n("m",-1,12),new n("am",22,9),new n("em",22,9),new n("om",22,9),new n("ám",22,10),new n("ém",22,11),new n("o",-1,18),new n("á",-1,19),new n("é",-1,20)],S=[new n("id",-1,10),new n("aid",0,9),new n("jaid",1,6),new n("eid",0,9),new n("jeid",3,6),new n("áid",0,7),new n("éid",0,8),new n("i",-1,15),new n("ai",7,14),new n("jai",8,11),new n("ei",7,14),new n("jei",10,11),new n("ái",7,12),new n("éi",7,13),new n("itek",-1,24),new n("eitek",14,21),new n("jeitek",15,20),new n("éitek",14,23),new n("ik",-1,29),new n("aik",18,26),new n("jaik",19,25),new n("eik",18,26),new n("jeik",21,25),new n("áik",18,27),new n("éik",18,28),new n("ink",-1,20),new n("aink",25,17),new n("jaink",26,16),new n("eink",25,17),new n("jeink",28,16),new n("áink",25,18),new n("éink",25,19),new n("aitok",-1,21),new n("jaitok",32,20),new n("áitok",-1,22),new n("im",-1,5),new n("aim",35,4),new n("jaim",36,1),new n("eim",35,4),new n("jeim",38,1),new n("áim",35,2),new n("éim",35,3)],W=[17,65,16,0,0,0,0,0,0,0,0,0,0,0,0,0,1,17,52,14],L=new r;this.setCurrent=function(e){L.setCurrent(e)},this.getCurrent=function(){return L.getCurrent()},this.stem=function(){var n=L.cursor;return e(),L.limit_backward=n,L.cursor=L.limit,c(),L.cursor=L.limit,o(),L.cursor=L.limit,w(),L.cursor=L.limit,l(),L.cursor=L.limit,u(),L.cursor=L.limit,k(),L.cursor=L.limit,f(),L.cursor=L.limit,b(),L.cursor=L.limit,m(),!0}};return function(e){return"function"==typeof e.update?e.update(function(e){return i.setCurrent(e),i.stem(),i.getCurrent()}):(i.setCurrent(e),i.stem(),i.getCurrent())}}(),e.Pipeline.registerFunction(e.hu.stemmer,"stemmer-hu"),e.hu.stopWordFilter=e.generateStopWordFilter("a abban ahhoz ahogy ahol aki akik akkor alatt amely amelyek amelyekben amelyeket amelyet amelynek ami amikor amit amolyan amíg annak arra arról az azok azon azonban azt aztán azután azzal azért be belül benne bár cikk cikkek cikkeket csak de e ebben eddig egy egyes egyetlen egyik egyre egyéb egész ehhez ekkor el ellen elsõ elég elõ elõször elõtt emilyen ennek erre ez ezek ezen ezt ezzel ezért fel felé hanem hiszen hogy hogyan igen ill ill. illetve ilyen ilyenkor ismét ison itt jobban jó jól kell kellett keressünk keresztül ki kívül között közül legalább legyen lehet lehetett lenne lenni lesz lett maga magát majd majd meg mellett mely melyek mert mi mikor milyen minden mindenki mindent mindig mint mintha mit mivel miért most már más másik még míg nagy nagyobb nagyon ne nekem neki nem nincs néha néhány nélkül olyan ott pedig persze rá s saját sem semmi sok sokat sokkal szemben szerint szinte számára talán tehát teljes tovább továbbá több ugyanis utolsó után utána vagy vagyis vagyok valaki valami valamint való van vannak vele vissza viszont volna volt voltak voltam voltunk által általában át én éppen és így õ õk õket össze úgy új újabb újra".split(" ")),e.Pipeline.registerFunction(e.hu.stopWordFilter,"stopWordFilter-hu")}}); \ No newline at end of file diff --git a/docs/assets/javascripts/lunr/min/lunr.it.min.js b/docs/assets/javascripts/lunr/min/lunr.it.min.js new file mode 100644 index 0000000..344b6a3 --- /dev/null +++ b/docs/assets/javascripts/lunr/min/lunr.it.min.js @@ -0,0 +1,18 @@ +/*! + * Lunr languages, `Italian` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.it=function(){this.pipeline.reset(),this.pipeline.add(e.it.trimmer,e.it.stopWordFilter,e.it.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.it.stemmer))},e.it.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.it.trimmer=e.trimmerSupport.generateTrimmer(e.it.wordCharacters),e.Pipeline.registerFunction(e.it.trimmer,"trimmer-it"),e.it.stemmer=function(){var r=e.stemmerSupport.Among,n=e.stemmerSupport.SnowballProgram,i=new function(){function e(e,r,n){return!(!x.eq_s(1,e)||(x.ket=x.cursor,!x.in_grouping(L,97,249)))&&(x.slice_from(r),x.cursor=n,!0)}function i(){for(var r,n,i,o,t=x.cursor;;){if(x.bra=x.cursor,r=x.find_among(h,7))switch(x.ket=x.cursor,r){case 1:x.slice_from("à");continue;case 2:x.slice_from("è");continue;case 3:x.slice_from("ì");continue;case 4:x.slice_from("ò");continue;case 5:x.slice_from("ù");continue;case 6:x.slice_from("qU");continue;case 7:if(x.cursor>=x.limit)break;x.cursor++;continue}break}for(x.cursor=t;;)for(n=x.cursor;;){if(i=x.cursor,x.in_grouping(L,97,249)){if(x.bra=x.cursor,o=x.cursor,e("u","U",i))break;if(x.cursor=o,e("i","I",i))break}if(x.cursor=i,x.cursor>=x.limit)return void(x.cursor=n);x.cursor++}}function o(e){if(x.cursor=e,!x.in_grouping(L,97,249))return!1;for(;!x.out_grouping(L,97,249);){if(x.cursor>=x.limit)return!1;x.cursor++}return!0}function t(){if(x.in_grouping(L,97,249)){var e=x.cursor;if(x.out_grouping(L,97,249)){for(;!x.in_grouping(L,97,249);){if(x.cursor>=x.limit)return o(e);x.cursor++}return!0}return o(e)}return!1}function s(){var e,r=x.cursor;if(!t()){if(x.cursor=r,!x.out_grouping(L,97,249))return;if(e=x.cursor,x.out_grouping(L,97,249)){for(;!x.in_grouping(L,97,249);){if(x.cursor>=x.limit)return x.cursor=e,void(x.in_grouping(L,97,249)&&x.cursor=x.limit)return;x.cursor++}k=x.cursor}function a(){for(;!x.in_grouping(L,97,249);){if(x.cursor>=x.limit)return!1;x.cursor++}for(;!x.out_grouping(L,97,249);){if(x.cursor>=x.limit)return!1;x.cursor++}return!0}function u(){var e=x.cursor;k=x.limit,p=k,g=k,s(),x.cursor=e,a()&&(p=x.cursor,a()&&(g=x.cursor))}function c(){for(var e;;){if(x.bra=x.cursor,!(e=x.find_among(q,3)))break;switch(x.ket=x.cursor,e){case 1:x.slice_from("i");break;case 2:x.slice_from("u");break;case 3:if(x.cursor>=x.limit)return;x.cursor++}}}function w(){return k<=x.cursor}function l(){return p<=x.cursor}function m(){return g<=x.cursor}function f(){var e;if(x.ket=x.cursor,x.find_among_b(C,37)&&(x.bra=x.cursor,(e=x.find_among_b(z,5))&&w()))switch(e){case 1:x.slice_del();break;case 2:x.slice_from("e")}}function v(){var e;if(x.ket=x.cursor,!(e=x.find_among_b(S,51)))return!1;switch(x.bra=x.cursor,e){case 1:if(!m())return!1;x.slice_del();break;case 2:if(!m())return!1;x.slice_del(),x.ket=x.cursor,x.eq_s_b(2,"ic")&&(x.bra=x.cursor,m()&&x.slice_del());break;case 3:if(!m())return!1;x.slice_from("log");break;case 4:if(!m())return!1;x.slice_from("u");break;case 5:if(!m())return!1;x.slice_from("ente");break;case 6:if(!w())return!1;x.slice_del();break;case 7:if(!l())return!1;x.slice_del(),x.ket=x.cursor,e=x.find_among_b(P,4),e&&(x.bra=x.cursor,m()&&(x.slice_del(),1==e&&(x.ket=x.cursor,x.eq_s_b(2,"at")&&(x.bra=x.cursor,m()&&x.slice_del()))));break;case 8:if(!m())return!1;x.slice_del(),x.ket=x.cursor,e=x.find_among_b(F,3),e&&(x.bra=x.cursor,1==e&&m()&&x.slice_del());break;case 9:if(!m())return!1;x.slice_del(),x.ket=x.cursor,x.eq_s_b(2,"at")&&(x.bra=x.cursor,m()&&(x.slice_del(),x.ket=x.cursor,x.eq_s_b(2,"ic")&&(x.bra=x.cursor,m()&&x.slice_del())))}return!0}function b(){var e,r;x.cursor>=k&&(r=x.limit_backward,x.limit_backward=k,x.ket=x.cursor,e=x.find_among_b(W,87),e&&(x.bra=x.cursor,1==e&&x.slice_del()),x.limit_backward=r)}function d(){var e=x.limit-x.cursor;if(x.ket=x.cursor,x.in_grouping_b(y,97,242)&&(x.bra=x.cursor,w()&&(x.slice_del(),x.ket=x.cursor,x.eq_s_b(1,"i")&&(x.bra=x.cursor,w()))))return void x.slice_del();x.cursor=x.limit-e}function _(){d(),x.ket=x.cursor,x.eq_s_b(1,"h")&&(x.bra=x.cursor,x.in_grouping_b(U,99,103)&&w()&&x.slice_del())}var g,p,k,h=[new r("",-1,7),new r("qu",0,6),new r("á",0,1),new r("é",0,2),new r("í",0,3),new r("ó",0,4),new r("ú",0,5)],q=[new r("",-1,3),new r("I",0,1),new r("U",0,2)],C=[new r("la",-1,-1),new r("cela",0,-1),new r("gliela",0,-1),new r("mela",0,-1),new r("tela",0,-1),new r("vela",0,-1),new r("le",-1,-1),new r("cele",6,-1),new r("gliele",6,-1),new r("mele",6,-1),new r("tele",6,-1),new r("vele",6,-1),new r("ne",-1,-1),new r("cene",12,-1),new r("gliene",12,-1),new r("mene",12,-1),new r("sene",12,-1),new r("tene",12,-1),new r("vene",12,-1),new r("ci",-1,-1),new r("li",-1,-1),new r("celi",20,-1),new r("glieli",20,-1),new r("meli",20,-1),new r("teli",20,-1),new r("veli",20,-1),new r("gli",20,-1),new r("mi",-1,-1),new r("si",-1,-1),new r("ti",-1,-1),new r("vi",-1,-1),new r("lo",-1,-1),new r("celo",31,-1),new r("glielo",31,-1),new r("melo",31,-1),new r("telo",31,-1),new r("velo",31,-1)],z=[new r("ando",-1,1),new r("endo",-1,1),new r("ar",-1,2),new r("er",-1,2),new r("ir",-1,2)],P=[new r("ic",-1,-1),new r("abil",-1,-1),new r("os",-1,-1),new r("iv",-1,1)],F=[new r("ic",-1,1),new r("abil",-1,1),new r("iv",-1,1)],S=[new r("ica",-1,1),new r("logia",-1,3),new r("osa",-1,1),new r("ista",-1,1),new r("iva",-1,9),new r("anza",-1,1),new r("enza",-1,5),new r("ice",-1,1),new r("atrice",7,1),new r("iche",-1,1),new r("logie",-1,3),new r("abile",-1,1),new r("ibile",-1,1),new r("usione",-1,4),new r("azione",-1,2),new r("uzione",-1,4),new r("atore",-1,2),new r("ose",-1,1),new r("ante",-1,1),new r("mente",-1,1),new r("amente",19,7),new r("iste",-1,1),new r("ive",-1,9),new r("anze",-1,1),new r("enze",-1,5),new r("ici",-1,1),new r("atrici",25,1),new r("ichi",-1,1),new r("abili",-1,1),new r("ibili",-1,1),new r("ismi",-1,1),new r("usioni",-1,4),new r("azioni",-1,2),new r("uzioni",-1,4),new r("atori",-1,2),new r("osi",-1,1),new r("anti",-1,1),new r("amenti",-1,6),new r("imenti",-1,6),new r("isti",-1,1),new r("ivi",-1,9),new r("ico",-1,1),new r("ismo",-1,1),new r("oso",-1,1),new r("amento",-1,6),new r("imento",-1,6),new r("ivo",-1,9),new r("ità",-1,8),new r("istà",-1,1),new r("istè",-1,1),new r("istì",-1,1)],W=[new r("isca",-1,1),new r("enda",-1,1),new r("ata",-1,1),new r("ita",-1,1),new r("uta",-1,1),new r("ava",-1,1),new r("eva",-1,1),new r("iva",-1,1),new r("erebbe",-1,1),new r("irebbe",-1,1),new r("isce",-1,1),new r("ende",-1,1),new r("are",-1,1),new r("ere",-1,1),new r("ire",-1,1),new r("asse",-1,1),new r("ate",-1,1),new r("avate",16,1),new r("evate",16,1),new r("ivate",16,1),new r("ete",-1,1),new r("erete",20,1),new r("irete",20,1),new r("ite",-1,1),new r("ereste",-1,1),new r("ireste",-1,1),new r("ute",-1,1),new r("erai",-1,1),new r("irai",-1,1),new r("isci",-1,1),new r("endi",-1,1),new r("erei",-1,1),new r("irei",-1,1),new r("assi",-1,1),new r("ati",-1,1),new r("iti",-1,1),new r("eresti",-1,1),new r("iresti",-1,1),new r("uti",-1,1),new r("avi",-1,1),new r("evi",-1,1),new r("ivi",-1,1),new r("isco",-1,1),new r("ando",-1,1),new r("endo",-1,1),new r("Yamo",-1,1),new r("iamo",-1,1),new r("avamo",-1,1),new r("evamo",-1,1),new r("ivamo",-1,1),new r("eremo",-1,1),new r("iremo",-1,1),new r("assimo",-1,1),new r("ammo",-1,1),new r("emmo",-1,1),new r("eremmo",54,1),new r("iremmo",54,1),new r("immo",-1,1),new r("ano",-1,1),new r("iscano",58,1),new r("avano",58,1),new r("evano",58,1),new r("ivano",58,1),new r("eranno",-1,1),new r("iranno",-1,1),new r("ono",-1,1),new r("iscono",65,1),new r("arono",65,1),new r("erono",65,1),new r("irono",65,1),new r("erebbero",-1,1),new r("irebbero",-1,1),new r("assero",-1,1),new r("essero",-1,1),new r("issero",-1,1),new r("ato",-1,1),new r("ito",-1,1),new r("uto",-1,1),new r("avo",-1,1),new r("evo",-1,1),new r("ivo",-1,1),new r("ar",-1,1),new r("ir",-1,1),new r("erà",-1,1),new r("irà",-1,1),new r("erò",-1,1),new r("irò",-1,1)],L=[17,65,16,0,0,0,0,0,0,0,0,0,0,0,0,128,128,8,2,1],y=[17,65,0,0,0,0,0,0,0,0,0,0,0,0,0,128,128,8,2],U=[17],x=new n;this.setCurrent=function(e){x.setCurrent(e)},this.getCurrent=function(){return x.getCurrent()},this.stem=function(){var e=x.cursor;return i(),x.cursor=e,u(),x.limit_backward=e,x.cursor=x.limit,f(),x.cursor=x.limit,v()||(x.cursor=x.limit,b()),x.cursor=x.limit,_(),x.cursor=x.limit_backward,c(),!0}};return function(e){return"function"==typeof e.update?e.update(function(e){return i.setCurrent(e),i.stem(),i.getCurrent()}):(i.setCurrent(e),i.stem(),i.getCurrent())}}(),e.Pipeline.registerFunction(e.it.stemmer,"stemmer-it"),e.it.stopWordFilter=e.generateStopWordFilter("a abbia abbiamo abbiano abbiate ad agl agli ai al all alla alle allo anche avemmo avendo avesse avessero avessi avessimo aveste avesti avete aveva avevamo avevano avevate avevi avevo avrai avranno avrebbe avrebbero avrei avremmo avremo avreste avresti avrete avrà avrò avuta avute avuti avuto c che chi ci coi col come con contro cui da dagl dagli dai dal dall dalla dalle dallo degl degli dei del dell della delle dello di dov dove e ebbe ebbero ebbi ed era erano eravamo eravate eri ero essendo faccia facciamo facciano facciate faccio facemmo facendo facesse facessero facessi facessimo faceste facesti faceva facevamo facevano facevate facevi facevo fai fanno farai faranno farebbe farebbero farei faremmo faremo fareste faresti farete farà farò fece fecero feci fosse fossero fossi fossimo foste fosti fu fui fummo furono gli ha hai hanno ho i il in io l la le lei li lo loro lui ma mi mia mie miei mio ne negl negli nei nel nell nella nelle nello noi non nostra nostre nostri nostro o per perché più quale quanta quante quanti quanto quella quelle quelli quello questa queste questi questo sarai saranno sarebbe sarebbero sarei saremmo saremo sareste saresti sarete sarà sarò se sei si sia siamo siano siate siete sono sta stai stando stanno starai staranno starebbe starebbero starei staremmo staremo stareste staresti starete starà starò stava stavamo stavano stavate stavi stavo stemmo stesse stessero stessi stessimo steste stesti stette stettero stetti stia stiamo stiano stiate sto su sua sue sugl sugli sui sul sull sulla sulle sullo suo suoi ti tra tu tua tue tuo tuoi tutti tutto un una uno vi voi vostra vostre vostri vostro è".split(" ")),e.Pipeline.registerFunction(e.it.stopWordFilter,"stopWordFilter-it")}}); \ No newline at end of file diff --git a/docs/assets/javascripts/lunr/min/lunr.ja.min.js b/docs/assets/javascripts/lunr/min/lunr.ja.min.js new file mode 100644 index 0000000..5f254eb --- /dev/null +++ b/docs/assets/javascripts/lunr/min/lunr.ja.min.js @@ -0,0 +1 @@ +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var r="2"==e.version[0];e.ja=function(){this.pipeline.reset(),this.pipeline.add(e.ja.trimmer,e.ja.stopWordFilter,e.ja.stemmer),r?this.tokenizer=e.ja.tokenizer:(e.tokenizer&&(e.tokenizer=e.ja.tokenizer),this.tokenizerFn&&(this.tokenizerFn=e.ja.tokenizer))};var t=new e.TinySegmenter;e.ja.tokenizer=function(i){var n,o,s,p,a,u,m,l,c,f;if(!arguments.length||null==i||void 0==i)return[];if(Array.isArray(i))return i.map(function(t){return r?new e.Token(t.toLowerCase()):t.toLowerCase()});for(o=i.toString().toLowerCase().replace(/^\s+/,""),n=o.length-1;n>=0;n--)if(/\S/.test(o.charAt(n))){o=o.substring(0,n+1);break}for(a=[],s=o.length,c=0,l=0;c<=s;c++)if(u=o.charAt(c),m=c-l,u.match(/\s/)||c==s){if(m>0)for(p=t.segment(o.slice(l,c)).filter(function(e){return!!e}),f=l,n=0;n=C.limit)break;C.cursor++;continue}break}for(C.cursor=o,C.bra=o,C.eq_s(1,"y")?(C.ket=C.cursor,C.slice_from("Y")):C.cursor=o;;)if(e=C.cursor,C.in_grouping(q,97,232)){if(i=C.cursor,C.bra=i,C.eq_s(1,"i"))C.ket=C.cursor,C.in_grouping(q,97,232)&&(C.slice_from("I"),C.cursor=e);else if(C.cursor=i,C.eq_s(1,"y"))C.ket=C.cursor,C.slice_from("Y"),C.cursor=e;else if(n(e))break}else if(n(e))break}function n(r){return C.cursor=r,r>=C.limit||(C.cursor++,!1)}function o(){_=C.limit,d=_,t()||(_=C.cursor,_<3&&(_=3),t()||(d=C.cursor))}function t(){for(;!C.in_grouping(q,97,232);){if(C.cursor>=C.limit)return!0;C.cursor++}for(;!C.out_grouping(q,97,232);){if(C.cursor>=C.limit)return!0;C.cursor++}return!1}function s(){for(var r;;)if(C.bra=C.cursor,r=C.find_among(p,3))switch(C.ket=C.cursor,r){case 1:C.slice_from("y");break;case 2:C.slice_from("i");break;case 3:if(C.cursor>=C.limit)return;C.cursor++}}function u(){return _<=C.cursor}function c(){return d<=C.cursor}function a(){var r=C.limit-C.cursor;C.find_among_b(g,3)&&(C.cursor=C.limit-r,C.ket=C.cursor,C.cursor>C.limit_backward&&(C.cursor--,C.bra=C.cursor,C.slice_del()))}function l(){var r;w=!1,C.ket=C.cursor,C.eq_s_b(1,"e")&&(C.bra=C.cursor,u()&&(r=C.limit-C.cursor,C.out_grouping_b(q,97,232)&&(C.cursor=C.limit-r,C.slice_del(),w=!0,a())))}function m(){var r;u()&&(r=C.limit-C.cursor,C.out_grouping_b(q,97,232)&&(C.cursor=C.limit-r,C.eq_s_b(3,"gem")||(C.cursor=C.limit-r,C.slice_del(),a())))}function f(){var r,e,i,n,o,t,s=C.limit-C.cursor;if(C.ket=C.cursor,r=C.find_among_b(h,5))switch(C.bra=C.cursor,r){case 1:u()&&C.slice_from("heid");break;case 2:m();break;case 3:u()&&C.out_grouping_b(j,97,232)&&C.slice_del()}if(C.cursor=C.limit-s,l(),C.cursor=C.limit-s,C.ket=C.cursor,C.eq_s_b(4,"heid")&&(C.bra=C.cursor,c()&&(e=C.limit-C.cursor,C.eq_s_b(1,"c")||(C.cursor=C.limit-e,C.slice_del(),C.ket=C.cursor,C.eq_s_b(2,"en")&&(C.bra=C.cursor,m())))),C.cursor=C.limit-s,C.ket=C.cursor,r=C.find_among_b(k,6))switch(C.bra=C.cursor,r){case 1:if(c()){if(C.slice_del(),i=C.limit-C.cursor,C.ket=C.cursor,C.eq_s_b(2,"ig")&&(C.bra=C.cursor,c()&&(n=C.limit-C.cursor,!C.eq_s_b(1,"e")))){C.cursor=C.limit-n,C.slice_del();break}C.cursor=C.limit-i,a()}break;case 2:c()&&(o=C.limit-C.cursor,C.eq_s_b(1,"e")||(C.cursor=C.limit-o,C.slice_del()));break;case 3:c()&&(C.slice_del(),l());break;case 4:c()&&C.slice_del();break;case 5:c()&&w&&C.slice_del()}C.cursor=C.limit-s,C.out_grouping_b(z,73,232)&&(t=C.limit-C.cursor,C.find_among_b(v,4)&&C.out_grouping_b(q,97,232)&&(C.cursor=C.limit-t,C.ket=C.cursor,C.cursor>C.limit_backward&&(C.cursor--,C.bra=C.cursor,C.slice_del())))}var d,_,w,b=[new e("",-1,6),new e("á",0,1),new e("ä",0,1),new e("é",0,2),new e("ë",0,2),new e("í",0,3),new e("ï",0,3),new e("ó",0,4),new e("ö",0,4),new e("ú",0,5),new e("ü",0,5)],p=[new e("",-1,3),new e("I",0,2),new e("Y",0,1)],g=[new e("dd",-1,-1),new e("kk",-1,-1),new e("tt",-1,-1)],h=[new e("ene",-1,2),new e("se",-1,3),new e("en",-1,2),new e("heden",2,1),new e("s",-1,3)],k=[new e("end",-1,1),new e("ig",-1,2),new e("ing",-1,1),new e("lijk",-1,3),new e("baar",-1,4),new e("bar",-1,5)],v=[new e("aa",-1,-1),new e("ee",-1,-1),new e("oo",-1,-1),new e("uu",-1,-1)],q=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,128],z=[1,0,0,17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,128],j=[17,67,16,1,0,0,0,0,0,0,0,0,0,0,0,0,128],C=new i;this.setCurrent=function(r){C.setCurrent(r)},this.getCurrent=function(){return C.getCurrent()},this.stem=function(){var e=C.cursor;return r(),C.cursor=e,o(),C.limit_backward=e,C.cursor=C.limit,f(),C.cursor=C.limit_backward,s(),!0}};return function(r){return"function"==typeof r.update?r.update(function(r){return n.setCurrent(r),n.stem(),n.getCurrent()}):(n.setCurrent(r),n.stem(),n.getCurrent())}}(),r.Pipeline.registerFunction(r.nl.stemmer,"stemmer-nl"),r.nl.stopWordFilter=r.generateStopWordFilter(" aan al alles als altijd andere ben bij daar dan dat de der deze die dit doch doen door dus een eens en er ge geen geweest haar had heb hebben heeft hem het hier hij hoe hun iemand iets ik in is ja je kan kon kunnen maar me meer men met mij mijn moet na naar niet niets nog nu of om omdat onder ons ook op over reeds te tegen toch toen tot u uit uw van veel voor want waren was wat werd wezen wie wil worden wordt zal ze zelf zich zij zijn zo zonder zou".split(" ")),r.Pipeline.registerFunction(r.nl.stopWordFilter,"stopWordFilter-nl")}}); \ No newline at end of file diff --git a/docs/assets/javascripts/lunr/min/lunr.no.min.js b/docs/assets/javascripts/lunr/min/lunr.no.min.js new file mode 100644 index 0000000..92bc7e4 --- /dev/null +++ b/docs/assets/javascripts/lunr/min/lunr.no.min.js @@ -0,0 +1,18 @@ +/*! + * Lunr languages, `Norwegian` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.no=function(){this.pipeline.reset(),this.pipeline.add(e.no.trimmer,e.no.stopWordFilter,e.no.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.no.stemmer))},e.no.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.no.trimmer=e.trimmerSupport.generateTrimmer(e.no.wordCharacters),e.Pipeline.registerFunction(e.no.trimmer,"trimmer-no"),e.no.stemmer=function(){var r=e.stemmerSupport.Among,n=e.stemmerSupport.SnowballProgram,i=new function(){function e(){var e,r=w.cursor+3;if(a=w.limit,0<=r||r<=w.limit){for(s=r;;){if(e=w.cursor,w.in_grouping(d,97,248)){w.cursor=e;break}if(e>=w.limit)return;w.cursor=e+1}for(;!w.out_grouping(d,97,248);){if(w.cursor>=w.limit)return;w.cursor++}a=w.cursor,a=a&&(r=w.limit_backward,w.limit_backward=a,w.ket=w.cursor,e=w.find_among_b(m,29),w.limit_backward=r,e))switch(w.bra=w.cursor,e){case 1:w.slice_del();break;case 2:n=w.limit-w.cursor,w.in_grouping_b(c,98,122)?w.slice_del():(w.cursor=w.limit-n,w.eq_s_b(1,"k")&&w.out_grouping_b(d,97,248)&&w.slice_del());break;case 3:w.slice_from("er")}}function t(){var e,r=w.limit-w.cursor;w.cursor>=a&&(e=w.limit_backward,w.limit_backward=a,w.ket=w.cursor,w.find_among_b(u,2)?(w.bra=w.cursor,w.limit_backward=e,w.cursor=w.limit-r,w.cursor>w.limit_backward&&(w.cursor--,w.bra=w.cursor,w.slice_del())):w.limit_backward=e)}function o(){var e,r;w.cursor>=a&&(r=w.limit_backward,w.limit_backward=a,w.ket=w.cursor,e=w.find_among_b(l,11),e?(w.bra=w.cursor,w.limit_backward=r,1==e&&w.slice_del()):w.limit_backward=r)}var s,a,m=[new r("a",-1,1),new r("e",-1,1),new r("ede",1,1),new r("ande",1,1),new r("ende",1,1),new r("ane",1,1),new r("ene",1,1),new r("hetene",6,1),new r("erte",1,3),new r("en",-1,1),new r("heten",9,1),new r("ar",-1,1),new r("er",-1,1),new r("heter",12,1),new r("s",-1,2),new r("as",14,1),new r("es",14,1),new r("edes",16,1),new r("endes",16,1),new r("enes",16,1),new r("hetenes",19,1),new r("ens",14,1),new r("hetens",21,1),new r("ers",14,1),new r("ets",14,1),new r("et",-1,1),new r("het",25,1),new r("ert",-1,3),new r("ast",-1,1)],u=[new r("dt",-1,-1),new r("vt",-1,-1)],l=[new r("leg",-1,1),new r("eleg",0,1),new r("ig",-1,1),new r("eig",2,1),new r("lig",2,1),new r("elig",4,1),new r("els",-1,1),new r("lov",-1,1),new r("elov",7,1),new r("slov",7,1),new r("hetslov",9,1)],d=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,48,0,128],c=[119,125,149,1],w=new n;this.setCurrent=function(e){w.setCurrent(e)},this.getCurrent=function(){return w.getCurrent()},this.stem=function(){var r=w.cursor;return e(),w.limit_backward=r,w.cursor=w.limit,i(),w.cursor=w.limit,t(),w.cursor=w.limit,o(),!0}};return function(e){return"function"==typeof e.update?e.update(function(e){return i.setCurrent(e),i.stem(),i.getCurrent()}):(i.setCurrent(e),i.stem(),i.getCurrent())}}(),e.Pipeline.registerFunction(e.no.stemmer,"stemmer-no"),e.no.stopWordFilter=e.generateStopWordFilter("alle at av bare begge ble blei bli blir blitt både båe da de deg dei deim deira deires dem den denne der dere deres det dette di din disse ditt du dykk dykkar då eg ein eit eitt eller elles en enn er et ett etter for fordi fra før ha hadde han hans har hennar henne hennes her hjå ho hoe honom hoss hossen hun hva hvem hver hvilke hvilken hvis hvor hvordan hvorfor i ikke ikkje ikkje ingen ingi inkje inn inni ja jeg kan kom korleis korso kun kunne kva kvar kvarhelst kven kvi kvifor man mange me med medan meg meget mellom men mi min mine mitt mot mykje ned no noe noen noka noko nokon nokor nokre nå når og også om opp oss over på samme seg selv si si sia sidan siden sin sine sitt sjøl skal skulle slik so som som somme somt så sånn til um upp ut uten var vart varte ved vere verte vi vil ville vore vors vort vår være være vært å".split(" ")),e.Pipeline.registerFunction(e.no.stopWordFilter,"stopWordFilter-no")}}); \ No newline at end of file diff --git a/docs/assets/javascripts/lunr/min/lunr.pt.min.js b/docs/assets/javascripts/lunr/min/lunr.pt.min.js new file mode 100644 index 0000000..6c16996 --- /dev/null +++ b/docs/assets/javascripts/lunr/min/lunr.pt.min.js @@ -0,0 +1,18 @@ +/*! + * Lunr languages, `Portuguese` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.pt=function(){this.pipeline.reset(),this.pipeline.add(e.pt.trimmer,e.pt.stopWordFilter,e.pt.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.pt.stemmer))},e.pt.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.pt.trimmer=e.trimmerSupport.generateTrimmer(e.pt.wordCharacters),e.Pipeline.registerFunction(e.pt.trimmer,"trimmer-pt"),e.pt.stemmer=function(){var r=e.stemmerSupport.Among,s=e.stemmerSupport.SnowballProgram,n=new function(){function e(){for(var e;;){if(z.bra=z.cursor,e=z.find_among(k,3))switch(z.ket=z.cursor,e){case 1:z.slice_from("a~");continue;case 2:z.slice_from("o~");continue;case 3:if(z.cursor>=z.limit)break;z.cursor++;continue}break}}function n(){if(z.out_grouping(y,97,250)){for(;!z.in_grouping(y,97,250);){if(z.cursor>=z.limit)return!0;z.cursor++}return!1}return!0}function i(){if(z.in_grouping(y,97,250))for(;!z.out_grouping(y,97,250);){if(z.cursor>=z.limit)return!1;z.cursor++}return g=z.cursor,!0}function o(){var e,r,s=z.cursor;if(z.in_grouping(y,97,250))if(e=z.cursor,n()){if(z.cursor=e,i())return}else g=z.cursor;if(z.cursor=s,z.out_grouping(y,97,250)){if(r=z.cursor,n()){if(z.cursor=r,!z.in_grouping(y,97,250)||z.cursor>=z.limit)return;z.cursor++}g=z.cursor}}function t(){for(;!z.in_grouping(y,97,250);){if(z.cursor>=z.limit)return!1;z.cursor++}for(;!z.out_grouping(y,97,250);){if(z.cursor>=z.limit)return!1;z.cursor++}return!0}function a(){var e=z.cursor;g=z.limit,b=g,h=g,o(),z.cursor=e,t()&&(b=z.cursor,t()&&(h=z.cursor))}function u(){for(var e;;){if(z.bra=z.cursor,e=z.find_among(q,3))switch(z.ket=z.cursor,e){case 1:z.slice_from("ã");continue;case 2:z.slice_from("õ");continue;case 3:if(z.cursor>=z.limit)break;z.cursor++;continue}break}}function w(){return g<=z.cursor}function m(){return b<=z.cursor}function c(){return h<=z.cursor}function l(){var e;if(z.ket=z.cursor,!(e=z.find_among_b(F,45)))return!1;switch(z.bra=z.cursor,e){case 1:if(!c())return!1;z.slice_del();break;case 2:if(!c())return!1;z.slice_from("log");break;case 3:if(!c())return!1;z.slice_from("u");break;case 4:if(!c())return!1;z.slice_from("ente");break;case 5:if(!m())return!1;z.slice_del(),z.ket=z.cursor,e=z.find_among_b(j,4),e&&(z.bra=z.cursor,c()&&(z.slice_del(),1==e&&(z.ket=z.cursor,z.eq_s_b(2,"at")&&(z.bra=z.cursor,c()&&z.slice_del()))));break;case 6:if(!c())return!1;z.slice_del(),z.ket=z.cursor,e=z.find_among_b(C,3),e&&(z.bra=z.cursor,1==e&&c()&&z.slice_del());break;case 7:if(!c())return!1;z.slice_del(),z.ket=z.cursor,e=z.find_among_b(P,3),e&&(z.bra=z.cursor,1==e&&c()&&z.slice_del());break;case 8:if(!c())return!1;z.slice_del(),z.ket=z.cursor,z.eq_s_b(2,"at")&&(z.bra=z.cursor,c()&&z.slice_del());break;case 9:if(!w()||!z.eq_s_b(1,"e"))return!1;z.slice_from("ir")}return!0}function f(){var e,r;if(z.cursor>=g){if(r=z.limit_backward,z.limit_backward=g,z.ket=z.cursor,e=z.find_among_b(S,120))return z.bra=z.cursor,1==e&&z.slice_del(),z.limit_backward=r,!0;z.limit_backward=r}return!1}function d(){var e;z.ket=z.cursor,(e=z.find_among_b(W,7))&&(z.bra=z.cursor,1==e&&w()&&z.slice_del())}function v(e,r){if(z.eq_s_b(1,e)){z.bra=z.cursor;var s=z.limit-z.cursor;if(z.eq_s_b(1,r))return z.cursor=z.limit-s,w()&&z.slice_del(),!1}return!0}function p(){var e;if(z.ket=z.cursor,e=z.find_among_b(L,4))switch(z.bra=z.cursor,e){case 1:w()&&(z.slice_del(),z.ket=z.cursor,z.limit-z.cursor,v("u","g")&&v("i","c"));break;case 2:z.slice_from("c")}}function _(){if(!l()&&(z.cursor=z.limit,!f()))return z.cursor=z.limit,void d();z.cursor=z.limit,z.ket=z.cursor,z.eq_s_b(1,"i")&&(z.bra=z.cursor,z.eq_s_b(1,"c")&&(z.cursor=z.limit,w()&&z.slice_del()))}var h,b,g,k=[new r("",-1,3),new r("ã",0,1),new r("õ",0,2)],q=[new r("",-1,3),new r("a~",0,1),new r("o~",0,2)],j=[new r("ic",-1,-1),new r("ad",-1,-1),new r("os",-1,-1),new r("iv",-1,1)],C=[new r("ante",-1,1),new r("avel",-1,1),new r("ível",-1,1)],P=[new r("ic",-1,1),new r("abil",-1,1),new r("iv",-1,1)],F=[new r("ica",-1,1),new r("ância",-1,1),new r("ência",-1,4),new r("ira",-1,9),new r("adora",-1,1),new r("osa",-1,1),new r("ista",-1,1),new r("iva",-1,8),new r("eza",-1,1),new r("logía",-1,2),new r("idade",-1,7),new r("ante",-1,1),new r("mente",-1,6),new r("amente",12,5),new r("ável",-1,1),new r("ível",-1,1),new r("ución",-1,3),new r("ico",-1,1),new r("ismo",-1,1),new r("oso",-1,1),new r("amento",-1,1),new r("imento",-1,1),new r("ivo",-1,8),new r("aça~o",-1,1),new r("ador",-1,1),new r("icas",-1,1),new r("ências",-1,4),new r("iras",-1,9),new r("adoras",-1,1),new r("osas",-1,1),new r("istas",-1,1),new r("ivas",-1,8),new r("ezas",-1,1),new r("logías",-1,2),new r("idades",-1,7),new r("uciones",-1,3),new r("adores",-1,1),new r("antes",-1,1),new r("aço~es",-1,1),new r("icos",-1,1),new r("ismos",-1,1),new r("osos",-1,1),new r("amentos",-1,1),new r("imentos",-1,1),new r("ivos",-1,8)],S=[new r("ada",-1,1),new r("ida",-1,1),new r("ia",-1,1),new r("aria",2,1),new r("eria",2,1),new r("iria",2,1),new r("ara",-1,1),new r("era",-1,1),new r("ira",-1,1),new r("ava",-1,1),new r("asse",-1,1),new r("esse",-1,1),new r("isse",-1,1),new r("aste",-1,1),new r("este",-1,1),new r("iste",-1,1),new r("ei",-1,1),new r("arei",16,1),new r("erei",16,1),new r("irei",16,1),new r("am",-1,1),new r("iam",20,1),new r("ariam",21,1),new r("eriam",21,1),new r("iriam",21,1),new r("aram",20,1),new r("eram",20,1),new r("iram",20,1),new r("avam",20,1),new r("em",-1,1),new r("arem",29,1),new r("erem",29,1),new r("irem",29,1),new r("assem",29,1),new r("essem",29,1),new r("issem",29,1),new r("ado",-1,1),new r("ido",-1,1),new r("ando",-1,1),new r("endo",-1,1),new r("indo",-1,1),new r("ara~o",-1,1),new r("era~o",-1,1),new r("ira~o",-1,1),new r("ar",-1,1),new r("er",-1,1),new r("ir",-1,1),new r("as",-1,1),new r("adas",47,1),new r("idas",47,1),new r("ias",47,1),new r("arias",50,1),new r("erias",50,1),new r("irias",50,1),new r("aras",47,1),new r("eras",47,1),new r("iras",47,1),new r("avas",47,1),new r("es",-1,1),new r("ardes",58,1),new r("erdes",58,1),new r("irdes",58,1),new r("ares",58,1),new r("eres",58,1),new r("ires",58,1),new r("asses",58,1),new r("esses",58,1),new r("isses",58,1),new r("astes",58,1),new r("estes",58,1),new r("istes",58,1),new r("is",-1,1),new r("ais",71,1),new r("eis",71,1),new r("areis",73,1),new r("ereis",73,1),new r("ireis",73,1),new r("áreis",73,1),new r("éreis",73,1),new r("íreis",73,1),new r("ásseis",73,1),new r("ésseis",73,1),new r("ísseis",73,1),new r("áveis",73,1),new r("íeis",73,1),new r("aríeis",84,1),new r("eríeis",84,1),new r("iríeis",84,1),new r("ados",-1,1),new r("idos",-1,1),new r("amos",-1,1),new r("áramos",90,1),new r("éramos",90,1),new r("íramos",90,1),new r("ávamos",90,1),new r("íamos",90,1),new r("aríamos",95,1),new r("eríamos",95,1),new r("iríamos",95,1),new r("emos",-1,1),new r("aremos",99,1),new r("eremos",99,1),new r("iremos",99,1),new r("ássemos",99,1),new r("êssemos",99,1),new r("íssemos",99,1),new r("imos",-1,1),new r("armos",-1,1),new r("ermos",-1,1),new r("irmos",-1,1),new r("ámos",-1,1),new r("arás",-1,1),new r("erás",-1,1),new r("irás",-1,1),new r("eu",-1,1),new r("iu",-1,1),new r("ou",-1,1),new r("ará",-1,1),new r("erá",-1,1),new r("irá",-1,1)],W=[new r("a",-1,1),new r("i",-1,1),new r("o",-1,1),new r("os",-1,1),new r("á",-1,1),new r("í",-1,1),new r("ó",-1,1)],L=[new r("e",-1,1),new r("ç",-1,2),new r("é",-1,1),new r("ê",-1,1)],y=[17,65,16,0,0,0,0,0,0,0,0,0,0,0,0,0,3,19,12,2],z=new s;this.setCurrent=function(e){z.setCurrent(e)},this.getCurrent=function(){return z.getCurrent()},this.stem=function(){var r=z.cursor;return e(),z.cursor=r,a(),z.limit_backward=r,z.cursor=z.limit,_(),z.cursor=z.limit,p(),z.cursor=z.limit_backward,u(),!0}};return function(e){return"function"==typeof e.update?e.update(function(e){return n.setCurrent(e),n.stem(),n.getCurrent()}):(n.setCurrent(e),n.stem(),n.getCurrent())}}(),e.Pipeline.registerFunction(e.pt.stemmer,"stemmer-pt"),e.pt.stopWordFilter=e.generateStopWordFilter("a ao aos aquela aquelas aquele aqueles aquilo as até com como da das de dela delas dele deles depois do dos e ela elas ele eles em entre era eram essa essas esse esses esta estamos estas estava estavam este esteja estejam estejamos estes esteve estive estivemos estiver estivera estiveram estiverem estivermos estivesse estivessem estivéramos estivéssemos estou está estávamos estão eu foi fomos for fora foram forem formos fosse fossem fui fôramos fôssemos haja hajam hajamos havemos hei houve houvemos houver houvera houveram houverei houverem houveremos houveria houveriam houvermos houverá houverão houveríamos houvesse houvessem houvéramos houvéssemos há hão isso isto já lhe lhes mais mas me mesmo meu meus minha minhas muito na nas nem no nos nossa nossas nosso nossos num numa não nós o os ou para pela pelas pelo pelos por qual quando que quem se seja sejam sejamos sem serei seremos seria seriam será serão seríamos seu seus somos sou sua suas são só também te tem temos tenha tenham tenhamos tenho terei teremos teria teriam terá terão teríamos teu teus teve tinha tinham tive tivemos tiver tivera tiveram tiverem tivermos tivesse tivessem tivéramos tivéssemos tu tua tuas tém tínhamos um uma você vocês vos à às éramos".split(" ")),e.Pipeline.registerFunction(e.pt.stopWordFilter,"stopWordFilter-pt")}}); \ No newline at end of file diff --git a/docs/assets/javascripts/lunr/min/lunr.ro.min.js b/docs/assets/javascripts/lunr/min/lunr.ro.min.js new file mode 100644 index 0000000..7277140 --- /dev/null +++ b/docs/assets/javascripts/lunr/min/lunr.ro.min.js @@ -0,0 +1,18 @@ +/*! + * Lunr languages, `Romanian` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +!function(e,i){"function"==typeof define&&define.amd?define(i):"object"==typeof exports?module.exports=i():i()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.ro=function(){this.pipeline.reset(),this.pipeline.add(e.ro.trimmer,e.ro.stopWordFilter,e.ro.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.ro.stemmer))},e.ro.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.ro.trimmer=e.trimmerSupport.generateTrimmer(e.ro.wordCharacters),e.Pipeline.registerFunction(e.ro.trimmer,"trimmer-ro"),e.ro.stemmer=function(){var i=e.stemmerSupport.Among,r=e.stemmerSupport.SnowballProgram,n=new function(){function e(e,i){L.eq_s(1,e)&&(L.ket=L.cursor,L.in_grouping(W,97,259)&&L.slice_from(i))}function n(){for(var i,r;;){if(i=L.cursor,L.in_grouping(W,97,259)&&(r=L.cursor,L.bra=r,e("u","U"),L.cursor=r,e("i","I")),L.cursor=i,L.cursor>=L.limit)break;L.cursor++}}function t(){if(L.out_grouping(W,97,259)){for(;!L.in_grouping(W,97,259);){if(L.cursor>=L.limit)return!0;L.cursor++}return!1}return!0}function a(){if(L.in_grouping(W,97,259))for(;!L.out_grouping(W,97,259);){if(L.cursor>=L.limit)return!0;L.cursor++}return!1}function o(){var e,i,r=L.cursor;if(L.in_grouping(W,97,259)){if(e=L.cursor,!t())return void(h=L.cursor);if(L.cursor=e,!a())return void(h=L.cursor)}L.cursor=r,L.out_grouping(W,97,259)&&(i=L.cursor,t()&&(L.cursor=i,L.in_grouping(W,97,259)&&L.cursor=L.limit)return!1;L.cursor++}for(;!L.out_grouping(W,97,259);){if(L.cursor>=L.limit)return!1;L.cursor++}return!0}function c(){var e=L.cursor;h=L.limit,k=h,g=h,o(),L.cursor=e,u()&&(k=L.cursor,u()&&(g=L.cursor))}function s(){for(var e;;){if(L.bra=L.cursor,e=L.find_among(z,3))switch(L.ket=L.cursor,e){case 1:L.slice_from("i");continue;case 2:L.slice_from("u");continue;case 3:if(L.cursor>=L.limit)break;L.cursor++;continue}break}}function w(){return h<=L.cursor}function m(){return k<=L.cursor}function l(){return g<=L.cursor}function f(){var e,i;if(L.ket=L.cursor,(e=L.find_among_b(C,16))&&(L.bra=L.cursor,m()))switch(e){case 1:L.slice_del();break;case 2:L.slice_from("a");break;case 3:L.slice_from("e");break;case 4:L.slice_from("i");break;case 5:i=L.limit-L.cursor,L.eq_s_b(2,"ab")||(L.cursor=L.limit-i,L.slice_from("i"));break;case 6:L.slice_from("at");break;case 7:L.slice_from("aţi")}}function p(){var e,i=L.limit-L.cursor;if(L.ket=L.cursor,(e=L.find_among_b(P,46))&&(L.bra=L.cursor,m())){switch(e){case 1:L.slice_from("abil");break;case 2:L.slice_from("ibil");break;case 3:L.slice_from("iv");break;case 4:L.slice_from("ic");break;case 5:L.slice_from("at");break;case 6:L.slice_from("it")}return _=!0,L.cursor=L.limit-i,!0}return!1}function d(){var e,i;for(_=!1;;)if(i=L.limit-L.cursor,!p()){L.cursor=L.limit-i;break}if(L.ket=L.cursor,(e=L.find_among_b(F,62))&&(L.bra=L.cursor,l())){switch(e){case 1:L.slice_del();break;case 2:L.eq_s_b(1,"ţ")&&(L.bra=L.cursor,L.slice_from("t"));break;case 3:L.slice_from("ist")}_=!0}}function b(){var e,i,r;if(L.cursor>=h){if(i=L.limit_backward,L.limit_backward=h,L.ket=L.cursor,e=L.find_among_b(q,94))switch(L.bra=L.cursor,e){case 1:if(r=L.limit-L.cursor,!L.out_grouping_b(W,97,259)&&(L.cursor=L.limit-r,!L.eq_s_b(1,"u")))break;case 2:L.slice_del()}L.limit_backward=i}}function v(){var e;L.ket=L.cursor,(e=L.find_among_b(S,5))&&(L.bra=L.cursor,w()&&1==e&&L.slice_del())}var _,g,k,h,z=[new i("",-1,3),new i("I",0,1),new i("U",0,2)],C=[new i("ea",-1,3),new i("aţia",-1,7),new i("aua",-1,2),new i("iua",-1,4),new i("aţie",-1,7),new i("ele",-1,3),new i("ile",-1,5),new i("iile",6,4),new i("iei",-1,4),new i("atei",-1,6),new i("ii",-1,4),new i("ului",-1,1),new i("ul",-1,1),new i("elor",-1,3),new i("ilor",-1,4),new i("iilor",14,4)],P=[new i("icala",-1,4),new i("iciva",-1,4),new i("ativa",-1,5),new i("itiva",-1,6),new i("icale",-1,4),new i("aţiune",-1,5),new i("iţiune",-1,6),new i("atoare",-1,5),new i("itoare",-1,6),new i("ătoare",-1,5),new i("icitate",-1,4),new i("abilitate",-1,1),new i("ibilitate",-1,2),new i("ivitate",-1,3),new i("icive",-1,4),new i("ative",-1,5),new i("itive",-1,6),new i("icali",-1,4),new i("atori",-1,5),new i("icatori",18,4),new i("itori",-1,6),new i("ători",-1,5),new i("icitati",-1,4),new i("abilitati",-1,1),new i("ivitati",-1,3),new i("icivi",-1,4),new i("ativi",-1,5),new i("itivi",-1,6),new i("icităi",-1,4),new i("abilităi",-1,1),new i("ivităi",-1,3),new i("icităţi",-1,4),new i("abilităţi",-1,1),new i("ivităţi",-1,3),new i("ical",-1,4),new i("ator",-1,5),new i("icator",35,4),new i("itor",-1,6),new i("ător",-1,5),new i("iciv",-1,4),new i("ativ",-1,5),new i("itiv",-1,6),new i("icală",-1,4),new i("icivă",-1,4),new i("ativă",-1,5),new i("itivă",-1,6)],F=[new i("ica",-1,1),new i("abila",-1,1),new i("ibila",-1,1),new i("oasa",-1,1),new i("ata",-1,1),new i("ita",-1,1),new i("anta",-1,1),new i("ista",-1,3),new i("uta",-1,1),new i("iva",-1,1),new i("ic",-1,1),new i("ice",-1,1),new i("abile",-1,1),new i("ibile",-1,1),new i("isme",-1,3),new i("iune",-1,2),new i("oase",-1,1),new i("ate",-1,1),new i("itate",17,1),new i("ite",-1,1),new i("ante",-1,1),new i("iste",-1,3),new i("ute",-1,1),new i("ive",-1,1),new i("ici",-1,1),new i("abili",-1,1),new i("ibili",-1,1),new i("iuni",-1,2),new i("atori",-1,1),new i("osi",-1,1),new i("ati",-1,1),new i("itati",30,1),new i("iti",-1,1),new i("anti",-1,1),new i("isti",-1,3),new i("uti",-1,1),new i("işti",-1,3),new i("ivi",-1,1),new i("ităi",-1,1),new i("oşi",-1,1),new i("ităţi",-1,1),new i("abil",-1,1),new i("ibil",-1,1),new i("ism",-1,3),new i("ator",-1,1),new i("os",-1,1),new i("at",-1,1),new i("it",-1,1),new i("ant",-1,1),new i("ist",-1,3),new i("ut",-1,1),new i("iv",-1,1),new i("ică",-1,1),new i("abilă",-1,1),new i("ibilă",-1,1),new i("oasă",-1,1),new i("ată",-1,1),new i("ită",-1,1),new i("antă",-1,1),new i("istă",-1,3),new i("ută",-1,1),new i("ivă",-1,1)],q=[new i("ea",-1,1),new i("ia",-1,1),new i("esc",-1,1),new i("ăsc",-1,1),new i("ind",-1,1),new i("ând",-1,1),new i("are",-1,1),new i("ere",-1,1),new i("ire",-1,1),new i("âre",-1,1),new i("se",-1,2),new i("ase",10,1),new i("sese",10,2),new i("ise",10,1),new i("use",10,1),new i("âse",10,1),new i("eşte",-1,1),new i("ăşte",-1,1),new i("eze",-1,1),new i("ai",-1,1),new i("eai",19,1),new i("iai",19,1),new i("sei",-1,2),new i("eşti",-1,1),new i("ăşti",-1,1),new i("ui",-1,1),new i("ezi",-1,1),new i("âi",-1,1),new i("aşi",-1,1),new i("seşi",-1,2),new i("aseşi",29,1),new i("seseşi",29,2),new i("iseşi",29,1),new i("useşi",29,1),new i("âseşi",29,1),new i("işi",-1,1),new i("uşi",-1,1),new i("âşi",-1,1),new i("aţi",-1,2),new i("eaţi",38,1),new i("iaţi",38,1),new i("eţi",-1,2),new i("iţi",-1,2),new i("âţi",-1,2),new i("arăţi",-1,1),new i("serăţi",-1,2),new i("aserăţi",45,1),new i("seserăţi",45,2),new i("iserăţi",45,1),new i("userăţi",45,1),new i("âserăţi",45,1),new i("irăţi",-1,1),new i("urăţi",-1,1),new i("ârăţi",-1,1),new i("am",-1,1),new i("eam",54,1),new i("iam",54,1),new i("em",-1,2),new i("asem",57,1),new i("sesem",57,2),new i("isem",57,1),new i("usem",57,1),new i("âsem",57,1),new i("im",-1,2),new i("âm",-1,2),new i("ăm",-1,2),new i("arăm",65,1),new i("serăm",65,2),new i("aserăm",67,1),new i("seserăm",67,2),new i("iserăm",67,1),new i("userăm",67,1),new i("âserăm",67,1),new i("irăm",65,1),new i("urăm",65,1),new i("ârăm",65,1),new i("au",-1,1),new i("eau",76,1),new i("iau",76,1),new i("indu",-1,1),new i("ându",-1,1),new i("ez",-1,1),new i("ească",-1,1),new i("ară",-1,1),new i("seră",-1,2),new i("aseră",84,1),new i("seseră",84,2),new i("iseră",84,1),new i("useră",84,1),new i("âseră",84,1),new i("iră",-1,1),new i("ură",-1,1),new i("âră",-1,1),new i("ează",-1,1)],S=[new i("a",-1,1),new i("e",-1,1),new i("ie",1,1),new i("i",-1,1),new i("ă",-1,1)],W=[17,65,16,0,0,0,0,0,0,0,0,0,0,0,0,0,2,32,0,0,4],L=new r;this.setCurrent=function(e){L.setCurrent(e)},this.getCurrent=function(){return L.getCurrent()},this.stem=function(){var e=L.cursor;return n(),L.cursor=e,c(),L.limit_backward=e,L.cursor=L.limit,f(),L.cursor=L.limit,d(),L.cursor=L.limit,_||(L.cursor=L.limit,b(),L.cursor=L.limit),v(),L.cursor=L.limit_backward,s(),!0}};return function(e){return"function"==typeof e.update?e.update(function(e){return n.setCurrent(e),n.stem(),n.getCurrent()}):(n.setCurrent(e),n.stem(),n.getCurrent())}}(),e.Pipeline.registerFunction(e.ro.stemmer,"stemmer-ro"),e.ro.stopWordFilter=e.generateStopWordFilter("acea aceasta această aceea acei aceia acel acela acele acelea acest acesta aceste acestea aceşti aceştia acolo acord acum ai aia aibă aici al ale alea altceva altcineva am ar are asemenea asta astea astăzi asupra au avea avem aveţi azi aş aşadar aţi bine bucur bună ca care caut ce cel ceva chiar cinci cine cineva contra cu cum cumva curând curînd când cât câte câtva câţi cînd cît cîte cîtva cîţi că căci cărei căror cărui către da dacă dar datorită dată dau de deci deja deoarece departe deşi din dinaintea dintr- dintre doi doilea două drept după dă ea ei el ele eram este eu eşti face fata fi fie fiecare fii fim fiu fiţi frumos fără graţie halbă iar ieri la le li lor lui lângă lîngă mai mea mei mele mereu meu mi mie mine mult multă mulţi mulţumesc mâine mîine mă ne nevoie nici nicăieri nimeni nimeri nimic nişte noastre noastră noi noroc nostru nouă noştri nu opt ori oricare orice oricine oricum oricând oricât oricînd oricît oriunde patra patru patrulea pe pentru peste pic poate pot prea prima primul prin puţin puţina puţină până pînă rog sa sale sau se spate spre sub sunt suntem sunteţi sută sînt sîntem sînteţi să săi său ta tale te timp tine toate toată tot totuşi toţi trei treia treilea tu tăi tău un una unde undeva unei uneia unele uneori unii unor unora unu unui unuia unul vi voastre voastră voi vostru vouă voştri vreme vreo vreun vă zece zero zi zice îi îl îmi împotriva în înainte înaintea încotro încât încît între întrucât întrucît îţi ăla ălea ăsta ăstea ăştia şapte şase şi ştiu ţi ţie".split(" ")),e.Pipeline.registerFunction(e.ro.stopWordFilter,"stopWordFilter-ro")}}); \ No newline at end of file diff --git a/docs/assets/javascripts/lunr/min/lunr.ru.min.js b/docs/assets/javascripts/lunr/min/lunr.ru.min.js new file mode 100644 index 0000000..186cc48 --- /dev/null +++ b/docs/assets/javascripts/lunr/min/lunr.ru.min.js @@ -0,0 +1,18 @@ +/*! + * Lunr languages, `Russian` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +!function(e,n){"function"==typeof define&&define.amd?define(n):"object"==typeof exports?module.exports=n():n()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.ru=function(){this.pipeline.reset(),this.pipeline.add(e.ru.trimmer,e.ru.stopWordFilter,e.ru.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.ru.stemmer))},e.ru.wordCharacters="Ѐ-҄҇-ԯᴫᵸⷠ-ⷿꙀ-ꚟ︮︯",e.ru.trimmer=e.trimmerSupport.generateTrimmer(e.ru.wordCharacters),e.Pipeline.registerFunction(e.ru.trimmer,"trimmer-ru"),e.ru.stemmer=function(){var n=e.stemmerSupport.Among,r=e.stemmerSupport.SnowballProgram,t=new function(){function e(){for(;!W.in_grouping(S,1072,1103);){if(W.cursor>=W.limit)return!1;W.cursor++}return!0}function t(){for(;!W.out_grouping(S,1072,1103);){if(W.cursor>=W.limit)return!1;W.cursor++}return!0}function w(){b=W.limit,_=b,e()&&(b=W.cursor,t()&&e()&&t()&&(_=W.cursor))}function i(){return _<=W.cursor}function u(e,n){var r,t;if(W.ket=W.cursor,r=W.find_among_b(e,n)){switch(W.bra=W.cursor,r){case 1:if(t=W.limit-W.cursor,!W.eq_s_b(1,"а")&&(W.cursor=W.limit-t,!W.eq_s_b(1,"я")))return!1;case 2:W.slice_del()}return!0}return!1}function o(){return u(h,9)}function s(e,n){var r;return W.ket=W.cursor,!!(r=W.find_among_b(e,n))&&(W.bra=W.cursor,1==r&&W.slice_del(),!0)}function c(){return s(g,26)}function m(){return!!c()&&(u(C,8),!0)}function f(){return s(k,2)}function l(){return u(P,46)}function a(){s(v,36)}function p(){var e;W.ket=W.cursor,(e=W.find_among_b(F,2))&&(W.bra=W.cursor,i()&&1==e&&W.slice_del())}function d(){var e;if(W.ket=W.cursor,e=W.find_among_b(q,4))switch(W.bra=W.cursor,e){case 1:if(W.slice_del(),W.ket=W.cursor,!W.eq_s_b(1,"н"))break;W.bra=W.cursor;case 2:if(!W.eq_s_b(1,"н"))break;case 3:W.slice_del()}}var _,b,h=[new n("в",-1,1),new n("ив",0,2),new n("ыв",0,2),new n("вши",-1,1),new n("ивши",3,2),new n("ывши",3,2),new n("вшись",-1,1),new n("ившись",6,2),new n("ывшись",6,2)],g=[new n("ее",-1,1),new n("ие",-1,1),new n("ое",-1,1),new n("ые",-1,1),new n("ими",-1,1),new n("ыми",-1,1),new n("ей",-1,1),new n("ий",-1,1),new n("ой",-1,1),new n("ый",-1,1),new n("ем",-1,1),new n("им",-1,1),new n("ом",-1,1),new n("ым",-1,1),new n("его",-1,1),new n("ого",-1,1),new n("ему",-1,1),new n("ому",-1,1),new n("их",-1,1),new n("ых",-1,1),new n("ею",-1,1),new n("ою",-1,1),new n("ую",-1,1),new n("юю",-1,1),new n("ая",-1,1),new n("яя",-1,1)],C=[new n("ем",-1,1),new n("нн",-1,1),new n("вш",-1,1),new n("ивш",2,2),new n("ывш",2,2),new n("щ",-1,1),new n("ющ",5,1),new n("ующ",6,2)],k=[new n("сь",-1,1),new n("ся",-1,1)],P=[new n("ла",-1,1),new n("ила",0,2),new n("ыла",0,2),new n("на",-1,1),new n("ена",3,2),new n("ете",-1,1),new n("ите",-1,2),new n("йте",-1,1),new n("ейте",7,2),new n("уйте",7,2),new n("ли",-1,1),new n("или",10,2),new n("ыли",10,2),new n("й",-1,1),new n("ей",13,2),new n("уй",13,2),new n("л",-1,1),new n("ил",16,2),new n("ыл",16,2),new n("ем",-1,1),new n("им",-1,2),new n("ым",-1,2),new n("н",-1,1),new n("ен",22,2),new n("ло",-1,1),new n("ило",24,2),new n("ыло",24,2),new n("но",-1,1),new n("ено",27,2),new n("нно",27,1),new n("ет",-1,1),new n("ует",30,2),new n("ит",-1,2),new n("ыт",-1,2),new n("ют",-1,1),new n("уют",34,2),new n("ят",-1,2),new n("ны",-1,1),new n("ены",37,2),new n("ть",-1,1),new n("ить",39,2),new n("ыть",39,2),new n("ешь",-1,1),new n("ишь",-1,2),new n("ю",-1,2),new n("ую",44,2)],v=[new n("а",-1,1),new n("ев",-1,1),new n("ов",-1,1),new n("е",-1,1),new n("ие",3,1),new n("ье",3,1),new n("и",-1,1),new n("еи",6,1),new n("ии",6,1),new n("ами",6,1),new n("ями",6,1),new n("иями",10,1),new n("й",-1,1),new n("ей",12,1),new n("ией",13,1),new n("ий",12,1),new n("ой",12,1),new n("ам",-1,1),new n("ем",-1,1),new n("ием",18,1),new n("ом",-1,1),new n("ям",-1,1),new n("иям",21,1),new n("о",-1,1),new n("у",-1,1),new n("ах",-1,1),new n("ях",-1,1),new n("иях",26,1),new n("ы",-1,1),new n("ь",-1,1),new n("ю",-1,1),new n("ию",30,1),new n("ью",30,1),new n("я",-1,1),new n("ия",33,1),new n("ья",33,1)],F=[new n("ост",-1,1),new n("ость",-1,1)],q=[new n("ейше",-1,1),new n("н",-1,2),new n("ейш",-1,1),new n("ь",-1,3)],S=[33,65,8,232],W=new r;this.setCurrent=function(e){W.setCurrent(e)},this.getCurrent=function(){return W.getCurrent()},this.stem=function(){return w(),W.cursor=W.limit,!(W.cursor=i&&(e-=i,t[e>>3]&1<<(7&e)))return this.cursor++,!0}return!1},in_grouping_b:function(t,i,s){if(this.cursor>this.limit_backward){var e=r.charCodeAt(this.cursor-1);if(e<=s&&e>=i&&(e-=i,t[e>>3]&1<<(7&e)))return this.cursor--,!0}return!1},out_grouping:function(t,i,s){if(this.cursors||e>3]&1<<(7&e)))return this.cursor++,!0}return!1},out_grouping_b:function(t,i,s){if(this.cursor>this.limit_backward){var e=r.charCodeAt(this.cursor-1);if(e>s||e>3]&1<<(7&e)))return this.cursor--,!0}return!1},eq_s:function(t,i){if(this.limit-this.cursor>1),f=0,l=o0||e==s||c)break;c=!0}}for(;;){var _=t[s];if(o>=_.s_size){if(this.cursor=n+_.s_size,!_.method)return _.result;var b=_.method();if(this.cursor=n+_.s_size,b)return _.result}if((s=_.substring_i)<0)return 0}},find_among_b:function(t,i){for(var s=0,e=i,n=this.cursor,u=this.limit_backward,o=0,h=0,c=!1;;){for(var a=s+(e-s>>1),f=0,l=o=0;m--){if(n-l==u){f=-1;break}if(f=r.charCodeAt(n-1-l)-_.s[m])break;l++}if(f<0?(e=a,h=l):(s=a,o=l),e-s<=1){if(s>0||e==s||c)break;c=!0}}for(;;){var _=t[s];if(o>=_.s_size){if(this.cursor=n-_.s_size,!_.method)return _.result;var b=_.method();if(this.cursor=n-_.s_size,b)return _.result}if((s=_.substring_i)<0)return 0}},replace_s:function(t,i,s){var e=s.length-(i-t),n=r.substring(0,t),u=r.substring(i);return r=n+s+u,this.limit+=e,this.cursor>=i?this.cursor+=e:this.cursor>t&&(this.cursor=t),e},slice_check:function(){if(this.bra<0||this.bra>this.ket||this.ket>this.limit||this.limit>r.length)throw"faulty slice operation"},slice_from:function(r){this.slice_check(),this.replace_s(this.bra,this.ket,r)},slice_del:function(){this.slice_from("")},insert:function(r,t,i){var s=this.replace_s(r,t,i);r<=this.bra&&(this.bra+=s),r<=this.ket&&(this.ket+=s)},slice_to:function(){return this.slice_check(),r.substring(this.bra,this.ket)},eq_v_b:function(r){return this.eq_s_b(r.length,r)}}}},r.trimmerSupport={generateTrimmer:function(r){var t=new RegExp("^[^"+r+"]+"),i=new RegExp("[^"+r+"]+$");return function(r){return"function"==typeof r.update?r.update(function(r){return r.replace(t,"").replace(i,"")}):r.replace(t,"").replace(i,"")}}}}}); \ No newline at end of file diff --git a/docs/assets/javascripts/lunr/min/lunr.sv.min.js b/docs/assets/javascripts/lunr/min/lunr.sv.min.js new file mode 100644 index 0000000..3e5eb64 --- /dev/null +++ b/docs/assets/javascripts/lunr/min/lunr.sv.min.js @@ -0,0 +1,18 @@ +/*! + * Lunr languages, `Swedish` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.sv=function(){this.pipeline.reset(),this.pipeline.add(e.sv.trimmer,e.sv.stopWordFilter,e.sv.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(e.sv.stemmer))},e.sv.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.sv.trimmer=e.trimmerSupport.generateTrimmer(e.sv.wordCharacters),e.Pipeline.registerFunction(e.sv.trimmer,"trimmer-sv"),e.sv.stemmer=function(){var r=e.stemmerSupport.Among,n=e.stemmerSupport.SnowballProgram,t=new function(){function e(){var e,r=w.cursor+3;if(o=w.limit,0<=r||r<=w.limit){for(a=r;;){if(e=w.cursor,w.in_grouping(l,97,246)){w.cursor=e;break}if(w.cursor=e,w.cursor>=w.limit)return;w.cursor++}for(;!w.out_grouping(l,97,246);){if(w.cursor>=w.limit)return;w.cursor++}o=w.cursor,o=o&&(w.limit_backward=o,w.cursor=w.limit,w.ket=w.cursor,e=w.find_among_b(u,37),w.limit_backward=r,e))switch(w.bra=w.cursor,e){case 1:w.slice_del();break;case 2:w.in_grouping_b(d,98,121)&&w.slice_del()}}function i(){var e=w.limit_backward;w.cursor>=o&&(w.limit_backward=o,w.cursor=w.limit,w.find_among_b(c,7)&&(w.cursor=w.limit,w.ket=w.cursor,w.cursor>w.limit_backward&&(w.bra=--w.cursor,w.slice_del())),w.limit_backward=e)}function s(){var e,r;if(w.cursor>=o){if(r=w.limit_backward,w.limit_backward=o,w.cursor=w.limit,w.ket=w.cursor,e=w.find_among_b(m,5))switch(w.bra=w.cursor,e){case 1:w.slice_del();break;case 2:w.slice_from("lös");break;case 3:w.slice_from("full")}w.limit_backward=r}}var a,o,u=[new r("a",-1,1),new r("arna",0,1),new r("erna",0,1),new r("heterna",2,1),new r("orna",0,1),new r("ad",-1,1),new r("e",-1,1),new r("ade",6,1),new r("ande",6,1),new r("arne",6,1),new r("are",6,1),new r("aste",6,1),new r("en",-1,1),new r("anden",12,1),new r("aren",12,1),new r("heten",12,1),new r("ern",-1,1),new r("ar",-1,1),new r("er",-1,1),new r("heter",18,1),new r("or",-1,1),new r("s",-1,2),new r("as",21,1),new r("arnas",22,1),new r("ernas",22,1),new r("ornas",22,1),new r("es",21,1),new r("ades",26,1),new r("andes",26,1),new r("ens",21,1),new r("arens",29,1),new r("hetens",29,1),new r("erns",21,1),new r("at",-1,1),new r("andet",-1,1),new r("het",-1,1),new r("ast",-1,1)],c=[new r("dd",-1,-1),new r("gd",-1,-1),new r("nn",-1,-1),new r("dt",-1,-1),new r("gt",-1,-1),new r("kt",-1,-1),new r("tt",-1,-1)],m=[new r("ig",-1,1),new r("lig",0,1),new r("els",-1,1),new r("fullt",-1,3),new r("löst",-1,2)],l=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,24,0,32],d=[119,127,149],w=new n;this.setCurrent=function(e){w.setCurrent(e)},this.getCurrent=function(){return w.getCurrent()},this.stem=function(){var r=w.cursor;return e(),w.limit_backward=r,w.cursor=w.limit,t(),w.cursor=w.limit,i(),w.cursor=w.limit,s(),!0}};return function(e){return"function"==typeof e.update?e.update(function(e){return t.setCurrent(e),t.stem(),t.getCurrent()}):(t.setCurrent(e),t.stem(),t.getCurrent())}}(),e.Pipeline.registerFunction(e.sv.stemmer,"stemmer-sv"),e.sv.stopWordFilter=e.generateStopWordFilter("alla allt att av blev bli blir blivit de dem den denna deras dess dessa det detta dig din dina ditt du där då efter ej eller en er era ert ett från för ha hade han hans har henne hennes hon honom hur här i icke ingen inom inte jag ju kan kunde man med mellan men mig min mina mitt mot mycket ni nu när någon något några och om oss på samma sedan sig sin sina sitta själv skulle som så sådan sådana sådant till under upp ut utan vad var vara varför varit varje vars vart vem vi vid vilka vilkas vilken vilket vår våra vårt än är åt över".split(" ")),e.Pipeline.registerFunction(e.sv.stopWordFilter,"stopWordFilter-sv")}}); \ No newline at end of file diff --git a/docs/assets/javascripts/lunr/min/lunr.tr.min.js b/docs/assets/javascripts/lunr/min/lunr.tr.min.js new file mode 100644 index 0000000..563f6ec --- /dev/null +++ b/docs/assets/javascripts/lunr/min/lunr.tr.min.js @@ -0,0 +1,18 @@ +/*! + * Lunr languages, `Turkish` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +!function(r,i){"function"==typeof define&&define.amd?define(i):"object"==typeof exports?module.exports=i():i()(r.lunr)}(this,function(){return function(r){if(void 0===r)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===r.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");r.tr=function(){this.pipeline.reset(),this.pipeline.add(r.tr.trimmer,r.tr.stopWordFilter,r.tr.stemmer),this.searchPipeline&&(this.searchPipeline.reset(),this.searchPipeline.add(r.tr.stemmer))},r.tr.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",r.tr.trimmer=r.trimmerSupport.generateTrimmer(r.tr.wordCharacters),r.Pipeline.registerFunction(r.tr.trimmer,"trimmer-tr"),r.tr.stemmer=function(){var i=r.stemmerSupport.Among,e=r.stemmerSupport.SnowballProgram,n=new function(){function r(r,i,e){for(;;){var n=Dr.limit-Dr.cursor;if(Dr.in_grouping_b(r,i,e)){Dr.cursor=Dr.limit-n;break}if(Dr.cursor=Dr.limit-n,Dr.cursor<=Dr.limit_backward)return!1;Dr.cursor--}return!0}function n(){var i,e;i=Dr.limit-Dr.cursor,r(Wr,97,305);for(var n=0;nDr.limit_backward&&(Dr.cursor--,e=Dr.limit-Dr.cursor,i()))?(Dr.cursor=Dr.limit-e,!0):(Dr.cursor=Dr.limit-n,r()?(Dr.cursor=Dr.limit-n,!1):(Dr.cursor=Dr.limit-n,!(Dr.cursor<=Dr.limit_backward)&&(Dr.cursor--,!!i()&&(Dr.cursor=Dr.limit-n,!0))))}function u(r){return t(r,function(){return Dr.in_grouping_b(Wr,97,305)})}function o(){return u(function(){return Dr.eq_s_b(1,"n")})}function s(){return u(function(){return Dr.eq_s_b(1,"s")})}function c(){return u(function(){return Dr.eq_s_b(1,"y")})}function l(){return t(function(){return Dr.in_grouping_b(Lr,105,305)},function(){return Dr.out_grouping_b(Wr,97,305)})}function a(){return Dr.find_among_b(ur,10)&&l()}function m(){return n()&&Dr.in_grouping_b(Lr,105,305)&&s()}function d(){return Dr.find_among_b(or,2)}function f(){return n()&&Dr.in_grouping_b(Lr,105,305)&&c()}function b(){return n()&&Dr.find_among_b(sr,4)}function w(){return n()&&Dr.find_among_b(cr,4)&&o()}function _(){return n()&&Dr.find_among_b(lr,2)&&c()}function k(){return n()&&Dr.find_among_b(ar,2)}function p(){return n()&&Dr.find_among_b(mr,4)}function g(){return n()&&Dr.find_among_b(dr,2)}function y(){return n()&&Dr.find_among_b(fr,4)}function z(){return n()&&Dr.find_among_b(br,2)}function v(){return n()&&Dr.find_among_b(wr,2)&&c()}function h(){return Dr.eq_s_b(2,"ki")}function q(){return n()&&Dr.find_among_b(_r,2)&&o()}function C(){return n()&&Dr.find_among_b(kr,4)&&c()}function P(){return n()&&Dr.find_among_b(pr,4)}function F(){return n()&&Dr.find_among_b(gr,4)&&c()}function S(){return Dr.find_among_b(yr,4)}function W(){return n()&&Dr.find_among_b(zr,2)}function L(){return n()&&Dr.find_among_b(vr,4)}function x(){return n()&&Dr.find_among_b(hr,8)}function A(){return Dr.find_among_b(qr,2)}function E(){return n()&&Dr.find_among_b(Cr,32)&&c()}function j(){return Dr.find_among_b(Pr,8)&&c()}function T(){return n()&&Dr.find_among_b(Fr,4)&&c()}function Z(){return Dr.eq_s_b(3,"ken")&&c()}function B(){var r=Dr.limit-Dr.cursor;return!(T()||(Dr.cursor=Dr.limit-r,E()||(Dr.cursor=Dr.limit-r,j()||(Dr.cursor=Dr.limit-r,Z()))))}function D(){if(A()){var r=Dr.limit-Dr.cursor;if(S()||(Dr.cursor=Dr.limit-r,W()||(Dr.cursor=Dr.limit-r,C()||(Dr.cursor=Dr.limit-r,P()||(Dr.cursor=Dr.limit-r,F()||(Dr.cursor=Dr.limit-r))))),T())return!1}return!0}function G(){if(W()){Dr.bra=Dr.cursor,Dr.slice_del();var r=Dr.limit-Dr.cursor;return Dr.ket=Dr.cursor,x()||(Dr.cursor=Dr.limit-r,E()||(Dr.cursor=Dr.limit-r,j()||(Dr.cursor=Dr.limit-r,T()||(Dr.cursor=Dr.limit-r)))),nr=!1,!1}return!0}function H(){if(!L())return!0;var r=Dr.limit-Dr.cursor;return!E()&&(Dr.cursor=Dr.limit-r,!j())}function I(){var r,i=Dr.limit-Dr.cursor;return!(S()||(Dr.cursor=Dr.limit-i,F()||(Dr.cursor=Dr.limit-i,P()||(Dr.cursor=Dr.limit-i,C()))))||(Dr.bra=Dr.cursor,Dr.slice_del(),r=Dr.limit-Dr.cursor,Dr.ket=Dr.cursor,T()||(Dr.cursor=Dr.limit-r),!1)}function J(){var r,i=Dr.limit-Dr.cursor;if(Dr.ket=Dr.cursor,nr=!0,B()&&(Dr.cursor=Dr.limit-i,D()&&(Dr.cursor=Dr.limit-i,G()&&(Dr.cursor=Dr.limit-i,H()&&(Dr.cursor=Dr.limit-i,I()))))){if(Dr.cursor=Dr.limit-i,!x())return;Dr.bra=Dr.cursor,Dr.slice_del(),Dr.ket=Dr.cursor,r=Dr.limit-Dr.cursor,S()||(Dr.cursor=Dr.limit-r,W()||(Dr.cursor=Dr.limit-r,C()||(Dr.cursor=Dr.limit-r,P()||(Dr.cursor=Dr.limit-r,F()||(Dr.cursor=Dr.limit-r))))),T()||(Dr.cursor=Dr.limit-r)}Dr.bra=Dr.cursor,Dr.slice_del()}function K(){var r,i,e,n;if(Dr.ket=Dr.cursor,h()){if(r=Dr.limit-Dr.cursor,p())return Dr.bra=Dr.cursor,Dr.slice_del(),i=Dr.limit-Dr.cursor,Dr.ket=Dr.cursor,W()?(Dr.bra=Dr.cursor,Dr.slice_del(),K()):(Dr.cursor=Dr.limit-i,a()&&(Dr.bra=Dr.cursor,Dr.slice_del(),Dr.ket=Dr.cursor,W()&&(Dr.bra=Dr.cursor,Dr.slice_del(),K()))),!0;if(Dr.cursor=Dr.limit-r,w()){if(Dr.bra=Dr.cursor,Dr.slice_del(),Dr.ket=Dr.cursor,e=Dr.limit-Dr.cursor,d())Dr.bra=Dr.cursor,Dr.slice_del();else{if(Dr.cursor=Dr.limit-e,Dr.ket=Dr.cursor,!a()&&(Dr.cursor=Dr.limit-e,!m()&&(Dr.cursor=Dr.limit-e,!K())))return!0;Dr.bra=Dr.cursor,Dr.slice_del(),Dr.ket=Dr.cursor,W()&&(Dr.bra=Dr.cursor,Dr.slice_del(),K())}return!0}if(Dr.cursor=Dr.limit-r,g()){if(n=Dr.limit-Dr.cursor,d())Dr.bra=Dr.cursor,Dr.slice_del();else if(Dr.cursor=Dr.limit-n,m())Dr.bra=Dr.cursor,Dr.slice_del(),Dr.ket=Dr.cursor,W()&&(Dr.bra=Dr.cursor,Dr.slice_del(),K());else if(Dr.cursor=Dr.limit-n,!K())return!1;return!0}}return!1}function M(r){if(Dr.ket=Dr.cursor,!g()&&(Dr.cursor=Dr.limit-r,!k()))return!1;var i=Dr.limit-Dr.cursor;if(d())Dr.bra=Dr.cursor,Dr.slice_del();else if(Dr.cursor=Dr.limit-i,m())Dr.bra=Dr.cursor,Dr.slice_del(),Dr.ket=Dr.cursor,W()&&(Dr.bra=Dr.cursor,Dr.slice_del(),K());else if(Dr.cursor=Dr.limit-i,!K())return!1;return!0}function N(r){if(Dr.ket=Dr.cursor,!z()&&(Dr.cursor=Dr.limit-r,!b()))return!1;var i=Dr.limit-Dr.cursor;return!(!m()&&(Dr.cursor=Dr.limit-i,!d()))&&(Dr.bra=Dr.cursor,Dr.slice_del(),Dr.ket=Dr.cursor,W()&&(Dr.bra=Dr.cursor,Dr.slice_del(),K()),!0)}function O(){var r,i=Dr.limit-Dr.cursor;return Dr.ket=Dr.cursor,!(!w()&&(Dr.cursor=Dr.limit-i,!v()))&&(Dr.bra=Dr.cursor,Dr.slice_del(),r=Dr.limit-Dr.cursor,Dr.ket=Dr.cursor,!(!W()||(Dr.bra=Dr.cursor,Dr.slice_del(),!K()))||(Dr.cursor=Dr.limit-r,Dr.ket=Dr.cursor,!(a()||(Dr.cursor=Dr.limit-r,m()||(Dr.cursor=Dr.limit-r,K())))||(Dr.bra=Dr.cursor,Dr.slice_del(),Dr.ket=Dr.cursor,W()&&(Dr.bra=Dr.cursor,Dr.slice_del(),K()),!0)))}function Q(){var r,i,e=Dr.limit-Dr.cursor;if(Dr.ket=Dr.cursor,!p()&&(Dr.cursor=Dr.limit-e,!f()&&(Dr.cursor=Dr.limit-e,!_())))return!1;if(Dr.bra=Dr.cursor,Dr.slice_del(),Dr.ket=Dr.cursor,r=Dr.limit-Dr.cursor,a())Dr.bra=Dr.cursor,Dr.slice_del(),i=Dr.limit-Dr.cursor,Dr.ket=Dr.cursor,W()||(Dr.cursor=Dr.limit-i);else if(Dr.cursor=Dr.limit-r,!W())return!0;return Dr.bra=Dr.cursor,Dr.slice_del(),Dr.ket=Dr.cursor,K(),!0}function R(){var r,i,e=Dr.limit-Dr.cursor;if(Dr.ket=Dr.cursor,W())return Dr.bra=Dr.cursor,Dr.slice_del(),void K();if(Dr.cursor=Dr.limit-e,Dr.ket=Dr.cursor,q())if(Dr.bra=Dr.cursor,Dr.slice_del(),r=Dr.limit-Dr.cursor,Dr.ket=Dr.cursor,d())Dr.bra=Dr.cursor,Dr.slice_del();else{if(Dr.cursor=Dr.limit-r,Dr.ket=Dr.cursor,!a()&&(Dr.cursor=Dr.limit-r,!m())){if(Dr.cursor=Dr.limit-r,Dr.ket=Dr.cursor,!W())return;if(Dr.bra=Dr.cursor,Dr.slice_del(),!K())return}Dr.bra=Dr.cursor,Dr.slice_del(),Dr.ket=Dr.cursor,W()&&(Dr.bra=Dr.cursor,Dr.slice_del(),K())}else if(Dr.cursor=Dr.limit-e,!M(e)&&(Dr.cursor=Dr.limit-e,!N(e))){if(Dr.cursor=Dr.limit-e,Dr.ket=Dr.cursor,y())return Dr.bra=Dr.cursor,Dr.slice_del(),Dr.ket=Dr.cursor,i=Dr.limit-Dr.cursor,void(a()?(Dr.bra=Dr.cursor,Dr.slice_del(),Dr.ket=Dr.cursor,W()&&(Dr.bra=Dr.cursor,Dr.slice_del(),K())):(Dr.cursor=Dr.limit-i,W()?(Dr.bra=Dr.cursor,Dr.slice_del(),K()):(Dr.cursor=Dr.limit-i,K())));if(Dr.cursor=Dr.limit-e,!O()){if(Dr.cursor=Dr.limit-e,d())return Dr.bra=Dr.cursor,void Dr.slice_del();Dr.cursor=Dr.limit-e,K()||(Dr.cursor=Dr.limit-e,Q()||(Dr.cursor=Dr.limit-e,Dr.ket=Dr.cursor,(a()||(Dr.cursor=Dr.limit-e,m()))&&(Dr.bra=Dr.cursor,Dr.slice_del(),Dr.ket=Dr.cursor,W()&&(Dr.bra=Dr.cursor,Dr.slice_del(),K()))))}}}function U(){var r;if(Dr.ket=Dr.cursor,r=Dr.find_among_b(Sr,4))switch(Dr.bra=Dr.cursor,r){case 1:Dr.slice_from("p");break;case 2:Dr.slice_from("ç");break;case 3:Dr.slice_from("t");break;case 4:Dr.slice_from("k")}}function V(){for(;;){var r=Dr.limit-Dr.cursor;if(Dr.in_grouping_b(Wr,97,305)){Dr.cursor=Dr.limit-r;break}if(Dr.cursor=Dr.limit-r,Dr.cursor<=Dr.limit_backward)return!1;Dr.cursor--}return!0}function X(r,i,e){if(Dr.cursor=Dr.limit-r,V()){var n=Dr.limit-Dr.cursor;if(!Dr.eq_s_b(1,i)&&(Dr.cursor=Dr.limit-n,!Dr.eq_s_b(1,e)))return!0;Dr.cursor=Dr.limit-r;var t=Dr.cursor;return Dr.insert(Dr.cursor,Dr.cursor,e),Dr.cursor=t,!1}return!0}function Y(){var r=Dr.limit-Dr.cursor;(Dr.eq_s_b(1,"d")||(Dr.cursor=Dr.limit-r,Dr.eq_s_b(1,"g")))&&X(r,"a","ı")&&X(r,"e","i")&&X(r,"o","u")&&X(r,"ö","ü")}function $(){for(var r,i=Dr.cursor,e=2;;){for(r=Dr.cursor;!Dr.in_grouping(Wr,97,305);){if(Dr.cursor>=Dr.limit)return Dr.cursor=r,!(e>0)&&(Dr.cursor=i,!0);Dr.cursor++}e--}}function rr(r,i,e){for(;!Dr.eq_s(i,e);){if(Dr.cursor>=Dr.limit)return!0;Dr.cursor++}return(tr=i)!=Dr.limit||(Dr.cursor=r,!1)}function ir(){var r=Dr.cursor;return!rr(r,2,"ad")||(Dr.cursor=r,!rr(r,5,"soyad"))}function er(){var r=Dr.cursor;return!ir()&&(Dr.limit_backward=r,Dr.cursor=Dr.limit,Y(),Dr.cursor=Dr.limit,U(),!0)}var nr,tr,ur=[new i("m",-1,-1),new i("n",-1,-1),new i("miz",-1,-1),new i("niz",-1,-1),new i("muz",-1,-1),new i("nuz",-1,-1),new i("müz",-1,-1),new i("nüz",-1,-1),new i("mız",-1,-1),new i("nız",-1,-1)],or=[new i("leri",-1,-1),new i("ları",-1,-1)],sr=[new i("ni",-1,-1),new i("nu",-1,-1),new i("nü",-1,-1),new i("nı",-1,-1)],cr=[new i("in",-1,-1),new i("un",-1,-1),new i("ün",-1,-1),new i("ın",-1,-1)],lr=[new i("a",-1,-1),new i("e",-1,-1)],ar=[new i("na",-1,-1),new i("ne",-1,-1)],mr=[new i("da",-1,-1),new i("ta",-1,-1),new i("de",-1,-1),new i("te",-1,-1)],dr=[new i("nda",-1,-1),new i("nde",-1,-1)],fr=[new i("dan",-1,-1),new i("tan",-1,-1),new i("den",-1,-1),new i("ten",-1,-1)],br=[new i("ndan",-1,-1),new i("nden",-1,-1)],wr=[new i("la",-1,-1),new i("le",-1,-1)],_r=[new i("ca",-1,-1),new i("ce",-1,-1)],kr=[new i("im",-1,-1),new i("um",-1,-1),new i("üm",-1,-1),new i("ım",-1,-1)],pr=[new i("sin",-1,-1),new i("sun",-1,-1),new i("sün",-1,-1),new i("sın",-1,-1)],gr=[new i("iz",-1,-1),new i("uz",-1,-1),new i("üz",-1,-1),new i("ız",-1,-1)],yr=[new i("siniz",-1,-1),new i("sunuz",-1,-1),new i("sünüz",-1,-1),new i("sınız",-1,-1)],zr=[new i("lar",-1,-1),new i("ler",-1,-1)],vr=[new i("niz",-1,-1),new i("nuz",-1,-1),new i("nüz",-1,-1),new i("nız",-1,-1)],hr=[new i("dir",-1,-1),new i("tir",-1,-1),new i("dur",-1,-1),new i("tur",-1,-1),new i("dür",-1,-1),new i("tür",-1,-1),new i("dır",-1,-1),new i("tır",-1,-1)],qr=[new i("casına",-1,-1),new i("cesine",-1,-1)],Cr=[new i("di",-1,-1),new i("ti",-1,-1),new i("dik",-1,-1),new i("tik",-1,-1),new i("duk",-1,-1),new i("tuk",-1,-1),new i("dük",-1,-1),new i("tük",-1,-1),new i("dık",-1,-1),new i("tık",-1,-1),new i("dim",-1,-1),new i("tim",-1,-1),new i("dum",-1,-1),new i("tum",-1,-1),new i("düm",-1,-1),new i("tüm",-1,-1),new i("dım",-1,-1),new i("tım",-1,-1),new i("din",-1,-1),new i("tin",-1,-1),new i("dun",-1,-1),new i("tun",-1,-1),new i("dün",-1,-1),new i("tün",-1,-1),new i("dın",-1,-1),new i("tın",-1,-1),new i("du",-1,-1),new i("tu",-1,-1),new i("dü",-1,-1),new i("tü",-1,-1),new i("dı",-1,-1),new i("tı",-1,-1)],Pr=[new i("sa",-1,-1),new i("se",-1,-1),new i("sak",-1,-1),new i("sek",-1,-1),new i("sam",-1,-1),new i("sem",-1,-1),new i("san",-1,-1),new i("sen",-1,-1)],Fr=[new i("miş",-1,-1),new i("muş",-1,-1),new i("müş",-1,-1),new i("mış",-1,-1)],Sr=[new i("b",-1,1),new i("c",-1,2),new i("d",-1,3),new i("ğ",-1,4)],Wr=[17,65,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,8,0,0,0,0,0,0,1],Lr=[1,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,1],xr=[1,64,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],Ar=[17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,130],Er=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],jr=[17],Tr=[65],Zr=[65],Br=[["a",xr,97,305],["e",Ar,101,252],["ı",Er,97,305],["i",jr,101,105],["o",Tr,111,117],["ö",Zr,246,252],["u",Tr,111,117]],Dr=new e;this.setCurrent=function(r){Dr.setCurrent(r)},this.getCurrent=function(){return Dr.getCurrent()},this.stem=function(){return!!($()&&(Dr.limit_backward=Dr.cursor,Dr.cursor=Dr.limit,J(),Dr.cursor=Dr.limit,nr&&(R(),Dr.cursor=Dr.limit_backward,er())))}};return function(r){return"function"==typeof r.update?r.update(function(r){return n.setCurrent(r),n.stem(),n.getCurrent()}):(n.setCurrent(r),n.stem(),n.getCurrent())}}(),r.Pipeline.registerFunction(r.tr.stemmer,"stemmer-tr"),r.tr.stopWordFilter=r.generateStopWordFilter("acaba altmış altı ama ancak arada aslında ayrıca bana bazı belki ben benden beni benim beri beş bile bin bir biri birkaç birkez birçok birşey birşeyi biz bizden bize bizi bizim bu buna bunda bundan bunlar bunları bunların bunu bunun burada böyle böylece da daha dahi de defa değil diye diğer doksan dokuz dolayı dolayısıyla dört edecek eden ederek edilecek ediliyor edilmesi ediyor elli en etmesi etti ettiği ettiğini eğer gibi göre halen hangi hatta hem henüz hep hepsi her herhangi herkesin hiç hiçbir iki ile ilgili ise itibaren itibariyle için işte kadar karşın katrilyon kendi kendilerine kendini kendisi kendisine kendisini kez ki kim kimden kime kimi kimse kırk milyar milyon mu mü mı nasıl ne neden nedenle nerde nerede nereye niye niçin o olan olarak oldu olduklarını olduğu olduğunu olmadı olmadığı olmak olması olmayan olmaz olsa olsun olup olur olursa oluyor on ona ondan onlar onlardan onları onların onu onun otuz oysa pek rağmen sadece sanki sekiz seksen sen senden seni senin siz sizden sizi sizin tarafından trilyon tüm var vardı ve veya ya yani yapacak yapmak yaptı yaptıkları yaptığı yaptığını yapılan yapılması yapıyor yedi yerine yetmiş yine yirmi yoksa yüz zaten çok çünkü öyle üzere üç şey şeyden şeyi şeyler şu şuna şunda şundan şunları şunu şöyle".split(" ")),r.Pipeline.registerFunction(r.tr.stopWordFilter,"stopWordFilter-tr")}}); \ No newline at end of file diff --git a/docs/assets/javascripts/lunr/min/lunr.vi.min.js b/docs/assets/javascripts/lunr/min/lunr.vi.min.js new file mode 100644 index 0000000..22aed28 --- /dev/null +++ b/docs/assets/javascripts/lunr/min/lunr.vi.min.js @@ -0,0 +1 @@ +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");e.vi=function(){this.pipeline.reset(),this.pipeline.add(e.vi.stopWordFilter,e.vi.trimmer)},e.vi.wordCharacters="[A-Za-ẓ̀͐́͑̉̃̓ÂâÊêÔôĂ-ăĐ-đƠ-ơƯ-ư]",e.vi.trimmer=e.trimmerSupport.generateTrimmer(e.vi.wordCharacters),e.Pipeline.registerFunction(e.vi.trimmer,"trimmer-vi"),e.vi.stopWordFilter=e.generateStopWordFilter("là cái nhưng mà".split(" "))}}); \ No newline at end of file diff --git a/docs/assets/javascripts/lunr/tinyseg.min.js b/docs/assets/javascripts/lunr/tinyseg.min.js new file mode 100644 index 0000000..302befb --- /dev/null +++ b/docs/assets/javascripts/lunr/tinyseg.min.js @@ -0,0 +1 @@ +!function(_,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():t()(_.lunr)}(this,(function(){return function(_){function t(){var _={"[一二三四五六七八九十百千万億兆]":"M","[一-龠々〆ヵヶ]":"H","[ぁ-ん]":"I","[ァ-ヴーア-ン゙ー]":"K","[a-zA-Za-zA-Z]":"A","[0-90-9]":"N"};for(var t in this.chartype_=[],_){var H=new RegExp(t);this.chartype_.push([H,_[t]])}return this.BIAS__=-332,this.BC1__={HH:6,II:2461,KH:406,OH:-1378},this.BC2__={AA:-3267,AI:2744,AN:-878,HH:-4070,HM:-1711,HN:4012,HO:3761,IA:1327,IH:-1184,II:-1332,IK:1721,IO:5492,KI:3831,KK:-8741,MH:-3132,MK:3334,OO:-2920},this.BC3__={HH:996,HI:626,HK:-721,HN:-1307,HO:-836,IH:-301,KK:2762,MK:1079,MM:4034,OA:-1652,OH:266},this.BP1__={BB:295,OB:304,OO:-125,UB:352},this.BP2__={BO:60,OO:-1762},this.BQ1__={BHH:1150,BHM:1521,BII:-1158,BIM:886,BMH:1208,BNH:449,BOH:-91,BOO:-2597,OHI:451,OIH:-296,OKA:1851,OKH:-1020,OKK:904,OOO:2965},this.BQ2__={BHH:118,BHI:-1159,BHM:466,BIH:-919,BKK:-1720,BKO:864,OHH:-1139,OHM:-181,OIH:153,UHI:-1146},this.BQ3__={BHH:-792,BHI:2664,BII:-299,BKI:419,BMH:937,BMM:8335,BNN:998,BOH:775,OHH:2174,OHM:439,OII:280,OKH:1798,OKI:-793,OKO:-2242,OMH:-2402,OOO:11699},this.BQ4__={BHH:-3895,BIH:3761,BII:-4654,BIK:1348,BKK:-1806,BMI:-3385,BOO:-12396,OAH:926,OHH:266,OHK:-2036,ONN:-973},this.BW1__={",と":660,",同":727,"B1あ":1404,"B1同":542,"、と":660,"、同":727,"」と":1682,"あっ":1505,"いう":1743,"いっ":-2055,"いる":672,"うし":-4817,"うん":665,"から":3472,"がら":600,"こう":-790,"こと":2083,"こん":-1262,"さら":-4143,"さん":4573,"した":2641,"して":1104,"すで":-3399,"そこ":1977,"それ":-871,"たち":1122,"ため":601,"った":3463,"つい":-802,"てい":805,"てき":1249,"でき":1127,"です":3445,"では":844,"とい":-4915,"とみ":1922,"どこ":3887,"ない":5713,"なっ":3015,"など":7379,"なん":-1113,"にし":2468,"には":1498,"にも":1671,"に対":-912,"の一":-501,"の中":741,"ませ":2448,"まで":1711,"まま":2600,"まる":-2155,"やむ":-1947,"よっ":-2565,"れた":2369,"れで":-913,"をし":1860,"を見":731,"亡く":-1886,"京都":2558,"取り":-2784,"大き":-2604,"大阪":1497,"平方":-2314,"引き":-1336,"日本":-195,"本当":-2423,"毎日":-2113,"目指":-724,"B1あ":1404,"B1同":542,"」と":1682},this.BW2__={"..":-11822,11:-669,"――":-5730,"−−":-13175,"いう":-1609,"うか":2490,"かし":-1350,"かも":-602,"から":-7194,"かれ":4612,"がい":853,"がら":-3198,"きた":1941,"くな":-1597,"こと":-8392,"この":-4193,"させ":4533,"され":13168,"さん":-3977,"しい":-1819,"しか":-545,"した":5078,"して":972,"しな":939,"その":-3744,"たい":-1253,"たた":-662,"ただ":-3857,"たち":-786,"たと":1224,"たは":-939,"った":4589,"って":1647,"っと":-2094,"てい":6144,"てき":3640,"てく":2551,"ては":-3110,"ても":-3065,"でい":2666,"でき":-1528,"でし":-3828,"です":-4761,"でも":-4203,"とい":1890,"とこ":-1746,"とと":-2279,"との":720,"とみ":5168,"とも":-3941,"ない":-2488,"なが":-1313,"など":-6509,"なの":2614,"なん":3099,"にお":-1615,"にし":2748,"にな":2454,"によ":-7236,"に対":-14943,"に従":-4688,"に関":-11388,"のか":2093,"ので":-7059,"のに":-6041,"のの":-6125,"はい":1073,"はが":-1033,"はず":-2532,"ばれ":1813,"まし":-1316,"まで":-6621,"まれ":5409,"めて":-3153,"もい":2230,"もの":-10713,"らか":-944,"らし":-1611,"らに":-1897,"りし":651,"りま":1620,"れた":4270,"れて":849,"れば":4114,"ろう":6067,"われ":7901,"を通":-11877,"んだ":728,"んな":-4115,"一人":602,"一方":-1375,"一日":970,"一部":-1051,"上が":-4479,"会社":-1116,"出て":2163,"分の":-7758,"同党":970,"同日":-913,"大阪":-2471,"委員":-1250,"少な":-1050,"年度":-8669,"年間":-1626,"府県":-2363,"手権":-1982,"新聞":-4066,"日新":-722,"日本":-7068,"日米":3372,"曜日":-601,"朝鮮":-2355,"本人":-2697,"東京":-1543,"然と":-1384,"社会":-1276,"立て":-990,"第に":-1612,"米国":-4268,"11":-669},this.BW3__={"あた":-2194,"あり":719,"ある":3846,"い.":-1185,"い。":-1185,"いい":5308,"いえ":2079,"いく":3029,"いた":2056,"いっ":1883,"いる":5600,"いわ":1527,"うち":1117,"うと":4798,"えと":1454,"か.":2857,"か。":2857,"かけ":-743,"かっ":-4098,"かに":-669,"から":6520,"かり":-2670,"が,":1816,"が、":1816,"がき":-4855,"がけ":-1127,"がっ":-913,"がら":-4977,"がり":-2064,"きた":1645,"けど":1374,"こと":7397,"この":1542,"ころ":-2757,"さい":-714,"さを":976,"し,":1557,"し、":1557,"しい":-3714,"した":3562,"して":1449,"しな":2608,"しま":1200,"す.":-1310,"す。":-1310,"する":6521,"ず,":3426,"ず、":3426,"ずに":841,"そう":428,"た.":8875,"た。":8875,"たい":-594,"たの":812,"たり":-1183,"たる":-853,"だ.":4098,"だ。":4098,"だっ":1004,"った":-4748,"って":300,"てい":6240,"てお":855,"ても":302,"です":1437,"でに":-1482,"では":2295,"とう":-1387,"とし":2266,"との":541,"とも":-3543,"どう":4664,"ない":1796,"なく":-903,"など":2135,"に,":-1021,"に、":-1021,"にし":1771,"にな":1906,"には":2644,"の,":-724,"の、":-724,"の子":-1e3,"は,":1337,"は、":1337,"べき":2181,"まし":1113,"ます":6943,"まっ":-1549,"まで":6154,"まれ":-793,"らし":1479,"られ":6820,"るる":3818,"れ,":854,"れ、":854,"れた":1850,"れて":1375,"れば":-3246,"れる":1091,"われ":-605,"んだ":606,"んで":798,"カ月":990,"会議":860,"入り":1232,"大会":2217,"始め":1681,"市":965,"新聞":-5055,"日,":974,"日、":974,"社会":2024,"カ月":990},this.TC1__={AAA:1093,HHH:1029,HHM:580,HII:998,HOH:-390,HOM:-331,IHI:1169,IOH:-142,IOI:-1015,IOM:467,MMH:187,OOI:-1832},this.TC2__={HHO:2088,HII:-1023,HMM:-1154,IHI:-1965,KKH:703,OII:-2649},this.TC3__={AAA:-294,HHH:346,HHI:-341,HII:-1088,HIK:731,HOH:-1486,IHH:128,IHI:-3041,IHO:-1935,IIH:-825,IIM:-1035,IOI:-542,KHH:-1216,KKA:491,KKH:-1217,KOK:-1009,MHH:-2694,MHM:-457,MHO:123,MMH:-471,NNH:-1689,NNO:662,OHO:-3393},this.TC4__={HHH:-203,HHI:1344,HHK:365,HHM:-122,HHN:182,HHO:669,HIH:804,HII:679,HOH:446,IHH:695,IHO:-2324,IIH:321,III:1497,IIO:656,IOO:54,KAK:4845,KKA:3386,KKK:3065,MHH:-405,MHI:201,MMH:-241,MMM:661,MOM:841},this.TQ1__={BHHH:-227,BHHI:316,BHIH:-132,BIHH:60,BIII:1595,BNHH:-744,BOHH:225,BOOO:-908,OAKK:482,OHHH:281,OHIH:249,OIHI:200,OIIH:-68},this.TQ2__={BIHH:-1401,BIII:-1033,BKAK:-543,BOOO:-5591},this.TQ3__={BHHH:478,BHHM:-1073,BHIH:222,BHII:-504,BIIH:-116,BIII:-105,BMHI:-863,BMHM:-464,BOMH:620,OHHH:346,OHHI:1729,OHII:997,OHMH:481,OIHH:623,OIIH:1344,OKAK:2792,OKHH:587,OKKA:679,OOHH:110,OOII:-685},this.TQ4__={BHHH:-721,BHHM:-3604,BHII:-966,BIIH:-607,BIII:-2181,OAAA:-2763,OAKK:180,OHHH:-294,OHHI:2446,OHHO:480,OHIH:-1573,OIHH:1935,OIHI:-493,OIIH:626,OIII:-4007,OKAK:-8156},this.TW1__={"につい":-4681,"東京都":2026},this.TW2__={"ある程":-2049,"いった":-1256,"ころが":-2434,"しょう":3873,"その後":-4430,"だって":-1049,"ていた":1833,"として":-4657,"ともに":-4517,"もので":1882,"一気に":-792,"初めて":-1512,"同時に":-8097,"大きな":-1255,"対して":-2721,"社会党":-3216},this.TW3__={"いただ":-1734,"してい":1314,"として":-4314,"につい":-5483,"にとっ":-5989,"に当た":-6247,"ので,":-727,"ので、":-727,"のもの":-600,"れから":-3752,"十二月":-2287},this.TW4__={"いう.":8576,"いう。":8576,"からな":-2348,"してい":2958,"たが,":1516,"たが、":1516,"ている":1538,"という":1349,"ました":5543,"ません":1097,"ようと":-4258,"よると":5865},this.UC1__={A:484,K:93,M:645,O:-505},this.UC2__={A:819,H:1059,I:409,M:3987,N:5775,O:646},this.UC3__={A:-1370,I:2311},this.UC4__={A:-2643,H:1809,I:-1032,K:-3450,M:3565,N:3876,O:6646},this.UC5__={H:313,I:-1238,K:-799,M:539,O:-831},this.UC6__={H:-506,I:-253,K:87,M:247,O:-387},this.UP1__={O:-214},this.UP2__={B:69,O:935},this.UP3__={B:189},this.UQ1__={BH:21,BI:-12,BK:-99,BN:142,BO:-56,OH:-95,OI:477,OK:410,OO:-2422},this.UQ2__={BH:216,BI:113,OK:1759},this.UQ3__={BA:-479,BH:42,BI:1913,BK:-7198,BM:3160,BN:6427,BO:14761,OI:-827,ON:-3212},this.UW1__={",":156,"、":156,"「":-463,"あ":-941,"う":-127,"が":-553,"き":121,"こ":505,"で":-201,"と":-547,"ど":-123,"に":-789,"の":-185,"は":-847,"も":-466,"や":-470,"よ":182,"ら":-292,"り":208,"れ":169,"を":-446,"ん":-137,"・":-135,"主":-402,"京":-268,"区":-912,"午":871,"国":-460,"大":561,"委":729,"市":-411,"日":-141,"理":361,"生":-408,"県":-386,"都":-718,"「":-463,"・":-135},this.UW2__={",":-829,"、":-829,"〇":892,"「":-645,"」":3145,"あ":-538,"い":505,"う":134,"お":-502,"か":1454,"が":-856,"く":-412,"こ":1141,"さ":878,"ざ":540,"し":1529,"す":-675,"せ":300,"そ":-1011,"た":188,"だ":1837,"つ":-949,"て":-291,"で":-268,"と":-981,"ど":1273,"な":1063,"に":-1764,"の":130,"は":-409,"ひ":-1273,"べ":1261,"ま":600,"も":-1263,"や":-402,"よ":1639,"り":-579,"る":-694,"れ":571,"を":-2516,"ん":2095,"ア":-587,"カ":306,"キ":568,"ッ":831,"三":-758,"不":-2150,"世":-302,"中":-968,"主":-861,"事":492,"人":-123,"会":978,"保":362,"入":548,"初":-3025,"副":-1566,"北":-3414,"区":-422,"大":-1769,"天":-865,"太":-483,"子":-1519,"学":760,"実":1023,"小":-2009,"市":-813,"年":-1060,"強":1067,"手":-1519,"揺":-1033,"政":1522,"文":-1355,"新":-1682,"日":-1815,"明":-1462,"最":-630,"朝":-1843,"本":-1650,"東":-931,"果":-665,"次":-2378,"民":-180,"気":-1740,"理":752,"発":529,"目":-1584,"相":-242,"県":-1165,"立":-763,"第":810,"米":509,"自":-1353,"行":838,"西":-744,"見":-3874,"調":1010,"議":1198,"込":3041,"開":1758,"間":-1257,"「":-645,"」":3145,"ッ":831,"ア":-587,"カ":306,"キ":568},this.UW3__={",":4889,1:-800,"−":-1723,"、":4889,"々":-2311,"〇":5827,"」":2670,"〓":-3573,"あ":-2696,"い":1006,"う":2342,"え":1983,"お":-4864,"か":-1163,"が":3271,"く":1004,"け":388,"げ":401,"こ":-3552,"ご":-3116,"さ":-1058,"し":-395,"す":584,"せ":3685,"そ":-5228,"た":842,"ち":-521,"っ":-1444,"つ":-1081,"て":6167,"で":2318,"と":1691,"ど":-899,"な":-2788,"に":2745,"の":4056,"は":4555,"ひ":-2171,"ふ":-1798,"へ":1199,"ほ":-5516,"ま":-4384,"み":-120,"め":1205,"も":2323,"や":-788,"よ":-202,"ら":727,"り":649,"る":5905,"れ":2773,"わ":-1207,"を":6620,"ん":-518,"ア":551,"グ":1319,"ス":874,"ッ":-1350,"ト":521,"ム":1109,"ル":1591,"ロ":2201,"ン":278,"・":-3794,"一":-1619,"下":-1759,"世":-2087,"両":3815,"中":653,"主":-758,"予":-1193,"二":974,"人":2742,"今":792,"他":1889,"以":-1368,"低":811,"何":4265,"作":-361,"保":-2439,"元":4858,"党":3593,"全":1574,"公":-3030,"六":755,"共":-1880,"円":5807,"再":3095,"分":457,"初":2475,"別":1129,"前":2286,"副":4437,"力":365,"動":-949,"務":-1872,"化":1327,"北":-1038,"区":4646,"千":-2309,"午":-783,"協":-1006,"口":483,"右":1233,"各":3588,"合":-241,"同":3906,"和":-837,"員":4513,"国":642,"型":1389,"場":1219,"外":-241,"妻":2016,"学":-1356,"安":-423,"実":-1008,"家":1078,"小":-513,"少":-3102,"州":1155,"市":3197,"平":-1804,"年":2416,"広":-1030,"府":1605,"度":1452,"建":-2352,"当":-3885,"得":1905,"思":-1291,"性":1822,"戸":-488,"指":-3973,"政":-2013,"教":-1479,"数":3222,"文":-1489,"新":1764,"日":2099,"旧":5792,"昨":-661,"時":-1248,"曜":-951,"最":-937,"月":4125,"期":360,"李":3094,"村":364,"東":-805,"核":5156,"森":2438,"業":484,"氏":2613,"民":-1694,"決":-1073,"法":1868,"海":-495,"無":979,"物":461,"特":-3850,"生":-273,"用":914,"町":1215,"的":7313,"直":-1835,"省":792,"県":6293,"知":-1528,"私":4231,"税":401,"立":-960,"第":1201,"米":7767,"系":3066,"約":3663,"級":1384,"統":-4229,"総":1163,"線":1255,"者":6457,"能":725,"自":-2869,"英":785,"見":1044,"調":-562,"財":-733,"費":1777,"車":1835,"軍":1375,"込":-1504,"通":-1136,"選":-681,"郎":1026,"郡":4404,"部":1200,"金":2163,"長":421,"開":-1432,"間":1302,"関":-1282,"雨":2009,"電":-1045,"非":2066,"駅":1620,"1":-800,"」":2670,"・":-3794,"ッ":-1350,"ア":551,"グ":1319,"ス":874,"ト":521,"ム":1109,"ル":1591,"ロ":2201,"ン":278},this.UW4__={",":3930,".":3508,"―":-4841,"、":3930,"。":3508,"〇":4999,"「":1895,"」":3798,"〓":-5156,"あ":4752,"い":-3435,"う":-640,"え":-2514,"お":2405,"か":530,"が":6006,"き":-4482,"ぎ":-3821,"く":-3788,"け":-4376,"げ":-4734,"こ":2255,"ご":1979,"さ":2864,"し":-843,"じ":-2506,"す":-731,"ず":1251,"せ":181,"そ":4091,"た":5034,"だ":5408,"ち":-3654,"っ":-5882,"つ":-1659,"て":3994,"で":7410,"と":4547,"な":5433,"に":6499,"ぬ":1853,"ね":1413,"の":7396,"は":8578,"ば":1940,"ひ":4249,"び":-4134,"ふ":1345,"へ":6665,"べ":-744,"ほ":1464,"ま":1051,"み":-2082,"む":-882,"め":-5046,"も":4169,"ゃ":-2666,"や":2795,"ょ":-1544,"よ":3351,"ら":-2922,"り":-9726,"る":-14896,"れ":-2613,"ろ":-4570,"わ":-1783,"を":13150,"ん":-2352,"カ":2145,"コ":1789,"セ":1287,"ッ":-724,"ト":-403,"メ":-1635,"ラ":-881,"リ":-541,"ル":-856,"ン":-3637,"・":-4371,"ー":-11870,"一":-2069,"中":2210,"予":782,"事":-190,"井":-1768,"人":1036,"以":544,"会":950,"体":-1286,"作":530,"側":4292,"先":601,"党":-2006,"共":-1212,"内":584,"円":788,"初":1347,"前":1623,"副":3879,"力":-302,"動":-740,"務":-2715,"化":776,"区":4517,"協":1013,"参":1555,"合":-1834,"和":-681,"員":-910,"器":-851,"回":1500,"国":-619,"園":-1200,"地":866,"場":-1410,"塁":-2094,"士":-1413,"多":1067,"大":571,"子":-4802,"学":-1397,"定":-1057,"寺":-809,"小":1910,"屋":-1328,"山":-1500,"島":-2056,"川":-2667,"市":2771,"年":374,"庁":-4556,"後":456,"性":553,"感":916,"所":-1566,"支":856,"改":787,"政":2182,"教":704,"文":522,"方":-856,"日":1798,"時":1829,"最":845,"月":-9066,"木":-485,"来":-442,"校":-360,"業":-1043,"氏":5388,"民":-2716,"気":-910,"沢":-939,"済":-543,"物":-735,"率":672,"球":-1267,"生":-1286,"産":-1101,"田":-2900,"町":1826,"的":2586,"目":922,"省":-3485,"県":2997,"空":-867,"立":-2112,"第":788,"米":2937,"系":786,"約":2171,"経":1146,"統":-1169,"総":940,"線":-994,"署":749,"者":2145,"能":-730,"般":-852,"行":-792,"規":792,"警":-1184,"議":-244,"谷":-1e3,"賞":730,"車":-1481,"軍":1158,"輪":-1433,"込":-3370,"近":929,"道":-1291,"選":2596,"郎":-4866,"都":1192,"野":-1100,"銀":-2213,"長":357,"間":-2344,"院":-2297,"際":-2604,"電":-878,"領":-1659,"題":-792,"館":-1984,"首":1749,"高":2120,"「":1895,"」":3798,"・":-4371,"ッ":-724,"ー":-11870,"カ":2145,"コ":1789,"セ":1287,"ト":-403,"メ":-1635,"ラ":-881,"リ":-541,"ル":-856,"ン":-3637},this.UW5__={",":465,".":-299,1:-514,E2:-32768,"]":-2762,"、":465,"。":-299,"「":363,"あ":1655,"い":331,"う":-503,"え":1199,"お":527,"か":647,"が":-421,"き":1624,"ぎ":1971,"く":312,"げ":-983,"さ":-1537,"し":-1371,"す":-852,"だ":-1186,"ち":1093,"っ":52,"つ":921,"て":-18,"で":-850,"と":-127,"ど":1682,"な":-787,"に":-1224,"の":-635,"は":-578,"べ":1001,"み":502,"め":865,"ゃ":3350,"ょ":854,"り":-208,"る":429,"れ":504,"わ":419,"を":-1264,"ん":327,"イ":241,"ル":451,"ン":-343,"中":-871,"京":722,"会":-1153,"党":-654,"務":3519,"区":-901,"告":848,"員":2104,"大":-1296,"学":-548,"定":1785,"嵐":-1304,"市":-2991,"席":921,"年":1763,"思":872,"所":-814,"挙":1618,"新":-1682,"日":218,"月":-4353,"査":932,"格":1356,"機":-1508,"氏":-1347,"田":240,"町":-3912,"的":-3149,"相":1319,"省":-1052,"県":-4003,"研":-997,"社":-278,"空":-813,"統":1955,"者":-2233,"表":663,"語":-1073,"議":1219,"選":-1018,"郎":-368,"長":786,"間":1191,"題":2368,"館":-689,"1":-514,"E2":-32768,"「":363,"イ":241,"ル":451,"ン":-343},this.UW6__={",":227,".":808,1:-270,E1:306,"、":227,"。":808,"あ":-307,"う":189,"か":241,"が":-73,"く":-121,"こ":-200,"じ":1782,"す":383,"た":-428,"っ":573,"て":-1014,"で":101,"と":-105,"な":-253,"に":-149,"の":-417,"は":-236,"も":-206,"り":187,"る":-135,"を":195,"ル":-673,"ン":-496,"一":-277,"中":201,"件":-800,"会":624,"前":302,"区":1792,"員":-1212,"委":798,"学":-960,"市":887,"広":-695,"後":535,"業":-697,"相":753,"社":-507,"福":974,"空":-822,"者":1811,"連":463,"郎":1082,"1":-270,"E1":306,"ル":-673,"ン":-496},this}t.prototype.ctype_=function(_){for(var t in this.chartype_)if(_.match(this.chartype_[t][0]))return this.chartype_[t][1];return"O"},t.prototype.ts_=function(_){return _||0},t.prototype.segment=function(_){if(null==_||null==_||""==_)return[];var t=[],H=["B3","B2","B1"],s=["O","O","O"],h=_.split("");for(K=0;K0&&(t.push(i),i="",N="B"),I=O,O=B,B=N,i+=H[K]}return t.push(i),t},_.TinySegmenter=t}})); \ No newline at end of file diff --git a/docs/assets/javascripts/vendor.c51dfa35.min.js b/docs/assets/javascripts/vendor.c51dfa35.min.js new file mode 100644 index 0000000..0f8ee22 --- /dev/null +++ b/docs/assets/javascripts/vendor.c51dfa35.min.js @@ -0,0 +1,31 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[1],[function(t,e,n){"use strict";n.d(e,"f",(function(){return i})),n.d(e,"a",(function(){return o})),n.d(e,"e",(function(){return s})),n.d(e,"g",(function(){return u})),n.d(e,"k",(function(){return c})),n.d(e,"h",(function(){return a})),n.d(e,"i",(function(){return f})),n.d(e,"j",(function(){return h})),n.d(e,"d",(function(){return l})),n.d(e,"b",(function(){return p})),n.d(e,"c",(function(){return d})); +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function i(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return(o=Object.assign||function(t){for(var e,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function f(){for(var t=[],e=0;e1||u(t,e)}))})}function u(t,e){try{(n=i[t](e)).value instanceof l?Promise.resolve(n.value.v).then(c,a):f(o[0][2],n)}catch(t){f(o[0][3],t)}var n}function c(t){u("next",t)}function a(t){u("throw",t)}function f(t,e){t(e),o.shift(),o.length&&u(o[0][0],o[0][1])}}function d(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=c(t),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise((function(r,i){(function(t,e,n,r){Promise.resolve(r).then((function(e){t({value:e,done:n})}),e)})(r,i,(e=t[n](e)).done,e.value)}))}}}},,,function(t,e,n){"use strict";n.d(e,"a",(function(){return f}));var r=n(0),i=n(15),o=n(40),s=n(8),u=n(32),c=n(12),a=n(23),f=function(t){function e(n,r,i){var s=t.call(this)||this;switch(s.syncErrorValue=null,s.syncErrorThrown=!1,s.syncErrorThrowable=!1,s.isStopped=!1,arguments.length){case 0:s.destination=o.a;break;case 1:if(!n){s.destination=o.a;break}if("object"==typeof n){n instanceof e?(s.syncErrorThrowable=n.syncErrorThrowable,s.destination=n,n.add(s)):(s.syncErrorThrowable=!0,s.destination=new h(s,n));break}default:s.syncErrorThrowable=!0,s.destination=new h(s,n,r,i)}return s}return Object(r.f)(e,t),e.prototype[u.a]=function(){return this},e.create=function(t,n,r){var i=new e(t,n,r);return i.syncErrorThrowable=!1,i},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},e.prototype._unsubscribeAndRecycle=function(){var t=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this},e}(s.a),h=function(t){function e(e,n,r,s){var u,c=t.call(this)||this;c._parentSubscriber=e;var a=c;return Object(i.a)(n)?u=n:n&&(u=n.next,r=n.error,s=n.complete,n!==o.a&&(a=Object.create(n),Object(i.a)(a.unsubscribe)&&c.add(a.unsubscribe.bind(a)),a.unsubscribe=c.unsubscribe.bind(c))),c._context=a,c._next=u,c._error=r,c._complete=s,c}return Object(r.f)(e,t),e.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;c.a.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}},e.prototype.error=function(t){if(!this.isStopped){var e=this._parentSubscriber,n=c.a.useDeprecatedSynchronousErrorHandling;if(this._error)n&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)n?(e.syncErrorValue=t,e.syncErrorThrown=!0):Object(a.a)(t),this.unsubscribe();else{if(this.unsubscribe(),n)throw t;Object(a.a)(t)}}},e.prototype.complete=function(){var t=this;if(!this.isStopped){var e=this._parentSubscriber;if(this._complete){var n=function(){return t._complete.call(t._context)};c.a.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?(this.__tryOrSetError(e,n),this.unsubscribe()):(this.__tryOrUnsub(n),this.unsubscribe())}else this.unsubscribe()}},e.prototype.__tryOrUnsub=function(t,e){try{t.call(this._context,e)}catch(t){if(this.unsubscribe(),c.a.useDeprecatedSynchronousErrorHandling)throw t;Object(a.a)(t)}},e.prototype.__tryOrSetError=function(t,e,n){if(!c.a.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,n)}catch(e){return c.a.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=e,t.syncErrorThrown=!0,!0):(Object(a.a)(e),!0)}return!1},e.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},e}(f)},,,function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n(3);var i=n(32),o=n(40);var s=n(17),u=n(44),c=n(12),a=n(0),f=function(){var t=this;this.resolve=null,this.reject=null,this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))};function h(t){return function(t){return Object(a.b)(this,arguments,(function(){var e,n,r,i,o,s,u,c;return Object(a.g)(this,(function(h){switch(h.label){case 0:e=[],n=[],r=!1,i=null,o=!1,s=t.subscribe({next:function(t){e.length>0?e.shift().resolve({value:t,done:!1}):n.push(t)},error:function(t){for(r=!0,i=t;e.length>0;)e.shift().reject(t)},complete:function(){for(o=!0;e.length>0;)e.shift().resolve({value:void 0,done:!0})}}),h.label=1;case 1:h.trys.push([1,16,17,18]),h.label=2;case 2:return n.length>0?[4,Object(a.d)(n.shift())]:[3,5];case 3:return[4,h.sent()];case 4:return h.sent(),[3,14];case 5:return o?[4,Object(a.d)(void 0)]:[3,7];case 6:return[2,h.sent()];case 7:if(!r)return[3,8];throw i;case 8:return u=new f,e.push(u),[4,Object(a.d)(u.promise)];case 9:return(c=h.sent()).done?[4,Object(a.d)(void 0)]:[3,11];case 10:return[2,h.sent()];case 11:return[4,Object(a.d)(c.value)];case 12:return[4,h.sent()];case 13:h.sent(),h.label=14;case 14:return[3,2];case 15:return[3,18];case 16:throw h.sent();case 17:return s.unsubscribe(),[7];case 18:return[2]}}))}))}(t)}var l=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var n=new t;return n.source=this,n.operator=e,n},t.prototype.subscribe=function(t,e,n){var s=this.operator,u=function(t,e,n){if(t){if(t instanceof r.a)return t;if(t[i.a])return t[i.a]()}return t||e||n?new r.a(t,e,n):new r.a(o.a)}(t,e,n);if(s?u.add(s.call(u,this.source)):u.add(this.source||c.a.useDeprecatedSynchronousErrorHandling&&!u.syncErrorThrowable?this._subscribe(u):this._trySubscribe(u)),c.a.useDeprecatedSynchronousErrorHandling&&u.syncErrorThrowable&&(u.syncErrorThrowable=!1,u.syncErrorThrown))throw u.syncErrorValue;return u},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){c.a.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),!function(t){for(;t;){var e=t,n=e.closed,i=e.destination,o=e.isStopped;if(n||o)return!1;t=i&&i instanceof r.a?i:null}return!0}(t)?console.warn(e):t.error(e)}},t.prototype.forEach=function(t,e){var n=this;return new(e=p(e))((function(e,r){var i;i=n.subscribe((function(e){try{t(e)}catch(t){r(t),i&&i.unsubscribe()}}),r,e)}))},t.prototype._subscribe=function(t){var e=this.source;return e&&e.subscribe(t)},t.prototype[s.a]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e0?this._next(e.shift()):0===this.active&&this.hasCompleted&&this.destination.complete()},e}(o.a),h=n(48);function l(t){return void 0===t&&(t=Number.POSITIVE_INFINITY),function t(e,n,r){return void 0===r&&(r=Number.POSITIVE_INFINITY),"function"==typeof n?function(i){return i.pipe(t((function(t,r){return Object(c.a)(e(t,r)).pipe(Object(u.a)((function(e,i){return n(t,e,r,i)})))}),r))}:("number"==typeof n&&(r=n),function(t){return t.lift(new a(e,r))})}(h.a,t)}},function(t,e,n){"use strict";n.d(e,"b",(function(){return s})),n.d(e,"a",(function(){return c}));var r=n(0),i=n(3),o=n(41);function s(t,e){return void 0===e&&(e=0),function(n){return n.lift(new u(t,e))}}var u=function(){function t(t,e){void 0===e&&(e=0),this.scheduler=t,this.delay=e}return t.prototype.call=function(t,e){return e.subscribe(new c(t,this.scheduler,this.delay))},t}(),c=function(t){function e(e,n,r){void 0===r&&(r=0);var i=t.call(this,e)||this;return i.scheduler=n,i.delay=r,i}return Object(r.f)(e,t),e.dispatch=function(t){var e=t.notification,n=t.destination;e.observe(n),this.unsubscribe()},e.prototype.scheduleMessage=function(t){this.destination.add(this.scheduler.schedule(e.dispatch,this.delay,new a(t,this.destination)))},e.prototype._next=function(t){this.scheduleMessage(o.a.createNext(t))},e.prototype._error=function(t){this.scheduleMessage(o.a.createError(t)),this.unsubscribe()},e.prototype._complete=function(){this.scheduleMessage(o.a.createComplete()),this.unsubscribe()},e}(i.a),a=function(t,e){this.notification=t,this.destination=e}},,function(t,e,n){ +/*! + * clipboard.js v2.0.6 + * https://clipboardjs.com/ + * + * Licensed MIT © Zeno Rocha + */ +var r;r=function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=6)}([function(t,e){t.exports=function(t){var e;if("SELECT"===t.nodeName)t.focus(),e=t.value;else if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName){var n=t.hasAttribute("readonly");n||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),n||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var r=window.getSelection(),i=document.createRange();i.selectNodeContents(t),r.removeAllRanges(),r.addRange(i),e=r.toString()}return e}},function(t,e){function n(){}n.prototype={on:function(t,e,n){var r=this.e||(this.e={});return(r[t]||(r[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){var r=this;function i(){r.off(t,i),e.apply(n,arguments)}return i._=e,this.on(t,i,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),r=0,i=n.length;r0&&void 0!==arguments[0]?arguments[0]:{};this.action=t.action,this.container=t.container,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function(){var t=this,e="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return t.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[e?"right":"left"]="-9999px";var n=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=n+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.container.appendChild(this.fakeElem),this.selectedText=i()(this.fakeElem),this.copyText()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=i()(this.target),this.copyText()}},{key:"copyText",value:function(){var t=void 0;try{t=document.execCommand(this.action)}catch(e){t=!1}this.handleResult(t)}},{key:"handleResult",value:function(t){this.emitter.emit(t?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),document.activeElement.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=t,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(t){if(void 0!==t){if(!t||"object"!==(void 0===t?"undefined":o(t))||1!==t.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&t.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=t}},get:function(){return this._target}}]),t}(),c=n(1),a=n.n(c),f=n(2),h=n.n(f),l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p=function(){function t(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof t.action?t.action:this.defaultAction,this.target="function"==typeof t.target?t.target:this.defaultTarget,this.text="function"==typeof t.text?t.text:this.defaultText,this.container="object"===l(t.container)?t.container:document.body}},{key:"listenClick",value:function(t){var e=this;this.listener=h()(t,"click",(function(t){return e.onClick(t)}))}},{key:"onClick",value:function(t){var e=t.delegateTarget||t.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new u({action:this.action(e),target:this.target(e),text:this.text(e),container:this.container,trigger:e,emitter:this})}},{key:"defaultAction",value:function(t){return b("action",t)}},{key:"defaultTarget",value:function(t){var e=b("target",t);if(e)return document.querySelector(e)}},{key:"defaultText",value:function(t){return b("text",t)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],e="string"==typeof t?[t]:t,n=!!document.queryCommandSupported;return e.forEach((function(t){n=n&&!!document.queryCommandSupported(t)})),n}}]),e}(a.a);function b(t,e){var n="data-clipboard-"+t;if(e.hasAttribute(n))return e.getAttribute(n)}e.default=d}]).default},t.exports=r()},function(t,e,n){"use strict";n.d(e,"a",(function(){return f}));var r=n(0),i=n(26),o=n(25),s=n(11),u=n(10),c=n(35),a={};function f(){for(var t=[],e=0;e0},t.prototype.connect_=function(){r&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),u?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},t.prototype.disconnect_=function(){r&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},t.prototype.onTransitionEnd_=function(t){var e=t.propertyName,n=void 0===e?"":e;s.some((function(t){return!!~n.indexOf(t)}))&&this.refresh()},t.getInstance=function(){return this.instance_||(this.instance_=new t),this.instance_},t.instance_=null,t}(),a=function(t,e){for(var n=0,r=Object.keys(e);n0},t}(),g="undefined"!=typeof WeakMap?new WeakMap:new n,O=function t(e){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=c.getInstance(),r=new _(e,n,this);g.set(this,r)};["observe","unobserve","disconnect"].forEach((function(t){O.prototype[t]=function(){var e;return(e=g.get(this))[t].apply(e,arguments)}}));var x=void 0!==i.ResizeObserver?i.ResizeObserver:O;e.a=x}).call(this,n(59))},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));var r=n(6),i=n(36),o=n(18);function s(t){return new r.a((function(e){var n;try{n=t()}catch(t){return void e.error(t)}return(n?Object(i.a)(n):o.a).subscribe(e)}))}},function(t,e,n){"use strict"; +/*! + * escape-html + * Copyright(c) 2012-2013 TJ Holowaychuk + * Copyright(c) 2015 Andreas Lubbe + * Copyright(c) 2015 Tiancheng "Timothy" Gu + * MIT Licensed + */var r=/["'&<>]/;t.exports=function(t){var e,n=""+t,i=r.exec(n);if(!i)return n;var o="",s=0,u=0;for(s=i.index;s0?t.prototype.schedule.call(this,e,n):(this.delay=n,this.state=e,this.scheduler.flush(this),this)},e.prototype.execute=function(e,n){return n>0||this.closed?t.prototype.execute.call(this,e,n):this._execute(e,n)},e.prototype.requestAsyncId=function(e,n,r){return void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0?t.prototype.requestAsyncId.call(this,e,n,r):e.flush(this)},e}(n(38).a),s=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(r.f)(e,t),e}(n(37).a))(o),u=n(8),c=n(55),a=n(19),f=n(47),h=function(t){function e(e,n,r){void 0===e&&(e=Number.POSITIVE_INFINITY),void 0===n&&(n=Number.POSITIVE_INFINITY);var i=t.call(this)||this;return i.scheduler=r,i._events=[],i._infiniteTimeWindow=!1,i._bufferSize=e<1?1:e,i._windowTime=n<1?1:n,n===Number.POSITIVE_INFINITY?(i._infiniteTimeWindow=!0,i.next=i.nextInfiniteTimeWindow):i.next=i.nextTimeWindow,i}return Object(r.f)(e,t),e.prototype.nextInfiniteTimeWindow=function(e){var n=this._events;n.push(e),n.length>this._bufferSize&&n.shift(),t.prototype.next.call(this,e)},e.prototype.nextTimeWindow=function(e){this._events.push(new l(this._getNow(),e)),this._trimBufferThenGetEvents(),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){var e,n=this._infiniteTimeWindow,r=n?this._events:this._trimBufferThenGetEvents(),i=this.scheduler,o=r.length;if(this.closed)throw new a.a;if(this.isStopped||this.hasError?e=u.a.EMPTY:(this.observers.push(t),e=new f.a(this,t)),i&&t.add(t=new c.a(t,i)),n)for(var s=0;se&&(o=Math.max(o,i-e)),o>0&&r.splice(0,o),r},e}(i.a),l=function(t,e){this.time=t,this.value=e}},function(t,e,n){"use strict";var r=n(22);function i(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var o=Object.prototype.toString,s=function(){return"[object Arguments]"===o.call(arguments)?function(t){return"[object Arguments]"===o.call(t)}:function(t){return i("callee",t)}}(),u=!{toString:null}.propertyIsEnumerable("toString"),c=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],a=function(){return arguments.propertyIsEnumerable("length")}(),f=function(t,e){for(var n=0;n=0;)i(e=c[n],t)&&!f(r,e)&&(r[r.length]=e),n-=1;return r})):Object(r.a)((function(t){return Object(t)!==t?[]:Object.keys(t)}));e.a=h},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(0),i=n(3),o=n(16),s=n(15);function u(t,e,n){return function(r){return r.lift(new c(t,e,n))}}var c=function(){function t(t,e,n){this.nextOrObserver=t,this.error=e,this.complete=n}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.nextOrObserver,this.error,this.complete))},t}(),a=function(t){function e(e,n,r,i){var u=t.call(this,e)||this;return u._tapNext=o.a,u._tapError=o.a,u._tapComplete=o.a,u._tapError=r||o.a,u._tapComplete=i||o.a,Object(s.a)(n)?(u._context=u,u._tapNext=n):n&&(u._context=n,u._tapNext=n.next||o.a,u._tapError=n.error||o.a,u._tapComplete=n.complete||o.a),u}return Object(r.f)(e,t),e.prototype._next=function(t){try{this._tapNext.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.next(t)},e.prototype._error=function(t){try{this._tapError.call(this._context,t)}catch(t){return void this.destination.error(t)}this.destination.error(t)},e.prototype._complete=function(){try{this._tapComplete.call(this._context)}catch(t){return void this.destination.error(t)}return this.destination.complete()},e}(i.a)},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(0),i=n(3);function o(t,e){var n=!1;return arguments.length>=2&&(n=!0),function(r){return r.lift(new s(t,e,n))}}var s=function(){function t(t,e,n){void 0===n&&(n=!1),this.accumulator=t,this.seed=e,this.hasSeed=n}return t.prototype.call=function(t,e){return e.subscribe(new u(t,this.accumulator,this.seed,this.hasSeed))},t}(),u=function(t){function e(e,n,r,i){var o=t.call(this,e)||this;return o.accumulator=n,o._state=r,o._hasState=i,o.index=0,o}return Object(r.f)(e,t),e.prototype._next=function(t){var e=this.destination;if(this._hasState){var n=this.index++,r=void 0;try{r=this.accumulator(this._state,t,n)}catch(t){return void e.error(t)}this._state=r,e.next(r)}else this._state=t,this._hasState=!0,e.next(t)},e}(i.a)},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));var r=n(0),i=n(3),o=n(8);function s(t){return function(e){return e.lift(new u(t))}}var u=function(){function t(t){this.callback=t}return t.prototype.call=function(t,e){return e.subscribe(new c(t,this.callback))},t}(),c=function(t){function e(e,n){var r=t.call(this,e)||this;return r.add(new o.a(n)),r}return Object(r.f)(e,t),e}(i.a)},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(0),i=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.scheduler=e,r.work=n,r}return Object(r.f)(e,t),e.prototype.requestAsyncId=function(e,n,r){return void 0===r&&(r=0),null!==r&&r>0?t.prototype.requestAsyncId.call(this,e,n,r):(e.actions.push(this),e.scheduled||(e.scheduled=requestAnimationFrame((function(){return e.flush(void 0)}))))},e.prototype.recycleAsyncId=function(e,n,r){if(void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,n,r);0===e.actions.length&&(cancelAnimationFrame(n),e.scheduled=void 0)},e}(n(38).a),o=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(r.f)(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,n=this.actions,r=-1,i=n.length;t=t||n.shift();do{if(e=t.execute(t.state,t.delay))break}while(++r0){var s=o.indexOf(n);-1!==s&&o.splice(s,1)}},e.prototype.notifyComplete=function(){},e.prototype._next=function(t){if(0===this.toRespond.length){var e=Object(r.j)([t],this.values);this.project?this._tryProject(e):this.destination.next(e)}},e.prototype._tryProject=function(t){var e;try{e=this.project.apply(this,t)}catch(t){return void this.destination.error(t)}this.destination.next(e)},e}(i.a)},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(0),i=n(3);function o(t,e){return void 0===e&&(e=null),function(n){return n.lift(new s(t,e))}}var s=function(){function t(t,e){this.bufferSize=t,this.startBufferEvery=e,this.subscriberClass=e&&t!==e?c:u}return t.prototype.call=function(t,e){return e.subscribe(new this.subscriberClass(t,this.bufferSize,this.startBufferEvery))},t}(),u=function(t){function e(e,n){var r=t.call(this,e)||this;return r.bufferSize=n,r.buffer=[],r}return Object(r.f)(e,t),e.prototype._next=function(t){var e=this.buffer;e.push(t),e.length==this.bufferSize&&(this.destination.next(e),this.buffer=[])},e.prototype._complete=function(){var e=this.buffer;e.length>0&&this.destination.next(e),t.prototype._complete.call(this)},e}(i.a),c=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.bufferSize=n,i.startBufferEvery=r,i.buffers=[],i.count=0,i}return Object(r.f)(e,t),e.prototype._next=function(t){var e=this.bufferSize,n=this.startBufferEvery,r=this.buffers,i=this.count;this.count++,i%n==0&&r.push([]);for(var o=r.length;o--;){var s=r[o];s.push(t),s.length===e&&(r.splice(o,1),this.destination.next(s))}},e.prototype._complete=function(){for(var e=this.buffers,n=this.destination;e.length>0;){var r=e.shift();r.length>0&&n.next(r)}t.prototype._complete.call(this)},e}(i.a)},function(t,e,n){"use strict";n.d(e,"a",(function(){return c}));var r=n(39),i=n(54);function o(){return Object(i.a)(1)}function s(){for(var t=[],e=0;e1?r.next(Array.prototype.slice.call(arguments)):r.next(t)}),r,n)}))}},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(0),i=n(3);function o(t){return function(e){return e.lift(new s(t))}}var s=function(){function t(t){this.value=t}return t.prototype.call=function(t,e){return e.subscribe(new u(t,this.value))},t}(),u=function(t){function e(e,n){var r=t.call(this,e)||this;return r.value=n,r}return Object(r.f)(e,t),e.prototype._next=function(t){this.destination.next(this.value)},e}(i.a)},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(6),i=n(26),o=n(54),s=n(35);function u(){for(var t=[],e=0;e1&&"number"==typeof t[t.length-1]&&(n=t.pop())):"number"==typeof c&&(n=t.pop()),!u&&1===t.length&&t[0]instanceof r.a?t[0]:Object(o.a)(n)(Object(s.a)(t,u))}},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(6),i=n(25),o=n(15),s=n(9);function u(t,e,n){return n?u(t,e).pipe(Object(s.a)((function(t){return Object(i.a)(t)?n.apply(void 0,t):n(t)}))):new r.a((function(n){var r,i=function(){for(var t=[],e=0;ethis.total&&this.destination.next(t)},e}(i.a)},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(0),i=n(11),o=n(29),s=n(10);function u(t){return function(e){var n=new c(t),r=e.lift(n);return n.caught=r}}var c=function(){function t(t){this.selector=t}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.selector,this.caught))},t}(),a=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.selector=n,i.caught=r,i}return Object(r.f)(e,t),e.prototype.error=function(e){if(!this.isStopped){var n=void 0;try{n=this.selector(e,this.caught)}catch(e){return void t.prototype.error.call(this,e)}this._unsubscribeAndRecycle();var r=new o.a(this,void 0,void 0);this.add(r);var i=Object(s.a)(this,n,void 0,void 0,r);i!==r&&this.add(i)}},e}(i.a)},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));var r=n(0),i=n(11),o=n(10);function s(t){return function(e){return e.lift(new u(t))}}var u=function(){function t(t){this.notifier=t}return t.prototype.call=function(t,e){var n=new c(t),r=e.subscribe(n);return r.add(Object(o.a)(n,this.notifier)),r},t}(),c=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.hasValue=!1,e}return Object(r.f)(e,t),e.prototype._next=function(t){this.value=t,this.hasValue=!0},e.prototype.notifyNext=function(t,e,n,r,i){this.emitValue()},e.prototype.notifyComplete=function(){this.emitValue()},e.prototype.emitValue=function(){this.hasValue&&(this.hasValue=!1,this.destination.next(this.value))},e}(i.a)},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));var r=n(0),i=n(3),o=n(52);function s(t,e){return void 0===e&&(e=o.a),function(n){return n.lift(new u(t,e))}}var u=function(){function t(t,e){this.dueTime=t,this.scheduler=e}return t.prototype.call=function(t,e){return e.subscribe(new c(t,this.dueTime,this.scheduler))},t}(),c=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.dueTime=n,i.scheduler=r,i.debouncedSubscription=null,i.lastValue=null,i.hasValue=!1,i}return Object(r.f)(e,t),e.prototype._next=function(t){this.clearDebounce(),this.lastValue=t,this.hasValue=!0,this.add(this.debouncedSubscription=this.scheduler.schedule(a,this.dueTime,this))},e.prototype._complete=function(){this.debouncedNext(),this.destination.complete()},e.prototype.debouncedNext=function(){if(this.clearDebounce(),this.hasValue){var t=this.lastValue;this.lastValue=null,this.hasValue=!1,this.destination.next(t)}},e.prototype.clearDebounce=function(){var t=this.debouncedSubscription;null!==t&&(this.remove(t),t.unsubscribe(),this.debouncedSubscription=null)},e}(i.a);function a(t){t.debouncedNext()}},function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(74),i=n(18);function o(t,e,n){return void 0===e&&(e=i.a),void 0===n&&(n=i.a),Object(r.a)((function(){return t()?e:n}))}},function(t,e,n){"use strict";var r=n(22),i=n(77),o=Object(r.a)((function(t){for(var e=Object(i.a)(t),n=e.length,r=[],o=0;o1)this.connection=null;else{var n=this.connection,r=t._connection;this.connection=null,!r||n&&r!==n||r.unsubscribe()}}else this.connection=null},e}(s.a),l=function(t){function e(e,n){var r=t.call(this)||this;return r.source=e,r.subjectFactory=n,r._refCount=0,r._isComplete=!1,r}return Object(r.f)(e,t),e.prototype._subscribe=function(t){return this.getSubject().subscribe(t)},e.prototype.getSubject=function(){var t=this._subject;return t&&!t.isStopped||(this._subject=this.subjectFactory()),this._subject},e.prototype.connect=function(){var t=this._connection;return t||(this._isComplete=!1,(t=this._connection=new u.a).add(this.source.subscribe(new d(this.getSubject(),this))),t.closed&&(this._connection=null,t=u.a.EMPTY)),t},e.prototype.refCount=function(){return c()(this)},e}(o.a),p={operator:{value:null},_refCount:{value:0,writable:!0},_subject:{value:null,writable:!0},_connection:{value:null,writable:!0},_subscribe:{value:(a=l.prototype)._subscribe},_isComplete:{value:a._isComplete,writable:!0},getSubject:{value:a.getSubject},connect:{value:a.connect},refCount:{value:a.refCount}},d=function(t){function e(e,n){var r=t.call(this,e)||this;return r.connectable=n,r}return Object(r.f)(e,t),e.prototype._error=function(e){this._unsubscribe(),t.prototype._error.call(this,e)},e.prototype._complete=function(){this.connectable._isComplete=!0,this._unsubscribe(),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._connection;t._refCount=0,t._subject=null,t._connection=null,e&&e.unsubscribe()}},e}(i.b),b=(function(){function t(t){this.connectable=t}t.prototype.call=function(t,e){var n=this.connectable;n._refCount++;var r=new b(t,n),i=e.subscribe(r);return r.closed||(r.connection=n.connect()),i}}(),function(t){function e(e,n){var r=t.call(this,e)||this;return r.connectable=n,r}return Object(r.f)(e,t),e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._refCount;if(e<=0)this.connection=null;else if(t._refCount=e-1,e>1)this.connection=null;else{var n=this.connection,r=t._connection;this.connection=null,!r||n&&r!==n||r.unsubscribe()}}else this.connection=null},e}(s.a));var v=function(){function t(t,e){this.subjectFactory=t,this.selector=e}return t.prototype.call=function(t,e){var n=this.selector,r=this.subjectFactory(),i=n(r).subscribe(t);return i.add(e.subscribe(r)),i},t}();function y(){return new i.a}function m(){return function(t){return c()((e=y,function(t){var r;if(r="function"==typeof e?e:function(){return e},"function"==typeof n)return t.lift(new v(r,n));var i=Object.create(t,p);return i.source=t,i.subjectFactory=r,i})(t));var e,n}}},function(t,e,n){"use strict";var r=n(22);function i(t){return t}var o=Object(r.a)(i);e.a=o},function(t,e,n){"use strict";n.d(e,"a",(function(){return g}));var r=n(0),i=n(13),o=n(6),s=n(3),u=n(9);function c(t,e){return new b({method:"GET",url:t,headers:e})}function a(t,e,n){return new b({method:"POST",url:t,body:e,headers:n})}function f(t,e){return new b({method:"DELETE",url:t,headers:e})}function h(t,e,n){return new b({method:"PUT",url:t,body:e,headers:n})}function l(t,e,n){return new b({method:"PATCH",url:t,body:e,headers:n})}var p=Object(u.a)((function(t,e){return t.response}));function d(t,e){return p(new b({method:"GET",url:t,responseType:"json",headers:e}))}var b=function(t){function e(e){var n=t.call(this)||this,r={async:!0,createXHR:function(){return this.crossDomain?function(){if(i.a.XMLHttpRequest)return new i.a.XMLHttpRequest;if(i.a.XDomainRequest)return new i.a.XDomainRequest;throw new Error("CORS is not supported by your browser")}():function(){if(i.a.XMLHttpRequest)return new i.a.XMLHttpRequest;var t=void 0;try{for(var e=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],n=0;n<3;n++)try{if(t=e[n],new i.a.ActiveXObject(t))break}catch(t){}return new i.a.ActiveXObject(t)}catch(t){throw new Error("XMLHttpRequest is not supported by your browser")}}()},crossDomain:!0,withCredentials:!1,headers:{},method:"GET",responseType:"json",timeout:0};if("string"==typeof e)r.url=e;else for(var o in e)e.hasOwnProperty(o)&&(r[o]=e[o]);return n.request=r,n}var n;return Object(r.f)(e,t),e.prototype._subscribe=function(t){return new v(t,this.request)},e.create=((n=function(t){return new e(t)}).get=c,n.post=a,n.delete=f,n.put=h,n.patch=l,n.getJSON=d,n),e}(o.a),v=function(t){function e(e,n){var r=t.call(this,e)||this;r.request=n,r.done=!1;var o=n.headers=n.headers||{};return n.crossDomain||r.getHeader(o,"X-Requested-With")||(o["X-Requested-With"]="XMLHttpRequest"),r.getHeader(o,"Content-Type")||i.a.FormData&&n.body instanceof i.a.FormData||void 0===n.body||(o["Content-Type"]="application/x-www-form-urlencoded; charset=UTF-8"),n.body=r.serializeBody(n.body,r.getHeader(n.headers,"Content-Type")),r.send(),r}return Object(r.f)(e,t),e.prototype.next=function(t){this.done=!0;var e,n=this.xhr,r=this.request,i=this.destination;try{e=new y(t,n,r)}catch(t){return i.error(t)}i.next(e)},e.prototype.send=function(){var t=this.request,e=this.request,n=e.user,r=e.method,i=e.url,o=e.async,s=e.password,u=e.headers,c=e.body;try{var a=this.xhr=t.createXHR();this.setupEvents(a,t),n?a.open(r,i,o,n,s):a.open(r,i,o),o&&(a.timeout=t.timeout,a.responseType=t.responseType),"withCredentials"in a&&(a.withCredentials=!!t.withCredentials),this.setHeaders(a,u),c?a.send(c):a.send()}catch(t){this.error(t)}},e.prototype.serializeBody=function(t,e){if(!t||"string"==typeof t)return t;if(i.a.FormData&&t instanceof i.a.FormData)return t;if(e){var n=e.indexOf(";");-1!==n&&(e=e.substring(0,n))}switch(e){case"application/x-www-form-urlencoded":return Object.keys(t).map((function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])})).join("&");case"application/json":return JSON.stringify(t);default:return t}},e.prototype.setHeaders=function(t,e){for(var n in e)e.hasOwnProperty(n)&&t.setRequestHeader(n,e[n])},e.prototype.getHeader=function(t,e){for(var n in t)if(n.toLowerCase()===e.toLowerCase())return t[n]},e.prototype.setupEvents=function(t,e){var n=e.progressSubscriber;function r(t){var e,n=r,i=n.subscriber,o=n.progressSubscriber,s=n.request;o&&o.error(t);try{e=new _(this,s)}catch(t){e=t}i.error(e)}if(t.ontimeout=r,r.request=e,r.subscriber=this,r.progressSubscriber=n,t.upload&&"withCredentials"in t){var o,s;if(n)o=function(t){o.progressSubscriber.next(t)},i.a.XDomainRequest?t.onprogress=o:t.upload.onprogress=o,o.progressSubscriber=n;s=function(t){var e,n=s,r=n.progressSubscriber,i=n.subscriber,o=n.request;r&&r.error(t);try{e=new m("ajax error",this,o)}catch(t){e=t}i.error(e)},t.onerror=s,s.request=e,s.subscriber=this,s.progressSubscriber=n}function u(t){}function c(t){var e=c,n=e.subscriber,r=e.progressSubscriber,i=e.request;if(4===this.readyState){var o=1223===this.status?204:this.status,s="text"===this.responseType?this.response||this.responseText:this.response;if(0===o&&(o=s?200:0),o<400)r&&r.complete(),n.next(t),n.complete();else{r&&r.error(t);var u=void 0;try{u=new m("ajax error "+o,this,i)}catch(t){u=t}n.error(u)}}}t.onreadystatechange=u,u.subscriber=this,u.progressSubscriber=n,u.request=e,t.onload=c,c.subscriber=this,c.progressSubscriber=n,c.request=e},e.prototype.unsubscribe=function(){var e=this.done,n=this.xhr;!e&&n&&4!==n.readyState&&"function"==typeof n.abort&&n.abort(),t.prototype.unsubscribe.call(this)},e}(s.a),y=function(t,e,n){this.originalEvent=t,this.xhr=e,this.request=n,this.status=e.status,this.responseType=e.responseType||n.responseType,this.response=w(this.responseType,e)},m=function(){function t(t,e,n){return Error.call(this),this.message=t,this.name="AjaxError",this.xhr=e,this.request=n,this.status=e.status,this.responseType=e.responseType||n.responseType,this.response=w(this.responseType,e),this}return t.prototype=Object.create(Error.prototype),t}();function w(t,e){switch(t){case"json":return function(t){return"response"in t?t.responseType?t.response:JSON.parse(t.response||t.responseText||"null"):JSON.parse(t.responseText||"null")}(e);case"xml":return e.responseXML;case"text":default:return"response"in e?e.response:e.responseText}}var _=function(){function t(t,e){return m.call(this,"ajax timeout",t,e),this.name="AjaxTimeoutError",this}return t.prototype=Object.create(m.prototype),t}(),g=b.create},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(0),i=n(52);var o=n(3),s=n(41);function u(t,e){void 0===e&&(e=i.a);var n,r=(n=t)instanceof Date&&!isNaN(+n)?+t-e.now():Math.abs(t);return function(t){return t.lift(new c(r,e))}}var c=function(){function t(t,e){this.delay=t,this.scheduler=e}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.delay,this.scheduler))},t}(),a=function(t){function e(e,n,r){var i=t.call(this,e)||this;return i.delay=n,i.scheduler=r,i.queue=[],i.active=!1,i.errored=!1,i}return Object(r.f)(e,t),e.dispatch=function(t){for(var e=t.source,n=e.queue,r=t.scheduler,i=t.destination;n.length>0&&n[0].time-r.now()<=0;)n.shift().notification.observe(i);if(n.length>0){var o=Math.max(0,n[0].time-r.now());this.schedule(t,o)}else e.isStopped?(e.destination.complete(),e.active=!1):(this.unsubscribe(),e.active=!1)},e.prototype._schedule=function(t){this.active=!0,this.destination.add(t.schedule(e.dispatch,this.delay,{source:this,destination:this.destination,scheduler:t}))},e.prototype.scheduleNotification=function(t){if(!0!==this.errored){var e=this.scheduler,n=new f(e.now()+this.delay,t);this.queue.push(n),!1===this.active&&this._schedule(e)}},e.prototype._next=function(t){this.scheduleNotification(s.a.createNext(t))},e.prototype._error=function(t){this.errored=!0,this.queue=[],this.destination.error(t),this.unsubscribe()},e.prototype._complete=function(){0===this.queue.length&&this.destination.complete(),this.unsubscribe()},e}(o.a),f=function(t,e){this.time=t,this.notification=e}},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(0),i=n(3),o=function(){function t(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return t.prototype=Object.create(Error.prototype),t}(),s=n(18);function u(t){return function(e){return 0===t?s.a:e.lift(new c(t))}}var c=function(){function t(t){if(this.total=t,this.total<0)throw new o}return t.prototype.call=function(t,e){return e.subscribe(new a(t,this.total))},t}(),a=function(t){function e(e,n){var r=t.call(this,e)||this;return r.total=n,r.count=0,r}return Object(r.f)(e,t),e.prototype._next=function(t){var e=this.total,n=++this.count;n<=e&&(this.destination.next(t),n===e&&(this.destination.complete(),this.unsubscribe()))},e}(i.a)}]]); +//# sourceMappingURL=vendor.c51dfa35.min.js.map \ No newline at end of file diff --git a/docs/assets/javascripts/vendor.c51dfa35.min.js.map b/docs/assets/javascripts/vendor.c51dfa35.min.js.map new file mode 100644 index 0000000..e885968 --- /dev/null +++ b/docs/assets/javascripts/vendor.c51dfa35.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///./node_modules/tslib/tslib.es6.js","webpack:///./node_modules/rxjs/dist/esm5/internal/Subscriber.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/deferred.js","webpack:///./node_modules/rxjs/dist/esm5/internal/asyncIteratorFrom.js","webpack:///./node_modules/rxjs/dist/esm5/internal/Observable.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/toSubscriber.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/canReportError.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js","webpack:///./node_modules/rxjs/dist/esm5/internal/Subscription.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/map.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/subscribeToResult.js","webpack:///./node_modules/rxjs/dist/esm5/internal/OuterSubscriber.js","webpack:///./node_modules/rxjs/dist/esm5/internal/config.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/root.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/isFunction.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/noop.js","webpack:///./node_modules/rxjs/dist/esm5/internal/symbol/observable.js","webpack:///./node_modules/rxjs/dist/esm5/internal/observable/empty.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/ObjectUnsubscribedError.js","webpack:///./node_modules/ramda/es/internal/_isPlaceholder.js","webpack:///./node_modules/ramda/es/internal/_curry1.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/hostReportError.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/isArray.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/isScheduler.js","webpack:///./node_modules/rxjs/dist/esm5/internal/Subject.js","webpack:///./node_modules/rxjs/dist/esm5/internal/symbol/iterator.js","webpack:///./node_modules/rxjs/dist/esm5/internal/InnerSubscriber.js","webpack:///./node_modules/rxjs/dist/esm5/internal/symbol/rxSubscriber.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/switchMap.js","webpack:///./node_modules/rxjs/dist/esm5/internal/scheduled/scheduleArray.js","webpack:///./node_modules/rxjs/dist/esm5/internal/observable/fromArray.js","webpack:///./node_modules/rxjs/dist/esm5/internal/scheduled/scheduled.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/isInteropObservable.js","webpack:///./node_modules/rxjs/dist/esm5/internal/scheduled/scheduleObservable.js","webpack:///./node_modules/rxjs/dist/esm5/internal/scheduled/schedulePromise.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/isIterable.js","webpack:///./node_modules/rxjs/dist/esm5/internal/scheduled/scheduleIterable.js","webpack:///./node_modules/rxjs/dist/esm5/internal/scheduled/scheduleAsyncIterable.js","webpack:///./node_modules/rxjs/dist/esm5/internal/observable/from.js","webpack:///./node_modules/rxjs/dist/esm5/internal/Scheduler.js","webpack:///./node_modules/rxjs/dist/esm5/internal/scheduler/AsyncScheduler.js","webpack:///./node_modules/rxjs/dist/esm5/internal/scheduler/AsyncAction.js","webpack:///./node_modules/rxjs/dist/esm5/internal/scheduler/Action.js","webpack:///./node_modules/rxjs/dist/esm5/internal/observable/of.js","webpack:///./node_modules/rxjs/dist/esm5/internal/Observer.js","webpack:///./node_modules/rxjs/dist/esm5/internal/Notification.js","webpack:///./node_modules/rxjs/dist/esm5/internal/observable/throwError.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/pipe.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/distinctUntilChanged.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/isObject.js","webpack:///./node_modules/rxjs/dist/esm5/internal/SubjectSubscription.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/identity.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/subscribeToArray.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/isArrayLike.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/isPromise.js","webpack:///./node_modules/rxjs/dist/esm5/internal/scheduler/async.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/subscribeToAsyncIterable.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/subscribeTo.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/subscribeToObservable.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/subscribeToPromise.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/subscribeToIterable.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/mergeMap.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/mergeAll.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/observeOn.js","webpack:///./node_modules/clipboard/dist/clipboard.js","webpack:///./node_modules/rxjs/dist/esm5/internal/observable/combineLatest.js","webpack:///(webpack)/buildin/global.js","webpack:///./node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js","webpack:///./node_modules/rxjs/dist/esm5/internal/observable/defer.js","webpack:///./node_modules/escape-html/index.js","webpack:///./node_modules/rxjs/dist/esm5/internal/scheduler/QueueAction.js","webpack:///./node_modules/rxjs/dist/esm5/internal/scheduler/queue.js","webpack:///./node_modules/rxjs/dist/esm5/internal/scheduler/QueueScheduler.js","webpack:///./node_modules/rxjs/dist/esm5/internal/ReplaySubject.js","webpack:///./node_modules/ramda/es/internal/_has.js","webpack:///./node_modules/ramda/es/internal/_isArguments.js","webpack:///./node_modules/ramda/es/keys.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/tap.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/scan.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/finalize.js","webpack:///./node_modules/rxjs/dist/esm5/internal/scheduler/AnimationFrameAction.js","webpack:///./node_modules/rxjs/dist/esm5/internal/scheduler/animationFrame.js","webpack:///./node_modules/rxjs/dist/esm5/internal/scheduler/AnimationFrameScheduler.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/shareReplay.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/distinctUntilKeyChanged.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/withLatestFrom.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/bufferCount.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/concatAll.js","webpack:///./node_modules/rxjs/dist/esm5/internal/observable/concat.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/startWith.js","webpack:///./node_modules/ramda/es/reverse.js","webpack:///./node_modules/ramda/es/internal/_isString.js","webpack:///./node_modules/rxjs/dist/esm5/internal/observable/fromEvent.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/mapTo.js","webpack:///./node_modules/rxjs/dist/esm5/internal/observable/merge.js","webpack:///./node_modules/rxjs/dist/esm5/internal/observable/fromEventPattern.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/filter.js","webpack:///./node_modules/rxjs/dist/esm5/internal/BehaviorSubject.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/pluck.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/throttle.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/switchMapTo.js","webpack:///./node_modules/rxjs/dist/esm5/internal/observable/never.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/skip.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/catchError.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/sample.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/debounceTime.js","webpack:///./node_modules/rxjs/dist/esm5/internal/observable/iif.js","webpack:///./node_modules/ramda/es/values.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/refCount.js","webpack:///./node_modules/rxjs/dist/esm5/internal/observable/ConnectableObservable.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/multicast.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/share.js","webpack:///./node_modules/ramda/es/internal/_identity.js","webpack:///./node_modules/ramda/es/identity.js","webpack:///./node_modules/rxjs/dist/esm5/internal/observable/dom/AjaxObservable.js","webpack:///./node_modules/rxjs/dist/esm5/internal/observable/dom/ajax.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/delay.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/isDate.js","webpack:///./node_modules/rxjs/dist/esm5/internal/util/ArgumentOutOfRangeError.js","webpack:///./node_modules/rxjs/dist/esm5/internal/operators/take.js"],"names":["extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","hasOwnProperty","__extends","__","this","constructor","prototype","create","__assign","assign","t","s","i","n","arguments","length","call","apply","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","__generator","body","f","y","g","_","label","sent","trys","ops","verb","Symbol","iterator","v","op","TypeError","pop","push","__values","o","m","__read","r","ar","error","__spread","concat","__spreadArrays","il","k","a","j","jl","__await","__asyncGenerator","asyncIterator","q","resume","fulfill","settle","shift","__asyncValues","Subscriber","_super","destinationOrNext","complete","_this","syncErrorValue","syncErrorThrown","syncErrorThrowable","isStopped","destination","add","SafeSubscriber","subscriber","_next","err","_error","_complete","unsubscribe","closed","_unsubscribeAndRecycle","_parentOrParents","_parentSubscriber","observerOrNext","context","bind","_context","useDeprecatedSynchronousErrorHandling","__tryOrSetError","__tryOrUnsub","wrappedComplete","fn","parent","Error","_unsubscribe","Deferred","promise","asyncIteratorFrom","source","deferreds","values","hasError","completed","subs","_a","subscribe","undefined","coroutine","Observable","_isScalar","_subscribe","lift","operator","observable","sink","nextOrObserver","rxSubscriber","toSubscriber","config","_trySubscribe","observer","closed_1","canReportError","console","warn","forEach","promiseCtor","getPromiseCtor","subscription","pipe","operations","_i","toPromise","x","UnsubscriptionError","UnsubscriptionErrorImpl","errors","message","map","toString","join","name","Subscription","_subscriptions","empty","remove","index","isFunction","flattenUnsubscriptionErrors","isArray","len","sub","isObject","teardown","EMPTY","tmp","indexOf","subscriptions","subscriptionIndex","splice","reduce","errs","project","MapOperator","MapSubscriber","count","subscribeToResult","outerSubscriber","outerValue","outerIndex","innerSubscriber","OuterSubscriber","notifyNext","innerValue","innerIndex","innerSub","notifyError","notifyComplete","_enable_super_gross_mode_that_will_cause_bad_things","stack","log","__window","window","__self","self","WorkerGlobalScope","_root","global","noop","ObjectUnsubscribedError","ObjectUnsubscribedErrorImpl","_isPlaceholder","_curry1","f1","hostReportError","setTimeout","isScheduler","schedule","SubjectSubscriber","Subject","observers","thrownError","subject","AnonymousSubject","copy","slice","asObservable","InnerSubscriber","Math","random","switchMap","resultSelector","ii","SwitchMapOperator","SwitchMapSubscriber","_innerSub","innerSubscription","scheduleArray","input","scheduler","fromArray","scheduled","isInteropObservable","scheduleObservable","isPromise","schedulePromise","isArrayLike","isIterable","return","scheduleIterable","scheduleAsyncIterable","from","subscribeTo","Scheduler","SchedulerAction","now","work","delay","state","Date","AsyncScheduler","delegate","actions","active","flush","action","execute","AsyncAction","pending","id","recycleAsyncId","requestAsyncId","setInterval","clearInterval","_execute","errored","errorValue","Action","of","args","NotificationKind","dispatch","Notification","kind","hasValue","observe","do","accept","toObservable","createNext","undefinedValueNotification","createError","createComplete","completeNotification","fns","pipeFromArray","prev","distinctUntilChanged","compare","keySelector","DistinctUntilChangedOperator","DistinctUntilChangedSubscriber","hasKey","key","SubjectSubscription","subscriberIndex","identity","subscribeToArray","array","async","subscribeToAsyncIterable","asyncIterable","asyncIterable_1","asyncIterable_1_1","e_1","e_1_1","_b","process","catch","obj","obs","iterable","item","MergeMapOperator","concurrent","Number","POSITIVE_INFINITY","MergeMapSubscriber","hasCompleted","buffer","_tryNext","ish","mergeAll","mergeMap","observeOn","ObserveOnOperator","ObserveOnSubscriber","arg","notification","scheduleMessage","ObserveOnMessage","factory","modules","installedModules","__webpack_require__","moduleId","exports","module","l","c","getter","defineProperty","enumerable","get","toStringTag","mode","__esModule","ns","object","property","element","selectedText","nodeName","focus","isReadOnly","hasAttribute","setAttribute","select","setSelectionRange","removeAttribute","selection","getSelection","range","document","createRange","selectNodeContents","removeAllRanges","addRange","E","on","callback","ctx","once","listener","off","emit","data","evtArr","evts","liveEvents","TinyEmitter","is","target","type","string","node","addEventListener","destroy","removeEventListener","listenNode","nodeList","listenNodeList","selector","listenSelector","HTMLElement","nodeType","String","closest","_delegate","useCapture","listenerFn","delegateTarget","elements","querySelectorAll","Element","matches","proto","matchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector","webkitMatchesSelector","parentNode","__webpack_exports__","src_select","select_default","_typeof","_createClass","defineProperties","props","descriptor","configurable","writable","Constructor","protoProps","staticProps","clipboard_action","ClipboardAction","options","instance","_classCallCheck","resolveOptions","initSelection","container","emitter","text","trigger","selectFake","selectTarget","isRTL","documentElement","getAttribute","removeFake","fakeHandlerCallback","fakeHandler","fakeElem","createElement","style","fontSize","border","padding","margin","position","yPosition","pageYOffset","scrollTop","top","appendChild","copyText","removeChild","succeeded","execCommand","handleResult","clearSelection","activeElement","blur","set","_action","_target","tiny_emitter","tiny_emitter_default","listen","listen_default","clipboard_typeof","clipboard_createClass","clipboard_Clipboard","_Emitter","Clipboard","clipboard_classCallCheck","ReferenceError","_possibleConstructorReturn","getPrototypeOf","listenClick","subClass","superClass","_inherits","defaultAction","defaultTarget","defaultText","_this2","onClick","currentTarget","clipboardAction","getAttributeValue","querySelector","support","queryCommandSupported","suffix","attribute","NONE","combineLatest","observables","CombineLatestOperator","CombineLatestSubscriber","toRespond","unused","oldVal","_tryResultSelector","Function","MapShim","Map","getIndex","arr","some","entry","class_1","__entries__","delete","entries","has","clear","isBrowser","global$1","requestAnimationFrame$1","requestAnimationFrame","transitionKeys","mutationObserverSupported","MutationObserver","ResizeObserverController","connected_","mutationEventsAdded_","mutationsObserver_","observers_","onTransitionEnd_","refresh","leadingCall","trailingCall","lastCallTime","resolvePending","proxy","timeoutCallback","timeStamp","throttle","addObserver","connect_","removeObserver","disconnect_","updateObservers_","activeObservers","filter","gatherActive","hasActive","broadcastActive","attributes","childList","characterData","subtree","disconnect","propertyName","getInstance","instance_","defineConfigurable","keys","getWindowOf","ownerDocument","defaultView","emptyRect","createRectInit","toFloat","parseFloat","getBordersSize","styles","positions","size","getHTMLElementContentRect","clientWidth","clientHeight","getComputedStyle","paddings","positions_1","getPaddings","horizPad","left","right","vertPad","bottom","width","height","boxSizing","round","isDocumentElement","vertScrollbar","horizScrollbar","abs","isSVGGraphicsElement","SVGGraphicsElement","SVGElement","getBBox","getContentRect","bbox","getSVGContentRect","ResizeObservation","broadcastWidth","broadcastHeight","contentRect_","isActive","rect","broadcastRect","ResizeObserverEntry","rectInit","Constr","contentRect","DOMRectReadOnly","ResizeObserverSPI","controller","callbackCtx","activeObservations_","observations_","callback_","controller_","callbackCtx_","observations","unobserve","clearActive","observation","WeakMap","ResizeObserver","method","defer","observableFactory","matchHtmlRegExp","escape","str","match","exec","html","lastIndex","charCodeAt","substring","QueueAction","queue","QueueScheduler","ReplaySubject","bufferSize","windowTime","_events","_infiniteTimeWindow","_bufferSize","_windowTime","nextInfiniteTimeWindow","nextTimeWindow","ReplayEvent","_getNow","_trimBufferThenGetEvents","eventsCount","spliceCount","time","max","_has","prop","hasEnumBug","propertyIsEnumerable","nonEnumerableProps","hasArgsEnumBug","contains","list","idx","nIdx","ks","checkArgsLength","tap","DoOperator","TapSubscriber","_tapNext","_tapError","_tapComplete","scan","accumulator","seed","hasSeed","ScanOperator","ScanSubscriber","_state","_hasState","finalize","FinallyOperator","FinallySubscriber","AnimationFrameAction","cancelAnimationFrame","animationFrame","AnimationFrameScheduler","shareReplay","configOrBufferSize","refCount","_c","useRefCount","isComplete","shareReplayOperator","distinctUntilKeyChanged","withLatestFrom","WithLatestFromOperator","WithLatestFromSubscriber","found","_tryProject","bufferCount","startBufferEvery","BufferCountOperator","subscriberClass","BufferSkipCountSubscriber","BufferCountSubscriber","buffers","concatAll","startWith","split","reverse","fromEvent","eventName","setupSubscription","sourceObj","handler","isEventTarget","source_1","isJQueryStyleEventEmitter","source_2","addListener","removeListener","isNodeStyleEventEmitter","source_3","mapTo","MapToOperator","MapToSubscriber","merge","last","fromEventPattern","addHandler","removeHandler","retValue","predicate","FilterOperator","FilterSubscriber","BehaviorSubject","_value","getValue","pluck","properties","currentProp","defaultThrottleConfig","leading","trailing","durationSelector","ThrottleOperator","ThrottleSubscriber","_leading","_trailing","_sendValue","_hasValue","_throttled","send","duration","tryDurationSelector","throttlingDone","switchMapTo","innerObservable","NEVER","skip","SkipOperator","total","SkipSubscriber","catchError","CatchOperator","caught","CatchSubscriber","err2","sample","notifier","SampleOperator","sampleSubscriber","SampleSubscriber","emitValue","debounceTime","dueTime","DebounceTimeOperator","DebounceTimeSubscriber","debouncedSubscription","lastValue","clearDebounce","dispatchNext","debouncedNext","iif","condition","trueResult","falseResult","vals","RefCountOperator","connectableProto","connectable","_refCount","refCounter","connection","connect","RefCountSubscriber","sharedConnection","_connection","ConnectableObservable","subjectFactory","_isComplete","getSubject","_subject","connectableObservableDescriptor","ConnectableSubscriber","MulticastOperator","shareSubjectFactory","share","subjectOrSubjectFactory","_identity","ajaxGet","url","headers","ajaxPost","ajaxDelete","ajaxPut","ajaxPatch","mapResponse","response","ajaxGetJSON","responseType","AjaxObservable","urlOrRequest","request","createXHR","crossDomain","root","XMLHttpRequest","XDomainRequest","getCORSRequest","progId","progIds","ActiveXObject","getXMLHttpRequest","withCredentials","timeout","post","put","patch","getJSON","AjaxSubscriber","getHeader","FormData","serializeBody","xhr","AjaxResponse","user","password","setupEvents","open","setHeaders","contentType","splitIndex","encodeURIComponent","JSON","stringify","setRequestHeader","headerName","toLowerCase","progressSubscriber","xhrTimeout","AjaxTimeoutError","ontimeout","upload","xhrProgress_1","xhrError_1","onprogress","AjaxError","onerror","xhrReadyStateChange","xhrLoad","readyState","status_1","status","responseText","onreadystatechange","onload","abort","originalEvent","parseXhrResponse","AjaxErrorImpl","parse","parseJson","responseXML","AjaxTimeoutErrorImpl","ajax","delayFor","isNaN","DelayOperator","DelaySubscriber","delay_1","_schedule","scheduleNotification","DelayMessage","ArgumentOutOfRangeError","ArgumentOutOfRangeErrorImpl","take","TakeOperator","TakeSubscriber"],"mappings":"sFAAA;;;;;;;;;;;;;;;AAgBA,IAAIA,EAAgB,SAASC,EAAGC,GAI5B,OAHAF,EAAgBG,OAAOC,gBAClB,CAAEC,UAAW,cAAgBC,OAAS,SAAUL,EAAGC,GAAKD,EAAEI,UAAYH,IACvE,SAAUD,EAAGC,GAAK,IAAK,IAAIK,KAAKL,EAAOA,EAAEM,eAAeD,KAAIN,EAAEM,GAAKL,EAAEK,MACpDN,EAAGC,IAGrB,SAASO,EAAUR,EAAGC,GAEzB,SAASQ,IAAOC,KAAKC,YAAcX,EADnCD,EAAcC,EAAGC,GAEjBD,EAAEY,UAAkB,OAANX,EAAaC,OAAOW,OAAOZ,IAAMQ,EAAGG,UAAYX,EAAEW,UAAW,IAAIH,GAG5E,IAAIK,EAAW,WAQlB,OAPAA,EAAWZ,OAAOa,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAIZ,KADTW,EAAIG,UAAUF,GACOhB,OAAOU,UAAUL,eAAee,KAAKL,EAAGX,KAAIU,EAAEV,GAAKW,EAAEX,IAE9E,OAAOU,IAEKO,MAAMb,KAAMU,YA8BzB,SAASI,EAAUC,EAASC,EAAYC,EAAGC,GAE9C,OAAO,IAAKD,IAAMA,EAAIE,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKN,EAAUO,KAAKF,IAAW,MAAOG,GAAKL,EAAOK,IACpF,SAASC,EAASJ,GAAS,IAAMC,EAAKN,EAAiB,MAAEK,IAAW,MAAOG,GAAKL,EAAOK,IACvF,SAASF,EAAKI,GAJlB,IAAeL,EAIaK,EAAOC,KAAOT,EAAQQ,EA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G,WACrDo4B,EARuB,G,QCI3B,SAASC,EAAKttB,GACjB,OAAO,SAAUnE,GACb,OAAc,IAAVmE,EACO,IAGAnE,EAAOa,KAAK,IAAI,EAAasD,KAIhD,IAAI,EAAgB,WAChB,SAASutB,EAAaxI,GAElB,GADAhwB,KAAKgwB,MAAQA,EACThwB,KAAKgwB,MAAQ,EACb,MAAM,IAAIqI,EAMlB,OAHAG,EAAat4B,UAAUU,KAAO,SAAUyE,EAAYyB,GAChD,OAAOA,EAAOO,UAAU,IAAI,EAAehC,EAAYrF,KAAKgwB,SAEzDwI,EAVQ,GAYf,EAAkB,SAAU9zB,GAE5B,SAAS+zB,EAAevzB,EAAa8qB,GACjC,IAAInrB,EAAQH,EAAO9D,KAAKZ,KAAMkF,IAAgBlF,KAG9C,OAFA6E,EAAMmrB,MAAQA,EACdnrB,EAAMoG,MAAQ,EACPpG,EAaX,OAlBA,YAAU4zB,EAAgB/zB,GAO1B+zB,EAAev4B,UAAUoF,MAAQ,SAAU/D,GACvC,IAAIyuB,EAAQhwB,KAAKgwB,MACb/kB,IAAUjL,KAAKiL,MACfA,GAAS+kB,IACThwB,KAAKkF,YAAYzD,KAAKF,GAClB0J,IAAU+kB,IACVhwB,KAAKkF,YAAYN,WACjB5E,KAAK0F,iBAIV+yB,EAnBU,CAoBnBh0B,EAAA","file":"assets/javascripts/vendor.c51dfa35.min.js","sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","import { __extends } from \"tslib\";\nimport { isFunction } from './util/isFunction';\nimport { empty as emptyObserver } from './Observer';\nimport { Subscription } from './Subscription';\nimport { rxSubscriber as rxSubscriberSymbol } from '../internal/symbol/rxSubscriber';\nimport { config } from './config';\nimport { hostReportError } from './util/hostReportError';\nvar Subscriber = (function (_super) {\n __extends(Subscriber, _super);\n function Subscriber(destinationOrNext, error, complete) {\n var _this = _super.call(this) || this;\n _this.syncErrorValue = null;\n _this.syncErrorThrown = false;\n _this.syncErrorThrowable = false;\n _this.isStopped = false;\n switch (arguments.length) {\n case 0:\n _this.destination = emptyObserver;\n break;\n case 1:\n if (!destinationOrNext) {\n _this.destination = emptyObserver;\n break;\n }\n if (typeof destinationOrNext === 'object') {\n if (destinationOrNext instanceof Subscriber) {\n _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;\n _this.destination = destinationOrNext;\n destinationOrNext.add(_this);\n }\n else {\n _this.syncErrorThrowable = true;\n _this.destination = new SafeSubscriber(_this, destinationOrNext);\n }\n break;\n }\n default:\n _this.syncErrorThrowable = true;\n _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);\n break;\n }\n return _this;\n }\n Subscriber.prototype[rxSubscriberSymbol] = function () { return this; };\n Subscriber.create = function (next, error, complete) {\n var subscriber = new Subscriber(next, error, complete);\n subscriber.syncErrorThrowable = false;\n return subscriber;\n };\n Subscriber.prototype.next = function (value) {\n if (!this.isStopped) {\n this._next(value);\n }\n };\n Subscriber.prototype.error = function (err) {\n if (!this.isStopped) {\n this.isStopped = true;\n this._error(err);\n }\n };\n Subscriber.prototype.complete = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this._complete();\n }\n };\n Subscriber.prototype.unsubscribe = function () {\n if (this.closed) {\n return;\n }\n this.isStopped = true;\n _super.prototype.unsubscribe.call(this);\n };\n Subscriber.prototype._next = function (value) {\n this.destination.next(value);\n };\n Subscriber.prototype._error = function (err) {\n this.destination.error(err);\n this.unsubscribe();\n };\n Subscriber.prototype._complete = function () {\n this.destination.complete();\n this.unsubscribe();\n };\n Subscriber.prototype._unsubscribeAndRecycle = function () {\n var _parentOrParents = this._parentOrParents;\n this._parentOrParents = null;\n this.unsubscribe();\n this.closed = false;\n this.isStopped = false;\n this._parentOrParents = _parentOrParents;\n return this;\n };\n return Subscriber;\n}(Subscription));\nexport { Subscriber };\nvar SafeSubscriber = (function (_super) {\n __extends(SafeSubscriber, _super);\n function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {\n var _this = _super.call(this) || this;\n _this._parentSubscriber = _parentSubscriber;\n var next;\n var context = _this;\n if (isFunction(observerOrNext)) {\n next = observerOrNext;\n }\n else if (observerOrNext) {\n next = observerOrNext.next;\n error = observerOrNext.error;\n complete = observerOrNext.complete;\n if (observerOrNext !== emptyObserver) {\n context = Object.create(observerOrNext);\n if (isFunction(context.unsubscribe)) {\n _this.add(context.unsubscribe.bind(context));\n }\n context.unsubscribe = _this.unsubscribe.bind(_this);\n }\n }\n _this._context = context;\n _this._next = next;\n _this._error = error;\n _this._complete = complete;\n return _this;\n }\n SafeSubscriber.prototype.next = function (value) {\n if (!this.isStopped && this._next) {\n var _parentSubscriber = this._parentSubscriber;\n if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {\n this.__tryOrUnsub(this._next, value);\n }\n else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {\n this.unsubscribe();\n }\n }\n };\n SafeSubscriber.prototype.error = function (err) {\n if (!this.isStopped) {\n var _parentSubscriber = this._parentSubscriber;\n var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;\n if (this._error) {\n if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {\n this.__tryOrUnsub(this._error, err);\n this.unsubscribe();\n }\n else {\n this.__tryOrSetError(_parentSubscriber, this._error, err);\n this.unsubscribe();\n }\n }\n else if (!_parentSubscriber.syncErrorThrowable) {\n this.unsubscribe();\n if (useDeprecatedSynchronousErrorHandling) {\n throw err;\n }\n hostReportError(err);\n }\n else {\n if (useDeprecatedSynchronousErrorHandling) {\n _parentSubscriber.syncErrorValue = err;\n _parentSubscriber.syncErrorThrown = true;\n }\n else {\n hostReportError(err);\n }\n this.unsubscribe();\n }\n }\n };\n SafeSubscriber.prototype.complete = function () {\n var _this = this;\n if (!this.isStopped) {\n var _parentSubscriber = this._parentSubscriber;\n if (this._complete) {\n var wrappedComplete = function () { return _this._complete.call(_this._context); };\n if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {\n this.__tryOrUnsub(wrappedComplete);\n this.unsubscribe();\n }\n else {\n this.__tryOrSetError(_parentSubscriber, wrappedComplete);\n this.unsubscribe();\n }\n }\n else {\n this.unsubscribe();\n }\n }\n };\n SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {\n try {\n fn.call(this._context, value);\n }\n catch (err) {\n this.unsubscribe();\n if (config.useDeprecatedSynchronousErrorHandling) {\n throw err;\n }\n else {\n hostReportError(err);\n }\n }\n };\n SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {\n if (!config.useDeprecatedSynchronousErrorHandling) {\n throw new Error('bad call');\n }\n try {\n fn.call(this._context, value);\n }\n catch (err) {\n if (config.useDeprecatedSynchronousErrorHandling) {\n parent.syncErrorValue = err;\n parent.syncErrorThrown = true;\n return true;\n }\n else {\n hostReportError(err);\n return true;\n }\n }\n return false;\n };\n SafeSubscriber.prototype._unsubscribe = function () {\n var _parentSubscriber = this._parentSubscriber;\n this._context = null;\n this._parentSubscriber = null;\n _parentSubscriber.unsubscribe();\n };\n return SafeSubscriber;\n}(Subscriber));\nexport { SafeSubscriber };\n//# sourceMappingURL=Subscriber.js.map","var Deferred = (function () {\n function Deferred() {\n var _this = this;\n this.resolve = null;\n this.reject = null;\n this.promise = new Promise(function (a, b) {\n _this.resolve = a;\n _this.reject = b;\n });\n }\n return Deferred;\n}());\nexport { Deferred };\n//# sourceMappingURL=deferred.js.map","import { __asyncGenerator, __await, __generator } from \"tslib\";\nimport { Deferred } from './util/deferred';\nexport function asyncIteratorFrom(source) {\n return coroutine(source);\n}\nfunction coroutine(source) {\n return __asyncGenerator(this, arguments, function coroutine_1() {\n var deferreds, values, hasError, error, completed, subs, d, result, err_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n deferreds = [];\n values = [];\n hasError = false;\n error = null;\n completed = false;\n subs = source.subscribe({\n next: function (value) {\n if (deferreds.length > 0) {\n deferreds.shift().resolve({ value: value, done: false });\n }\n else {\n values.push(value);\n }\n },\n error: function (err) {\n hasError = true;\n error = err;\n while (deferreds.length > 0) {\n deferreds.shift().reject(err);\n }\n },\n complete: function () {\n completed = true;\n while (deferreds.length > 0) {\n deferreds.shift().resolve({ value: undefined, done: true });\n }\n },\n });\n _a.label = 1;\n case 1:\n _a.trys.push([1, 16, 17, 18]);\n _a.label = 2;\n case 2:\n if (!true) return [3, 15];\n if (!(values.length > 0)) return [3, 5];\n return [4, __await(values.shift())];\n case 3: return [4, _a.sent()];\n case 4:\n _a.sent();\n return [3, 14];\n case 5:\n if (!completed) return [3, 7];\n return [4, __await(void 0)];\n case 6: return [2, _a.sent()];\n case 7:\n if (!hasError) return [3, 8];\n throw error;\n case 8:\n d = new Deferred();\n deferreds.push(d);\n return [4, __await(d.promise)];\n case 9:\n result = _a.sent();\n if (!result.done) return [3, 11];\n return [4, __await(void 0)];\n case 10: return [2, _a.sent()];\n case 11: return [4, __await(result.value)];\n case 12: return [4, _a.sent()];\n case 13:\n _a.sent();\n _a.label = 14;\n case 14: return [3, 2];\n case 15: return [3, 18];\n case 16:\n err_1 = _a.sent();\n throw err_1;\n case 17:\n subs.unsubscribe();\n return [7];\n case 18: return [2];\n }\n });\n });\n}\n//# sourceMappingURL=asyncIteratorFrom.js.map","import { canReportError } from './util/canReportError';\nimport { toSubscriber } from './util/toSubscriber';\nimport { observable as Symbol_observable } from './symbol/observable';\nimport { pipeFromArray } from './util/pipe';\nimport { config } from './config';\nimport { asyncIteratorFrom } from './asyncIteratorFrom';\nvar Observable = (function () {\n function Observable(subscribe) {\n this._isScalar = false;\n if (subscribe) {\n this._subscribe = subscribe;\n }\n }\n Observable.prototype.lift = function (operator) {\n var observable = new Observable();\n observable.source = this;\n observable.operator = operator;\n return observable;\n };\n Observable.prototype.subscribe = function (observerOrNext, error, complete) {\n var operator = this.operator;\n var sink = toSubscriber(observerOrNext, error, complete);\n if (operator) {\n sink.add(operator.call(sink, this.source));\n }\n else {\n sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?\n this._subscribe(sink) :\n this._trySubscribe(sink));\n }\n if (config.useDeprecatedSynchronousErrorHandling) {\n if (sink.syncErrorThrowable) {\n sink.syncErrorThrowable = false;\n if (sink.syncErrorThrown) {\n throw sink.syncErrorValue;\n }\n }\n }\n return sink;\n };\n Observable.prototype._trySubscribe = function (sink) {\n try {\n return this._subscribe(sink);\n }\n catch (err) {\n if (config.useDeprecatedSynchronousErrorHandling) {\n sink.syncErrorThrown = true;\n sink.syncErrorValue = err;\n }\n if (canReportError(sink)) {\n sink.error(err);\n }\n else {\n console.warn(err);\n }\n }\n };\n Observable.prototype.forEach = function (next, promiseCtor) {\n var _this = this;\n promiseCtor = getPromiseCtor(promiseCtor);\n return new promiseCtor(function (resolve, reject) {\n var subscription;\n subscription = _this.subscribe(function (value) {\n try {\n next(value);\n }\n catch (err) {\n reject(err);\n if (subscription) {\n subscription.unsubscribe();\n }\n }\n }, reject, resolve);\n });\n };\n Observable.prototype._subscribe = function (subscriber) {\n var source = this.source;\n return source && source.subscribe(subscriber);\n };\n Observable.prototype[Symbol_observable] = function () {\n return this;\n };\n Observable.prototype.pipe = function () {\n var operations = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n operations[_i] = arguments[_i];\n }\n if (operations.length === 0) {\n return this;\n }\n return pipeFromArray(operations)(this);\n };\n Observable.prototype.toPromise = function (promiseCtor) {\n var _this = this;\n promiseCtor = getPromiseCtor(promiseCtor);\n return new promiseCtor(function (resolve, reject) {\n var value;\n _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });\n });\n };\n Observable.create = function (subscribe) {\n return new Observable(subscribe);\n };\n return Observable;\n}());\nexport { Observable };\nfunction getPromiseCtor(promiseCtor) {\n if (!promiseCtor) {\n promiseCtor = config.Promise || Promise;\n }\n if (!promiseCtor) {\n throw new Error('no Promise impl found');\n }\n return promiseCtor;\n}\n(function () {\n if (Symbol && Symbol.asyncIterator) {\n Observable.prototype[Symbol.asyncIterator] = function () {\n return asyncIteratorFrom(this);\n };\n }\n})();\n//# sourceMappingURL=Observable.js.map","import { Subscriber } from '../Subscriber';\nimport { rxSubscriber as rxSubscriberSymbol } from '../symbol/rxSubscriber';\nimport { empty as emptyObserver } from '../Observer';\nexport function toSubscriber(nextOrObserver, error, complete) {\n if (nextOrObserver) {\n if (nextOrObserver instanceof Subscriber) {\n return nextOrObserver;\n }\n if (nextOrObserver[rxSubscriberSymbol]) {\n return nextOrObserver[rxSubscriberSymbol]();\n }\n }\n if (!nextOrObserver && !error && !complete) {\n return new Subscriber(emptyObserver);\n }\n return new Subscriber(nextOrObserver, error, complete);\n}\n//# sourceMappingURL=toSubscriber.js.map","import { Subscriber } from '../Subscriber';\nexport function canReportError(observer) {\n while (observer) {\n var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;\n if (closed_1 || isStopped) {\n return false;\n }\n else if (destination && destination instanceof Subscriber) {\n observer = destination;\n }\n else {\n observer = null;\n }\n }\n return true;\n}\n//# sourceMappingURL=canReportError.js.map","var UnsubscriptionErrorImpl = (function () {\n function UnsubscriptionErrorImpl(errors) {\n Error.call(this);\n this.message = errors ?\n errors.length + \" errors occurred during unsubscription:\\n\" + errors.map(function (err, i) { return i + 1 + \") \" + err.toString(); }).join('\\n ') : '';\n this.name = 'UnsubscriptionError';\n this.errors = errors;\n return this;\n }\n UnsubscriptionErrorImpl.prototype = Object.create(Error.prototype);\n return UnsubscriptionErrorImpl;\n})();\nexport var UnsubscriptionError = UnsubscriptionErrorImpl;\n//# sourceMappingURL=UnsubscriptionError.js.map","import { isArray } from './util/isArray';\nimport { isObject } from './util/isObject';\nimport { isFunction } from './util/isFunction';\nimport { UnsubscriptionError } from './util/UnsubscriptionError';\nvar Subscription = (function () {\n function Subscription(unsubscribe) {\n this.closed = false;\n this._parentOrParents = null;\n this._subscriptions = null;\n if (unsubscribe) {\n this._unsubscribe = unsubscribe;\n }\n }\n Subscription.prototype.unsubscribe = function () {\n var errors;\n if (this.closed) {\n return;\n }\n var _a = this, _parentOrParents = _a._parentOrParents, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;\n this.closed = true;\n this._parentOrParents = null;\n this._subscriptions = null;\n if (_parentOrParents instanceof Subscription) {\n _parentOrParents.remove(this);\n }\n else if (_parentOrParents !== null) {\n for (var index = 0; index < _parentOrParents.length; ++index) {\n var parent_1 = _parentOrParents[index];\n parent_1.remove(this);\n }\n }\n if (isFunction(_unsubscribe)) {\n try {\n _unsubscribe.call(this);\n }\n catch (e) {\n errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];\n }\n }\n if (isArray(_subscriptions)) {\n var index = -1;\n var len = _subscriptions.length;\n while (++index < len) {\n var sub = _subscriptions[index];\n if (isObject(sub)) {\n try {\n sub.unsubscribe();\n }\n catch (e) {\n errors = errors || [];\n if (e instanceof UnsubscriptionError) {\n errors = errors.concat(flattenUnsubscriptionErrors(e.errors));\n }\n else {\n errors.push(e);\n }\n }\n }\n }\n }\n if (errors) {\n throw new UnsubscriptionError(errors);\n }\n };\n Subscription.prototype.add = function (teardown) {\n var subscription = teardown;\n if (!teardown) {\n return Subscription.EMPTY;\n }\n switch (typeof teardown) {\n case 'function':\n subscription = new Subscription(teardown);\n case 'object':\n if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {\n return subscription;\n }\n else if (this.closed) {\n subscription.unsubscribe();\n return subscription;\n }\n else if (!(subscription instanceof Subscription)) {\n var tmp = subscription;\n subscription = new Subscription();\n subscription._subscriptions = [tmp];\n }\n break;\n default: {\n throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');\n }\n }\n var _parentOrParents = subscription._parentOrParents;\n if (_parentOrParents === null) {\n subscription._parentOrParents = this;\n }\n else if (_parentOrParents instanceof Subscription) {\n if (_parentOrParents === this) {\n return subscription;\n }\n subscription._parentOrParents = [_parentOrParents, this];\n }\n else if (_parentOrParents.indexOf(this) === -1) {\n _parentOrParents.push(this);\n }\n else {\n return subscription;\n }\n var subscriptions = this._subscriptions;\n if (subscriptions === null) {\n this._subscriptions = [subscription];\n }\n else {\n subscriptions.push(subscription);\n }\n return subscription;\n };\n Subscription.prototype.remove = function (subscription) {\n var subscriptions = this._subscriptions;\n if (subscriptions) {\n var subscriptionIndex = subscriptions.indexOf(subscription);\n if (subscriptionIndex !== -1) {\n subscriptions.splice(subscriptionIndex, 1);\n }\n }\n };\n Subscription.EMPTY = (function (empty) {\n empty.closed = true;\n return empty;\n }(new Subscription()));\n return Subscription;\n}());\nexport { Subscription };\nfunction flattenUnsubscriptionErrors(errors) {\n return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError) ? err.errors : err); }, []);\n}\n//# sourceMappingURL=Subscription.js.map","import { __extends } from \"tslib\";\nimport { Subscriber } from '../Subscriber';\nexport function map(project, thisArg) {\n return function mapOperation(source) {\n if (typeof project !== 'function') {\n throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');\n }\n return source.lift(new MapOperator(project, thisArg));\n };\n}\nvar MapOperator = (function () {\n function MapOperator(project, thisArg) {\n this.project = project;\n this.thisArg = thisArg;\n }\n MapOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));\n };\n return MapOperator;\n}());\nexport { MapOperator };\nvar MapSubscriber = (function (_super) {\n __extends(MapSubscriber, _super);\n function MapSubscriber(destination, project, thisArg) {\n var _this = _super.call(this, destination) || this;\n _this.project = project;\n _this.count = 0;\n _this.thisArg = thisArg || _this;\n return _this;\n }\n MapSubscriber.prototype._next = function (value) {\n var result;\n try {\n result = this.project.call(this.thisArg, value, this.count++);\n }\n catch (err) {\n this.destination.error(err);\n return;\n }\n this.destination.next(result);\n };\n return MapSubscriber;\n}(Subscriber));\n//# sourceMappingURL=map.js.map","import { InnerSubscriber } from '../InnerSubscriber';\nimport { subscribeTo } from './subscribeTo';\nimport { Observable } from '../Observable';\nexport function subscribeToResult(outerSubscriber, result, outerValue, outerIndex, innerSubscriber) {\n if (innerSubscriber === void 0) { innerSubscriber = new InnerSubscriber(outerSubscriber, outerValue, outerIndex); }\n if (innerSubscriber.closed) {\n return undefined;\n }\n if (result instanceof Observable) {\n return result.subscribe(innerSubscriber);\n }\n return subscribeTo(result)(innerSubscriber);\n}\n//# sourceMappingURL=subscribeToResult.js.map","import { __extends } from \"tslib\";\nimport { Subscriber } from './Subscriber';\nvar OuterSubscriber = (function (_super) {\n __extends(OuterSubscriber, _super);\n function OuterSubscriber() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {\n this.destination.next(innerValue);\n };\n OuterSubscriber.prototype.notifyError = function (error, innerSub) {\n this.destination.error(error);\n };\n OuterSubscriber.prototype.notifyComplete = function (innerSub) {\n this.destination.complete();\n };\n return OuterSubscriber;\n}(Subscriber));\nexport { OuterSubscriber };\n//# sourceMappingURL=OuterSubscriber.js.map","var _enable_super_gross_mode_that_will_cause_bad_things = false;\nexport var config = {\n Promise: undefined,\n set useDeprecatedSynchronousErrorHandling(value) {\n if (value) {\n var error = new Error();\n console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \\n' + error.stack);\n }\n else if (_enable_super_gross_mode_that_will_cause_bad_things) {\n console.log('RxJS: Back to a better error behavior. Thank you. <3');\n }\n _enable_super_gross_mode_that_will_cause_bad_things = value;\n },\n get useDeprecatedSynchronousErrorHandling() {\n return _enable_super_gross_mode_that_will_cause_bad_things;\n },\n};\n//# sourceMappingURL=config.js.map","var __window = typeof window !== 'undefined' && window;\nvar __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&\n self instanceof WorkerGlobalScope && self;\nvar __global = typeof global !== 'undefined' && global;\nvar _root = __window || __global || __self;\n(function () {\n if (!_root) {\n throw new Error('RxJS could not find any global context (window, self, global)');\n }\n})();\nexport { _root as root };\n//# sourceMappingURL=root.js.map","export function isFunction(x) {\n return typeof x === 'function';\n}\n//# sourceMappingURL=isFunction.js.map","export function noop() { }\n//# sourceMappingURL=noop.js.map","export var observable = (function () { return typeof Symbol === 'function' && Symbol.observable || '@@observable'; })();\n//# sourceMappingURL=observable.js.map","import { Observable } from '../Observable';\nexport var EMPTY = new Observable(function (subscriber) { return subscriber.complete(); });\nexport function empty(scheduler) {\n return scheduler ? emptyScheduled(scheduler) : EMPTY;\n}\nfunction emptyScheduled(scheduler) {\n return new Observable(function (subscriber) { return scheduler.schedule(function () { return subscriber.complete(); }); });\n}\n//# sourceMappingURL=empty.js.map","var ObjectUnsubscribedErrorImpl = (function () {\n function ObjectUnsubscribedErrorImpl() {\n Error.call(this);\n this.message = 'object unsubscribed';\n this.name = 'ObjectUnsubscribedError';\n return this;\n }\n ObjectUnsubscribedErrorImpl.prototype = Object.create(Error.prototype);\n return ObjectUnsubscribedErrorImpl;\n})();\nexport var ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;\n//# sourceMappingURL=ObjectUnsubscribedError.js.map","export default function _isPlaceholder(a) {\n return a != null && typeof a === 'object' && a['@@functional/placeholder'] === true;\n}","import _isPlaceholder from \"./_isPlaceholder.js\";\n/**\n * Optimized internal one-arity curry function.\n *\n * @private\n * @category Function\n * @param {Function} fn The function to curry.\n * @return {Function} The curried function.\n */\n\nexport default function _curry1(fn) {\n return function f1(a) {\n if (arguments.length === 0 || _isPlaceholder(a)) {\n return f1;\n } else {\n return fn.apply(this, arguments);\n }\n };\n}","export function hostReportError(err) {\n setTimeout(function () { throw err; }, 0);\n}\n//# sourceMappingURL=hostReportError.js.map","export var isArray = (function () { return Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); })();\n//# sourceMappingURL=isArray.js.map","export function isScheduler(value) {\n return value && typeof value.schedule === 'function';\n}\n//# sourceMappingURL=isScheduler.js.map","import { __extends } from \"tslib\";\nimport { Observable } from './Observable';\nimport { Subscriber } from './Subscriber';\nimport { Subscription } from './Subscription';\nimport { ObjectUnsubscribedError } from './util/ObjectUnsubscribedError';\nimport { SubjectSubscription } from './SubjectSubscription';\nimport { rxSubscriber as rxSubscriberSymbol } from '../internal/symbol/rxSubscriber';\nvar SubjectSubscriber = (function (_super) {\n __extends(SubjectSubscriber, _super);\n function SubjectSubscriber(destination) {\n var _this = _super.call(this, destination) || this;\n _this.destination = destination;\n return _this;\n }\n return SubjectSubscriber;\n}(Subscriber));\nexport { SubjectSubscriber };\nvar Subject = (function (_super) {\n __extends(Subject, _super);\n function Subject() {\n var _this = _super.call(this) || this;\n _this.observers = [];\n _this.closed = false;\n _this.isStopped = false;\n _this.hasError = false;\n _this.thrownError = null;\n return _this;\n }\n Subject.prototype[rxSubscriberSymbol] = function () {\n return new SubjectSubscriber(this);\n };\n Subject.prototype.lift = function (operator) {\n var subject = new AnonymousSubject(this, this);\n subject.operator = operator;\n return subject;\n };\n Subject.prototype.next = function (value) {\n if (this.closed) {\n throw new ObjectUnsubscribedError();\n }\n if (!this.isStopped) {\n var observers = this.observers;\n var len = observers.length;\n var copy = observers.slice();\n for (var i = 0; i < len; i++) {\n copy[i].next(value);\n }\n }\n };\n Subject.prototype.error = function (err) {\n if (this.closed) {\n throw new ObjectUnsubscribedError();\n }\n this.hasError = true;\n this.thrownError = err;\n this.isStopped = true;\n var observers = this.observers;\n var len = observers.length;\n var copy = observers.slice();\n for (var i = 0; i < len; i++) {\n copy[i].error(err);\n }\n this.observers.length = 0;\n };\n Subject.prototype.complete = function () {\n if (this.closed) {\n throw new ObjectUnsubscribedError();\n }\n this.isStopped = true;\n var observers = this.observers;\n var len = observers.length;\n var copy = observers.slice();\n for (var i = 0; i < len; i++) {\n copy[i].complete();\n }\n this.observers.length = 0;\n };\n Subject.prototype.unsubscribe = function () {\n this.isStopped = true;\n this.closed = true;\n this.observers = null;\n };\n Subject.prototype._trySubscribe = function (subscriber) {\n if (this.closed) {\n throw new ObjectUnsubscribedError();\n }\n else {\n return _super.prototype._trySubscribe.call(this, subscriber);\n }\n };\n Subject.prototype._subscribe = function (subscriber) {\n if (this.closed) {\n throw new ObjectUnsubscribedError();\n }\n else if (this.hasError) {\n subscriber.error(this.thrownError);\n return Subscription.EMPTY;\n }\n else if (this.isStopped) {\n subscriber.complete();\n return Subscription.EMPTY;\n }\n else {\n this.observers.push(subscriber);\n return new SubjectSubscription(this, subscriber);\n }\n };\n Subject.prototype.asObservable = function () {\n var observable = new Observable();\n observable.source = this;\n return observable;\n };\n Subject.create = function (destination, source) {\n return new AnonymousSubject(destination, source);\n };\n return Subject;\n}(Observable));\nexport { Subject };\nvar AnonymousSubject = (function (_super) {\n __extends(AnonymousSubject, _super);\n function AnonymousSubject(destination, source) {\n var _this = _super.call(this) || this;\n _this.destination = destination;\n _this.source = source;\n return _this;\n }\n AnonymousSubject.prototype.next = function (value) {\n var destination = this.destination;\n if (destination && destination.next) {\n destination.next(value);\n }\n };\n AnonymousSubject.prototype.error = function (err) {\n var destination = this.destination;\n if (destination && destination.error) {\n this.destination.error(err);\n }\n };\n AnonymousSubject.prototype.complete = function () {\n var destination = this.destination;\n if (destination && destination.complete) {\n this.destination.complete();\n }\n };\n AnonymousSubject.prototype._subscribe = function (subscriber) {\n var source = this.source;\n if (source) {\n return this.source.subscribe(subscriber);\n }\n else {\n return Subscription.EMPTY;\n }\n };\n return AnonymousSubject;\n}(Subject));\nexport { AnonymousSubject };\n//# sourceMappingURL=Subject.js.map","export function getSymbolIterator() {\n if (typeof Symbol !== 'function' || !Symbol.iterator) {\n return '@@iterator';\n }\n return Symbol.iterator;\n}\nexport var iterator = getSymbolIterator();\nexport var $$iterator = iterator;\n//# sourceMappingURL=iterator.js.map","import { __extends } from \"tslib\";\nimport { Subscriber } from './Subscriber';\nvar InnerSubscriber = (function (_super) {\n __extends(InnerSubscriber, _super);\n function InnerSubscriber(parent, outerValue, outerIndex) {\n var _this = _super.call(this) || this;\n _this.parent = parent;\n _this.outerValue = outerValue;\n _this.outerIndex = outerIndex;\n _this.index = 0;\n return _this;\n }\n InnerSubscriber.prototype._next = function (value) {\n this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this);\n };\n InnerSubscriber.prototype._error = function (error) {\n this.parent.notifyError(error, this);\n this.unsubscribe();\n };\n InnerSubscriber.prototype._complete = function () {\n this.parent.notifyComplete(this);\n this.unsubscribe();\n };\n return InnerSubscriber;\n}(Subscriber));\nexport { InnerSubscriber };\n//# sourceMappingURL=InnerSubscriber.js.map","export var rxSubscriber = (function () {\n return typeof Symbol === 'function'\n ? Symbol('rxSubscriber')\n : '@@rxSubscriber_' + Math.random();\n})();\nexport var $$rxSubscriber = rxSubscriber;\n//# sourceMappingURL=rxSubscriber.js.map","import { __extends } from \"tslib\";\nimport { OuterSubscriber } from '../OuterSubscriber';\nimport { InnerSubscriber } from '../InnerSubscriber';\nimport { subscribeToResult } from '../util/subscribeToResult';\nimport { map } from './map';\nimport { from } from '../observable/from';\nexport function switchMap(project, resultSelector) {\n if (typeof resultSelector === 'function') {\n return function (source) { return source.pipe(switchMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };\n }\n return function (source) { return source.lift(new SwitchMapOperator(project)); };\n}\nvar SwitchMapOperator = (function () {\n function SwitchMapOperator(project) {\n this.project = project;\n }\n SwitchMapOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new SwitchMapSubscriber(subscriber, this.project));\n };\n return SwitchMapOperator;\n}());\nvar SwitchMapSubscriber = (function (_super) {\n __extends(SwitchMapSubscriber, _super);\n function SwitchMapSubscriber(destination, project) {\n var _this = _super.call(this, destination) || this;\n _this.project = project;\n _this.index = 0;\n return _this;\n }\n SwitchMapSubscriber.prototype._next = function (value) {\n var result;\n var index = this.index++;\n try {\n result = this.project(value, index);\n }\n catch (error) {\n this.destination.error(error);\n return;\n }\n this._innerSub(result, value, index);\n };\n SwitchMapSubscriber.prototype._innerSub = function (result, value, index) {\n var innerSubscription = this.innerSubscription;\n if (innerSubscription) {\n innerSubscription.unsubscribe();\n }\n var innerSubscriber = new InnerSubscriber(this, value, index);\n var destination = this.destination;\n destination.add(innerSubscriber);\n this.innerSubscription = subscribeToResult(this, result, undefined, undefined, innerSubscriber);\n if (this.innerSubscription !== innerSubscriber) {\n destination.add(this.innerSubscription);\n }\n };\n SwitchMapSubscriber.prototype._complete = function () {\n var innerSubscription = this.innerSubscription;\n if (!innerSubscription || innerSubscription.closed) {\n _super.prototype._complete.call(this);\n }\n this.unsubscribe();\n };\n SwitchMapSubscriber.prototype._unsubscribe = function () {\n this.innerSubscription = null;\n };\n SwitchMapSubscriber.prototype.notifyComplete = function (innerSub) {\n var destination = this.destination;\n destination.remove(innerSub);\n this.innerSubscription = null;\n if (this.isStopped) {\n _super.prototype._complete.call(this);\n }\n };\n SwitchMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {\n this.destination.next(innerValue);\n };\n return SwitchMapSubscriber;\n}(OuterSubscriber));\n//# sourceMappingURL=switchMap.js.map","import { Observable } from '../Observable';\nimport { Subscription } from '../Subscription';\nexport function scheduleArray(input, scheduler) {\n return new Observable(function (subscriber) {\n var sub = new Subscription();\n var i = 0;\n sub.add(scheduler.schedule(function () {\n if (i === input.length) {\n subscriber.complete();\n return;\n }\n subscriber.next(input[i++]);\n if (!subscriber.closed) {\n sub.add(this.schedule());\n }\n }));\n return sub;\n });\n}\n//# sourceMappingURL=scheduleArray.js.map","import { Observable } from '../Observable';\nimport { subscribeToArray } from '../util/subscribeToArray';\nimport { scheduleArray } from '../scheduled/scheduleArray';\nexport function fromArray(input, scheduler) {\n if (!scheduler) {\n return new Observable(subscribeToArray(input));\n }\n else {\n return scheduleArray(input, scheduler);\n }\n}\n//# sourceMappingURL=fromArray.js.map","import { scheduleObservable } from './scheduleObservable';\nimport { schedulePromise } from './schedulePromise';\nimport { scheduleArray } from './scheduleArray';\nimport { scheduleIterable } from './scheduleIterable';\nimport { isInteropObservable } from '../util/isInteropObservable';\nimport { isPromise } from '../util/isPromise';\nimport { isArrayLike } from '../util/isArrayLike';\nimport { isIterable } from '../util/isIterable';\nimport { scheduleAsyncIterable } from './scheduleAsyncIterable';\nexport function scheduled(input, scheduler) {\n if (input != null) {\n if (isInteropObservable(input)) {\n return scheduleObservable(input, scheduler);\n }\n else if (isPromise(input)) {\n return schedulePromise(input, scheduler);\n }\n else if (isArrayLike(input)) {\n return scheduleArray(input, scheduler);\n }\n else if (isIterable(input) || typeof input === 'string') {\n return scheduleIterable(input, scheduler);\n }\n else if (Symbol && Symbol.asyncIterator && typeof input[Symbol.asyncIterator] === 'function') {\n return scheduleAsyncIterable(input, scheduler);\n }\n }\n throw new TypeError((input !== null && typeof input || input) + ' is not observable');\n}\n//# sourceMappingURL=scheduled.js.map","import { observable as Symbol_observable } from '../symbol/observable';\nexport function isInteropObservable(input) {\n return input && typeof input[Symbol_observable] === 'function';\n}\n//# sourceMappingURL=isInteropObservable.js.map","import { Observable } from '../Observable';\nimport { Subscription } from '../Subscription';\nimport { observable as Symbol_observable } from '../symbol/observable';\nexport function scheduleObservable(input, scheduler) {\n return new Observable(function (subscriber) {\n var sub = new Subscription();\n sub.add(scheduler.schedule(function () {\n var observable = input[Symbol_observable]();\n sub.add(observable.subscribe({\n next: function (value) { sub.add(scheduler.schedule(function () { return subscriber.next(value); })); },\n error: function (err) { sub.add(scheduler.schedule(function () { return subscriber.error(err); })); },\n complete: function () { sub.add(scheduler.schedule(function () { return subscriber.complete(); })); },\n }));\n }));\n return sub;\n });\n}\n//# sourceMappingURL=scheduleObservable.js.map","import { Observable } from '../Observable';\nimport { Subscription } from '../Subscription';\nexport function schedulePromise(input, scheduler) {\n return new Observable(function (subscriber) {\n var sub = new Subscription();\n sub.add(scheduler.schedule(function () { return input.then(function (value) {\n sub.add(scheduler.schedule(function () {\n subscriber.next(value);\n sub.add(scheduler.schedule(function () { return subscriber.complete(); }));\n }));\n }, function (err) {\n sub.add(scheduler.schedule(function () { return subscriber.error(err); }));\n }); }));\n return sub;\n });\n}\n//# sourceMappingURL=schedulePromise.js.map","import { iterator as Symbol_iterator } from '../symbol/iterator';\nexport function isIterable(input) {\n return input && typeof input[Symbol_iterator] === 'function';\n}\n//# sourceMappingURL=isIterable.js.map","import { Observable } from '../Observable';\nimport { Subscription } from '../Subscription';\nimport { iterator as Symbol_iterator } from '../symbol/iterator';\nexport function scheduleIterable(input, scheduler) {\n if (!input) {\n throw new Error('Iterable cannot be null');\n }\n return new Observable(function (subscriber) {\n var sub = new Subscription();\n var iterator;\n sub.add(function () {\n if (iterator && typeof iterator.return === 'function') {\n iterator.return();\n }\n });\n sub.add(scheduler.schedule(function () {\n iterator = input[Symbol_iterator]();\n sub.add(scheduler.schedule(function () {\n if (subscriber.closed) {\n return;\n }\n var value;\n var done;\n try {\n var result = iterator.next();\n value = result.value;\n done = result.done;\n }\n catch (err) {\n subscriber.error(err);\n return;\n }\n if (done) {\n subscriber.complete();\n }\n else {\n subscriber.next(value);\n this.schedule();\n }\n }));\n }));\n return sub;\n });\n}\n//# sourceMappingURL=scheduleIterable.js.map","import { Observable } from '../Observable';\nimport { Subscription } from '../Subscription';\nexport function scheduleAsyncIterable(input, scheduler) {\n if (!input) {\n throw new Error('Iterable cannot be null');\n }\n return new Observable(function (subscriber) {\n var sub = new Subscription();\n sub.add(scheduler.schedule(function () {\n var iterator = input[Symbol.asyncIterator]();\n sub.add(scheduler.schedule(function () {\n var _this = this;\n iterator.next().then(function (result) {\n if (result.done) {\n subscriber.complete();\n }\n else {\n subscriber.next(result.value);\n _this.schedule();\n }\n });\n }));\n }));\n return sub;\n });\n}\n//# sourceMappingURL=scheduleAsyncIterable.js.map","import { Observable } from '../Observable';\nimport { subscribeTo } from '../util/subscribeTo';\nimport { scheduled } from '../scheduled/scheduled';\nexport function from(input, scheduler) {\n if (!scheduler) {\n if (input instanceof Observable) {\n return input;\n }\n return new Observable(subscribeTo(input));\n }\n else {\n return scheduled(input, scheduler);\n }\n}\n//# sourceMappingURL=from.js.map","var Scheduler = (function () {\n function Scheduler(SchedulerAction, now) {\n if (now === void 0) { now = Scheduler.now; }\n this.SchedulerAction = SchedulerAction;\n this.now = now;\n }\n Scheduler.prototype.schedule = function (work, delay, state) {\n if (delay === void 0) { delay = 0; }\n return new this.SchedulerAction(this, work).schedule(state, delay);\n };\n Scheduler.now = function () { return Date.now(); };\n return Scheduler;\n}());\nexport { Scheduler };\n//# sourceMappingURL=Scheduler.js.map","import { __extends } from \"tslib\";\nimport { Scheduler } from '../Scheduler';\nvar AsyncScheduler = (function (_super) {\n __extends(AsyncScheduler, _super);\n function AsyncScheduler(SchedulerAction, now) {\n if (now === void 0) { now = Scheduler.now; }\n var _this = _super.call(this, SchedulerAction, function () {\n if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) {\n return AsyncScheduler.delegate.now();\n }\n else {\n return now();\n }\n }) || this;\n _this.actions = [];\n _this.active = false;\n _this.scheduled = undefined;\n return _this;\n }\n AsyncScheduler.prototype.schedule = function (work, delay, state) {\n if (delay === void 0) { delay = 0; }\n if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {\n return AsyncScheduler.delegate.schedule(work, delay, state);\n }\n else {\n return _super.prototype.schedule.call(this, work, delay, state);\n }\n };\n AsyncScheduler.prototype.flush = function (action) {\n var actions = this.actions;\n if (this.active) {\n actions.push(action);\n return;\n }\n var error;\n this.active = true;\n do {\n if (error = action.execute(action.state, action.delay)) {\n break;\n }\n } while (action = actions.shift());\n this.active = false;\n if (error) {\n while (action = actions.shift()) {\n action.unsubscribe();\n }\n throw error;\n }\n };\n return AsyncScheduler;\n}(Scheduler));\nexport { AsyncScheduler };\n//# sourceMappingURL=AsyncScheduler.js.map","import { __extends } from \"tslib\";\nimport { Action } from './Action';\nvar AsyncAction = (function (_super) {\n __extends(AsyncAction, _super);\n function AsyncAction(scheduler, work) {\n var _this = _super.call(this, scheduler, work) || this;\n _this.scheduler = scheduler;\n _this.work = work;\n _this.pending = false;\n return _this;\n }\n AsyncAction.prototype.schedule = function (state, delay) {\n if (delay === void 0) { delay = 0; }\n if (this.closed) {\n return this;\n }\n this.state = state;\n var id = this.id;\n var scheduler = this.scheduler;\n if (id != null) {\n this.id = this.recycleAsyncId(scheduler, id, delay);\n }\n this.pending = true;\n this.delay = delay;\n this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);\n return this;\n };\n AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) {\n if (delay === void 0) { delay = 0; }\n return setInterval(scheduler.flush.bind(scheduler, this), delay);\n };\n AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) {\n if (delay === void 0) { delay = 0; }\n if (delay !== null && this.delay === delay && this.pending === false) {\n return id;\n }\n clearInterval(id);\n return undefined;\n };\n AsyncAction.prototype.execute = function (state, delay) {\n if (this.closed) {\n return new Error('executing a cancelled action');\n }\n this.pending = false;\n var error = this._execute(state, delay);\n if (error) {\n return error;\n }\n else if (this.pending === false && this.id != null) {\n this.id = this.recycleAsyncId(this.scheduler, this.id, null);\n }\n };\n AsyncAction.prototype._execute = function (state, delay) {\n var errored = false;\n var errorValue = undefined;\n try {\n this.work(state);\n }\n catch (e) {\n errored = true;\n errorValue = !!e && e || new Error(e);\n }\n if (errored) {\n this.unsubscribe();\n return errorValue;\n }\n };\n AsyncAction.prototype._unsubscribe = function () {\n var id = this.id;\n var scheduler = this.scheduler;\n var actions = scheduler.actions;\n var index = actions.indexOf(this);\n this.work = null;\n this.state = null;\n this.pending = false;\n this.scheduler = null;\n if (index !== -1) {\n actions.splice(index, 1);\n }\n if (id != null) {\n this.id = this.recycleAsyncId(scheduler, id, null);\n }\n this.delay = null;\n };\n return AsyncAction;\n}(Action));\nexport { AsyncAction };\n//# sourceMappingURL=AsyncAction.js.map","import { __extends } from \"tslib\";\nimport { Subscription } from '../Subscription';\nvar Action = (function (_super) {\n __extends(Action, _super);\n function Action(scheduler, work) {\n return _super.call(this) || this;\n }\n Action.prototype.schedule = function (state, delay) {\n if (delay === void 0) { delay = 0; }\n return this;\n };\n return Action;\n}(Subscription));\nexport { Action };\n//# sourceMappingURL=Action.js.map","import { isScheduler } from '../util/isScheduler';\nimport { fromArray } from './fromArray';\nimport { scheduleArray } from '../scheduled/scheduleArray';\nexport function of() {\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n var scheduler = args[args.length - 1];\n if (isScheduler(scheduler)) {\n args.pop();\n return scheduleArray(args, scheduler);\n }\n else {\n return fromArray(args);\n }\n}\n//# sourceMappingURL=of.js.map","import { config } from './config';\nimport { hostReportError } from './util/hostReportError';\nexport var empty = {\n closed: true,\n next: function (value) { },\n error: function (err) {\n if (config.useDeprecatedSynchronousErrorHandling) {\n throw err;\n }\n else {\n hostReportError(err);\n }\n },\n complete: function () { }\n};\n//# sourceMappingURL=Observer.js.map","import { EMPTY } from './observable/empty';\nimport { of } from './observable/of';\nimport { throwError } from './observable/throwError';\nexport var NotificationKind;\n(function (NotificationKind) {\n NotificationKind[\"NEXT\"] = \"N\";\n NotificationKind[\"ERROR\"] = \"E\";\n NotificationKind[\"COMPLETE\"] = \"C\";\n})(NotificationKind || (NotificationKind = {}));\nvar Notification = (function () {\n function Notification(kind, value, error) {\n this.kind = kind;\n this.value = value;\n this.error = error;\n this.hasValue = kind === 'N';\n }\n Notification.prototype.observe = function (observer) {\n switch (this.kind) {\n case 'N':\n return observer.next && observer.next(this.value);\n case 'E':\n return observer.error && observer.error(this.error);\n case 'C':\n return observer.complete && observer.complete();\n }\n };\n Notification.prototype.do = function (next, error, complete) {\n var kind = this.kind;\n switch (kind) {\n case 'N':\n return next && next(this.value);\n case 'E':\n return error && error(this.error);\n case 'C':\n return complete && complete();\n }\n };\n Notification.prototype.accept = function (nextOrObserver, error, complete) {\n if (nextOrObserver && typeof nextOrObserver.next === 'function') {\n return this.observe(nextOrObserver);\n }\n else {\n return this.do(nextOrObserver, error, complete);\n }\n };\n Notification.prototype.toObservable = function () {\n var kind = this.kind;\n switch (kind) {\n case 'N':\n return of(this.value);\n case 'E':\n return throwError(this.error);\n case 'C':\n return EMPTY;\n }\n throw new Error('unexpected notification kind value');\n };\n Notification.createNext = function (value) {\n if (typeof value !== 'undefined') {\n return new Notification('N', value);\n }\n return Notification.undefinedValueNotification;\n };\n Notification.createError = function (err) {\n return new Notification('E', undefined, err);\n };\n Notification.createComplete = function () {\n return Notification.completeNotification;\n };\n Notification.completeNotification = new Notification('C');\n Notification.undefinedValueNotification = new Notification('N', undefined);\n return Notification;\n}());\nexport { Notification };\n//# sourceMappingURL=Notification.js.map","import { Observable } from '../Observable';\nexport function throwError(error, scheduler) {\n if (!scheduler) {\n return new Observable(function (subscriber) { return subscriber.error(error); });\n }\n else {\n return new Observable(function (subscriber) { return scheduler.schedule(dispatch, 0, { error: error, subscriber: subscriber }); });\n }\n}\nfunction dispatch(_a) {\n var error = _a.error, subscriber = _a.subscriber;\n subscriber.error(error);\n}\n//# sourceMappingURL=throwError.js.map","import { identity } from './identity';\nexport function pipe() {\n var fns = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n fns[_i] = arguments[_i];\n }\n return pipeFromArray(fns);\n}\nexport function pipeFromArray(fns) {\n if (fns.length === 0) {\n return identity;\n }\n if (fns.length === 1) {\n return fns[0];\n }\n return function piped(input) {\n return fns.reduce(function (prev, fn) { return fn(prev); }, input);\n };\n}\n//# sourceMappingURL=pipe.js.map","import { __extends } from \"tslib\";\nimport { Subscriber } from '../Subscriber';\nexport function distinctUntilChanged(compare, keySelector) {\n return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };\n}\nvar DistinctUntilChangedOperator = (function () {\n function DistinctUntilChangedOperator(compare, keySelector) {\n this.compare = compare;\n this.keySelector = keySelector;\n }\n DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));\n };\n return DistinctUntilChangedOperator;\n}());\nvar DistinctUntilChangedSubscriber = (function (_super) {\n __extends(DistinctUntilChangedSubscriber, _super);\n function DistinctUntilChangedSubscriber(destination, compare, keySelector) {\n var _this = _super.call(this, destination) || this;\n _this.keySelector = keySelector;\n _this.hasKey = false;\n if (typeof compare === 'function') {\n _this.compare = compare;\n }\n return _this;\n }\n DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {\n return x === y;\n };\n DistinctUntilChangedSubscriber.prototype._next = function (value) {\n var key;\n try {\n var keySelector = this.keySelector;\n key = keySelector ? keySelector(value) : value;\n }\n catch (err) {\n return this.destination.error(err);\n }\n var result = false;\n if (this.hasKey) {\n try {\n var compare = this.compare;\n result = compare(this.key, key);\n }\n catch (err) {\n return this.destination.error(err);\n }\n }\n else {\n this.hasKey = true;\n }\n if (!result) {\n this.key = key;\n this.destination.next(value);\n }\n };\n return DistinctUntilChangedSubscriber;\n}(Subscriber));\n//# sourceMappingURL=distinctUntilChanged.js.map","export function isObject(x) {\n return x !== null && typeof x === 'object';\n}\n//# sourceMappingURL=isObject.js.map","import { __extends } from \"tslib\";\nimport { Subscription } from './Subscription';\nvar SubjectSubscription = (function (_super) {\n __extends(SubjectSubscription, _super);\n function SubjectSubscription(subject, subscriber) {\n var _this = _super.call(this) || this;\n _this.subject = subject;\n _this.subscriber = subscriber;\n _this.closed = false;\n return _this;\n }\n SubjectSubscription.prototype.unsubscribe = function () {\n if (this.closed) {\n return;\n }\n this.closed = true;\n var subject = this.subject;\n var observers = subject.observers;\n this.subject = null;\n if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {\n return;\n }\n var subscriberIndex = observers.indexOf(this.subscriber);\n if (subscriberIndex !== -1) {\n observers.splice(subscriberIndex, 1);\n }\n };\n return SubjectSubscription;\n}(Subscription));\nexport { SubjectSubscription };\n//# sourceMappingURL=SubjectSubscription.js.map","export function identity(x) {\n return x;\n}\n//# sourceMappingURL=identity.js.map","export var subscribeToArray = function (array) { return function (subscriber) {\n for (var i = 0, len = array.length; i < len && !subscriber.closed; i++) {\n subscriber.next(array[i]);\n }\n subscriber.complete();\n}; };\n//# sourceMappingURL=subscribeToArray.js.map","export var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });\n//# sourceMappingURL=isArrayLike.js.map","export function isPromise(value) {\n return !!value && typeof value.subscribe !== 'function' && typeof value.then === 'function';\n}\n//# sourceMappingURL=isPromise.js.map","import { AsyncAction } from './AsyncAction';\nimport { AsyncScheduler } from './AsyncScheduler';\nexport var async = new AsyncScheduler(AsyncAction);\n//# sourceMappingURL=async.js.map","import { __asyncValues, __awaiter, __generator } from \"tslib\";\nexport function subscribeToAsyncIterable(asyncIterable) {\n return function (subscriber) {\n process(asyncIterable, subscriber).catch(function (err) { return subscriber.error(err); });\n };\n}\nfunction process(asyncIterable, subscriber) {\n var asyncIterable_1, asyncIterable_1_1;\n var e_1, _a;\n return __awaiter(this, void 0, void 0, function () {\n var value, e_1_1;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n _b.trys.push([0, 5, 6, 11]);\n asyncIterable_1 = __asyncValues(asyncIterable);\n _b.label = 1;\n case 1: return [4, asyncIterable_1.next()];\n case 2:\n if (!(asyncIterable_1_1 = _b.sent(), !asyncIterable_1_1.done)) return [3, 4];\n value = asyncIterable_1_1.value;\n subscriber.next(value);\n _b.label = 3;\n case 3: return [3, 1];\n case 4: return [3, 11];\n case 5:\n e_1_1 = _b.sent();\n e_1 = { error: e_1_1 };\n return [3, 11];\n case 6:\n _b.trys.push([6, , 9, 10]);\n if (!(asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return))) return [3, 8];\n return [4, _a.call(asyncIterable_1)];\n case 7:\n _b.sent();\n _b.label = 8;\n case 8: return [3, 10];\n case 9:\n if (e_1) throw e_1.error;\n return [7];\n case 10: return [7];\n case 11:\n subscriber.complete();\n return [2];\n }\n });\n });\n}\n//# sourceMappingURL=subscribeToAsyncIterable.js.map","import { subscribeToArray } from './subscribeToArray';\nimport { subscribeToPromise } from './subscribeToPromise';\nimport { subscribeToIterable } from './subscribeToIterable';\nimport { subscribeToObservable } from './subscribeToObservable';\nimport { isArrayLike } from './isArrayLike';\nimport { isPromise } from './isPromise';\nimport { isObject } from './isObject';\nimport { iterator as Symbol_iterator } from '../symbol/iterator';\nimport { observable as Symbol_observable } from '../symbol/observable';\nimport { subscribeToAsyncIterable } from './subscribeToAsyncIterable';\nexport var subscribeTo = function (result) {\n if (!!result && typeof result[Symbol_observable] === 'function') {\n return subscribeToObservable(result);\n }\n else if (isArrayLike(result)) {\n return subscribeToArray(result);\n }\n else if (isPromise(result)) {\n return subscribeToPromise(result);\n }\n else if (!!result && typeof result[Symbol_iterator] === 'function') {\n return subscribeToIterable(result);\n }\n else if (Symbol && Symbol.asyncIterator &&\n !!result && typeof result[Symbol.asyncIterator] === 'function') {\n return subscribeToAsyncIterable(result);\n }\n else {\n var value = isObject(result) ? 'an invalid object' : \"'\" + result + \"'\";\n var msg = \"You provided \" + value + \" where a stream was expected.\"\n + ' You can provide an Observable, Promise, Array, or Iterable.';\n throw new TypeError(msg);\n }\n};\n//# sourceMappingURL=subscribeTo.js.map","import { observable as Symbol_observable } from '../symbol/observable';\nexport var subscribeToObservable = function (obj) { return function (subscriber) {\n var obs = obj[Symbol_observable]();\n if (typeof obs.subscribe !== 'function') {\n throw new TypeError('Provided object does not correctly implement Symbol.observable');\n }\n else {\n return obs.subscribe(subscriber);\n }\n}; };\n//# sourceMappingURL=subscribeToObservable.js.map","import { hostReportError } from './hostReportError';\nexport var subscribeToPromise = function (promise) { return function (subscriber) {\n promise.then(function (value) {\n if (!subscriber.closed) {\n subscriber.next(value);\n subscriber.complete();\n }\n }, function (err) { return subscriber.error(err); })\n .then(null, hostReportError);\n return subscriber;\n}; };\n//# sourceMappingURL=subscribeToPromise.js.map","import { iterator as Symbol_iterator } from '../symbol/iterator';\nexport var subscribeToIterable = function (iterable) { return function (subscriber) {\n var iterator = iterable[Symbol_iterator]();\n do {\n var item = iterator.next();\n if (item.done) {\n subscriber.complete();\n break;\n }\n subscriber.next(item.value);\n if (subscriber.closed) {\n break;\n }\n } while (true);\n if (typeof iterator.return === 'function') {\n subscriber.add(function () {\n if (iterator.return) {\n iterator.return();\n }\n });\n }\n return subscriber;\n}; };\n//# sourceMappingURL=subscribeToIterable.js.map","import { __extends } from \"tslib\";\nimport { subscribeToResult } from '../util/subscribeToResult';\nimport { OuterSubscriber } from '../OuterSubscriber';\nimport { InnerSubscriber } from '../InnerSubscriber';\nimport { map } from './map';\nimport { from } from '../observable/from';\nexport function mergeMap(project, resultSelector, concurrent) {\n if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }\n if (typeof resultSelector === 'function') {\n return function (source) { return source.pipe(mergeMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); }, concurrent)); };\n }\n else if (typeof resultSelector === 'number') {\n concurrent = resultSelector;\n }\n return function (source) { return source.lift(new MergeMapOperator(project, concurrent)); };\n}\nvar MergeMapOperator = (function () {\n function MergeMapOperator(project, concurrent) {\n if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }\n this.project = project;\n this.concurrent = concurrent;\n }\n MergeMapOperator.prototype.call = function (observer, source) {\n return source.subscribe(new MergeMapSubscriber(observer, this.project, this.concurrent));\n };\n return MergeMapOperator;\n}());\nexport { MergeMapOperator };\nvar MergeMapSubscriber = (function (_super) {\n __extends(MergeMapSubscriber, _super);\n function MergeMapSubscriber(destination, project, concurrent) {\n if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }\n var _this = _super.call(this, destination) || this;\n _this.project = project;\n _this.concurrent = concurrent;\n _this.hasCompleted = false;\n _this.buffer = [];\n _this.active = 0;\n _this.index = 0;\n return _this;\n }\n MergeMapSubscriber.prototype._next = function (value) {\n if (this.active < this.concurrent) {\n this._tryNext(value);\n }\n else {\n this.buffer.push(value);\n }\n };\n MergeMapSubscriber.prototype._tryNext = function (value) {\n var result;\n var index = this.index++;\n try {\n result = this.project(value, index);\n }\n catch (err) {\n this.destination.error(err);\n return;\n }\n this.active++;\n this._innerSub(result, value, index);\n };\n MergeMapSubscriber.prototype._innerSub = function (ish, value, index) {\n var innerSubscriber = new InnerSubscriber(this, value, index);\n var destination = this.destination;\n destination.add(innerSubscriber);\n var innerSubscription = subscribeToResult(this, ish, undefined, undefined, innerSubscriber);\n if (innerSubscription !== innerSubscriber) {\n destination.add(innerSubscription);\n }\n };\n MergeMapSubscriber.prototype._complete = function () {\n this.hasCompleted = true;\n if (this.active === 0 && this.buffer.length === 0) {\n this.destination.complete();\n }\n this.unsubscribe();\n };\n MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {\n this.destination.next(innerValue);\n };\n MergeMapSubscriber.prototype.notifyComplete = function (innerSub) {\n var buffer = this.buffer;\n this.remove(innerSub);\n this.active--;\n if (buffer.length > 0) {\n this._next(buffer.shift());\n }\n else if (this.active === 0 && this.hasCompleted) {\n this.destination.complete();\n }\n };\n return MergeMapSubscriber;\n}(OuterSubscriber));\nexport { MergeMapSubscriber };\n//# sourceMappingURL=mergeMap.js.map","import { mergeMap } from './mergeMap';\nimport { identity } from '../util/identity';\nexport function mergeAll(concurrent) {\n if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }\n return mergeMap(identity, concurrent);\n}\n//# sourceMappingURL=mergeAll.js.map","import { __extends } from \"tslib\";\nimport { Subscriber } from '../Subscriber';\nimport { Notification } from '../Notification';\nexport function observeOn(scheduler, delay) {\n if (delay === void 0) { delay = 0; }\n return function observeOnOperatorFunction(source) {\n return source.lift(new ObserveOnOperator(scheduler, delay));\n };\n}\nvar ObserveOnOperator = (function () {\n function ObserveOnOperator(scheduler, delay) {\n if (delay === void 0) { delay = 0; }\n this.scheduler = scheduler;\n this.delay = delay;\n }\n ObserveOnOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));\n };\n return ObserveOnOperator;\n}());\nexport { ObserveOnOperator };\nvar ObserveOnSubscriber = (function (_super) {\n __extends(ObserveOnSubscriber, _super);\n function ObserveOnSubscriber(destination, scheduler, delay) {\n if (delay === void 0) { delay = 0; }\n var _this = _super.call(this, destination) || this;\n _this.scheduler = scheduler;\n _this.delay = delay;\n return _this;\n }\n ObserveOnSubscriber.dispatch = function (arg) {\n var notification = arg.notification, destination = arg.destination;\n notification.observe(destination);\n this.unsubscribe();\n };\n ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {\n var destination = this.destination;\n destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));\n };\n ObserveOnSubscriber.prototype._next = function (value) {\n this.scheduleMessage(Notification.createNext(value));\n };\n ObserveOnSubscriber.prototype._error = function (err) {\n this.scheduleMessage(Notification.createError(err));\n this.unsubscribe();\n };\n ObserveOnSubscriber.prototype._complete = function () {\n this.scheduleMessage(Notification.createComplete());\n this.unsubscribe();\n };\n return ObserveOnSubscriber;\n}(Subscriber));\nexport { ObserveOnSubscriber };\nvar ObserveOnMessage = (function () {\n function ObserveOnMessage(notification, destination) {\n this.notification = notification;\n this.destination = destination;\n }\n return ObserveOnMessage;\n}());\nexport { ObserveOnMessage };\n//# sourceMappingURL=observeOn.js.map","/*!\n * clipboard.js v2.0.6\n * https://clipboardjs.com/\n * \n * Licensed MIT © Zeno Rocha\n */\n(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"ClipboardJS\"] = factory();\n\telse\n\t\troot[\"ClipboardJS\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// define __esModule on exports\n/******/ \t__webpack_require__.r = function(exports) {\n/******/ \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n/******/ \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n/******/ \t\t}\n/******/ \t\tObject.defineProperty(exports, '__esModule', { value: true });\n/******/ \t};\n/******/\n/******/ \t// create a fake namespace object\n/******/ \t// mode & 1: value is a module id, require it\n/******/ \t// mode & 2: merge all properties of value into the ns\n/******/ \t// mode & 4: return value when already ns object\n/******/ \t// mode & 8|1: behave like require\n/******/ \t__webpack_require__.t = function(value, mode) {\n/******/ \t\tif(mode & 1) value = __webpack_require__(value);\n/******/ \t\tif(mode & 8) return value;\n/******/ \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n/******/ \t\tvar ns = Object.create(null);\n/******/ \t\t__webpack_require__.r(ns);\n/******/ \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n/******/ \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n/******/ \t\treturn ns;\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 6);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports) {\n\nfunction select(element) {\n var selectedText;\n\n if (element.nodeName === 'SELECT') {\n element.focus();\n\n selectedText = element.value;\n }\n else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {\n var isReadOnly = element.hasAttribute('readonly');\n\n if (!isReadOnly) {\n element.setAttribute('readonly', '');\n }\n\n element.select();\n element.setSelectionRange(0, element.value.length);\n\n if (!isReadOnly) {\n element.removeAttribute('readonly');\n }\n\n selectedText = element.value;\n }\n else {\n if (element.hasAttribute('contenteditable')) {\n element.focus();\n }\n\n var selection = window.getSelection();\n var range = document.createRange();\n\n range.selectNodeContents(element);\n selection.removeAllRanges();\n selection.addRange(range);\n\n selectedText = selection.toString();\n }\n\n return selectedText;\n}\n\nmodule.exports = select;\n\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports) {\n\nfunction E () {\n // Keep this empty so it's easier to inherit from\n // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)\n}\n\nE.prototype = {\n on: function (name, callback, ctx) {\n var e = this.e || (this.e = {});\n\n (e[name] || (e[name] = [])).push({\n fn: callback,\n ctx: ctx\n });\n\n return this;\n },\n\n once: function (name, callback, ctx) {\n var self = this;\n function listener () {\n self.off(name, listener);\n callback.apply(ctx, arguments);\n };\n\n listener._ = callback\n return this.on(name, listener, ctx);\n },\n\n emit: function (name) {\n var data = [].slice.call(arguments, 1);\n var evtArr = ((this.e || (this.e = {}))[name] || []).slice();\n var i = 0;\n var len = evtArr.length;\n\n for (i; i < len; i++) {\n evtArr[i].fn.apply(evtArr[i].ctx, data);\n }\n\n return this;\n },\n\n off: function (name, callback) {\n var e = this.e || (this.e = {});\n var evts = e[name];\n var liveEvents = [];\n\n if (evts && callback) {\n for (var i = 0, len = evts.length; i < len; i++) {\n if (evts[i].fn !== callback && evts[i].fn._ !== callback)\n liveEvents.push(evts[i]);\n }\n }\n\n // Remove event from queue to prevent memory leak\n // Suggested by https://github.com/lazd\n // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910\n\n (liveEvents.length)\n ? e[name] = liveEvents\n : delete e[name];\n\n return this;\n }\n};\n\nmodule.exports = E;\nmodule.exports.TinyEmitter = E;\n\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\nvar is = __webpack_require__(3);\nvar delegate = __webpack_require__(4);\n\n/**\n * Validates all params and calls the right\n * listener function based on its target type.\n *\n * @param {String|HTMLElement|HTMLCollection|NodeList} target\n * @param {String} type\n * @param {Function} callback\n * @return {Object}\n */\nfunction listen(target, type, callback) {\n if (!target && !type && !callback) {\n throw new Error('Missing required arguments');\n }\n\n if (!is.string(type)) {\n throw new TypeError('Second argument must be a String');\n }\n\n if (!is.fn(callback)) {\n throw new TypeError('Third argument must be a Function');\n }\n\n if (is.node(target)) {\n return listenNode(target, type, callback);\n }\n else if (is.nodeList(target)) {\n return listenNodeList(target, type, callback);\n }\n else if (is.string(target)) {\n return listenSelector(target, type, callback);\n }\n else {\n throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');\n }\n}\n\n/**\n * Adds an event listener to a HTML element\n * and returns a remove listener function.\n *\n * @param {HTMLElement} node\n * @param {String} type\n * @param {Function} callback\n * @return {Object}\n */\nfunction listenNode(node, type, callback) {\n node.addEventListener(type, callback);\n\n return {\n destroy: function() {\n node.removeEventListener(type, callback);\n }\n }\n}\n\n/**\n * Add an event listener to a list of HTML elements\n * and returns a remove listener function.\n *\n * @param {NodeList|HTMLCollection} nodeList\n * @param {String} type\n * @param {Function} callback\n * @return {Object}\n */\nfunction listenNodeList(nodeList, type, callback) {\n Array.prototype.forEach.call(nodeList, function(node) {\n node.addEventListener(type, callback);\n });\n\n return {\n destroy: function() {\n Array.prototype.forEach.call(nodeList, function(node) {\n node.removeEventListener(type, callback);\n });\n }\n }\n}\n\n/**\n * Add an event listener to a selector\n * and returns a remove listener function.\n *\n * @param {String} selector\n * @param {String} type\n * @param {Function} callback\n * @return {Object}\n */\nfunction listenSelector(selector, type, callback) {\n return delegate(document.body, selector, type, callback);\n}\n\nmodule.exports = listen;\n\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports) {\n\n/**\n * Check if argument is a HTML element.\n *\n * @param {Object} value\n * @return {Boolean}\n */\nexports.node = function(value) {\n return value !== undefined\n && value instanceof HTMLElement\n && value.nodeType === 1;\n};\n\n/**\n * Check if argument is a list of HTML elements.\n *\n * @param {Object} value\n * @return {Boolean}\n */\nexports.nodeList = function(value) {\n var type = Object.prototype.toString.call(value);\n\n return value !== undefined\n && (type === '[object NodeList]' || type === '[object HTMLCollection]')\n && ('length' in value)\n && (value.length === 0 || exports.node(value[0]));\n};\n\n/**\n * Check if argument is a string.\n *\n * @param {Object} value\n * @return {Boolean}\n */\nexports.string = function(value) {\n return typeof value === 'string'\n || value instanceof String;\n};\n\n/**\n * Check if argument is a function.\n *\n * @param {Object} value\n * @return {Boolean}\n */\nexports.fn = function(value) {\n var type = Object.prototype.toString.call(value);\n\n return type === '[object Function]';\n};\n\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports, __webpack_require__) {\n\nvar closest = __webpack_require__(5);\n\n/**\n * Delegates event to a selector.\n *\n * @param {Element} element\n * @param {String} selector\n * @param {String} type\n * @param {Function} callback\n * @param {Boolean} useCapture\n * @return {Object}\n */\nfunction _delegate(element, selector, type, callback, useCapture) {\n var listenerFn = listener.apply(this, arguments);\n\n element.addEventListener(type, listenerFn, useCapture);\n\n return {\n destroy: function() {\n element.removeEventListener(type, listenerFn, useCapture);\n }\n }\n}\n\n/**\n * Delegates event to a selector.\n *\n * @param {Element|String|Array} [elements]\n * @param {String} selector\n * @param {String} type\n * @param {Function} callback\n * @param {Boolean} useCapture\n * @return {Object}\n */\nfunction delegate(elements, selector, type, callback, useCapture) {\n // Handle the regular Element usage\n if (typeof elements.addEventListener === 'function') {\n return _delegate.apply(null, arguments);\n }\n\n // Handle Element-less usage, it defaults to global delegation\n if (typeof type === 'function') {\n // Use `document` as the first parameter, then apply arguments\n // This is a short way to .unshift `arguments` without running into deoptimizations\n return _delegate.bind(null, document).apply(null, arguments);\n }\n\n // Handle Selector-based usage\n if (typeof elements === 'string') {\n elements = document.querySelectorAll(elements);\n }\n\n // Handle Array-like based usage\n return Array.prototype.map.call(elements, function (element) {\n return _delegate(element, selector, type, callback, useCapture);\n });\n}\n\n/**\n * Finds closest match and invokes callback.\n *\n * @param {Element} element\n * @param {String} selector\n * @param {String} type\n * @param {Function} callback\n * @return {Function}\n */\nfunction listener(element, selector, type, callback) {\n return function(e) {\n e.delegateTarget = closest(e.target, selector);\n\n if (e.delegateTarget) {\n callback.call(element, e);\n }\n }\n}\n\nmodule.exports = delegate;\n\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports) {\n\nvar DOCUMENT_NODE_TYPE = 9;\n\n/**\n * A polyfill for Element.matches()\n */\nif (typeof Element !== 'undefined' && !Element.prototype.matches) {\n var proto = Element.prototype;\n\n proto.matches = proto.matchesSelector ||\n proto.mozMatchesSelector ||\n proto.msMatchesSelector ||\n proto.oMatchesSelector ||\n proto.webkitMatchesSelector;\n}\n\n/**\n * Finds the closest parent that matches a selector.\n *\n * @param {Element} element\n * @param {String} selector\n * @return {Function}\n */\nfunction closest (element, selector) {\n while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {\n if (typeof element.matches === 'function' &&\n element.matches(selector)) {\n return element;\n }\n element = element.parentNode;\n }\n}\n\nmodule.exports = closest;\n\n\n/***/ }),\n/* 6 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n\n// EXTERNAL MODULE: ./node_modules/select/src/select.js\nvar src_select = __webpack_require__(0);\nvar select_default = /*#__PURE__*/__webpack_require__.n(src_select);\n\n// CONCATENATED MODULE: ./src/clipboard-action.js\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n\n\n/**\n * Inner class which performs selection from either `text` or `target`\n * properties and then executes copy or cut operations.\n */\n\nvar clipboard_action_ClipboardAction = function () {\n /**\n * @param {Object} options\n */\n function ClipboardAction(options) {\n _classCallCheck(this, ClipboardAction);\n\n this.resolveOptions(options);\n this.initSelection();\n }\n\n /**\n * Defines base properties passed from constructor.\n * @param {Object} options\n */\n\n\n _createClass(ClipboardAction, [{\n key: 'resolveOptions',\n value: function resolveOptions() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n this.action = options.action;\n this.container = options.container;\n this.emitter = options.emitter;\n this.target = options.target;\n this.text = options.text;\n this.trigger = options.trigger;\n\n this.selectedText = '';\n }\n\n /**\n * Decides which selection strategy is going to be applied based\n * on the existence of `text` and `target` properties.\n */\n\n }, {\n key: 'initSelection',\n value: function initSelection() {\n if (this.text) {\n this.selectFake();\n } else if (this.target) {\n this.selectTarget();\n }\n }\n\n /**\n * Creates a fake textarea element, sets its value from `text` property,\n * and makes a selection on it.\n */\n\n }, {\n key: 'selectFake',\n value: function selectFake() {\n var _this = this;\n\n var isRTL = document.documentElement.getAttribute('dir') == 'rtl';\n\n this.removeFake();\n\n this.fakeHandlerCallback = function () {\n return _this.removeFake();\n };\n this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true;\n\n this.fakeElem = document.createElement('textarea');\n // Prevent zooming on iOS\n this.fakeElem.style.fontSize = '12pt';\n // Reset box model\n this.fakeElem.style.border = '0';\n this.fakeElem.style.padding = '0';\n this.fakeElem.style.margin = '0';\n // Move element out of screen horizontally\n this.fakeElem.style.position = 'absolute';\n this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';\n // Move element to the same position vertically\n var yPosition = window.pageYOffset || document.documentElement.scrollTop;\n this.fakeElem.style.top = yPosition + 'px';\n\n this.fakeElem.setAttribute('readonly', '');\n this.fakeElem.value = this.text;\n\n this.container.appendChild(this.fakeElem);\n\n this.selectedText = select_default()(this.fakeElem);\n this.copyText();\n }\n\n /**\n * Only removes the fake element after another click event, that way\n * a user can hit `Ctrl+C` to copy because selection still exists.\n */\n\n }, {\n key: 'removeFake',\n value: function removeFake() {\n if (this.fakeHandler) {\n this.container.removeEventListener('click', this.fakeHandlerCallback);\n this.fakeHandler = null;\n this.fakeHandlerCallback = null;\n }\n\n if (this.fakeElem) {\n this.container.removeChild(this.fakeElem);\n this.fakeElem = null;\n }\n }\n\n /**\n * Selects the content from element passed on `target` property.\n */\n\n }, {\n key: 'selectTarget',\n value: function selectTarget() {\n this.selectedText = select_default()(this.target);\n this.copyText();\n }\n\n /**\n * Executes the copy operation based on the current selection.\n */\n\n }, {\n key: 'copyText',\n value: function copyText() {\n var succeeded = void 0;\n\n try {\n succeeded = document.execCommand(this.action);\n } catch (err) {\n succeeded = false;\n }\n\n this.handleResult(succeeded);\n }\n\n /**\n * Fires an event based on the copy operation result.\n * @param {Boolean} succeeded\n */\n\n }, {\n key: 'handleResult',\n value: function handleResult(succeeded) {\n this.emitter.emit(succeeded ? 'success' : 'error', {\n action: this.action,\n text: this.selectedText,\n trigger: this.trigger,\n clearSelection: this.clearSelection.bind(this)\n });\n }\n\n /**\n * Moves focus away from `target` and back to the trigger, removes current selection.\n */\n\n }, {\n key: 'clearSelection',\n value: function clearSelection() {\n if (this.trigger) {\n this.trigger.focus();\n }\n document.activeElement.blur();\n window.getSelection().removeAllRanges();\n }\n\n /**\n * Sets the `action` to be performed which can be either 'copy' or 'cut'.\n * @param {String} action\n */\n\n }, {\n key: 'destroy',\n\n\n /**\n * Destroy lifecycle.\n */\n value: function destroy() {\n this.removeFake();\n }\n }, {\n key: 'action',\n set: function set() {\n var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';\n\n this._action = action;\n\n if (this._action !== 'copy' && this._action !== 'cut') {\n throw new Error('Invalid \"action\" value, use either \"copy\" or \"cut\"');\n }\n }\n\n /**\n * Gets the `action` property.\n * @return {String}\n */\n ,\n get: function get() {\n return this._action;\n }\n\n /**\n * Sets the `target` property using an element\n * that will be have its content copied.\n * @param {Element} target\n */\n\n }, {\n key: 'target',\n set: function set(target) {\n if (target !== undefined) {\n if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) {\n if (this.action === 'copy' && target.hasAttribute('disabled')) {\n throw new Error('Invalid \"target\" attribute. Please use \"readonly\" instead of \"disabled\" attribute');\n }\n\n if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {\n throw new Error('Invalid \"target\" attribute. You can\\'t cut text from elements with \"readonly\" or \"disabled\" attributes');\n }\n\n this._target = target;\n } else {\n throw new Error('Invalid \"target\" value, use a valid Element');\n }\n }\n }\n\n /**\n * Gets the `target` property.\n * @return {String|HTMLElement}\n */\n ,\n get: function get() {\n return this._target;\n }\n }]);\n\n return ClipboardAction;\n}();\n\n/* harmony default export */ var clipboard_action = (clipboard_action_ClipboardAction);\n// EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js\nvar tiny_emitter = __webpack_require__(1);\nvar tiny_emitter_default = /*#__PURE__*/__webpack_require__.n(tiny_emitter);\n\n// EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js\nvar listen = __webpack_require__(2);\nvar listen_default = /*#__PURE__*/__webpack_require__.n(listen);\n\n// CONCATENATED MODULE: ./src/clipboard.js\nvar clipboard_typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nvar clipboard_createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction clipboard_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n\n\n\n\n/**\n * Base class which takes one or more elements, adds event listeners to them,\n * and instantiates a new `ClipboardAction` on each click.\n */\n\nvar clipboard_Clipboard = function (_Emitter) {\n _inherits(Clipboard, _Emitter);\n\n /**\n * @param {String|HTMLElement|HTMLCollection|NodeList} trigger\n * @param {Object} options\n */\n function Clipboard(trigger, options) {\n clipboard_classCallCheck(this, Clipboard);\n\n var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this));\n\n _this.resolveOptions(options);\n _this.listenClick(trigger);\n return _this;\n }\n\n /**\n * Defines if attributes would be resolved using internal setter functions\n * or custom functions that were passed in the constructor.\n * @param {Object} options\n */\n\n\n clipboard_createClass(Clipboard, [{\n key: 'resolveOptions',\n value: function resolveOptions() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n this.action = typeof options.action === 'function' ? options.action : this.defaultAction;\n this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;\n this.text = typeof options.text === 'function' ? options.text : this.defaultText;\n this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body;\n }\n\n /**\n * Adds a click event listener to the passed trigger.\n * @param {String|HTMLElement|HTMLCollection|NodeList} trigger\n */\n\n }, {\n key: 'listenClick',\n value: function listenClick(trigger) {\n var _this2 = this;\n\n this.listener = listen_default()(trigger, 'click', function (e) {\n return _this2.onClick(e);\n });\n }\n\n /**\n * Defines a new `ClipboardAction` on each click event.\n * @param {Event} e\n */\n\n }, {\n key: 'onClick',\n value: function onClick(e) {\n var trigger = e.delegateTarget || e.currentTarget;\n\n if (this.clipboardAction) {\n this.clipboardAction = null;\n }\n\n this.clipboardAction = new clipboard_action({\n action: this.action(trigger),\n target: this.target(trigger),\n text: this.text(trigger),\n container: this.container,\n trigger: trigger,\n emitter: this\n });\n }\n\n /**\n * Default `action` lookup function.\n * @param {Element} trigger\n */\n\n }, {\n key: 'defaultAction',\n value: function defaultAction(trigger) {\n return getAttributeValue('action', trigger);\n }\n\n /**\n * Default `target` lookup function.\n * @param {Element} trigger\n */\n\n }, {\n key: 'defaultTarget',\n value: function defaultTarget(trigger) {\n var selector = getAttributeValue('target', trigger);\n\n if (selector) {\n return document.querySelector(selector);\n }\n }\n\n /**\n * Returns the support of the given action, or all actions if no action is\n * given.\n * @param {String} [action]\n */\n\n }, {\n key: 'defaultText',\n\n\n /**\n * Default `text` lookup function.\n * @param {Element} trigger\n */\n value: function defaultText(trigger) {\n return getAttributeValue('text', trigger);\n }\n\n /**\n * Destroy lifecycle.\n */\n\n }, {\n key: 'destroy',\n value: function destroy() {\n this.listener.destroy();\n\n if (this.clipboardAction) {\n this.clipboardAction.destroy();\n this.clipboardAction = null;\n }\n }\n }], [{\n key: 'isSupported',\n value: function isSupported() {\n var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];\n\n var actions = typeof action === 'string' ? [action] : action;\n var support = !!document.queryCommandSupported;\n\n actions.forEach(function (action) {\n support = support && !!document.queryCommandSupported(action);\n });\n\n return support;\n }\n }]);\n\n return Clipboard;\n}(tiny_emitter_default.a);\n\n/**\n * Helper function to retrieve attribute value.\n * @param {String} suffix\n * @param {Element} element\n */\n\n\nfunction getAttributeValue(suffix, element) {\n var attribute = 'data-clipboard-' + suffix;\n\n if (!element.hasAttribute(attribute)) {\n return;\n }\n\n return element.getAttribute(attribute);\n}\n\n/* harmony default export */ var clipboard = __webpack_exports__[\"default\"] = (clipboard_Clipboard);\n\n/***/ })\n/******/ ])[\"default\"];\n});","import { __extends } from \"tslib\";\nimport { isScheduler } from '../util/isScheduler';\nimport { isArray } from '../util/isArray';\nimport { OuterSubscriber } from '../OuterSubscriber';\nimport { subscribeToResult } from '../util/subscribeToResult';\nimport { fromArray } from './fromArray';\nvar NONE = {};\nexport function combineLatest() {\n var observables = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n observables[_i] = arguments[_i];\n }\n var resultSelector = undefined;\n var scheduler = undefined;\n if (isScheduler(observables[observables.length - 1])) {\n scheduler = observables.pop();\n }\n if (typeof observables[observables.length - 1] === 'function') {\n resultSelector = observables.pop();\n }\n if (observables.length === 1 && isArray(observables[0])) {\n observables = observables[0];\n }\n return fromArray(observables, scheduler).lift(new CombineLatestOperator(resultSelector));\n}\nvar CombineLatestOperator = (function () {\n function CombineLatestOperator(resultSelector) {\n this.resultSelector = resultSelector;\n }\n CombineLatestOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new CombineLatestSubscriber(subscriber, this.resultSelector));\n };\n return CombineLatestOperator;\n}());\nexport { CombineLatestOperator };\nvar CombineLatestSubscriber = (function (_super) {\n __extends(CombineLatestSubscriber, _super);\n function CombineLatestSubscriber(destination, resultSelector) {\n var _this = _super.call(this, destination) || this;\n _this.resultSelector = resultSelector;\n _this.active = 0;\n _this.values = [];\n _this.observables = [];\n return _this;\n }\n CombineLatestSubscriber.prototype._next = function (observable) {\n this.values.push(NONE);\n this.observables.push(observable);\n };\n CombineLatestSubscriber.prototype._complete = function () {\n var observables = this.observables;\n var len = observables.length;\n if (len === 0) {\n this.destination.complete();\n }\n else {\n this.active = len;\n this.toRespond = len;\n for (var i = 0; i < len; i++) {\n var observable = observables[i];\n this.add(subscribeToResult(this, observable, observable, i));\n }\n }\n };\n CombineLatestSubscriber.prototype.notifyComplete = function (unused) {\n if ((this.active -= 1) === 0) {\n this.destination.complete();\n }\n };\n CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {\n var values = this.values;\n var oldVal = values[outerIndex];\n var toRespond = !this.toRespond\n ? 0\n : oldVal === NONE ? --this.toRespond : this.toRespond;\n values[outerIndex] = innerValue;\n if (toRespond === 0) {\n if (this.resultSelector) {\n this._tryResultSelector(values);\n }\n else {\n this.destination.next(values.slice());\n }\n }\n };\n CombineLatestSubscriber.prototype._tryResultSelector = function (values) {\n var result;\n try {\n result = this.resultSelector.apply(this, values);\n }\n catch (err) {\n this.destination.error(err);\n return;\n }\n this.destination.next(result);\n };\n return CombineLatestSubscriber;\n}(OuterSubscriber));\nexport { CombineLatestSubscriber };\n//# sourceMappingURL=combineLatest.js.map","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","/**\r\n * A collection of shims that provide minimal functionality of the ES6 collections.\r\n *\r\n * These implementations are not meant to be used outside of the ResizeObserver\r\n * modules as they cover only a limited range of use cases.\r\n */\r\n/* eslint-disable require-jsdoc, valid-jsdoc */\r\nvar MapShim = (function () {\r\n if (typeof Map !== 'undefined') {\r\n return Map;\r\n }\r\n /**\r\n * Returns index in provided array that matches the specified key.\r\n *\r\n * @param {Array} arr\r\n * @param {*} key\r\n * @returns {number}\r\n */\r\n function getIndex(arr, key) {\r\n var result = -1;\r\n arr.some(function (entry, index) {\r\n if (entry[0] === key) {\r\n result = index;\r\n return true;\r\n }\r\n return false;\r\n });\r\n return result;\r\n }\r\n return /** @class */ (function () {\r\n function class_1() {\r\n this.__entries__ = [];\r\n }\r\n Object.defineProperty(class_1.prototype, \"size\", {\r\n /**\r\n * @returns {boolean}\r\n */\r\n get: function () {\r\n return this.__entries__.length;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * @param {*} key\r\n * @returns {*}\r\n */\r\n class_1.prototype.get = function (key) {\r\n var index = getIndex(this.__entries__, key);\r\n var entry = this.__entries__[index];\r\n return entry && entry[1];\r\n };\r\n /**\r\n * @param {*} key\r\n * @param {*} value\r\n * @returns {void}\r\n */\r\n class_1.prototype.set = function (key, value) {\r\n var index = getIndex(this.__entries__, key);\r\n if (~index) {\r\n this.__entries__[index][1] = value;\r\n }\r\n else {\r\n this.__entries__.push([key, value]);\r\n }\r\n };\r\n /**\r\n * @param {*} key\r\n * @returns {void}\r\n */\r\n class_1.prototype.delete = function (key) {\r\n var entries = this.__entries__;\r\n var index = getIndex(entries, key);\r\n if (~index) {\r\n entries.splice(index, 1);\r\n }\r\n };\r\n /**\r\n * @param {*} key\r\n * @returns {void}\r\n */\r\n class_1.prototype.has = function (key) {\r\n return !!~getIndex(this.__entries__, key);\r\n };\r\n /**\r\n * @returns {void}\r\n */\r\n class_1.prototype.clear = function () {\r\n this.__entries__.splice(0);\r\n };\r\n /**\r\n * @param {Function} callback\r\n * @param {*} [ctx=null]\r\n * @returns {void}\r\n */\r\n class_1.prototype.forEach = function (callback, ctx) {\r\n if (ctx === void 0) { ctx = null; }\r\n for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {\r\n var entry = _a[_i];\r\n callback.call(ctx, entry[1], entry[0]);\r\n }\r\n };\r\n return class_1;\r\n }());\r\n})();\n\n/**\r\n * Detects whether window and document objects are available in current environment.\r\n */\r\nvar isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document;\n\n// Returns global object of a current environment.\r\nvar global$1 = (function () {\r\n if (typeof global !== 'undefined' && global.Math === Math) {\r\n return global;\r\n }\r\n if (typeof self !== 'undefined' && self.Math === Math) {\r\n return self;\r\n }\r\n if (typeof window !== 'undefined' && window.Math === Math) {\r\n return window;\r\n }\r\n // eslint-disable-next-line no-new-func\r\n return Function('return this')();\r\n})();\n\n/**\r\n * A shim for the requestAnimationFrame which falls back to the setTimeout if\r\n * first one is not supported.\r\n *\r\n * @returns {number} Requests' identifier.\r\n */\r\nvar requestAnimationFrame$1 = (function () {\r\n if (typeof requestAnimationFrame === 'function') {\r\n // It's required to use a bounded function because IE sometimes throws\r\n // an \"Invalid calling object\" error if rAF is invoked without the global\r\n // object on the left hand side.\r\n return requestAnimationFrame.bind(global$1);\r\n }\r\n return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };\r\n})();\n\n// Defines minimum timeout before adding a trailing call.\r\nvar trailingTimeout = 2;\r\n/**\r\n * Creates a wrapper function which ensures that provided callback will be\r\n * invoked only once during the specified delay period.\r\n *\r\n * @param {Function} callback - Function to be invoked after the delay period.\r\n * @param {number} delay - Delay after which to invoke callback.\r\n * @returns {Function}\r\n */\r\nfunction throttle (callback, delay) {\r\n var leadingCall = false, trailingCall = false, lastCallTime = 0;\r\n /**\r\n * Invokes the original callback function and schedules new invocation if\r\n * the \"proxy\" was called during current request.\r\n *\r\n * @returns {void}\r\n */\r\n function resolvePending() {\r\n if (leadingCall) {\r\n leadingCall = false;\r\n callback();\r\n }\r\n if (trailingCall) {\r\n proxy();\r\n }\r\n }\r\n /**\r\n * Callback invoked after the specified delay. It will further postpone\r\n * invocation of the original function delegating it to the\r\n * requestAnimationFrame.\r\n *\r\n * @returns {void}\r\n */\r\n function timeoutCallback() {\r\n requestAnimationFrame$1(resolvePending);\r\n }\r\n /**\r\n * Schedules invocation of the original function.\r\n *\r\n * @returns {void}\r\n */\r\n function proxy() {\r\n var timeStamp = Date.now();\r\n if (leadingCall) {\r\n // Reject immediately following calls.\r\n if (timeStamp - lastCallTime < trailingTimeout) {\r\n return;\r\n }\r\n // Schedule new call to be in invoked when the pending one is resolved.\r\n // This is important for \"transitions\" which never actually start\r\n // immediately so there is a chance that we might miss one if change\r\n // happens amids the pending invocation.\r\n trailingCall = true;\r\n }\r\n else {\r\n leadingCall = true;\r\n trailingCall = false;\r\n setTimeout(timeoutCallback, delay);\r\n }\r\n lastCallTime = timeStamp;\r\n }\r\n return proxy;\r\n}\n\n// Minimum delay before invoking the update of observers.\r\nvar REFRESH_DELAY = 20;\r\n// A list of substrings of CSS properties used to find transition events that\r\n// might affect dimensions of observed elements.\r\nvar transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];\r\n// Check if MutationObserver is available.\r\nvar mutationObserverSupported = typeof MutationObserver !== 'undefined';\r\n/**\r\n * Singleton controller class which handles updates of ResizeObserver instances.\r\n */\r\nvar ResizeObserverController = /** @class */ (function () {\r\n /**\r\n * Creates a new instance of ResizeObserverController.\r\n *\r\n * @private\r\n */\r\n function ResizeObserverController() {\r\n /**\r\n * Indicates whether DOM listeners have been added.\r\n *\r\n * @private {boolean}\r\n */\r\n this.connected_ = false;\r\n /**\r\n * Tells that controller has subscribed for Mutation Events.\r\n *\r\n * @private {boolean}\r\n */\r\n this.mutationEventsAdded_ = false;\r\n /**\r\n * Keeps reference to the instance of MutationObserver.\r\n *\r\n * @private {MutationObserver}\r\n */\r\n this.mutationsObserver_ = null;\r\n /**\r\n * A list of connected observers.\r\n *\r\n * @private {Array}\r\n */\r\n this.observers_ = [];\r\n this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);\r\n this.refresh = throttle(this.refresh.bind(this), REFRESH_DELAY);\r\n }\r\n /**\r\n * Adds observer to observers list.\r\n *\r\n * @param {ResizeObserverSPI} observer - Observer to be added.\r\n * @returns {void}\r\n */\r\n ResizeObserverController.prototype.addObserver = function (observer) {\r\n if (!~this.observers_.indexOf(observer)) {\r\n this.observers_.push(observer);\r\n }\r\n // Add listeners if they haven't been added yet.\r\n if (!this.connected_) {\r\n this.connect_();\r\n }\r\n };\r\n /**\r\n * Removes observer from observers list.\r\n *\r\n * @param {ResizeObserverSPI} observer - Observer to be removed.\r\n * @returns {void}\r\n */\r\n ResizeObserverController.prototype.removeObserver = function (observer) {\r\n var observers = this.observers_;\r\n var index = observers.indexOf(observer);\r\n // Remove observer if it's present in registry.\r\n if (~index) {\r\n observers.splice(index, 1);\r\n }\r\n // Remove listeners if controller has no connected observers.\r\n if (!observers.length && this.connected_) {\r\n this.disconnect_();\r\n }\r\n };\r\n /**\r\n * Invokes the update of observers. It will continue running updates insofar\r\n * it detects changes.\r\n *\r\n * @returns {void}\r\n */\r\n ResizeObserverController.prototype.refresh = function () {\r\n var changesDetected = this.updateObservers_();\r\n // Continue running updates if changes have been detected as there might\r\n // be future ones caused by CSS transitions.\r\n if (changesDetected) {\r\n this.refresh();\r\n }\r\n };\r\n /**\r\n * Updates every observer from observers list and notifies them of queued\r\n * entries.\r\n *\r\n * @private\r\n * @returns {boolean} Returns \"true\" if any observer has detected changes in\r\n * dimensions of it's elements.\r\n */\r\n ResizeObserverController.prototype.updateObservers_ = function () {\r\n // Collect observers that have active observations.\r\n var activeObservers = this.observers_.filter(function (observer) {\r\n return observer.gatherActive(), observer.hasActive();\r\n });\r\n // Deliver notifications in a separate cycle in order to avoid any\r\n // collisions between observers, e.g. when multiple instances of\r\n // ResizeObserver are tracking the same element and the callback of one\r\n // of them changes content dimensions of the observed target. Sometimes\r\n // this may result in notifications being blocked for the rest of observers.\r\n activeObservers.forEach(function (observer) { return observer.broadcastActive(); });\r\n return activeObservers.length > 0;\r\n };\r\n /**\r\n * Initializes DOM listeners.\r\n *\r\n * @private\r\n * @returns {void}\r\n */\r\n ResizeObserverController.prototype.connect_ = function () {\r\n // Do nothing if running in a non-browser environment or if listeners\r\n // have been already added.\r\n if (!isBrowser || this.connected_) {\r\n return;\r\n }\r\n // Subscription to the \"Transitionend\" event is used as a workaround for\r\n // delayed transitions. This way it's possible to capture at least the\r\n // final state of an element.\r\n document.addEventListener('transitionend', this.onTransitionEnd_);\r\n window.addEventListener('resize', this.refresh);\r\n if (mutationObserverSupported) {\r\n this.mutationsObserver_ = new MutationObserver(this.refresh);\r\n this.mutationsObserver_.observe(document, {\r\n attributes: true,\r\n childList: true,\r\n characterData: true,\r\n subtree: true\r\n });\r\n }\r\n else {\r\n document.addEventListener('DOMSubtreeModified', this.refresh);\r\n this.mutationEventsAdded_ = true;\r\n }\r\n this.connected_ = true;\r\n };\r\n /**\r\n * Removes DOM listeners.\r\n *\r\n * @private\r\n * @returns {void}\r\n */\r\n ResizeObserverController.prototype.disconnect_ = function () {\r\n // Do nothing if running in a non-browser environment or if listeners\r\n // have been already removed.\r\n if (!isBrowser || !this.connected_) {\r\n return;\r\n }\r\n document.removeEventListener('transitionend', this.onTransitionEnd_);\r\n window.removeEventListener('resize', this.refresh);\r\n if (this.mutationsObserver_) {\r\n this.mutationsObserver_.disconnect();\r\n }\r\n if (this.mutationEventsAdded_) {\r\n document.removeEventListener('DOMSubtreeModified', this.refresh);\r\n }\r\n this.mutationsObserver_ = null;\r\n this.mutationEventsAdded_ = false;\r\n this.connected_ = false;\r\n };\r\n /**\r\n * \"Transitionend\" event handler.\r\n *\r\n * @private\r\n * @param {TransitionEvent} event\r\n * @returns {void}\r\n */\r\n ResizeObserverController.prototype.onTransitionEnd_ = function (_a) {\r\n var _b = _a.propertyName, propertyName = _b === void 0 ? '' : _b;\r\n // Detect whether transition may affect dimensions of an element.\r\n var isReflowProperty = transitionKeys.some(function (key) {\r\n return !!~propertyName.indexOf(key);\r\n });\r\n if (isReflowProperty) {\r\n this.refresh();\r\n }\r\n };\r\n /**\r\n * Returns instance of the ResizeObserverController.\r\n *\r\n * @returns {ResizeObserverController}\r\n */\r\n ResizeObserverController.getInstance = function () {\r\n if (!this.instance_) {\r\n this.instance_ = new ResizeObserverController();\r\n }\r\n return this.instance_;\r\n };\r\n /**\r\n * Holds reference to the controller's instance.\r\n *\r\n * @private {ResizeObserverController}\r\n */\r\n ResizeObserverController.instance_ = null;\r\n return ResizeObserverController;\r\n}());\n\n/**\r\n * Defines non-writable/enumerable properties of the provided target object.\r\n *\r\n * @param {Object} target - Object for which to define properties.\r\n * @param {Object} props - Properties to be defined.\r\n * @returns {Object} Target object.\r\n */\r\nvar defineConfigurable = (function (target, props) {\r\n for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {\r\n var key = _a[_i];\r\n Object.defineProperty(target, key, {\r\n value: props[key],\r\n enumerable: false,\r\n writable: false,\r\n configurable: true\r\n });\r\n }\r\n return target;\r\n});\n\n/**\r\n * Returns the global object associated with provided element.\r\n *\r\n * @param {Object} target\r\n * @returns {Object}\r\n */\r\nvar getWindowOf = (function (target) {\r\n // Assume that the element is an instance of Node, which means that it\r\n // has the \"ownerDocument\" property from which we can retrieve a\r\n // corresponding global object.\r\n var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;\r\n // Return the local global object if it's not possible extract one from\r\n // provided element.\r\n return ownerGlobal || global$1;\r\n});\n\n// Placeholder of an empty content rectangle.\r\nvar emptyRect = createRectInit(0, 0, 0, 0);\r\n/**\r\n * Converts provided string to a number.\r\n *\r\n * @param {number|string} value\r\n * @returns {number}\r\n */\r\nfunction toFloat(value) {\r\n return parseFloat(value) || 0;\r\n}\r\n/**\r\n * Extracts borders size from provided styles.\r\n *\r\n * @param {CSSStyleDeclaration} styles\r\n * @param {...string} positions - Borders positions (top, right, ...)\r\n * @returns {number}\r\n */\r\nfunction getBordersSize(styles) {\r\n var positions = [];\r\n for (var _i = 1; _i < arguments.length; _i++) {\r\n positions[_i - 1] = arguments[_i];\r\n }\r\n return positions.reduce(function (size, position) {\r\n var value = styles['border-' + position + '-width'];\r\n return size + toFloat(value);\r\n }, 0);\r\n}\r\n/**\r\n * Extracts paddings sizes from provided styles.\r\n *\r\n * @param {CSSStyleDeclaration} styles\r\n * @returns {Object} Paddings box.\r\n */\r\nfunction getPaddings(styles) {\r\n var positions = ['top', 'right', 'bottom', 'left'];\r\n var paddings = {};\r\n for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {\r\n var position = positions_1[_i];\r\n var value = styles['padding-' + position];\r\n paddings[position] = toFloat(value);\r\n }\r\n return paddings;\r\n}\r\n/**\r\n * Calculates content rectangle of provided SVG element.\r\n *\r\n * @param {SVGGraphicsElement} target - Element content rectangle of which needs\r\n * to be calculated.\r\n * @returns {DOMRectInit}\r\n */\r\nfunction getSVGContentRect(target) {\r\n var bbox = target.getBBox();\r\n return createRectInit(0, 0, bbox.width, bbox.height);\r\n}\r\n/**\r\n * Calculates content rectangle of provided HTMLElement.\r\n *\r\n * @param {HTMLElement} target - Element for which to calculate the content rectangle.\r\n * @returns {DOMRectInit}\r\n */\r\nfunction getHTMLElementContentRect(target) {\r\n // Client width & height properties can't be\r\n // used exclusively as they provide rounded values.\r\n var clientWidth = target.clientWidth, clientHeight = target.clientHeight;\r\n // By this condition we can catch all non-replaced inline, hidden and\r\n // detached elements. Though elements with width & height properties less\r\n // than 0.5 will be discarded as well.\r\n //\r\n // Without it we would need to implement separate methods for each of\r\n // those cases and it's not possible to perform a precise and performance\r\n // effective test for hidden elements. E.g. even jQuery's ':visible' filter\r\n // gives wrong results for elements with width & height less than 0.5.\r\n if (!clientWidth && !clientHeight) {\r\n return emptyRect;\r\n }\r\n var styles = getWindowOf(target).getComputedStyle(target);\r\n var paddings = getPaddings(styles);\r\n var horizPad = paddings.left + paddings.right;\r\n var vertPad = paddings.top + paddings.bottom;\r\n // Computed styles of width & height are being used because they are the\r\n // only dimensions available to JS that contain non-rounded values. It could\r\n // be possible to utilize the getBoundingClientRect if only it's data wasn't\r\n // affected by CSS transformations let alone paddings, borders and scroll bars.\r\n var width = toFloat(styles.width), height = toFloat(styles.height);\r\n // Width & height include paddings and borders when the 'border-box' box\r\n // model is applied (except for IE).\r\n if (styles.boxSizing === 'border-box') {\r\n // Following conditions are required to handle Internet Explorer which\r\n // doesn't include paddings and borders to computed CSS dimensions.\r\n //\r\n // We can say that if CSS dimensions + paddings are equal to the \"client\"\r\n // properties then it's either IE, and thus we don't need to subtract\r\n // anything, or an element merely doesn't have paddings/borders styles.\r\n if (Math.round(width + horizPad) !== clientWidth) {\r\n width -= getBordersSize(styles, 'left', 'right') + horizPad;\r\n }\r\n if (Math.round(height + vertPad) !== clientHeight) {\r\n height -= getBordersSize(styles, 'top', 'bottom') + vertPad;\r\n }\r\n }\r\n // Following steps can't be applied to the document's root element as its\r\n // client[Width/Height] properties represent viewport area of the window.\r\n // Besides, it's as well not necessary as the itself neither has\r\n // rendered scroll bars nor it can be clipped.\r\n if (!isDocumentElement(target)) {\r\n // In some browsers (only in Firefox, actually) CSS width & height\r\n // include scroll bars size which can be removed at this step as scroll\r\n // bars are the only difference between rounded dimensions + paddings\r\n // and \"client\" properties, though that is not always true in Chrome.\r\n var vertScrollbar = Math.round(width + horizPad) - clientWidth;\r\n var horizScrollbar = Math.round(height + vertPad) - clientHeight;\r\n // Chrome has a rather weird rounding of \"client\" properties.\r\n // E.g. for an element with content width of 314.2px it sometimes gives\r\n // the client width of 315px and for the width of 314.7px it may give\r\n // 314px. And it doesn't happen all the time. So just ignore this delta\r\n // as a non-relevant.\r\n if (Math.abs(vertScrollbar) !== 1) {\r\n width -= vertScrollbar;\r\n }\r\n if (Math.abs(horizScrollbar) !== 1) {\r\n height -= horizScrollbar;\r\n }\r\n }\r\n return createRectInit(paddings.left, paddings.top, width, height);\r\n}\r\n/**\r\n * Checks whether provided element is an instance of the SVGGraphicsElement.\r\n *\r\n * @param {Element} target - Element to be checked.\r\n * @returns {boolean}\r\n */\r\nvar isSVGGraphicsElement = (function () {\r\n // Some browsers, namely IE and Edge, don't have the SVGGraphicsElement\r\n // interface.\r\n if (typeof SVGGraphicsElement !== 'undefined') {\r\n return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; };\r\n }\r\n // If it's so, then check that element is at least an instance of the\r\n // SVGElement and that it has the \"getBBox\" method.\r\n // eslint-disable-next-line no-extra-parens\r\n return function (target) { return (target instanceof getWindowOf(target).SVGElement &&\r\n typeof target.getBBox === 'function'); };\r\n})();\r\n/**\r\n * Checks whether provided element is a document element ().\r\n *\r\n * @param {Element} target - Element to be checked.\r\n * @returns {boolean}\r\n */\r\nfunction isDocumentElement(target) {\r\n return target === getWindowOf(target).document.documentElement;\r\n}\r\n/**\r\n * Calculates an appropriate content rectangle for provided html or svg element.\r\n *\r\n * @param {Element} target - Element content rectangle of which needs to be calculated.\r\n * @returns {DOMRectInit}\r\n */\r\nfunction getContentRect(target) {\r\n if (!isBrowser) {\r\n return emptyRect;\r\n }\r\n if (isSVGGraphicsElement(target)) {\r\n return getSVGContentRect(target);\r\n }\r\n return getHTMLElementContentRect(target);\r\n}\r\n/**\r\n * Creates rectangle with an interface of the DOMRectReadOnly.\r\n * Spec: https://drafts.fxtf.org/geometry/#domrectreadonly\r\n *\r\n * @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.\r\n * @returns {DOMRectReadOnly}\r\n */\r\nfunction createReadOnlyRect(_a) {\r\n var x = _a.x, y = _a.y, width = _a.width, height = _a.height;\r\n // If DOMRectReadOnly is available use it as a prototype for the rectangle.\r\n var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;\r\n var rect = Object.create(Constr.prototype);\r\n // Rectangle's properties are not writable and non-enumerable.\r\n defineConfigurable(rect, {\r\n x: x, y: y, width: width, height: height,\r\n top: y,\r\n right: x + width,\r\n bottom: height + y,\r\n left: x\r\n });\r\n return rect;\r\n}\r\n/**\r\n * Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.\r\n * Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit\r\n *\r\n * @param {number} x - X coordinate.\r\n * @param {number} y - Y coordinate.\r\n * @param {number} width - Rectangle's width.\r\n * @param {number} height - Rectangle's height.\r\n * @returns {DOMRectInit}\r\n */\r\nfunction createRectInit(x, y, width, height) {\r\n return { x: x, y: y, width: width, height: height };\r\n}\n\n/**\r\n * Class that is responsible for computations of the content rectangle of\r\n * provided DOM element and for keeping track of it's changes.\r\n */\r\nvar ResizeObservation = /** @class */ (function () {\r\n /**\r\n * Creates an instance of ResizeObservation.\r\n *\r\n * @param {Element} target - Element to be observed.\r\n */\r\n function ResizeObservation(target) {\r\n /**\r\n * Broadcasted width of content rectangle.\r\n *\r\n * @type {number}\r\n */\r\n this.broadcastWidth = 0;\r\n /**\r\n * Broadcasted height of content rectangle.\r\n *\r\n * @type {number}\r\n */\r\n this.broadcastHeight = 0;\r\n /**\r\n * Reference to the last observed content rectangle.\r\n *\r\n * @private {DOMRectInit}\r\n */\r\n this.contentRect_ = createRectInit(0, 0, 0, 0);\r\n this.target = target;\r\n }\r\n /**\r\n * Updates content rectangle and tells whether it's width or height properties\r\n * have changed since the last broadcast.\r\n *\r\n * @returns {boolean}\r\n */\r\n ResizeObservation.prototype.isActive = function () {\r\n var rect = getContentRect(this.target);\r\n this.contentRect_ = rect;\r\n return (rect.width !== this.broadcastWidth ||\r\n rect.height !== this.broadcastHeight);\r\n };\r\n /**\r\n * Updates 'broadcastWidth' and 'broadcastHeight' properties with a data\r\n * from the corresponding properties of the last observed content rectangle.\r\n *\r\n * @returns {DOMRectInit} Last observed content rectangle.\r\n */\r\n ResizeObservation.prototype.broadcastRect = function () {\r\n var rect = this.contentRect_;\r\n this.broadcastWidth = rect.width;\r\n this.broadcastHeight = rect.height;\r\n return rect;\r\n };\r\n return ResizeObservation;\r\n}());\n\nvar ResizeObserverEntry = /** @class */ (function () {\r\n /**\r\n * Creates an instance of ResizeObserverEntry.\r\n *\r\n * @param {Element} target - Element that is being observed.\r\n * @param {DOMRectInit} rectInit - Data of the element's content rectangle.\r\n */\r\n function ResizeObserverEntry(target, rectInit) {\r\n var contentRect = createReadOnlyRect(rectInit);\r\n // According to the specification following properties are not writable\r\n // and are also not enumerable in the native implementation.\r\n //\r\n // Property accessors are not being used as they'd require to define a\r\n // private WeakMap storage which may cause memory leaks in browsers that\r\n // don't support this type of collections.\r\n defineConfigurable(this, { target: target, contentRect: contentRect });\r\n }\r\n return ResizeObserverEntry;\r\n}());\n\nvar ResizeObserverSPI = /** @class */ (function () {\r\n /**\r\n * Creates a new instance of ResizeObserver.\r\n *\r\n * @param {ResizeObserverCallback} callback - Callback function that is invoked\r\n * when one of the observed elements changes it's content dimensions.\r\n * @param {ResizeObserverController} controller - Controller instance which\r\n * is responsible for the updates of observer.\r\n * @param {ResizeObserver} callbackCtx - Reference to the public\r\n * ResizeObserver instance which will be passed to callback function.\r\n */\r\n function ResizeObserverSPI(callback, controller, callbackCtx) {\r\n /**\r\n * Collection of resize observations that have detected changes in dimensions\r\n * of elements.\r\n *\r\n * @private {Array}\r\n */\r\n this.activeObservations_ = [];\r\n /**\r\n * Registry of the ResizeObservation instances.\r\n *\r\n * @private {Map}\r\n */\r\n this.observations_ = new MapShim();\r\n if (typeof callback !== 'function') {\r\n throw new TypeError('The callback provided as parameter 1 is not a function.');\r\n }\r\n this.callback_ = callback;\r\n this.controller_ = controller;\r\n this.callbackCtx_ = callbackCtx;\r\n }\r\n /**\r\n * Starts observing provided element.\r\n *\r\n * @param {Element} target - Element to be observed.\r\n * @returns {void}\r\n */\r\n ResizeObserverSPI.prototype.observe = function (target) {\r\n if (!arguments.length) {\r\n throw new TypeError('1 argument required, but only 0 present.');\r\n }\r\n // Do nothing if current environment doesn't have the Element interface.\r\n if (typeof Element === 'undefined' || !(Element instanceof Object)) {\r\n return;\r\n }\r\n if (!(target instanceof getWindowOf(target).Element)) {\r\n throw new TypeError('parameter 1 is not of type \"Element\".');\r\n }\r\n var observations = this.observations_;\r\n // Do nothing if element is already being observed.\r\n if (observations.has(target)) {\r\n return;\r\n }\r\n observations.set(target, new ResizeObservation(target));\r\n this.controller_.addObserver(this);\r\n // Force the update of observations.\r\n this.controller_.refresh();\r\n };\r\n /**\r\n * Stops observing provided element.\r\n *\r\n * @param {Element} target - Element to stop observing.\r\n * @returns {void}\r\n */\r\n ResizeObserverSPI.prototype.unobserve = function (target) {\r\n if (!arguments.length) {\r\n throw new TypeError('1 argument required, but only 0 present.');\r\n }\r\n // Do nothing if current environment doesn't have the Element interface.\r\n if (typeof Element === 'undefined' || !(Element instanceof Object)) {\r\n return;\r\n }\r\n if (!(target instanceof getWindowOf(target).Element)) {\r\n throw new TypeError('parameter 1 is not of type \"Element\".');\r\n }\r\n var observations = this.observations_;\r\n // Do nothing if element is not being observed.\r\n if (!observations.has(target)) {\r\n return;\r\n }\r\n observations.delete(target);\r\n if (!observations.size) {\r\n this.controller_.removeObserver(this);\r\n }\r\n };\r\n /**\r\n * Stops observing all elements.\r\n *\r\n * @returns {void}\r\n */\r\n ResizeObserverSPI.prototype.disconnect = function () {\r\n this.clearActive();\r\n this.observations_.clear();\r\n this.controller_.removeObserver(this);\r\n };\r\n /**\r\n * Collects observation instances the associated element of which has changed\r\n * it's content rectangle.\r\n *\r\n * @returns {void}\r\n */\r\n ResizeObserverSPI.prototype.gatherActive = function () {\r\n var _this = this;\r\n this.clearActive();\r\n this.observations_.forEach(function (observation) {\r\n if (observation.isActive()) {\r\n _this.activeObservations_.push(observation);\r\n }\r\n });\r\n };\r\n /**\r\n * Invokes initial callback function with a list of ResizeObserverEntry\r\n * instances collected from active resize observations.\r\n *\r\n * @returns {void}\r\n */\r\n ResizeObserverSPI.prototype.broadcastActive = function () {\r\n // Do nothing if observer doesn't have active observations.\r\n if (!this.hasActive()) {\r\n return;\r\n }\r\n var ctx = this.callbackCtx_;\r\n // Create ResizeObserverEntry instance for every active observation.\r\n var entries = this.activeObservations_.map(function (observation) {\r\n return new ResizeObserverEntry(observation.target, observation.broadcastRect());\r\n });\r\n this.callback_.call(ctx, entries, ctx);\r\n this.clearActive();\r\n };\r\n /**\r\n * Clears the collection of active observations.\r\n *\r\n * @returns {void}\r\n */\r\n ResizeObserverSPI.prototype.clearActive = function () {\r\n this.activeObservations_.splice(0);\r\n };\r\n /**\r\n * Tells whether observer has active observations.\r\n *\r\n * @returns {boolean}\r\n */\r\n ResizeObserverSPI.prototype.hasActive = function () {\r\n return this.activeObservations_.length > 0;\r\n };\r\n return ResizeObserverSPI;\r\n}());\n\n// Registry of internal observers. If WeakMap is not available use current shim\r\n// for the Map collection as it has all required methods and because WeakMap\r\n// can't be fully polyfilled anyway.\r\nvar observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();\r\n/**\r\n * ResizeObserver API. Encapsulates the ResizeObserver SPI implementation\r\n * exposing only those methods and properties that are defined in the spec.\r\n */\r\nvar ResizeObserver = /** @class */ (function () {\r\n /**\r\n * Creates a new instance of ResizeObserver.\r\n *\r\n * @param {ResizeObserverCallback} callback - Callback that is invoked when\r\n * dimensions of the observed elements change.\r\n */\r\n function ResizeObserver(callback) {\r\n if (!(this instanceof ResizeObserver)) {\r\n throw new TypeError('Cannot call a class as a function.');\r\n }\r\n if (!arguments.length) {\r\n throw new TypeError('1 argument required, but only 0 present.');\r\n }\r\n var controller = ResizeObserverController.getInstance();\r\n var observer = new ResizeObserverSPI(callback, controller, this);\r\n observers.set(this, observer);\r\n }\r\n return ResizeObserver;\r\n}());\r\n// Expose public methods of ResizeObserver.\r\n[\r\n 'observe',\r\n 'unobserve',\r\n 'disconnect'\r\n].forEach(function (method) {\r\n ResizeObserver.prototype[method] = function () {\r\n var _a;\r\n return (_a = observers.get(this))[method].apply(_a, arguments);\r\n };\r\n});\n\nvar index = (function () {\r\n // Export existing implementation if available.\r\n if (typeof global$1.ResizeObserver !== 'undefined') {\r\n return global$1.ResizeObserver;\r\n }\r\n return ResizeObserver;\r\n})();\n\nexport default index;\n","import { Observable } from '../Observable';\nimport { from } from './from';\nimport { EMPTY } from './empty';\nexport function defer(observableFactory) {\n return new Observable(function (subscriber) {\n var input;\n try {\n input = observableFactory();\n }\n catch (err) {\n subscriber.error(err);\n return undefined;\n }\n var source = input ? from(input) : EMPTY;\n return source.subscribe(subscriber);\n });\n}\n//# sourceMappingURL=defer.js.map","/*!\n * escape-html\n * Copyright(c) 2012-2013 TJ Holowaychuk\n * Copyright(c) 2015 Andreas Lubbe\n * Copyright(c) 2015 Tiancheng \"Timothy\" Gu\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module variables.\n * @private\n */\n\nvar matchHtmlRegExp = /[\"'&<>]/;\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = escapeHtml;\n\n/**\n * Escape special characters in the given string of html.\n *\n * @param {string} string The string to escape for inserting into HTML\n * @return {string}\n * @public\n */\n\nfunction escapeHtml(string) {\n var str = '' + string;\n var match = matchHtmlRegExp.exec(str);\n\n if (!match) {\n return str;\n }\n\n var escape;\n var html = '';\n var index = 0;\n var lastIndex = 0;\n\n for (index = match.index; index < str.length; index++) {\n switch (str.charCodeAt(index)) {\n case 34: // \"\n escape = '"';\n break;\n case 38: // &\n escape = '&';\n break;\n case 39: // '\n escape = ''';\n break;\n case 60: // <\n escape = '<';\n break;\n case 62: // >\n escape = '>';\n break;\n default:\n continue;\n }\n\n if (lastIndex !== index) {\n html += str.substring(lastIndex, index);\n }\n\n lastIndex = index + 1;\n html += escape;\n }\n\n return lastIndex !== index\n ? html + str.substring(lastIndex, index)\n : html;\n}\n","import { __extends } from \"tslib\";\nimport { AsyncAction } from './AsyncAction';\nvar QueueAction = (function (_super) {\n __extends(QueueAction, _super);\n function QueueAction(scheduler, work) {\n var _this = _super.call(this, scheduler, work) || this;\n _this.scheduler = scheduler;\n _this.work = work;\n return _this;\n }\n QueueAction.prototype.schedule = function (state, delay) {\n if (delay === void 0) { delay = 0; }\n if (delay > 0) {\n return _super.prototype.schedule.call(this, state, delay);\n }\n this.delay = delay;\n this.state = state;\n this.scheduler.flush(this);\n return this;\n };\n QueueAction.prototype.execute = function (state, delay) {\n return (delay > 0 || this.closed) ?\n _super.prototype.execute.call(this, state, delay) :\n this._execute(state, delay);\n };\n QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) {\n if (delay === void 0) { delay = 0; }\n if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {\n return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);\n }\n return scheduler.flush(this);\n };\n return QueueAction;\n}(AsyncAction));\nexport { QueueAction };\n//# sourceMappingURL=QueueAction.js.map","import { QueueAction } from './QueueAction';\nimport { QueueScheduler } from './QueueScheduler';\nexport var queue = new QueueScheduler(QueueAction);\n//# sourceMappingURL=queue.js.map","import { __extends } from \"tslib\";\nimport { AsyncScheduler } from './AsyncScheduler';\nvar QueueScheduler = (function (_super) {\n __extends(QueueScheduler, _super);\n function QueueScheduler() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n return QueueScheduler;\n}(AsyncScheduler));\nexport { QueueScheduler };\n//# sourceMappingURL=QueueScheduler.js.map","import { __extends } from \"tslib\";\nimport { Subject } from './Subject';\nimport { queue } from './scheduler/queue';\nimport { Subscription } from './Subscription';\nimport { ObserveOnSubscriber } from './operators/observeOn';\nimport { ObjectUnsubscribedError } from './util/ObjectUnsubscribedError';\nimport { SubjectSubscription } from './SubjectSubscription';\nvar ReplaySubject = (function (_super) {\n __extends(ReplaySubject, _super);\n function ReplaySubject(bufferSize, windowTime, scheduler) {\n if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }\n if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }\n var _this = _super.call(this) || this;\n _this.scheduler = scheduler;\n _this._events = [];\n _this._infiniteTimeWindow = false;\n _this._bufferSize = bufferSize < 1 ? 1 : bufferSize;\n _this._windowTime = windowTime < 1 ? 1 : windowTime;\n if (windowTime === Number.POSITIVE_INFINITY) {\n _this._infiniteTimeWindow = true;\n _this.next = _this.nextInfiniteTimeWindow;\n }\n else {\n _this.next = _this.nextTimeWindow;\n }\n return _this;\n }\n ReplaySubject.prototype.nextInfiniteTimeWindow = function (value) {\n var _events = this._events;\n _events.push(value);\n if (_events.length > this._bufferSize) {\n _events.shift();\n }\n _super.prototype.next.call(this, value);\n };\n ReplaySubject.prototype.nextTimeWindow = function (value) {\n this._events.push(new ReplayEvent(this._getNow(), value));\n this._trimBufferThenGetEvents();\n _super.prototype.next.call(this, value);\n };\n ReplaySubject.prototype._subscribe = function (subscriber) {\n var _infiniteTimeWindow = this._infiniteTimeWindow;\n var _events = _infiniteTimeWindow ? this._events : this._trimBufferThenGetEvents();\n var scheduler = this.scheduler;\n var len = _events.length;\n var subscription;\n if (this.closed) {\n throw new ObjectUnsubscribedError();\n }\n else if (this.isStopped || this.hasError) {\n subscription = Subscription.EMPTY;\n }\n else {\n this.observers.push(subscriber);\n subscription = new SubjectSubscription(this, subscriber);\n }\n if (scheduler) {\n subscriber.add(subscriber = new ObserveOnSubscriber(subscriber, scheduler));\n }\n if (_infiniteTimeWindow) {\n for (var i = 0; i < len && !subscriber.closed; i++) {\n subscriber.next(_events[i]);\n }\n }\n else {\n for (var i = 0; i < len && !subscriber.closed; i++) {\n subscriber.next(_events[i].value);\n }\n }\n if (this.hasError) {\n subscriber.error(this.thrownError);\n }\n else if (this.isStopped) {\n subscriber.complete();\n }\n return subscription;\n };\n ReplaySubject.prototype._getNow = function () {\n return (this.scheduler || queue).now();\n };\n ReplaySubject.prototype._trimBufferThenGetEvents = function () {\n var now = this._getNow();\n var _bufferSize = this._bufferSize;\n var _windowTime = this._windowTime;\n var _events = this._events;\n var eventsCount = _events.length;\n var spliceCount = 0;\n while (spliceCount < eventsCount) {\n if ((now - _events[spliceCount].time) < _windowTime) {\n break;\n }\n spliceCount++;\n }\n if (eventsCount > _bufferSize) {\n spliceCount = Math.max(spliceCount, eventsCount - _bufferSize);\n }\n if (spliceCount > 0) {\n _events.splice(0, spliceCount);\n }\n return _events;\n };\n return ReplaySubject;\n}(Subject));\nexport { ReplaySubject };\nvar ReplayEvent = (function () {\n function ReplayEvent(time, value) {\n this.time = time;\n this.value = value;\n }\n return ReplayEvent;\n}());\n//# sourceMappingURL=ReplaySubject.js.map","export default function _has(prop, obj) {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}","import _has from \"./_has.js\";\nvar toString = Object.prototype.toString;\n\nvar _isArguments =\n/*#__PURE__*/\nfunction () {\n return toString.call(arguments) === '[object Arguments]' ? function _isArguments(x) {\n return toString.call(x) === '[object Arguments]';\n } : function _isArguments(x) {\n return _has('callee', x);\n };\n}();\n\nexport default _isArguments;","import _curry1 from \"./internal/_curry1.js\";\nimport _has from \"./internal/_has.js\";\nimport _isArguments from \"./internal/_isArguments.js\"; // cover IE < 9 keys issues\n\nvar hasEnumBug = !\n/*#__PURE__*/\n{\n toString: null\n}.propertyIsEnumerable('toString');\nvar nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; // Safari bug\n\nvar hasArgsEnumBug =\n/*#__PURE__*/\nfunction () {\n 'use strict';\n\n return arguments.propertyIsEnumerable('length');\n}();\n\nvar contains = function contains(list, item) {\n var idx = 0;\n\n while (idx < list.length) {\n if (list[idx] === item) {\n return true;\n }\n\n idx += 1;\n }\n\n return false;\n};\n/**\n * Returns a list containing the names of all the enumerable own properties of\n * the supplied object.\n * Note that the order of the output array is not guaranteed to be consistent\n * across different JS platforms.\n *\n * @func\n * @memberOf R\n * @since v0.1.0\n * @category Object\n * @sig {k: v} -> [k]\n * @param {Object} obj The object to extract properties from\n * @return {Array} An array of the object's own properties.\n * @see R.keysIn, R.values\n * @example\n *\n * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c']\n */\n\n\nvar keys = typeof Object.keys === 'function' && !hasArgsEnumBug ?\n/*#__PURE__*/\n_curry1(function keys(obj) {\n return Object(obj) !== obj ? [] : Object.keys(obj);\n}) :\n/*#__PURE__*/\n_curry1(function keys(obj) {\n if (Object(obj) !== obj) {\n return [];\n }\n\n var prop, nIdx;\n var ks = [];\n\n var checkArgsLength = hasArgsEnumBug && _isArguments(obj);\n\n for (prop in obj) {\n if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) {\n ks[ks.length] = prop;\n }\n }\n\n if (hasEnumBug) {\n nIdx = nonEnumerableProps.length - 1;\n\n while (nIdx >= 0) {\n prop = nonEnumerableProps[nIdx];\n\n if (_has(prop, obj) && !contains(ks, prop)) {\n ks[ks.length] = prop;\n }\n\n nIdx -= 1;\n }\n }\n\n return ks;\n});\nexport default keys;","import { __extends } from \"tslib\";\nimport { Subscriber } from '../Subscriber';\nimport { noop } from '../util/noop';\nimport { isFunction } from '../util/isFunction';\nexport function tap(nextOrObserver, error, complete) {\n return function tapOperatorFunction(source) {\n return source.lift(new DoOperator(nextOrObserver, error, complete));\n };\n}\nvar DoOperator = (function () {\n function DoOperator(nextOrObserver, error, complete) {\n this.nextOrObserver = nextOrObserver;\n this.error = error;\n this.complete = complete;\n }\n DoOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));\n };\n return DoOperator;\n}());\nvar TapSubscriber = (function (_super) {\n __extends(TapSubscriber, _super);\n function TapSubscriber(destination, observerOrNext, error, complete) {\n var _this = _super.call(this, destination) || this;\n _this._tapNext = noop;\n _this._tapError = noop;\n _this._tapComplete = noop;\n _this._tapError = error || noop;\n _this._tapComplete = complete || noop;\n if (isFunction(observerOrNext)) {\n _this._context = _this;\n _this._tapNext = observerOrNext;\n }\n else if (observerOrNext) {\n _this._context = observerOrNext;\n _this._tapNext = observerOrNext.next || noop;\n _this._tapError = observerOrNext.error || noop;\n _this._tapComplete = observerOrNext.complete || noop;\n }\n return _this;\n }\n TapSubscriber.prototype._next = function (value) {\n try {\n this._tapNext.call(this._context, value);\n }\n catch (err) {\n this.destination.error(err);\n return;\n }\n this.destination.next(value);\n };\n TapSubscriber.prototype._error = function (err) {\n try {\n this._tapError.call(this._context, err);\n }\n catch (err) {\n this.destination.error(err);\n return;\n }\n this.destination.error(err);\n };\n TapSubscriber.prototype._complete = function () {\n try {\n this._tapComplete.call(this._context);\n }\n catch (err) {\n this.destination.error(err);\n return;\n }\n return this.destination.complete();\n };\n return TapSubscriber;\n}(Subscriber));\n//# sourceMappingURL=tap.js.map","import { __extends } from \"tslib\";\nimport { Subscriber } from '../Subscriber';\nexport function scan(accumulator, seed) {\n var hasSeed = false;\n if (arguments.length >= 2) {\n hasSeed = true;\n }\n return function scanOperatorFunction(source) {\n return source.lift(new ScanOperator(accumulator, seed, hasSeed));\n };\n}\nvar ScanOperator = (function () {\n function ScanOperator(accumulator, seed, hasSeed) {\n if (hasSeed === void 0) { hasSeed = false; }\n this.accumulator = accumulator;\n this.seed = seed;\n this.hasSeed = hasSeed;\n }\n ScanOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed));\n };\n return ScanOperator;\n}());\nvar ScanSubscriber = (function (_super) {\n __extends(ScanSubscriber, _super);\n function ScanSubscriber(destination, accumulator, _state, _hasState) {\n var _this = _super.call(this, destination) || this;\n _this.accumulator = accumulator;\n _this._state = _state;\n _this._hasState = _hasState;\n _this.index = 0;\n return _this;\n }\n ScanSubscriber.prototype._next = function (value) {\n var destination = this.destination;\n if (!this._hasState) {\n this._state = value;\n this._hasState = true;\n destination.next(value);\n }\n else {\n var index = this.index++;\n var result = void 0;\n try {\n result = this.accumulator(this._state, value, index);\n }\n catch (err) {\n destination.error(err);\n return;\n }\n this._state = result;\n destination.next(result);\n }\n };\n return ScanSubscriber;\n}(Subscriber));\n//# sourceMappingURL=scan.js.map","import { __extends } from \"tslib\";\nimport { Subscriber } from '../Subscriber';\nimport { Subscription } from '../Subscription';\nexport function finalize(callback) {\n return function (source) { return source.lift(new FinallyOperator(callback)); };\n}\nvar FinallyOperator = (function () {\n function FinallyOperator(callback) {\n this.callback = callback;\n }\n FinallyOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new FinallySubscriber(subscriber, this.callback));\n };\n return FinallyOperator;\n}());\nvar FinallySubscriber = (function (_super) {\n __extends(FinallySubscriber, _super);\n function FinallySubscriber(destination, callback) {\n var _this = _super.call(this, destination) || this;\n _this.add(new Subscription(callback));\n return _this;\n }\n return FinallySubscriber;\n}(Subscriber));\n//# sourceMappingURL=finalize.js.map","import { __extends } from \"tslib\";\nimport { AsyncAction } from './AsyncAction';\nvar AnimationFrameAction = (function (_super) {\n __extends(AnimationFrameAction, _super);\n function AnimationFrameAction(scheduler, work) {\n var _this = _super.call(this, scheduler, work) || this;\n _this.scheduler = scheduler;\n _this.work = work;\n return _this;\n }\n AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) {\n if (delay === void 0) { delay = 0; }\n if (delay !== null && delay > 0) {\n return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);\n }\n scheduler.actions.push(this);\n return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(function () { return scheduler.flush(undefined); }));\n };\n AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) {\n if (delay === void 0) { delay = 0; }\n if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {\n return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);\n }\n if (scheduler.actions.length === 0) {\n cancelAnimationFrame(id);\n scheduler.scheduled = undefined;\n }\n return undefined;\n };\n return AnimationFrameAction;\n}(AsyncAction));\nexport { AnimationFrameAction };\n//# sourceMappingURL=AnimationFrameAction.js.map","import { AnimationFrameAction } from './AnimationFrameAction';\nimport { AnimationFrameScheduler } from './AnimationFrameScheduler';\nexport var animationFrame = new AnimationFrameScheduler(AnimationFrameAction);\n//# sourceMappingURL=animationFrame.js.map","import { __extends } from \"tslib\";\nimport { AsyncScheduler } from './AsyncScheduler';\nvar AnimationFrameScheduler = (function (_super) {\n __extends(AnimationFrameScheduler, _super);\n function AnimationFrameScheduler() {\n return _super !== null && _super.apply(this, arguments) || this;\n }\n AnimationFrameScheduler.prototype.flush = function (action) {\n this.active = true;\n this.scheduled = undefined;\n var actions = this.actions;\n var error;\n var index = -1;\n var count = actions.length;\n action = action || actions.shift();\n do {\n if (error = action.execute(action.state, action.delay)) {\n break;\n }\n } while (++index < count && (action = actions.shift()));\n this.active = false;\n if (error) {\n while (++index < count && (action = actions.shift())) {\n action.unsubscribe();\n }\n throw error;\n }\n };\n return AnimationFrameScheduler;\n}(AsyncScheduler));\nexport { AnimationFrameScheduler };\n//# sourceMappingURL=AnimationFrameScheduler.js.map","import { ReplaySubject } from '../ReplaySubject';\nexport function shareReplay(configOrBufferSize, windowTime, scheduler) {\n var config;\n if (configOrBufferSize && typeof configOrBufferSize === 'object') {\n config = configOrBufferSize;\n }\n else {\n config = {\n bufferSize: configOrBufferSize,\n windowTime: windowTime,\n refCount: false,\n scheduler: scheduler\n };\n }\n return function (source) { return source.lift(shareReplayOperator(config)); };\n}\nfunction shareReplayOperator(_a) {\n var _b = _a.bufferSize, bufferSize = _b === void 0 ? Number.POSITIVE_INFINITY : _b, _c = _a.windowTime, windowTime = _c === void 0 ? Number.POSITIVE_INFINITY : _c, useRefCount = _a.refCount, scheduler = _a.scheduler;\n var subject;\n var refCount = 0;\n var subscription;\n var hasError = false;\n var isComplete = false;\n return function shareReplayOperation(source) {\n refCount++;\n if (!subject || hasError) {\n hasError = false;\n subject = new ReplaySubject(bufferSize, windowTime, scheduler);\n subscription = source.subscribe({\n next: function (value) { subject.next(value); },\n error: function (err) {\n hasError = true;\n subject.error(err);\n },\n complete: function () {\n isComplete = true;\n subscription = undefined;\n subject.complete();\n },\n });\n }\n var innerSub = subject.subscribe(this);\n this.add(function () {\n refCount--;\n innerSub.unsubscribe();\n if (subscription && !isComplete && useRefCount && refCount === 0) {\n subscription.unsubscribe();\n subscription = undefined;\n subject = undefined;\n }\n });\n };\n}\n//# sourceMappingURL=shareReplay.js.map","import { distinctUntilChanged } from './distinctUntilChanged';\nexport function distinctUntilKeyChanged(key, compare) {\n return distinctUntilChanged(function (x, y) { return compare ? compare(x[key], y[key]) : x[key] === y[key]; });\n}\n//# sourceMappingURL=distinctUntilKeyChanged.js.map","import { __extends, __spreadArrays } from \"tslib\";\nimport { OuterSubscriber } from '../OuterSubscriber';\nimport { subscribeToResult } from '../util/subscribeToResult';\nexport function withLatestFrom() {\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n return function (source) {\n var project;\n if (typeof args[args.length - 1] === 'function') {\n project = args.pop();\n }\n var observables = args;\n return source.lift(new WithLatestFromOperator(observables, project));\n };\n}\nvar WithLatestFromOperator = (function () {\n function WithLatestFromOperator(observables, project) {\n this.observables = observables;\n this.project = project;\n }\n WithLatestFromOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new WithLatestFromSubscriber(subscriber, this.observables, this.project));\n };\n return WithLatestFromOperator;\n}());\nvar WithLatestFromSubscriber = (function (_super) {\n __extends(WithLatestFromSubscriber, _super);\n function WithLatestFromSubscriber(destination, observables, project) {\n var _this = _super.call(this, destination) || this;\n _this.observables = observables;\n _this.project = project;\n _this.toRespond = [];\n var len = observables.length;\n _this.values = new Array(len);\n for (var i = 0; i < len; i++) {\n _this.toRespond.push(i);\n }\n for (var i = 0; i < len; i++) {\n var observable = observables[i];\n _this.add(subscribeToResult(_this, observable, observable, i));\n }\n return _this;\n }\n WithLatestFromSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {\n this.values[outerIndex] = innerValue;\n var toRespond = this.toRespond;\n if (toRespond.length > 0) {\n var found = toRespond.indexOf(outerIndex);\n if (found !== -1) {\n toRespond.splice(found, 1);\n }\n }\n };\n WithLatestFromSubscriber.prototype.notifyComplete = function () {\n };\n WithLatestFromSubscriber.prototype._next = function (value) {\n if (this.toRespond.length === 0) {\n var args = __spreadArrays([value], this.values);\n if (this.project) {\n this._tryProject(args);\n }\n else {\n this.destination.next(args);\n }\n }\n };\n WithLatestFromSubscriber.prototype._tryProject = function (args) {\n var result;\n try {\n result = this.project.apply(this, args);\n }\n catch (err) {\n this.destination.error(err);\n return;\n }\n this.destination.next(result);\n };\n return WithLatestFromSubscriber;\n}(OuterSubscriber));\n//# sourceMappingURL=withLatestFrom.js.map","import { __extends } from \"tslib\";\nimport { Subscriber } from '../Subscriber';\nexport function bufferCount(bufferSize, startBufferEvery) {\n if (startBufferEvery === void 0) { startBufferEvery = null; }\n return function bufferCountOperatorFunction(source) {\n return source.lift(new BufferCountOperator(bufferSize, startBufferEvery));\n };\n}\nvar BufferCountOperator = (function () {\n function BufferCountOperator(bufferSize, startBufferEvery) {\n this.bufferSize = bufferSize;\n this.startBufferEvery = startBufferEvery;\n if (!startBufferEvery || bufferSize === startBufferEvery) {\n this.subscriberClass = BufferCountSubscriber;\n }\n else {\n this.subscriberClass = BufferSkipCountSubscriber;\n }\n }\n BufferCountOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new this.subscriberClass(subscriber, this.bufferSize, this.startBufferEvery));\n };\n return BufferCountOperator;\n}());\nvar BufferCountSubscriber = (function (_super) {\n __extends(BufferCountSubscriber, _super);\n function BufferCountSubscriber(destination, bufferSize) {\n var _this = _super.call(this, destination) || this;\n _this.bufferSize = bufferSize;\n _this.buffer = [];\n return _this;\n }\n BufferCountSubscriber.prototype._next = function (value) {\n var buffer = this.buffer;\n buffer.push(value);\n if (buffer.length == this.bufferSize) {\n this.destination.next(buffer);\n this.buffer = [];\n }\n };\n BufferCountSubscriber.prototype._complete = function () {\n var buffer = this.buffer;\n if (buffer.length > 0) {\n this.destination.next(buffer);\n }\n _super.prototype._complete.call(this);\n };\n return BufferCountSubscriber;\n}(Subscriber));\nvar BufferSkipCountSubscriber = (function (_super) {\n __extends(BufferSkipCountSubscriber, _super);\n function BufferSkipCountSubscriber(destination, bufferSize, startBufferEvery) {\n var _this = _super.call(this, destination) || this;\n _this.bufferSize = bufferSize;\n _this.startBufferEvery = startBufferEvery;\n _this.buffers = [];\n _this.count = 0;\n return _this;\n }\n BufferSkipCountSubscriber.prototype._next = function (value) {\n var _a = this, bufferSize = _a.bufferSize, startBufferEvery = _a.startBufferEvery, buffers = _a.buffers, count = _a.count;\n this.count++;\n if (count % startBufferEvery === 0) {\n buffers.push([]);\n }\n for (var i = buffers.length; i--;) {\n var buffer = buffers[i];\n buffer.push(value);\n if (buffer.length === bufferSize) {\n buffers.splice(i, 1);\n this.destination.next(buffer);\n }\n }\n };\n BufferSkipCountSubscriber.prototype._complete = function () {\n var _a = this, buffers = _a.buffers, destination = _a.destination;\n while (buffers.length > 0) {\n var buffer = buffers.shift();\n if (buffer.length > 0) {\n destination.next(buffer);\n }\n }\n _super.prototype._complete.call(this);\n };\n return BufferSkipCountSubscriber;\n}(Subscriber));\n//# sourceMappingURL=bufferCount.js.map","import { mergeAll } from './mergeAll';\nexport function concatAll() {\n return mergeAll(1);\n}\n//# sourceMappingURL=concatAll.js.map","import { of } from './of';\nimport { concatAll } from '../operators/concatAll';\nexport function concat() {\n var observables = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n observables[_i] = arguments[_i];\n }\n return concatAll()(of.apply(void 0, observables));\n}\n//# sourceMappingURL=concat.js.map","import { concat } from '../observable/concat';\nimport { isScheduler } from '../util/isScheduler';\nexport function startWith() {\n var values = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n values[_i] = arguments[_i];\n }\n var scheduler = values[values.length - 1];\n if (isScheduler(scheduler)) {\n values.pop();\n return function (source) { return concat(values, source, scheduler); };\n }\n else {\n return function (source) { return concat(values, source); };\n }\n}\n//# sourceMappingURL=startWith.js.map","import _curry1 from \"./internal/_curry1.js\";\nimport _isString from \"./internal/_isString.js\";\n/**\n * Returns a new list or string with the elements or characters in reverse\n * order.\n *\n * @func\n * @memberOf R\n * @since v0.1.0\n * @category List\n * @sig [a] -> [a]\n * @sig String -> String\n * @param {Array|String} list\n * @return {Array|String}\n * @example\n *\n * R.reverse([1, 2, 3]); //=> [3, 2, 1]\n * R.reverse([1, 2]); //=> [2, 1]\n * R.reverse([1]); //=> [1]\n * R.reverse([]); //=> []\n *\n * R.reverse('abc'); //=> 'cba'\n * R.reverse('ab'); //=> 'ba'\n * R.reverse('a'); //=> 'a'\n * R.reverse(''); //=> ''\n */\n\nvar reverse =\n/*#__PURE__*/\n_curry1(function reverse(list) {\n return _isString(list) ? list.split('').reverse().join('') : Array.prototype.slice.call(list, 0).reverse();\n});\n\nexport default reverse;","export default function _isString(x) {\n return Object.prototype.toString.call(x) === '[object String]';\n}","import { Observable } from '../Observable';\nimport { isArray } from '../util/isArray';\nimport { isFunction } from '../util/isFunction';\nimport { map } from '../operators/map';\nexport function fromEvent(target, eventName, options, resultSelector) {\n if (isFunction(options)) {\n resultSelector = options;\n options = undefined;\n }\n if (resultSelector) {\n return fromEvent(target, eventName, options).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));\n }\n return new Observable(function (subscriber) {\n function handler(e) {\n if (arguments.length > 1) {\n subscriber.next(Array.prototype.slice.call(arguments));\n }\n else {\n subscriber.next(e);\n }\n }\n setupSubscription(target, eventName, handler, subscriber, options);\n });\n}\nfunction setupSubscription(sourceObj, eventName, handler, subscriber, options) {\n var unsubscribe;\n if (isEventTarget(sourceObj)) {\n var source_1 = sourceObj;\n sourceObj.addEventListener(eventName, handler, options);\n unsubscribe = function () { return source_1.removeEventListener(eventName, handler, options); };\n }\n else if (isJQueryStyleEventEmitter(sourceObj)) {\n var source_2 = sourceObj;\n sourceObj.on(eventName, handler);\n unsubscribe = function () { return source_2.off(eventName, handler); };\n }\n else if (isNodeStyleEventEmitter(sourceObj)) {\n var source_3 = sourceObj;\n sourceObj.addListener(eventName, handler);\n unsubscribe = function () { return source_3.removeListener(eventName, handler); };\n }\n else if (sourceObj && sourceObj.length) {\n for (var i = 0, len = sourceObj.length; i < len; i++) {\n setupSubscription(sourceObj[i], eventName, handler, subscriber, options);\n }\n }\n else {\n throw new TypeError('Invalid event target');\n }\n subscriber.add(unsubscribe);\n}\nfunction isNodeStyleEventEmitter(sourceObj) {\n return sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function';\n}\nfunction isJQueryStyleEventEmitter(sourceObj) {\n return sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function';\n}\nfunction isEventTarget(sourceObj) {\n return sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function';\n}\n//# sourceMappingURL=fromEvent.js.map","import { __extends } from \"tslib\";\nimport { Subscriber } from '../Subscriber';\nexport function mapTo(value) {\n return function (source) { return source.lift(new MapToOperator(value)); };\n}\nvar MapToOperator = (function () {\n function MapToOperator(value) {\n this.value = value;\n }\n MapToOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new MapToSubscriber(subscriber, this.value));\n };\n return MapToOperator;\n}());\nvar MapToSubscriber = (function (_super) {\n __extends(MapToSubscriber, _super);\n function MapToSubscriber(destination, value) {\n var _this = _super.call(this, destination) || this;\n _this.value = value;\n return _this;\n }\n MapToSubscriber.prototype._next = function (x) {\n this.destination.next(this.value);\n };\n return MapToSubscriber;\n}(Subscriber));\n//# sourceMappingURL=mapTo.js.map","import { Observable } from '../Observable';\nimport { isScheduler } from '../util/isScheduler';\nimport { mergeAll } from '../operators/mergeAll';\nimport { fromArray } from './fromArray';\nexport function merge() {\n var observables = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n observables[_i] = arguments[_i];\n }\n var concurrent = Number.POSITIVE_INFINITY;\n var scheduler = undefined;\n var last = observables[observables.length - 1];\n if (isScheduler(last)) {\n scheduler = observables.pop();\n if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {\n concurrent = observables.pop();\n }\n }\n else if (typeof last === 'number') {\n concurrent = observables.pop();\n }\n if (!scheduler && observables.length === 1 && observables[0] instanceof Observable) {\n return observables[0];\n }\n return mergeAll(concurrent)(fromArray(observables, scheduler));\n}\n//# sourceMappingURL=merge.js.map","import { Observable } from '../Observable';\nimport { isArray } from '../util/isArray';\nimport { isFunction } from '../util/isFunction';\nimport { map } from '../operators/map';\nexport function fromEventPattern(addHandler, removeHandler, resultSelector) {\n if (resultSelector) {\n return fromEventPattern(addHandler, removeHandler).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));\n }\n return new Observable(function (subscriber) {\n var handler = function () {\n var e = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n e[_i] = arguments[_i];\n }\n return subscriber.next(e.length === 1 ? e[0] : e);\n };\n var retValue;\n try {\n retValue = addHandler(handler);\n }\n catch (err) {\n subscriber.error(err);\n return undefined;\n }\n if (!isFunction(removeHandler)) {\n return undefined;\n }\n return function () { return removeHandler(handler, retValue); };\n });\n}\n//# sourceMappingURL=fromEventPattern.js.map","import { __extends } from \"tslib\";\nimport { Subscriber } from '../Subscriber';\nexport function filter(predicate, thisArg) {\n return function filterOperatorFunction(source) {\n return source.lift(new FilterOperator(predicate, thisArg));\n };\n}\nvar FilterOperator = (function () {\n function FilterOperator(predicate, thisArg) {\n this.predicate = predicate;\n this.thisArg = thisArg;\n }\n FilterOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));\n };\n return FilterOperator;\n}());\nvar FilterSubscriber = (function (_super) {\n __extends(FilterSubscriber, _super);\n function FilterSubscriber(destination, predicate, thisArg) {\n var _this = _super.call(this, destination) || this;\n _this.predicate = predicate;\n _this.thisArg = thisArg;\n _this.count = 0;\n return _this;\n }\n FilterSubscriber.prototype._next = function (value) {\n var result;\n try {\n result = this.predicate.call(this.thisArg, value, this.count++);\n }\n catch (err) {\n this.destination.error(err);\n return;\n }\n if (result) {\n this.destination.next(value);\n }\n };\n return FilterSubscriber;\n}(Subscriber));\n//# sourceMappingURL=filter.js.map","import { __extends } from \"tslib\";\nimport { Subject } from './Subject';\nimport { ObjectUnsubscribedError } from './util/ObjectUnsubscribedError';\nvar BehaviorSubject = (function (_super) {\n __extends(BehaviorSubject, _super);\n function BehaviorSubject(_value) {\n var _this = _super.call(this) || this;\n _this._value = _value;\n return _this;\n }\n Object.defineProperty(BehaviorSubject.prototype, \"value\", {\n get: function () {\n return this.getValue();\n },\n enumerable: true,\n configurable: true\n });\n BehaviorSubject.prototype._subscribe = function (subscriber) {\n var subscription = _super.prototype._subscribe.call(this, subscriber);\n if (subscription && !subscription.closed) {\n subscriber.next(this._value);\n }\n return subscription;\n };\n BehaviorSubject.prototype.getValue = function () {\n if (this.hasError) {\n throw this.thrownError;\n }\n else if (this.closed) {\n throw new ObjectUnsubscribedError();\n }\n else {\n return this._value;\n }\n };\n BehaviorSubject.prototype.next = function (value) {\n _super.prototype.next.call(this, this._value = value);\n };\n return BehaviorSubject;\n}(Subject));\nexport { BehaviorSubject };\n//# sourceMappingURL=BehaviorSubject.js.map","import { map } from './map';\nexport function pluck() {\n var properties = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n properties[_i] = arguments[_i];\n }\n var length = properties.length;\n if (length === 0) {\n throw new Error('list of properties cannot be empty.');\n }\n return map(function (x) {\n var currentProp = x;\n for (var i = 0; i < length; i++) {\n var p = currentProp[properties[i]];\n if (typeof p !== 'undefined') {\n currentProp = p;\n }\n else {\n return undefined;\n }\n }\n return currentProp;\n });\n}\n//# sourceMappingURL=pluck.js.map","import { __extends } from \"tslib\";\nimport { OuterSubscriber } from '../OuterSubscriber';\nimport { subscribeToResult } from '../util/subscribeToResult';\nexport var defaultThrottleConfig = {\n leading: true,\n trailing: false\n};\nexport function throttle(durationSelector, config) {\n if (config === void 0) { config = defaultThrottleConfig; }\n return function (source) { return source.lift(new ThrottleOperator(durationSelector, !!config.leading, !!config.trailing)); };\n}\nvar ThrottleOperator = (function () {\n function ThrottleOperator(durationSelector, leading, trailing) {\n this.durationSelector = durationSelector;\n this.leading = leading;\n this.trailing = trailing;\n }\n ThrottleOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new ThrottleSubscriber(subscriber, this.durationSelector, this.leading, this.trailing));\n };\n return ThrottleOperator;\n}());\nvar ThrottleSubscriber = (function (_super) {\n __extends(ThrottleSubscriber, _super);\n function ThrottleSubscriber(destination, durationSelector, _leading, _trailing) {\n var _this = _super.call(this, destination) || this;\n _this.destination = destination;\n _this.durationSelector = durationSelector;\n _this._leading = _leading;\n _this._trailing = _trailing;\n _this._sendValue = null;\n _this._hasValue = false;\n return _this;\n }\n ThrottleSubscriber.prototype._next = function (value) {\n this._hasValue = true;\n this._sendValue = value;\n if (!this._throttled) {\n if (this._leading) {\n this.send();\n }\n else {\n this.throttle(value);\n }\n }\n };\n ThrottleSubscriber.prototype.send = function () {\n var _a = this, _hasValue = _a._hasValue, _sendValue = _a._sendValue;\n if (_hasValue) {\n this.destination.next(_sendValue);\n this.throttle(_sendValue);\n }\n this._hasValue = false;\n this._sendValue = null;\n };\n ThrottleSubscriber.prototype.throttle = function (value) {\n var duration = this.tryDurationSelector(value);\n if (!!duration) {\n this.add(this._throttled = subscribeToResult(this, duration));\n }\n };\n ThrottleSubscriber.prototype.tryDurationSelector = function (value) {\n try {\n return this.durationSelector(value);\n }\n catch (err) {\n this.destination.error(err);\n return null;\n }\n };\n ThrottleSubscriber.prototype.throttlingDone = function () {\n var _a = this, _throttled = _a._throttled, _trailing = _a._trailing;\n if (_throttled) {\n _throttled.unsubscribe();\n }\n this._throttled = null;\n if (_trailing) {\n this.send();\n }\n };\n ThrottleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {\n this.throttlingDone();\n };\n ThrottleSubscriber.prototype.notifyComplete = function () {\n this.throttlingDone();\n };\n return ThrottleSubscriber;\n}(OuterSubscriber));\n//# sourceMappingURL=throttle.js.map","import { switchMap } from './switchMap';\nexport function switchMapTo(innerObservable, resultSelector) {\n return resultSelector ? switchMap(function () { return innerObservable; }, resultSelector) : switchMap(function () { return innerObservable; });\n}\n//# sourceMappingURL=switchMapTo.js.map","import { Observable } from '../Observable';\nimport { noop } from '../util/noop';\nexport var NEVER = new Observable(noop);\nexport function never() {\n return NEVER;\n}\n//# sourceMappingURL=never.js.map","import { __extends } from \"tslib\";\nimport { Subscriber } from '../Subscriber';\nexport function skip(count) {\n return function (source) { return source.lift(new SkipOperator(count)); };\n}\nvar SkipOperator = (function () {\n function SkipOperator(total) {\n this.total = total;\n }\n SkipOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new SkipSubscriber(subscriber, this.total));\n };\n return SkipOperator;\n}());\nvar SkipSubscriber = (function (_super) {\n __extends(SkipSubscriber, _super);\n function SkipSubscriber(destination, total) {\n var _this = _super.call(this, destination) || this;\n _this.total = total;\n _this.count = 0;\n return _this;\n }\n SkipSubscriber.prototype._next = function (x) {\n if (++this.count > this.total) {\n this.destination.next(x);\n }\n };\n return SkipSubscriber;\n}(Subscriber));\n//# sourceMappingURL=skip.js.map","import { __extends } from \"tslib\";\nimport { OuterSubscriber } from '../OuterSubscriber';\nimport { InnerSubscriber } from '../InnerSubscriber';\nimport { subscribeToResult } from '../util/subscribeToResult';\nexport function catchError(selector) {\n return function catchErrorOperatorFunction(source) {\n var operator = new CatchOperator(selector);\n var caught = source.lift(operator);\n return (operator.caught = caught);\n };\n}\nvar CatchOperator = (function () {\n function CatchOperator(selector) {\n this.selector = selector;\n }\n CatchOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));\n };\n return CatchOperator;\n}());\nvar CatchSubscriber = (function (_super) {\n __extends(CatchSubscriber, _super);\n function CatchSubscriber(destination, selector, caught) {\n var _this = _super.call(this, destination) || this;\n _this.selector = selector;\n _this.caught = caught;\n return _this;\n }\n CatchSubscriber.prototype.error = function (err) {\n if (!this.isStopped) {\n var result = void 0;\n try {\n result = this.selector(err, this.caught);\n }\n catch (err2) {\n _super.prototype.error.call(this, err2);\n return;\n }\n this._unsubscribeAndRecycle();\n var innerSubscriber = new InnerSubscriber(this, undefined, undefined);\n this.add(innerSubscriber);\n var innerSubscription = subscribeToResult(this, result, undefined, undefined, innerSubscriber);\n if (innerSubscription !== innerSubscriber) {\n this.add(innerSubscription);\n }\n }\n };\n return CatchSubscriber;\n}(OuterSubscriber));\n//# sourceMappingURL=catchError.js.map","import { __extends } from \"tslib\";\nimport { OuterSubscriber } from '../OuterSubscriber';\nimport { subscribeToResult } from '../util/subscribeToResult';\nexport function sample(notifier) {\n return function (source) { return source.lift(new SampleOperator(notifier)); };\n}\nvar SampleOperator = (function () {\n function SampleOperator(notifier) {\n this.notifier = notifier;\n }\n SampleOperator.prototype.call = function (subscriber, source) {\n var sampleSubscriber = new SampleSubscriber(subscriber);\n var subscription = source.subscribe(sampleSubscriber);\n subscription.add(subscribeToResult(sampleSubscriber, this.notifier));\n return subscription;\n };\n return SampleOperator;\n}());\nvar SampleSubscriber = (function (_super) {\n __extends(SampleSubscriber, _super);\n function SampleSubscriber() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.hasValue = false;\n return _this;\n }\n SampleSubscriber.prototype._next = function (value) {\n this.value = value;\n this.hasValue = true;\n };\n SampleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {\n this.emitValue();\n };\n SampleSubscriber.prototype.notifyComplete = function () {\n this.emitValue();\n };\n SampleSubscriber.prototype.emitValue = function () {\n if (this.hasValue) {\n this.hasValue = false;\n this.destination.next(this.value);\n }\n };\n return SampleSubscriber;\n}(OuterSubscriber));\n//# sourceMappingURL=sample.js.map","import { __extends } from \"tslib\";\nimport { Subscriber } from '../Subscriber';\nimport { async } from '../scheduler/async';\nexport function debounceTime(dueTime, scheduler) {\n if (scheduler === void 0) { scheduler = async; }\n return function (source) { return source.lift(new DebounceTimeOperator(dueTime, scheduler)); };\n}\nvar DebounceTimeOperator = (function () {\n function DebounceTimeOperator(dueTime, scheduler) {\n this.dueTime = dueTime;\n this.scheduler = scheduler;\n }\n DebounceTimeOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler));\n };\n return DebounceTimeOperator;\n}());\nvar DebounceTimeSubscriber = (function (_super) {\n __extends(DebounceTimeSubscriber, _super);\n function DebounceTimeSubscriber(destination, dueTime, scheduler) {\n var _this = _super.call(this, destination) || this;\n _this.dueTime = dueTime;\n _this.scheduler = scheduler;\n _this.debouncedSubscription = null;\n _this.lastValue = null;\n _this.hasValue = false;\n return _this;\n }\n DebounceTimeSubscriber.prototype._next = function (value) {\n this.clearDebounce();\n this.lastValue = value;\n this.hasValue = true;\n this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext, this.dueTime, this));\n };\n DebounceTimeSubscriber.prototype._complete = function () {\n this.debouncedNext();\n this.destination.complete();\n };\n DebounceTimeSubscriber.prototype.debouncedNext = function () {\n this.clearDebounce();\n if (this.hasValue) {\n var lastValue = this.lastValue;\n this.lastValue = null;\n this.hasValue = false;\n this.destination.next(lastValue);\n }\n };\n DebounceTimeSubscriber.prototype.clearDebounce = function () {\n var debouncedSubscription = this.debouncedSubscription;\n if (debouncedSubscription !== null) {\n this.remove(debouncedSubscription);\n debouncedSubscription.unsubscribe();\n this.debouncedSubscription = null;\n }\n };\n return DebounceTimeSubscriber;\n}(Subscriber));\nfunction dispatchNext(subscriber) {\n subscriber.debouncedNext();\n}\n//# sourceMappingURL=debounceTime.js.map","import { defer } from './defer';\nimport { EMPTY } from './empty';\nexport function iif(condition, trueResult, falseResult) {\n if (trueResult === void 0) { trueResult = EMPTY; }\n if (falseResult === void 0) { falseResult = EMPTY; }\n return defer(function () { return condition() ? trueResult : falseResult; });\n}\n//# sourceMappingURL=iif.js.map","import _curry1 from \"./internal/_curry1.js\";\nimport keys from \"./keys.js\";\n/**\n * Returns a list of all the enumerable own properties of the supplied object.\n * Note that the order of the output array is not guaranteed across different\n * JS platforms.\n *\n * @func\n * @memberOf R\n * @since v0.1.0\n * @category Object\n * @sig {k: v} -> [v]\n * @param {Object} obj The object to extract values from\n * @return {Array} An array of the values of the object's own properties.\n * @see R.valuesIn, R.keys\n * @example\n *\n * R.values({a: 1, b: 2, c: 3}); //=> [1, 2, 3]\n */\n\nvar values =\n/*#__PURE__*/\n_curry1(function values(obj) {\n var props = keys(obj);\n var len = props.length;\n var vals = [];\n var idx = 0;\n\n while (idx < len) {\n vals[idx] = obj[props[idx]];\n idx += 1;\n }\n\n return vals;\n});\n\nexport default values;","import { __extends } from \"tslib\";\nimport { Subscriber } from '../Subscriber';\nexport function refCount() {\n return function refCountOperatorFunction(source) {\n return source.lift(new RefCountOperator(source));\n };\n}\nvar RefCountOperator = (function () {\n function RefCountOperator(connectable) {\n this.connectable = connectable;\n }\n RefCountOperator.prototype.call = function (subscriber, source) {\n var connectable = this.connectable;\n connectable._refCount++;\n var refCounter = new RefCountSubscriber(subscriber, connectable);\n var subscription = source.subscribe(refCounter);\n if (!refCounter.closed) {\n refCounter.connection = connectable.connect();\n }\n return subscription;\n };\n return RefCountOperator;\n}());\nvar RefCountSubscriber = (function (_super) {\n __extends(RefCountSubscriber, _super);\n function RefCountSubscriber(destination, connectable) {\n var _this = _super.call(this, destination) || this;\n _this.connectable = connectable;\n _this.connection = null;\n return _this;\n }\n RefCountSubscriber.prototype._unsubscribe = function () {\n var connectable = this.connectable;\n if (!connectable) {\n this.connection = null;\n return;\n }\n this.connectable = null;\n var refCount = connectable._refCount;\n if (refCount <= 0) {\n this.connection = null;\n return;\n }\n connectable._refCount = refCount - 1;\n if (refCount > 1) {\n this.connection = null;\n return;\n }\n var connection = this.connection;\n var sharedConnection = connectable._connection;\n this.connection = null;\n if (sharedConnection && (!connection || sharedConnection === connection)) {\n sharedConnection.unsubscribe();\n }\n };\n return RefCountSubscriber;\n}(Subscriber));\n//# sourceMappingURL=refCount.js.map","import { __extends } from \"tslib\";\nimport { SubjectSubscriber } from '../Subject';\nimport { Observable } from '../Observable';\nimport { Subscriber } from '../Subscriber';\nimport { Subscription } from '../Subscription';\nimport { refCount as higherOrderRefCount } from '../operators/refCount';\nvar ConnectableObservable = (function (_super) {\n __extends(ConnectableObservable, _super);\n function ConnectableObservable(source, subjectFactory) {\n var _this = _super.call(this) || this;\n _this.source = source;\n _this.subjectFactory = subjectFactory;\n _this._refCount = 0;\n _this._isComplete = false;\n return _this;\n }\n ConnectableObservable.prototype._subscribe = function (subscriber) {\n return this.getSubject().subscribe(subscriber);\n };\n ConnectableObservable.prototype.getSubject = function () {\n var subject = this._subject;\n if (!subject || subject.isStopped) {\n this._subject = this.subjectFactory();\n }\n return this._subject;\n };\n ConnectableObservable.prototype.connect = function () {\n var connection = this._connection;\n if (!connection) {\n this._isComplete = false;\n connection = this._connection = new Subscription();\n connection.add(this.source\n .subscribe(new ConnectableSubscriber(this.getSubject(), this)));\n if (connection.closed) {\n this._connection = null;\n connection = Subscription.EMPTY;\n }\n }\n return connection;\n };\n ConnectableObservable.prototype.refCount = function () {\n return higherOrderRefCount()(this);\n };\n return ConnectableObservable;\n}(Observable));\nexport { ConnectableObservable };\nexport var connectableObservableDescriptor = (function () {\n var connectableProto = ConnectableObservable.prototype;\n return {\n operator: { value: null },\n _refCount: { value: 0, writable: true },\n _subject: { value: null, writable: true },\n _connection: { value: null, writable: true },\n _subscribe: { value: connectableProto._subscribe },\n _isComplete: { value: connectableProto._isComplete, writable: true },\n getSubject: { value: connectableProto.getSubject },\n connect: { value: connectableProto.connect },\n refCount: { value: connectableProto.refCount }\n };\n})();\nvar ConnectableSubscriber = (function (_super) {\n __extends(ConnectableSubscriber, _super);\n function ConnectableSubscriber(destination, connectable) {\n var _this = _super.call(this, destination) || this;\n _this.connectable = connectable;\n return _this;\n }\n ConnectableSubscriber.prototype._error = function (err) {\n this._unsubscribe();\n _super.prototype._error.call(this, err);\n };\n ConnectableSubscriber.prototype._complete = function () {\n this.connectable._isComplete = true;\n this._unsubscribe();\n _super.prototype._complete.call(this);\n };\n ConnectableSubscriber.prototype._unsubscribe = function () {\n var connectable = this.connectable;\n if (connectable) {\n this.connectable = null;\n var connection = connectable._connection;\n connectable._refCount = 0;\n connectable._subject = null;\n connectable._connection = null;\n if (connection) {\n connection.unsubscribe();\n }\n }\n };\n return ConnectableSubscriber;\n}(SubjectSubscriber));\nvar RefCountOperator = (function () {\n function RefCountOperator(connectable) {\n this.connectable = connectable;\n }\n RefCountOperator.prototype.call = function (subscriber, source) {\n var connectable = this.connectable;\n connectable._refCount++;\n var refCounter = new RefCountSubscriber(subscriber, connectable);\n var subscription = source.subscribe(refCounter);\n if (!refCounter.closed) {\n refCounter.connection = connectable.connect();\n }\n return subscription;\n };\n return RefCountOperator;\n}());\nvar RefCountSubscriber = (function (_super) {\n __extends(RefCountSubscriber, _super);\n function RefCountSubscriber(destination, connectable) {\n var _this = _super.call(this, destination) || this;\n _this.connectable = connectable;\n return _this;\n }\n RefCountSubscriber.prototype._unsubscribe = function () {\n var connectable = this.connectable;\n if (!connectable) {\n this.connection = null;\n return;\n }\n this.connectable = null;\n var refCount = connectable._refCount;\n if (refCount <= 0) {\n this.connection = null;\n return;\n }\n connectable._refCount = refCount - 1;\n if (refCount > 1) {\n this.connection = null;\n return;\n }\n var connection = this.connection;\n var sharedConnection = connectable._connection;\n this.connection = null;\n if (sharedConnection && (!connection || sharedConnection === connection)) {\n sharedConnection.unsubscribe();\n }\n };\n return RefCountSubscriber;\n}(Subscriber));\n//# sourceMappingURL=ConnectableObservable.js.map","import { connectableObservableDescriptor } from '../observable/ConnectableObservable';\nexport function multicast(subjectOrSubjectFactory, selector) {\n return function multicastOperatorFunction(source) {\n var subjectFactory;\n if (typeof subjectOrSubjectFactory === 'function') {\n subjectFactory = subjectOrSubjectFactory;\n }\n else {\n subjectFactory = function subjectFactory() {\n return subjectOrSubjectFactory;\n };\n }\n if (typeof selector === 'function') {\n return source.lift(new MulticastOperator(subjectFactory, selector));\n }\n var connectable = Object.create(source, connectableObservableDescriptor);\n connectable.source = source;\n connectable.subjectFactory = subjectFactory;\n return connectable;\n };\n}\nvar MulticastOperator = (function () {\n function MulticastOperator(subjectFactory, selector) {\n this.subjectFactory = subjectFactory;\n this.selector = selector;\n }\n MulticastOperator.prototype.call = function (subscriber, source) {\n var selector = this.selector;\n var subject = this.subjectFactory();\n var subscription = selector(subject).subscribe(subscriber);\n subscription.add(source.subscribe(subject));\n return subscription;\n };\n return MulticastOperator;\n}());\nexport { MulticastOperator };\n//# sourceMappingURL=multicast.js.map","import { multicast } from './multicast';\nimport { refCount } from './refCount';\nimport { Subject } from '../Subject';\nfunction shareSubjectFactory() {\n return new Subject();\n}\nexport function share() {\n return function (source) { return refCount()(multicast(shareSubjectFactory)(source)); };\n}\n//# sourceMappingURL=share.js.map","export default function _identity(x) {\n return x;\n}","import _curry1 from \"./internal/_curry1.js\";\nimport _identity from \"./internal/_identity.js\";\n/**\n * A function that does nothing but return the parameter supplied to it. Good\n * as a default or placeholder function.\n *\n * @func\n * @memberOf R\n * @since v0.1.0\n * @category Function\n * @sig a -> a\n * @param {*} x The value to return.\n * @return {*} The input value, `x`.\n * @example\n *\n * R.identity(1); //=> 1\n *\n * const obj = {};\n * R.identity(obj) === obj; //=> true\n * @symb R.identity(a) = a\n */\n\nvar identity =\n/*#__PURE__*/\n_curry1(_identity);\n\nexport default identity;","import { __extends } from \"tslib\";\nimport { root } from '../../util/root';\nimport { Observable } from '../../Observable';\nimport { Subscriber } from '../../Subscriber';\nimport { map } from '../../operators/map';\nfunction getCORSRequest() {\n if (root.XMLHttpRequest) {\n return new root.XMLHttpRequest();\n }\n else if (!!root.XDomainRequest) {\n return new root.XDomainRequest();\n }\n else {\n throw new Error('CORS is not supported by your browser');\n }\n}\nfunction getXMLHttpRequest() {\n if (root.XMLHttpRequest) {\n return new root.XMLHttpRequest();\n }\n else {\n var progId = void 0;\n try {\n var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];\n for (var i = 0; i < 3; i++) {\n try {\n progId = progIds[i];\n if (new root.ActiveXObject(progId)) {\n break;\n }\n }\n catch (e) {\n }\n }\n return new root.ActiveXObject(progId);\n }\n catch (e) {\n throw new Error('XMLHttpRequest is not supported by your browser');\n }\n }\n}\nexport function ajaxGet(url, headers) {\n return new AjaxObservable({ method: 'GET', url: url, headers: headers });\n}\nexport function ajaxPost(url, body, headers) {\n return new AjaxObservable({ method: 'POST', url: url, body: body, headers: headers });\n}\nexport function ajaxDelete(url, headers) {\n return new AjaxObservable({ method: 'DELETE', url: url, headers: headers });\n}\nexport function ajaxPut(url, body, headers) {\n return new AjaxObservable({ method: 'PUT', url: url, body: body, headers: headers });\n}\nexport function ajaxPatch(url, body, headers) {\n return new AjaxObservable({ method: 'PATCH', url: url, body: body, headers: headers });\n}\nvar mapResponse = map(function (x, index) { return x.response; });\nexport function ajaxGetJSON(url, headers) {\n return mapResponse(new AjaxObservable({\n method: 'GET',\n url: url,\n responseType: 'json',\n headers: headers\n }));\n}\nvar AjaxObservable = (function (_super) {\n __extends(AjaxObservable, _super);\n function AjaxObservable(urlOrRequest) {\n var _this = _super.call(this) || this;\n var request = {\n async: true,\n createXHR: function () {\n return this.crossDomain ? getCORSRequest() : getXMLHttpRequest();\n },\n crossDomain: true,\n withCredentials: false,\n headers: {},\n method: 'GET',\n responseType: 'json',\n timeout: 0\n };\n if (typeof urlOrRequest === 'string') {\n request.url = urlOrRequest;\n }\n else {\n for (var prop in urlOrRequest) {\n if (urlOrRequest.hasOwnProperty(prop)) {\n request[prop] = urlOrRequest[prop];\n }\n }\n }\n _this.request = request;\n return _this;\n }\n AjaxObservable.prototype._subscribe = function (subscriber) {\n return new AjaxSubscriber(subscriber, this.request);\n };\n AjaxObservable.create = (function () {\n var create = function (urlOrRequest) {\n return new AjaxObservable(urlOrRequest);\n };\n create.get = ajaxGet;\n create.post = ajaxPost;\n create.delete = ajaxDelete;\n create.put = ajaxPut;\n create.patch = ajaxPatch;\n create.getJSON = ajaxGetJSON;\n return create;\n })();\n return AjaxObservable;\n}(Observable));\nexport { AjaxObservable };\nvar AjaxSubscriber = (function (_super) {\n __extends(AjaxSubscriber, _super);\n function AjaxSubscriber(destination, request) {\n var _this = _super.call(this, destination) || this;\n _this.request = request;\n _this.done = false;\n var headers = request.headers = request.headers || {};\n if (!request.crossDomain && !_this.getHeader(headers, 'X-Requested-With')) {\n headers['X-Requested-With'] = 'XMLHttpRequest';\n }\n var contentTypeHeader = _this.getHeader(headers, 'Content-Type');\n if (!contentTypeHeader && !(root.FormData && request.body instanceof root.FormData) && typeof request.body !== 'undefined') {\n headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';\n }\n request.body = _this.serializeBody(request.body, _this.getHeader(request.headers, 'Content-Type'));\n _this.send();\n return _this;\n }\n AjaxSubscriber.prototype.next = function (e) {\n this.done = true;\n var _a = this, xhr = _a.xhr, request = _a.request, destination = _a.destination;\n var result;\n try {\n result = new AjaxResponse(e, xhr, request);\n }\n catch (err) {\n return destination.error(err);\n }\n destination.next(result);\n };\n AjaxSubscriber.prototype.send = function () {\n var _a = this, request = _a.request, _b = _a.request, user = _b.user, method = _b.method, url = _b.url, async = _b.async, password = _b.password, headers = _b.headers, body = _b.body;\n try {\n var xhr = this.xhr = request.createXHR();\n this.setupEvents(xhr, request);\n if (user) {\n xhr.open(method, url, async, user, password);\n }\n else {\n xhr.open(method, url, async);\n }\n if (async) {\n xhr.timeout = request.timeout;\n xhr.responseType = request.responseType;\n }\n if ('withCredentials' in xhr) {\n xhr.withCredentials = !!request.withCredentials;\n }\n this.setHeaders(xhr, headers);\n if (body) {\n xhr.send(body);\n }\n else {\n xhr.send();\n }\n }\n catch (err) {\n this.error(err);\n }\n };\n AjaxSubscriber.prototype.serializeBody = function (body, contentType) {\n if (!body || typeof body === 'string') {\n return body;\n }\n else if (root.FormData && body instanceof root.FormData) {\n return body;\n }\n if (contentType) {\n var splitIndex = contentType.indexOf(';');\n if (splitIndex !== -1) {\n contentType = contentType.substring(0, splitIndex);\n }\n }\n switch (contentType) {\n case 'application/x-www-form-urlencoded':\n return Object.keys(body).map(function (key) { return encodeURIComponent(key) + \"=\" + encodeURIComponent(body[key]); }).join('&');\n case 'application/json':\n return JSON.stringify(body);\n default:\n return body;\n }\n };\n AjaxSubscriber.prototype.setHeaders = function (xhr, headers) {\n for (var key in headers) {\n if (headers.hasOwnProperty(key)) {\n xhr.setRequestHeader(key, headers[key]);\n }\n }\n };\n AjaxSubscriber.prototype.getHeader = function (headers, headerName) {\n for (var key in headers) {\n if (key.toLowerCase() === headerName.toLowerCase()) {\n return headers[key];\n }\n }\n return undefined;\n };\n AjaxSubscriber.prototype.setupEvents = function (xhr, request) {\n var progressSubscriber = request.progressSubscriber;\n function xhrTimeout(e) {\n var _a = xhrTimeout, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request;\n if (progressSubscriber) {\n progressSubscriber.error(e);\n }\n var error;\n try {\n error = new AjaxTimeoutError(this, request);\n }\n catch (err) {\n error = err;\n }\n subscriber.error(error);\n }\n xhr.ontimeout = xhrTimeout;\n xhrTimeout.request = request;\n xhrTimeout.subscriber = this;\n xhrTimeout.progressSubscriber = progressSubscriber;\n if (xhr.upload && 'withCredentials' in xhr) {\n if (progressSubscriber) {\n var xhrProgress_1;\n xhrProgress_1 = function (e) {\n var progressSubscriber = xhrProgress_1.progressSubscriber;\n progressSubscriber.next(e);\n };\n if (root.XDomainRequest) {\n xhr.onprogress = xhrProgress_1;\n }\n else {\n xhr.upload.onprogress = xhrProgress_1;\n }\n xhrProgress_1.progressSubscriber = progressSubscriber;\n }\n var xhrError_1;\n xhrError_1 = function (e) {\n var _a = xhrError_1, progressSubscriber = _a.progressSubscriber, subscriber = _a.subscriber, request = _a.request;\n if (progressSubscriber) {\n progressSubscriber.error(e);\n }\n var error;\n try {\n error = new AjaxError('ajax error', this, request);\n }\n catch (err) {\n error = err;\n }\n subscriber.error(error);\n };\n xhr.onerror = xhrError_1;\n xhrError_1.request = request;\n xhrError_1.subscriber = this;\n xhrError_1.progressSubscriber = progressSubscriber;\n }\n function xhrReadyStateChange(e) {\n return;\n }\n xhr.onreadystatechange = xhrReadyStateChange;\n xhrReadyStateChange.subscriber = this;\n xhrReadyStateChange.progressSubscriber = progressSubscriber;\n xhrReadyStateChange.request = request;\n function xhrLoad(e) {\n var _a = xhrLoad, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request;\n if (this.readyState === 4) {\n var status_1 = this.status === 1223 ? 204 : this.status;\n var response = (this.responseType === 'text' ? (this.response || this.responseText) : this.response);\n if (status_1 === 0) {\n status_1 = response ? 200 : 0;\n }\n if (status_1 < 400) {\n if (progressSubscriber) {\n progressSubscriber.complete();\n }\n subscriber.next(e);\n subscriber.complete();\n }\n else {\n if (progressSubscriber) {\n progressSubscriber.error(e);\n }\n var error = void 0;\n try {\n error = new AjaxError('ajax error ' + status_1, this, request);\n }\n catch (err) {\n error = err;\n }\n subscriber.error(error);\n }\n }\n }\n xhr.onload = xhrLoad;\n xhrLoad.subscriber = this;\n xhrLoad.progressSubscriber = progressSubscriber;\n xhrLoad.request = request;\n };\n AjaxSubscriber.prototype.unsubscribe = function () {\n var _a = this, done = _a.done, xhr = _a.xhr;\n if (!done && xhr && xhr.readyState !== 4 && typeof xhr.abort === 'function') {\n xhr.abort();\n }\n _super.prototype.unsubscribe.call(this);\n };\n return AjaxSubscriber;\n}(Subscriber));\nexport { AjaxSubscriber };\nvar AjaxResponse = (function () {\n function AjaxResponse(originalEvent, xhr, request) {\n this.originalEvent = originalEvent;\n this.xhr = xhr;\n this.request = request;\n this.status = xhr.status;\n this.responseType = xhr.responseType || request.responseType;\n this.response = parseXhrResponse(this.responseType, xhr);\n }\n return AjaxResponse;\n}());\nexport { AjaxResponse };\nvar AjaxErrorImpl = (function () {\n function AjaxErrorImpl(message, xhr, request) {\n Error.call(this);\n this.message = message;\n this.name = 'AjaxError';\n this.xhr = xhr;\n this.request = request;\n this.status = xhr.status;\n this.responseType = xhr.responseType || request.responseType;\n this.response = parseXhrResponse(this.responseType, xhr);\n return this;\n }\n AjaxErrorImpl.prototype = Object.create(Error.prototype);\n return AjaxErrorImpl;\n})();\nexport var AjaxError = AjaxErrorImpl;\nfunction parseJson(xhr) {\n if ('response' in xhr) {\n return xhr.responseType ? xhr.response : JSON.parse(xhr.response || xhr.responseText || 'null');\n }\n else {\n return JSON.parse(xhr.responseText || 'null');\n }\n}\nfunction parseXhrResponse(responseType, xhr) {\n switch (responseType) {\n case 'json':\n return parseJson(xhr);\n case 'xml':\n return xhr.responseXML;\n case 'text':\n default:\n return ('response' in xhr) ? xhr.response : xhr.responseText;\n }\n}\nvar AjaxTimeoutErrorImpl = (function () {\n function AjaxTimeoutErrorImpl(xhr, request) {\n AjaxError.call(this, 'ajax timeout', xhr, request);\n this.name = 'AjaxTimeoutError';\n return this;\n }\n AjaxTimeoutErrorImpl.prototype = Object.create(AjaxError.prototype);\n return AjaxTimeoutErrorImpl;\n})();\nexport var AjaxTimeoutError = AjaxTimeoutErrorImpl;\n//# sourceMappingURL=AjaxObservable.js.map","import { AjaxObservable } from './AjaxObservable';\nexport var ajax = (function () { return AjaxObservable.create; })();\n//# sourceMappingURL=ajax.js.map","import { __extends } from \"tslib\";\nimport { async } from '../scheduler/async';\nimport { isDate } from '../util/isDate';\nimport { Subscriber } from '../Subscriber';\nimport { Notification } from '../Notification';\nexport function delay(delay, scheduler) {\n if (scheduler === void 0) { scheduler = async; }\n var absoluteDelay = isDate(delay);\n var delayFor = absoluteDelay ? (+delay - scheduler.now()) : Math.abs(delay);\n return function (source) { return source.lift(new DelayOperator(delayFor, scheduler)); };\n}\nvar DelayOperator = (function () {\n function DelayOperator(delay, scheduler) {\n this.delay = delay;\n this.scheduler = scheduler;\n }\n DelayOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new DelaySubscriber(subscriber, this.delay, this.scheduler));\n };\n return DelayOperator;\n}());\nvar DelaySubscriber = (function (_super) {\n __extends(DelaySubscriber, _super);\n function DelaySubscriber(destination, delay, scheduler) {\n var _this = _super.call(this, destination) || this;\n _this.delay = delay;\n _this.scheduler = scheduler;\n _this.queue = [];\n _this.active = false;\n _this.errored = false;\n return _this;\n }\n DelaySubscriber.dispatch = function (state) {\n var source = state.source;\n var queue = source.queue;\n var scheduler = state.scheduler;\n var destination = state.destination;\n while (queue.length > 0 && (queue[0].time - scheduler.now()) <= 0) {\n queue.shift().notification.observe(destination);\n }\n if (queue.length > 0) {\n var delay_1 = Math.max(0, queue[0].time - scheduler.now());\n this.schedule(state, delay_1);\n }\n else if (source.isStopped) {\n source.destination.complete();\n source.active = false;\n }\n else {\n this.unsubscribe();\n source.active = false;\n }\n };\n DelaySubscriber.prototype._schedule = function (scheduler) {\n this.active = true;\n var destination = this.destination;\n destination.add(scheduler.schedule(DelaySubscriber.dispatch, this.delay, {\n source: this, destination: this.destination, scheduler: scheduler\n }));\n };\n DelaySubscriber.prototype.scheduleNotification = function (notification) {\n if (this.errored === true) {\n return;\n }\n var scheduler = this.scheduler;\n var message = new DelayMessage(scheduler.now() + this.delay, notification);\n this.queue.push(message);\n if (this.active === false) {\n this._schedule(scheduler);\n }\n };\n DelaySubscriber.prototype._next = function (value) {\n this.scheduleNotification(Notification.createNext(value));\n };\n DelaySubscriber.prototype._error = function (err) {\n this.errored = true;\n this.queue = [];\n this.destination.error(err);\n this.unsubscribe();\n };\n DelaySubscriber.prototype._complete = function () {\n if (this.queue.length === 0) {\n this.destination.complete();\n }\n this.unsubscribe();\n };\n return DelaySubscriber;\n}(Subscriber));\nvar DelayMessage = (function () {\n function DelayMessage(time, notification) {\n this.time = time;\n this.notification = notification;\n }\n return DelayMessage;\n}());\n//# sourceMappingURL=delay.js.map","export function isDate(value) {\n return value instanceof Date && !isNaN(+value);\n}\n//# sourceMappingURL=isDate.js.map","var ArgumentOutOfRangeErrorImpl = (function () {\n function ArgumentOutOfRangeErrorImpl() {\n Error.call(this);\n this.message = 'argument out of range';\n this.name = 'ArgumentOutOfRangeError';\n return this;\n }\n ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype);\n return ArgumentOutOfRangeErrorImpl;\n})();\nexport var ArgumentOutOfRangeError = ArgumentOutOfRangeErrorImpl;\n//# sourceMappingURL=ArgumentOutOfRangeError.js.map","import { __extends } from \"tslib\";\nimport { Subscriber } from '../Subscriber';\nimport { ArgumentOutOfRangeError } from '../util/ArgumentOutOfRangeError';\nimport { EMPTY } from '../observable/empty';\nexport function take(count) {\n return function (source) {\n if (count === 0) {\n return EMPTY;\n }\n else {\n return source.lift(new TakeOperator(count));\n }\n };\n}\nvar TakeOperator = (function () {\n function TakeOperator(total) {\n this.total = total;\n if (this.total < 0) {\n throw new ArgumentOutOfRangeError;\n }\n }\n TakeOperator.prototype.call = function (subscriber, source) {\n return source.subscribe(new TakeSubscriber(subscriber, this.total));\n };\n return TakeOperator;\n}());\nvar TakeSubscriber = (function (_super) {\n __extends(TakeSubscriber, _super);\n function TakeSubscriber(destination, total) {\n var _this = _super.call(this, destination) || this;\n _this.total = total;\n _this.count = 0;\n return _this;\n }\n TakeSubscriber.prototype._next = function (value) {\n var total = this.total;\n var count = ++this.count;\n if (count <= total) {\n this.destination.next(value);\n if (count === total) {\n this.destination.complete();\n this.unsubscribe();\n }\n }\n };\n return TakeSubscriber;\n}(Subscriber));\n//# sourceMappingURL=take.js.map"],"sourceRoot":""} \ No newline at end of file diff --git a/docs/assets/javascripts/worker/search.58d22e8e.min.js b/docs/assets/javascripts/worker/search.58d22e8e.min.js new file mode 100644 index 0000000..1418ab0 --- /dev/null +++ b/docs/assets/javascripts/worker/search.58d22e8e.min.js @@ -0,0 +1,59 @@ +!function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}([function(e,t,r){"use strict"; +/*! + * escape-html + * Copyright(c) 2012-2013 TJ Holowaychuk + * Copyright(c) 2015 Andreas Lubbe + * Copyright(c) 2015 Tiancheng "Timothy" Gu + * MIT Licensed + */var n=/["'&<>]/;e.exports=function(e){var t,r=""+e,i=n.exec(r);if(!i)return r;var s="",o=0,a=0;for(o=i.index;o0){var u=I.utils.clone(t)||{};u.position=[o,a],u.index=i.length,i.push(new I.Token(r.slice(o,s),u))}o=s+1}}return i},I.tokenizer.separator=/[\s\-]+/ +/*! + * lunr.Pipeline + * Copyright (C) 2019 Oliver Nightingale + */,I.Pipeline=function(){this._stack=[]},I.Pipeline.registeredFunctions=Object.create(null),I.Pipeline.registerFunction=function(e,t){t in this.registeredFunctions&&I.utils.warn("Overwriting existing registered function: "+t),e.label=t,I.Pipeline.registeredFunctions[e.label]=e},I.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||I.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},I.Pipeline.load=function(e){var t=new I.Pipeline;return e.forEach((function(e){var r=I.Pipeline.registeredFunctions[e];if(!r)throw new Error("Cannot load unregistered function: "+e);t.add(r)})),t},I.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach((function(e){I.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)}),this)},I.Pipeline.prototype.after=function(e,t){I.Pipeline.warnIfFunctionNotRegistered(t);var r=this._stack.indexOf(e);if(-1==r)throw new Error("Cannot find existingFn");r+=1,this._stack.splice(r,0,t)},I.Pipeline.prototype.before=function(e,t){I.Pipeline.warnIfFunctionNotRegistered(t);var r=this._stack.indexOf(e);if(-1==r)throw new Error("Cannot find existingFn");this._stack.splice(r,0,t)},I.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);-1!=t&&this._stack.splice(t,1)},I.Pipeline.prototype.run=function(e){for(var t=this._stack.length,r=0;r1&&(se&&(r=i),s!=e);)n=r-t,i=t+Math.floor(n/2),s=this.elements[2*i];return s==e||s>e?2*i:sa?l+=2:o==a&&(t+=r[u+1]*n[l+1],u+=2,l+=2);return t},I.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},I.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),t=1,r=0;t0){var s,o=i.str.charAt(0);o in i.node.edges?s=i.node.edges[o]:(s=new I.TokenSet,i.node.edges[o]=s),1==i.str.length&&(s.final=!0),n.push({node:s,editsRemaining:i.editsRemaining,str:i.str.slice(1)})}if(0!=i.editsRemaining){if("*"in i.node.edges)var a=i.node.edges["*"];else{a=new I.TokenSet;i.node.edges["*"]=a}if(0==i.str.length&&(a.final=!0),n.push({node:a,editsRemaining:i.editsRemaining-1,str:i.str}),i.str.length>1&&n.push({node:i.node,editsRemaining:i.editsRemaining-1,str:i.str.slice(1)}),1==i.str.length&&(i.node.final=!0),i.str.length>=1){if("*"in i.node.edges)var u=i.node.edges["*"];else{u=new I.TokenSet;i.node.edges["*"]=u}1==i.str.length&&(u.final=!0),n.push({node:u,editsRemaining:i.editsRemaining-1,str:i.str.slice(1)})}if(i.str.length>1){var l,c=i.str.charAt(0),h=i.str.charAt(1);h in i.node.edges?l=i.node.edges[h]:(l=new I.TokenSet,i.node.edges[h]=l),1==i.str.length&&(l.final=!0),n.push({node:l,editsRemaining:i.editsRemaining-1,str:c+i.str.slice(2)})}}}return r},I.TokenSet.fromString=function(e){for(var t=new I.TokenSet,r=t,n=0,i=e.length;n=e;t--){var r=this.uncheckedNodes[t],n=r.child.toString();n in this.minimizedNodes?r.parent.edges[r.char]=this.minimizedNodes[n]:(r.child._str=n,this.minimizedNodes[n]=r.child),this.uncheckedNodes.pop()}} +/*! + * lunr.Index + * Copyright (C) 2019 Oliver Nightingale + */,I.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},I.Index.prototype.search=function(e){return this.query((function(t){new I.QueryParser(e,t).parse()}))},I.Index.prototype.query=function(e){for(var t=new I.Query(this.fields),r=Object.create(null),n=Object.create(null),i=Object.create(null),s=Object.create(null),o=Object.create(null),a=0;a1?1:e},I.Builder.prototype.k1=function(e){this._k1=e},I.Builder.prototype.add=function(e,t){var r=e[this._ref],n=Object.keys(this._fields);this._documents[r]=t||{},this.documentCount+=1;for(var i=0;i=this.length)return I.QueryLexer.EOS;var e=this.str.charAt(this.pos);return this.pos+=1,e},I.QueryLexer.prototype.width=function(){return this.pos-this.start},I.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},I.QueryLexer.prototype.backup=function(){this.pos-=1},I.QueryLexer.prototype.acceptDigitRun=function(){var e,t;do{t=(e=this.next()).charCodeAt(0)}while(t>47&&t<58);e!=I.QueryLexer.EOS&&this.backup()},I.QueryLexer.prototype.more=function(){return this.pos1&&(e.backup(),e.emit(I.QueryLexer.TERM)),e.ignore(),e.more())return I.QueryLexer.lexText},I.QueryLexer.lexEditDistance=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(I.QueryLexer.EDIT_DISTANCE),I.QueryLexer.lexText},I.QueryLexer.lexBoost=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(I.QueryLexer.BOOST),I.QueryLexer.lexText},I.QueryLexer.lexEOS=function(e){e.width()>0&&e.emit(I.QueryLexer.TERM)},I.QueryLexer.termSeparator=I.tokenizer.separator,I.QueryLexer.lexText=function(e){for(;;){var t=e.next();if(t==I.QueryLexer.EOS)return I.QueryLexer.lexEOS;if(92!=t.charCodeAt(0)){if(":"==t)return I.QueryLexer.lexField;if("~"==t)return e.backup(),e.width()>0&&e.emit(I.QueryLexer.TERM),I.QueryLexer.lexEditDistance;if("^"==t)return e.backup(),e.width()>0&&e.emit(I.QueryLexer.TERM),I.QueryLexer.lexBoost;if("+"==t&&1===e.width())return e.emit(I.QueryLexer.PRESENCE),I.QueryLexer.lexText;if("-"==t&&1===e.width())return e.emit(I.QueryLexer.PRESENCE),I.QueryLexer.lexText;if(t.match(I.QueryLexer.termSeparator))return I.QueryLexer.lexTerm}else e.escapeCharacter()}},I.QueryParser=function(e,t){this.lexer=new I.QueryLexer(e),this.query=t,this.currentClause={},this.lexemeIdx=0},I.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var e=I.QueryParser.parseClause;e;)e=e(this);return this.query},I.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},I.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},I.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},I.QueryParser.parseClause=function(e){var t=e.peekLexeme();if(null!=t)switch(t.type){case I.QueryLexer.PRESENCE:return I.QueryParser.parsePresence;case I.QueryLexer.FIELD:return I.QueryParser.parseField;case I.QueryLexer.TERM:return I.QueryParser.parseTerm;default:var r="expected either a field or a term, found "+t.type;throw t.str.length>=1&&(r+=" with value '"+t.str+"'"),new I.QueryParseError(r,t.start,t.end)}},I.QueryParser.parsePresence=function(e){var t=e.consumeLexeme();if(null!=t){switch(t.str){case"-":e.currentClause.presence=I.Query.presence.PROHIBITED;break;case"+":e.currentClause.presence=I.Query.presence.REQUIRED;break;default:var r="unrecognised presence operator'"+t.str+"'";throw new I.QueryParseError(r,t.start,t.end)}var n=e.peekLexeme();if(null==n){r="expecting term or field, found nothing";throw new I.QueryParseError(r,t.start,t.end)}switch(n.type){case I.QueryLexer.FIELD:return I.QueryParser.parseField;case I.QueryLexer.TERM:return I.QueryParser.parseTerm;default:r="expecting term or field, found '"+n.type+"'";throw new I.QueryParseError(r,n.start,n.end)}}},I.QueryParser.parseField=function(e){var t=e.consumeLexeme();if(null!=t){if(-1==e.query.allFields.indexOf(t.str)){var r=e.query.allFields.map((function(e){return"'"+e+"'"})).join(", "),n="unrecognised field '"+t.str+"', possible fields: "+r;throw new I.QueryParseError(n,t.start,t.end)}e.currentClause.fields=[t.str];var i=e.peekLexeme();if(null==i){n="expecting term, found nothing";throw new I.QueryParseError(n,t.start,t.end)}switch(i.type){case I.QueryLexer.TERM:return I.QueryParser.parseTerm;default:n="expecting term, found '"+i.type+"'";throw new I.QueryParseError(n,i.start,i.end)}}},I.QueryParser.parseTerm=function(e){var t=e.consumeLexeme();if(null!=t){e.currentClause.term=t.str.toLowerCase(),-1!=t.str.indexOf("*")&&(e.currentClause.usePipeline=!1);var r=e.peekLexeme();if(null!=r)switch(r.type){case I.QueryLexer.TERM:return e.nextClause(),I.QueryParser.parseTerm;case I.QueryLexer.FIELD:return e.nextClause(),I.QueryParser.parseField;case I.QueryLexer.EDIT_DISTANCE:return I.QueryParser.parseEditDistance;case I.QueryLexer.BOOST:return I.QueryParser.parseBoost;case I.QueryLexer.PRESENCE:return e.nextClause(),I.QueryParser.parsePresence;default:var n="Unexpected lexeme type '"+r.type+"'";throw new I.QueryParseError(n,r.start,r.end)}else e.nextClause()}},I.QueryParser.parseEditDistance=function(e){var t=e.consumeLexeme();if(null!=t){var r=parseInt(t.str,10);if(isNaN(r)){var n="edit distance must be numeric";throw new I.QueryParseError(n,t.start,t.end)}e.currentClause.editDistance=r;var i=e.peekLexeme();if(null!=i)switch(i.type){case I.QueryLexer.TERM:return e.nextClause(),I.QueryParser.parseTerm;case I.QueryLexer.FIELD:return e.nextClause(),I.QueryParser.parseField;case I.QueryLexer.EDIT_DISTANCE:return I.QueryParser.parseEditDistance;case I.QueryLexer.BOOST:return I.QueryParser.parseBoost;case I.QueryLexer.PRESENCE:return e.nextClause(),I.QueryParser.parsePresence;default:n="Unexpected lexeme type '"+i.type+"'";throw new I.QueryParseError(n,i.start,i.end)}else e.nextClause()}},I.QueryParser.parseBoost=function(e){var t=e.consumeLexeme();if(null!=t){var r=parseInt(t.str,10);if(isNaN(r)){var n="boost must be numeric";throw new I.QueryParseError(n,t.start,t.end)}e.currentClause.boost=r;var i=e.peekLexeme();if(null!=i)switch(i.type){case I.QueryLexer.TERM:return e.nextClause(),I.QueryParser.parseTerm;case I.QueryLexer.FIELD:return e.nextClause(),I.QueryParser.parseField;case I.QueryLexer.EDIT_DISTANCE:return I.QueryParser.parseEditDistance;case I.QueryLexer.BOOST:return I.QueryParser.parseBoost;case I.QueryLexer.PRESENCE:return e.nextClause(),I.QueryParser.parsePresence;default:n="Unexpected lexeme type '"+i.type+"'";throw new I.QueryParseError(n,i.start,i.end)}else e.nextClause()}},void 0===(i="function"==typeof(n=function(){return I})?n.call(t,r,t,e):n)||(e.exports=i)}()},function(e,t,r){"use strict";r.r(t),r.d(t,"handler",(function(){return h}));var n=function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,s=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o}function o(){for(var e=[],t=0;t"+r+""};return function(i){i=i.replace(/[\s*+-:~^]+/g," ").trim();var s=new RegExp("(^|"+e.separator+")("+i.replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&").replace(t,"|")+")","img");return function(e){return n(n({},e),{title:e.title.replace(s,r),text:e.text.replace(s,r)})}}}(t),this.index=void 0===l?lunr((function(){var e,n,s,a,l;u=u||["trimmer","stopWordFilter"],this.pipeline.reset();try{for(var c=i(u),h=c.next();!h.done;h=c.next()){var d=h.value;this.pipeline.add(lunr[d])}}catch(t){e={error:t}}finally{try{h&&!h.done&&(n=c.return)&&n.call(c)}finally{if(e)throw e.error}}1===t.lang.length&&"en"!==t.lang[0]?this.use(lunr[t.lang[0]]):t.lang.length>1&&this.use((s=lunr).multiLanguage.apply(s,o(t.lang))),this.field("title",{boost:1e3}),this.field("text"),this.ref("location");try{for(var f=i(r),p=f.next();!p.done;p=f.next()){var y=p.value;this.add(y)}}catch(e){a={error:e}}finally{try{p&&!p.done&&(l=f.return)&&l.call(f)}finally{if(a)throw a.error}}})):lunr.Index.load("string"==typeof l?JSON.parse(l):l)}return e.prototype.query=function(e){var t=this;if(e)try{var r=this.index.search(e).reduce((function(e,r){var n=t.documents.get(r.ref);if(void 0!==n)if("parent"in n){var i=n.parent.location;e.set(i,o(e.get(i)||[],[r]))}else{i=n.location;e.set(i,e.get(i)||[])}return e}),new Map),n=this.highlight(e);return o(r).map((function(e){var r=s(e,2),i=r[0],o=r[1];return{article:n(t.documents.get(i)),sections:o.map((function(e){return n(t.documents.get(e.ref))}))}}))}catch(t){console.warn("Invalid query: "+e+" – see https://bit.ly/2s3ChXG")}return[]},e}();function h(e){switch(e.type){case u.SETUP:return function(e){var t,r,n="../lunr",s=[];try{for(var a=i(e.lang),u=a.next();!u.done;u=a.next()){var l=u.value;"ja"===l&&s.push(n+"/tinyseg.min.js"),"en"!==l&&s.push(n+"/min/lunr."+l+".min.js")}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}e.lang.length>1&&s.push(n+"/min/lunr.multi.min.js"),s.length&&importScripts.apply(void 0,o([n+"/min/lunr.stemmer.support.min.js"],s))}(e.data.config),l=new c(e.data),{type:u.READY};case u.QUERY:return{type:u.RESULT,data:l?l.query(e.data):[]};default:throw new TypeError("Invalid message type")}}!function(e){e[e.SETUP=0]="SETUP",e[e.READY=1]="READY",e[e.QUERY=2]="QUERY",e[e.RESULT=3]="RESULT"}(u||(u={})),addEventListener("message",(function(e){postMessage(h(e.data))}))}]); +//# sourceMappingURL=search.58d22e8e.min.js.map \ No newline at end of file diff --git a/docs/assets/javascripts/worker/search.58d22e8e.min.js.map b/docs/assets/javascripts/worker/search.58d22e8e.min.js.map new file mode 100644 index 0000000..177b4c3 --- /dev/null +++ b/docs/assets/javascripts/worker/search.58d22e8e.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./node_modules/escape-html/index.js","webpack:///./node_modules/lunr/lunr.js-exposed","webpack:///(webpack)/buildin/global.js","webpack:///./node_modules/lunr/lunr.js","webpack:///./node_modules/tslib/tslib.es6.js","webpack:///./src/assets/javascripts/integrations/search/_/index.ts","webpack:///./src/assets/javascripts/integrations/search/worker/message/index.ts","webpack:///./src/assets/javascripts/integrations/search/worker/main/index.ts","webpack:///./src/assets/javascripts/integrations/search/document/index.ts","webpack:///./src/assets/javascripts/integrations/search/highlighter/index.ts"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","matchHtmlRegExp","string","escape","str","match","exec","html","index","lastIndex","length","charCodeAt","substring","g","this","Function","e","window","global","step2list","step3list","v","C","re_mgr0","re_mgr1","re_meq1","re_s_v","re_1a","re2_1a","re_1b","re2_1b","re_1b_2","re2_1b_2","re3_1b_2","re4_1b_2","re_1c","re_2","re_3","re_4","re2_4","re_5","re_5_1","re3_5","porterStemmer","lunr","config","builder","Builder","pipeline","add","trimmer","stopWordFilter","stemmer","searchPipeline","build","version","utils","warn","message","console","asString","obj","toString","clone","keys","val","Array","isArray","slice","TypeError","FieldRef","docRef","fieldName","stringValue","_stringValue","joiner","fromString","indexOf","fieldRef","undefined","Set","elements","complete","intersect","other","union","contains","empty","a","b","intersection","element","push","concat","idf","posting","documentCount","documentsWithTerm","x","Math","log","abs","Token","metadata","update","fn","tokenizer","map","toLowerCase","len","tokens","sliceEnd","sliceStart","sliceLength","charAt","separator","tokenMetadata","Pipeline","_stack","registeredFunctions","registerFunction","label","warnIfFunctionNotRegistered","load","serialised","forEach","fnName","Error","fns","arguments","after","existingFn","newFn","pos","splice","before","remove","run","stackLength","memo","j","result","k","runString","token","reset","toJSON","Vector","_magnitude","positionForIndex","start","end","pivotPoint","floor","pivotIndex","insert","insertIdx","upsert","position","magnitude","sumOfSquares","elementsLength","sqrt","dot","otherVector","dotProduct","aLen","bLen","aVal","bVal","similarity","toArray","output","RegExp","w","stem","suffix","firstch","re","re2","re3","re4","substr","toUpperCase","test","replace","fp","generateStopWordFilter","stopWords","words","reduce","stopWord","TokenSet","final","edges","id","_nextId","fromArray","arr","finish","root","fromClause","clause","fromFuzzyString","term","editDistance","stack","node","editsRemaining","frame","pop","noEditNode","char","insertionNode","substitutionNode","transposeNode","charA","charB","next","prefix","edge","_str","labels","sort","qNode","qEdges","qLen","nEdges","nLen","q","qEdge","nEdge","previousWord","uncheckedNodes","minimizedNodes","word","commonPrefix","minimize","child","nextNode","parent","downTo","childKey","Index","attrs","invertedIndex","fieldVectors","tokenSet","fields","search","queryString","query","QueryParser","parse","Query","matchingFields","queryVectors","termFieldCache","requiredMatches","prohibitedMatches","clauses","terms","clauseMatches","usePipeline","termTokenSet","expandedTerms","presence","REQUIRED","field","expandedTerm","termIndex","_index","fieldPosting","matchingDocumentRefs","termField","matchingDocumentsSet","PROHIBITED","boost","fieldMatch","matchingDocumentRef","matchingFieldRef","MatchData","allRequiredMatches","allProhibitedMatches","matchingFieldRefs","results","matches","isNegated","docMatch","fieldVector","score","matchData","combine","ref","serializedIndex","serializedVectors","serializedInvertedIndex","tokenSetBuilder","tuple","_ref","_fields","_documents","fieldTermFrequencies","fieldLengths","_b","_k1","metadataWhitelist","attributes","RangeError","number","k1","doc","extractor","fieldTerms","metadataKey","calculateAverageFieldLengths","fieldRefs","numberOfFields","accumulator","documentsWithField","averageFieldLength","createFieldVectors","fieldRefsLength","termIdfCache","fieldLength","termFrequencies","termsLength","fieldBoost","docBoost","scoreWithPrecision","tf","round","createTokenSet","use","args","unshift","apply","clonedMetadata","metadataKeys","otherMatchData","allFields","wildcard","String","NONE","LEADING","TRAILING","OPTIONAL","options","QueryParseError","QueryLexer","lexemes","escapeCharPositions","state","lexText","sliceString","subSlices","join","emit","type","escapeCharacter","EOS","width","ignore","backup","acceptDigitRun","charCode","more","FIELD","TERM","EDIT_DISTANCE","BOOST","PRESENCE","lexField","lexer","lexTerm","lexEditDistance","lexBoost","lexEOS","termSeparator","currentClause","lexemeIdx","parseClause","peekLexeme","consumeLexeme","lexeme","nextClause","completedClause","parser","parsePresence","parseField","parseTerm","errorMessage","nextLexeme","possibleFields","f","parseEditDistance","parseBoost","parseInt","isNaN","__assign","assign","__values","iterator","done","__read","ar","error","__spread","SearchMessageType","docs","documents","Map","path","hash","location","title","text","linked","set","setupSearchDocumentMap","highlight","_","data","trim","document","setupSearchHighlighter","lang","multiLanguage","JSON","groups","sections","article","section","err","handler","SETUP","base","scripts","importScripts","setupLunrLanguages","READY","QUERY","RESULT","addEventListener","ev","postMessage"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,E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KAAKT,KAAWK,EAAII,KAAKT,MACjDD,EAAIC,IAKRI,EAAM3J,GADN0J,EAAKzI,GAEE+I,KAAKV,IAAMK,EAAIK,KAAKV,KACzBI,EAAKnJ,EACL+I,EAAIA,EAAEW,QAAQP,EAAG,KAKJ,KAAXD,IACFH,EAAIG,EAAQrE,cAAgBkE,EAAEQ,OAAO,IAGhCR,GAGF,SAAU9B,GACf,OAAOA,EAAMxC,OAAO7D,KAIxBC,EAAKyE,SAASG,iBAAiB5E,EAAKQ,QAAS;;;;IAmB7CR,EAAK+I,uBAAyB,SAAUC,GACtC,IAAIC,EAAQD,EAAUE,QAAO,SAAUnD,EAAMoD,GAE3C,OADApD,EAAKoD,GAAYA,EACVpD,IACN,IAEH,OAAO,SAAUK,GACf,GAAIA,GAAS6C,EAAM7C,EAAMlF,cAAgBkF,EAAMlF,WAAY,OAAOkF,IAiBtEpG,EAAKO,eAAiBP,EAAK+I,uBAAuB,CAChD,IACA,OACA,QACA,SACA,QACA,MACA,SACA,OACA,KACA,QACA,KACA,MACA,MACA,MACA,KACA,KACA,KACA,UACA,OACA,MACA,KACA,MACA,SACA,QACA,OACA,MACA,KACA,OACA,SACA,OACA,OACA,QACA,MACA,OACA,MACA,MACA,MACA,MACA,OACA,KACA,MACA,OACA,MACA,MACA,MACA,UACA,IACA,KACA,KACA,OACA,KACA,KACA,MACA,OACA,QACA,MACA,OACA,SACA,MACA,KACA,QACA,OACA,OACA,KACA,UACA,KACA,MACA,MACA,KACA,MACA,QACA,KACA,OACA,KACA,QACA,MACA,MACA,SACA,OACA,MACA,OACA,MACA,SACA,QACA,KACA,OACA,OACA,OACA,MACA,QACA,OACA,OACA,QACA,QACA,OACA,OACA,MACA,KACA,MACA,OACA,KACA,QACA,MACA,KACA,OACA,OACA,OACA,QACA,QACA,QACA,MACA,OACA,MACA,OACA,OACA,QACA,MACA,MACA,SAGF/I,EAAKyE,SAASG,iBAAiB5E,EAAKO,eAAgB;;;;IAqBpDP,EAAKM,QAAU,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,IAAMA,EAAI,QACA,OAATA,GAAeW,EAAQzV,KAAQwV,EAAI,mBAC1B,OAATV,GAAeW,EAAQzV,KAAQwV,EAAI,aAAaV,EAAI,Y,iGAItD7X,EAAO6X,KAAKha,OAAS,GACvB2a,EAAQzV,KAAQwV,EAAI,0BAGlBC,EAAQ3a,QACV4a,cAAa,gBACRF,EAAI,oCACJC,IAoBHE,CAAmB7X,EAAQ4W,KAAKzX,QAChC4M,EAAS,IAAI,EAAO/L,EAAQ4W,MACrB,CACLhE,KAAMkD,EAAkBgC,OAI5B,KAAKhC,EAAkBiC,MACrB,MAAO,CACLnF,KAAMkD,EAAkBkC,OACxBpB,KAAM7K,EAASA,EAAOE,MAAMjM,EAAQ4W,MAAQ,IAIhD,QACE,MAAM,IAAIjW,UAAU,0BDtE1B,SAAkBmV,GAChB,qBACA,qBACA,qBACA,uBAJF,CAAkBA,MAAiB,KC8EnCmC,iBAAiB,WAAW,SAAAC,GAC1BC,YAAYX,EAAQU,EAAGtB","file":"assets/javascripts/worker/search.58d22e8e.min.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 4);\n","/*!\n * escape-html\n * Copyright(c) 2012-2013 TJ Holowaychuk\n * Copyright(c) 2015 Andreas Lubbe\n * Copyright(c) 2015 Tiancheng \"Timothy\" Gu\n * MIT Licensed\n */\n\n'use strict';\n\n/**\n * Module variables.\n * @private\n */\n\nvar matchHtmlRegExp = /[\"'&<>]/;\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = escapeHtml;\n\n/**\n * Escape special characters in the given string of html.\n *\n * @param {string} string The string to escape for inserting into HTML\n * @return {string}\n * @public\n */\n\nfunction escapeHtml(string) {\n var str = '' + string;\n var match = matchHtmlRegExp.exec(str);\n\n if (!match) {\n return str;\n }\n\n var escape;\n var html = '';\n var index = 0;\n var lastIndex = 0;\n\n for (index = match.index; index < str.length; index++) {\n switch (str.charCodeAt(index)) {\n case 34: // \"\n escape = '"';\n break;\n case 38: // &\n escape = '&';\n break;\n case 39: // '\n escape = ''';\n break;\n case 60: // <\n escape = '<';\n break;\n case 62: // >\n escape = '>';\n break;\n default:\n continue;\n }\n\n if (lastIndex !== index) {\n html += str.substring(lastIndex, index);\n }\n\n lastIndex = index + 1;\n html += escape;\n }\n\n return lastIndex !== index\n ? html + str.substring(lastIndex, index)\n : html;\n}\n","module.exports = global[\"lunr\"] = require(\"-!./lunr.js\");","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","/**\n * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.8\n * Copyright (C) 2019 Oliver Nightingale\n * @license MIT\n */\n\n;(function(){\n\n/**\n * A convenience function for configuring and constructing\n * a new lunr Index.\n *\n * A lunr.Builder instance is created and the pipeline setup\n * with a trimmer, stop word filter and stemmer.\n *\n * This builder object is yielded to the configuration function\n * that is passed as a parameter, allowing the list of fields\n * and other builder parameters to be customised.\n *\n * All documents _must_ be added within the passed config function.\n *\n * @example\n * var idx = lunr(function () {\n * this.field('title')\n * this.field('body')\n * this.ref('id')\n *\n * documents.forEach(function (doc) {\n * this.add(doc)\n * }, this)\n * })\n *\n * @see {@link lunr.Builder}\n * @see {@link lunr.Pipeline}\n * @see {@link lunr.trimmer}\n * @see {@link lunr.stopWordFilter}\n * @see {@link lunr.stemmer}\n * @namespace {function} lunr\n */\nvar lunr = function (config) {\n var builder = new lunr.Builder\n\n builder.pipeline.add(\n lunr.trimmer,\n lunr.stopWordFilter,\n lunr.stemmer\n )\n\n builder.searchPipeline.add(\n lunr.stemmer\n )\n\n config.call(builder, builder)\n return builder.build()\n}\n\nlunr.version = \"2.3.8\"\n/*!\n * lunr.utils\n * Copyright (C) 2019 Oliver Nightingale\n */\n\n/**\n * A namespace containing utils for the rest of the lunr library\n * @namespace lunr.utils\n */\nlunr.utils = {}\n\n/**\n * Print a warning message to the console.\n *\n * @param {String} message The message to be printed.\n * @memberOf lunr.utils\n * @function\n */\nlunr.utils.warn = (function (global) {\n /* eslint-disable no-console */\n return function (message) {\n if (global.console && console.warn) {\n console.warn(message)\n }\n }\n /* eslint-enable no-console */\n})(this)\n\n/**\n * Convert an object to a string.\n *\n * In the case of `null` and `undefined` the function returns\n * the empty string, in all other cases the result of calling\n * `toString` on the passed object is returned.\n *\n * @param {Any} obj The object to convert to a string.\n * @return {String} string representation of the passed object.\n * @memberOf lunr.utils\n */\nlunr.utils.asString = function (obj) {\n if (obj === void 0 || obj === null) {\n return \"\"\n } else {\n return obj.toString()\n }\n}\n\n/**\n * Clones an object.\n *\n * Will create a copy of an existing object such that any mutations\n * on the copy cannot affect the original.\n *\n * Only shallow objects are supported, passing a nested object to this\n * function will cause a TypeError.\n *\n * Objects with primitives, and arrays of primitives are supported.\n *\n * @param {Object} obj The object to clone.\n * @return {Object} a clone of the passed object.\n * @throws {TypeError} when a nested object is passed.\n * @memberOf Utils\n */\nlunr.utils.clone = function (obj) {\n if (obj === null || obj === undefined) {\n return obj\n }\n\n var clone = Object.create(null),\n keys = Object.keys(obj)\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i],\n val = obj[key]\n\n if (Array.isArray(val)) {\n clone[key] = val.slice()\n continue\n }\n\n if (typeof val === 'string' ||\n typeof val === 'number' ||\n typeof val === 'boolean') {\n clone[key] = val\n continue\n }\n\n throw new TypeError(\"clone is not deep and does not support nested objects\")\n }\n\n return clone\n}\nlunr.FieldRef = function (docRef, fieldName, stringValue) {\n this.docRef = docRef\n this.fieldName = fieldName\n this._stringValue = stringValue\n}\n\nlunr.FieldRef.joiner = \"/\"\n\nlunr.FieldRef.fromString = function (s) {\n var n = s.indexOf(lunr.FieldRef.joiner)\n\n if (n === -1) {\n throw \"malformed field ref string\"\n }\n\n var fieldRef = s.slice(0, n),\n docRef = s.slice(n + 1)\n\n return new lunr.FieldRef (docRef, fieldRef, s)\n}\n\nlunr.FieldRef.prototype.toString = function () {\n if (this._stringValue == undefined) {\n this._stringValue = this.fieldName + lunr.FieldRef.joiner + this.docRef\n }\n\n return this._stringValue\n}\n/*!\n * lunr.Set\n * Copyright (C) 2019 Oliver Nightingale\n */\n\n/**\n * A lunr set.\n *\n * @constructor\n */\nlunr.Set = function (elements) {\n this.elements = Object.create(null)\n\n if (elements) {\n this.length = elements.length\n\n for (var i = 0; i < this.length; i++) {\n this.elements[elements[i]] = true\n }\n } else {\n this.length = 0\n }\n}\n\n/**\n * A complete set that contains all elements.\n *\n * @static\n * @readonly\n * @type {lunr.Set}\n */\nlunr.Set.complete = {\n intersect: function (other) {\n return other\n },\n\n union: function (other) {\n return other\n },\n\n contains: function () {\n return true\n }\n}\n\n/**\n * An empty set that contains no elements.\n *\n * @static\n * @readonly\n * @type {lunr.Set}\n */\nlunr.Set.empty = {\n intersect: function () {\n return this\n },\n\n union: function (other) {\n return other\n },\n\n contains: function () {\n return false\n }\n}\n\n/**\n * Returns true if this set contains the specified object.\n *\n * @param {object} object - Object whose presence in this set is to be tested.\n * @returns {boolean} - True if this set contains the specified object.\n */\nlunr.Set.prototype.contains = function (object) {\n return !!this.elements[object]\n}\n\n/**\n * Returns a new set containing only the elements that are present in both\n * this set and the specified set.\n *\n * @param {lunr.Set} other - set to intersect with this set.\n * @returns {lunr.Set} a new set that is the intersection of this and the specified set.\n */\n\nlunr.Set.prototype.intersect = function (other) {\n var a, b, elements, intersection = []\n\n if (other === lunr.Set.complete) {\n return this\n }\n\n if (other === lunr.Set.empty) {\n return other\n }\n\n if (this.length < other.length) {\n a = this\n b = other\n } else {\n a = other\n b = this\n }\n\n elements = Object.keys(a.elements)\n\n for (var i = 0; i < elements.length; i++) {\n var element = elements[i]\n if (element in b.elements) {\n intersection.push(element)\n }\n }\n\n return new lunr.Set (intersection)\n}\n\n/**\n * Returns a new set combining the elements of this and the specified set.\n *\n * @param {lunr.Set} other - set to union with this set.\n * @return {lunr.Set} a new set that is the union of this and the specified set.\n */\n\nlunr.Set.prototype.union = function (other) {\n if (other === lunr.Set.complete) {\n return lunr.Set.complete\n }\n\n if (other === lunr.Set.empty) {\n return this\n }\n\n return new lunr.Set(Object.keys(this.elements).concat(Object.keys(other.elements)))\n}\n/**\n * A function to calculate the inverse document frequency for\n * a posting. This is shared between the builder and the index\n *\n * @private\n * @param {object} posting - The posting for a given term\n * @param {number} documentCount - The total number of documents.\n */\nlunr.idf = function (posting, documentCount) {\n var documentsWithTerm = 0\n\n for (var fieldName in posting) {\n if (fieldName == '_index') continue // Ignore the term index, its not a field\n documentsWithTerm += Object.keys(posting[fieldName]).length\n }\n\n var x = (documentCount - documentsWithTerm + 0.5) / (documentsWithTerm + 0.5)\n\n return Math.log(1 + Math.abs(x))\n}\n\n/**\n * A token wraps a string representation of a token\n * as it is passed through the text processing pipeline.\n *\n * @constructor\n * @param {string} [str=''] - The string token being wrapped.\n * @param {object} [metadata={}] - Metadata associated with this token.\n */\nlunr.Token = function (str, metadata) {\n this.str = str || \"\"\n this.metadata = metadata || {}\n}\n\n/**\n * Returns the token string that is being wrapped by this object.\n *\n * @returns {string}\n */\nlunr.Token.prototype.toString = function () {\n return this.str\n}\n\n/**\n * A token update function is used when updating or optionally\n * when cloning a token.\n *\n * @callback lunr.Token~updateFunction\n * @param {string} str - The string representation of the token.\n * @param {Object} metadata - All metadata associated with this token.\n */\n\n/**\n * Applies the given function to the wrapped string token.\n *\n * @example\n * token.update(function (str, metadata) {\n * return str.toUpperCase()\n * })\n *\n * @param {lunr.Token~updateFunction} fn - A function to apply to the token string.\n * @returns {lunr.Token}\n */\nlunr.Token.prototype.update = function (fn) {\n this.str = fn(this.str, this.metadata)\n return this\n}\n\n/**\n * Creates a clone of this token. Optionally a function can be\n * applied to the cloned token.\n *\n * @param {lunr.Token~updateFunction} [fn] - An optional function to apply to the cloned token.\n * @returns {lunr.Token}\n */\nlunr.Token.prototype.clone = function (fn) {\n fn = fn || function (s) { return s }\n return new lunr.Token (fn(this.str, this.metadata), this.metadata)\n}\n/*!\n * lunr.tokenizer\n * Copyright (C) 2019 Oliver Nightingale\n */\n\n/**\n * A function for splitting a string into tokens ready to be inserted into\n * the search index. Uses `lunr.tokenizer.separator` to split strings, change\n * the value of this property to change how strings are split into tokens.\n *\n * This tokenizer will convert its parameter to a string by calling `toString` and\n * then will split this string on the character in `lunr.tokenizer.separator`.\n * Arrays will have their elements converted to strings and wrapped in a lunr.Token.\n *\n * Optional metadata can be passed to the tokenizer, this metadata will be cloned and\n * added as metadata to every token that is created from the object to be tokenized.\n *\n * @static\n * @param {?(string|object|object[])} obj - The object to convert into tokens\n * @param {?object} metadata - Optional metadata to associate with every token\n * @returns {lunr.Token[]}\n * @see {@link lunr.Pipeline}\n */\nlunr.tokenizer = function (obj, metadata) {\n if (obj == null || obj == undefined) {\n return []\n }\n\n if (Array.isArray(obj)) {\n return obj.map(function (t) {\n return new lunr.Token(\n lunr.utils.asString(t).toLowerCase(),\n lunr.utils.clone(metadata)\n )\n })\n }\n\n var str = obj.toString().toLowerCase(),\n len = str.length,\n tokens = []\n\n for (var sliceEnd = 0, sliceStart = 0; sliceEnd <= len; sliceEnd++) {\n var char = str.charAt(sliceEnd),\n sliceLength = sliceEnd - sliceStart\n\n if ((char.match(lunr.tokenizer.separator) || sliceEnd == len)) {\n\n if (sliceLength > 0) {\n var tokenMetadata = lunr.utils.clone(metadata) || {}\n tokenMetadata[\"position\"] = [sliceStart, sliceLength]\n tokenMetadata[\"index\"] = tokens.length\n\n tokens.push(\n new lunr.Token (\n str.slice(sliceStart, sliceEnd),\n tokenMetadata\n )\n )\n }\n\n sliceStart = sliceEnd + 1\n }\n\n }\n\n return tokens\n}\n\n/**\n * The separator used to split a string into tokens. Override this property to change the behaviour of\n * `lunr.tokenizer` behaviour when tokenizing strings. By default this splits on whitespace and hyphens.\n *\n * @static\n * @see lunr.tokenizer\n */\nlunr.tokenizer.separator = /[\\s\\-]+/\n/*!\n * lunr.Pipeline\n * Copyright (C) 2019 Oliver Nightingale\n */\n\n/**\n * lunr.Pipelines maintain an ordered list of functions to be applied to all\n * tokens in documents entering the search index and queries being ran against\n * the index.\n *\n * An instance of lunr.Index created with the lunr shortcut will contain a\n * pipeline with a stop word filter and an English language stemmer. Extra\n * functions can be added before or after either of these functions or these\n * default functions can be removed.\n *\n * When run the pipeline will call each function in turn, passing a token, the\n * index of that token in the original list of all tokens and finally a list of\n * all the original tokens.\n *\n * The output of functions in the pipeline will be passed to the next function\n * in the pipeline. To exclude a token from entering the index the function\n * should return undefined, the rest of the pipeline will not be called with\n * this token.\n *\n * For serialisation of pipelines to work, all functions used in an instance of\n * a pipeline should be registered with lunr.Pipeline. Registered functions can\n * then be loaded. If trying to load a serialised pipeline that uses functions\n * that are not registered an error will be thrown.\n *\n * If not planning on serialising the pipeline then registering pipeline functions\n * is not necessary.\n *\n * @constructor\n */\nlunr.Pipeline = function () {\n this._stack = []\n}\n\nlunr.Pipeline.registeredFunctions = Object.create(null)\n\n/**\n * A pipeline function maps lunr.Token to lunr.Token. A lunr.Token contains the token\n * string as well as all known metadata. A pipeline function can mutate the token string\n * or mutate (or add) metadata for a given token.\n *\n * A pipeline function can indicate that the passed token should be discarded by returning\n * null, undefined or an empty string. This token will not be passed to any downstream pipeline\n * functions and will not be added to the index.\n *\n * Multiple tokens can be returned by returning an array of tokens. Each token will be passed\n * to any downstream pipeline functions and all will returned tokens will be added to the index.\n *\n * Any number of pipeline functions may be chained together using a lunr.Pipeline.\n *\n * @interface lunr.PipelineFunction\n * @param {lunr.Token} token - A token from the document being processed.\n * @param {number} i - The index of this token in the complete list of tokens for this document/field.\n * @param {lunr.Token[]} tokens - All tokens for this document/field.\n * @returns {(?lunr.Token|lunr.Token[])}\n */\n\n/**\n * Register a function with the pipeline.\n *\n * Functions that are used in the pipeline should be registered if the pipeline\n * needs to be serialised, or a serialised pipeline needs to be loaded.\n *\n * Registering a function does not add it to a pipeline, functions must still be\n * added to instances of the pipeline for them to be used when running a pipeline.\n *\n * @param {lunr.PipelineFunction} fn - The function to check for.\n * @param {String} label - The label to register this function with\n */\nlunr.Pipeline.registerFunction = function (fn, label) {\n if (label in this.registeredFunctions) {\n lunr.utils.warn('Overwriting existing registered function: ' + label)\n }\n\n fn.label = label\n lunr.Pipeline.registeredFunctions[fn.label] = fn\n}\n\n/**\n * Warns if the function is not registered as a Pipeline function.\n *\n * @param {lunr.PipelineFunction} fn - The function to check for.\n * @private\n */\nlunr.Pipeline.warnIfFunctionNotRegistered = function (fn) {\n var isRegistered = fn.label && (fn.label in this.registeredFunctions)\n\n if (!isRegistered) {\n lunr.utils.warn('Function is not registered with pipeline. This may cause problems when serialising the index.\\n', fn)\n }\n}\n\n/**\n * Loads a previously serialised pipeline.\n *\n * All functions to be loaded must already be registered with lunr.Pipeline.\n * If any function from the serialised data has not been registered then an\n * error will be thrown.\n *\n * @param {Object} serialised - The serialised pipeline to load.\n * @returns {lunr.Pipeline}\n */\nlunr.Pipeline.load = function (serialised) {\n var pipeline = new lunr.Pipeline\n\n serialised.forEach(function (fnName) {\n var fn = lunr.Pipeline.registeredFunctions[fnName]\n\n if (fn) {\n pipeline.add(fn)\n } else {\n throw new Error('Cannot load unregistered function: ' + fnName)\n }\n })\n\n return pipeline\n}\n\n/**\n * Adds new functions to the end of the pipeline.\n *\n * Logs a warning if the function has not been registered.\n *\n * @param {lunr.PipelineFunction[]} functions - Any number of functions to add to the pipeline.\n */\nlunr.Pipeline.prototype.add = function () {\n var fns = Array.prototype.slice.call(arguments)\n\n fns.forEach(function (fn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(fn)\n this._stack.push(fn)\n }, this)\n}\n\n/**\n * Adds a single function after a function that already exists in the\n * pipeline.\n *\n * Logs a warning if the function has not been registered.\n *\n * @param {lunr.PipelineFunction} existingFn - A function that already exists in the pipeline.\n * @param {lunr.PipelineFunction} newFn - The new function to add to the pipeline.\n */\nlunr.Pipeline.prototype.after = function (existingFn, newFn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(newFn)\n\n var pos = this._stack.indexOf(existingFn)\n if (pos == -1) {\n throw new Error('Cannot find existingFn')\n }\n\n pos = pos + 1\n this._stack.splice(pos, 0, newFn)\n}\n\n/**\n * Adds a single function before a function that already exists in the\n * pipeline.\n *\n * Logs a warning if the function has not been registered.\n *\n * @param {lunr.PipelineFunction} existingFn - A function that already exists in the pipeline.\n * @param {lunr.PipelineFunction} newFn - The new function to add to the pipeline.\n */\nlunr.Pipeline.prototype.before = function (existingFn, newFn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(newFn)\n\n var pos = this._stack.indexOf(existingFn)\n if (pos == -1) {\n throw new Error('Cannot find existingFn')\n }\n\n this._stack.splice(pos, 0, newFn)\n}\n\n/**\n * Removes a function from the pipeline.\n *\n * @param {lunr.PipelineFunction} fn The function to remove from the pipeline.\n */\nlunr.Pipeline.prototype.remove = function (fn) {\n var pos = this._stack.indexOf(fn)\n if (pos == -1) {\n return\n }\n\n this._stack.splice(pos, 1)\n}\n\n/**\n * Runs the current list of functions that make up the pipeline against the\n * passed tokens.\n *\n * @param {Array} tokens The tokens to run through the pipeline.\n * @returns {Array}\n */\nlunr.Pipeline.prototype.run = function (tokens) {\n var stackLength = this._stack.length\n\n for (var i = 0; i < stackLength; i++) {\n var fn = this._stack[i]\n var memo = []\n\n for (var j = 0; j < tokens.length; j++) {\n var result = fn(tokens[j], j, tokens)\n\n if (result === null || result === void 0 || result === '') continue\n\n if (Array.isArray(result)) {\n for (var k = 0; k < result.length; k++) {\n memo.push(result[k])\n }\n } else {\n memo.push(result)\n }\n }\n\n tokens = memo\n }\n\n return tokens\n}\n\n/**\n * Convenience method for passing a string through a pipeline and getting\n * strings out. This method takes care of wrapping the passed string in a\n * token and mapping the resulting tokens back to strings.\n *\n * @param {string} str - The string to pass through the pipeline.\n * @param {?object} metadata - Optional metadata to associate with the token\n * passed to the pipeline.\n * @returns {string[]}\n */\nlunr.Pipeline.prototype.runString = function (str, metadata) {\n var token = new lunr.Token (str, metadata)\n\n return this.run([token]).map(function (t) {\n return t.toString()\n })\n}\n\n/**\n * Resets the pipeline by removing any existing processors.\n *\n */\nlunr.Pipeline.prototype.reset = function () {\n this._stack = []\n}\n\n/**\n * Returns a representation of the pipeline ready for serialisation.\n *\n * Logs a warning if the function has not been registered.\n *\n * @returns {Array}\n */\nlunr.Pipeline.prototype.toJSON = function () {\n return this._stack.map(function (fn) {\n lunr.Pipeline.warnIfFunctionNotRegistered(fn)\n\n return fn.label\n })\n}\n/*!\n * lunr.Vector\n * Copyright (C) 2019 Oliver Nightingale\n */\n\n/**\n * A vector is used to construct the vector space of documents and queries. These\n * vectors support operations to determine the similarity between two documents or\n * a document and a query.\n *\n * Normally no parameters are required for initializing a vector, but in the case of\n * loading a previously dumped vector the raw elements can be provided to the constructor.\n *\n * For performance reasons vectors are implemented with a flat array, where an elements\n * index is immediately followed by its value. E.g. [index, value, index, value]. This\n * allows the underlying array to be as sparse as possible and still offer decent\n * performance when being used for vector calculations.\n *\n * @constructor\n * @param {Number[]} [elements] - The flat list of element index and element value pairs.\n */\nlunr.Vector = function (elements) {\n this._magnitude = 0\n this.elements = elements || []\n}\n\n\n/**\n * Calculates the position within the vector to insert a given index.\n *\n * This is used internally by insert and upsert. If there are duplicate indexes then\n * the position is returned as if the value for that index were to be updated, but it\n * is the callers responsibility to check whether there is a duplicate at that index\n *\n * @param {Number} insertIdx - The index at which the element should be inserted.\n * @returns {Number}\n */\nlunr.Vector.prototype.positionForIndex = function (index) {\n // For an empty vector the tuple can be inserted at the beginning\n if (this.elements.length == 0) {\n return 0\n }\n\n var start = 0,\n end = this.elements.length / 2,\n sliceLength = end - start,\n pivotPoint = Math.floor(sliceLength / 2),\n pivotIndex = this.elements[pivotPoint * 2]\n\n while (sliceLength > 1) {\n if (pivotIndex < index) {\n start = pivotPoint\n }\n\n if (pivotIndex > index) {\n end = pivotPoint\n }\n\n if (pivotIndex == index) {\n break\n }\n\n sliceLength = end - start\n pivotPoint = start + Math.floor(sliceLength / 2)\n pivotIndex = this.elements[pivotPoint * 2]\n }\n\n if (pivotIndex == index) {\n return pivotPoint * 2\n }\n\n if (pivotIndex > index) {\n return pivotPoint * 2\n }\n\n if (pivotIndex < index) {\n return (pivotPoint + 1) * 2\n }\n}\n\n/**\n * Inserts an element at an index within the vector.\n *\n * Does not allow duplicates, will throw an error if there is already an entry\n * for this index.\n *\n * @param {Number} insertIdx - The index at which the element should be inserted.\n * @param {Number} val - The value to be inserted into the vector.\n */\nlunr.Vector.prototype.insert = function (insertIdx, val) {\n this.upsert(insertIdx, val, function () {\n throw \"duplicate index\"\n })\n}\n\n/**\n * Inserts or updates an existing index within the vector.\n *\n * @param {Number} insertIdx - The index at which the element should be inserted.\n * @param {Number} val - The value to be inserted into the vector.\n * @param {function} fn - A function that is called for updates, the existing value and the\n * requested value are passed as arguments\n */\nlunr.Vector.prototype.upsert = function (insertIdx, val, fn) {\n this._magnitude = 0\n var position = this.positionForIndex(insertIdx)\n\n if (this.elements[position] == insertIdx) {\n this.elements[position + 1] = fn(this.elements[position + 1], val)\n } else {\n this.elements.splice(position, 0, insertIdx, val)\n }\n}\n\n/**\n * Calculates the magnitude of this vector.\n *\n * @returns {Number}\n */\nlunr.Vector.prototype.magnitude = function () {\n if (this._magnitude) return this._magnitude\n\n var sumOfSquares = 0,\n elementsLength = this.elements.length\n\n for (var i = 1; i < elementsLength; i += 2) {\n var val = this.elements[i]\n sumOfSquares += val * val\n }\n\n return this._magnitude = Math.sqrt(sumOfSquares)\n}\n\n/**\n * Calculates the dot product of this vector and another vector.\n *\n * @param {lunr.Vector} otherVector - The vector to compute the dot product with.\n * @returns {Number}\n */\nlunr.Vector.prototype.dot = function (otherVector) {\n var dotProduct = 0,\n a = this.elements, b = otherVector.elements,\n aLen = a.length, bLen = b.length,\n aVal = 0, bVal = 0,\n i = 0, j = 0\n\n while (i < aLen && j < bLen) {\n aVal = a[i], bVal = b[j]\n if (aVal < bVal) {\n i += 2\n } else if (aVal > bVal) {\n j += 2\n } else if (aVal == bVal) {\n dotProduct += a[i + 1] * b[j + 1]\n i += 2\n j += 2\n }\n }\n\n return dotProduct\n}\n\n/**\n * Calculates the similarity between this vector and another vector.\n *\n * @param {lunr.Vector} otherVector - The other vector to calculate the\n * similarity with.\n * @returns {Number}\n */\nlunr.Vector.prototype.similarity = function (otherVector) {\n return this.dot(otherVector) / this.magnitude() || 0\n}\n\n/**\n * Converts the vector to an array of the elements within the vector.\n *\n * @returns {Number[]}\n */\nlunr.Vector.prototype.toArray = function () {\n var output = new Array (this.elements.length / 2)\n\n for (var i = 1, j = 0; i < this.elements.length; i += 2, j++) {\n output[j] = this.elements[i]\n }\n\n return output\n}\n\n/**\n * A JSON serializable representation of the vector.\n *\n * @returns {Number[]}\n */\nlunr.Vector.prototype.toJSON = function () {\n return this.elements\n}\n/* eslint-disable */\n/*!\n * lunr.stemmer\n * Copyright (C) 2019 Oliver Nightingale\n * Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt\n */\n\n/**\n * lunr.stemmer is an english language stemmer, this is a JavaScript\n * implementation of the PorterStemmer taken from http://tartarus.org/~martin\n *\n * @static\n * @implements {lunr.PipelineFunction}\n * @param {lunr.Token} token - The string to stem\n * @returns {lunr.Token}\n * @see {@link lunr.Pipeline}\n * @function\n */\nlunr.stemmer = (function(){\n var step2list = {\n \"ational\" : \"ate\",\n \"tional\" : \"tion\",\n \"enci\" : \"ence\",\n \"anci\" : \"ance\",\n \"izer\" : \"ize\",\n \"bli\" : \"ble\",\n \"alli\" : \"al\",\n \"entli\" : \"ent\",\n \"eli\" : \"e\",\n \"ousli\" : \"ous\",\n \"ization\" : \"ize\",\n \"ation\" : \"ate\",\n \"ator\" : \"ate\",\n \"alism\" : \"al\",\n \"iveness\" : \"ive\",\n \"fulness\" : \"ful\",\n \"ousness\" : \"ous\",\n \"aliti\" : \"al\",\n \"iviti\" : \"ive\",\n \"biliti\" : \"ble\",\n \"logi\" : \"log\"\n },\n\n step3list = {\n \"icate\" : \"ic\",\n \"ative\" : \"\",\n \"alize\" : \"al\",\n \"iciti\" : \"ic\",\n \"ical\" : \"ic\",\n \"ful\" : \"\",\n \"ness\" : \"\"\n },\n\n c = \"[^aeiou]\", // consonant\n v = \"[aeiouy]\", // vowel\n C = c + \"[^aeiouy]*\", // consonant sequence\n V = v + \"[aeiou]*\", // vowel sequence\n\n mgr0 = \"^(\" + C + \")?\" + V + C, // [C]VC... is m>0\n meq1 = \"^(\" + C + \")?\" + V + C + \"(\" + V + \")?$\", // [C]VC[V] is m=1\n mgr1 = \"^(\" + C + \")?\" + V + C + V + C, // [C]VCVC... is m>1\n s_v = \"^(\" + C + \")?\" + v; // vowel in stem\n\n var re_mgr0 = new RegExp(mgr0);\n var re_mgr1 = new RegExp(mgr1);\n var re_meq1 = new RegExp(meq1);\n var re_s_v = new RegExp(s_v);\n\n var re_1a = /^(.+?)(ss|i)es$/;\n var re2_1a = /^(.+?)([^s])s$/;\n var re_1b = /^(.+?)eed$/;\n var re2_1b = /^(.+?)(ed|ing)$/;\n var re_1b_2 = /.$/;\n var re2_1b_2 = /(at|bl|iz)$/;\n var re3_1b_2 = new RegExp(\"([^aeiouylsz])\\\\1$\");\n var re4_1b_2 = new RegExp(\"^\" + C + v + \"[^aeiouwxy]$\");\n\n var re_1c = /^(.+?[^aeiou])y$/;\n var re_2 = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;\n\n var re_3 = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;\n\n var re_4 = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;\n var re2_4 = /^(.+?)(s|t)(ion)$/;\n\n var re_5 = /^(.+?)e$/;\n var re_5_1 = /ll$/;\n var re3_5 = new RegExp(\"^\" + C + v + \"[^aeiouwxy]$\");\n\n var porterStemmer = function porterStemmer(w) {\n var stem,\n suffix,\n firstch,\n re,\n re2,\n re3,\n re4;\n\n if (w.length < 3) { return w; }\n\n firstch = w.substr(0,1);\n if (firstch == \"y\") {\n w = firstch.toUpperCase() + w.substr(1);\n }\n\n // Step 1a\n re = re_1a\n re2 = re2_1a;\n\n if (re.test(w)) { w = w.replace(re,\"$1$2\"); }\n else if (re2.test(w)) { w = w.replace(re2,\"$1$2\"); }\n\n // Step 1b\n re = re_1b;\n re2 = re2_1b;\n if (re.test(w)) {\n var fp = re.exec(w);\n re = re_mgr0;\n if (re.test(fp[1])) {\n re = re_1b_2;\n w = w.replace(re,\"\");\n }\n } else if (re2.test(w)) {\n var fp = re2.exec(w);\n stem = fp[1];\n re2 = re_s_v;\n if (re2.test(stem)) {\n w = stem;\n re2 = re2_1b_2;\n re3 = re3_1b_2;\n re4 = re4_1b_2;\n if (re2.test(w)) { w = w + \"e\"; }\n else if (re3.test(w)) { re = re_1b_2; w = w.replace(re,\"\"); }\n else if (re4.test(w)) { w = w + \"e\"; }\n }\n }\n\n // Step 1c - replace suffix y or Y by i if preceded by a non-vowel which is not the first letter of the word (so cry -> cri, by -> by, say -> say)\n re = re_1c;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n w = stem + \"i\";\n }\n\n // Step 2\n re = re_2;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n suffix = fp[2];\n re = re_mgr0;\n if (re.test(stem)) {\n w = stem + step2list[suffix];\n }\n }\n\n // Step 3\n re = re_3;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n suffix = fp[2];\n re = re_mgr0;\n if (re.test(stem)) {\n w = stem + step3list[suffix];\n }\n }\n\n // Step 4\n re = re_4;\n re2 = re2_4;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n re = re_mgr1;\n if (re.test(stem)) {\n w = stem;\n }\n } else if (re2.test(w)) {\n var fp = re2.exec(w);\n stem = fp[1] + fp[2];\n re2 = re_mgr1;\n if (re2.test(stem)) {\n w = stem;\n }\n }\n\n // Step 5\n re = re_5;\n if (re.test(w)) {\n var fp = re.exec(w);\n stem = fp[1];\n re = re_mgr1;\n re2 = re_meq1;\n re3 = re3_5;\n if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) {\n w = stem;\n }\n }\n\n re = re_5_1;\n re2 = re_mgr1;\n if (re.test(w) && re2.test(w)) {\n re = re_1b_2;\n w = w.replace(re,\"\");\n }\n\n // and turn initial Y back to y\n\n if (firstch == \"y\") {\n w = firstch.toLowerCase() + w.substr(1);\n }\n\n return w;\n };\n\n return function (token) {\n return token.update(porterStemmer);\n }\n})();\n\nlunr.Pipeline.registerFunction(lunr.stemmer, 'stemmer')\n/*!\n * lunr.stopWordFilter\n * Copyright (C) 2019 Oliver Nightingale\n */\n\n/**\n * lunr.generateStopWordFilter builds a stopWordFilter function from the provided\n * list of stop words.\n *\n * The built in lunr.stopWordFilter is built using this generator and can be used\n * to generate custom stopWordFilters for applications or non English languages.\n *\n * @function\n * @param {Array} token The token to pass through the filter\n * @returns {lunr.PipelineFunction}\n * @see lunr.Pipeline\n * @see lunr.stopWordFilter\n */\nlunr.generateStopWordFilter = function (stopWords) {\n var words = stopWords.reduce(function (memo, stopWord) {\n memo[stopWord] = stopWord\n return memo\n }, {})\n\n return function (token) {\n if (token && words[token.toString()] !== token.toString()) return token\n }\n}\n\n/**\n * lunr.stopWordFilter is an English language stop word list filter, any words\n * contained in the list will not be passed through the filter.\n *\n * This is intended to be used in the Pipeline. If the token does not pass the\n * filter then undefined will be returned.\n *\n * @function\n * @implements {lunr.PipelineFunction}\n * @params {lunr.Token} token - A token to check for being a stop word.\n * @returns {lunr.Token}\n * @see {@link lunr.Pipeline}\n */\nlunr.stopWordFilter = lunr.generateStopWordFilter([\n 'a',\n 'able',\n 'about',\n 'across',\n 'after',\n 'all',\n 'almost',\n 'also',\n 'am',\n 'among',\n 'an',\n 'and',\n 'any',\n 'are',\n 'as',\n 'at',\n 'be',\n 'because',\n 'been',\n 'but',\n 'by',\n 'can',\n 'cannot',\n 'could',\n 'dear',\n 'did',\n 'do',\n 'does',\n 'either',\n 'else',\n 'ever',\n 'every',\n 'for',\n 'from',\n 'get',\n 'got',\n 'had',\n 'has',\n 'have',\n 'he',\n 'her',\n 'hers',\n 'him',\n 'his',\n 'how',\n 'however',\n 'i',\n 'if',\n 'in',\n 'into',\n 'is',\n 'it',\n 'its',\n 'just',\n 'least',\n 'let',\n 'like',\n 'likely',\n 'may',\n 'me',\n 'might',\n 'most',\n 'must',\n 'my',\n 'neither',\n 'no',\n 'nor',\n 'not',\n 'of',\n 'off',\n 'often',\n 'on',\n 'only',\n 'or',\n 'other',\n 'our',\n 'own',\n 'rather',\n 'said',\n 'say',\n 'says',\n 'she',\n 'should',\n 'since',\n 'so',\n 'some',\n 'than',\n 'that',\n 'the',\n 'their',\n 'them',\n 'then',\n 'there',\n 'these',\n 'they',\n 'this',\n 'tis',\n 'to',\n 'too',\n 'twas',\n 'us',\n 'wants',\n 'was',\n 'we',\n 'were',\n 'what',\n 'when',\n 'where',\n 'which',\n 'while',\n 'who',\n 'whom',\n 'why',\n 'will',\n 'with',\n 'would',\n 'yet',\n 'you',\n 'your'\n])\n\nlunr.Pipeline.registerFunction(lunr.stopWordFilter, 'stopWordFilter')\n/*!\n * lunr.trimmer\n * Copyright (C) 2019 Oliver Nightingale\n */\n\n/**\n * lunr.trimmer is a pipeline function for trimming non word\n * characters from the beginning and end of tokens before they\n * enter the index.\n *\n * This implementation may not work correctly for non latin\n * characters and should either be removed or adapted for use\n * with languages with non-latin characters.\n *\n * @static\n * @implements {lunr.PipelineFunction}\n * @param {lunr.Token} token The token to pass through the filter\n * @returns {lunr.Token}\n * @see lunr.Pipeline\n */\nlunr.trimmer = function (token) {\n return token.update(function (s) {\n return s.replace(/^\\W+/, '').replace(/\\W+$/, '')\n })\n}\n\nlunr.Pipeline.registerFunction(lunr.trimmer, 'trimmer')\n/*!\n * lunr.TokenSet\n * Copyright (C) 2019 Oliver Nightingale\n */\n\n/**\n * A token set is used to store the unique list of all tokens\n * within an index. Token sets are also used to represent an\n * incoming query to the index, this query token set and index\n * token set are then intersected to find which tokens to look\n * up in the inverted index.\n *\n * A token set can hold multiple tokens, as in the case of the\n * index token set, or it can hold a single token as in the\n * case of a simple query token set.\n *\n * Additionally token sets are used to perform wildcard matching.\n * Leading, contained and trailing wildcards are supported, and\n * from this edit distance matching can also be provided.\n *\n * Token sets are implemented as a minimal finite state automata,\n * where both common prefixes and suffixes are shared between tokens.\n * This helps to reduce the space used for storing the token set.\n *\n * @constructor\n */\nlunr.TokenSet = function () {\n this.final = false\n this.edges = {}\n this.id = lunr.TokenSet._nextId\n lunr.TokenSet._nextId += 1\n}\n\n/**\n * Keeps track of the next, auto increment, identifier to assign\n * to a new tokenSet.\n *\n * TokenSets require a unique identifier to be correctly minimised.\n *\n * @private\n */\nlunr.TokenSet._nextId = 1\n\n/**\n * Creates a TokenSet instance from the given sorted array of words.\n *\n * @param {String[]} arr - A sorted array of strings to create the set from.\n * @returns {lunr.TokenSet}\n * @throws Will throw an error if the input array is not sorted.\n */\nlunr.TokenSet.fromArray = function (arr) {\n var builder = new lunr.TokenSet.Builder\n\n for (var i = 0, len = arr.length; i < len; i++) {\n builder.insert(arr[i])\n }\n\n builder.finish()\n return builder.root\n}\n\n/**\n * Creates a token set from a query clause.\n *\n * @private\n * @param {Object} clause - A single clause from lunr.Query.\n * @param {string} clause.term - The query clause term.\n * @param {number} [clause.editDistance] - The optional edit distance for the term.\n * @returns {lunr.TokenSet}\n */\nlunr.TokenSet.fromClause = function (clause) {\n if ('editDistance' in clause) {\n return lunr.TokenSet.fromFuzzyString(clause.term, clause.editDistance)\n } else {\n return lunr.TokenSet.fromString(clause.term)\n }\n}\n\n/**\n * Creates a token set representing a single string with a specified\n * edit distance.\n *\n * Insertions, deletions, substitutions and transpositions are each\n * treated as an edit distance of 1.\n *\n * Increasing the allowed edit distance will have a dramatic impact\n * on the performance of both creating and intersecting these TokenSets.\n * It is advised to keep the edit distance less than 3.\n *\n * @param {string} str - The string to create the token set from.\n * @param {number} editDistance - The allowed edit distance to match.\n * @returns {lunr.Vector}\n */\nlunr.TokenSet.fromFuzzyString = function (str, editDistance) {\n var root = new lunr.TokenSet\n\n var stack = [{\n node: root,\n editsRemaining: editDistance,\n str: str\n }]\n\n while (stack.length) {\n var frame = stack.pop()\n\n // no edit\n if (frame.str.length > 0) {\n var char = frame.str.charAt(0),\n noEditNode\n\n if (char in frame.node.edges) {\n noEditNode = frame.node.edges[char]\n } else {\n noEditNode = new lunr.TokenSet\n frame.node.edges[char] = noEditNode\n }\n\n if (frame.str.length == 1) {\n noEditNode.final = true\n }\n\n stack.push({\n node: noEditNode,\n editsRemaining: frame.editsRemaining,\n str: frame.str.slice(1)\n })\n }\n\n if (frame.editsRemaining == 0) {\n continue\n }\n\n // insertion\n if (\"*\" in frame.node.edges) {\n var insertionNode = frame.node.edges[\"*\"]\n } else {\n var insertionNode = new lunr.TokenSet\n frame.node.edges[\"*\"] = insertionNode\n }\n\n if (frame.str.length == 0) {\n insertionNode.final = true\n }\n\n stack.push({\n node: insertionNode,\n editsRemaining: frame.editsRemaining - 1,\n str: frame.str\n })\n\n // deletion\n // can only do a deletion if we have enough edits remaining\n // and if there are characters left to delete in the string\n if (frame.str.length > 1) {\n stack.push({\n node: frame.node,\n editsRemaining: frame.editsRemaining - 1,\n str: frame.str.slice(1)\n })\n }\n\n // deletion\n // just removing the last character from the str\n if (frame.str.length == 1) {\n frame.node.final = true\n }\n\n // substitution\n // can only do a substitution if we have enough edits remaining\n // and if there are characters left to substitute\n if (frame.str.length >= 1) {\n if (\"*\" in frame.node.edges) {\n var substitutionNode = frame.node.edges[\"*\"]\n } else {\n var substitutionNode = new lunr.TokenSet\n frame.node.edges[\"*\"] = substitutionNode\n }\n\n if (frame.str.length == 1) {\n substitutionNode.final = true\n }\n\n stack.push({\n node: substitutionNode,\n editsRemaining: frame.editsRemaining - 1,\n str: frame.str.slice(1)\n })\n }\n\n // transposition\n // can only do a transposition if there are edits remaining\n // and there are enough characters to transpose\n if (frame.str.length > 1) {\n var charA = frame.str.charAt(0),\n charB = frame.str.charAt(1),\n transposeNode\n\n if (charB in frame.node.edges) {\n transposeNode = frame.node.edges[charB]\n } else {\n transposeNode = new lunr.TokenSet\n frame.node.edges[charB] = transposeNode\n }\n\n if (frame.str.length == 1) {\n transposeNode.final = true\n }\n\n stack.push({\n node: transposeNode,\n editsRemaining: frame.editsRemaining - 1,\n str: charA + frame.str.slice(2)\n })\n }\n }\n\n return root\n}\n\n/**\n * Creates a TokenSet from a string.\n *\n * The string may contain one or more wildcard characters (*)\n * that will allow wildcard matching when intersecting with\n * another TokenSet.\n *\n * @param {string} str - The string to create a TokenSet from.\n * @returns {lunr.TokenSet}\n */\nlunr.TokenSet.fromString = function (str) {\n var node = new lunr.TokenSet,\n root = node\n\n /*\n * Iterates through all characters within the passed string\n * appending a node for each character.\n *\n * When a wildcard character is found then a self\n * referencing edge is introduced to continually match\n * any number of any characters.\n */\n for (var i = 0, len = str.length; i < len; i++) {\n var char = str[i],\n final = (i == len - 1)\n\n if (char == \"*\") {\n node.edges[char] = node\n node.final = final\n\n } else {\n var next = new lunr.TokenSet\n next.final = final\n\n node.edges[char] = next\n node = next\n }\n }\n\n return root\n}\n\n/**\n * Converts this TokenSet into an array of strings\n * contained within the TokenSet.\n *\n * This is not intended to be used on a TokenSet that\n * contains wildcards, in these cases the results are\n * undefined and are likely to cause an infinite loop.\n *\n * @returns {string[]}\n */\nlunr.TokenSet.prototype.toArray = function () {\n var words = []\n\n var stack = [{\n prefix: \"\",\n node: this\n }]\n\n while (stack.length) {\n var frame = stack.pop(),\n edges = Object.keys(frame.node.edges),\n len = edges.length\n\n if (frame.node.final) {\n /* In Safari, at this point the prefix is sometimes corrupted, see:\n * https://github.com/olivernn/lunr.js/issues/279 Calling any\n * String.prototype method forces Safari to \"cast\" this string to what\n * it's supposed to be, fixing the bug. */\n frame.prefix.charAt(0)\n words.push(frame.prefix)\n }\n\n for (var i = 0; i < len; i++) {\n var edge = edges[i]\n\n stack.push({\n prefix: frame.prefix.concat(edge),\n node: frame.node.edges[edge]\n })\n }\n }\n\n return words\n}\n\n/**\n * Generates a string representation of a TokenSet.\n *\n * This is intended to allow TokenSets to be used as keys\n * in objects, largely to aid the construction and minimisation\n * of a TokenSet. As such it is not designed to be a human\n * friendly representation of the TokenSet.\n *\n * @returns {string}\n */\nlunr.TokenSet.prototype.toString = function () {\n // NOTE: Using Object.keys here as this.edges is very likely\n // to enter 'hash-mode' with many keys being added\n //\n // avoiding a for-in loop here as it leads to the function\n // being de-optimised (at least in V8). From some simple\n // benchmarks the performance is comparable, but allowing\n // V8 to optimize may mean easy performance wins in the future.\n\n if (this._str) {\n return this._str\n }\n\n var str = this.final ? '1' : '0',\n labels = Object.keys(this.edges).sort(),\n len = labels.length\n\n for (var i = 0; i < len; i++) {\n var label = labels[i],\n node = this.edges[label]\n\n str = str + label + node.id\n }\n\n return str\n}\n\n/**\n * Returns a new TokenSet that is the intersection of\n * this TokenSet and the passed TokenSet.\n *\n * This intersection will take into account any wildcards\n * contained within the TokenSet.\n *\n * @param {lunr.TokenSet} b - An other TokenSet to intersect with.\n * @returns {lunr.TokenSet}\n */\nlunr.TokenSet.prototype.intersect = function (b) {\n var output = new lunr.TokenSet,\n frame = undefined\n\n var stack = [{\n qNode: b,\n output: output,\n node: this\n }]\n\n while (stack.length) {\n frame = stack.pop()\n\n // NOTE: As with the #toString method, we are using\n // Object.keys and a for loop instead of a for-in loop\n // as both of these objects enter 'hash' mode, causing\n // the function to be de-optimised in V8\n var qEdges = Object.keys(frame.qNode.edges),\n qLen = qEdges.length,\n nEdges = Object.keys(frame.node.edges),\n nLen = nEdges.length\n\n for (var q = 0; q < qLen; q++) {\n var qEdge = qEdges[q]\n\n for (var n = 0; n < nLen; n++) {\n var nEdge = nEdges[n]\n\n if (nEdge == qEdge || qEdge == '*') {\n var node = frame.node.edges[nEdge],\n qNode = frame.qNode.edges[qEdge],\n final = node.final && qNode.final,\n next = undefined\n\n if (nEdge in frame.output.edges) {\n // an edge already exists for this character\n // no need to create a new node, just set the finality\n // bit unless this node is already final\n next = frame.output.edges[nEdge]\n next.final = next.final || final\n\n } else {\n // no edge exists yet, must create one\n // set the finality bit and insert it\n // into the output\n next = new lunr.TokenSet\n next.final = final\n frame.output.edges[nEdge] = next\n }\n\n stack.push({\n qNode: qNode,\n output: next,\n node: node\n })\n }\n }\n }\n }\n\n return output\n}\nlunr.TokenSet.Builder = function () {\n this.previousWord = \"\"\n this.root = new lunr.TokenSet\n this.uncheckedNodes = []\n this.minimizedNodes = {}\n}\n\nlunr.TokenSet.Builder.prototype.insert = function (word) {\n var node,\n commonPrefix = 0\n\n if (word < this.previousWord) {\n throw new Error (\"Out of order word insertion\")\n }\n\n for (var i = 0; i < word.length && i < this.previousWord.length; i++) {\n if (word[i] != this.previousWord[i]) break\n commonPrefix++\n }\n\n this.minimize(commonPrefix)\n\n if (this.uncheckedNodes.length == 0) {\n node = this.root\n } else {\n node = this.uncheckedNodes[this.uncheckedNodes.length - 1].child\n }\n\n for (var i = commonPrefix; i < word.length; i++) {\n var nextNode = new lunr.TokenSet,\n char = word[i]\n\n node.edges[char] = nextNode\n\n this.uncheckedNodes.push({\n parent: node,\n char: char,\n child: nextNode\n })\n\n node = nextNode\n }\n\n node.final = true\n this.previousWord = word\n}\n\nlunr.TokenSet.Builder.prototype.finish = function () {\n this.minimize(0)\n}\n\nlunr.TokenSet.Builder.prototype.minimize = function (downTo) {\n for (var i = this.uncheckedNodes.length - 1; i >= downTo; i--) {\n var node = this.uncheckedNodes[i],\n childKey = node.child.toString()\n\n if (childKey in this.minimizedNodes) {\n node.parent.edges[node.char] = this.minimizedNodes[childKey]\n } else {\n // Cache the key for this node since\n // we know it can't change anymore\n node.child._str = childKey\n\n this.minimizedNodes[childKey] = node.child\n }\n\n this.uncheckedNodes.pop()\n }\n}\n/*!\n * lunr.Index\n * Copyright (C) 2019 Oliver Nightingale\n */\n\n/**\n * An index contains the built index of all documents and provides a query interface\n * to the index.\n *\n * Usually instances of lunr.Index will not be created using this constructor, instead\n * lunr.Builder should be used to construct new indexes, or lunr.Index.load should be\n * used to load previously built and serialized indexes.\n *\n * @constructor\n * @param {Object} attrs - The attributes of the built search index.\n * @param {Object} attrs.invertedIndex - An index of term/field to document reference.\n * @param {Object} attrs.fieldVectors - Field vectors\n * @param {lunr.TokenSet} attrs.tokenSet - An set of all corpus tokens.\n * @param {string[]} attrs.fields - The names of indexed document fields.\n * @param {lunr.Pipeline} attrs.pipeline - The pipeline to use for search terms.\n */\nlunr.Index = function (attrs) {\n this.invertedIndex = attrs.invertedIndex\n this.fieldVectors = attrs.fieldVectors\n this.tokenSet = attrs.tokenSet\n this.fields = attrs.fields\n this.pipeline = attrs.pipeline\n}\n\n/**\n * A result contains details of a document matching a search query.\n * @typedef {Object} lunr.Index~Result\n * @property {string} ref - The reference of the document this result represents.\n * @property {number} score - A number between 0 and 1 representing how similar this document is to the query.\n * @property {lunr.MatchData} matchData - Contains metadata about this match including which term(s) caused the match.\n */\n\n/**\n * Although lunr provides the ability to create queries using lunr.Query, it also provides a simple\n * query language which itself is parsed into an instance of lunr.Query.\n *\n * For programmatically building queries it is advised to directly use lunr.Query, the query language\n * is best used for human entered text rather than program generated text.\n *\n * At its simplest queries can just be a single term, e.g. `hello`, multiple terms are also supported\n * and will be combined with OR, e.g `hello world` will match documents that contain either 'hello'\n * or 'world', though those that contain both will rank higher in the results.\n *\n * Wildcards can be included in terms to match one or more unspecified characters, these wildcards can\n * be inserted anywhere within the term, and more than one wildcard can exist in a single term. Adding\n * wildcards will increase the number of documents that will be found but can also have a negative\n * impact on query performance, especially with wildcards at the beginning of a term.\n *\n * Terms can be restricted to specific fields, e.g. `title:hello`, only documents with the term\n * hello in the title field will match this query. Using a field not present in the index will lead\n * to an error being thrown.\n *\n * Modifiers can also be added to terms, lunr supports edit distance and boost modifiers on terms. A term\n * boost will make documents matching that term score higher, e.g. `foo^5`. Edit distance is also supported\n * to provide fuzzy matching, e.g. 'hello~2' will match documents with hello with an edit distance of 2.\n * Avoid large values for edit distance to improve query performance.\n *\n * Each term also supports a presence modifier. By default a term's presence in document is optional, however\n * this can be changed to either required or prohibited. For a term's presence to be required in a document the\n * term should be prefixed with a '+', e.g. `+foo bar` is a search for documents that must contain 'foo' and\n * optionally contain 'bar'. Conversely a leading '-' sets the terms presence to prohibited, i.e. it must not\n * appear in a document, e.g. `-foo bar` is a search for documents that do not contain 'foo' but may contain 'bar'.\n *\n * To escape special characters the backslash character '\\' can be used, this allows searches to include\n * characters that would normally be considered modifiers, e.g. `foo\\~2` will search for a term \"foo~2\" instead\n * of attempting to apply a boost of 2 to the search term \"foo\".\n *\n * @typedef {string} lunr.Index~QueryString\n * @example Simple single term query\n * hello\n * @example Multiple term query\n * hello world\n * @example term scoped to a field\n * title:hello\n * @example term with a boost of 10\n * hello^10\n * @example term with an edit distance of 2\n * hello~2\n * @example terms with presence modifiers\n * -foo +bar baz\n */\n\n/**\n * Performs a search against the index using lunr query syntax.\n *\n * Results will be returned sorted by their score, the most relevant results\n * will be returned first. For details on how the score is calculated, please see\n * the {@link https://lunrjs.com/guides/searching.html#scoring|guide}.\n *\n * For more programmatic querying use lunr.Index#query.\n *\n * @param {lunr.Index~QueryString} queryString - A string containing a lunr query.\n * @throws {lunr.QueryParseError} If the passed query string cannot be parsed.\n * @returns {lunr.Index~Result[]}\n */\nlunr.Index.prototype.search = function (queryString) {\n return this.query(function (query) {\n var parser = new lunr.QueryParser(queryString, query)\n parser.parse()\n })\n}\n\n/**\n * A query builder callback provides a query object to be used to express\n * the query to perform on the index.\n *\n * @callback lunr.Index~queryBuilder\n * @param {lunr.Query} query - The query object to build up.\n * @this lunr.Query\n */\n\n/**\n * Performs a query against the index using the yielded lunr.Query object.\n *\n * If performing programmatic queries against the index, this method is preferred\n * over lunr.Index#search so as to avoid the additional query parsing overhead.\n *\n * A query object is yielded to the supplied function which should be used to\n * express the query to be run against the index.\n *\n * Note that although this function takes a callback parameter it is _not_ an\n * asynchronous operation, the callback is just yielded a query object to be\n * customized.\n *\n * @param {lunr.Index~queryBuilder} fn - A function that is used to build the query.\n * @returns {lunr.Index~Result[]}\n */\nlunr.Index.prototype.query = function (fn) {\n // for each query clause\n // * process terms\n // * expand terms from token set\n // * find matching documents and metadata\n // * get document vectors\n // * score documents\n\n var query = new lunr.Query(this.fields),\n matchingFields = Object.create(null),\n queryVectors = Object.create(null),\n termFieldCache = Object.create(null),\n requiredMatches = Object.create(null),\n prohibitedMatches = Object.create(null)\n\n /*\n * To support field level boosts a query vector is created per\n * field. An empty vector is eagerly created to support negated\n * queries.\n */\n for (var i = 0; i < this.fields.length; i++) {\n queryVectors[this.fields[i]] = new lunr.Vector\n }\n\n fn.call(query, query)\n\n for (var i = 0; i < query.clauses.length; i++) {\n /*\n * Unless the pipeline has been disabled for this term, which is\n * the case for terms with wildcards, we need to pass the clause\n * term through the search pipeline. A pipeline returns an array\n * of processed terms. Pipeline functions may expand the passed\n * term, which means we may end up performing multiple index lookups\n * for a single query term.\n */\n var clause = query.clauses[i],\n terms = null,\n clauseMatches = lunr.Set.complete\n\n if (clause.usePipeline) {\n terms = this.pipeline.runString(clause.term, {\n fields: clause.fields\n })\n } else {\n terms = [clause.term]\n }\n\n for (var m = 0; m < terms.length; m++) {\n var term = terms[m]\n\n /*\n * Each term returned from the pipeline needs to use the same query\n * clause object, e.g. the same boost and or edit distance. The\n * simplest way to do this is to re-use the clause object but mutate\n * its term property.\n */\n clause.term = term\n\n /*\n * From the term in the clause we create a token set which will then\n * be used to intersect the indexes token set to get a list of terms\n * to lookup in the inverted index\n */\n var termTokenSet = lunr.TokenSet.fromClause(clause),\n expandedTerms = this.tokenSet.intersect(termTokenSet).toArray()\n\n /*\n * If a term marked as required does not exist in the tokenSet it is\n * impossible for the search to return any matches. We set all the field\n * scoped required matches set to empty and stop examining any further\n * clauses.\n */\n if (expandedTerms.length === 0 && clause.presence === lunr.Query.presence.REQUIRED) {\n for (var k = 0; k < clause.fields.length; k++) {\n var field = clause.fields[k]\n requiredMatches[field] = lunr.Set.empty\n }\n\n break\n }\n\n for (var j = 0; j < expandedTerms.length; j++) {\n /*\n * For each term get the posting and termIndex, this is required for\n * building the query vector.\n */\n var expandedTerm = expandedTerms[j],\n posting = this.invertedIndex[expandedTerm],\n termIndex = posting._index\n\n for (var k = 0; k < clause.fields.length; k++) {\n /*\n * For each field that this query term is scoped by (by default\n * all fields are in scope) we need to get all the document refs\n * that have this term in that field.\n *\n * The posting is the entry in the invertedIndex for the matching\n * term from above.\n */\n var field = clause.fields[k],\n fieldPosting = posting[field],\n matchingDocumentRefs = Object.keys(fieldPosting),\n termField = expandedTerm + \"/\" + field,\n matchingDocumentsSet = new lunr.Set(matchingDocumentRefs)\n\n /*\n * if the presence of this term is required ensure that the matching\n * documents are added to the set of required matches for this clause.\n *\n */\n if (clause.presence == lunr.Query.presence.REQUIRED) {\n clauseMatches = clauseMatches.union(matchingDocumentsSet)\n\n if (requiredMatches[field] === undefined) {\n requiredMatches[field] = lunr.Set.complete\n }\n }\n\n /*\n * if the presence of this term is prohibited ensure that the matching\n * documents are added to the set of prohibited matches for this field,\n * creating that set if it does not yet exist.\n */\n if (clause.presence == lunr.Query.presence.PROHIBITED) {\n if (prohibitedMatches[field] === undefined) {\n prohibitedMatches[field] = lunr.Set.empty\n }\n\n prohibitedMatches[field] = prohibitedMatches[field].union(matchingDocumentsSet)\n\n /*\n * Prohibited matches should not be part of the query vector used for\n * similarity scoring and no metadata should be extracted so we continue\n * to the next field\n */\n continue\n }\n\n /*\n * The query field vector is populated using the termIndex found for\n * the term and a unit value with the appropriate boost applied.\n * Using upsert because there could already be an entry in the vector\n * for the term we are working with. In that case we just add the scores\n * together.\n */\n queryVectors[field].upsert(termIndex, clause.boost, function (a, b) { return a + b })\n\n /**\n * If we've already seen this term, field combo then we've already collected\n * the matching documents and metadata, no need to go through all that again\n */\n if (termFieldCache[termField]) {\n continue\n }\n\n for (var l = 0; l < matchingDocumentRefs.length; l++) {\n /*\n * All metadata for this term/field/document triple\n * are then extracted and collected into an instance\n * of lunr.MatchData ready to be returned in the query\n * results\n */\n var matchingDocumentRef = matchingDocumentRefs[l],\n matchingFieldRef = new lunr.FieldRef (matchingDocumentRef, field),\n metadata = fieldPosting[matchingDocumentRef],\n fieldMatch\n\n if ((fieldMatch = matchingFields[matchingFieldRef]) === undefined) {\n matchingFields[matchingFieldRef] = new lunr.MatchData (expandedTerm, field, metadata)\n } else {\n fieldMatch.add(expandedTerm, field, metadata)\n }\n\n }\n\n termFieldCache[termField] = true\n }\n }\n }\n\n /**\n * If the presence was required we need to update the requiredMatches field sets.\n * We do this after all fields for the term have collected their matches because\n * the clause terms presence is required in _any_ of the fields not _all_ of the\n * fields.\n */\n if (clause.presence === lunr.Query.presence.REQUIRED) {\n for (var k = 0; k < clause.fields.length; k++) {\n var field = clause.fields[k]\n requiredMatches[field] = requiredMatches[field].intersect(clauseMatches)\n }\n }\n }\n\n /**\n * Need to combine the field scoped required and prohibited\n * matching documents into a global set of required and prohibited\n * matches\n */\n var allRequiredMatches = lunr.Set.complete,\n allProhibitedMatches = lunr.Set.empty\n\n for (var i = 0; i < this.fields.length; i++) {\n var field = this.fields[i]\n\n if (requiredMatches[field]) {\n allRequiredMatches = allRequiredMatches.intersect(requiredMatches[field])\n }\n\n if (prohibitedMatches[field]) {\n allProhibitedMatches = allProhibitedMatches.union(prohibitedMatches[field])\n }\n }\n\n var matchingFieldRefs = Object.keys(matchingFields),\n results = [],\n matches = Object.create(null)\n\n /*\n * If the query is negated (contains only prohibited terms)\n * we need to get _all_ fieldRefs currently existing in the\n * index. This is only done when we know that the query is\n * entirely prohibited terms to avoid any cost of getting all\n * fieldRefs unnecessarily.\n *\n * Additionally, blank MatchData must be created to correctly\n * populate the results.\n */\n if (query.isNegated()) {\n matchingFieldRefs = Object.keys(this.fieldVectors)\n\n for (var i = 0; i < matchingFieldRefs.length; i++) {\n var matchingFieldRef = matchingFieldRefs[i]\n var fieldRef = lunr.FieldRef.fromString(matchingFieldRef)\n matchingFields[matchingFieldRef] = new lunr.MatchData\n }\n }\n\n for (var i = 0; i < matchingFieldRefs.length; i++) {\n /*\n * Currently we have document fields that match the query, but we\n * need to return documents. The matchData and scores are combined\n * from multiple fields belonging to the same document.\n *\n * Scores are calculated by field, using the query vectors created\n * above, and combined into a final document score using addition.\n */\n var fieldRef = lunr.FieldRef.fromString(matchingFieldRefs[i]),\n docRef = fieldRef.docRef\n\n if (!allRequiredMatches.contains(docRef)) {\n continue\n }\n\n if (allProhibitedMatches.contains(docRef)) {\n continue\n }\n\n var fieldVector = this.fieldVectors[fieldRef],\n score = queryVectors[fieldRef.fieldName].similarity(fieldVector),\n docMatch\n\n if ((docMatch = matches[docRef]) !== undefined) {\n docMatch.score += score\n docMatch.matchData.combine(matchingFields[fieldRef])\n } else {\n var match = {\n ref: docRef,\n score: score,\n matchData: matchingFields[fieldRef]\n }\n matches[docRef] = match\n results.push(match)\n }\n }\n\n /*\n * Sort the results objects by score, highest first.\n */\n return results.sort(function (a, b) {\n return b.score - a.score\n })\n}\n\n/**\n * Prepares the index for JSON serialization.\n *\n * The schema for this JSON blob will be described in a\n * separate JSON schema file.\n *\n * @returns {Object}\n */\nlunr.Index.prototype.toJSON = function () {\n var invertedIndex = Object.keys(this.invertedIndex)\n .sort()\n .map(function (term) {\n return [term, this.invertedIndex[term]]\n }, this)\n\n var fieldVectors = Object.keys(this.fieldVectors)\n .map(function (ref) {\n return [ref, this.fieldVectors[ref].toJSON()]\n }, this)\n\n return {\n version: lunr.version,\n fields: this.fields,\n fieldVectors: fieldVectors,\n invertedIndex: invertedIndex,\n pipeline: this.pipeline.toJSON()\n }\n}\n\n/**\n * Loads a previously serialized lunr.Index\n *\n * @param {Object} serializedIndex - A previously serialized lunr.Index\n * @returns {lunr.Index}\n */\nlunr.Index.load = function (serializedIndex) {\n var attrs = {},\n fieldVectors = {},\n serializedVectors = serializedIndex.fieldVectors,\n invertedIndex = Object.create(null),\n serializedInvertedIndex = serializedIndex.invertedIndex,\n tokenSetBuilder = new lunr.TokenSet.Builder,\n pipeline = lunr.Pipeline.load(serializedIndex.pipeline)\n\n if (serializedIndex.version != lunr.version) {\n lunr.utils.warn(\"Version mismatch when loading serialised index. Current version of lunr '\" + lunr.version + \"' does not match serialized index '\" + serializedIndex.version + \"'\")\n }\n\n for (var i = 0; i < serializedVectors.length; i++) {\n var tuple = serializedVectors[i],\n ref = tuple[0],\n elements = tuple[1]\n\n fieldVectors[ref] = new lunr.Vector(elements)\n }\n\n for (var i = 0; i < serializedInvertedIndex.length; i++) {\n var tuple = serializedInvertedIndex[i],\n term = tuple[0],\n posting = tuple[1]\n\n tokenSetBuilder.insert(term)\n invertedIndex[term] = posting\n }\n\n tokenSetBuilder.finish()\n\n attrs.fields = serializedIndex.fields\n\n attrs.fieldVectors = fieldVectors\n attrs.invertedIndex = invertedIndex\n attrs.tokenSet = tokenSetBuilder.root\n attrs.pipeline = pipeline\n\n return new lunr.Index(attrs)\n}\n/*!\n * lunr.Builder\n * Copyright (C) 2019 Oliver Nightingale\n */\n\n/**\n * lunr.Builder performs indexing on a set of documents and\n * returns instances of lunr.Index ready for querying.\n *\n * All configuration of the index is done via the builder, the\n * fields to index, the document reference, the text processing\n * pipeline and document scoring parameters are all set on the\n * builder before indexing.\n *\n * @constructor\n * @property {string} _ref - Internal reference to the document reference field.\n * @property {string[]} _fields - Internal reference to the document fields to index.\n * @property {object} invertedIndex - The inverted index maps terms to document fields.\n * @property {object} documentTermFrequencies - Keeps track of document term frequencies.\n * @property {object} documentLengths - Keeps track of the length of documents added to the index.\n * @property {lunr.tokenizer} tokenizer - Function for splitting strings into tokens for indexing.\n * @property {lunr.Pipeline} pipeline - The pipeline performs text processing on tokens before indexing.\n * @property {lunr.Pipeline} searchPipeline - A pipeline for processing search terms before querying the index.\n * @property {number} documentCount - Keeps track of the total number of documents indexed.\n * @property {number} _b - A parameter to control field length normalization, setting this to 0 disabled normalization, 1 fully normalizes field lengths, the default value is 0.75.\n * @property {number} _k1 - A parameter to control how quickly an increase in term frequency results in term frequency saturation, the default value is 1.2.\n * @property {number} termIndex - A counter incremented for each unique term, used to identify a terms position in the vector space.\n * @property {array} metadataWhitelist - A list of metadata keys that have been whitelisted for entry in the index.\n */\nlunr.Builder = function () {\n this._ref = \"id\"\n this._fields = Object.create(null)\n this._documents = Object.create(null)\n this.invertedIndex = Object.create(null)\n this.fieldTermFrequencies = {}\n this.fieldLengths = {}\n this.tokenizer = lunr.tokenizer\n this.pipeline = new lunr.Pipeline\n this.searchPipeline = new lunr.Pipeline\n this.documentCount = 0\n this._b = 0.75\n this._k1 = 1.2\n this.termIndex = 0\n this.metadataWhitelist = []\n}\n\n/**\n * Sets the document field used as the document reference. Every document must have this field.\n * The type of this field in the document should be a string, if it is not a string it will be\n * coerced into a string by calling toString.\n *\n * The default ref is 'id'.\n *\n * The ref should _not_ be changed during indexing, it should be set before any documents are\n * added to the index. Changing it during indexing can lead to inconsistent results.\n *\n * @param {string} ref - The name of the reference field in the document.\n */\nlunr.Builder.prototype.ref = function (ref) {\n this._ref = ref\n}\n\n/**\n * A function that is used to extract a field from a document.\n *\n * Lunr expects a field to be at the top level of a document, if however the field\n * is deeply nested within a document an extractor function can be used to extract\n * the right field for indexing.\n *\n * @callback fieldExtractor\n * @param {object} doc - The document being added to the index.\n * @returns {?(string|object|object[])} obj - The object that will be indexed for this field.\n * @example Extracting a nested field\n * function (doc) { return doc.nested.field }\n */\n\n/**\n * Adds a field to the list of document fields that will be indexed. Every document being\n * indexed should have this field. Null values for this field in indexed documents will\n * not cause errors but will limit the chance of that document being retrieved by searches.\n *\n * All fields should be added before adding documents to the index. Adding fields after\n * a document has been indexed will have no effect on already indexed documents.\n *\n * Fields can be boosted at build time. This allows terms within that field to have more\n * importance when ranking search results. Use a field boost to specify that matches within\n * one field are more important than other fields.\n *\n * @param {string} fieldName - The name of a field to index in all documents.\n * @param {object} attributes - Optional attributes associated with this field.\n * @param {number} [attributes.boost=1] - Boost applied to all terms within this field.\n * @param {fieldExtractor} [attributes.extractor] - Function to extract a field from a document.\n * @throws {RangeError} fieldName cannot contain unsupported characters '/'\n */\nlunr.Builder.prototype.field = function (fieldName, attributes) {\n if (/\\//.test(fieldName)) {\n throw new RangeError (\"Field '\" + fieldName + \"' contains illegal character '/'\")\n }\n\n this._fields[fieldName] = attributes || {}\n}\n\n/**\n * A parameter to tune the amount of field length normalisation that is applied when\n * calculating relevance scores. A value of 0 will completely disable any normalisation\n * and a value of 1 will fully normalise field lengths. The default is 0.75. Values of b\n * will be clamped to the range 0 - 1.\n *\n * @param {number} number - The value to set for this tuning parameter.\n */\nlunr.Builder.prototype.b = function (number) {\n if (number < 0) {\n this._b = 0\n } else if (number > 1) {\n this._b = 1\n } else {\n this._b = number\n }\n}\n\n/**\n * A parameter that controls the speed at which a rise in term frequency results in term\n * frequency saturation. The default value is 1.2. Setting this to a higher value will give\n * slower saturation levels, a lower value will result in quicker saturation.\n *\n * @param {number} number - The value to set for this tuning parameter.\n */\nlunr.Builder.prototype.k1 = function (number) {\n this._k1 = number\n}\n\n/**\n * Adds a document to the index.\n *\n * Before adding fields to the index the index should have been fully setup, with the document\n * ref and all fields to index already having been specified.\n *\n * The document must have a field name as specified by the ref (by default this is 'id') and\n * it should have all fields defined for indexing, though null or undefined values will not\n * cause errors.\n *\n * Entire documents can be boosted at build time. Applying a boost to a document indicates that\n * this document should rank higher in search results than other documents.\n *\n * @param {object} doc - The document to add to the index.\n * @param {object} attributes - Optional attributes associated with this document.\n * @param {number} [attributes.boost=1] - Boost applied to all terms within this document.\n */\nlunr.Builder.prototype.add = function (doc, attributes) {\n var docRef = doc[this._ref],\n fields = Object.keys(this._fields)\n\n this._documents[docRef] = attributes || {}\n this.documentCount += 1\n\n for (var i = 0; i < fields.length; i++) {\n var fieldName = fields[i],\n extractor = this._fields[fieldName].extractor,\n field = extractor ? extractor(doc) : doc[fieldName],\n tokens = this.tokenizer(field, {\n fields: [fieldName]\n }),\n terms = this.pipeline.run(tokens),\n fieldRef = new lunr.FieldRef (docRef, fieldName),\n fieldTerms = Object.create(null)\n\n this.fieldTermFrequencies[fieldRef] = fieldTerms\n this.fieldLengths[fieldRef] = 0\n\n // store the length of this field for this document\n this.fieldLengths[fieldRef] += terms.length\n\n // calculate term frequencies for this field\n for (var j = 0; j < terms.length; j++) {\n var term = terms[j]\n\n if (fieldTerms[term] == undefined) {\n fieldTerms[term] = 0\n }\n\n fieldTerms[term] += 1\n\n // add to inverted index\n // create an initial posting if one doesn't exist\n if (this.invertedIndex[term] == undefined) {\n var posting = Object.create(null)\n posting[\"_index\"] = this.termIndex\n this.termIndex += 1\n\n for (var k = 0; k < fields.length; k++) {\n posting[fields[k]] = Object.create(null)\n }\n\n this.invertedIndex[term] = posting\n }\n\n // add an entry for this term/fieldName/docRef to the invertedIndex\n if (this.invertedIndex[term][fieldName][docRef] == undefined) {\n this.invertedIndex[term][fieldName][docRef] = Object.create(null)\n }\n\n // store all whitelisted metadata about this token in the\n // inverted index\n for (var l = 0; l < this.metadataWhitelist.length; l++) {\n var metadataKey = this.metadataWhitelist[l],\n metadata = term.metadata[metadataKey]\n\n if (this.invertedIndex[term][fieldName][docRef][metadataKey] == undefined) {\n this.invertedIndex[term][fieldName][docRef][metadataKey] = []\n }\n\n this.invertedIndex[term][fieldName][docRef][metadataKey].push(metadata)\n }\n }\n\n }\n}\n\n/**\n * Calculates the average document length for this index\n *\n * @private\n */\nlunr.Builder.prototype.calculateAverageFieldLengths = function () {\n\n var fieldRefs = Object.keys(this.fieldLengths),\n numberOfFields = fieldRefs.length,\n accumulator = {},\n documentsWithField = {}\n\n for (var i = 0; i < numberOfFields; i++) {\n var fieldRef = lunr.FieldRef.fromString(fieldRefs[i]),\n field = fieldRef.fieldName\n\n documentsWithField[field] || (documentsWithField[field] = 0)\n documentsWithField[field] += 1\n\n accumulator[field] || (accumulator[field] = 0)\n accumulator[field] += this.fieldLengths[fieldRef]\n }\n\n var fields = Object.keys(this._fields)\n\n for (var i = 0; i < fields.length; i++) {\n var fieldName = fields[i]\n accumulator[fieldName] = accumulator[fieldName] / documentsWithField[fieldName]\n }\n\n this.averageFieldLength = accumulator\n}\n\n/**\n * Builds a vector space model of every document using lunr.Vector\n *\n * @private\n */\nlunr.Builder.prototype.createFieldVectors = function () {\n var fieldVectors = {},\n fieldRefs = Object.keys(this.fieldTermFrequencies),\n fieldRefsLength = fieldRefs.length,\n termIdfCache = Object.create(null)\n\n for (var i = 0; i < fieldRefsLength; i++) {\n var fieldRef = lunr.FieldRef.fromString(fieldRefs[i]),\n fieldName = fieldRef.fieldName,\n fieldLength = this.fieldLengths[fieldRef],\n fieldVector = new lunr.Vector,\n termFrequencies = this.fieldTermFrequencies[fieldRef],\n terms = Object.keys(termFrequencies),\n termsLength = terms.length\n\n\n var fieldBoost = this._fields[fieldName].boost || 1,\n docBoost = this._documents[fieldRef.docRef].boost || 1\n\n for (var j = 0; j < termsLength; j++) {\n var term = terms[j],\n tf = termFrequencies[term],\n termIndex = this.invertedIndex[term]._index,\n idf, score, scoreWithPrecision\n\n if (termIdfCache[term] === undefined) {\n idf = lunr.idf(this.invertedIndex[term], this.documentCount)\n termIdfCache[term] = idf\n } else {\n idf = termIdfCache[term]\n }\n\n score = idf * ((this._k1 + 1) * tf) / (this._k1 * (1 - this._b + this._b * (fieldLength / this.averageFieldLength[fieldName])) + tf)\n score *= fieldBoost\n score *= docBoost\n scoreWithPrecision = Math.round(score * 1000) / 1000\n // Converts 1.23456789 to 1.234.\n // Reducing the precision so that the vectors take up less\n // space when serialised. Doing it now so that they behave\n // the same before and after serialisation. Also, this is\n // the fastest approach to reducing a number's precision in\n // JavaScript.\n\n fieldVector.insert(termIndex, scoreWithPrecision)\n }\n\n fieldVectors[fieldRef] = fieldVector\n }\n\n this.fieldVectors = fieldVectors\n}\n\n/**\n * Creates a token set of all tokens in the index using lunr.TokenSet\n *\n * @private\n */\nlunr.Builder.prototype.createTokenSet = function () {\n this.tokenSet = lunr.TokenSet.fromArray(\n Object.keys(this.invertedIndex).sort()\n )\n}\n\n/**\n * Builds the index, creating an instance of lunr.Index.\n *\n * This completes the indexing process and should only be called\n * once all documents have been added to the index.\n *\n * @returns {lunr.Index}\n */\nlunr.Builder.prototype.build = function () {\n this.calculateAverageFieldLengths()\n this.createFieldVectors()\n this.createTokenSet()\n\n return new lunr.Index({\n invertedIndex: this.invertedIndex,\n fieldVectors: this.fieldVectors,\n tokenSet: this.tokenSet,\n fields: Object.keys(this._fields),\n pipeline: this.searchPipeline\n })\n}\n\n/**\n * Applies a plugin to the index builder.\n *\n * A plugin is a function that is called with the index builder as its context.\n * Plugins can be used to customise or extend the behaviour of the index\n * in some way. A plugin is just a function, that encapsulated the custom\n * behaviour that should be applied when building the index.\n *\n * The plugin function will be called with the index builder as its argument, additional\n * arguments can also be passed when calling use. The function will be called\n * with the index builder as its context.\n *\n * @param {Function} plugin The plugin to apply.\n */\nlunr.Builder.prototype.use = function (fn) {\n var args = Array.prototype.slice.call(arguments, 1)\n args.unshift(this)\n fn.apply(this, args)\n}\n/**\n * Contains and collects metadata about a matching document.\n * A single instance of lunr.MatchData is returned as part of every\n * lunr.Index~Result.\n *\n * @constructor\n * @param {string} term - The term this match data is associated with\n * @param {string} field - The field in which the term was found\n * @param {object} metadata - The metadata recorded about this term in this field\n * @property {object} metadata - A cloned collection of metadata associated with this document.\n * @see {@link lunr.Index~Result}\n */\nlunr.MatchData = function (term, field, metadata) {\n var clonedMetadata = Object.create(null),\n metadataKeys = Object.keys(metadata || {})\n\n // Cloning the metadata to prevent the original\n // being mutated during match data combination.\n // Metadata is kept in an array within the inverted\n // index so cloning the data can be done with\n // Array#slice\n for (var i = 0; i < metadataKeys.length; i++) {\n var key = metadataKeys[i]\n clonedMetadata[key] = metadata[key].slice()\n }\n\n this.metadata = Object.create(null)\n\n if (term !== undefined) {\n this.metadata[term] = Object.create(null)\n this.metadata[term][field] = clonedMetadata\n }\n}\n\n/**\n * An instance of lunr.MatchData will be created for every term that matches a\n * document. However only one instance is required in a lunr.Index~Result. This\n * method combines metadata from another instance of lunr.MatchData with this\n * objects metadata.\n *\n * @param {lunr.MatchData} otherMatchData - Another instance of match data to merge with this one.\n * @see {@link lunr.Index~Result}\n */\nlunr.MatchData.prototype.combine = function (otherMatchData) {\n var terms = Object.keys(otherMatchData.metadata)\n\n for (var i = 0; i < terms.length; i++) {\n var term = terms[i],\n fields = Object.keys(otherMatchData.metadata[term])\n\n if (this.metadata[term] == undefined) {\n this.metadata[term] = Object.create(null)\n }\n\n for (var j = 0; j < fields.length; j++) {\n var field = fields[j],\n keys = Object.keys(otherMatchData.metadata[term][field])\n\n if (this.metadata[term][field] == undefined) {\n this.metadata[term][field] = Object.create(null)\n }\n\n for (var k = 0; k < keys.length; k++) {\n var key = keys[k]\n\n if (this.metadata[term][field][key] == undefined) {\n this.metadata[term][field][key] = otherMatchData.metadata[term][field][key]\n } else {\n this.metadata[term][field][key] = this.metadata[term][field][key].concat(otherMatchData.metadata[term][field][key])\n }\n\n }\n }\n }\n}\n\n/**\n * Add metadata for a term/field pair to this instance of match data.\n *\n * @param {string} term - The term this match data is associated with\n * @param {string} field - The field in which the term was found\n * @param {object} metadata - The metadata recorded about this term in this field\n */\nlunr.MatchData.prototype.add = function (term, field, metadata) {\n if (!(term in this.metadata)) {\n this.metadata[term] = Object.create(null)\n this.metadata[term][field] = metadata\n return\n }\n\n if (!(field in this.metadata[term])) {\n this.metadata[term][field] = metadata\n return\n }\n\n var metadataKeys = Object.keys(metadata)\n\n for (var i = 0; i < metadataKeys.length; i++) {\n var key = metadataKeys[i]\n\n if (key in this.metadata[term][field]) {\n this.metadata[term][field][key] = this.metadata[term][field][key].concat(metadata[key])\n } else {\n this.metadata[term][field][key] = metadata[key]\n }\n }\n}\n/**\n * A lunr.Query provides a programmatic way of defining queries to be performed\n * against a {@link lunr.Index}.\n *\n * Prefer constructing a lunr.Query using the {@link lunr.Index#query} method\n * so the query object is pre-initialized with the right index fields.\n *\n * @constructor\n * @property {lunr.Query~Clause[]} clauses - An array of query clauses.\n * @property {string[]} allFields - An array of all available fields in a lunr.Index.\n */\nlunr.Query = function (allFields) {\n this.clauses = []\n this.allFields = allFields\n}\n\n/**\n * Constants for indicating what kind of automatic wildcard insertion will be used when constructing a query clause.\n *\n * This allows wildcards to be added to the beginning and end of a term without having to manually do any string\n * concatenation.\n *\n * The wildcard constants can be bitwise combined to select both leading and trailing wildcards.\n *\n * @constant\n * @default\n * @property {number} wildcard.NONE - The term will have no wildcards inserted, this is the default behaviour\n * @property {number} wildcard.LEADING - Prepend the term with a wildcard, unless a leading wildcard already exists\n * @property {number} wildcard.TRAILING - Append a wildcard to the term, unless a trailing wildcard already exists\n * @see lunr.Query~Clause\n * @see lunr.Query#clause\n * @see lunr.Query#term\n * @example query term with trailing wildcard\n * query.term('foo', { wildcard: lunr.Query.wildcard.TRAILING })\n * @example query term with leading and trailing wildcard\n * query.term('foo', {\n * wildcard: lunr.Query.wildcard.LEADING | lunr.Query.wildcard.TRAILING\n * })\n */\n\nlunr.Query.wildcard = new String (\"*\")\nlunr.Query.wildcard.NONE = 0\nlunr.Query.wildcard.LEADING = 1\nlunr.Query.wildcard.TRAILING = 2\n\n/**\n * Constants for indicating what kind of presence a term must have in matching documents.\n *\n * @constant\n * @enum {number}\n * @see lunr.Query~Clause\n * @see lunr.Query#clause\n * @see lunr.Query#term\n * @example query term with required presence\n * query.term('foo', { presence: lunr.Query.presence.REQUIRED })\n */\nlunr.Query.presence = {\n /**\n * Term's presence in a document is optional, this is the default value.\n */\n OPTIONAL: 1,\n\n /**\n * Term's presence in a document is required, documents that do not contain\n * this term will not be returned.\n */\n REQUIRED: 2,\n\n /**\n * Term's presence in a document is prohibited, documents that do contain\n * this term will not be returned.\n */\n PROHIBITED: 3\n}\n\n/**\n * A single clause in a {@link lunr.Query} contains a term and details on how to\n * match that term against a {@link lunr.Index}.\n *\n * @typedef {Object} lunr.Query~Clause\n * @property {string[]} fields - The fields in an index this clause should be matched against.\n * @property {number} [boost=1] - Any boost that should be applied when matching this clause.\n * @property {number} [editDistance] - Whether the term should have fuzzy matching applied, and how fuzzy the match should be.\n * @property {boolean} [usePipeline] - Whether the term should be passed through the search pipeline.\n * @property {number} [wildcard=lunr.Query.wildcard.NONE] - Whether the term should have wildcards appended or prepended.\n * @property {number} [presence=lunr.Query.presence.OPTIONAL] - The terms presence in any matching documents.\n */\n\n/**\n * Adds a {@link lunr.Query~Clause} to this query.\n *\n * Unless the clause contains the fields to be matched all fields will be matched. In addition\n * a default boost of 1 is applied to the clause.\n *\n * @param {lunr.Query~Clause} clause - The clause to add to this query.\n * @see lunr.Query~Clause\n * @returns {lunr.Query}\n */\nlunr.Query.prototype.clause = function (clause) {\n if (!('fields' in clause)) {\n clause.fields = this.allFields\n }\n\n if (!('boost' in clause)) {\n clause.boost = 1\n }\n\n if (!('usePipeline' in clause)) {\n clause.usePipeline = true\n }\n\n if (!('wildcard' in clause)) {\n clause.wildcard = lunr.Query.wildcard.NONE\n }\n\n if ((clause.wildcard & lunr.Query.wildcard.LEADING) && (clause.term.charAt(0) != lunr.Query.wildcard)) {\n clause.term = \"*\" + clause.term\n }\n\n if ((clause.wildcard & lunr.Query.wildcard.TRAILING) && (clause.term.slice(-1) != lunr.Query.wildcard)) {\n clause.term = \"\" + clause.term + \"*\"\n }\n\n if (!('presence' in clause)) {\n clause.presence = lunr.Query.presence.OPTIONAL\n }\n\n this.clauses.push(clause)\n\n return this\n}\n\n/**\n * A negated query is one in which every clause has a presence of\n * prohibited. These queries require some special processing to return\n * the expected results.\n *\n * @returns boolean\n */\nlunr.Query.prototype.isNegated = function () {\n for (var i = 0; i < this.clauses.length; i++) {\n if (this.clauses[i].presence != lunr.Query.presence.PROHIBITED) {\n return false\n }\n }\n\n return true\n}\n\n/**\n * Adds a term to the current query, under the covers this will create a {@link lunr.Query~Clause}\n * to the list of clauses that make up this query.\n *\n * The term is used as is, i.e. no tokenization will be performed by this method. Instead conversion\n * to a token or token-like string should be done before calling this method.\n *\n * The term will be converted to a string by calling `toString`. Multiple terms can be passed as an\n * array, each term in the array will share the same options.\n *\n * @param {object|object[]} term - The term(s) to add to the query.\n * @param {object} [options] - Any additional properties to add to the query clause.\n * @returns {lunr.Query}\n * @see lunr.Query#clause\n * @see lunr.Query~Clause\n * @example adding a single term to a query\n * query.term(\"foo\")\n * @example adding a single term to a query and specifying search fields, term boost and automatic trailing wildcard\n * query.term(\"foo\", {\n * fields: [\"title\"],\n * boost: 10,\n * wildcard: lunr.Query.wildcard.TRAILING\n * })\n * @example using lunr.tokenizer to convert a string to tokens before using them as terms\n * query.term(lunr.tokenizer(\"foo bar\"))\n */\nlunr.Query.prototype.term = function (term, options) {\n if (Array.isArray(term)) {\n term.forEach(function (t) { this.term(t, lunr.utils.clone(options)) }, this)\n return this\n }\n\n var clause = options || {}\n clause.term = term.toString()\n\n this.clause(clause)\n\n return this\n}\nlunr.QueryParseError = function (message, start, end) {\n this.name = \"QueryParseError\"\n this.message = message\n this.start = start\n this.end = end\n}\n\nlunr.QueryParseError.prototype = new Error\nlunr.QueryLexer = function (str) {\n this.lexemes = []\n this.str = str\n this.length = str.length\n this.pos = 0\n this.start = 0\n this.escapeCharPositions = []\n}\n\nlunr.QueryLexer.prototype.run = function () {\n var state = lunr.QueryLexer.lexText\n\n while (state) {\n state = state(this)\n }\n}\n\nlunr.QueryLexer.prototype.sliceString = function () {\n var subSlices = [],\n sliceStart = this.start,\n sliceEnd = this.pos\n\n for (var i = 0; i < this.escapeCharPositions.length; i++) {\n sliceEnd = this.escapeCharPositions[i]\n subSlices.push(this.str.slice(sliceStart, sliceEnd))\n sliceStart = sliceEnd + 1\n }\n\n subSlices.push(this.str.slice(sliceStart, this.pos))\n this.escapeCharPositions.length = 0\n\n return subSlices.join('')\n}\n\nlunr.QueryLexer.prototype.emit = function (type) {\n this.lexemes.push({\n type: type,\n str: this.sliceString(),\n start: this.start,\n end: this.pos\n })\n\n this.start = this.pos\n}\n\nlunr.QueryLexer.prototype.escapeCharacter = function () {\n this.escapeCharPositions.push(this.pos - 1)\n this.pos += 1\n}\n\nlunr.QueryLexer.prototype.next = function () {\n if (this.pos >= this.length) {\n return lunr.QueryLexer.EOS\n }\n\n var char = this.str.charAt(this.pos)\n this.pos += 1\n return char\n}\n\nlunr.QueryLexer.prototype.width = function () {\n return this.pos - this.start\n}\n\nlunr.QueryLexer.prototype.ignore = function () {\n if (this.start == this.pos) {\n this.pos += 1\n }\n\n this.start = this.pos\n}\n\nlunr.QueryLexer.prototype.backup = function () {\n this.pos -= 1\n}\n\nlunr.QueryLexer.prototype.acceptDigitRun = function () {\n var char, charCode\n\n do {\n char = this.next()\n charCode = char.charCodeAt(0)\n } while (charCode > 47 && charCode < 58)\n\n if (char != lunr.QueryLexer.EOS) {\n this.backup()\n }\n}\n\nlunr.QueryLexer.prototype.more = function () {\n return this.pos < this.length\n}\n\nlunr.QueryLexer.EOS = 'EOS'\nlunr.QueryLexer.FIELD = 'FIELD'\nlunr.QueryLexer.TERM = 'TERM'\nlunr.QueryLexer.EDIT_DISTANCE = 'EDIT_DISTANCE'\nlunr.QueryLexer.BOOST = 'BOOST'\nlunr.QueryLexer.PRESENCE = 'PRESENCE'\n\nlunr.QueryLexer.lexField = function (lexer) {\n lexer.backup()\n lexer.emit(lunr.QueryLexer.FIELD)\n lexer.ignore()\n return lunr.QueryLexer.lexText\n}\n\nlunr.QueryLexer.lexTerm = function (lexer) {\n if (lexer.width() > 1) {\n lexer.backup()\n lexer.emit(lunr.QueryLexer.TERM)\n }\n\n lexer.ignore()\n\n if (lexer.more()) {\n return lunr.QueryLexer.lexText\n }\n}\n\nlunr.QueryLexer.lexEditDistance = function (lexer) {\n lexer.ignore()\n lexer.acceptDigitRun()\n lexer.emit(lunr.QueryLexer.EDIT_DISTANCE)\n return lunr.QueryLexer.lexText\n}\n\nlunr.QueryLexer.lexBoost = function (lexer) {\n lexer.ignore()\n lexer.acceptDigitRun()\n lexer.emit(lunr.QueryLexer.BOOST)\n return lunr.QueryLexer.lexText\n}\n\nlunr.QueryLexer.lexEOS = function (lexer) {\n if (lexer.width() > 0) {\n lexer.emit(lunr.QueryLexer.TERM)\n }\n}\n\n// This matches the separator used when tokenising fields\n// within a document. These should match otherwise it is\n// not possible to search for some tokens within a document.\n//\n// It is possible for the user to change the separator on the\n// tokenizer so it _might_ clash with any other of the special\n// characters already used within the search string, e.g. :.\n//\n// This means that it is possible to change the separator in\n// such a way that makes some words unsearchable using a search\n// string.\nlunr.QueryLexer.termSeparator = lunr.tokenizer.separator\n\nlunr.QueryLexer.lexText = function (lexer) {\n while (true) {\n var char = lexer.next()\n\n if (char == lunr.QueryLexer.EOS) {\n return lunr.QueryLexer.lexEOS\n }\n\n // Escape character is '\\'\n if (char.charCodeAt(0) == 92) {\n lexer.escapeCharacter()\n continue\n }\n\n if (char == \":\") {\n return lunr.QueryLexer.lexField\n }\n\n if (char == \"~\") {\n lexer.backup()\n if (lexer.width() > 0) {\n lexer.emit(lunr.QueryLexer.TERM)\n }\n return lunr.QueryLexer.lexEditDistance\n }\n\n if (char == \"^\") {\n lexer.backup()\n if (lexer.width() > 0) {\n lexer.emit(lunr.QueryLexer.TERM)\n }\n return lunr.QueryLexer.lexBoost\n }\n\n // \"+\" indicates term presence is required\n // checking for length to ensure that only\n // leading \"+\" are considered\n if (char == \"+\" && lexer.width() === 1) {\n lexer.emit(lunr.QueryLexer.PRESENCE)\n return lunr.QueryLexer.lexText\n }\n\n // \"-\" indicates term presence is prohibited\n // checking for length to ensure that only\n // leading \"-\" are considered\n if (char == \"-\" && lexer.width() === 1) {\n lexer.emit(lunr.QueryLexer.PRESENCE)\n return lunr.QueryLexer.lexText\n }\n\n if (char.match(lunr.QueryLexer.termSeparator)) {\n return lunr.QueryLexer.lexTerm\n }\n }\n}\n\nlunr.QueryParser = function (str, query) {\n this.lexer = new lunr.QueryLexer (str)\n this.query = query\n this.currentClause = {}\n this.lexemeIdx = 0\n}\n\nlunr.QueryParser.prototype.parse = function () {\n this.lexer.run()\n this.lexemes = this.lexer.lexemes\n\n var state = lunr.QueryParser.parseClause\n\n while (state) {\n state = state(this)\n }\n\n return this.query\n}\n\nlunr.QueryParser.prototype.peekLexeme = function () {\n return this.lexemes[this.lexemeIdx]\n}\n\nlunr.QueryParser.prototype.consumeLexeme = function () {\n var lexeme = this.peekLexeme()\n this.lexemeIdx += 1\n return lexeme\n}\n\nlunr.QueryParser.prototype.nextClause = function () {\n var completedClause = this.currentClause\n this.query.clause(completedClause)\n this.currentClause = {}\n}\n\nlunr.QueryParser.parseClause = function (parser) {\n var lexeme = parser.peekLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n switch (lexeme.type) {\n case lunr.QueryLexer.PRESENCE:\n return lunr.QueryParser.parsePresence\n case lunr.QueryLexer.FIELD:\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.TERM:\n return lunr.QueryParser.parseTerm\n default:\n var errorMessage = \"expected either a field or a term, found \" + lexeme.type\n\n if (lexeme.str.length >= 1) {\n errorMessage += \" with value '\" + lexeme.str + \"'\"\n }\n\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n}\n\nlunr.QueryParser.parsePresence = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n switch (lexeme.str) {\n case \"-\":\n parser.currentClause.presence = lunr.Query.presence.PROHIBITED\n break\n case \"+\":\n parser.currentClause.presence = lunr.Query.presence.REQUIRED\n break\n default:\n var errorMessage = \"unrecognised presence operator'\" + lexeme.str + \"'\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n var errorMessage = \"expecting term or field, found nothing\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.FIELD:\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.TERM:\n return lunr.QueryParser.parseTerm\n default:\n var errorMessage = \"expecting term or field, found '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseField = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n if (parser.query.allFields.indexOf(lexeme.str) == -1) {\n var possibleFields = parser.query.allFields.map(function (f) { return \"'\" + f + \"'\" }).join(', '),\n errorMessage = \"unrecognised field '\" + lexeme.str + \"', possible fields: \" + possibleFields\n\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n parser.currentClause.fields = [lexeme.str]\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n var errorMessage = \"expecting term, found nothing\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n return lunr.QueryParser.parseTerm\n default:\n var errorMessage = \"expecting term, found '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseTerm = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n parser.currentClause.term = lexeme.str.toLowerCase()\n\n if (lexeme.str.indexOf(\"*\") != -1) {\n parser.currentClause.usePipeline = false\n }\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n parser.nextClause()\n return\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n parser.nextClause()\n return lunr.QueryParser.parseTerm\n case lunr.QueryLexer.FIELD:\n parser.nextClause()\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.EDIT_DISTANCE:\n return lunr.QueryParser.parseEditDistance\n case lunr.QueryLexer.BOOST:\n return lunr.QueryParser.parseBoost\n case lunr.QueryLexer.PRESENCE:\n parser.nextClause()\n return lunr.QueryParser.parsePresence\n default:\n var errorMessage = \"Unexpected lexeme type '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseEditDistance = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n var editDistance = parseInt(lexeme.str, 10)\n\n if (isNaN(editDistance)) {\n var errorMessage = \"edit distance must be numeric\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n parser.currentClause.editDistance = editDistance\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n parser.nextClause()\n return\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n parser.nextClause()\n return lunr.QueryParser.parseTerm\n case lunr.QueryLexer.FIELD:\n parser.nextClause()\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.EDIT_DISTANCE:\n return lunr.QueryParser.parseEditDistance\n case lunr.QueryLexer.BOOST:\n return lunr.QueryParser.parseBoost\n case lunr.QueryLexer.PRESENCE:\n parser.nextClause()\n return lunr.QueryParser.parsePresence\n default:\n var errorMessage = \"Unexpected lexeme type '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\nlunr.QueryParser.parseBoost = function (parser) {\n var lexeme = parser.consumeLexeme()\n\n if (lexeme == undefined) {\n return\n }\n\n var boost = parseInt(lexeme.str, 10)\n\n if (isNaN(boost)) {\n var errorMessage = \"boost must be numeric\"\n throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)\n }\n\n parser.currentClause.boost = boost\n\n var nextLexeme = parser.peekLexeme()\n\n if (nextLexeme == undefined) {\n parser.nextClause()\n return\n }\n\n switch (nextLexeme.type) {\n case lunr.QueryLexer.TERM:\n parser.nextClause()\n return lunr.QueryParser.parseTerm\n case lunr.QueryLexer.FIELD:\n parser.nextClause()\n return lunr.QueryParser.parseField\n case lunr.QueryLexer.EDIT_DISTANCE:\n return lunr.QueryParser.parseEditDistance\n case lunr.QueryLexer.BOOST:\n return lunr.QueryParser.parseBoost\n case lunr.QueryLexer.PRESENCE:\n parser.nextClause()\n return lunr.QueryParser.parsePresence\n default:\n var errorMessage = \"Unexpected lexeme type '\" + nextLexeme.type + \"'\"\n throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)\n }\n}\n\n /**\n * export the module via AMD, CommonJS or as a browser global\n * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js\n */\n ;(function (root, factory) {\n if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define(factory)\n } else if (typeof exports === 'object') {\n /**\n * Node. Does not work with strict CommonJS, but\n * only CommonJS-like enviroments that support module.exports,\n * like Node.\n */\n module.exports = factory()\n } else {\n // Browser globals (root is window)\n root.lunr = factory()\n }\n }(this, function () {\n /**\n * Just return a value to define the module export.\n * This example returns an object, but the module\n * can return a function as the exported value.\n */\n return lunr\n }))\n})();\n","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport {\n ArticleDocument,\n SearchDocumentMap,\n SectionDocument,\n setupSearchDocumentMap\n} from \"../document\"\nimport {\n SearchHighlightFactoryFn,\n setupSearchHighlighter\n} from \"../highlighter\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search index configuration\n */\nexport interface SearchIndexConfig {\n lang: string[] /* Search languages */\n separator: string /* Search separator */\n}\n\n/**\n * Search index document\n */\nexport interface SearchIndexDocument {\n location: string /* Document location */\n title: string /* Document title */\n text: string /* Document text */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Search index pipeline function\n */\nexport type SearchIndexPipelineFn =\n | \"stemmer\" /* Stemmer */\n | \"stopWordFilter\" /* Stop word filter */\n | \"trimmer\" /* Trimmer */\n\n/**\n * Search index pipeline\n */\nexport type SearchIndexPipeline = SearchIndexPipelineFn[]\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Search index\n *\n * This interfaces describes the format of the `search_index.json` file which\n * is automatically built by the MkDocs search plugin.\n */\nexport interface SearchIndex {\n config: SearchIndexConfig /* Search index configuration */\n docs: SearchIndexDocument[] /* Search index documents */\n index?: object | string /* Prebuilt or serialized index */\n pipeline?: SearchIndexPipeline /* Search index pipeline */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Search result\n */\nexport interface SearchResult {\n article: ArticleDocument /* Article document */\n sections: SectionDocument[] /* Section documents */\n}\n\n/* ----------------------------------------------------------------------------\n * Class\n * ------------------------------------------------------------------------- */\n\n/**\n * Search\n *\n * Note that `lunr` is injected via Webpack, as it will otherwise also be\n * bundled in the application bundle.\n */\nexport class Search {\n\n /**\n * Search document mapping\n *\n * A mapping of URLs (including hash fragments) to the actual articles and\n * sections of the documentation. The search document mapping must be created\n * regardless of whether the index was prebuilt or not, as `lunr` itself will\n * only store the actual index.\n */\n protected documents: SearchDocumentMap\n\n /**\n * Search highlight factory function\n */\n protected highlight: SearchHighlightFactoryFn\n\n /**\n * The `lunr` search index\n */\n protected index: lunr.Index\n\n /**\n * Create the search integration\n *\n * @param data - Search index\n */\n public constructor({ config, docs, pipeline, index }: SearchIndex) {\n this.documents = setupSearchDocumentMap(docs)\n this.highlight = setupSearchHighlighter(config)\n\n /* If no index was given, create it */\n if (typeof index === \"undefined\") {\n this.index = lunr(function() {\n pipeline = pipeline || [\"trimmer\", \"stopWordFilter\"]\n\n /* Set up pipeline according to configuration */\n this.pipeline.reset()\n for (const fn of pipeline)\n this.pipeline.add(lunr[fn])\n\n /* Set up alternate search languages */\n if (config.lang.length === 1 && config.lang[0] !== \"en\") {\n this.use((lunr as any)[config.lang[0]])\n } else if (config.lang.length > 1) {\n this.use((lunr as any).multiLanguage(...config.lang))\n }\n\n /* Set up fields and reference */\n this.field(\"title\", { boost: 1000 })\n this.field(\"text\")\n this.ref(\"location\")\n\n /* Index documents */\n for (const doc of docs)\n this.add(doc)\n })\n\n /* Prebuilt or serialized index */\n } else {\n this.index = lunr.Index.load(\n typeof index === \"string\"\n ? JSON.parse(index)\n : index\n )\n }\n }\n\n /**\n * Search for matching documents\n *\n * The search index which MkDocs provides is divided up into articles, which\n * contain the whole content of the individual pages, and sections, which only\n * contain the contents of the subsections obtained by breaking the individual\n * pages up at `h1` ... `h6`. As there may be many sections on different pages\n * with identical titles (for example within this very project, e.g. \"Usage\"\n * or \"Installation\"), they need to be put into the context of the containing\n * page. For this reason, section results are grouped within their respective\n * articles which are the top-level results that are returned.\n *\n * @param value - Query value\n *\n * @return Search results\n */\n public query(value: string): SearchResult[] {\n if (value) {\n try {\n\n /* Group sections by containing article */\n const groups = this.index.search(value)\n .reduce((results, result) => {\n const document = this.documents.get(result.ref)\n if (typeof document !== \"undefined\") {\n if (\"parent\" in document) {\n const ref = document.parent.location\n results.set(ref, [...results.get(ref) || [], result])\n } else {\n const ref = document.location\n results.set(ref, results.get(ref) || [])\n }\n }\n return results\n }, new Map())\n\n /* Create highlighter for query */\n const fn = this.highlight(value)\n\n /* Map groups to search documents */\n return [...groups].map(([ref, sections]) => ({\n article: fn(this.documents.get(ref) as ArticleDocument),\n sections: sections.map(section => {\n return fn(this.documents.get(section.ref) as SectionDocument)\n })\n }))\n\n /* Log errors to console (for now) */\n } catch (err) {\n // tslint:disable-next-line no-console\n console.warn(`Invalid query: ${value} – see https://bit.ly/2s3ChXG`)\n }\n }\n\n /* Return nothing in case of error or empty query */\n return []\n }\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A RTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { SearchIndex, SearchResult } from \"../../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search message type\n */\nexport const enum SearchMessageType {\n SETUP, /* Search index setup */\n READY, /* Search index ready */\n QUERY, /* Search query */\n RESULT /* Search results */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * A message containing the data necessary to setup the search index\n */\nexport interface SearchSetupMessage {\n type: SearchMessageType.SETUP /* Message type */\n data: SearchIndex /* Message data */\n}\n\n/**\n * A message indicating the search index is ready\n */\nexport interface SearchReadyMessage {\n type: SearchMessageType.READY /* Message type */\n}\n\n/**\n * A message containing a search query\n */\nexport interface SearchQueryMessage {\n type: SearchMessageType.QUERY /* Message type */\n data: string /* Message data */\n}\n\n/**\n * A message containing results for a search query\n */\nexport interface SearchResultMessage {\n type: SearchMessageType.RESULT /* Message type */\n data: SearchResult[] /* Message data */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * A message exchanged with the search worker\n */\nexport type SearchMessage =\n | SearchSetupMessage\n | SearchReadyMessage\n | SearchQueryMessage\n | SearchResultMessage\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Type guard for search setup messages\n *\n * @param message - Search worker message\n *\n * @return Test result\n */\nexport function isSearchSetupMessage(\n message: SearchMessage\n): message is SearchSetupMessage {\n return message.type === SearchMessageType.SETUP\n}\n\n/**\n * Type guard for search ready messages\n *\n * @param message - Search worker message\n *\n * @return Test result\n */\nexport function isSearchReadyMessage(\n message: SearchMessage\n): message is SearchReadyMessage {\n return message.type === SearchMessageType.READY\n}\n\n/**\n * Type guard for search query messages\n *\n * @param message - Search worker message\n *\n * @return Test result\n */\nexport function isSearchQueryMessage(\n message: SearchMessage\n): message is SearchQueryMessage {\n return message.type === SearchMessageType.QUERY\n}\n\n/**\n * Type guard for search result messages\n *\n * @param message - Search worker message\n *\n * @return Test result\n */\nexport function isSearchResultMessage(\n message: SearchMessage\n): message is SearchResultMessage {\n return message.type === SearchMessageType.RESULT\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A RTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport \"expose-loader?lunr!lunr\"\n\nimport { Search, SearchIndexConfig } from \"../../_\"\nimport { SearchMessage, SearchMessageType } from \"../message\"\n\n/* ----------------------------------------------------------------------------\n * Data\n * ------------------------------------------------------------------------- */\n\n/**\n * Search\n */\nlet search: Search\n\n/* ----------------------------------------------------------------------------\n * Helper functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Set up multi-language support through `lunr-languages`\n *\n * This function will automatically import the stemmers necessary to process\n * the languages which were given through the search index configuration.\n *\n * @param config - Search index configuration\n */\nfunction setupLunrLanguages(config: SearchIndexConfig): void {\n const base = \"../lunr\"\n\n /* Add scripts for languages */\n const scripts = []\n for (const lang of config.lang) {\n if (lang === \"ja\") scripts.push(`${base}/tinyseg.min.js`)\n if (lang !== \"en\") scripts.push(`${base}/min/lunr.${lang}.min.js`)\n }\n\n /* Add multi-language support */\n if (config.lang.length > 1)\n scripts.push(`${base}/min/lunr.multi.min.js`)\n\n /* Load scripts synchronously */\n if (scripts.length)\n importScripts(\n `${base}/min/lunr.stemmer.support.min.js`,\n ...scripts\n )\n}\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Message handler\n *\n * @param message - Source message\n *\n * @return Target message\n */\nexport function handler(message: SearchMessage): SearchMessage {\n switch (message.type) {\n\n /* Search setup message */\n case SearchMessageType.SETUP:\n setupLunrLanguages(message.data.config)\n search = new Search(message.data)\n return {\n type: SearchMessageType.READY\n }\n\n /* Search query message */\n case SearchMessageType.QUERY:\n return {\n type: SearchMessageType.RESULT,\n data: search ? search.query(message.data) : []\n }\n\n /* All other messages */\n default:\n throw new TypeError(\"Invalid message type\")\n }\n}\n\n/* ----------------------------------------------------------------------------\n * Worker\n * ------------------------------------------------------------------------- */\n\naddEventListener(\"message\", ev => {\n postMessage(handler(ev.data))\n})\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport * as escapeHTML from \"escape-html\"\n\nimport { SearchIndexDocument } from \"../_\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * A top-level article\n */\nexport interface ArticleDocument extends SearchIndexDocument {\n linked: boolean /* Whether the section was linked */\n}\n\n/**\n * A section of an article\n */\nexport interface SectionDocument extends SearchIndexDocument {\n parent: ArticleDocument /* Parent article */\n}\n\n/* ------------------------------------------------------------------------- */\n\n/**\n * Search document\n */\nexport type SearchDocument =\n | ArticleDocument\n | SectionDocument\n\n/**\n * Search document mapping\n */\nexport type SearchDocumentMap = Map\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Create a search document mapping\n *\n * @param docs - Search index documents\n *\n * @return Search document map\n */\nexport function setupSearchDocumentMap(\n docs: SearchIndexDocument[]\n): SearchDocumentMap {\n const documents = new Map()\n for (const doc of docs) {\n const [path, hash] = doc.location.split(\"#\")\n\n /* Extract location and title */\n const location = doc.location\n const title = doc.title\n\n /* Escape and cleanup text */\n const text = escapeHTML(doc.text)\n .replace(/\\s+(?=[,.:;!?])/g, \"\")\n .replace(/\\s+/g, \" \")\n\n /* Handle section */\n if (hash) {\n const parent = documents.get(path) as ArticleDocument\n\n /* Ignore first section, override article */\n if (!parent.linked) {\n parent.title = doc.title\n parent.text = text\n parent.linked = true\n\n /* Add subsequent section */\n } else {\n documents.set(location, {\n location,\n title,\n text,\n parent\n })\n }\n\n /* Add article */\n } else {\n documents.set(location, {\n location,\n title,\n text,\n linked: false\n })\n }\n }\n return documents\n}\n","/*\n * Copyright (c) 2016-2020 Martin Donath \n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\nimport { SearchIndexConfig } from \"../_\"\nimport { SearchDocument } from \"../document\"\n\n/* ----------------------------------------------------------------------------\n * Types\n * ------------------------------------------------------------------------- */\n\n/**\n * Search highlight function\n *\n * @template T - Search document type\n *\n * @param document - Search document\n *\n * @return Highlighted document\n */\nexport type SearchHighlightFn = <\n T extends SearchDocument\n>(document: Readonly) => T\n\n/**\n * Search highlight factory function\n *\n * @param value - Query value\n *\n * @return Search highlight function\n */\nexport type SearchHighlightFactoryFn = (value: string) => SearchHighlightFn\n\n/* ----------------------------------------------------------------------------\n * Functions\n * ------------------------------------------------------------------------- */\n\n/**\n * Create a search highlighter\n *\n * @param config - Search index configuration\n *\n * @return Search highlight factory function\n */\nexport function setupSearchHighlighter(\n config: SearchIndexConfig\n): SearchHighlightFactoryFn {\n const separator = new RegExp(config.separator, \"img\")\n const highlight = (_: unknown, data: string, term: string) => {\n return `${data}${term}`\n }\n\n /* Return factory function */\n return (value: string) => {\n value = value\n .replace(/[\\s*+-:~^]+/g, \" \")\n .trim()\n\n /* Create search term match expression */\n const match = new RegExp(`(^|${config.separator})(${\n value\n .replace(/[|\\\\{}()[\\]^$+*?.-]/g, \"\\\\$&\")\n .replace(separator, \"|\")\n })`, \"img\")\n\n /* Highlight document */\n return document => ({\n ...document,\n title: document.title.replace(match, highlight),\n text: document.text.replace(match, highlight)\n })\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/docs/assets/stylesheets/main.a676eddb.min.css b/docs/assets/stylesheets/main.a676eddb.min.css new file mode 100644 index 0000000..280ee99 --- /dev/null +++ b/docs/assets/stylesheets/main.a676eddb.min.css @@ -0,0 +1,3 @@ +html{box-sizing:border-box}*,*::before,*::after{box-sizing:inherit}html{-webkit-text-size-adjust:none;-moz-text-size-adjust:none;-ms-text-size-adjust:none;text-size-adjust:none}body{margin:0}hr{box-sizing:content-box;overflow:visible}a,button,label,input{-webkit-tap-highlight-color:transparent}a{color:inherit;text-decoration:none}small{font-size:80%}sub,sup{position:relative;font-size:80%;line-height:0;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}table{border-collapse:separate;border-spacing:0}td,th{font-weight:normal;vertical-align:top}button{margin:0;padding:0;font-size:inherit;background:transparent;border:0}input{border:0;outline:0}:root{--md-default-fg-color: hsla(0, 0%, 0%, 0.87);--md-default-fg-color--light: hsla(0, 0%, 0%, 0.54);--md-default-fg-color--lighter: hsla(0, 0%, 0%, 0.26);--md-default-fg-color--lightest: hsla(0, 0%, 0%, 0.07);--md-default-bg-color: hsla(0, 0%, 100%, 1);--md-default-bg-color--light: hsla(0, 0%, 100%, 0.7);--md-default-bg-color--lighter: hsla(0, 0%, 100%, 0.3);--md-default-bg-color--lightest: hsla(0, 0%, 100%, 0.12);--md-primary-fg-color: hsla(231deg, 48%, 48%, 1);--md-primary-fg-color--light: hsla(230deg, 44%, 64%, 1);--md-primary-fg-color--dark: hsla(232deg, 54%, 41%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light);--md-accent-fg-color: hsla(231deg, 99%, 66%, 1);--md-accent-fg-color--transparent: hsla(231deg, 99%, 66%, 0.1);--md-accent-bg-color: var(--md-default-bg-color);--md-accent-bg-color--light: var(--md-default-bg-color--light);--md-code-bg-color: hsla(0, 0%, 96%, 1);--md-code-fg-color: hsla(200, 18%, 26%, 1)}.md-icon svg{display:block;width:1.2rem;height:1.2rem;margin:0 auto;fill:currentColor}body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}body,input{color:var(--md-default-fg-color);-webkit-font-feature-settings:"kern","liga";font-feature-settings:"kern","liga";font-family:-apple-system,BlinkMacSystemFont,Helvetica,Arial,sans-serif}code,pre,kbd{color:var(--md-default-fg-color);-webkit-font-feature-settings:"kern";font-feature-settings:"kern";font-family:SFMono-Regular,Consolas,Menlo,monospace}.md-typeset{font-size:.8rem;line-height:1.6;-webkit-print-color-adjust:exact;color-adjust:exact}.md-typeset p,.md-typeset ul,.md-typeset ol,.md-typeset blockquote{margin:1em 0}.md-typeset h1{margin:0 0 2rem;color:var(--md-default-fg-color--light);font-weight:300;font-size:1.5625rem;line-height:1.3;letter-spacing:-0.01em}.md-typeset h2{margin:2rem 0 .8rem;font-weight:300;font-size:1.25rem;line-height:1.4;letter-spacing:-0.01em}.md-typeset h3{margin:1.6rem 0 .8rem;font-weight:400;font-size:1rem;line-height:1.5;letter-spacing:-0.01em}.md-typeset h2+h3{margin-top:.8rem}.md-typeset h4{margin:.8rem 0;font-weight:700;font-size:.8rem;letter-spacing:-0.01em}.md-typeset h5,.md-typeset h6{margin:.8rem 0;color:var(--md-default-fg-color--light);font-weight:700;font-size:.64rem;letter-spacing:-0.01em}.md-typeset h5{text-transform:uppercase}.md-typeset hr{margin:1.5em 0;border-bottom:.05rem dotted var(--md-default-fg-color--lighter)}.md-typeset a{color:var(--md-primary-fg-color);word-break:break-word}.md-typeset a,.md-typeset a::before{transition:color 125ms}.md-typeset a:focus,.md-typeset a:hover{color:var(--md-accent-fg-color)}.md-typeset code,.md-typeset pre,.md-typeset kbd{color:var(--md-code-fg-color);direction:ltr}.md-typeset code{padding:0 .2941176471em;font-size:.85em;word-break:break-word;background-color:var(--md-code-bg-color);border-radius:.1rem;-webkit-box-decoration-break:clone;box-decoration-break:clone}.md-typeset h1 code,.md-typeset h2 code,.md-typeset h3 code,.md-typeset h4 code,.md-typeset h5 code,.md-typeset h6 code{margin:initial;padding:initial;background-color:transparent;box-shadow:none}.md-typeset a>code{color:currentColor}.md-typeset pre{position:relative;margin:1em 0;line-height:1.4}.md-typeset pre>code{display:block;margin:0;padding:.525rem 1.1764705882em;overflow:auto;word-break:normal;box-shadow:none;-webkit-box-decoration-break:slice;box-decoration-break:slice;touch-action:auto}.md-typeset pre>code::-webkit-scrollbar{width:.2rem;height:.2rem}.md-typeset pre>code::-webkit-scrollbar-thumb{background-color:var(--md-default-fg-color--lighter)}.md-typeset pre>code::-webkit-scrollbar-thumb:hover{background-color:var(--md-accent-fg-color)}.md-typeset kbd{display:inline-block;padding:0 .6666666667em;font-size:.75em;line-height:1.5;vertical-align:text-top;word-break:break-word;border-radius:.1rem;box-shadow:0 .1rem 0 .05rem var(--md-default-fg-color--lighter),0 .1rem 0 var(--md-default-fg-color--lighter),inset 0 -0.1rem .2rem var(--md-default-bg-color)}.md-typeset mark{padding:0 .25em;word-break:break-word;background-color:rgba(255,235,59,.5);border-radius:.1rem;-webkit-box-decoration-break:clone;box-decoration-break:clone}.md-typeset abbr{text-decoration:none;border-bottom:.05rem dotted var(--md-default-fg-color--light);cursor:help}.md-typeset small{opacity:.75}.md-typeset sup,.md-typeset sub{margin-left:.078125em}[dir=rtl] .md-typeset sup,[dir=rtl] .md-typeset sub{margin-right:.078125em;margin-left:initial}.md-typeset blockquote{padding-left:.6rem;color:var(--md-default-fg-color--light);border-left:.2rem solid var(--md-default-fg-color--lighter)}[dir=rtl] .md-typeset blockquote{padding-right:.6rem;padding-left:initial;border-right:.2rem solid var(--md-default-fg-color--lighter);border-left:initial}.md-typeset ul{list-style-type:disc}.md-typeset ul,.md-typeset ol{margin-left:.625em;padding:0}[dir=rtl] .md-typeset ul,[dir=rtl] .md-typeset ol{margin-right:.625em;margin-left:initial}.md-typeset ul ol,.md-typeset ol ol{list-style-type:lower-alpha}.md-typeset ul ol ol,.md-typeset ol ol ol{list-style-type:lower-roman}.md-typeset ul li,.md-typeset ol li{margin-bottom:.5em;margin-left:1.25em}[dir=rtl] .md-typeset ul li,[dir=rtl] .md-typeset ol li{margin-right:1.25em;margin-left:initial}.md-typeset ul li p,.md-typeset ul li blockquote,.md-typeset ol li p,.md-typeset ol li blockquote{margin:.5em 0}.md-typeset ul li:last-child,.md-typeset ol li:last-child{margin-bottom:0}.md-typeset ul li ul,.md-typeset ul li ol,.md-typeset ol li ul,.md-typeset ol li ol{margin:.5em 0 .5em .625em}[dir=rtl] .md-typeset ul li ul,[dir=rtl] .md-typeset ul li ol,[dir=rtl] .md-typeset ol li ul,[dir=rtl] .md-typeset ol li ol{margin-right:.625em;margin-left:initial}.md-typeset dd{margin:1em 0 1em 1.875em}[dir=rtl] .md-typeset dd{margin-right:1.875em;margin-left:initial}.md-typeset iframe,.md-typeset img,.md-typeset svg{max-width:100%}.md-typeset table:not([class]){display:inline-block;max-width:100%;overflow:auto;font-size:.64rem;background:var(--md-default-bg-color);border-radius:.1rem;box-shadow:0 .2rem .5rem rgba(0,0,0,.05),0 0 .05rem rgba(0,0,0,.1);touch-action:auto}.md-typeset table:not([class])+*{margin-top:1.5em}.md-typeset table:not([class]) th:not([align]),.md-typeset table:not([class]) td:not([align]){text-align:left}[dir=rtl] .md-typeset table:not([class]) th:not([align]),[dir=rtl] .md-typeset table:not([class]) td:not([align]){text-align:right}.md-typeset table:not([class]) th{min-width:5rem;padding:.6rem .8rem;color:var(--md-default-bg-color);vertical-align:top;background-color:var(--md-default-fg-color--light)}.md-typeset table:not([class]) td{padding:.6rem .8rem;vertical-align:top;border-top:.05rem solid var(--md-default-fg-color--lightest)}.md-typeset table:not([class]) tr{transition:background-color 125ms}.md-typeset table:not([class]) tr:hover{background-color:rgba(0,0,0,.035);box-shadow:0 .05rem 0 var(--md-default-bg-color) inset}.md-typeset table:not([class]) tr:first-child td{border-top:0}.md-typeset table:not([class]) a{word-break:normal}.md-typeset__scrollwrap{margin:1em -0.8rem;overflow-x:auto;touch-action:auto}.md-typeset__table{display:inline-block;margin-bottom:.5em;padding:0 .8rem}.md-typeset__table table{display:table;width:100%;margin:0;overflow:hidden}html{height:100%;overflow-x:hidden;font-size:125%;background-color:var(--md-default-bg-color)}body{position:relative;display:flex;flex-direction:column;width:100%;min-height:100%;font-size:.5rem}hr{display:block;height:.05rem;padding:0;border:0}.md-grid{max-width:61rem;margin-right:auto;margin-left:auto}.md-container{display:flex;flex-direction:column;flex-grow:1}.md-main{flex-grow:1}.md-main__inner{height:100%;margin-top:1.5rem}.md-ellipsis{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.md-toggle{display:none}.md-overlay{position:fixed;top:0;z-index:3;width:0;height:0;background-color:var(--md-default-fg-color--light);opacity:0;transition:width 0ms 250ms,height 0ms 250ms,opacity 250ms}.md-skip{position:fixed;z-index:-1;margin:.5rem;padding:.3rem .5rem;color:var(--md-default-bg-color);font-size:.64rem;background-color:var(--md-default-fg-color);border-radius:.1rem;transform:translateY(0.4rem);opacity:0}.md-skip:focus{z-index:10;transform:translateY(0);opacity:1;transition:transform 250ms cubic-bezier(0.4, 0, 0.2, 1),opacity 175ms 75ms}@page{margin:25mm}.md-announce{overflow:auto;background-color:var(--md-default-fg-color)}.md-announce__inner{margin:.6rem auto;padding:0 .8rem;color:var(--md-default-bg-color);font-size:.7rem}.md-typeset .md-button{display:inline-block;padding:.625em 2em;color:var(--md-primary-fg-color);font-weight:700;border:.1rem solid currentColor;border-radius:.1rem;transition:color 125ms,background-color 125ms,border-color 125ms}.md-typeset .md-button--primary{color:var(--md-primary-bg-color);background-color:var(--md-primary-fg-color);border-color:var(--md-primary-fg-color)}.md-typeset .md-button:focus,.md-typeset .md-button:hover{color:var(--md-accent-bg-color);background-color:var(--md-accent-fg-color);border-color:var(--md-accent-fg-color)}.md-clipboard{position:absolute;top:.4rem;right:.5em;z-index:1;width:1.5em;height:1.5em;color:var(--md-default-fg-color--lightest);border-radius:.1rem;cursor:pointer;transition:color 125ms}.md-clipboard svg{width:1.125em;height:1.125em}pre:hover .md-clipboard{color:var(--md-default-fg-color--light)}pre .md-clipboard:focus,pre .md-clipboard:hover{color:var(--md-accent-fg-color)}.md-content__inner{margin:0 .8rem 1.2rem;padding-top:.6rem}.md-content__inner::before{display:block;height:.4rem;content:""}.md-content__inner>:last-child{margin-bottom:0}.md-content__button{float:right;margin:.4rem 0;margin-left:.4rem;padding:0}[dir=rtl] .md-content__button{float:left;margin-right:.4rem;margin-left:initial}[dir=rtl] .md-content__button svg{transform:scaleX(-1)}.md-typeset .md-content__button{color:var(--md-default-fg-color--lighter)}.md-content__button svg{display:inline;vertical-align:top}.md-dialog{box-shadow:0 2px 2px 0 rgba(0,0,0,.14),0 1px 5px 0 rgba(0,0,0,.12),0 3px 1px -2px rgba(0,0,0,.2);position:fixed;right:.8rem;bottom:.8rem;left:initial;z-index:2;display:block;min-width:11.1rem;padding:.4rem .6rem;color:var(--md-default-bg-color);font-size:.7rem;background:var(--md-default-fg-color);border:none;border-radius:.1rem;transform:translateY(100%);opacity:0;transition:transform 0ms 400ms,opacity 400ms}[dir=rtl] .md-dialog{right:initial;left:.8rem}.md-dialog[data-md-state=open]{transform:translateY(0);opacity:1;transition:transform 400ms cubic-bezier(0.075, 0.85, 0.175, 1),opacity 400ms}.md-header{position:-webkit-sticky;position:sticky;top:0;right:0;left:0;z-index:2;height:2.4rem;color:var(--md-primary-bg-color);background-color:var(--md-primary-fg-color);box-shadow:0 0 .2rem rgba(0,0,0,0),0 .2rem .4rem rgba(0,0,0,0);transition:color 250ms,background-color 250ms}.no-js .md-header{box-shadow:none;transition:none}.md-header[data-md-state=shadow]{box-shadow:0 0 .2rem rgba(0,0,0,.1),0 .2rem .4rem rgba(0,0,0,.2);transition:color 250ms,background-color 250ms,box-shadow 250ms}.md-header-nav{display:flex;padding:0 .2rem}.md-header-nav__button{position:relative;z-index:1;margin:.2rem;padding:.4rem;cursor:pointer;transition:opacity 250ms}[dir=rtl] .md-header-nav__button svg{transform:scaleX(-1)}.md-header-nav__button:focus,.md-header-nav__button:hover{opacity:.7}.md-header-nav__button.md-logo{margin:.2rem;padding:.4rem}.md-header-nav__button.md-logo img,.md-header-nav__button.md-logo svg{display:block;width:1.2rem;height:1.2rem;fill:currentColor}.no-js .md-header-nav__button[for=__search]{display:none}.md-header-nav__topic{position:absolute;width:100%;transition:transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),opacity 150ms}.md-header-nav__topic+.md-header-nav__topic{z-index:-1;transform:translateX(1.25rem);opacity:0;transition:transform 400ms cubic-bezier(1, 0.7, 0.1, 0.1),opacity 150ms;pointer-events:none}[dir=rtl] .md-header-nav__topic+.md-header-nav__topic{transform:translateX(-1.25rem)}.no-js .md-header-nav__topic{position:initial}.no-js .md-header-nav__topic+.md-header-nav__topic{display:none}.md-header-nav__title{flex-grow:1;padding:0 1rem;font-size:.9rem;line-height:2.4rem}.md-header-nav__title[data-md-state=active] .md-header-nav__topic{z-index:-1;transform:translateX(-1.25rem);opacity:0;transition:transform 400ms cubic-bezier(1, 0.7, 0.1, 0.1),opacity 150ms;pointer-events:none}[dir=rtl] .md-header-nav__title[data-md-state=active] .md-header-nav__topic{transform:translateX(1.25rem)}.md-header-nav__title[data-md-state=active] .md-header-nav__topic+.md-header-nav__topic{z-index:0;transform:translateX(0);opacity:1;transition:transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),opacity 150ms;pointer-events:initial}.md-header-nav__title>.md-header-nav__ellipsis{position:relative;width:100%;height:100%}.md-header-nav__source{display:none}.md-hero{overflow:hidden;color:var(--md-primary-bg-color);font-size:1rem;background-color:var(--md-primary-fg-color);transition:background 250ms}.md-hero__inner{margin-top:1rem;padding:.8rem .8rem .4rem;transition:transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),opacity 250ms;transition-delay:100ms}[data-md-state=hidden] .md-hero__inner{transform:translateY(0.625rem);opacity:0;transition:transform 0ms 400ms,opacity 100ms 0ms;pointer-events:none}.md-hero--expand .md-hero__inner{margin-bottom:1.2rem}.md-footer{color:var(--md-default-bg-color);background-color:var(--md-default-fg-color)}.md-footer-nav__inner{padding:.2rem;overflow:auto}.md-footer-nav__link{display:flex;padding-top:1.4rem;padding-bottom:.4rem;transition:opacity 250ms}.md-footer-nav__link:focus,.md-footer-nav__link:hover{opacity:.7}.md-footer-nav__link--prev{float:left;width:25%}[dir=rtl] .md-footer-nav__link--prev{float:right}[dir=rtl] .md-footer-nav__link--prev svg{transform:scaleX(-1)}.md-footer-nav__link--next{float:right;width:75%;text-align:right}[dir=rtl] .md-footer-nav__link--next{float:left;text-align:left}[dir=rtl] .md-footer-nav__link--next svg{transform:scaleX(-1)}.md-footer-nav__title{position:relative;flex-grow:1;max-width:calc(100% - 2.4rem);padding:0 1rem;font-size:.9rem;line-height:2.4rem}.md-footer-nav__button{margin:.2rem;padding:.4rem}.md-footer-nav__direction{position:absolute;right:0;left:0;margin-top:-1rem;padding:0 1rem;color:var(--md-default-bg-color--light);font-size:.64rem}.md-footer-meta{background-color:var(--md-default-fg-color--lighter)}.md-footer-meta__inner{display:flex;flex-wrap:wrap;justify-content:space-between;padding:.2rem}html .md-footer-meta.md-typeset a{color:var(--md-default-bg-color--light)}html .md-footer-meta.md-typeset a:focus,html .md-footer-meta.md-typeset a:hover{color:var(--md-default-bg-color)}.md-footer-copyright{width:100%;margin:auto .6rem;padding:.4rem 0;color:var(--md-default-bg-color--lighter);font-size:.64rem}.md-footer-copyright__highlight{color:var(--md-default-bg-color--light)}.md-footer-social{margin:0 .4rem;padding:.2rem 0 .6rem}.md-footer-social__link{display:inline-block;width:1.6rem;height:1.6rem;text-align:center}.md-footer-social__link::before{line-height:1.9}.md-footer-social__link svg{max-height:.8rem;vertical-align:-25%;fill:currentColor}.md-nav{font-size:.7rem;line-height:1.3}.md-nav__title{display:block;padding:0 .6rem;overflow:hidden;font-weight:700;text-overflow:ellipsis}.md-nav__title .md-nav__button{display:none}.md-nav__title .md-nav__button img{width:100%;height:auto}.md-nav__title .md-nav__button.md-logo img,.md-nav__title .md-nav__button.md-logo svg{display:block;width:2.4rem;height:2.4rem}.md-nav__title .md-nav__button.md-logo svg{fill:currentColor}.md-nav__list{margin:0;padding:0;list-style:none}.md-nav__item{padding:0 .6rem}.md-nav__item:last-child{padding-bottom:.6rem}.md-nav__item .md-nav__item{padding-right:0}[dir=rtl] .md-nav__item .md-nav__item{padding-right:.6rem;padding-left:0}.md-nav__item .md-nav__item:last-child{padding-bottom:0}.md-nav__link{display:block;margin-top:.625em;overflow:hidden;text-overflow:ellipsis;cursor:pointer;transition:color 125ms;scroll-snap-align:start}html .md-nav__link[for=__toc]{display:none}html .md-nav__link[for=__toc]~.md-nav{display:none}.md-nav__link[data-md-state=blur]{color:var(--md-default-fg-color--light)}.md-nav__item .md-nav__link--active{color:var(--md-primary-fg-color)}.md-nav__item--nested>.md-nav__link{color:inherit}.md-nav__link:focus,.md-nav__link:hover{color:var(--md-accent-fg-color)}.md-nav__source{display:none}.md-search{position:relative}.no-js .md-search{display:none}.md-search__overlay{z-index:1;opacity:0}.md-search__inner{-webkit-backface-visibility:hidden;backface-visibility:hidden}.md-search__form{position:relative}.md-search__input{position:relative;z-index:2;padding:0 2.2rem 0 3.6rem;text-overflow:ellipsis}[dir=rtl] .md-search__input{padding:0 3.6rem 0 2.2rem}.md-search__input::-webkit-input-placeholder{-webkit-transition:color 250ms;transition:color 250ms}.md-search__input::-moz-placeholder{-moz-transition:color 250ms;transition:color 250ms}.md-search__input::-ms-input-placeholder{-ms-transition:color 250ms;transition:color 250ms}.md-search__input::placeholder{transition:color 250ms}.md-search__input::-webkit-input-placeholder{color:var(--md-default-fg-color--light)}.md-search__input::-moz-placeholder{color:var(--md-default-fg-color--light)}.md-search__input::-ms-input-placeholder{color:var(--md-default-fg-color--light)}.md-search__input~.md-search__icon,.md-search__input::placeholder{color:var(--md-default-fg-color--light)}.md-search__input::-ms-clear{display:none}.md-search__icon{position:absolute;z-index:2;width:1.2rem;height:1.2rem;cursor:pointer;transition:color 250ms,opacity 250ms}.md-search__icon:hover{opacity:.7}.md-search__icon[for=__search]{top:.3rem;left:.5rem}[dir=rtl] .md-search__icon[for=__search]{right:.5rem;left:initial}[dir=rtl] .md-search__icon[for=__search] svg{transform:scaleX(-1)}.md-search__icon[type=reset]{top:.3rem;right:.5rem;transform:scale(0.75);opacity:0;transition:transform 150ms cubic-bezier(0.1, 0.7, 0.1, 1),opacity 150ms;pointer-events:none}[dir=rtl] .md-search__icon[type=reset]{right:initial;left:.5rem}[data-md-toggle=search]:checked~.md-header .md-search__input:not(:placeholder-shown)~.md-search__icon[type=reset]{transform:scale(1);opacity:1;pointer-events:initial}[data-md-toggle=search]:checked~.md-header .md-search__input:not(:placeholder-shown)~.md-search__icon[type=reset]:hover{opacity:.7}.md-search__output{position:absolute;z-index:1;width:100%;overflow:hidden;border-radius:0 0 .1rem .1rem}.md-search__scrollwrap{height:100%;overflow-y:auto;background-color:var(--md-default-bg-color);box-shadow:inset 0 .05rem 0 var(--md-default-fg-color--lightest);-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-scroll-snap-type:y mandatory;-ms-scroll-snap-type:y mandatory;scroll-snap-type:y mandatory;touch-action:pan-y}.md-search-result{color:var(--md-default-fg-color);word-break:break-word}.md-search-result__meta{padding:0 .8rem;color:var(--md-default-fg-color--light);font-size:.64rem;line-height:1.8rem;background-color:var(--md-default-fg-color--lightest);scroll-snap-align:start}.md-search-result__list{margin:0;padding:0;list-style:none;border-top:.05rem solid var(--md-default-fg-color--lightest)}.md-search-result__item{box-shadow:0 -0.05rem 0 var(--md-default-fg-color--lightest)}.md-search-result__link{display:block;outline:0;transition:background 250ms;scroll-snap-align:start}.md-search-result__link:focus,.md-search-result__link:hover{background-color:var(--md-accent-fg-color--transparent)}.md-search-result__link:focus .md-search-result__article::before,.md-search-result__link:hover .md-search-result__article::before{opacity:.7}.md-search-result__link:last-child .md-search-result__teaser{margin-bottom:.6rem}.md-search-result__article{position:relative;padding:0 .8rem;overflow:auto}.md-search-result__article--document .md-search-result__title{margin:.55rem 0;font-weight:400;font-size:.8rem;line-height:1.4}.md-search-result__icon{position:absolute;left:0;margin:.1rem;padding:.4rem;color:var(--md-default-fg-color--light)}[dir=rtl] .md-search-result__icon{right:0;left:initial}[dir=rtl] .md-search-result__icon svg{transform:scaleX(-1)}.md-search-result__title{margin:.5em 0;font-weight:700;font-size:.64rem;line-height:1.4}.md-search-result__teaser{display:-webkit-box;max-height:1.65rem;margin:.5em 0;overflow:hidden;color:var(--md-default-fg-color--light);font-size:.64rem;line-height:1.4;text-overflow:ellipsis;-webkit-box-orient:vertical;-webkit-line-clamp:2}.md-search-result em{font-weight:700;font-style:normal;text-decoration:underline}.md-sidebar{position:absolute;width:12.1rem;padding:1.2rem 0;overflow:hidden}.md-sidebar[data-md-state=lock]{position:fixed;top:2.4rem}.md-sidebar--secondary{display:none}.md-sidebar__scrollwrap{max-height:100%;margin:0 .2rem;overflow-y:auto;-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-scroll-snap-type:y mandatory;-ms-scroll-snap-type:y mandatory;scroll-snap-type:y mandatory}.md-sidebar__scrollwrap::-webkit-scrollbar{width:.2rem;height:.2rem}.md-sidebar__scrollwrap::-webkit-scrollbar-thumb{background-color:var(--md-default-fg-color--lighter)}.md-sidebar__scrollwrap::-webkit-scrollbar-thumb:hover{background-color:var(--md-accent-fg-color)}@-webkit-keyframes md-source__facts--done{0%{height:0}100%{height:.65rem}}@keyframes md-source__facts--done{0%{height:0}100%{height:.65rem}}@-webkit-keyframes md-source__fact--done{0%{transform:translateY(100%);opacity:0}50%{opacity:0}100%{transform:translateY(0%);opacity:1}}@keyframes md-source__fact--done{0%{transform:translateY(100%);opacity:0}50%{opacity:0}100%{transform:translateY(0%);opacity:1}}.md-source{display:block;font-size:.65rem;line-height:1.2;white-space:nowrap;-webkit-backface-visibility:hidden;backface-visibility:hidden;transition:opacity 250ms}.md-source:hover{opacity:.7}.md-source__icon{display:inline-block;width:2.4rem;height:2.4rem;vertical-align:middle}.md-source__icon svg{margin-top:.6rem;margin-left:.6rem}[dir=rtl] .md-source__icon svg{margin-right:.6rem;margin-left:initial}.md-source__icon+.md-source__repository{margin-left:-2rem;padding-left:2rem}[dir=rtl] .md-source__icon+.md-source__repository{margin-right:-2rem;margin-left:initial;padding-right:2rem;padding-left:initial}.md-source__repository{display:inline-block;max-width:calc(100% - 1.2rem);margin-left:.6rem;overflow:hidden;font-weight:700;text-overflow:ellipsis;vertical-align:middle}.md-source__facts{margin:0;padding:0;overflow:hidden;font-weight:700;font-size:.55rem;list-style-type:none;opacity:.75}[data-md-state=done] .md-source__facts{-webkit-animation:md-source__facts--done 250ms ease-in;animation:md-source__facts--done 250ms ease-in}.md-source__fact{float:left}[dir=rtl] .md-source__fact{float:right}[data-md-state=done] .md-source__fact{-webkit-animation:md-source__fact--done 400ms ease-out;animation:md-source__fact--done 400ms ease-out}.md-source__fact::before{margin:0 .1rem;content:"·"}.md-source__fact:first-child::before{display:none}.md-tabs{width:100%;overflow:auto;color:var(--md-primary-bg-color);background-color:var(--md-primary-fg-color);transition:background 250ms}.no-js .md-tabs{transition:none}.md-tabs__list{margin:0;margin-left:.2rem;padding:0;white-space:nowrap;list-style:none;contain:content}[dir=rtl] .md-tabs__list{margin-right:.2rem;margin-left:initial}.md-tabs__item{display:inline-block;height:2.4rem;padding-right:.6rem;padding-left:.6rem}.md-tabs__link{display:block;margin-top:.8rem;font-size:.7rem;opacity:.7;transition:transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),opacity 250ms}.no-js .md-tabs__link{transition:none}.md-tabs__link--active,.md-tabs__link:hover{color:inherit;opacity:1}.md-tabs__item:nth-child(2) .md-tabs__link{transition-delay:20ms}.md-tabs__item:nth-child(3) .md-tabs__link{transition-delay:40ms}.md-tabs__item:nth-child(4) .md-tabs__link{transition-delay:60ms}.md-tabs__item:nth-child(5) .md-tabs__link{transition-delay:80ms}.md-tabs__item:nth-child(6) .md-tabs__link{transition-delay:100ms}.md-tabs__item:nth-child(7) .md-tabs__link{transition-delay:120ms}.md-tabs__item:nth-child(8) .md-tabs__link{transition-delay:140ms}.md-tabs__item:nth-child(9) .md-tabs__link{transition-delay:160ms}.md-tabs__item:nth-child(10) .md-tabs__link{transition-delay:180ms}.md-tabs__item:nth-child(11) .md-tabs__link{transition-delay:200ms}.md-tabs__item:nth-child(12) .md-tabs__link{transition-delay:220ms}.md-tabs__item:nth-child(13) .md-tabs__link{transition-delay:240ms}.md-tabs__item:nth-child(14) .md-tabs__link{transition-delay:260ms}.md-tabs__item:nth-child(15) .md-tabs__link{transition-delay:280ms}.md-tabs__item:nth-child(16) .md-tabs__link{transition-delay:300ms}.md-tabs[data-md-state=hidden]{pointer-events:none}.md-tabs[data-md-state=hidden] .md-tabs__link{transform:translateY(50%);opacity:0;transition:color 250ms,transform 0ms 400ms,opacity 100ms}:root{--md-admonition-icon--note: url("data:image/svg+xml;utf8,");--md-admonition-icon--abstract: url("data:image/svg+xml;utf8,");--md-admonition-icon--info: url("data:image/svg+xml;utf8,");--md-admonition-icon--tip: url("data:image/svg+xml;utf8,");--md-admonition-icon--success: url("data:image/svg+xml;utf8,");--md-admonition-icon--question: url("data:image/svg+xml;utf8,");--md-admonition-icon--warning: url("data:image/svg+xml;utf8,");--md-admonition-icon--failure: url("data:image/svg+xml;utf8,");--md-admonition-icon--danger: url("data:image/svg+xml;utf8,");--md-admonition-icon--bug: url("data:image/svg+xml;utf8,");--md-admonition-icon--example: url("data:image/svg+xml;utf8,");--md-admonition-icon--quote: url("data:image/svg+xml;utf8,")}.md-typeset .admonition,.md-typeset details{margin:1.5625em 0;padding:0 .6rem;overflow:hidden;font-size:.64rem;page-break-inside:avoid;border-left:.2rem solid #448aff;border-radius:.1rem;box-shadow:0 .2rem .5rem rgba(0,0,0,.05),0 0 .05rem rgba(0,0,0,.1)}[dir=rtl] .md-typeset .admonition,[dir=rtl] .md-typeset details{border-right:.2rem solid #448aff;border-left:none}html .md-typeset .admonition>:last-child,html .md-typeset details>:last-child{margin-bottom:.6rem}.md-typeset .admonition .admonition,.md-typeset details .admonition,.md-typeset .admonition details,.md-typeset details details{margin:1em 0}.md-typeset .admonition .md-typeset__scrollwrap,.md-typeset details .md-typeset__scrollwrap{margin:1em -0.6rem}.md-typeset .admonition .md-typeset__table,.md-typeset details .md-typeset__table{padding:0 .6rem}.md-typeset .admonition-title,.md-typeset summary{position:relative;margin:0 -0.6rem;padding:.4rem .6rem .4rem 2rem;font-weight:700;background-color:rgba(68,138,255,.1)}[dir=rtl] .md-typeset .admonition-title,[dir=rtl] .md-typeset summary{padding:.4rem 2rem .4rem .6rem}html .md-typeset .admonition-title:last-child,html .md-typeset summary:last-child{margin-bottom:0}.md-typeset .admonition-title::before,.md-typeset summary::before{position:absolute;left:.6rem;width:1rem;height:1rem;background-color:#448aff;-webkit-mask-image:var(--md-admonition-icon--note);mask-image:var(--md-admonition-icon--note);content:""}[dir=rtl] .md-typeset .admonition-title::before,[dir=rtl] .md-typeset summary::before{right:.6rem;left:initial}.md-typeset .admonition-title code,.md-typeset summary code{margin:initial;padding:initial;color:currentColor;background-color:transparent;border-radius:initial;box-shadow:none}.md-typeset .admonition.note,.md-typeset details.note{border-color:#448aff}.md-typeset .note>.admonition-title,.md-typeset .note>summary{background-color:rgba(68,138,255,.1)}.md-typeset .note>.admonition-title::before,.md-typeset .note>summary::before{background-color:#448aff;-webkit-mask-image:var(--md-admonition-icon--note);mask-image:var(--md-admonition-icon--note)}.md-typeset .admonition.abstract,.md-typeset details.abstract,.md-typeset .admonition.tldr,.md-typeset details.tldr,.md-typeset .admonition.summary,.md-typeset details.summary{border-color:#00b0ff}.md-typeset .abstract>.admonition-title,.md-typeset .abstract>summary,.md-typeset .tldr>.admonition-title,.md-typeset .tldr>summary,.md-typeset .summary>.admonition-title,.md-typeset .summary>summary{background-color:rgba(0,176,255,.1)}.md-typeset .abstract>.admonition-title::before,.md-typeset .abstract>summary::before,.md-typeset .tldr>.admonition-title::before,.md-typeset .tldr>summary::before,.md-typeset .summary>.admonition-title::before,.md-typeset .summary>summary::before{background-color:#00b0ff;-webkit-mask-image:var(--md-admonition-icon--abstract);mask-image:var(--md-admonition-icon--abstract)}.md-typeset .admonition.info,.md-typeset details.info,.md-typeset .admonition.todo,.md-typeset details.todo{border-color:#00b8d4}.md-typeset .info>.admonition-title,.md-typeset .info>summary,.md-typeset .todo>.admonition-title,.md-typeset .todo>summary{background-color:rgba(0,184,212,.1)}.md-typeset .info>.admonition-title::before,.md-typeset .info>summary::before,.md-typeset .todo>.admonition-title::before,.md-typeset .todo>summary::before{background-color:#00b8d4;-webkit-mask-image:var(--md-admonition-icon--info);mask-image:var(--md-admonition-icon--info)}.md-typeset .admonition.tip,.md-typeset details.tip,.md-typeset .admonition.important,.md-typeset details.important,.md-typeset .admonition.hint,.md-typeset details.hint{border-color:#00bfa5}.md-typeset .tip>.admonition-title,.md-typeset .tip>summary,.md-typeset .important>.admonition-title,.md-typeset .important>summary,.md-typeset .hint>.admonition-title,.md-typeset .hint>summary{background-color:rgba(0,191,165,.1)}.md-typeset .tip>.admonition-title::before,.md-typeset .tip>summary::before,.md-typeset .important>.admonition-title::before,.md-typeset .important>summary::before,.md-typeset .hint>.admonition-title::before,.md-typeset .hint>summary::before{background-color:#00bfa5;-webkit-mask-image:var(--md-admonition-icon--tip);mask-image:var(--md-admonition-icon--tip)}.md-typeset .admonition.success,.md-typeset details.success,.md-typeset .admonition.done,.md-typeset details.done,.md-typeset .admonition.check,.md-typeset details.check{border-color:#00c853}.md-typeset .success>.admonition-title,.md-typeset .success>summary,.md-typeset .done>.admonition-title,.md-typeset .done>summary,.md-typeset .check>.admonition-title,.md-typeset .check>summary{background-color:rgba(0,200,83,.1)}.md-typeset .success>.admonition-title::before,.md-typeset .success>summary::before,.md-typeset .done>.admonition-title::before,.md-typeset .done>summary::before,.md-typeset .check>.admonition-title::before,.md-typeset .check>summary::before{background-color:#00c853;-webkit-mask-image:var(--md-admonition-icon--success);mask-image:var(--md-admonition-icon--success)}.md-typeset .admonition.question,.md-typeset details.question,.md-typeset .admonition.faq,.md-typeset details.faq,.md-typeset .admonition.help,.md-typeset details.help{border-color:#64dd17}.md-typeset .question>.admonition-title,.md-typeset .question>summary,.md-typeset .faq>.admonition-title,.md-typeset .faq>summary,.md-typeset .help>.admonition-title,.md-typeset .help>summary{background-color:rgba(100,221,23,.1)}.md-typeset .question>.admonition-title::before,.md-typeset .question>summary::before,.md-typeset .faq>.admonition-title::before,.md-typeset .faq>summary::before,.md-typeset .help>.admonition-title::before,.md-typeset .help>summary::before{background-color:#64dd17;-webkit-mask-image:var(--md-admonition-icon--question);mask-image:var(--md-admonition-icon--question)}.md-typeset .admonition.warning,.md-typeset details.warning,.md-typeset .admonition.attention,.md-typeset details.attention,.md-typeset .admonition.caution,.md-typeset details.caution{border-color:#ff9100}.md-typeset .warning>.admonition-title,.md-typeset .warning>summary,.md-typeset .attention>.admonition-title,.md-typeset .attention>summary,.md-typeset .caution>.admonition-title,.md-typeset .caution>summary{background-color:rgba(255,145,0,.1)}.md-typeset .warning>.admonition-title::before,.md-typeset .warning>summary::before,.md-typeset .attention>.admonition-title::before,.md-typeset .attention>summary::before,.md-typeset .caution>.admonition-title::before,.md-typeset .caution>summary::before{background-color:#ff9100;-webkit-mask-image:var(--md-admonition-icon--warning);mask-image:var(--md-admonition-icon--warning)}.md-typeset .admonition.failure,.md-typeset details.failure,.md-typeset .admonition.missing,.md-typeset details.missing,.md-typeset .admonition.fail,.md-typeset details.fail{border-color:#ff5252}.md-typeset .failure>.admonition-title,.md-typeset .failure>summary,.md-typeset .missing>.admonition-title,.md-typeset .missing>summary,.md-typeset .fail>.admonition-title,.md-typeset .fail>summary{background-color:rgba(255,82,82,.1)}.md-typeset .failure>.admonition-title::before,.md-typeset .failure>summary::before,.md-typeset .missing>.admonition-title::before,.md-typeset .missing>summary::before,.md-typeset .fail>.admonition-title::before,.md-typeset .fail>summary::before{background-color:#ff5252;-webkit-mask-image:var(--md-admonition-icon--failure);mask-image:var(--md-admonition-icon--failure)}.md-typeset .admonition.danger,.md-typeset details.danger,.md-typeset .admonition.error,.md-typeset details.error{border-color:#ff1744}.md-typeset .danger>.admonition-title,.md-typeset .danger>summary,.md-typeset .error>.admonition-title,.md-typeset .error>summary{background-color:rgba(255,23,68,.1)}.md-typeset .danger>.admonition-title::before,.md-typeset .danger>summary::before,.md-typeset .error>.admonition-title::before,.md-typeset .error>summary::before{background-color:#ff1744;-webkit-mask-image:var(--md-admonition-icon--danger);mask-image:var(--md-admonition-icon--danger)}.md-typeset .admonition.bug,.md-typeset details.bug{border-color:#f50057}.md-typeset .bug>.admonition-title,.md-typeset .bug>summary{background-color:rgba(245,0,87,.1)}.md-typeset .bug>.admonition-title::before,.md-typeset .bug>summary::before{background-color:#f50057;-webkit-mask-image:var(--md-admonition-icon--bug);mask-image:var(--md-admonition-icon--bug)}.md-typeset .admonition.example,.md-typeset details.example{border-color:#651fff}.md-typeset .example>.admonition-title,.md-typeset .example>summary{background-color:rgba(101,31,255,.1)}.md-typeset .example>.admonition-title::before,.md-typeset .example>summary::before{background-color:#651fff;-webkit-mask-image:var(--md-admonition-icon--example);mask-image:var(--md-admonition-icon--example)}.md-typeset .admonition.quote,.md-typeset details.quote,.md-typeset .admonition.cite,.md-typeset details.cite{border-color:#9e9e9e}.md-typeset .quote>.admonition-title,.md-typeset .quote>summary,.md-typeset .cite>.admonition-title,.md-typeset .cite>summary{background-color:rgba(158,158,158,.1)}.md-typeset .quote>.admonition-title::before,.md-typeset .quote>summary::before,.md-typeset .cite>.admonition-title::before,.md-typeset .cite>summary::before{background-color:#9e9e9e;-webkit-mask-image:var(--md-admonition-icon--quote);mask-image:var(--md-admonition-icon--quote)}.codehilite .o,.highlight .o{color:inherit}.codehilite .ow,.highlight .ow{color:inherit}.codehilite .ge,.highlight .ge{color:#000}.codehilite .gr,.highlight .gr{color:#a00}.codehilite .gh,.highlight .gh{color:#999}.codehilite .go,.highlight .go{color:#888}.codehilite .gp,.highlight .gp{color:#555}.codehilite .gs,.highlight .gs{color:inherit}.codehilite .gu,.highlight .gu{color:#aaa}.codehilite .gt,.highlight .gt{color:#a00}.codehilite .gd,.highlight .gd{background-color:#fdd}.codehilite .gi,.highlight .gi{background-color:#dfd}.codehilite .k,.highlight .k{color:#3b78e7}.codehilite .kc,.highlight .kc{color:#a71d5d}.codehilite .kd,.highlight .kd{color:#3b78e7}.codehilite .kn,.highlight .kn{color:#3b78e7}.codehilite .kp,.highlight .kp{color:#a71d5d}.codehilite .kr,.highlight .kr{color:#3e61a2}.codehilite .kt,.highlight .kt{color:#3e61a2}.codehilite .c,.highlight .c{color:#999}.codehilite .cm,.highlight .cm{color:#999}.codehilite .cp,.highlight .cp{color:#666}.codehilite .c1,.highlight .c1{color:#999}.codehilite .ch,.highlight .ch{color:#999}.codehilite .cs,.highlight .cs{color:#999}.codehilite .na,.highlight .na{color:#c2185b}.codehilite .nb,.highlight .nb{color:#c2185b}.codehilite .bp,.highlight .bp{color:#3e61a2}.codehilite .nc,.highlight .nc{color:#c2185b}.codehilite .no,.highlight .no{color:#3e61a2}.codehilite .nd,.highlight .nd{color:#666}.codehilite .ni,.highlight .ni{color:#666}.codehilite .ne,.highlight .ne{color:#c2185b}.codehilite .nf,.highlight .nf{color:#c2185b}.codehilite .nl,.highlight .nl{color:#3b5179}.codehilite .nn,.highlight .nn{color:#ec407a}.codehilite .nt,.highlight .nt{color:#3b78e7}.codehilite .nv,.highlight .nv{color:#3e61a2}.codehilite .vc,.highlight .vc{color:#3e61a2}.codehilite .vg,.highlight .vg{color:#3e61a2}.codehilite .vi,.highlight .vi{color:#3e61a2}.codehilite .nx,.highlight .nx{color:#ec407a}.codehilite .m,.highlight .m{color:#e74c3c}.codehilite .mf,.highlight .mf{color:#e74c3c}.codehilite .mh,.highlight .mh{color:#e74c3c}.codehilite .mi,.highlight .mi{color:#e74c3c}.codehilite .il,.highlight .il{color:#e74c3c}.codehilite .mo,.highlight .mo{color:#e74c3c}.codehilite .s,.highlight .s{color:#0d904f}.codehilite .sb,.highlight .sb{color:#0d904f}.codehilite .sc,.highlight .sc{color:#0d904f}.codehilite .sd,.highlight .sd{color:#999}.codehilite .s2,.highlight .s2{color:#0d904f}.codehilite .se,.highlight .se{color:#183691}.codehilite .sh,.highlight .sh{color:#183691}.codehilite .si,.highlight .si{color:#183691}.codehilite .sx,.highlight .sx{color:#183691}.codehilite .sr,.highlight .sr{color:#009926}.codehilite .s1,.highlight .s1{color:#0d904f}.codehilite .ss,.highlight .ss{color:#0d904f}.codehilite .err,.highlight .err{color:#a61717}.codehilite .w,.highlight .w{color:transparent}.codehilite .hll,.highlight .hll{display:block;margin:0 -1.1764705882em;padding:0 1.1764705882em;background-color:rgba(255,235,59,.5)}.codehilitetable,.highlighttable{display:block;overflow:hidden}.codehilitetable tbody,.highlighttable tbody,.codehilitetable td,.highlighttable td{display:block;padding:0}.codehilitetable tr,.highlighttable tr{display:flex}.codehilitetable pre,.highlighttable pre{margin:0}.codehilitetable .linenos,.highlighttable .linenos{padding:.525rem 1.1764705882em;padding-right:0;font-size:.85em;background-color:var(--md-code-bg-color);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.codehilitetable .linenodiv,.highlighttable .linenodiv{padding-right:.5882352941em;box-shadow:inset -0.05rem 0 var(--md-default-fg-color--lightest)}.codehilitetable .linenodiv pre,.highlighttable .linenodiv pre{color:var(--md-default-fg-color--lighter);text-align:right}.codehilitetable .code,.highlighttable .code{flex:1;overflow:hidden}.md-typeset .codehilitetable,.md-typeset .highlighttable{margin:1em 0;direction:ltr;border-radius:.1rem}.md-typeset .codehilitetable code,.md-typeset .highlighttable code{border-radius:0}:root{--md-footnotes-icon: url("data:image/svg+xml;utf8,")}.md-typeset [id^="fnref:"]{display:inline-block}.md-typeset [id^="fnref:"]:target{margin-top:-3.8rem;padding-top:3.8rem;pointer-events:none}.md-typeset [id^="fn:"]::before{display:none;height:0;content:""}.md-typeset [id^="fn:"]:target::before{display:block;margin-top:-3.5rem;padding-top:3.5rem;pointer-events:none}.md-typeset .footnote{color:var(--md-default-fg-color--light);font-size:.64rem}.md-typeset .footnote ol{margin-left:0}.md-typeset .footnote li{transition:color 125ms}.md-typeset .footnote li:target{color:var(--md-default-fg-color)}.md-typeset .footnote li :first-child{margin-top:0}.md-typeset .footnote li:hover .footnote-backref,.md-typeset .footnote li:target .footnote-backref{transform:translateX(0);opacity:1}.md-typeset .footnote li:hover .footnote-backref:hover{color:var(--md-accent-fg-color)}.md-typeset .footnote-ref{display:inline-block;pointer-events:initial}.md-typeset .footnote-backref{display:inline-block;color:var(--md-primary-fg-color);font-size:0;vertical-align:text-bottom;transform:translateX(0.25rem);opacity:0;transition:color 250ms,transform 250ms 250ms,opacity 125ms 250ms}[dir=rtl] .md-typeset .footnote-backref{transform:translateX(-0.25rem)}.md-typeset .footnote-backref::before{display:inline-block;width:.8rem;height:.8rem;background-color:currentColor;-webkit-mask-image:var(--md-footnotes-icon);mask-image:var(--md-footnotes-icon);content:""}[dir=rtl] .md-typeset .footnote-backref::before svg{transform:scaleX(-1)}.md-typeset .headerlink{display:inline-block;margin-left:.5rem;visibility:hidden;opacity:0;transition:color 250ms,visibility 0ms 500ms,opacity 125ms}[dir=rtl] .md-typeset .headerlink{margin-right:.5rem;margin-left:initial}html body .md-typeset .headerlink{color:var(--md-default-fg-color--lighter)}.md-typeset :hover>.headerlink,.md-typeset :target>.headerlink,.md-typeset .headerlink:focus{visibility:visible;opacity:1;transition:color 250ms,visibility 0ms,opacity 125ms}.md-typeset :target>.headerlink,.md-typeset .headerlink:focus,.md-typeset .headerlink:hover{color:var(--md-accent-fg-color)}.md-typeset h3[id]::before,.md-typeset h2[id]::before,.md-typeset h1[id]::before{display:block;margin-top:-0.4rem;padding-top:.4rem;content:""}.md-typeset h3[id]:target::before,.md-typeset h2[id]:target::before,.md-typeset h1[id]:target::before{margin-top:-3.4rem;padding-top:3.4rem}.md-typeset h4[id]::before{display:block;margin-top:-0.45rem;padding-top:.45rem;content:""}.md-typeset h4[id]:target::before{margin-top:-3.45rem;padding-top:3.45rem}.md-typeset h6[id]::before,.md-typeset h5[id]::before{display:block;margin-top:-0.6rem;padding-top:.6rem;content:""}.md-typeset h6[id]:target::before,.md-typeset h5[id]:target::before{margin-top:-3.6rem;padding-top:3.6rem}.md-typeset .MJXc-display{margin:.75em 0;padding:.75em 0;overflow:auto;touch-action:auto}.md-typeset .MathJax_CHTML{outline:0}.md-typeset del.critic,.md-typeset ins.critic,.md-typeset .critic.comment{padding:0 .25em;border-radius:.1rem;-webkit-box-decoration-break:clone;box-decoration-break:clone}.md-typeset del.critic{background-color:#fdd}.md-typeset ins.critic{background-color:#dfd}.md-typeset .critic.comment{color:#999}.md-typeset .critic.comment::before{content:"/* "}.md-typeset .critic.comment::after{content:" */"}.md-typeset .critic.block{display:block;margin:1em 0;padding-right:.8rem;padding-left:.8rem;overflow:auto;box-shadow:none}.md-typeset .critic.block :first-child{margin-top:.5em}.md-typeset .critic.block :last-child{margin-bottom:.5em}:root{--md-details-icon: url("data:image/svg+xml;utf8,")}.md-typeset details{display:block;padding-top:0;overflow:visible}.md-typeset details[open]>summary::after{transform:rotate(90deg)}.md-typeset details:not([open]){padding-bottom:0}.md-typeset details:not([open])>summary{border-bottom-right-radius:.1rem}.md-typeset details::after{display:table;content:""}.md-typeset summary{display:block;min-height:1rem;padding:.4rem 1.8rem .4rem 2rem;border-top-right-radius:.1rem;cursor:pointer}[dir=rtl] .md-typeset summary{padding:.4rem 2rem .4rem 1.8rem}.md-typeset summary::-webkit-details-marker{display:none}.md-typeset summary::after{position:absolute;top:.4rem;right:.4rem;width:1rem;height:1rem;background-color:currentColor;-webkit-mask-image:var(--md-details-icon);mask-image:var(--md-details-icon);transform:rotate(0deg);transition:transform 250ms;content:""}[dir=rtl] .md-typeset summary::after{right:initial;left:.4rem;transform:rotate(180deg)}.md-typeset img.emojione,.md-typeset img.twemoji,.md-typeset img.gemoji{width:1.125em;vertical-align:-15%}.md-typeset span.twemoji{display:inline-block;height:1.125em;vertical-align:text-top}.md-typeset span.twemoji svg{width:1.125em;fill:currentColor}.highlight [data-linenos]::before{position:-webkit-sticky;position:sticky;left:-1.1764705882em;float:left;margin-right:1.1764705882em;margin-left:-1.1764705882em;padding-left:1.1764705882em;color:var(--md-default-fg-color--lighter);background-color:var(--md-code-bg-color);box-shadow:inset -0.05rem 0 var(--md-default-fg-color--lightest);content:attr(data-linenos);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.md-typeset .tabbed-content{display:none;order:99;width:100%;box-shadow:0 -0.05rem var(--md-default-fg-color--lightest)}.md-typeset .tabbed-content>.codehilite:only-child pre,.md-typeset .tabbed-content>.codehilitetable:only-child,.md-typeset .tabbed-content>.highlight:only-child pre,.md-typeset .tabbed-content>.highlighttable:only-child{margin:0}.md-typeset .tabbed-content>.codehilite:only-child pre>code,.md-typeset .tabbed-content>.codehilitetable:only-child>code,.md-typeset .tabbed-content>.highlight:only-child pre>code,.md-typeset .tabbed-content>.highlighttable:only-child>code{border-top-left-radius:0;border-top-right-radius:0}.md-typeset .tabbed-content>.tabbed-set{margin:0}.md-typeset .tabbed-set{position:relative;display:flex;flex-wrap:wrap;margin:1em 0;border-radius:.1rem}.md-typeset .tabbed-set>input{display:none}.md-typeset .tabbed-set>input:checked+label{color:var(--md-accent-fg-color);border-color:var(--md-accent-fg-color)}.md-typeset .tabbed-set>input:checked+label+.tabbed-content{display:block}.md-typeset .tabbed-set>label{z-index:1;width:auto;padding:.6rem 1.25em .5rem;color:var(--md-default-fg-color--light);font-weight:700;font-size:.64rem;border-bottom:.1rem solid transparent;cursor:pointer;transition:color 125ms}html .md-typeset .tabbed-set>label:hover{color:var(--md-accent-fg-color)}:root{--md-tasklist-icon: url("data:image/svg+xml;utf8,");--md-tasklist-icon--checked: url("data:image/svg+xml;utf8,")}.md-typeset .task-list-item{position:relative;list-style-type:none}.md-typeset .task-list-item [type=checkbox]{position:absolute;top:.45em;left:-2em}[dir=rtl] .md-typeset .task-list-item [type=checkbox]{right:-2em;left:initial}.md-typeset .task-list-control .task-list-indicator::before{position:absolute;top:.15em;left:-1.5em;width:1.25em;height:1.25em;background-color:var(--md-default-fg-color--lightest);-webkit-mask-image:var(--md-tasklist-icon);mask-image:var(--md-tasklist-icon);content:""}[dir=rtl] .md-typeset .task-list-control .task-list-indicator::before{right:-1.5em;left:initial}.md-typeset .task-list-control [type=checkbox]:checked+.task-list-indicator::before{background-color:#00e676;-webkit-mask-image:var(--md-tasklist-icon--checked);mask-image:var(--md-tasklist-icon--checked)}.md-typeset .task-list-control [type=checkbox]{z-index:-1;opacity:0}@media print{.md-typeset code,.md-typeset pre,.md-typeset kbd{white-space:pre-wrap}body{display:block}.md-container{display:block}.md-clipboard{display:none}.md-content__button{display:none}.md-dialog{display:none}.md-header{display:none}.md-footer{display:none}.md-sidebar{display:none}.md-tabs{display:none}.md-typeset .admonition,.md-typeset details{box-shadow:none}.md-typeset .footnote-backref{color:var(--md-primary-fg-color);transform:translateX(0);opacity:1}.md-typeset .headerlink{display:none}}@media screen and (max-width: 44.9375em){.md-typeset>pre{margin:1em -0.8rem}.md-typeset>pre code{border-radius:0}.md-footer-nav__link--prev .md-footer-nav__title{display:none}.md-search-result__teaser{max-height:2.5rem;-webkit-line-clamp:3}.md-typeset>.codehilite,.md-typeset>.highlight{margin:1em -0.8rem}.md-typeset>.codehilite .hll,.md-typeset>.highlight .hll{margin:0 -0.8rem;padding:0 .8rem}.md-typeset>.codehilite code,.md-typeset>.highlight code{border-radius:0}.md-typeset>.codehilitetable,.md-typeset>.highlighttable{margin:1em -0.8rem;border-radius:0}.md-typeset>.codehilitetable .hll,.md-typeset>.highlighttable .hll{margin:0 -0.8rem;padding:0 .8rem}.md-typeset>p>.MJXc-display{margin:.75em -0.8rem;padding:.25em .8rem}}@media screen and (min-width: 100em){html{font-size:137.5%}}@media screen and (min-width: 125em){html{font-size:150%}}@media screen and (max-width: 59.9375em){body[data-md-state=lock]{position:fixed}html .md-nav__link[for=__toc]{display:block;padding-right:2.4rem}html .md-nav__link[for=__toc]+.md-nav__link{display:none}html .md-nav__link[for=__toc]~.md-nav{display:flex}html [dir=rtl] .md-nav__link{padding-right:.8rem;padding-left:2.4rem}.md-nav__source{display:block;padding:0 .2rem;color:var(--md-primary-bg-color);background-color:var(--md-primary-fg-color--dark)}.md-search__overlay{position:absolute;top:.2rem;left:-2.2rem;width:2rem;height:2rem;overflow:hidden;background-color:var(--md-default-bg-color);border-radius:1rem;transform-origin:center;transition:transform 300ms 100ms,opacity 200ms 200ms;pointer-events:none}[dir=rtl] .md-search__overlay{right:-2.2rem;left:initial}[data-md-toggle=search]:checked~.md-header .md-search__overlay{opacity:1;transition:transform 400ms,opacity 100ms}.md-search__inner{position:fixed;top:0;left:100%;z-index:2;width:100%;height:100%;transform:translateX(5%);opacity:0;transition:right 0ms 300ms,left 0ms 300ms,transform 150ms 150ms cubic-bezier(0.4, 0, 0.2, 1),opacity 150ms 150ms}[data-md-toggle=search]:checked~.md-header .md-search__inner{left:0;transform:translateX(0);opacity:1;transition:right 0ms 0ms,left 0ms 0ms,transform 150ms 150ms cubic-bezier(0.1, 0.7, 0.1, 1),opacity 150ms 150ms}[dir=rtl] [data-md-toggle=search]:checked~.md-header .md-search__inner{right:0;left:initial}html [dir=rtl] .md-search__inner{right:100%;left:initial;transform:translateX(-5%)}.md-search__input{width:100%;height:2.4rem;font-size:.9rem}.md-search__icon[for=__search]{top:.6rem;left:.8rem}[dir=rtl] .md-search__icon[for=__search]{right:.8rem;left:initial}.md-search__icon[for=__search] svg:first-child{display:none}.md-search__icon[type=reset]{top:.6rem;right:.8rem}[dir=rtl] .md-search__icon[type=reset]{right:initial;left:.8rem}.md-search__output{top:2.4rem;bottom:0}.md-search-result__icon{display:none}}@media screen and (max-width: 76.1875em){[data-md-toggle=drawer]:checked~.md-overlay{width:100%;height:100%;opacity:1;transition:width 0ms,height 0ms,opacity 250ms}.md-header-nav__button.md-logo{display:none}.md-hero__inner{margin-top:2.4rem;margin-bottom:1.2rem}.md-nav{background-color:var(--md-default-bg-color)}.md-nav--primary,.md-nav--primary .md-nav{position:absolute;top:0;right:0;left:0;z-index:1;display:flex;flex-direction:column;height:100%}.md-nav--primary .md-nav__title,.md-nav--primary .md-nav__item{font-size:.8rem;line-height:1.5}.md-nav--primary .md-nav__title{position:relative;height:5.6rem;padding:3rem .8rem .2rem;color:var(--md-default-fg-color--light);font-weight:400;line-height:2.4rem;white-space:nowrap;background-color:var(--md-default-fg-color--lightest);cursor:pointer}.md-nav--primary .md-nav__title .md-nav__icon{position:absolute;top:.4rem;left:.4rem;display:block;width:1.2rem;height:1.2rem;margin:.2rem}[dir=rtl] .md-nav--primary .md-nav__title .md-nav__icon{right:.4rem;left:initial}.md-nav--primary .md-nav__title~.md-nav__list{overflow-y:auto;background-color:var(--md-default-bg-color);box-shadow:inset 0 .05rem 0 var(--md-default-fg-color--lightest);-webkit-scroll-snap-type:y mandatory;-ms-scroll-snap-type:y mandatory;scroll-snap-type:y mandatory;touch-action:pan-y}.md-nav--primary .md-nav__title~.md-nav__list>.md-nav__item:first-child{border-top:0}.md-nav--primary .md-nav__title[for=__drawer]{position:relative;color:var(--md-primary-bg-color);background-color:var(--md-primary-fg-color)}.md-nav--primary .md-nav__title[for=__drawer] .md-nav__button{position:absolute;top:.2rem;left:.2rem;display:block;margin:.2rem;padding:.4rem;font-size:2.4rem}html [dir=rtl] .md-nav--primary .md-nav__title[for=__drawer] .md-nav__button{right:.2rem;left:initial}.md-nav--primary .md-nav__list{flex:1}.md-nav--primary .md-nav__item{padding:0;border-top:.05rem solid var(--md-default-fg-color--lightest)}[dir=rtl] .md-nav--primary .md-nav__item{padding:0}.md-nav--primary .md-nav__item--nested>.md-nav__link{padding-right:2.4rem}[dir=rtl] .md-nav--primary .md-nav__item--nested>.md-nav__link{padding-right:.8rem;padding-left:2.4rem}.md-nav--primary .md-nav__item--active>.md-nav__link{color:var(--md-primary-fg-color)}.md-nav--primary .md-nav__item--active>.md-nav__link:focus,.md-nav--primary .md-nav__item--active>.md-nav__link:hover{color:var(--md-accent-fg-color)}.md-nav--primary .md-nav__link{position:relative;margin-top:0;padding:.6rem .8rem}.md-nav--primary .md-nav__link .md-nav__icon{position:absolute;top:50%;right:.6rem;margin-top:-0.6rem;color:inherit;font-size:1.2rem}[dir=rtl] .md-nav--primary .md-nav__link .md-nav__icon{right:initial;left:.6rem}[dir=rtl] .md-nav--primary .md-nav__icon svg{transform:scale(-1)}.md-nav--primary .md-nav--secondary .md-nav__link{position:static}.md-nav--primary .md-nav--secondary .md-nav{position:static;background-color:transparent}.md-nav--primary .md-nav--secondary .md-nav .md-nav__link{padding-left:1.4rem}[dir=rtl] .md-nav--primary .md-nav--secondary .md-nav .md-nav__link{padding-right:1.4rem;padding-left:initial}.md-nav--primary .md-nav--secondary .md-nav .md-nav .md-nav__link{padding-left:2rem}[dir=rtl] .md-nav--primary .md-nav--secondary .md-nav .md-nav .md-nav__link{padding-right:2rem;padding-left:initial}.md-nav--primary .md-nav--secondary .md-nav .md-nav .md-nav .md-nav__link{padding-left:2.6rem}[dir=rtl] .md-nav--primary .md-nav--secondary .md-nav .md-nav .md-nav .md-nav__link{padding-right:2.6rem;padding-left:initial}.md-nav--primary .md-nav--secondary .md-nav .md-nav .md-nav .md-nav .md-nav__link{padding-left:3.2rem}[dir=rtl] .md-nav--primary .md-nav--secondary .md-nav .md-nav .md-nav .md-nav .md-nav__link{padding-right:3.2rem;padding-left:initial}.md-nav__toggle~.md-nav{display:flex;transform:translateX(100%);opacity:0;transition:transform 250ms cubic-bezier(0.8, 0, 0.6, 1),opacity 125ms 50ms}[dir=rtl] .md-nav__toggle~.md-nav{transform:translateX(-100%)}.md-nav__toggle:checked~.md-nav{transform:translateX(0);opacity:1;transition:transform 250ms cubic-bezier(0.4, 0, 0.2, 1),opacity 125ms 125ms}.md-nav__toggle:checked~.md-nav>.md-nav__list{-webkit-backface-visibility:hidden;backface-visibility:hidden}.md-sidebar--primary{position:fixed;top:0;left:-12.1rem;z-index:3;width:12.1rem;height:100%;background-color:var(--md-default-bg-color);transform:translateX(0);transition:transform 250ms cubic-bezier(0.4, 0, 0.2, 1),box-shadow 250ms}[dir=rtl] .md-sidebar--primary{right:-12.1rem;left:initial}[data-md-toggle=drawer]:checked~.md-container .md-sidebar--primary{box-shadow:0 8px 10px 1px rgba(0,0,0,.14),0 3px 14px 2px rgba(0,0,0,.12),0 5px 5px -3px rgba(0,0,0,.4);transform:translateX(12.1rem)}[dir=rtl] [data-md-toggle=drawer]:checked~.md-container .md-sidebar--primary{transform:translateX(-12.1rem)}.md-sidebar--primary .md-sidebar__scrollwrap{overflow:hidden}.md-sidebar--primary .md-sidebar__scrollwrap{position:absolute;top:0;right:0;bottom:0;left:0;margin:0;-webkit-scroll-snap-type:none;-ms-scroll-snap-type:none;scroll-snap-type:none}.md-tabs{display:none}}@media screen and (min-width: 60em){.md-content{margin-right:12.1rem}[dir=rtl] .md-content{margin-right:initial;margin-left:12.1rem}.md-header-nav__button[for=__search]{display:none}.md-header-nav__source{display:block;width:11.7rem;max-width:11.7rem;margin-left:1rem}[dir=rtl] .md-header-nav__source{margin-right:1rem;margin-left:initial}.md-nav--secondary .md-nav__title[for=__toc]{scroll-snap-align:start}.md-nav--secondary .md-nav__title .md-nav__icon{display:none}.md-search{padding:.2rem 0}.md-search__overlay{position:fixed;top:0;left:0;width:0;height:0;background-color:var(--md-default-fg-color--light);cursor:pointer;transition:width 0ms 250ms,height 0ms 250ms,opacity 250ms}[dir=rtl] .md-search__overlay{right:0;left:initial}[data-md-toggle=search]:checked~.md-header .md-search__overlay{width:100%;height:100%;opacity:1;transition:width 0ms,height 0ms,opacity 250ms}.md-search__inner{position:relative;float:right;width:11.7rem;padding:.1rem 0;transition:width 250ms cubic-bezier(0.1, 0.7, 0.1, 1)}[dir=rtl] .md-search__inner{float:left}.md-search__form{border-radius:.1rem}.md-search__input{width:100%;height:1.8rem;padding-left:2.2rem;color:inherit;font-size:.8rem;background-color:var(--md-default-fg-color--lighter);border-radius:.1rem;transition:color 250ms,background-color 250ms}[dir=rtl] .md-search__input{padding-right:2.2rem}.md-search__input+.md-search__icon{color:var(--md-primary-bg-color)}.md-search__input::-webkit-input-placeholder{color:var(--md-primary-bg-color--light)}.md-search__input::-moz-placeholder{color:var(--md-primary-bg-color--light)}.md-search__input::-ms-input-placeholder{color:var(--md-primary-bg-color--light)}.md-search__input::placeholder{color:var(--md-primary-bg-color--light)}.md-search__input:hover{background-color:var(--md-default-bg-color--lightest)}[data-md-toggle=search]:checked~.md-header .md-search__input{color:var(--md-default-fg-color);text-overflow:clip;background-color:var(--md-default-bg-color);border-radius:.1rem .1rem 0 0}[data-md-toggle=search]:checked~.md-header .md-search__input::-webkit-input-placeholder{color:var(--md-default-fg-color--light)}[data-md-toggle=search]:checked~.md-header .md-search__input::-moz-placeholder{color:var(--md-default-fg-color--light)}[data-md-toggle=search]:checked~.md-header .md-search__input::-ms-input-placeholder{color:var(--md-default-fg-color--light)}[data-md-toggle=search]:checked~.md-header .md-search__input+.md-search__icon,[data-md-toggle=search]:checked~.md-header .md-search__input::placeholder{color:var(--md-default-fg-color--light)}.md-search__icon[for=__search]{pointer-events:none}.md-search__icon[for=__search] svg:last-child{display:none}.md-search__output{top:1.9rem;opacity:0;transition:opacity 400ms}[data-md-toggle=search]:checked~.md-header .md-search__output{box-shadow:0 6px 10px 0 rgba(0,0,0,.14),0 1px 18px 0 rgba(0,0,0,.12),0 3px 5px -1px rgba(0,0,0,.4);opacity:1}.md-search__scrollwrap{max-height:0}[data-md-toggle=search]:checked~.md-header .md-search__scrollwrap{max-height:75vh}.md-search__scrollwrap::-webkit-scrollbar{width:.2rem;height:.2rem}.md-search__scrollwrap::-webkit-scrollbar-thumb{background-color:var(--md-default-fg-color--lighter)}.md-search__scrollwrap::-webkit-scrollbar-thumb:hover{background-color:var(--md-accent-fg-color)}.md-search-result__meta{padding-left:2.2rem}[dir=rtl] .md-search-result__meta{padding-right:2.2rem;padding-left:initial}.md-search-result__article{padding-left:2.2rem}[dir=rtl] .md-search-result__article{padding-right:2.2rem;padding-left:.8rem}.md-sidebar--secondary{display:block;margin-left:calc(100% - 12.1rem)}[dir=rtl] .md-sidebar--secondary{margin-right:calc(100% - 12.1rem);margin-left:initial}.md-sidebar--secondary .md-sidebar__scrollwrap{touch-action:pan-y}}@media screen and (min-width: 76.25em){.md-content{margin-left:12.1rem}[dir=rtl] .md-content{margin-right:12.1rem}.md-content__inner{margin-right:1.2rem;margin-left:1.2rem}.md-header-nav__button[for=__drawer]{display:none}.md-header-nav__source{margin-left:1.4rem}[dir=rtl] .md-header-nav__source{margin-right:1.4rem}.md-nav{transition:max-height 250ms cubic-bezier(0.86, 0, 0.07, 1)}.md-nav--primary .md-nav__title[for=__drawer]{scroll-snap-align:start}.md-nav--primary .md-nav__title .md-nav__icon{display:none}.md-nav__toggle~.md-nav{display:none}.md-nav__toggle:checked~.md-nav{display:block}.md-nav__item--nested>.md-nav>.md-nav__title{display:none}.md-nav__icon{float:right;height:.9rem;transition:transform 250ms}[dir=rtl] .md-nav__icon{float:left;transform:rotate(180deg)}.md-nav__icon svg{display:inline-block;width:.9rem;height:.9rem;vertical-align:-0.1rem}.md-nav__item--nested .md-nav__toggle:checked~.md-nav__link .md-nav__icon{transform:rotate(90deg)}[data-md-toggle=search]:checked~.md-header .md-search__inner{width:34.4rem}.md-search__scrollwrap{width:34.4rem}.md-sidebar--secondary{margin-left:48.9rem}[dir=rtl] .md-sidebar--secondary{margin-right:48.9rem;margin-left:initial}.md-tabs~.md-main .md-nav--primary>.md-nav__list>.md-nav__item--nested{display:none}.md-tabs--active~.md-main .md-nav--primary .md-nav__title{display:block;padding:0 .6rem;pointer-events:none;scroll-snap-align:start}.md-tabs--active~.md-main .md-nav--primary .md-nav__title[for=__drawer]{display:none}.md-tabs--active~.md-main .md-nav--primary>.md-nav__list>.md-nav__item{display:none}.md-tabs--active~.md-main .md-nav--primary>.md-nav__list>.md-nav__item--active{display:block;padding:0}.md-tabs--active~.md-main .md-nav--primary>.md-nav__list>.md-nav__item--active>.md-nav__link{display:none}.md-tabs--active~.md-main .md-nav[data-md-level="1"]>.md-nav__list>.md-nav__item{padding:0 .6rem}.md-tabs--active~.md-main .md-nav[data-md-level="1"] .md-nav .md-nav__title{display:none}}@media screen and (min-width: 45em){.md-footer-nav__link{width:50%}.md-footer-copyright{width:auto}.md-footer-social{padding:.6rem 0}}@media screen and (max-width: 29.9375em){[data-md-toggle=search]:checked~.md-header .md-search__overlay{transform:scale(45)}}@media screen and (min-width: 30em)and (max-width: 44.9375em){[data-md-toggle=search]:checked~.md-header .md-search__overlay{transform:scale(60)}}@media screen and (min-width: 45em)and (max-width: 59.9375em){[data-md-toggle=search]:checked~.md-header .md-search__overlay{transform:scale(75)}}@media screen and (min-width: 60em)and (max-width: 76.1875em){[data-md-toggle=search]:checked~.md-header .md-search__inner{width:23.4rem}.md-search__scrollwrap{width:23.4rem}.md-search-result__teaser{max-height:2.5rem;-webkit-line-clamp:3}}@media(-webkit-max-device-pixel-ratio: 1), (max-resolution: 1dppx){.md-search__scrollwrap{transform:translateZ(0)}} + +/*# sourceMappingURL=main.a676eddb.min.css.map*/ \ No newline at end of file diff --git a/docs/assets/stylesheets/main.a676eddb.min.css.map b/docs/assets/stylesheets/main.a676eddb.min.css.map new file mode 100644 index 0000000..499acd5 --- /dev/null +++ b/docs/assets/stylesheets/main.a676eddb.min.css.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///./src/assets/stylesheets/main.scss","webpack:///./src/assets/stylesheets/base/_reset.scss","webpack:///./src/assets/stylesheets/base/_colors.scss","webpack:///./src/assets/stylesheets/base/_icons.scss","webpack:///./src/assets/stylesheets/base/_typeset.scss","webpack:///./src/assets/stylesheets/layout/_base.scss","webpack:///./src/assets/stylesheets/layout/_announce.scss","webpack:///./src/assets/stylesheets/layout/_button.scss","webpack:///./src/assets/stylesheets/layout/_clipboard.scss","webpack:///./src/assets/stylesheets/layout/_content.scss","webpack:///./src/assets/stylesheets/layout/_dialog.scss","webpack:///./node_modules/material-shadows/material-shadows.scss","webpack:///./src/assets/stylesheets/layout/_header.scss","webpack:///./src/assets/stylesheets/layout/_hero.scss","webpack:///./src/assets/stylesheets/layout/_footer.scss","webpack:///./src/assets/stylesheets/layout/_nav.scss","webpack:///./src/assets/stylesheets/layout/_search.scss","webpack:///./src/assets/stylesheets/layout/_sidebar.scss","webpack:///./src/assets/stylesheets/layout/_source.scss","webpack:///./src/assets/stylesheets/layout/_tabs.scss","webpack:///./src/assets/stylesheets/extensions/_admonition.scss","webpack:///./node_modules/material-design-color/material-color.scss","webpack:///./src/assets/stylesheets/extensions/_codehilite.scss","webpack:///./src/assets/stylesheets/extensions/_footnotes.scss","webpack:///./src/assets/stylesheets/extensions/_permalinks.scss","webpack:///./src/assets/stylesheets/extensions/pymdown/_arithmatex.scss","webpack:///./src/assets/stylesheets/extensions/pymdown/_critic.scss","webpack:///./src/assets/stylesheets/extensions/pymdown/_details.scss","webpack:///./src/assets/stylesheets/extensions/pymdown/_emoji.scss","webpack:///./src/assets/stylesheets/extensions/pymdown/_highlight.scss","webpack:///./src/assets/stylesheets/extensions/pymdown/_tabbed.scss","webpack:///./src/assets/stylesheets/extensions/pymdown/_tasklist.scss","webpack:///./src/assets/stylesheets/utilities/_break.scss"],"names":[],"mappings":"AAAA,KC6BA,qBACE,sBAIF,kBAGE,MAIF,6BACE,CADF,0BACE,CADF,yBACE,CADF,qBACE,MAIF,QACE,IAIF,sBACE,iBACA,sBAIF,uCAIE,GAIF,aACE,qBACA,OAIF,aACE,SAIF,iBAEE,cACA,cACA,wBACA,KAIF,cACE,KAIF,UACE,KAIF,iBACE,OAIF,wBACE,iBACA,OAIF,kBAEE,mBACA,QAIF,QACE,UACA,kBACA,uBACA,SACA,OAIF,QACE,UACA,OCjGF,4CAGE,oDACA,sDACA,uDACA,4CACA,qDACA,uDACA,yDACA,iDAGA,wDACA,uDACA,kDACA,gEACA,gDAGA,+DACA,iDACA,+DACA,wCAGA,2CACA,cCxBA,aACE,aACA,cACA,cACA,kBACA,MCRJ,kCACE,kCACA,YAIF,gCAEE,4CACA,CADA,mCACA,wEACA,cAIF,gCAGE,qCACA,CADA,4BACA,oDACA,aAWF,eACE,gBACA,iCACA,CADA,kBACA,oEAGA,YAIE,gBAIF,eACE,wCACA,gBACA,oBACA,gBACA,uBACA,gBAIF,mBACE,gBACA,kBACA,gBACA,uBACA,gBAIF,qBACE,gBACA,eACA,gBACA,uBACA,mBAIF,gBACE,gBAIF,cACE,gBACA,gBACA,uBACA,+BAIF,cAEE,wCACA,gBACA,iBACA,uBACA,gBAIF,wBACE,gBAIF,cACE,gEACA,eAIF,gCACE,sBACA,qCAGA,sBAEE,yCAIF,+BAEE,kDAKJ,6BAGE,cACA,CAIE,iBAKJ,uBACE,gBACA,sBACA,yCACA,oBACA,mCACA,CADA,0BACA,yHAIF,cAME,gBACA,6BACA,gBACA,oBAIF,kBACE,iBAIF,iBACE,aACA,gBACA,sBAGA,aACE,SACA,+BACA,cACA,kBACA,gBACA,mCACA,CADA,0BACA,kBACA,yCAGA,WACE,aACA,+CAIF,oDACE,qDAGA,0CACE,CAeF,gBAMN,oBACE,wBACA,gBACA,gBACA,wBACA,sBACA,oBACA,+JAEE,kBAMJ,eACE,sBACA,qCACA,oBACA,mCACA,CADA,0BACA,kBAIF,oBACE,8DACA,YACA,mBAIF,WACE,iCAIF,qBAEE,qDAGA,sBACE,oBACA,wBAKJ,kBACE,wCACA,4DACA,kCAGA,mBACE,qBACA,6DACA,oBACA,gBAKJ,oBACE,+BAIF,kBAEE,UACA,mDAGA,mBACE,oBACA,qCAIF,2BACE,2CAGA,2BACE,qCAKJ,kBACE,mBACA,yDAGA,mBACE,oBACA,mGAIF,aAEE,2DAIF,eACE,qFAIF,yBAEE,6HAGA,mBACE,oBACA,gBAOR,wBACE,0BAGA,oBACE,oBACA,oDAKJ,cAGE,gCAIF,oBACE,eACA,cACA,iBACA,sCACA,oBACA,mEAEE,kBAEF,kCAKA,gBACE,+FAIF,eAEE,mHAGA,gBACE,mCAKJ,cACE,oBACA,iCACA,mBACA,mDACA,mCAIF,mBACE,mBACA,6DACA,mCAIF,iCACE,yCAGA,iCACE,uDACA,kDAIF,YACE,kCAMJ,iBACE,yBAKJ,kBACE,gBACA,kBACA,oBAIF,oBACE,mBACA,gBACA,0BAGA,aACE,WACA,SACA,gBACA,MCpbN,WACE,kBAKA,eAOA,4CACA,CASE,KAKJ,iBACE,aACA,sBACA,WACA,gBACA,gBAGA,CAcE,GAKJ,aACE,cACA,UACA,SACA,UAIF,eACE,kBACA,iBACA,eAIF,YACE,sBACA,YACA,CAKE,SAKJ,WACE,iBAGA,WACE,kBACA,cAKJ,aACE,gBACA,mBACA,uBACA,YAQF,YACE,aAIF,cACE,MACA,UACA,QACA,SACA,mDACA,UACA,0DAEE,CAaI,SAYR,cACE,WAGA,aACA,oBACA,iCACA,iBACA,4CACA,oBACA,6BACA,UACA,gBAGA,UACE,wBACA,UACA,2EAEE,OAUN,WACE,cCzLF,aACE,4CACA,qBAGA,iBACE,gBACA,iCACA,gBACA,wBCNF,oBACE,mBACA,iCACA,gBACA,gCACA,oBACA,iEAEE,iCAKF,gCACE,4CACA,wCACA,2DAIF,+BAEE,2CACA,uCACA,eC3BN,iBACE,UACA,WACA,UACA,YACA,aACA,2CACA,oBACA,eACA,uBACA,CAIE,kBAIF,aACE,eACA,yBAIF,uCACE,iDAIF,+BAEE,CCZE,mBAKJ,qBACE,kBACA,CAKE,2BAKF,aACE,aACA,WACA,gCAIF,eACE,qBAKJ,WACE,eACA,kBACA,UACA,+BAGA,UACE,mBACA,oBACA,mCAGA,oBACE,iCAKJ,yCACE,yBAIF,cACE,mBACA,CAKA,WChFN,gGCFE,eDKA,YACA,aACA,aACA,UACA,cACA,kBACA,oBACA,iCACA,gBACA,sCACA,YACA,oBACA,2BACA,UACA,6CAEE,sBAIF,aACE,WACA,gCAIF,uBACE,UACA,6EAEE,CAMF,WEvCJ,uBACE,CADF,eACE,MACA,QACA,OACA,UACA,cACA,iCACA,4CACA,+DAIE,8CAGA,mBAIF,eACE,gBACA,kCAIF,gEAEI,+DAGA,CAOF,eAKJ,YACE,gBACA,wBAGA,iBACE,UACA,aACA,cACA,eACA,yBACA,sCAME,oBACE,2DAKJ,UAEE,gCAIF,YACE,cACA,uEAGA,aAEE,aACA,cACA,kBACA,6CAKJ,YACE,CA0BE,sBAMN,iBACE,WACA,wEAEE,6CAIF,UACE,8BACA,UACA,wEAEE,oBAEF,uDAGA,8BACE,8BAKJ,gBACE,oDAIF,YACE,uBAKJ,WACE,eACA,gBACA,mBACA,mEAGA,UACE,+BACA,UACA,wEAEE,oBAEF,6EAGA,6BACE,yFAIF,SACE,wBACA,UACA,wEAEE,uBAEF,gDAKJ,iBACE,WACA,YACA,wBAKJ,YACE,CAsBI,SC3NR,eACE,iCACA,eACA,4CACA,4BACA,iBAGA,eACE,0BACA,wEAEE,uBAEF,CAKE,uCAIF,8BACE,UACA,iDAEE,oBAEF,kCAIF,oBACE,YClCN,gCACE,4CACA,CAIE,sBAQF,aACE,cACA,sBAIF,YACE,mBACA,qBACA,yBACA,CAIE,sDAIF,UAEE,4BAIF,UACE,UACA,sCAGA,WACE,0CAGA,oBACE,CASA,2BAMN,WACE,UACA,iBACA,sCAGA,UACE,gBACA,0CAGA,oBACE,uBAOR,iBACE,YACA,8BACA,eACA,gBACA,mBACA,wBAIF,YACE,cACA,2BAIF,iBACE,QACA,OACA,iBACA,eACA,wCACA,iBACA,iBAKJ,oDACE,wBAGA,YACE,eACA,8BACA,cACA,mCAIF,uCACE,iFAGA,gCAEE,sBAMN,UACE,kBACA,gBACA,0CACA,iBACA,CAIE,gCAIF,uCACE,mBAKJ,cACE,sBACA,CAIE,wBAIF,oBACE,aACA,cACA,kBACA,iCAGA,eACE,6BAIF,gBACE,oBACA,kBACA,SClLN,eACE,gBACA,gBAGA,aACE,gBACA,gBACA,gBACA,uBACA,gCAGA,YACE,oCAGA,UACE,YACA,uFAOA,aAEE,aACA,cACA,4CAIF,iBACE,eAOR,QACE,UACA,gBACA,eAIF,eACE,0BAGA,oBACE,6BAIF,eACE,uCAGA,mBACE,eACA,wCAIF,gBACE,eAMN,aACE,kBACA,gBACA,uBACA,eACA,uBACA,wBACA,+BAIA,YACE,uCAGA,YACE,mCAKJ,uCACE,qCAIF,gCACE,qCAIF,aACE,yCAIF,+BAEE,iBAKJ,YACE,CAuXI,WCteR,iBACE,mBAGA,YACE,CAKA,oBAIF,SACE,UACA,CA8EM,kBAQR,kCAEE,CAFF,0BAEE,CAoEI,iBAMN,iBACE,CAIE,kBAKJ,iBACE,UACA,0BACA,uBACA,6BAGA,yBACE,8CAIF,8BACE,CADF,sBACE,CALA,oCAIF,2BACE,CADF,sBACE,CALA,yCAIF,0BACE,CADF,sBACE,CALA,+BAIF,sBACE,8CAIF,uCAEE,CANA,oCAIF,uCAEE,CANA,yCAIF,uCAEE,CANA,kEAIF,uCAEE,8BAIF,YACE,CAqDI,iBAOR,iBACE,UACA,aACA,cACA,eACA,qCAEE,wBAIF,UACE,gCAIF,SACE,WACA,0CAGA,WACE,aACA,8CAGA,oBACE,CA2BA,6BAMN,SACE,YACA,sBACA,UACA,wEAEE,oBAEF,wCAGA,aACE,WACA,CAWE,kHAKJ,kBAEE,UACA,uBACA,yHAGA,UACE,oBAOR,iBACE,UACA,WACA,gBACA,8BACA,CAkBI,uBAMN,WACE,gBACA,4CACA,iEACA,mCAEA,CAFA,0BAEA,qCACA,CADA,gCACA,CADA,4BACA,mBACA,CAsCM,kBAQV,gCACE,sBACA,yBAGA,eACE,wCACA,iBACA,mBACA,sDACA,wBACA,CASI,wBAMN,QACE,UACA,gBACA,6DACA,yBAIF,4DACE,yBAIF,aACE,UACA,4BACA,wBACA,6DAGA,uDAEE,mIAGA,UACE,8DAKJ,mBACE,4BAKJ,iBACE,gBACA,cACA,CASI,8DAQF,eACE,gBACA,gBACA,gBACA,yBAMN,iBACE,OACA,aACA,cACA,wCACA,mCAGA,OACE,aACA,uCAGA,oBACE,CAMF,yBAKJ,aACE,gBACA,iBACA,gBACA,2BAMF,mBACE,mBACA,cACA,gBACA,wCACA,iBACA,gBACA,uBACA,4BACA,qBACA,CAWE,qBAOJ,eACE,kBACA,0BACA,aC1mBJ,iBACE,cACA,iBACA,gBACA,CAIE,gCAIF,cACE,WACA,CAwCI,uBAMN,YACE,CA0BI,wBAMN,eACE,eACA,gBACA,mCAEA,CAFA,0BAEA,qCACA,CADA,gCACA,CADA,4BACA,CAaI,2CAKJ,WACE,aACA,kDAIF,oDACE,wDAGA,0CACE,2CCxIR,GACE,QACE,MAGF,aACE,EDkII,kCCxIR,GACE,QACE,MAGF,aACE,2CAKJ,GACE,0BACE,UACA,KAGF,SACE,MAGF,wBACE,UACA,EAjBA,iCAKJ,GACE,0BACE,UACA,KAGF,SACE,MAGF,wBACE,UACA,aASJ,aACE,iBACA,gBACA,mBACA,mCAEA,CAFA,0BAEA,yBACA,kBAGA,UACE,kBAIF,oBACE,aACA,cACA,sBACA,sBAGA,gBACE,kBACA,gCAGA,kBACE,oBACA,yCAKJ,iBACE,kBACA,mDAGA,kBACE,oBACA,mBACA,qBACA,wBAMN,oBACE,8BACA,kBACA,gBACA,gBACA,uBACA,sBACA,mBAIF,QACE,UACA,gBACA,gBACA,iBACA,qBACA,YACA,wCAGA,sDACE,CADF,8CACE,kBAKJ,UACE,4BAGA,WACE,uCAIF,sDACE,CADF,8CACE,0BAIF,cACE,YACA,sCAIF,YACE,UCjIN,UACE,cACA,iCACA,4CACA,4BACA,iBAGA,eACE,CAUA,eAIF,QACE,kBACA,UACA,mBACA,gBACA,gBACA,0BAGA,kBACE,oBACA,gBAKJ,oBACE,cACA,oBACA,mBACA,gBAKF,aACE,iBACA,gBACA,WACA,wEAEE,uBAIF,eACE,6CAIF,aAEE,UACA,4CAKA,qBACE,4CADF,qBACE,4CADF,qBACE,4CADF,qBACE,4CADF,sBACE,4CADF,sBACE,4CADF,sBACE,4CADF,sBACE,6CADF,sBACE,6CADF,sBACE,6CADF,sBACE,6CADF,sBACE,6CADF,sBACE,6CADF,sBACE,6CADF,sBACE,gCAMN,mB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,gEAGA,qFAwBF,mCAIE,2BgBtUJ,iChBkXF,uBAOI,sFCrdJ,+CAMI,kCAGA,iDACE,cACA,4CAIF,YR1EA,4CuBuJF,wBvBhKJ,yEAwBE,gCuBwIE,+FpBuDE,sGGvNN,8BAybI,8EAOI,8BAIF,8CAOA,6DAKA,+BAIF,SACE,gBAIF,8BAEE,0BACA,sBAGA,UACE,kDAKF,YACE,oBACA,uBACA,oBACA,0DAIF,oCiB7UF,gGhB6PF,iBgB7PE,oBf5FF,8CAyBI,uBACE,iDekEJ,uCb/DA,qBACE,+FAYI,CACA,wEACA,+BAGA,OACE,6EAKJ,UACE,uFAGA,iBAEE,gGAGA,6BACE,kEAUN,UACE,qHLtHN,oBkBwIA,8ClB1BJ,6BAmBA,oBErGU,oCgB8HN,8EhBpHI,4EgB6EF,iFhBxEE,uEgBwEF,gEhBnEE,qDA8FA,8DgB3BF,mDhBkRJ,4CAsLA,8BApaM,CAsPJ,wFAGA,uCACE,k6I","file":"assets/stylesheets/main.a676eddb.min.css","sourcesContent":["html{box-sizing:border-box}*,*::before,*::after{box-sizing:inherit}html{text-size-adjust:none}body{margin:0}hr{box-sizing:content-box;overflow:visible}a,button,label,input{-webkit-tap-highlight-color:transparent}a{color:inherit;text-decoration:none}small{font-size:80%}sub,sup{position:relative;font-size:80%;line-height:0;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}table{border-collapse:separate;border-spacing:0}td,th{font-weight:normal;vertical-align:top}button{margin:0;padding:0;font-size:inherit;background:transparent;border:0}input{border:0;outline:0}:root{--md-default-fg-color: hsla(0, 0%, 0%, 0.87);--md-default-fg-color--light: hsla(0, 0%, 0%, 0.54);--md-default-fg-color--lighter: hsla(0, 0%, 0%, 0.26);--md-default-fg-color--lightest: hsla(0, 0%, 0%, 0.07);--md-default-bg-color: hsla(0, 0%, 100%, 1);--md-default-bg-color--light: hsla(0, 0%, 100%, 0.7);--md-default-bg-color--lighter: hsla(0, 0%, 100%, 0.3);--md-default-bg-color--lightest: hsla(0, 0%, 100%, 0.12);--md-primary-fg-color: hsla(231deg, 48%, 48%, 1);--md-primary-fg-color--light: hsla(230deg, 44%, 64%, 1);--md-primary-fg-color--dark: hsla(232deg, 54%, 41%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light);--md-accent-fg-color: hsla(231deg, 99%, 66%, 1);--md-accent-fg-color--transparent: hsla(231deg, 99%, 66%, 0.1);--md-accent-bg-color: var(--md-default-bg-color);--md-accent-bg-color--light: var(--md-default-bg-color--light);--md-code-bg-color: hsla(0, 0%, 96%, 1);--md-code-fg-color: hsla(200, 18%, 26%, 1)}.md-icon svg{display:block;width:1.2rem;height:1.2rem;margin:0 auto;fill:currentColor}body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}body,input{color:var(--md-default-fg-color);font-feature-settings:\"kern\",\"liga\";font-family:-apple-system,BlinkMacSystemFont,Helvetica,Arial,sans-serif}code,pre,kbd{color:var(--md-default-fg-color);font-feature-settings:\"kern\";font-family:SFMono-Regular,Consolas,Menlo,monospace}.md-typeset{font-size:.8rem;line-height:1.6;color-adjust:exact}.md-typeset p,.md-typeset ul,.md-typeset ol,.md-typeset blockquote{margin:1em 0}.md-typeset h1{margin:0 0 2rem;color:var(--md-default-fg-color--light);font-weight:300;font-size:1.5625rem;line-height:1.3;letter-spacing:-0.01em}.md-typeset h2{margin:2rem 0 .8rem;font-weight:300;font-size:1.25rem;line-height:1.4;letter-spacing:-0.01em}.md-typeset h3{margin:1.6rem 0 .8rem;font-weight:400;font-size:1rem;line-height:1.5;letter-spacing:-0.01em}.md-typeset h2+h3{margin-top:.8rem}.md-typeset h4{margin:.8rem 0;font-weight:700;font-size:.8rem;letter-spacing:-0.01em}.md-typeset h5,.md-typeset h6{margin:.8rem 0;color:var(--md-default-fg-color--light);font-weight:700;font-size:.64rem;letter-spacing:-0.01em}.md-typeset h5{text-transform:uppercase}.md-typeset hr{margin:1.5em 0;border-bottom:.05rem dotted var(--md-default-fg-color--lighter)}.md-typeset a{color:var(--md-primary-fg-color);word-break:break-word}.md-typeset a,.md-typeset a::before{transition:color 125ms}.md-typeset a:focus,.md-typeset a:hover{color:var(--md-accent-fg-color)}.md-typeset code,.md-typeset pre,.md-typeset kbd{color:var(--md-code-fg-color);direction:ltr}@media print{.md-typeset code,.md-typeset pre,.md-typeset kbd{white-space:pre-wrap}}.md-typeset code{padding:0 .2941176471em;font-size:.85em;word-break:break-word;background-color:var(--md-code-bg-color);border-radius:.1rem;box-decoration-break:clone}.md-typeset h1 code,.md-typeset h2 code,.md-typeset h3 code,.md-typeset h4 code,.md-typeset h5 code,.md-typeset h6 code{margin:initial;padding:initial;background-color:transparent;box-shadow:none}.md-typeset a>code{color:currentColor}.md-typeset pre{position:relative;margin:1em 0;line-height:1.4}.md-typeset pre>code{display:block;margin:0;padding:.525rem 1.1764705882em;overflow:auto;word-break:normal;box-shadow:none;box-decoration-break:slice;touch-action:auto}.md-typeset pre>code::-webkit-scrollbar{width:.2rem;height:.2rem}.md-typeset pre>code::-webkit-scrollbar-thumb{background-color:var(--md-default-fg-color--lighter)}.md-typeset pre>code::-webkit-scrollbar-thumb:hover{background-color:var(--md-accent-fg-color)}@media screen and (max-width: 44.9375em){.md-typeset>pre{margin:1em -0.8rem}.md-typeset>pre code{border-radius:0}}.md-typeset kbd{display:inline-block;padding:0 .6666666667em;font-size:.75em;line-height:1.5;vertical-align:text-top;word-break:break-word;border-radius:.1rem;box-shadow:0 .1rem 0 .05rem var(--md-default-fg-color--lighter),0 .1rem 0 var(--md-default-fg-color--lighter),inset 0 -0.1rem .2rem var(--md-default-bg-color)}.md-typeset mark{padding:0 .25em;word-break:break-word;background-color:rgba(255,235,59,.5);border-radius:.1rem;box-decoration-break:clone}.md-typeset abbr{text-decoration:none;border-bottom:.05rem dotted var(--md-default-fg-color--light);cursor:help}.md-typeset small{opacity:.75}.md-typeset sup,.md-typeset sub{margin-left:.078125em}[dir=rtl] .md-typeset sup,[dir=rtl] .md-typeset sub{margin-right:.078125em;margin-left:initial}.md-typeset blockquote{padding-left:.6rem;color:var(--md-default-fg-color--light);border-left:.2rem solid var(--md-default-fg-color--lighter)}[dir=rtl] .md-typeset blockquote{padding-right:.6rem;padding-left:initial;border-right:.2rem solid var(--md-default-fg-color--lighter);border-left:initial}.md-typeset ul{list-style-type:disc}.md-typeset ul,.md-typeset ol{margin-left:.625em;padding:0}[dir=rtl] .md-typeset ul,[dir=rtl] .md-typeset ol{margin-right:.625em;margin-left:initial}.md-typeset ul ol,.md-typeset ol ol{list-style-type:lower-alpha}.md-typeset ul ol ol,.md-typeset ol ol ol{list-style-type:lower-roman}.md-typeset ul li,.md-typeset ol li{margin-bottom:.5em;margin-left:1.25em}[dir=rtl] .md-typeset ul li,[dir=rtl] .md-typeset ol li{margin-right:1.25em;margin-left:initial}.md-typeset ul li p,.md-typeset ul li blockquote,.md-typeset ol li p,.md-typeset ol li blockquote{margin:.5em 0}.md-typeset ul li:last-child,.md-typeset ol li:last-child{margin-bottom:0}.md-typeset ul li ul,.md-typeset ul li ol,.md-typeset ol li ul,.md-typeset ol li ol{margin:.5em 0 .5em .625em}[dir=rtl] .md-typeset ul li ul,[dir=rtl] .md-typeset ul li ol,[dir=rtl] .md-typeset ol li ul,[dir=rtl] .md-typeset ol li ol{margin-right:.625em;margin-left:initial}.md-typeset dd{margin:1em 0 1em 1.875em}[dir=rtl] .md-typeset dd{margin-right:1.875em;margin-left:initial}.md-typeset iframe,.md-typeset img,.md-typeset svg{max-width:100%}.md-typeset table:not([class]){display:inline-block;max-width:100%;overflow:auto;font-size:.64rem;background:var(--md-default-bg-color);border-radius:.1rem;box-shadow:0 .2rem .5rem rgba(0,0,0,.05),0 0 .05rem rgba(0,0,0,.1);touch-action:auto}.md-typeset table:not([class])+*{margin-top:1.5em}.md-typeset table:not([class]) th:not([align]),.md-typeset table:not([class]) td:not([align]){text-align:left}[dir=rtl] .md-typeset table:not([class]) th:not([align]),[dir=rtl] .md-typeset table:not([class]) td:not([align]){text-align:right}.md-typeset table:not([class]) th{min-width:5rem;padding:.6rem .8rem;color:var(--md-default-bg-color);vertical-align:top;background-color:var(--md-default-fg-color--light)}.md-typeset table:not([class]) td{padding:.6rem .8rem;vertical-align:top;border-top:.05rem solid var(--md-default-fg-color--lightest)}.md-typeset table:not([class]) tr{transition:background-color 125ms}.md-typeset table:not([class]) tr:hover{background-color:rgba(0,0,0,.035);box-shadow:0 .05rem 0 var(--md-default-bg-color) inset}.md-typeset table:not([class]) tr:first-child td{border-top:0}.md-typeset table:not([class]) a{word-break:normal}.md-typeset__scrollwrap{margin:1em -0.8rem;overflow-x:auto;touch-action:auto}.md-typeset__table{display:inline-block;margin-bottom:.5em;padding:0 .8rem}.md-typeset__table table{display:table;width:100%;margin:0;overflow:hidden}html{height:100%;overflow-x:hidden;font-size:125%;background-color:var(--md-default-bg-color)}@media screen and (min-width: 100em){html{font-size:137.5%}}@media screen and (min-width: 125em){html{font-size:150%}}body{position:relative;display:flex;flex-direction:column;width:100%;min-height:100%;font-size:.5rem}@media screen and (max-width: 59.9375em){body[data-md-state=lock]{position:fixed}}@media print{body{display:block}}hr{display:block;height:.05rem;padding:0;border:0}.md-grid{max-width:61rem;margin-right:auto;margin-left:auto}.md-container{display:flex;flex-direction:column;flex-grow:1}@media print{.md-container{display:block}}.md-main{flex-grow:1}.md-main__inner{height:100%;margin-top:1.5rem}.md-ellipsis{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.md-toggle{display:none}.md-overlay{position:fixed;top:0;z-index:3;width:0;height:0;background-color:var(--md-default-fg-color--light);opacity:0;transition:width 0ms 250ms,height 0ms 250ms,opacity 250ms}@media screen and (max-width: 76.1875em){[data-md-toggle=drawer]:checked~.md-overlay{width:100%;height:100%;opacity:1;transition:width 0ms,height 0ms,opacity 250ms}}.md-skip{position:fixed;z-index:-1;margin:.5rem;padding:.3rem .5rem;color:var(--md-default-bg-color);font-size:.64rem;background-color:var(--md-default-fg-color);border-radius:.1rem;transform:translateY(0.4rem);opacity:0}.md-skip:focus{z-index:10;transform:translateY(0);opacity:1;transition:transform 250ms cubic-bezier(0.4, 0, 0.2, 1),opacity 175ms 75ms}@page{margin:25mm}.md-announce{overflow:auto;background-color:var(--md-default-fg-color)}.md-announce__inner{margin:.6rem auto;padding:0 .8rem;color:var(--md-default-bg-color);font-size:.7rem}.md-typeset .md-button{display:inline-block;padding:.625em 2em;color:var(--md-primary-fg-color);font-weight:700;border:.1rem solid currentColor;border-radius:.1rem;transition:color 125ms,background-color 125ms,border-color 125ms}.md-typeset .md-button--primary{color:var(--md-primary-bg-color);background-color:var(--md-primary-fg-color);border-color:var(--md-primary-fg-color)}.md-typeset .md-button:focus,.md-typeset .md-button:hover{color:var(--md-accent-bg-color);background-color:var(--md-accent-fg-color);border-color:var(--md-accent-fg-color)}.md-clipboard{position:absolute;top:.4rem;right:.5em;z-index:1;width:1.5em;height:1.5em;color:var(--md-default-fg-color--lightest);border-radius:.1rem;cursor:pointer;transition:color 125ms}@media print{.md-clipboard{display:none}}.md-clipboard svg{width:1.125em;height:1.125em}pre:hover .md-clipboard{color:var(--md-default-fg-color--light)}pre .md-clipboard:focus,pre .md-clipboard:hover{color:var(--md-accent-fg-color)}@media screen and (min-width: 60em){.md-content{margin-right:12.1rem}[dir=rtl] .md-content{margin-right:initial;margin-left:12.1rem}}@media screen and (min-width: 76.25em){.md-content{margin-left:12.1rem}[dir=rtl] .md-content{margin-right:12.1rem}}.md-content__inner{margin:0 .8rem 1.2rem;padding-top:.6rem}@media screen and (min-width: 76.25em){.md-content__inner{margin-right:1.2rem;margin-left:1.2rem}}.md-content__inner::before{display:block;height:.4rem;content:\"\"}.md-content__inner>:last-child{margin-bottom:0}.md-content__button{float:right;margin:.4rem 0;margin-left:.4rem;padding:0}[dir=rtl] .md-content__button{float:left;margin-right:.4rem;margin-left:initial}[dir=rtl] .md-content__button svg{transform:scaleX(-1)}.md-typeset .md-content__button{color:var(--md-default-fg-color--lighter)}.md-content__button svg{display:inline;vertical-align:top}@media print{.md-content__button{display:none}}.md-dialog{box-shadow:0 2px 2px 0 rgba(0,0,0,.14),0 1px 5px 0 rgba(0,0,0,.12),0 3px 1px -2px rgba(0,0,0,.2);position:fixed;right:.8rem;bottom:.8rem;left:initial;z-index:2;display:block;min-width:11.1rem;padding:.4rem .6rem;color:var(--md-default-bg-color);font-size:.7rem;background:var(--md-default-fg-color);border:none;border-radius:.1rem;transform:translateY(100%);opacity:0;transition:transform 0ms 400ms,opacity 400ms}[dir=rtl] .md-dialog{right:initial;left:.8rem}.md-dialog[data-md-state=open]{transform:translateY(0);opacity:1;transition:transform 400ms cubic-bezier(0.075, 0.85, 0.175, 1),opacity 400ms}@media print{.md-dialog{display:none}}.md-header{position:sticky;top:0;right:0;left:0;z-index:2;height:2.4rem;color:var(--md-primary-bg-color);background-color:var(--md-primary-fg-color);box-shadow:0 0 .2rem rgba(0,0,0,0),0 .2rem .4rem rgba(0,0,0,0);transition:color 250ms,background-color 250ms}.no-js .md-header{box-shadow:none;transition:none}.md-header[data-md-state=shadow]{box-shadow:0 0 .2rem rgba(0,0,0,.1),0 .2rem .4rem rgba(0,0,0,.2);transition:color 250ms,background-color 250ms,box-shadow 250ms}@media print{.md-header{display:none}}.md-header-nav{display:flex;padding:0 .2rem}.md-header-nav__button{position:relative;z-index:1;margin:.2rem;padding:.4rem;cursor:pointer;transition:opacity 250ms}[dir=rtl] .md-header-nav__button svg{transform:scaleX(-1)}.md-header-nav__button:focus,.md-header-nav__button:hover{opacity:.7}.md-header-nav__button.md-logo{margin:.2rem;padding:.4rem}.md-header-nav__button.md-logo img,.md-header-nav__button.md-logo svg{display:block;width:1.2rem;height:1.2rem;fill:currentColor}.no-js .md-header-nav__button[for=__search]{display:none}@media screen and (min-width: 60em){.md-header-nav__button[for=__search]{display:none}}@media screen and (max-width: 76.1875em){.md-header-nav__button.md-logo{display:none}}@media screen and (min-width: 76.25em){.md-header-nav__button[for=__drawer]{display:none}}.md-header-nav__topic{position:absolute;width:100%;transition:transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),opacity 150ms}.md-header-nav__topic+.md-header-nav__topic{z-index:-1;transform:translateX(1.25rem);opacity:0;transition:transform 400ms cubic-bezier(1, 0.7, 0.1, 0.1),opacity 150ms;pointer-events:none}[dir=rtl] .md-header-nav__topic+.md-header-nav__topic{transform:translateX(-1.25rem)}.no-js .md-header-nav__topic{position:initial}.no-js .md-header-nav__topic+.md-header-nav__topic{display:none}.md-header-nav__title{flex-grow:1;padding:0 1rem;font-size:.9rem;line-height:2.4rem}.md-header-nav__title[data-md-state=active] .md-header-nav__topic{z-index:-1;transform:translateX(-1.25rem);opacity:0;transition:transform 400ms cubic-bezier(1, 0.7, 0.1, 0.1),opacity 150ms;pointer-events:none}[dir=rtl] .md-header-nav__title[data-md-state=active] .md-header-nav__topic{transform:translateX(1.25rem)}.md-header-nav__title[data-md-state=active] .md-header-nav__topic+.md-header-nav__topic{z-index:0;transform:translateX(0);opacity:1;transition:transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),opacity 150ms;pointer-events:initial}.md-header-nav__title>.md-header-nav__ellipsis{position:relative;width:100%;height:100%}.md-header-nav__source{display:none}@media screen and (min-width: 60em){.md-header-nav__source{display:block;width:11.7rem;max-width:11.7rem;margin-left:1rem}[dir=rtl] .md-header-nav__source{margin-right:1rem;margin-left:initial}}@media screen and (min-width: 76.25em){.md-header-nav__source{margin-left:1.4rem}[dir=rtl] .md-header-nav__source{margin-right:1.4rem}}.md-hero{overflow:hidden;color:var(--md-primary-bg-color);font-size:1rem;background-color:var(--md-primary-fg-color);transition:background 250ms}.md-hero__inner{margin-top:1rem;padding:.8rem .8rem .4rem;transition:transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),opacity 250ms;transition-delay:100ms}@media screen and (max-width: 76.1875em){.md-hero__inner{margin-top:2.4rem;margin-bottom:1.2rem}}[data-md-state=hidden] .md-hero__inner{transform:translateY(0.625rem);opacity:0;transition:transform 0ms 400ms,opacity 100ms 0ms;pointer-events:none}.md-hero--expand .md-hero__inner{margin-bottom:1.2rem}.md-footer{color:var(--md-default-bg-color);background-color:var(--md-default-fg-color)}@media print{.md-footer{display:none}}.md-footer-nav__inner{padding:.2rem;overflow:auto}.md-footer-nav__link{display:flex;padding-top:1.4rem;padding-bottom:.4rem;transition:opacity 250ms}@media screen and (min-width: 45em){.md-footer-nav__link{width:50%}}.md-footer-nav__link:focus,.md-footer-nav__link:hover{opacity:.7}.md-footer-nav__link--prev{float:left;width:25%}[dir=rtl] .md-footer-nav__link--prev{float:right}[dir=rtl] .md-footer-nav__link--prev svg{transform:scaleX(-1)}@media screen and (max-width: 44.9375em){.md-footer-nav__link--prev .md-footer-nav__title{display:none}}.md-footer-nav__link--next{float:right;width:75%;text-align:right}[dir=rtl] .md-footer-nav__link--next{float:left;text-align:left}[dir=rtl] .md-footer-nav__link--next svg{transform:scaleX(-1)}.md-footer-nav__title{position:relative;flex-grow:1;max-width:calc(100% - 2.4rem);padding:0 1rem;font-size:.9rem;line-height:2.4rem}.md-footer-nav__button{margin:.2rem;padding:.4rem}.md-footer-nav__direction{position:absolute;right:0;left:0;margin-top:-1rem;padding:0 1rem;color:var(--md-default-bg-color--light);font-size:.64rem}.md-footer-meta{background-color:var(--md-default-fg-color--lighter)}.md-footer-meta__inner{display:flex;flex-wrap:wrap;justify-content:space-between;padding:.2rem}html .md-footer-meta.md-typeset a{color:var(--md-default-bg-color--light)}html .md-footer-meta.md-typeset a:focus,html .md-footer-meta.md-typeset a:hover{color:var(--md-default-bg-color)}.md-footer-copyright{width:100%;margin:auto .6rem;padding:.4rem 0;color:var(--md-default-bg-color--lighter);font-size:.64rem}@media screen and (min-width: 45em){.md-footer-copyright{width:auto}}.md-footer-copyright__highlight{color:var(--md-default-bg-color--light)}.md-footer-social{margin:0 .4rem;padding:.2rem 0 .6rem}@media screen and (min-width: 45em){.md-footer-social{padding:.6rem 0}}.md-footer-social__link{display:inline-block;width:1.6rem;height:1.6rem;text-align:center}.md-footer-social__link::before{line-height:1.9}.md-footer-social__link svg{max-height:.8rem;vertical-align:-25%;fill:currentColor}.md-nav{font-size:.7rem;line-height:1.3}.md-nav__title{display:block;padding:0 .6rem;overflow:hidden;font-weight:700;text-overflow:ellipsis}.md-nav__title .md-nav__button{display:none}.md-nav__title .md-nav__button img{width:100%;height:auto}.md-nav__title .md-nav__button.md-logo img,.md-nav__title .md-nav__button.md-logo svg{display:block;width:2.4rem;height:2.4rem}.md-nav__title .md-nav__button.md-logo svg{fill:currentColor}.md-nav__list{margin:0;padding:0;list-style:none}.md-nav__item{padding:0 .6rem}.md-nav__item:last-child{padding-bottom:.6rem}.md-nav__item .md-nav__item{padding-right:0}[dir=rtl] .md-nav__item .md-nav__item{padding-right:.6rem;padding-left:0}.md-nav__item .md-nav__item:last-child{padding-bottom:0}.md-nav__link{display:block;margin-top:.625em;overflow:hidden;text-overflow:ellipsis;cursor:pointer;transition:color 125ms;scroll-snap-align:start}html .md-nav__link[for=__toc]{display:none}html .md-nav__link[for=__toc]~.md-nav{display:none}.md-nav__link[data-md-state=blur]{color:var(--md-default-fg-color--light)}.md-nav__item .md-nav__link--active{color:var(--md-primary-fg-color)}.md-nav__item--nested>.md-nav__link{color:inherit}.md-nav__link:focus,.md-nav__link:hover{color:var(--md-accent-fg-color)}.md-nav__source{display:none}@media screen and (max-width: 76.1875em){.md-nav{background-color:var(--md-default-bg-color)}.md-nav--primary,.md-nav--primary .md-nav{position:absolute;top:0;right:0;left:0;z-index:1;display:flex;flex-direction:column;height:100%}.md-nav--primary .md-nav__title,.md-nav--primary .md-nav__item{font-size:.8rem;line-height:1.5}.md-nav--primary .md-nav__title{position:relative;height:5.6rem;padding:3rem .8rem .2rem;color:var(--md-default-fg-color--light);font-weight:400;line-height:2.4rem;white-space:nowrap;background-color:var(--md-default-fg-color--lightest);cursor:pointer}.md-nav--primary .md-nav__title .md-nav__icon{position:absolute;top:.4rem;left:.4rem;display:block;width:1.2rem;height:1.2rem;margin:.2rem}[dir=rtl] .md-nav--primary .md-nav__title .md-nav__icon{right:.4rem;left:initial}.md-nav--primary .md-nav__title~.md-nav__list{overflow-y:auto;background-color:var(--md-default-bg-color);box-shadow:inset 0 .05rem 0 var(--md-default-fg-color--lightest);scroll-snap-type:y mandatory;touch-action:pan-y}.md-nav--primary .md-nav__title~.md-nav__list>.md-nav__item:first-child{border-top:0}.md-nav--primary .md-nav__title[for=__drawer]{position:relative;color:var(--md-primary-bg-color);background-color:var(--md-primary-fg-color)}.md-nav--primary .md-nav__title[for=__drawer] .md-nav__button{position:absolute;top:.2rem;left:.2rem;display:block;margin:.2rem;padding:.4rem;font-size:2.4rem}html [dir=rtl] .md-nav--primary .md-nav__title[for=__drawer] .md-nav__button{right:.2rem;left:initial}.md-nav--primary .md-nav__list{flex:1}.md-nav--primary .md-nav__item{padding:0;border-top:.05rem solid var(--md-default-fg-color--lightest)}[dir=rtl] .md-nav--primary .md-nav__item{padding:0}.md-nav--primary .md-nav__item--nested>.md-nav__link{padding-right:2.4rem}[dir=rtl] .md-nav--primary .md-nav__item--nested>.md-nav__link{padding-right:.8rem;padding-left:2.4rem}.md-nav--primary .md-nav__item--active>.md-nav__link{color:var(--md-primary-fg-color)}.md-nav--primary .md-nav__item--active>.md-nav__link:focus,.md-nav--primary .md-nav__item--active>.md-nav__link:hover{color:var(--md-accent-fg-color)}.md-nav--primary .md-nav__link{position:relative;margin-top:0;padding:.6rem .8rem}.md-nav--primary .md-nav__link .md-nav__icon{position:absolute;top:50%;right:.6rem;margin-top:-0.6rem;color:inherit;font-size:1.2rem}[dir=rtl] .md-nav--primary .md-nav__link .md-nav__icon{right:initial;left:.6rem}[dir=rtl] .md-nav--primary .md-nav__icon svg{transform:scale(-1)}.md-nav--primary .md-nav--secondary .md-nav__link{position:static}.md-nav--primary .md-nav--secondary .md-nav{position:static;background-color:transparent}.md-nav--primary .md-nav--secondary .md-nav .md-nav__link{padding-left:1.4rem}[dir=rtl] .md-nav--primary .md-nav--secondary .md-nav .md-nav__link{padding-right:1.4rem;padding-left:initial}.md-nav--primary .md-nav--secondary .md-nav .md-nav .md-nav__link{padding-left:2rem}[dir=rtl] .md-nav--primary .md-nav--secondary .md-nav .md-nav .md-nav__link{padding-right:2rem;padding-left:initial}.md-nav--primary .md-nav--secondary .md-nav .md-nav .md-nav .md-nav__link{padding-left:2.6rem}[dir=rtl] .md-nav--primary .md-nav--secondary .md-nav .md-nav .md-nav .md-nav__link{padding-right:2.6rem;padding-left:initial}.md-nav--primary .md-nav--secondary .md-nav .md-nav .md-nav .md-nav .md-nav__link{padding-left:3.2rem}[dir=rtl] .md-nav--primary .md-nav--secondary .md-nav .md-nav .md-nav .md-nav .md-nav__link{padding-right:3.2rem;padding-left:initial}.md-nav__toggle~.md-nav{display:flex;transform:translateX(100%);opacity:0;transition:transform 250ms cubic-bezier(0.8, 0, 0.6, 1),opacity 125ms 50ms}[dir=rtl] .md-nav__toggle~.md-nav{transform:translateX(-100%)}.md-nav__toggle:checked~.md-nav{transform:translateX(0);opacity:1;transition:transform 250ms cubic-bezier(0.4, 0, 0.2, 1),opacity 125ms 125ms}.md-nav__toggle:checked~.md-nav>.md-nav__list{backface-visibility:hidden}}@media screen and (max-width: 59.9375em){html .md-nav__link[for=__toc]{display:block;padding-right:2.4rem}html .md-nav__link[for=__toc]+.md-nav__link{display:none}html .md-nav__link[for=__toc]~.md-nav{display:flex}html [dir=rtl] .md-nav__link{padding-right:.8rem;padding-left:2.4rem}.md-nav__source{display:block;padding:0 .2rem;color:var(--md-primary-bg-color);background-color:var(--md-primary-fg-color--dark)}}@media screen and (min-width: 60em){.md-nav--secondary .md-nav__title[for=__toc]{scroll-snap-align:start}.md-nav--secondary .md-nav__title .md-nav__icon{display:none}}@media screen and (min-width: 76.25em){.md-nav{transition:max-height 250ms cubic-bezier(0.86, 0, 0.07, 1)}.md-nav--primary .md-nav__title[for=__drawer]{scroll-snap-align:start}.md-nav--primary .md-nav__title .md-nav__icon{display:none}.md-nav__toggle~.md-nav{display:none}.md-nav__toggle:checked~.md-nav{display:block}.md-nav__item--nested>.md-nav>.md-nav__title{display:none}.md-nav__icon{float:right;height:.9rem;transition:transform 250ms}[dir=rtl] .md-nav__icon{float:left;transform:rotate(180deg)}.md-nav__icon svg{display:inline-block;width:.9rem;height:.9rem;vertical-align:-0.1rem}.md-nav__item--nested .md-nav__toggle:checked~.md-nav__link .md-nav__icon{transform:rotate(90deg)}}.md-search{position:relative}.no-js .md-search{display:none}@media screen and (min-width: 60em){.md-search{padding:.2rem 0}}.md-search__overlay{z-index:1;opacity:0}@media screen and (max-width: 59.9375em){.md-search__overlay{position:absolute;top:.2rem;left:-2.2rem;width:2rem;height:2rem;overflow:hidden;background-color:var(--md-default-bg-color);border-radius:1rem;transform-origin:center;transition:transform 300ms 100ms,opacity 200ms 200ms;pointer-events:none}[dir=rtl] .md-search__overlay{right:-2.2rem;left:initial}[data-md-toggle=search]:checked~.md-header .md-search__overlay{opacity:1;transition:transform 400ms,opacity 100ms}}@media screen and (max-width: 29.9375em){[data-md-toggle=search]:checked~.md-header .md-search__overlay{transform:scale(45)}}@media screen and (min-width: 30em)and (max-width: 44.9375em){[data-md-toggle=search]:checked~.md-header .md-search__overlay{transform:scale(60)}}@media screen and (min-width: 45em)and (max-width: 59.9375em){[data-md-toggle=search]:checked~.md-header .md-search__overlay{transform:scale(75)}}@media screen and (min-width: 60em){.md-search__overlay{position:fixed;top:0;left:0;width:0;height:0;background-color:var(--md-default-fg-color--light);cursor:pointer;transition:width 0ms 250ms,height 0ms 250ms,opacity 250ms}[dir=rtl] .md-search__overlay{right:0;left:initial}[data-md-toggle=search]:checked~.md-header .md-search__overlay{width:100%;height:100%;opacity:1;transition:width 0ms,height 0ms,opacity 250ms}}.md-search__inner{backface-visibility:hidden}@media screen and (max-width: 59.9375em){.md-search__inner{position:fixed;top:0;left:100%;z-index:2;width:100%;height:100%;transform:translateX(5%);opacity:0;transition:right 0ms 300ms,left 0ms 300ms,transform 150ms 150ms cubic-bezier(0.4, 0, 0.2, 1),opacity 150ms 150ms}[data-md-toggle=search]:checked~.md-header .md-search__inner{left:0;transform:translateX(0);opacity:1;transition:right 0ms 0ms,left 0ms 0ms,transform 150ms 150ms cubic-bezier(0.1, 0.7, 0.1, 1),opacity 150ms 150ms}[dir=rtl] [data-md-toggle=search]:checked~.md-header .md-search__inner{right:0;left:initial}html [dir=rtl] .md-search__inner{right:100%;left:initial;transform:translateX(-5%)}}@media screen and (min-width: 60em){.md-search__inner{position:relative;float:right;width:11.7rem;padding:.1rem 0;transition:width 250ms cubic-bezier(0.1, 0.7, 0.1, 1)}[dir=rtl] .md-search__inner{float:left}}@media screen and (min-width: 60em)and (max-width: 76.1875em){[data-md-toggle=search]:checked~.md-header .md-search__inner{width:23.4rem}}@media screen and (min-width: 76.25em){[data-md-toggle=search]:checked~.md-header .md-search__inner{width:34.4rem}}.md-search__form{position:relative}@media screen and (min-width: 60em){.md-search__form{border-radius:.1rem}}.md-search__input{position:relative;z-index:2;padding:0 2.2rem 0 3.6rem;text-overflow:ellipsis}[dir=rtl] .md-search__input{padding:0 3.6rem 0 2.2rem}.md-search__input::placeholder{transition:color 250ms}.md-search__input~.md-search__icon,.md-search__input::placeholder{color:var(--md-default-fg-color--light)}.md-search__input::-ms-clear{display:none}@media screen and (max-width: 59.9375em){.md-search__input{width:100%;height:2.4rem;font-size:.9rem}}@media screen and (min-width: 60em){.md-search__input{width:100%;height:1.8rem;padding-left:2.2rem;color:inherit;font-size:.8rem;background-color:var(--md-default-fg-color--lighter);border-radius:.1rem;transition:color 250ms,background-color 250ms}[dir=rtl] .md-search__input{padding-right:2.2rem}.md-search__input+.md-search__icon{color:var(--md-primary-bg-color)}.md-search__input::placeholder{color:var(--md-primary-bg-color--light)}.md-search__input:hover{background-color:var(--md-default-bg-color--lightest)}[data-md-toggle=search]:checked~.md-header .md-search__input{color:var(--md-default-fg-color);text-overflow:clip;background-color:var(--md-default-bg-color);border-radius:.1rem .1rem 0 0}[data-md-toggle=search]:checked~.md-header .md-search__input+.md-search__icon,[data-md-toggle=search]:checked~.md-header .md-search__input::placeholder{color:var(--md-default-fg-color--light)}}.md-search__icon{position:absolute;z-index:2;width:1.2rem;height:1.2rem;cursor:pointer;transition:color 250ms,opacity 250ms}.md-search__icon:hover{opacity:.7}.md-search__icon[for=__search]{top:.3rem;left:.5rem}[dir=rtl] .md-search__icon[for=__search]{right:.5rem;left:initial}[dir=rtl] .md-search__icon[for=__search] svg{transform:scaleX(-1)}@media screen and (max-width: 59.9375em){.md-search__icon[for=__search]{top:.6rem;left:.8rem}[dir=rtl] .md-search__icon[for=__search]{right:.8rem;left:initial}.md-search__icon[for=__search] svg:first-child{display:none}}@media screen and (min-width: 60em){.md-search__icon[for=__search]{pointer-events:none}.md-search__icon[for=__search] svg:last-child{display:none}}.md-search__icon[type=reset]{top:.3rem;right:.5rem;transform:scale(0.75);opacity:0;transition:transform 150ms cubic-bezier(0.1, 0.7, 0.1, 1),opacity 150ms;pointer-events:none}[dir=rtl] .md-search__icon[type=reset]{right:initial;left:.5rem}@media screen and (max-width: 59.9375em){.md-search__icon[type=reset]{top:.6rem;right:.8rem}[dir=rtl] .md-search__icon[type=reset]{right:initial;left:.8rem}}[data-md-toggle=search]:checked~.md-header .md-search__input:not(:placeholder-shown)~.md-search__icon[type=reset]{transform:scale(1);opacity:1;pointer-events:initial}[data-md-toggle=search]:checked~.md-header .md-search__input:not(:placeholder-shown)~.md-search__icon[type=reset]:hover{opacity:.7}.md-search__output{position:absolute;z-index:1;width:100%;overflow:hidden;border-radius:0 0 .1rem .1rem}@media screen and (max-width: 59.9375em){.md-search__output{top:2.4rem;bottom:0}}@media screen and (min-width: 60em){.md-search__output{top:1.9rem;opacity:0;transition:opacity 400ms}[data-md-toggle=search]:checked~.md-header .md-search__output{box-shadow:0 6px 10px 0 rgba(0,0,0,.14),0 1px 18px 0 rgba(0,0,0,.12),0 3px 5px -1px rgba(0,0,0,.4);opacity:1}}.md-search__scrollwrap{height:100%;overflow-y:auto;background-color:var(--md-default-bg-color);box-shadow:inset 0 .05rem 0 var(--md-default-fg-color--lightest);backface-visibility:hidden;scroll-snap-type:y mandatory;touch-action:pan-y}@media(max-resolution: 1dppx){.md-search__scrollwrap{transform:translateZ(0)}}@media screen and (min-width: 60em)and (max-width: 76.1875em){.md-search__scrollwrap{width:23.4rem}}@media screen and (min-width: 76.25em){.md-search__scrollwrap{width:34.4rem}}@media screen and (min-width: 60em){.md-search__scrollwrap{max-height:0}[data-md-toggle=search]:checked~.md-header .md-search__scrollwrap{max-height:75vh}.md-search__scrollwrap::-webkit-scrollbar{width:.2rem;height:.2rem}.md-search__scrollwrap::-webkit-scrollbar-thumb{background-color:var(--md-default-fg-color--lighter)}.md-search__scrollwrap::-webkit-scrollbar-thumb:hover{background-color:var(--md-accent-fg-color)}}.md-search-result{color:var(--md-default-fg-color);word-break:break-word}.md-search-result__meta{padding:0 .8rem;color:var(--md-default-fg-color--light);font-size:.64rem;line-height:1.8rem;background-color:var(--md-default-fg-color--lightest);scroll-snap-align:start}@media screen and (min-width: 60em){.md-search-result__meta{padding-left:2.2rem}[dir=rtl] .md-search-result__meta{padding-right:2.2rem;padding-left:initial}}.md-search-result__list{margin:0;padding:0;list-style:none;border-top:.05rem solid var(--md-default-fg-color--lightest)}.md-search-result__item{box-shadow:0 -0.05rem 0 var(--md-default-fg-color--lightest)}.md-search-result__link{display:block;outline:0;transition:background 250ms;scroll-snap-align:start}.md-search-result__link:focus,.md-search-result__link:hover{background-color:var(--md-accent-fg-color--transparent)}.md-search-result__link:focus .md-search-result__article::before,.md-search-result__link:hover .md-search-result__article::before{opacity:.7}.md-search-result__link:last-child .md-search-result__teaser{margin-bottom:.6rem}.md-search-result__article{position:relative;padding:0 .8rem;overflow:auto}@media screen and (min-width: 60em){.md-search-result__article{padding-left:2.2rem}[dir=rtl] .md-search-result__article{padding-right:2.2rem;padding-left:.8rem}}.md-search-result__article--document .md-search-result__title{margin:.55rem 0;font-weight:400;font-size:.8rem;line-height:1.4}.md-search-result__icon{position:absolute;left:0;margin:.1rem;padding:.4rem;color:var(--md-default-fg-color--light)}[dir=rtl] .md-search-result__icon{right:0;left:initial}[dir=rtl] .md-search-result__icon svg{transform:scaleX(-1)}@media screen and (max-width: 59.9375em){.md-search-result__icon{display:none}}.md-search-result__title{margin:.5em 0;font-weight:700;font-size:.64rem;line-height:1.4}.md-search-result__teaser{display:-webkit-box;max-height:1.65rem;margin:.5em 0;overflow:hidden;color:var(--md-default-fg-color--light);font-size:.64rem;line-height:1.4;text-overflow:ellipsis;-webkit-box-orient:vertical;-webkit-line-clamp:2}@media screen and (max-width: 44.9375em){.md-search-result__teaser{max-height:2.5rem;-webkit-line-clamp:3}}@media screen and (min-width: 60em)and (max-width: 76.1875em){.md-search-result__teaser{max-height:2.5rem;-webkit-line-clamp:3}}.md-search-result em{font-weight:700;font-style:normal;text-decoration:underline}.md-sidebar{position:absolute;width:12.1rem;padding:1.2rem 0;overflow:hidden}@media print{.md-sidebar{display:none}}.md-sidebar[data-md-state=lock]{position:fixed;top:2.4rem}@media screen and (max-width: 76.1875em){.md-sidebar--primary{position:fixed;top:0;left:-12.1rem;z-index:3;width:12.1rem;height:100%;background-color:var(--md-default-bg-color);transform:translateX(0);transition:transform 250ms cubic-bezier(0.4, 0, 0.2, 1),box-shadow 250ms}[dir=rtl] .md-sidebar--primary{right:-12.1rem;left:initial}[data-md-toggle=drawer]:checked~.md-container .md-sidebar--primary{box-shadow:0 8px 10px 1px rgba(0,0,0,.14),0 3px 14px 2px rgba(0,0,0,.12),0 5px 5px -3px rgba(0,0,0,.4);transform:translateX(12.1rem)}[dir=rtl] [data-md-toggle=drawer]:checked~.md-container .md-sidebar--primary{transform:translateX(-12.1rem)}.md-sidebar--primary .md-sidebar__scrollwrap{overflow:hidden}}.md-sidebar--secondary{display:none}@media screen and (min-width: 60em){.md-sidebar--secondary{display:block;margin-left:calc(100% - 12.1rem)}[dir=rtl] .md-sidebar--secondary{margin-right:calc(100% - 12.1rem);margin-left:initial}.md-sidebar--secondary .md-sidebar__scrollwrap{touch-action:pan-y}}@media screen and (min-width: 76.25em){.md-sidebar--secondary{margin-left:48.9rem}[dir=rtl] .md-sidebar--secondary{margin-right:48.9rem;margin-left:initial}}.md-sidebar__scrollwrap{max-height:100%;margin:0 .2rem;overflow-y:auto;backface-visibility:hidden;scroll-snap-type:y mandatory}@media screen and (max-width: 76.1875em){.md-sidebar--primary .md-sidebar__scrollwrap{position:absolute;top:0;right:0;bottom:0;left:0;margin:0;scroll-snap-type:none}}.md-sidebar__scrollwrap::-webkit-scrollbar{width:.2rem;height:.2rem}.md-sidebar__scrollwrap::-webkit-scrollbar-thumb{background-color:var(--md-default-fg-color--lighter)}.md-sidebar__scrollwrap::-webkit-scrollbar-thumb:hover{background-color:var(--md-accent-fg-color)}@keyframes md-source__facts--done{0%{height:0}100%{height:.65rem}}@keyframes md-source__fact--done{0%{transform:translateY(100%);opacity:0}50%{opacity:0}100%{transform:translateY(0%);opacity:1}}.md-source{display:block;font-size:.65rem;line-height:1.2;white-space:nowrap;backface-visibility:hidden;transition:opacity 250ms}.md-source:hover{opacity:.7}.md-source__icon{display:inline-block;width:2.4rem;height:2.4rem;vertical-align:middle}.md-source__icon svg{margin-top:.6rem;margin-left:.6rem}[dir=rtl] .md-source__icon svg{margin-right:.6rem;margin-left:initial}.md-source__icon+.md-source__repository{margin-left:-2rem;padding-left:2rem}[dir=rtl] .md-source__icon+.md-source__repository{margin-right:-2rem;margin-left:initial;padding-right:2rem;padding-left:initial}.md-source__repository{display:inline-block;max-width:calc(100% - 1.2rem);margin-left:.6rem;overflow:hidden;font-weight:700;text-overflow:ellipsis;vertical-align:middle}.md-source__facts{margin:0;padding:0;overflow:hidden;font-weight:700;font-size:.55rem;list-style-type:none;opacity:.75}[data-md-state=done] .md-source__facts{animation:md-source__facts--done 250ms ease-in}.md-source__fact{float:left}[dir=rtl] .md-source__fact{float:right}[data-md-state=done] .md-source__fact{animation:md-source__fact--done 400ms ease-out}.md-source__fact::before{margin:0 .1rem;content:\"·\"}.md-source__fact:first-child::before{display:none}.md-tabs{width:100%;overflow:auto;color:var(--md-primary-bg-color);background-color:var(--md-primary-fg-color);transition:background 250ms}.no-js .md-tabs{transition:none}@media screen and (max-width: 76.1875em){.md-tabs{display:none}}@media print{.md-tabs{display:none}}.md-tabs__list{margin:0;margin-left:.2rem;padding:0;white-space:nowrap;list-style:none;contain:content}[dir=rtl] .md-tabs__list{margin-right:.2rem;margin-left:initial}.md-tabs__item{display:inline-block;height:2.4rem;padding-right:.6rem;padding-left:.6rem}.md-tabs__link{display:block;margin-top:.8rem;font-size:.7rem;opacity:.7;transition:transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),opacity 250ms}.no-js .md-tabs__link{transition:none}.md-tabs__link--active,.md-tabs__link:hover{color:inherit;opacity:1}.md-tabs__item:nth-child(2) .md-tabs__link{transition-delay:20ms}.md-tabs__item:nth-child(3) .md-tabs__link{transition-delay:40ms}.md-tabs__item:nth-child(4) .md-tabs__link{transition-delay:60ms}.md-tabs__item:nth-child(5) .md-tabs__link{transition-delay:80ms}.md-tabs__item:nth-child(6) .md-tabs__link{transition-delay:100ms}.md-tabs__item:nth-child(7) .md-tabs__link{transition-delay:120ms}.md-tabs__item:nth-child(8) .md-tabs__link{transition-delay:140ms}.md-tabs__item:nth-child(9) .md-tabs__link{transition-delay:160ms}.md-tabs__item:nth-child(10) .md-tabs__link{transition-delay:180ms}.md-tabs__item:nth-child(11) .md-tabs__link{transition-delay:200ms}.md-tabs__item:nth-child(12) .md-tabs__link{transition-delay:220ms}.md-tabs__item:nth-child(13) .md-tabs__link{transition-delay:240ms}.md-tabs__item:nth-child(14) .md-tabs__link{transition-delay:260ms}.md-tabs__item:nth-child(15) .md-tabs__link{transition-delay:280ms}.md-tabs__item:nth-child(16) .md-tabs__link{transition-delay:300ms}.md-tabs[data-md-state=hidden]{pointer-events:none}.md-tabs[data-md-state=hidden] .md-tabs__link{transform:translateY(50%);opacity:0;transition:color 250ms,transform 0ms 400ms,opacity 100ms}@media screen and (min-width: 76.25em){.md-tabs~.md-main .md-nav--primary>.md-nav__list>.md-nav__item--nested{display:none}.md-tabs--active~.md-main .md-nav--primary .md-nav__title{display:block;padding:0 .6rem;pointer-events:none;scroll-snap-align:start}.md-tabs--active~.md-main .md-nav--primary .md-nav__title[for=__drawer]{display:none}.md-tabs--active~.md-main .md-nav--primary>.md-nav__list>.md-nav__item{display:none}.md-tabs--active~.md-main .md-nav--primary>.md-nav__list>.md-nav__item--active{display:block;padding:0}.md-tabs--active~.md-main .md-nav--primary>.md-nav__list>.md-nav__item--active>.md-nav__link{display:none}.md-tabs--active~.md-main .md-nav[data-md-level=\"1\"]>.md-nav__list>.md-nav__item{padding:0 .6rem}.md-tabs--active~.md-main .md-nav[data-md-level=\"1\"] .md-nav .md-nav__title{display:none}}:root{--md-admonition-icon--note: url(\"{{ pencil }}\");--md-admonition-icon--abstract: url(\"{{ text-subject }}\");--md-admonition-icon--info: url(\"{{ information }}\");--md-admonition-icon--tip: url(\"{{ fire }}\");--md-admonition-icon--success: url(\"{{ check-circle }}\");--md-admonition-icon--question: url(\"{{ help-circle }}\");--md-admonition-icon--warning: url(\"{{ alert }}\");--md-admonition-icon--failure: url(\"{{ close-circle }}\");--md-admonition-icon--danger: url(\"{{ flash-circle }}\");--md-admonition-icon--bug: url(\"{{ bug }}\");--md-admonition-icon--example: url(\"{{ format-list-numbered }}\");--md-admonition-icon--quote: url(\"{{ format-quote-close }}\")}.md-typeset .admonition,.md-typeset details{margin:1.5625em 0;padding:0 .6rem;overflow:hidden;font-size:.64rem;page-break-inside:avoid;border-left:.2rem solid #448aff;border-radius:.1rem;box-shadow:0 .2rem .5rem rgba(0,0,0,.05),0 0 .05rem rgba(0,0,0,.1)}[dir=rtl] .md-typeset .admonition,[dir=rtl] .md-typeset details{border-right:.2rem solid #448aff;border-left:none}@media print{.md-typeset .admonition,.md-typeset details{box-shadow:none}}html .md-typeset .admonition>:last-child,html .md-typeset details>:last-child{margin-bottom:.6rem}.md-typeset .admonition .admonition,.md-typeset details .admonition,.md-typeset .admonition details,.md-typeset details details{margin:1em 0}.md-typeset .admonition .md-typeset__scrollwrap,.md-typeset details .md-typeset__scrollwrap{margin:1em -0.6rem}.md-typeset .admonition .md-typeset__table,.md-typeset details .md-typeset__table{padding:0 .6rem}.md-typeset .admonition-title,.md-typeset summary{position:relative;margin:0 -0.6rem;padding:.4rem .6rem .4rem 2rem;font-weight:700;background-color:rgba(68,138,255,.1)}[dir=rtl] .md-typeset .admonition-title,[dir=rtl] .md-typeset summary{padding:.4rem 2rem .4rem .6rem}html .md-typeset .admonition-title:last-child,html .md-typeset summary:last-child{margin-bottom:0}.md-typeset .admonition-title::before,.md-typeset summary::before{position:absolute;left:.6rem;width:1rem;height:1rem;background-color:#448aff;mask-image:var(--md-admonition-icon--note);content:\"\"}[dir=rtl] .md-typeset .admonition-title::before,[dir=rtl] .md-typeset summary::before{right:.6rem;left:initial}.md-typeset .admonition-title code,.md-typeset summary code{margin:initial;padding:initial;color:currentColor;background-color:transparent;border-radius:initial;box-shadow:none}.md-typeset .admonition.note,.md-typeset details.note{border-color:#448aff}.md-typeset .note>.admonition-title,.md-typeset .note>summary{background-color:rgba(68,138,255,.1)}.md-typeset .note>.admonition-title::before,.md-typeset .note>summary::before{background-color:#448aff;mask-image:var(--md-admonition-icon--note)}.md-typeset .admonition.abstract,.md-typeset details.abstract,.md-typeset .admonition.tldr,.md-typeset details.tldr,.md-typeset .admonition.summary,.md-typeset details.summary{border-color:#00b0ff}.md-typeset .abstract>.admonition-title,.md-typeset .abstract>summary,.md-typeset .tldr>.admonition-title,.md-typeset .tldr>summary,.md-typeset .summary>.admonition-title,.md-typeset .summary>summary{background-color:rgba(0,176,255,.1)}.md-typeset .abstract>.admonition-title::before,.md-typeset .abstract>summary::before,.md-typeset .tldr>.admonition-title::before,.md-typeset .tldr>summary::before,.md-typeset .summary>.admonition-title::before,.md-typeset .summary>summary::before{background-color:#00b0ff;mask-image:var(--md-admonition-icon--abstract)}.md-typeset .admonition.info,.md-typeset details.info,.md-typeset .admonition.todo,.md-typeset details.todo{border-color:#00b8d4}.md-typeset .info>.admonition-title,.md-typeset .info>summary,.md-typeset .todo>.admonition-title,.md-typeset .todo>summary{background-color:rgba(0,184,212,.1)}.md-typeset .info>.admonition-title::before,.md-typeset .info>summary::before,.md-typeset .todo>.admonition-title::before,.md-typeset .todo>summary::before{background-color:#00b8d4;mask-image:var(--md-admonition-icon--info)}.md-typeset .admonition.tip,.md-typeset details.tip,.md-typeset .admonition.important,.md-typeset details.important,.md-typeset .admonition.hint,.md-typeset details.hint{border-color:#00bfa5}.md-typeset .tip>.admonition-title,.md-typeset .tip>summary,.md-typeset .important>.admonition-title,.md-typeset .important>summary,.md-typeset .hint>.admonition-title,.md-typeset .hint>summary{background-color:rgba(0,191,165,.1)}.md-typeset .tip>.admonition-title::before,.md-typeset .tip>summary::before,.md-typeset .important>.admonition-title::before,.md-typeset .important>summary::before,.md-typeset .hint>.admonition-title::before,.md-typeset .hint>summary::before{background-color:#00bfa5;mask-image:var(--md-admonition-icon--tip)}.md-typeset .admonition.success,.md-typeset details.success,.md-typeset .admonition.done,.md-typeset details.done,.md-typeset .admonition.check,.md-typeset details.check{border-color:#00c853}.md-typeset .success>.admonition-title,.md-typeset .success>summary,.md-typeset .done>.admonition-title,.md-typeset .done>summary,.md-typeset .check>.admonition-title,.md-typeset .check>summary{background-color:rgba(0,200,83,.1)}.md-typeset .success>.admonition-title::before,.md-typeset .success>summary::before,.md-typeset .done>.admonition-title::before,.md-typeset .done>summary::before,.md-typeset .check>.admonition-title::before,.md-typeset .check>summary::before{background-color:#00c853;mask-image:var(--md-admonition-icon--success)}.md-typeset .admonition.question,.md-typeset details.question,.md-typeset .admonition.faq,.md-typeset details.faq,.md-typeset .admonition.help,.md-typeset details.help{border-color:#64dd17}.md-typeset .question>.admonition-title,.md-typeset .question>summary,.md-typeset .faq>.admonition-title,.md-typeset .faq>summary,.md-typeset .help>.admonition-title,.md-typeset .help>summary{background-color:rgba(100,221,23,.1)}.md-typeset .question>.admonition-title::before,.md-typeset .question>summary::before,.md-typeset .faq>.admonition-title::before,.md-typeset .faq>summary::before,.md-typeset .help>.admonition-title::before,.md-typeset .help>summary::before{background-color:#64dd17;mask-image:var(--md-admonition-icon--question)}.md-typeset .admonition.warning,.md-typeset details.warning,.md-typeset .admonition.attention,.md-typeset details.attention,.md-typeset .admonition.caution,.md-typeset details.caution{border-color:#ff9100}.md-typeset .warning>.admonition-title,.md-typeset .warning>summary,.md-typeset .attention>.admonition-title,.md-typeset .attention>summary,.md-typeset .caution>.admonition-title,.md-typeset .caution>summary{background-color:rgba(255,145,0,.1)}.md-typeset .warning>.admonition-title::before,.md-typeset .warning>summary::before,.md-typeset .attention>.admonition-title::before,.md-typeset .attention>summary::before,.md-typeset .caution>.admonition-title::before,.md-typeset .caution>summary::before{background-color:#ff9100;mask-image:var(--md-admonition-icon--warning)}.md-typeset .admonition.failure,.md-typeset details.failure,.md-typeset .admonition.missing,.md-typeset details.missing,.md-typeset .admonition.fail,.md-typeset details.fail{border-color:#ff5252}.md-typeset .failure>.admonition-title,.md-typeset .failure>summary,.md-typeset .missing>.admonition-title,.md-typeset .missing>summary,.md-typeset .fail>.admonition-title,.md-typeset .fail>summary{background-color:rgba(255,82,82,.1)}.md-typeset .failure>.admonition-title::before,.md-typeset .failure>summary::before,.md-typeset .missing>.admonition-title::before,.md-typeset .missing>summary::before,.md-typeset .fail>.admonition-title::before,.md-typeset .fail>summary::before{background-color:#ff5252;mask-image:var(--md-admonition-icon--failure)}.md-typeset .admonition.danger,.md-typeset details.danger,.md-typeset .admonition.error,.md-typeset details.error{border-color:#ff1744}.md-typeset .danger>.admonition-title,.md-typeset .danger>summary,.md-typeset .error>.admonition-title,.md-typeset .error>summary{background-color:rgba(255,23,68,.1)}.md-typeset .danger>.admonition-title::before,.md-typeset .danger>summary::before,.md-typeset .error>.admonition-title::before,.md-typeset .error>summary::before{background-color:#ff1744;mask-image:var(--md-admonition-icon--danger)}.md-typeset .admonition.bug,.md-typeset details.bug{border-color:#f50057}.md-typeset .bug>.admonition-title,.md-typeset .bug>summary{background-color:rgba(245,0,87,.1)}.md-typeset .bug>.admonition-title::before,.md-typeset .bug>summary::before{background-color:#f50057;mask-image:var(--md-admonition-icon--bug)}.md-typeset .admonition.example,.md-typeset details.example{border-color:#651fff}.md-typeset .example>.admonition-title,.md-typeset .example>summary{background-color:rgba(101,31,255,.1)}.md-typeset .example>.admonition-title::before,.md-typeset .example>summary::before{background-color:#651fff;mask-image:var(--md-admonition-icon--example)}.md-typeset .admonition.quote,.md-typeset details.quote,.md-typeset .admonition.cite,.md-typeset details.cite{border-color:#9e9e9e}.md-typeset .quote>.admonition-title,.md-typeset .quote>summary,.md-typeset .cite>.admonition-title,.md-typeset .cite>summary{background-color:rgba(158,158,158,.1)}.md-typeset .quote>.admonition-title::before,.md-typeset .quote>summary::before,.md-typeset .cite>.admonition-title::before,.md-typeset .cite>summary::before{background-color:#9e9e9e;mask-image:var(--md-admonition-icon--quote)}.codehilite .o,.highlight .o{color:inherit}.codehilite .ow,.highlight .ow{color:inherit}.codehilite .ge,.highlight .ge{color:#000}.codehilite .gr,.highlight .gr{color:#a00}.codehilite .gh,.highlight .gh{color:#999}.codehilite .go,.highlight .go{color:#888}.codehilite .gp,.highlight .gp{color:#555}.codehilite .gs,.highlight .gs{color:inherit}.codehilite .gu,.highlight .gu{color:#aaa}.codehilite .gt,.highlight .gt{color:#a00}.codehilite .gd,.highlight .gd{background-color:#fdd}.codehilite .gi,.highlight .gi{background-color:#dfd}.codehilite .k,.highlight .k{color:#3b78e7}.codehilite .kc,.highlight .kc{color:#a71d5d}.codehilite .kd,.highlight .kd{color:#3b78e7}.codehilite .kn,.highlight .kn{color:#3b78e7}.codehilite .kp,.highlight .kp{color:#a71d5d}.codehilite .kr,.highlight .kr{color:#3e61a2}.codehilite .kt,.highlight .kt{color:#3e61a2}.codehilite .c,.highlight .c{color:#999}.codehilite .cm,.highlight .cm{color:#999}.codehilite .cp,.highlight .cp{color:#666}.codehilite .c1,.highlight .c1{color:#999}.codehilite .ch,.highlight .ch{color:#999}.codehilite .cs,.highlight .cs{color:#999}.codehilite .na,.highlight .na{color:#c2185b}.codehilite .nb,.highlight .nb{color:#c2185b}.codehilite .bp,.highlight .bp{color:#3e61a2}.codehilite .nc,.highlight .nc{color:#c2185b}.codehilite .no,.highlight .no{color:#3e61a2}.codehilite .nd,.highlight .nd{color:#666}.codehilite .ni,.highlight .ni{color:#666}.codehilite .ne,.highlight .ne{color:#c2185b}.codehilite .nf,.highlight .nf{color:#c2185b}.codehilite .nl,.highlight .nl{color:#3b5179}.codehilite .nn,.highlight .nn{color:#ec407a}.codehilite .nt,.highlight .nt{color:#3b78e7}.codehilite .nv,.highlight .nv{color:#3e61a2}.codehilite .vc,.highlight .vc{color:#3e61a2}.codehilite .vg,.highlight .vg{color:#3e61a2}.codehilite .vi,.highlight .vi{color:#3e61a2}.codehilite .nx,.highlight .nx{color:#ec407a}.codehilite .m,.highlight .m{color:#e74c3c}.codehilite .mf,.highlight .mf{color:#e74c3c}.codehilite .mh,.highlight .mh{color:#e74c3c}.codehilite .mi,.highlight .mi{color:#e74c3c}.codehilite .il,.highlight .il{color:#e74c3c}.codehilite .mo,.highlight .mo{color:#e74c3c}.codehilite .s,.highlight .s{color:#0d904f}.codehilite .sb,.highlight .sb{color:#0d904f}.codehilite .sc,.highlight .sc{color:#0d904f}.codehilite .sd,.highlight .sd{color:#999}.codehilite .s2,.highlight .s2{color:#0d904f}.codehilite .se,.highlight .se{color:#183691}.codehilite .sh,.highlight .sh{color:#183691}.codehilite .si,.highlight .si{color:#183691}.codehilite .sx,.highlight .sx{color:#183691}.codehilite .sr,.highlight .sr{color:#009926}.codehilite .s1,.highlight .s1{color:#0d904f}.codehilite .ss,.highlight .ss{color:#0d904f}.codehilite .err,.highlight .err{color:#a61717}.codehilite .w,.highlight .w{color:transparent}.codehilite .hll,.highlight .hll{display:block;margin:0 -1.1764705882em;padding:0 1.1764705882em;background-color:rgba(255,235,59,.5)}.codehilitetable,.highlighttable{display:block;overflow:hidden}.codehilitetable tbody,.highlighttable tbody,.codehilitetable td,.highlighttable td{display:block;padding:0}.codehilitetable tr,.highlighttable tr{display:flex}.codehilitetable pre,.highlighttable pre{margin:0}.codehilitetable .linenos,.highlighttable .linenos{padding:.525rem 1.1764705882em;padding-right:0;font-size:.85em;background-color:var(--md-code-bg-color);user-select:none}.codehilitetable .linenodiv,.highlighttable .linenodiv{padding-right:.5882352941em;box-shadow:inset -0.05rem 0 var(--md-default-fg-color--lightest)}.codehilitetable .linenodiv pre,.highlighttable .linenodiv pre{color:var(--md-default-fg-color--lighter);text-align:right}.codehilitetable .code,.highlighttable .code{flex:1;overflow:hidden}.md-typeset .codehilitetable,.md-typeset .highlighttable{margin:1em 0;direction:ltr;border-radius:.1rem}.md-typeset .codehilitetable code,.md-typeset .highlighttable code{border-radius:0}@media screen and (max-width: 44.9375em){.md-typeset>.codehilite,.md-typeset>.highlight{margin:1em -0.8rem}.md-typeset>.codehilite .hll,.md-typeset>.highlight .hll{margin:0 -0.8rem;padding:0 .8rem}.md-typeset>.codehilite code,.md-typeset>.highlight code{border-radius:0}.md-typeset>.codehilitetable,.md-typeset>.highlighttable{margin:1em -0.8rem;border-radius:0}.md-typeset>.codehilitetable .hll,.md-typeset>.highlighttable .hll{margin:0 -0.8rem;padding:0 .8rem}}:root{--md-footnotes-icon: url(\"{{ keyboard-return }}\")}.md-typeset [id^=\"fnref:\"]{display:inline-block}.md-typeset [id^=\"fnref:\"]:target{margin-top:-3.8rem;padding-top:3.8rem;pointer-events:none}.md-typeset [id^=\"fn:\"]::before{display:none;height:0;content:\"\"}.md-typeset [id^=\"fn:\"]:target::before{display:block;margin-top:-3.5rem;padding-top:3.5rem;pointer-events:none}.md-typeset .footnote{color:var(--md-default-fg-color--light);font-size:.64rem}.md-typeset .footnote ol{margin-left:0}.md-typeset .footnote li{transition:color 125ms}.md-typeset .footnote li:target{color:var(--md-default-fg-color)}.md-typeset .footnote li :first-child{margin-top:0}.md-typeset .footnote li:hover .footnote-backref,.md-typeset .footnote li:target .footnote-backref{transform:translateX(0);opacity:1}.md-typeset .footnote li:hover .footnote-backref:hover{color:var(--md-accent-fg-color)}.md-typeset .footnote-ref{display:inline-block;pointer-events:initial}.md-typeset .footnote-backref{display:inline-block;color:var(--md-primary-fg-color);font-size:0;vertical-align:text-bottom;transform:translateX(0.25rem);opacity:0;transition:color 250ms,transform 250ms 250ms,opacity 125ms 250ms}[dir=rtl] .md-typeset .footnote-backref{transform:translateX(-0.25rem)}.md-typeset .footnote-backref::before{display:inline-block;width:.8rem;height:.8rem;background-color:currentColor;mask-image:var(--md-footnotes-icon);content:\"\"}[dir=rtl] .md-typeset .footnote-backref::before svg{transform:scaleX(-1)}@media print{.md-typeset .footnote-backref{color:var(--md-primary-fg-color);transform:translateX(0);opacity:1}}.md-typeset .headerlink{display:inline-block;margin-left:.5rem;visibility:hidden;opacity:0;transition:color 250ms,visibility 0ms 500ms,opacity 125ms}[dir=rtl] .md-typeset .headerlink{margin-right:.5rem;margin-left:initial}html body .md-typeset .headerlink{color:var(--md-default-fg-color--lighter)}@media print{.md-typeset .headerlink{display:none}}.md-typeset :hover>.headerlink,.md-typeset :target>.headerlink,.md-typeset .headerlink:focus{visibility:visible;opacity:1;transition:color 250ms,visibility 0ms,opacity 125ms}.md-typeset :target>.headerlink,.md-typeset .headerlink:focus,.md-typeset .headerlink:hover{color:var(--md-accent-fg-color)}.md-typeset h3[id]::before,.md-typeset h2[id]::before,.md-typeset h1[id]::before{display:block;margin-top:-0.4rem;padding-top:.4rem;content:\"\"}.md-typeset h3[id]:target::before,.md-typeset h2[id]:target::before,.md-typeset h1[id]:target::before{margin-top:-3.4rem;padding-top:3.4rem}.md-typeset h4[id]::before{display:block;margin-top:-0.45rem;padding-top:.45rem;content:\"\"}.md-typeset h4[id]:target::before{margin-top:-3.45rem;padding-top:3.45rem}.md-typeset h6[id]::before,.md-typeset h5[id]::before{display:block;margin-top:-0.6rem;padding-top:.6rem;content:\"\"}.md-typeset h6[id]:target::before,.md-typeset h5[id]:target::before{margin-top:-3.6rem;padding-top:3.6rem}.md-typeset .MJXc-display{margin:.75em 0;padding:.75em 0;overflow:auto;touch-action:auto}@media screen and (max-width: 44.9375em){.md-typeset>p>.MJXc-display{margin:.75em -0.8rem;padding:.25em .8rem}}.md-typeset .MathJax_CHTML{outline:0}.md-typeset del.critic,.md-typeset ins.critic,.md-typeset .critic.comment{padding:0 .25em;border-radius:.1rem;box-decoration-break:clone}.md-typeset del.critic{background-color:#fdd}.md-typeset ins.critic{background-color:#dfd}.md-typeset .critic.comment{color:#999}.md-typeset .critic.comment::before{content:\"/* \"}.md-typeset .critic.comment::after{content:\" */\"}.md-typeset .critic.block{display:block;margin:1em 0;padding-right:.8rem;padding-left:.8rem;overflow:auto;box-shadow:none}.md-typeset .critic.block :first-child{margin-top:.5em}.md-typeset .critic.block :last-child{margin-bottom:.5em}:root{--md-details-icon: url(\"{{ chevron-right }}\")}.md-typeset details{display:block;padding-top:0;overflow:visible}.md-typeset details[open]>summary::after{transform:rotate(90deg)}.md-typeset details:not([open]){padding-bottom:0}.md-typeset details:not([open])>summary{border-bottom-right-radius:.1rem}.md-typeset details::after{display:table;content:\"\"}.md-typeset summary{display:block;min-height:1rem;padding:.4rem 1.8rem .4rem 2rem;border-top-right-radius:.1rem;cursor:pointer}[dir=rtl] .md-typeset summary{padding:.4rem 2rem .4rem 1.8rem}.md-typeset summary::-webkit-details-marker{display:none}.md-typeset summary::after{position:absolute;top:.4rem;right:.4rem;width:1rem;height:1rem;background-color:currentColor;mask-image:var(--md-details-icon);transform:rotate(0deg);transition:transform 250ms;content:\"\"}[dir=rtl] .md-typeset summary::after{right:initial;left:.4rem;transform:rotate(180deg)}.md-typeset img.emojione,.md-typeset img.twemoji,.md-typeset img.gemoji{width:1.125em;vertical-align:-15%}.md-typeset span.twemoji{display:inline-block;height:1.125em;vertical-align:text-top}.md-typeset span.twemoji svg{width:1.125em;fill:currentColor}.highlight [data-linenos]::before{position:sticky;left:-1.1764705882em;float:left;margin-right:1.1764705882em;margin-left:-1.1764705882em;padding-left:1.1764705882em;color:var(--md-default-fg-color--lighter);background-color:var(--md-code-bg-color);box-shadow:inset -0.05rem 0 var(--md-default-fg-color--lightest);content:attr(data-linenos);user-select:none}.md-typeset .tabbed-content{display:none;order:99;width:100%;box-shadow:0 -0.05rem var(--md-default-fg-color--lightest)}.md-typeset .tabbed-content>.codehilite:only-child pre,.md-typeset .tabbed-content>.codehilitetable:only-child,.md-typeset .tabbed-content>.highlight:only-child pre,.md-typeset .tabbed-content>.highlighttable:only-child{margin:0}.md-typeset .tabbed-content>.codehilite:only-child pre>code,.md-typeset .tabbed-content>.codehilitetable:only-child>code,.md-typeset .tabbed-content>.highlight:only-child pre>code,.md-typeset .tabbed-content>.highlighttable:only-child>code{border-top-left-radius:0;border-top-right-radius:0}.md-typeset .tabbed-content>.tabbed-set{margin:0}.md-typeset .tabbed-set{position:relative;display:flex;flex-wrap:wrap;margin:1em 0;border-radius:.1rem}.md-typeset .tabbed-set>input{display:none}.md-typeset .tabbed-set>input:checked+label{color:var(--md-accent-fg-color);border-color:var(--md-accent-fg-color)}.md-typeset .tabbed-set>input:checked+label+.tabbed-content{display:block}.md-typeset .tabbed-set>label{z-index:1;width:auto;padding:.6rem 1.25em .5rem;color:var(--md-default-fg-color--light);font-weight:700;font-size:.64rem;border-bottom:.1rem solid transparent;cursor:pointer;transition:color 125ms}html .md-typeset .tabbed-set>label:hover{color:var(--md-accent-fg-color)}:root{--md-tasklist-icon: url(\"{{ checkbox-blank-circle }}\");--md-tasklist-icon--checked: url(\"{{ check-circle }}\")}.md-typeset .task-list-item{position:relative;list-style-type:none}.md-typeset .task-list-item [type=checkbox]{position:absolute;top:.45em;left:-2em}[dir=rtl] .md-typeset .task-list-item [type=checkbox]{right:-2em;left:initial}.md-typeset .task-list-control .task-list-indicator::before{position:absolute;top:.15em;left:-1.5em;width:1.25em;height:1.25em;background-color:var(--md-default-fg-color--lightest);mask-image:var(--md-tasklist-icon);content:\"\"}[dir=rtl] .md-typeset .task-list-control .task-list-indicator::before{right:-1.5em;left:initial}.md-typeset .task-list-control [type=checkbox]:checked+.task-list-indicator::before{background-color:#00e676;mask-image:var(--md-tasklist-icon--checked)}.md-typeset .task-list-control [type=checkbox]{z-index:-1;opacity:0}","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// stylelint-disable no-duplicate-selectors\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Enforce correct box model\nhtml {\n box-sizing: border-box;\n}\n\n// All elements shall inherit the document default\n*,\n*::before,\n*::after {\n box-sizing: inherit;\n}\n\n// Prevent adjustments of font size after orientation changes in IE and iOS\nhtml {\n text-size-adjust: none;\n}\n\n// Remove margin in all browsers\nbody {\n margin: 0;\n}\n\n// Reset horizontal rules in FF\nhr {\n box-sizing: content-box;\n overflow: visible;\n}\n\n// Reset tap outlines on iOS and Android\na,\nbutton,\nlabel,\ninput {\n -webkit-tap-highlight-color: transparent;\n}\n\n// Reset link styles\na {\n color: inherit;\n text-decoration: none;\n}\n\n// Normalize font-size in all browsers\nsmall {\n font-size: 80%;\n}\n\n// Prevent subscript and superscript from affecting line-height\nsub,\nsup {\n position: relative;\n font-size: 80%;\n line-height: 0;\n vertical-align: baseline;\n}\n\n// Correct subscript offset\nsub {\n bottom: -0.25em;\n}\n\n// Correct superscript offset\nsup {\n top: -0.5em;\n}\n\n// Remove borders on images\nimg {\n border-style: none;\n}\n\n// Reset table styles\ntable {\n border-collapse: separate;\n border-spacing: 0;\n}\n\n// Reset table cell styles\ntd,\nth {\n font-weight: normal; // stylelint-disable-line\n vertical-align: top;\n}\n\n// Reset button styles\nbutton {\n margin: 0;\n padding: 0;\n font-size: inherit;\n background: transparent;\n border: 0;\n}\n\n// Reset input styles\ninput {\n border: 0;\n outline: 0;\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Color definitions\n:root {\n\n // Default color shades\n --md-default-fg-color: hsla(0, 0%, 0%, 0.87);\n --md-default-fg-color--light: hsla(0, 0%, 0%, 0.54);\n --md-default-fg-color--lighter: hsla(0, 0%, 0%, 0.26);\n --md-default-fg-color--lightest: hsla(0, 0%, 0%, 0.07);\n --md-default-bg-color: hsla(0, 0%, 100%, 1);\n --md-default-bg-color--light: hsla(0, 0%, 100%, 0.7);\n --md-default-bg-color--lighter: hsla(0, 0%, 100%, 0.3);\n --md-default-bg-color--lightest: hsla(0, 0%, 100%, 0.12);\n\n // Primary color shades\n --md-primary-fg-color: hsla(#{hex2hsl($clr-indigo-500)}, 1);\n --md-primary-fg-color--light: hsla(#{hex2hsl($clr-indigo-300)}, 1);\n --md-primary-fg-color--dark: hsla(#{hex2hsl($clr-indigo-700)}, 1);\n --md-primary-bg-color: var(--md-default-bg-color);\n --md-primary-bg-color--light: var(--md-default-bg-color--light);\n\n // Accent color shades\n --md-accent-fg-color: hsla(#{hex2hsl($clr-indigo-a200)}, 1);\n --md-accent-fg-color--transparent: hsla(#{hex2hsl($clr-indigo-a200)}, 0.1);\n --md-accent-bg-color: var(--md-default-bg-color);\n --md-accent-bg-color--light: var(--md-default-bg-color--light);\n\n // Code block color shades\n --md-code-bg-color: hsla(0, 0%, 96%, 1);\n --md-code-fg-color: hsla(200, 18%, 26%, 1);\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Icon\n.md-icon {\n\n // SVG defaults\n svg {\n display: block;\n width: px2rem(24px);\n height: px2rem(24px);\n margin: 0 auto;\n fill: currentColor;\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules: font definitions\n// ----------------------------------------------------------------------------\n\n// Enable font-smoothing in Webkit and FF\nbody {\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n// Default fonts\nbody,\ninput {\n color: var(--md-default-fg-color);\n font-feature-settings: \"kern\", \"liga\";\n font-family: -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;\n}\n\n// Proportionally spaced fonts\ncode,\npre,\nkbd {\n color: var(--md-default-fg-color);\n font-feature-settings: \"kern\";\n font-family: SFMono-Regular, Consolas, Menlo, monospace;\n}\n\n// ----------------------------------------------------------------------------\n// Rules: typesetted content\n// ----------------------------------------------------------------------------\n\n// Content that is typeset - if possible, all margins, paddings and font sizes\n// should be set in ems, so nested blocks (e.g. Admonition) render correctly,\n// except headlines that should only appear on the top level and need to have\n// consistent spacing due to layout constraints.\n.md-typeset {\n font-size: ms(0);\n line-height: 1.6;\n color-adjust: exact;\n\n // Default spacing\n p,\n ul,\n ol,\n blockquote {\n margin: 1em 0;\n }\n\n // 1st level headline\n h1 {\n margin: 0 0 px2rem(40px);\n color: var(--md-default-fg-color--light);\n font-weight: 300;\n font-size: ms(3);\n line-height: 1.3;\n letter-spacing: -0.01em;\n }\n\n // 2nd level headline\n h2 {\n margin: px2rem(40px) 0 px2rem(16px);\n font-weight: 300;\n font-size: ms(2);\n line-height: 1.4;\n letter-spacing: -0.01em;\n }\n\n // 3rd level headline\n h3 {\n margin: px2rem(32px) 0 px2rem(16px);\n font-weight: 400;\n font-size: ms(1);\n line-height: 1.5;\n letter-spacing: -0.01em;\n }\n\n // 3rd level headline following an 2nd level headline\n h2 + h3 {\n margin-top: px2rem(16px);\n }\n\n // 4th level headline\n h4 {\n margin: px2rem(16px) 0;\n font-weight: 700;\n font-size: ms(0);\n letter-spacing: -0.01em;\n }\n\n // 5th and 6th level headline\n h5,\n h6 {\n margin: px2rem(16px) 0;\n color: var(--md-default-fg-color--light);\n font-weight: 700;\n font-size: ms(-1);\n letter-spacing: -0.01em;\n }\n\n // Overrides for 5th level headline\n h5 {\n text-transform: uppercase;\n }\n\n // Horizontal separators\n hr {\n margin: 1.5em 0;\n border-bottom: px2rem(1px) dotted var(--md-default-fg-color--lighter);\n }\n\n // Links\n a {\n color: var(--md-primary-fg-color);\n word-break: break-word;\n\n // Also enable color transition on pseudo elements\n &,\n &::before {\n transition: color 125ms;\n }\n\n // Focused or hover links\n &:focus,\n &:hover {\n color: var(--md-accent-fg-color);\n }\n }\n\n // Code blocks\n code,\n pre,\n kbd {\n color: var(--md-code-fg-color);\n direction: ltr;\n\n // Wrap text and hide scollbars\n @media print {\n white-space: pre-wrap;\n }\n }\n\n // Inline code blocks\n code {\n padding: 0 px2em(4px, 13.6px);\n font-size: px2em(13.6px);\n word-break: break-word;\n background-color: var(--md-code-bg-color);\n border-radius: px2rem(2px);\n box-decoration-break: clone;\n }\n\n // Disable containing block inside headlines\n h1 code,\n h2 code,\n h3 code,\n h4 code,\n h5 code,\n h6 code {\n margin: initial;\n padding: initial;\n background-color: transparent;\n box-shadow: none;\n }\n\n // Ensure link color in code blocks\n a > code {\n color: currentColor;\n }\n\n // Unformatted code blocks\n pre {\n position: relative;\n margin: 1em 0;\n line-height: 1.4;\n\n // Actual container with code, overflowing\n > code {\n display: block;\n margin: 0;\n padding: px2rem(10.5px) px2em(16px, 13.6px);\n overflow: auto;\n word-break: normal;\n box-shadow: none;\n box-decoration-break: slice;\n touch-action: auto;\n\n // Override native scrollbar styles\n &::-webkit-scrollbar {\n width: px2rem(4px);\n height: px2rem(4px);\n }\n\n // Scrollbar thumb\n &::-webkit-scrollbar-thumb {\n background-color: var(--md-default-fg-color--lighter);\n\n // Hovered scrollbar thumb\n &:hover {\n background-color: var(--md-accent-fg-color);\n }\n }\n }\n }\n\n // [mobile -]: Stretch to whole width\n @include break-to-device(mobile) {\n\n // Stretch top-level containers\n > pre {\n margin: 1em px2rem(-16px);\n\n // Remove rounded borders\n code {\n border-radius: 0;\n }\n }\n }\n\n // Keystrokes\n kbd {\n display: inline-block;\n padding: 0 px2em(8px, 12px);\n font-size: px2em(12px);\n line-height: 1.5;\n vertical-align: text-top;\n word-break: break-word;\n border-radius: px2rem(2px);\n box-shadow:\n 0 px2rem(2px) 0 px2rem(1px) var(--md-default-fg-color--lighter),\n 0 px2rem(2px) 0 var(--md-default-fg-color--lighter),\n inset 0 px2rem(-2px) px2rem(4px) var(--md-default-bg-color);\n }\n\n // Text highlighting marker\n mark {\n padding: 0 px2em(4px, 16px);\n word-break: break-word;\n background-color: transparentize($clr-yellow-500, 0.5);\n border-radius: px2rem(2px);\n box-decoration-break: clone;\n }\n\n // Abbreviations\n abbr {\n text-decoration: none;\n border-bottom: px2rem(1px) dotted var(--md-default-fg-color--light);\n cursor: help;\n }\n\n // Small text\n small {\n opacity: 0.75;\n }\n\n // Superscript and subscript\n sup,\n sub {\n margin-left: px2em(1px, 12.8px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n margin-right: px2em(1px, 12.8px);\n margin-left: initial;\n }\n }\n\n // Blockquotes, possibly nested\n blockquote {\n padding-left: px2rem(12px);\n color: var(--md-default-fg-color--light);\n border-left: px2rem(4px) solid var(--md-default-fg-color--lighter);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n padding-right: px2rem(12px);\n padding-left: initial;\n border-right: px2rem(4px) solid var(--md-default-fg-color--lighter);\n border-left: initial;\n }\n }\n\n // Unordered lists\n ul {\n list-style-type: disc;\n }\n\n // Unordered and ordered lists\n ul,\n ol {\n margin-left: px2em(10px, 16px);\n padding: 0;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n margin-right: px2em(10px, 16px);\n margin-left: initial;\n }\n\n // Nested ordered lists\n ol {\n list-style-type: lower-alpha;\n\n // Triply nested ordered list\n ol {\n list-style-type: lower-roman;\n }\n }\n\n // List elements\n li {\n margin-bottom: 0.5em;\n margin-left: px2em(20px, 16px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n margin-right: px2em(20px, 16px);\n margin-left: initial;\n }\n\n // Decrease vertical spacing\n p,\n blockquote {\n margin: 0.5em 0;\n }\n\n // Remove margin on last element\n &:last-child {\n margin-bottom: 0;\n }\n\n // Nested lists\n ul,\n ol {\n margin: 0.5em 0 0.5em px2em(10px, 16px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n margin-right: px2em(10px, 16px);\n margin-left: initial;\n }\n }\n }\n }\n\n // Definition lists\n dd {\n margin: 1em 0 1em px2em(30px, 16px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n margin-right: px2em(30px, 16px);\n margin-left: initial;\n }\n }\n\n // Limit width to container\n iframe,\n img,\n svg {\n max-width: 100%;\n }\n\n // Data tables\n table:not([class]) {\n display: inline-block;\n max-width: 100%;\n overflow: auto;\n font-size: ms(-1);\n background: var(--md-default-bg-color);\n border-radius: px2rem(2px);\n box-shadow:\n 0 px2rem(4px) px2rem(10px) hsla(0, 0%, 0%, 0.05),\n 0 0 px2rem(1px) hsla(0, 0%, 0%, 0.1);\n touch-action: auto;\n\n // Due to margin collapse because of the necessary inline-block hack, we\n // cannot increase the bottom margin on the table, so we just increase the\n // top margin on the following element\n & + * {\n margin-top: 1.5em;\n }\n\n // Table headings and cells\n th:not([align]),\n td:not([align]) {\n text-align: left;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n text-align: right;\n }\n }\n\n // Table headings\n th {\n min-width: px2rem(100px);\n padding: px2rem(12px) px2rem(16px);\n color: var(--md-default-bg-color);\n vertical-align: top;\n background-color: var(--md-default-fg-color--light);\n }\n\n // Table cells\n td {\n padding: px2rem(12px) px2rem(16px);\n vertical-align: top;\n border-top: px2rem(1px) solid var(--md-default-fg-color--lightest);\n }\n\n // Table rows\n tr {\n transition: background-color 125ms;\n\n // Add background on hover\n &:hover {\n background-color: rgba(0, 0, 0, 0.035);\n box-shadow: 0 px2rem(1px) 0 var(--md-default-bg-color) inset;\n }\n\n // Remove top border on first row\n &:first-child td {\n border-top: 0;\n }\n }\n\n\n // Do not wrap links in tables\n a {\n word-break: normal;\n }\n }\n\n // Wrapper for scrolling on overflow\n &__scrollwrap {\n margin: 1em px2rem(-16px);\n overflow-x: auto;\n touch-action: auto;\n }\n\n // Data table wrapper, in case JavaScript is available\n &__table {\n display: inline-block;\n margin-bottom: 0.5em;\n padding: 0 px2rem(16px);\n\n // Data tables\n table {\n display: table;\n width: 100%;\n margin: 0;\n overflow: hidden;\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Variables\n// ----------------------------------------------------------------------------\n\n// Active (toggled) drawer\n$md-toggle__drawer--checked:\n \"[data-md-toggle=\\\"drawer\\\"]:checked ~\";\n\n// ----------------------------------------------------------------------------\n// Rules: base grid and containers\n// ----------------------------------------------------------------------------\n\n// Stretch container to viewport and set base font-sizefor simple calculations\n// based on relative ems (rems)\nhtml {\n height: 100%;\n // Hack: some browsers on some operating systems don't account for scroll\n // bars when firing media queries, so we need to do this for safety. This\n // currently impacts the table of contents component between 1220 and 1234px\n // and is to current knowledge not fixable.\n overflow-x: hidden;\n // Hack: normally, we would set the base font-size to 62.5%, so we can base\n // all calculations on 10px, but Chromium and Chrome define a minimal font\n // size of 12 if the system language is set to Chinese. For this reason we\n // just double the font-size, set it to 20px which seems to do the trick.\n //\n // See https://github.com/squidfunk/mkdocs-material/issues/911\n font-size: 125%;\n background-color: var(--md-default-bg-color);\n\n // [screen medium +]: Set base font-size to 11px\n @include break-from-device(screen medium) {\n font-size: 137.50%;\n }\n\n // [screen large +]: Set base font-size to 12px\n @include break-from-device(screen large) {\n font-size: 150%;\n }\n}\n\n// Stretch body to container and leave room for footer\nbody {\n position: relative;\n display: flex;\n flex-direction: column;\n width: 100%;\n min-height: 100%;\n // Hack: reset font-size to 10px, so the spacing for all inline elements is\n // correct again. Otherwise the spacing would be based on 20px.\n font-size: 0.5rem; // stylelint-disable-line unit-whitelist\n\n // [tablet portrait -]: Lock body to disable scroll bubbling\n @include break-to-device(tablet portrait) {\n\n // Lock body to viewport height (e.g. in search mode)\n &[data-md-state=\"lock\"] {\n position: fixed;\n }\n }\n\n // Hack: we must not use flex, or Firefox will only print the first page\n // see https://mzl.la/39DgR3m\n @media print {\n display: block;\n }\n}\n\n// Horizontal separators\nhr {\n display: block;\n height: px2rem(1px);\n padding: 0;\n border: 0;\n}\n\n// Template-wide grid\n.md-grid {\n max-width: px2rem(1220px);\n margin-right: auto;\n margin-left: auto;\n}\n\n// Content wrapper\n.md-container {\n display: flex;\n flex-direction: column;\n flex-grow: 1;\n\n // Hack: we must not use flex, or Firefox will only print the first page\n // see https://mzl.la/39DgR3m\n @media print {\n display: block;\n }\n}\n\n// The main content should stretch to maximum height in the table\n.md-main {\n flex-grow: 1;\n\n // Increase top spacing of content area to give typography more room\n &__inner {\n height: 100%;\n margin-top: px2rem(24px + 6px);\n }\n}\n\n// Apply ellipsis in case of overflowing text\n.md-ellipsis {\n display: block;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n\n// ----------------------------------------------------------------------------\n// Rules: navigational elements\n// ----------------------------------------------------------------------------\n\n// Toggle checkbox\n.md-toggle {\n display: none;\n}\n\n// Overlay below expanded drawer\n.md-overlay {\n position: fixed;\n top: 0;\n z-index: 3;\n width: 0;\n height: 0;\n background-color: var(--md-default-fg-color--light);\n opacity: 0;\n transition:\n width 0ms 250ms,\n height 0ms 250ms,\n opacity 250ms;\n\n // [tablet -]: Trigger overlay\n @include break-to-device(tablet) {\n\n // Expanded drawer\n #{$md-toggle__drawer--checked} & {\n width: 100%;\n height: 100%;\n opacity: 1;\n transition:\n width 0ms,\n height 0ms,\n opacity 250ms;\n }\n }\n}\n\n// ----------------------------------------------------------------------------\n// Rules: skip link\n// ----------------------------------------------------------------------------\n\n// Skip link\n.md-skip {\n position: fixed;\n // Hack: if we don't set the negative z-index, the skip link will induce the\n // creation of new layers when code blocks are near the header on scrolling\n z-index: -1;\n margin: px2rem(10px);\n padding: px2rem(6px) px2rem(10px);\n color: var(--md-default-bg-color);\n font-size: ms(-1);\n background-color: var(--md-default-fg-color);\n border-radius: px2rem(2px);\n transform: translateY(px2rem(8px));\n opacity: 0;\n\n // Show skip link on focus\n &:focus {\n z-index: 10;\n transform: translateY(0);\n opacity: 1;\n transition:\n transform 250ms cubic-bezier(0.4, 0, 0.2, 1),\n opacity 175ms 75ms;\n }\n}\n\n// ----------------------------------------------------------------------------\n// Rules: print styles\n// ----------------------------------------------------------------------------\n\n// Add margins to page\n@page {\n margin: 25mm;\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Announcement bar\n.md-announce {\n overflow: auto;\n background-color: var(--md-default-fg-color);\n\n // Actual content\n &__inner {\n margin: px2rem(12px) auto;\n padding: 0 px2rem(16px);\n color: var(--md-default-bg-color);\n font-size: px2rem(14px);\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Scoped in typesetted content to match specificity of regular content\n.md-typeset {\n\n // Button\n .md-button {\n display: inline-block;\n padding: px2em(10px, 16px) px2em(32px, 16px);\n color: var(--md-primary-fg-color);\n font-weight: 700;\n border: px2rem(2px) solid currentColor;\n border-radius: px2rem(2px);\n transition:\n color 125ms,\n background-color 125ms,\n border-color 125ms;\n\n // Primary button\n &--primary {\n color: var(--md-primary-bg-color);\n background-color: var(--md-primary-fg-color);\n border-color: var(--md-primary-fg-color);\n }\n\n // Focused or hovered button\n &:focus,\n &:hover {\n color: var(--md-accent-bg-color);\n background-color: var(--md-accent-fg-color);\n border-color: var(--md-accent-fg-color);\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Copy to clipboard\n.md-clipboard {\n position: absolute;\n top: px2rem(8px);\n right: px2em(8px, 16px);\n z-index: 1;\n width: px2em(24px, 16px);\n height: px2em(24px, 16px);\n color: var(--md-default-fg-color--lightest);\n border-radius: px2rem(2px);\n cursor: pointer;\n transition: color 125ms;\n\n // Hide for print\n @media print {\n display: none;\n }\n\n // Slightly smaller icon\n svg {\n width: px2em(18px, 16px);\n height: px2em(18px, 16px);\n }\n\n // Show on container hover\n pre:hover & {\n color: var(--md-default-fg-color--light);\n }\n\n // Focused or hovered icon\n pre &:focus,\n pre &:hover {\n color: var(--md-accent-fg-color);\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Content container\n.md-content {\n\n // [tablet landscape +]: Add space for table of contents\n @include break-from-device(tablet landscape) {\n margin-right: px2rem(242px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n margin-right: initial;\n margin-left: px2rem(242px);\n }\n }\n\n // [screen +]: Add space for table of contents\n @include break-from-device(screen) {\n margin-left: px2rem(242px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n margin-right: px2rem(242px);\n }\n }\n\n // Define spacing\n &__inner {\n margin: 0 px2rem(16px) px2rem(24px);\n padding-top: px2rem(12px);\n\n // [screen +]: Increase horizontal spacing\n @include break-from-device(screen) {\n margin-right: px2rem(24px);\n margin-left: px2rem(24px);\n }\n\n // Hack: add pseudo element for spacing, as the overflow of the content\n // container may not be hidden due to an imminent offset error on targets\n &::before {\n display: block;\n height: px2rem(8px);\n content: \"\";\n }\n\n // Hack: remove bottom spacing of last element, due to margin collapse\n > :last-child {\n margin-bottom: 0;\n }\n }\n\n // Button next to the title\n &__button {\n float: right;\n margin: px2rem(8px) 0;\n margin-left: px2rem(8px);\n padding: 0;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n float: left;\n margin-right: px2rem(8px);\n margin-left: initial;\n\n // Flip icon vertically\n svg {\n transform: scaleX(-1);\n }\n }\n\n // Override default link color for icons\n .md-typeset & {\n color: var(--md-default-fg-color--lighter);\n }\n\n // Align text with icon\n svg {\n display: inline;\n vertical-align: top;\n }\n\n // Hide for print\n @media print {\n display: none;\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Dialog rendered as snackbar\n.md-dialog {\n @include z-depth(2);\n\n position: fixed;\n right: px2rem(16px);\n bottom: px2rem(16px);\n left: initial;\n z-index: 2;\n display: block;\n min-width: px2rem(222px);\n padding: px2rem(8px) px2rem(12px);\n color: var(--md-default-bg-color);\n font-size: px2rem(14px);\n background: var(--md-default-fg-color);\n border: none;\n border-radius: px2rem(2px);\n transform: translateY(100%);\n opacity: 0;\n transition:\n transform 0ms 400ms,\n opacity 400ms;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n right: initial;\n left: px2rem(16px);\n }\n\n // Show open dialog\n &[data-md-state=\"open\"] {\n transform: translateY(0);\n opacity: 1;\n transition:\n transform 400ms cubic-bezier(0.075, 0.85, 0.175, 1),\n opacity 400ms;\n }\n\n // Hide for print\n @media print {\n display: none;\n }\n}\n","//\n// Name: Material Shadows\n// Description: Mixins for Material Design Shadows.\n// Version: 3.0.1\n//\n// Author: Denis Malinochkin\n// Git: https://github.com/mrmlnc/material-shadows\n//\n// twitter: @mrmlnc\n//\n// ------------------------------------\n\n\n// Mixins\n// ------------------------------------\n\n@mixin z-depth-transition() {\n transition: box-shadow .28s cubic-bezier(.4, 0, .2, 1);\n}\n\n@mixin z-depth-focus() {\n box-shadow: 0 0 8px rgba(0, 0, 0, .18), 0 8px 16px rgba(0, 0, 0, .36);\n}\n\n@mixin z-depth-2dp() {\n box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14),\n 0 1px 5px 0 rgba(0, 0, 0, .12),\n 0 3px 1px -2px rgba(0, 0, 0, .2);\n}\n\n@mixin z-depth-3dp() {\n box-shadow: 0 3px 4px 0 rgba(0, 0, 0, .14),\n 0 1px 8px 0 rgba(0, 0, 0, .12),\n 0 3px 3px -2px rgba(0, 0, 0, .4);\n}\n\n@mixin z-depth-4dp() {\n box-shadow: 0 4px 5px 0 rgba(0, 0, 0, .14),\n 0 1px 10px 0 rgba(0, 0, 0, .12),\n 0 2px 4px -1px rgba(0, 0, 0, .4);\n}\n\n@mixin z-depth-6dp() {\n box-shadow: 0 6px 10px 0 rgba(0, 0, 0, .14),\n 0 1px 18px 0 rgba(0, 0, 0, .12),\n 0 3px 5px -1px rgba(0, 0, 0, .4);\n}\n\n@mixin z-depth-8dp() {\n box-shadow: 0 8px 10px 1px rgba(0, 0, 0, .14),\n 0 3px 14px 2px rgba(0, 0, 0, .12),\n 0 5px 5px -3px rgba(0, 0, 0, .4);\n}\n\n@mixin z-depth-16dp() {\n box-shadow: 0 16px 24px 2px rgba(0, 0, 0, .14),\n 0 6px 30px 5px rgba(0, 0, 0, .12),\n 0 8px 10px -5px rgba(0, 0, 0, .4);\n}\n\n@mixin z-depth-24dp() {\n box-shadow: 0 9px 46px 8px rgba(0, 0, 0, .14),\n 0 24px 38px 3px rgba(0, 0, 0, .12),\n 0 11px 15px -7px rgba(0, 0, 0, .4);\n}\n\n@mixin z-depth($dp: 2) {\n @if $dp == 2 {\n @include z-depth-2dp();\n } @else if $dp == 3 {\n @include z-depth-3dp();\n } @else if $dp == 4 {\n @include z-depth-4dp();\n } @else if $dp == 6 {\n @include z-depth-6dp();\n } @else if $dp == 8 {\n @include z-depth-8dp();\n } @else if $dp == 16 {\n @include z-depth-16dp();\n } @else if $dp == 24 {\n @include z-depth-24dp();\n }\n}\n\n\n// Class generator\n// ------------------------------------\n\n@mixin z-depth-classes($transition: false, $focus: false) {\n @if $transition == true {\n &-transition {\n @include z-depth-transition();\n }\n }\n\n @if $focus == true {\n &-focus {\n @include z-depth-focus();\n }\n }\n\n // The available values for the shadow depth\n @each $depth in 2, 3, 4, 6, 8, 16, 24 {\n &-#{$depth}dp {\n @include z-depth($depth);\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Application header (stays always on top)\n.md-header {\n position: sticky;\n top: 0;\n right: 0;\n left: 0;\n z-index: 2;\n height: px2rem(48px);\n color: var(--md-primary-bg-color);\n background-color: var(--md-primary-fg-color);\n // Hack: reduce jitter by adding a transparent box shadow of the same size\n // so the size of the layer doesn't change during animation\n box-shadow:\n 0 0 px2rem(4px) rgba(0, 0, 0, 0),\n 0 px2rem(4px) px2rem(8px) rgba(0, 0, 0, 0);\n transition:\n color 250ms,\n background-color 250ms;\n\n // Always hide shadow, in case JavaScript is not available\n .no-js & {\n box-shadow: none;\n transition: none;\n }\n\n // Show and animate shadow\n &[data-md-state=\"shadow\"] {\n box-shadow:\n 0 0 px2rem(4px) rgba(0, 0, 0, 0.1),\n 0 px2rem(4px) px2rem(8px) rgba(0, 0, 0, 0.2);\n transition:\n color 250ms,\n background-color 250ms,\n box-shadow 250ms;\n }\n\n // Hide for print\n @media print {\n display: none;\n }\n}\n\n// Navigation within header\n.md-header-nav {\n display: flex;\n padding: 0 px2rem(4px);\n\n // Icon buttons\n &__button {\n position: relative;\n z-index: 1;\n margin: px2rem(4px);\n padding: px2rem(8px);\n cursor: pointer;\n transition: opacity 250ms;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n\n // Flip icon vertically\n svg {\n transform: scaleX(-1);\n }\n }\n\n // Focused or hovered icon\n &:focus,\n &:hover {\n opacity: 0.7;\n }\n\n // Logo\n &.md-logo {\n margin: px2rem(4px);\n padding: px2rem(8px);\n\n // Image or icon\n img,\n svg {\n display: block;\n width: px2rem(24px);\n height: px2rem(24px);\n fill: currentColor;\n }\n }\n\n // Hide search icon, if JavaScript is not available.\n .no-js &[for=\"__search\"] {\n display: none;\n }\n\n // [tablet landscape +]: Hide the search button\n @include break-from-device(tablet landscape) {\n\n // Search button\n &[for=\"__search\"] {\n display: none;\n }\n }\n\n // [tablet -]: Hide the logo\n @include break-to-device(tablet) {\n\n // Logo\n &.md-logo {\n display: none;\n }\n }\n\n // [screen +]: Hide the menu button\n @include break-from-device(screen) {\n\n // Menu button\n &[for=\"__drawer\"] {\n display: none;\n }\n }\n }\n\n // Header topics\n &__topic {\n position: absolute;\n width: 100%;\n transition:\n transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),\n opacity 150ms;\n\n // Page title\n & + & {\n z-index: -1;\n transform: translateX(px2rem(25px));\n opacity: 0;\n transition:\n transform 400ms cubic-bezier(1, 0.7, 0.1, 0.1),\n opacity 150ms;\n pointer-events: none;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n transform: translateX(px2rem(-25px));\n }\n }\n\n // Induce ellipsis, if no JavaScript is available\n .no-js & {\n position: initial;\n }\n\n // Hide page title as it is invisible anyway and will overflow the header\n .no-js & + & {\n display: none;\n }\n }\n\n // Header title - set line height to match icon for correct alignment\n &__title {\n flex-grow: 1;\n padding: 0 px2rem(20px);\n font-size: px2rem(18px);\n line-height: px2rem(48px);\n\n // Show page title\n &[data-md-state=\"active\"] .md-header-nav__topic {\n z-index: -1;\n transform: translateX(px2rem(-25px));\n opacity: 0;\n transition:\n transform 400ms cubic-bezier(1, 0.7, 0.1, 0.1),\n opacity 150ms;\n pointer-events: none;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n transform: translateX(px2rem(25px));\n }\n\n // Page title\n & + .md-header-nav__topic {\n z-index: 0;\n transform: translateX(0);\n opacity: 1;\n transition:\n transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),\n opacity 150ms;\n pointer-events: initial;\n }\n }\n\n // Patch ellipsis\n > .md-header-nav__ellipsis {\n position: relative;\n width: 100%;\n height: 100%;\n }\n }\n\n // Repository containing source\n &__source {\n display: none;\n\n // [tablet landscape +]: Show the reposistory from tablet\n @include break-from-device(tablet landscape) {\n display: block;\n width: px2rem(234px);\n max-width: px2rem(234px);\n margin-left: px2rem(20px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n margin-right: px2rem(20px);\n margin-left: initial;\n }\n }\n\n // [screen +]: Increase spacing of search bar\n @include break-from-device(screen) {\n margin-left: px2rem(28px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n margin-right: px2rem(28px);\n }\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Hero teaser\n.md-hero {\n overflow: hidden;\n color: var(--md-primary-bg-color);\n font-size: ms(1);\n background-color: var(--md-primary-fg-color);\n transition: background 250ms;\n\n // Inner wrapper\n &__inner {\n margin-top: px2rem(20px);\n padding: px2rem(16px) px2rem(16px) px2rem(8px);\n transition:\n transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),\n opacity 250ms;\n transition-delay: 100ms;\n\n // [tablet -]: Compensate for missing tabs\n @include break-to-device(tablet) {\n margin-top: px2rem(48px);\n margin-bottom: px2rem(24px);\n }\n\n // Fade-out tabs background upon scrolling\n [data-md-state=\"hidden\"] & {\n transform: translateY(px2rem(12.5px));\n opacity: 0;\n transition:\n transform 0ms 400ms,\n opacity 100ms 0ms;\n pointer-events: none;\n }\n\n // Adjust bottom spacing if there are no tabs\n .md-hero--expand & {\n margin-bottom: px2rem(24px);\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Application footer\n.md-footer {\n color: var(--md-default-bg-color);\n background-color: var(--md-default-fg-color);\n\n // Hide for print\n @media print {\n display: none;\n }\n}\n\n// Navigation within footer\n.md-footer-nav {\n\n // Set spacing\n &__inner {\n padding: px2rem(4px);\n overflow: auto;\n }\n\n // Links to previous and next page\n &__link {\n display: flex;\n padding-top: px2rem(28px);\n padding-bottom: px2rem(8px);\n transition: opacity 250ms;\n\n // [tablet +]: Set proportional width\n @include break-from-device(tablet) {\n width: 50%;\n }\n\n // Focused or hovered links\n &:focus,\n &:hover {\n opacity: 0.7;\n }\n\n // Link to previous page\n &--prev {\n float: left;\n width: 25%;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n float: right;\n\n // Flip icon vertically\n svg {\n transform: scaleX(-1);\n }\n }\n\n // Title\n .md-footer-nav__title {\n\n // [mobile -]: Hide title for previous page\n @include break-to-device(mobile) {\n display: none;\n }\n }\n }\n\n // Link to next page\n &--next {\n float: right;\n width: 75%;\n text-align: right;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n float: left;\n text-align: left;\n\n // Flip icon vertically\n svg {\n transform: scaleX(-1);\n }\n }\n }\n }\n\n // Link title - set line height to match icon for correct alignment\n &__title {\n position: relative;\n flex-grow: 1;\n max-width: calc(100% - #{px2rem(48px)});\n padding: 0 px2rem(20px);\n font-size: px2rem(18px);\n line-height: px2rem(48px);\n }\n\n // Link button\n &__button {\n margin: px2rem(4px);\n padding: px2rem(8px);\n }\n\n // Link direction\n &__direction {\n position: absolute;\n right: 0;\n left: 0;\n margin-top: px2rem(-20px);\n padding: 0 px2rem(20px);\n color: var(--md-default-bg-color--light);\n font-size: ms(-1);\n }\n}\n\n// Non-navigational information\n.md-footer-meta {\n background-color: var(--md-default-fg-color--lighter);\n\n // Set spacing\n &__inner {\n display: flex;\n flex-wrap: wrap;\n justify-content: space-between;\n padding: px2rem(4px);\n }\n\n // Use a decent color for non-hovered links and ensure specificity\n html &.md-typeset a {\n color: var(--md-default-bg-color--light);\n\n // Focused or hovered link\n &:focus,\n &:hover {\n color: var(--md-default-bg-color);\n }\n }\n}\n\n// Copyright and theme information\n.md-footer-copyright {\n width: 100%;\n margin: auto px2rem(12px);\n padding: px2rem(8px) 0;\n color: var(--md-default-bg-color--lighter);\n font-size: ms(-1);\n\n // [tablet portrait +]: Show next to social media links\n @include break-from-device(tablet portrait) {\n width: auto;\n }\n\n // Highlight copyright information\n &__highlight {\n color: var(--md-default-bg-color--light);\n }\n}\n\n// Social links\n.md-footer-social {\n margin: 0 px2rem(8px);\n padding: px2rem(4px) 0 px2rem(12px);\n\n // [tablet portrait +]: Show next to copyright information\n @include break-from-device(tablet portrait) {\n padding: px2rem(12px) 0;\n }\n\n // Link with icon\n &__link {\n display: inline-block;\n width: px2rem(32px);\n height: px2rem(32px);\n text-align: center;\n\n // Adjust line-height to match height for correct alignment\n &::before {\n line-height: 1.9;\n }\n\n // Social icon\n svg {\n max-height: px2rem(16px);\n vertical-align: -25%;\n fill: currentColor;\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Navigation container\n.md-nav {\n font-size: px2rem(14px);\n line-height: 1.3;\n\n // List title\n &__title {\n display: block;\n padding: 0 px2rem(12px);\n overflow: hidden;\n font-weight: 700;\n text-overflow: ellipsis;\n\n // Hide buttons by default\n .md-nav__button {\n display: none;\n\n // Stretch images\n img {\n width: 100%;\n height: auto;\n }\n\n // Logo\n &.md-logo {\n\n // Image or icon\n img,\n svg {\n display: block;\n width: px2rem(48px);\n height: px2rem(48px);\n }\n\n // Icon\n svg {\n fill: currentColor;\n }\n }\n }\n }\n\n // List of items\n &__list {\n margin: 0;\n padding: 0;\n list-style: none;\n }\n\n // List item\n &__item {\n padding: 0 px2rem(12px);\n\n // Add bottom spacing to last item\n &:last-child {\n padding-bottom: px2rem(12px);\n }\n\n // 2nd+ level items\n & & {\n padding-right: 0;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n padding-right: px2rem(12px);\n padding-left: 0;\n }\n\n // Remove bottom spacing for nested items\n &:last-child {\n padding-bottom: 0;\n }\n }\n }\n\n // Link inside item\n &__link {\n display: block;\n margin-top: 0.625em;\n overflow: hidden;\n text-overflow: ellipsis;\n cursor: pointer;\n transition: color 125ms;\n scroll-snap-align: start;\n\n // Hide link to table of contents by default - this will only match the\n // table of contents inside the drawer below and including tablet portrait\n html &[for=\"__toc\"] {\n display: none;\n\n // Hide table of contents by default\n & ~ .md-nav {\n display: none;\n }\n }\n\n // Blurred link\n &[data-md-state=\"blur\"] {\n color: var(--md-default-fg-color--light);\n }\n\n // Active link\n .md-nav__item &--active {\n color: var(--md-primary-fg-color);\n }\n\n // Reset active color for nested list titles\n .md-nav__item--nested > & {\n color: inherit;\n }\n\n // Focused or hovered link\n &:focus,\n &:hover {\n color: var(--md-accent-fg-color);\n }\n }\n\n // Repository containing source\n &__source {\n display: none;\n }\n\n // [tablet -]: Layered navigation\n @include break-to-device(tablet) {\n background-color: var(--md-default-bg-color);\n\n // Stretch primary navigation to drawer\n &--primary,\n &--primary .md-nav {\n position: absolute;\n top: 0;\n right: 0;\n left: 0;\n z-index: 1;\n display: flex;\n flex-direction: column;\n height: 100%;\n }\n\n // Adjust styles for primary navigation\n &--primary {\n\n // List title and item\n .md-nav__title,\n .md-nav__item {\n font-size: px2rem(16px);\n line-height: 1.5;\n }\n\n // List title\n .md-nav__title {\n position: relative;\n height: px2rem(112px);\n padding: px2rem(60px) px2rem(16px) px2rem(4px);\n color: var(--md-default-fg-color--light);\n font-weight: 400;\n line-height: px2rem(48px);\n white-space: nowrap;\n background-color: var(--md-default-fg-color--lightest);\n cursor: pointer;\n\n // Icon\n .md-nav__icon {\n position: absolute;\n top: px2rem(8px);\n left: px2rem(8px);\n display: block;\n width: px2rem(24px);\n height: px2rem(24px);\n margin: px2rem(4px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n right: px2rem(8px);\n left: initial;\n }\n }\n\n // Main lists\n ~ .md-nav__list {\n overflow-y: auto;\n background-color: var(--md-default-bg-color);\n box-shadow:\n inset 0 px2rem(1px) 0 var(--md-default-fg-color--lightest);\n scroll-snap-type: y mandatory;\n touch-action: pan-y;\n\n // Remove border for first list item\n > .md-nav__item:first-child {\n border-top: 0;\n }\n }\n\n // Site title in main navigation\n &[for=\"__drawer\"] {\n position: relative;\n color: var(--md-primary-bg-color);\n background-color: var(--md-primary-fg-color);\n\n // Site logo\n .md-nav__button {\n position: absolute;\n top: px2rem(4px);\n left: px2rem(4px);\n display: block;\n margin: px2rem(4px);\n padding: px2rem(8px);\n font-size: px2rem(48px);\n }\n }\n }\n\n // Adjust for right-to-left languages\n html [dir=\"rtl\"] & .md-nav__title {\n\n // Site title in main navigation\n &[for=\"__drawer\"] .md-nav__button {\n right: px2rem(4px);\n left: initial;\n }\n }\n\n // List of items\n .md-nav__list {\n flex: 1;\n }\n\n // List item\n .md-nav__item {\n padding: 0;\n border-top: px2rem(1px) solid var(--md-default-fg-color--lightest);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n padding: 0;\n }\n\n // Increase spacing to account for icon\n &--nested > .md-nav__link {\n padding-right: px2rem(48px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n padding-right: px2rem(16px);\n padding-left: px2rem(48px);\n }\n }\n\n // Active parent item\n &--active > .md-nav__link {\n color: var(--md-primary-fg-color);\n\n // Focused or hovered linl\n &:focus,\n &:hover {\n color: var(--md-accent-fg-color);\n }\n }\n }\n\n // Link inside item\n .md-nav__link {\n position: relative;\n margin-top: 0;\n padding: px2rem(12px) px2rem(16px);\n\n // Icon\n .md-nav__icon {\n position: absolute;\n top: 50%;\n right: px2rem(12px);\n margin-top: px2rem(-12px);\n color: inherit;\n font-size: px2rem(24px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n right: initial;\n left: px2rem(12px);\n }\n }\n }\n\n // Icon\n .md-nav__icon {\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n\n // Flip icon vertically\n svg {\n transform: scale(-1);\n }\n }\n }\n\n // Table of contents inside navigation\n .md-nav--secondary {\n\n // Set links to static to avoid unnecessary layering\n .md-nav__link {\n position: static;\n }\n\n // Set nested navigation for table of contents to static\n .md-nav {\n position: static;\n background-color: transparent;\n\n // 3rd level link\n .md-nav__link {\n padding-left: px2rem(28px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n padding-right: px2rem(28px);\n padding-left: initial;\n }\n }\n\n // 4th level link\n .md-nav .md-nav__link {\n padding-left: px2rem(40px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n padding-right: px2rem(40px);\n padding-left: initial;\n }\n }\n\n // 5th level link\n .md-nav .md-nav .md-nav__link {\n padding-left: px2rem(52px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n padding-right: px2rem(52px);\n padding-left: initial;\n }\n }\n\n // 6th level link\n .md-nav .md-nav .md-nav .md-nav__link {\n padding-left: px2rem(64px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n padding-right: px2rem(64px);\n padding-left: initial;\n }\n }\n }\n }\n }\n\n // Hide nested navigation by default\n .md-nav__toggle ~ & {\n display: flex;\n transform: translateX(100%);\n opacity: 0;\n transition:\n transform 250ms cubic-bezier(0.8, 0, 0.6, 1),\n opacity 125ms 50ms;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n transform: translateX(-100%);\n }\n }\n\n // Expand nested navigation, if toggle is checked\n .md-nav__toggle:checked ~ & {\n transform: translateX(0);\n opacity: 1;\n transition:\n transform 250ms cubic-bezier(0.4, 0, 0.2, 1),\n opacity 125ms 125ms;\n\n // Hack: reduce jitter\n > .md-nav__list {\n backface-visibility: hidden;\n }\n }\n }\n\n // [tablet portrait -]: Show table of contents in drawer\n @include break-to-device(tablet portrait) {\n\n // Show link to table of contents - higher specificity is necessary to\n // display the table of contents inside the drawer\n html &__link[for=\"__toc\"] {\n display: block;\n padding-right: px2rem(48px);\n\n // Hide link to current item\n + .md-nav__link {\n display: none;\n }\n\n // Show table of contents\n & ~ .md-nav {\n display: flex;\n }\n }\n\n // Adjust for right-to-left languages\n html [dir=\"rtl\"] &__link {\n padding-right: px2rem(16px);\n padding-left: px2rem(48px);\n }\n\n // Repository containing source\n &__source {\n display: block;\n padding: 0 px2rem(4px);\n color: var(--md-primary-bg-color);\n background-color: var(--md-primary-fg-color--dark);\n }\n }\n\n // [tablet landscape +]: Tree-like navigation\n @include break-from-device(tablet landscape) {\n\n // List title\n &--secondary .md-nav__title {\n\n // Snap to table of contents title\n &[for=\"__toc\"] {\n scroll-snap-align: start;\n }\n\n // Hide icon\n .md-nav__icon {\n display: none;\n }\n }\n }\n\n // [screen +]: Tree-like navigation\n @include break-from-device(screen) {\n transition: max-height 250ms cubic-bezier(0.86, 0, 0.07, 1);\n\n // List title\n &--primary .md-nav__title {\n\n // Snap to site title\n &[for=\"__drawer\"] {\n scroll-snap-align: start;\n }\n\n // Hide icon\n .md-nav__icon {\n display: none;\n }\n }\n\n // Hide nested navigation by default\n .md-nav__toggle ~ & {\n display: none;\n }\n\n // Show nested navigation, if toggle is checked\n .md-nav__toggle:checked ~ & {\n display: block;\n }\n\n // Hide titles for nested navigation\n &__item--nested > .md-nav > &__title {\n display: none;\n }\n\n // Icon\n &__icon {\n float: right;\n height: px2rem(18px);\n transition: transform 250ms;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n float: left;\n transform: rotate(180deg);\n }\n\n // Inline icon and adjust to match font size\n svg {\n display: inline-block;\n width: px2rem(18px);\n height: px2rem(18px);\n vertical-align: px2rem(-2px);\n }\n\n // Rotate icon for expanded lists\n .md-nav__item--nested .md-nav__toggle:checked ~ .md-nav__link & {\n transform: rotate(90deg);\n }\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Variables\n// ----------------------------------------------------------------------------\n\n// Active (toggled) search\n$md-toggle__search--checked:\n \"[data-md-toggle=\\\"search\\\"]:checked ~ .md-header\";\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Search container\n.md-search {\n position: relative;\n\n // Hide search, if JavaScript is not available.\n .no-js & {\n display: none;\n }\n\n // [tablet landscape +]: Header-embedded search\n @include break-from-device(tablet landscape) {\n padding: px2rem(4px) 0;\n }\n\n // Search modal overlay\n &__overlay {\n z-index: 1;\n opacity: 0;\n\n // [tablet portrait -]: Full-screen search bar\n @include break-to-device(tablet portrait) {\n position: absolute;\n top: px2rem(4px);\n left: px2rem(-44px);\n width: px2rem(40px);\n height: px2rem(40px);\n overflow: hidden;\n background-color: var(--md-default-bg-color);\n border-radius: px2rem(20px);\n transform-origin: center;\n transition:\n transform 300ms 100ms,\n opacity 200ms 200ms;\n pointer-events: none;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n right: px2rem(-44px);\n left: initial;\n }\n\n // Expanded overlay\n #{$md-toggle__search--checked} & {\n opacity: 1;\n transition:\n transform 400ms,\n opacity 100ms;\n }\n }\n\n // Set scale factors\n #{$md-toggle__search--checked} & {\n\n // [mobile portrait -]: Scale up 45 times\n @include break-to-device(mobile portrait) {\n transform: scale(45);\n }\n\n // [mobile landscape]: Scale up 60 times\n @include break-at-device(mobile landscape) {\n transform: scale(60);\n }\n\n // [tablet portrait]: Scale up 75 times\n @include break-at-device(tablet portrait) {\n transform: scale(75);\n }\n }\n\n // [tablet landscape +]: Overlay for better focus on search\n @include break-from-device(tablet landscape) {\n position: fixed;\n top: 0;\n left: 0;\n width: 0;\n height: 0;\n background-color: var(--md-default-fg-color--light);\n cursor: pointer;\n transition:\n width 0ms 250ms,\n height 0ms 250ms,\n opacity 250ms;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n right: 0;\n left: initial;\n }\n\n // Expanded overlay\n #{$md-toggle__search--checked} & {\n width: 100%;\n height: 100%;\n opacity: 1;\n transition:\n width 0ms,\n height 0ms,\n opacity 250ms;\n }\n }\n }\n\n // Search modal wrapper\n &__inner {\n // Hack: reduce jitter\n backface-visibility: hidden;\n\n // [tablet portrait -]: Put search modal off-canvas by default\n @include break-to-device(tablet portrait) {\n position: fixed;\n top: 0;\n left: 100%;\n z-index: 2;\n width: 100%;\n height: 100%;\n transform: translateX(5%);\n opacity: 0;\n transition:\n right 0ms 300ms,\n left 0ms 300ms,\n transform 150ms 150ms cubic-bezier(0.4, 0, 0.2, 1),\n opacity 150ms 150ms;\n\n // Active search modal\n #{$md-toggle__search--checked} & {\n left: 0;\n transform: translateX(0);\n opacity: 1;\n transition:\n right 0ms 0ms,\n left 0ms 0ms,\n transform 150ms 150ms cubic-bezier(0.1, 0.7, 0.1, 1),\n opacity 150ms 150ms;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n right: 0;\n left: initial;\n }\n }\n\n // Adjust for right-to-left languages\n html [dir=\"rtl\"] & {\n right: 100%;\n left: initial;\n transform: translateX(-5%);\n }\n }\n\n // [tablet landscape +]: Header-embedded search\n @include break-from-device(tablet landscape) {\n position: relative;\n float: right;\n width: px2rem(234px);\n padding: px2rem(2px) 0;\n transition: width 250ms cubic-bezier(0.1, 0.7, 0.1, 1);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n float: left;\n }\n }\n\n // Set maximum width\n #{$md-toggle__search--checked} & {\n\n // [tablet landscape]: Do not overlay title\n @include break-at-device(tablet landscape) {\n width: px2rem(468px);\n }\n\n // [screen +]: Match content width\n @include break-from-device(screen) {\n width: px2rem(688px);\n }\n }\n }\n\n // Search form\n &__form {\n position: relative;\n\n // [tablet landscape +]: Header-embedded search\n @include break-from-device(tablet landscape) {\n border-radius: px2rem(2px);\n }\n }\n\n // Search input\n &__input {\n position: relative;\n z-index: 2;\n padding: 0 px2rem(44px) 0 px2rem(72px);\n text-overflow: ellipsis;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n padding: 0 px2rem(72px) 0 px2rem(44px);\n }\n\n // Transition on placeholder\n &::placeholder {\n transition: color 250ms;\n }\n\n // Placeholder and icon color in active state\n ~ .md-search__icon,\n &::placeholder {\n color: var(--md-default-fg-color--light);\n }\n\n // Remove the \"x\" rendered by Internet Explorer\n &::-ms-clear {\n display: none;\n }\n\n // [tablet portrait -]: Full-screen search bar\n @include break-to-device(tablet portrait) {\n width: 100%;\n height: px2rem(48px);\n font-size: px2rem(18px);\n }\n\n // [tablet landscape +]: Header-embedded search\n @include break-from-device(tablet landscape) {\n width: 100%;\n height: px2rem(36px);\n padding-left: px2rem(44px);\n color: inherit;\n font-size: ms(0);\n background-color: var(--md-default-fg-color--lighter);\n border-radius: px2rem(2px);\n transition:\n color 250ms,\n background-color 250ms;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n padding-right: px2rem(44px);\n }\n\n // Icon color\n + .md-search__icon {\n color: var(--md-primary-bg-color);\n }\n\n // Placeholder color\n &::placeholder {\n color: var(--md-primary-bg-color--light);\n }\n\n // Hovered search field\n &:hover {\n background-color: var(--md-default-bg-color--lightest);\n }\n\n // Set light background on active search field\n #{$md-toggle__search--checked} & {\n color: var(--md-default-fg-color);\n text-overflow: clip;\n background-color: var(--md-default-bg-color);\n border-radius: px2rem(2px) px2rem(2px) 0 0;\n\n // Icon and placeholder color in active state\n + .md-search__icon,\n &::placeholder {\n color: var(--md-default-fg-color--light);\n }\n }\n }\n }\n\n // Icon\n &__icon {\n position: absolute;\n z-index: 2;\n width: px2rem(24px);\n height: px2rem(24px);\n cursor: pointer;\n transition:\n color 250ms,\n opacity 250ms;\n\n // Hovered icon\n &:hover {\n opacity: 0.7;\n }\n\n // Search icon\n &[for=\"__search\"] {\n top: px2rem(6px);\n left: px2rem(10px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n right: px2rem(10px);\n left: initial;\n\n // Flip icon vertically\n svg {\n transform: scaleX(-1);\n }\n }\n\n // [tablet portrait -]: Full-screen search bar\n @include break-to-device(tablet portrait) {\n top: px2rem(12px);\n left: px2rem(16px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n right: px2rem(16px);\n left: initial;\n }\n\n // Hide the magnifying glass (1st icon)\n svg:first-child {\n display: none;\n }\n }\n\n // [tablet landscape +]: Header-embedded search\n @include break-from-device(tablet landscape) {\n pointer-events: none;\n\n // Hide the arrow (2nd icon)\n svg:last-child {\n display: none;\n }\n }\n }\n\n // Reset button\n &[type=\"reset\"] {\n top: px2rem(6px);\n right: px2rem(10px);\n transform: scale(0.75);\n opacity: 0;\n transition:\n transform 150ms cubic-bezier(0.1, 0.7, 0.1, 1),\n opacity 150ms;\n pointer-events: none;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n right: initial;\n left: px2rem(10px);\n }\n\n // [tablet portrait -]: Full-screen search bar\n @include break-to-device(tablet portrait) {\n top: px2rem(12px);\n right: px2rem(16px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n right: initial;\n left: px2rem(16px);\n }\n }\n\n // Show reset button if search is active and input non-empty\n #{$md-toggle__search--checked}\n .md-search__input:not(:placeholder-shown) ~ & {\n transform: scale(1);\n opacity: 1;\n pointer-events: initial;\n\n // Hovered icon\n &:hover {\n opacity: 0.7;\n }\n }\n }\n }\n\n // Search output container\n &__output {\n position: absolute;\n z-index: 1;\n width: 100%;\n overflow: hidden;\n border-radius: 0 0 px2rem(2px) px2rem(2px);\n\n // [tablet portrait -]: Full-screen search bar\n @include break-to-device(tablet portrait) {\n top: px2rem(48px);\n bottom: 0;\n }\n\n // [tablet landscape +]: Header-embedded search\n @include break-from-device(tablet landscape) {\n top: px2rem(38px);\n opacity: 0;\n transition: opacity 400ms;\n\n // Show search output in active state\n #{$md-toggle__search--checked} & {\n @include z-depth(6);\n\n opacity: 1;\n }\n }\n }\n\n // Wrapper for scrolling on overflow\n &__scrollwrap {\n height: 100%;\n overflow-y: auto;\n background-color: var(--md-default-bg-color);\n box-shadow: inset 0 px2rem(1px) 0 var(--md-default-fg-color--lightest);\n // Hack: reduce jitter\n backface-visibility: hidden;\n scroll-snap-type: y mandatory;\n touch-action: pan-y;\n\n // Mitigiate excessive repaints on non-retina devices\n @media (max-resolution: 1dppx) {\n transform: translateZ(0);\n }\n\n // [tablet landscape]: Set absolute width to omit unnecessary reflow\n @include break-at-device(tablet landscape) {\n width: px2rem(468px);\n }\n\n // [screen +]: Set absolute width to omit unnecessary reflow\n @include break-from-device(screen) {\n width: px2rem(688px);\n }\n\n // [tablet landscape +]: Limit height to viewport\n @include break-from-device(tablet landscape) {\n max-height: 0;\n\n // Expand in active state\n #{$md-toggle__search--checked} & {\n max-height: 75vh;\n }\n\n // Override native scrollbar styles\n &::-webkit-scrollbar {\n width: px2rem(4px);\n height: px2rem(4px);\n }\n\n // Scrollbar thumb\n &::-webkit-scrollbar-thumb {\n background-color: var(--md-default-fg-color--lighter);\n\n // Hovered scrollbar thumb\n &:hover {\n background-color: var(--md-accent-fg-color);\n }\n }\n }\n }\n}\n\n// Search result\n.md-search-result {\n color: var(--md-default-fg-color);\n word-break: break-word;\n\n // Search metadata\n &__meta {\n padding: 0 px2rem(16px);\n color: var(--md-default-fg-color--light);\n font-size: ms(-1);\n line-height: px2rem(36px);\n background-color: var(--md-default-fg-color--lightest);\n scroll-snap-align: start;\n\n // [tablet landscape +]: Increase left indent\n @include break-from-device(tablet landscape) {\n padding-left: px2rem(44px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n padding-right: px2rem(44px);\n padding-left: initial;\n }\n }\n }\n\n // List of items\n &__list {\n margin: 0;\n padding: 0;\n list-style: none;\n border-top: px2rem(1px) solid var(--md-default-fg-color--lightest);\n }\n\n // List item\n &__item {\n box-shadow: 0 px2rem(-1px) 0 var(--md-default-fg-color--lightest);\n }\n\n // Link inside item\n &__link {\n display: block;\n outline: 0;\n transition: background 250ms;\n scroll-snap-align: start;\n\n // Focused or hovered link\n &:focus,\n &:hover {\n background-color: var(--md-accent-fg-color--transparent);\n\n // Slightly transparent icon\n .md-search-result__article::before {\n opacity: 0.7;\n }\n }\n\n // Add a little spacing on the teaser of the last link\n &:last-child .md-search-result__teaser {\n margin-bottom: px2rem(12px);\n }\n }\n\n // Article - document or section\n &__article {\n position: relative;\n padding: 0 px2rem(16px);\n overflow: auto;\n\n // [tablet landscape +]: Increase left indent\n @include break-from-device(tablet landscape) {\n padding-left: px2rem(44px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n padding-right: px2rem(44px);\n padding-left: px2rem(16px);\n }\n }\n\n // Document\n &--document {\n\n // Title\n .md-search-result__title {\n margin: px2rem(11px) 0;\n font-weight: 400;\n font-size: ms(0);\n line-height: 1.4;\n }\n }\n }\n\n // Icon\n &__icon {\n position: absolute;\n left: 0;\n margin: px2rem(2px);\n padding: px2rem(8px);\n color: var(--md-default-fg-color--light);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n right: 0;\n left: initial;\n\n // Flip icon vertically\n svg {\n transform: scaleX(-1);\n }\n }\n\n // [tablet portrait -]: Hide page icon\n @include break-to-device(tablet portrait) {\n display: none;\n }\n }\n\n // Title\n &__title {\n margin: 0.5em 0;\n font-weight: 700;\n font-size: ms(-1);\n line-height: 1.4;\n }\n\n // stylelint-disable value-no-vendor-prefix, property-no-vendor-prefix\n\n // Teaser\n &__teaser {\n display: -webkit-box;\n max-height: px2rem(33px);\n margin: 0.5em 0;\n overflow: hidden;\n color: var(--md-default-fg-color--light);\n font-size: ms(-1);\n line-height: 1.4;\n text-overflow: ellipsis;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 2;\n\n // [mobile -]: Increase number of lines\n @include break-to-device(mobile) {\n max-height: px2rem(50px);\n -webkit-line-clamp: 3;\n }\n\n // [tablet landscape]: Increase number of lines\n @include break-at-device(tablet landscape) {\n max-height: px2rem(50px);\n -webkit-line-clamp: 3;\n }\n }\n\n // stylelint-enable value-no-vendor-prefix, property-no-vendor-prefix\n\n // Search term highlighting\n em {\n font-weight: 700;\n font-style: normal;\n text-decoration: underline;\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Variables\n// ----------------------------------------------------------------------------\n\n// Active (toggled) drawer\n$md-toggle__drawer--checked:\n \"[data-md-toggle=\\\"drawer\\\"]:checked ~ .md-container\";\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Sidebar container\n.md-sidebar {\n position: absolute;\n width: px2rem(242px);\n padding: px2rem(24px) 0;\n overflow: hidden;\n\n // Hide for print\n @media print {\n display: none;\n }\n\n // Lock sidebar to container height (account for fixed header)\n &[data-md-state=\"lock\"] {\n position: fixed;\n top: px2rem(48px);\n }\n\n // [tablet -]: Convert navigation to drawer\n @include break-to-device(tablet) {\n\n // Render primary sidebar as a slideout container\n &--primary {\n position: fixed;\n top: 0;\n left: px2rem(-242px);\n z-index: 3;\n width: px2rem(242px);\n height: 100%;\n background-color: var(--md-default-bg-color);\n transform: translateX(0);\n transition:\n transform 250ms cubic-bezier(0.4, 0, 0.2, 1),\n box-shadow 250ms;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n right: px2rem(-242px);\n left: initial;\n }\n\n // Expanded drawer\n #{$md-toggle__drawer--checked} & {\n @include z-depth(8);\n\n transform: translateX(px2rem(242px));\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n transform: translateX(px2rem(-242px));\n }\n }\n\n // Hide overflow for nested navigation\n .md-sidebar__scrollwrap {\n overflow: hidden;\n }\n }\n }\n\n // Secondary sidebar with table of contents\n &--secondary {\n display: none;\n\n // [tablet landscape +]: Show table of contents next to body copy\n @include break-from-device(tablet landscape) {\n display: block;\n margin-left: calc(100% - #{px2rem(242px)});\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n margin-right: calc(100% - #{px2rem(242px)});\n margin-left: initial;\n }\n\n // Ensure smooth scrolling on iOS\n .md-sidebar__scrollwrap {\n touch-action: pan-y;\n }\n }\n\n // [screen +]: Limit to grid\n @include break-from-device(screen) {\n margin-left: px2rem((1220 - 242) * 1px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n margin-right: px2rem((1220 - 242) * 1px);\n margin-left: initial;\n }\n }\n }\n\n // Wrapper for scrolling on overflow\n &__scrollwrap {\n max-height: 100%;\n margin: 0 px2rem(4px);\n overflow-y: auto;\n // Hack: reduce jitter\n backface-visibility: hidden;\n scroll-snap-type: y mandatory;\n\n // [tablet -]: Adjust margins\n @include break-to-device(tablet) {\n\n // Stretch scrollwrap for primary sidebar\n .md-sidebar--primary & {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n margin: 0;\n scroll-snap-type: none;\n }\n }\n\n // Override native scrollbar styles\n &::-webkit-scrollbar {\n width: px2rem(4px);\n height: px2rem(4px);\n }\n\n // Scrollbar thumb\n &::-webkit-scrollbar-thumb {\n background-color: var(--md-default-fg-color--lighter);\n\n // Hovered scrollbar thumb\n &:hover {\n background-color: var(--md-accent-fg-color);\n }\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Keyframes\n// ----------------------------------------------------------------------------\n\n// Show source facts\n@keyframes md-source__facts--done {\n 0% {\n height: 0;\n }\n\n 100% {\n height: px2rem(13px);\n }\n}\n\n// Show source fact\n@keyframes md-source__fact--done {\n 0% {\n transform: translateY(100%);\n opacity: 0;\n }\n\n 50% {\n opacity: 0;\n }\n\n 100% {\n transform: translateY(0%);\n opacity: 1;\n }\n}\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Source container\n.md-source {\n display: block;\n font-size: px2rem(13px);\n line-height: 1.2;\n white-space: nowrap;\n // Hack: reduce jitter\n backface-visibility: hidden;\n transition: opacity 250ms;\n\n // Hovered source container\n &:hover {\n opacity: 0.7;\n }\n\n // Repository platform icon\n &__icon {\n display: inline-block;\n width: px2rem(48px);\n height: px2rem(48px);\n vertical-align: middle;\n\n // Align with margin only (as opposed to normal button alignment)\n svg {\n margin-top: px2rem(12px);\n margin-left: px2rem(12px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n margin-right: px2rem(12px);\n margin-left: initial;\n }\n }\n\n // Correct alignment, if icon is present\n + .md-source__repository {\n margin-left: px2rem(-40px);\n padding-left: px2rem(40px);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n margin-right: px2rem(-40px);\n margin-left: initial;\n padding-right: px2rem(40px);\n padding-left: initial;\n }\n }\n }\n\n // Repository name\n &__repository {\n display: inline-block;\n max-width: calc(100% - #{px2rem(24px)});\n margin-left: px2rem(12px);\n overflow: hidden;\n font-weight: 700;\n text-overflow: ellipsis;\n vertical-align: middle;\n }\n\n // Source facts (statistics etc.)\n &__facts {\n margin: 0;\n padding: 0;\n overflow: hidden;\n font-weight: 700;\n font-size: px2rem(11px);\n list-style-type: none;\n opacity: 0.75;\n\n // Show after the data was loaded\n [data-md-state=\"done\"] & {\n animation: md-source__facts--done 250ms ease-in;\n }\n }\n\n // Fact\n &__fact {\n float: left;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n float: right;\n }\n\n // Show after the data was loaded\n [data-md-state=\"done\"] & {\n animation: md-source__fact--done 400ms ease-out;\n }\n\n // Middle dot before fact\n &::before {\n margin: 0 px2rem(2px);\n content: \"\\00B7\";\n }\n\n // Remove middle dot on first fact\n &:first-child::before {\n display: none;\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Tabs with outline\n.md-tabs {\n width: 100%;\n overflow: auto;\n color: var(--md-primary-bg-color);\n background-color: var(--md-primary-fg-color);\n transition: background 250ms;\n\n // Omit transitions, in case JavaScript is not available\n .no-js & {\n transition: none;\n }\n\n // [tablet -]: Hide tabs for tablet and below, as they don't make any sense\n @include break-to-device(tablet) {\n display: none;\n }\n\n // Hide for print\n @media print {\n display: none;\n }\n\n // List of items\n &__list {\n margin: 0;\n margin-left: px2rem(4px);\n padding: 0;\n white-space: nowrap;\n list-style: none;\n contain: content;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n margin-right: px2rem(4px);\n margin-left: initial;\n }\n }\n\n // List item\n &__item {\n display: inline-block;\n height: px2rem(48px);\n padding-right: px2rem(12px);\n padding-left: px2rem(12px);\n }\n\n // Link inside item - could be defined as block elements and aligned via\n // line height, but this would imply more repaints when scrolling\n &__link {\n display: block;\n margin-top: px2rem(16px);\n font-size: px2rem(14px);\n opacity: 0.7;\n transition:\n transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),\n opacity 250ms;\n\n // Omit transitions, in case JavaScript is not available\n .no-js & {\n transition: none;\n }\n\n // Active or hovered link\n &--active,\n &:hover {\n color: inherit;\n opacity: 1;\n }\n\n // Delay transitions by a small amount\n @for $i from 2 through 16 {\n .md-tabs__item:nth-child(#{$i}) & {\n transition-delay: 20ms * ($i - 1);\n }\n }\n }\n\n // Fade-out tabs background upon scrolling\n &[data-md-state=\"hidden\"] {\n pointer-events: none;\n\n // Hide tabs upon scrolling - disable transition to minimizes repaints\n // while scrolling down, while scrolling up seems to be okay\n .md-tabs__link {\n transform: translateY(50%);\n opacity: 0;\n transition:\n color 250ms,\n transform 0ms 400ms,\n opacity 100ms;\n }\n }\n\n // [screen +]: Adjust main navigation styles\n @include break-from-device(screen) {\n\n // Hide 1st level nested items, as they are listed in the tabs\n ~ .md-main .md-nav--primary > .md-nav__list > .md-nav__item--nested {\n display: none;\n }\n\n // Active tab\n &--active ~ .md-main {\n\n // Adjust 1st level styles\n .md-nav--primary {\n\n // Show title and remove spacing\n .md-nav__title {\n display: block;\n padding: 0 px2rem(12px);\n pointer-events: none;\n scroll-snap-align: start;\n\n // Hide site title\n &[for=\"__drawer\"] {\n display: none;\n }\n }\n\n // Hide 1st level items\n > .md-nav__list > .md-nav__item {\n display: none;\n\n // Show 1st level active nested items\n &--active {\n display: block;\n padding: 0;\n\n // Hide nested links\n > .md-nav__link {\n display: none;\n }\n }\n }\n }\n\n // Always expand nested navigation on 2nd level\n .md-nav[data-md-level=\"1\"] {\n\n // Remove spacing on 2nd level items\n > .md-nav__list > .md-nav__item {\n padding: 0 px2rem(12px);\n }\n\n // Hide titles from 2nd level on\n .md-nav .md-nav__title {\n display: none;\n }\n }\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Variables\n// ----------------------------------------------------------------------------\n\n///\n/// Admonition flavours\n///\n$admonitions: (\n note: pencil $clr-blue-a200,\n abstract summary tldr: text-subject $clr-light-blue-a400,\n info todo: information $clr-cyan-a700,\n tip hint important: fire $clr-teal-a700,\n success check done: check-circle $clr-green-a700,\n question help faq: help-circle $clr-light-green-a700,\n warning caution attention: alert $clr-orange-a400,\n failure fail missing: close-circle $clr-red-a200,\n danger error: flash-circle $clr-red-a400,\n bug: bug $clr-pink-a400,\n example: format-list-numbered $clr-deep-purple-a400,\n quote cite: format-quote-close $clr-grey\n) !default;\n\n// ----------------------------------------------------------------------------\n// Rules: layout\n// ----------------------------------------------------------------------------\n\n// Icon definitions\n:root {\n @each $names, $props in $admonitions {\n $name: nth($names, 1);\n $icon: nth($props, 1);\n\n // Inline icon through string-replace-loader in webpack\n --md-admonition-icon--#{$name}: url(\"{{ #{$icon} }}\");\n }\n}\n\n// ----------------------------------------------------------------------------\n\n// Scoped in typesetted content to match specificity of regular content\n.md-typeset {\n\n // Admonition extension\n .admonition {\n margin: 1.5625em 0;\n padding: 0 px2rem(12px);\n overflow: hidden;\n font-size: ms(-1);\n page-break-inside: avoid;\n border-left: px2rem(4px) solid $clr-blue-a200;\n border-radius: px2rem(2px);\n box-shadow:\n 0 px2rem(4px) px2rem(10px) hsla(0, 0%, 0%, 0.05),\n 0 0 px2rem(1px) hsla(0, 0%, 0%, 0.1);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n border-right: px2rem(4px) solid $clr-blue-a200;\n border-left: none;\n }\n\n // Hack: omit rendering errors for print\n @media print {\n box-shadow: none;\n }\n\n // Adjust spacing on last element\n html & > :last-child {\n margin-bottom: px2rem(12px);\n }\n\n // Adjust margin for nested admonition blocks\n .admonition {\n margin: 1em 0;\n }\n\n // Wrapper for scrolling on overflow\n .md-typeset__scrollwrap {\n margin: 1em px2rem(-12px);\n }\n\n // Data table wrapper, in case JavaScript is available\n .md-typeset__table {\n padding: 0 px2rem(12px);\n }\n }\n\n // Admonition title\n .admonition-title {\n position: relative;\n margin: 0 px2rem(-12px);\n padding: px2rem(8px) px2rem(12px) px2rem(8px) px2rem(40px);\n font-weight: 700;\n background-color: transparentize($clr-blue-a200, 0.9);\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n padding: px2rem(8px) px2rem(40px) px2rem(8px) px2rem(12px);\n }\n\n // Reset spacing, if title is the only element\n html &:last-child {\n margin-bottom: 0;\n }\n\n // Icon\n &::before {\n position: absolute;\n left: px2rem(12px);\n width: px2rem(20px);\n height: px2rem(20px);\n background-color: $clr-blue-a200;\n mask-image: var(--md-admonition-icon--note);\n content: \"\";\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n right: px2rem(12px);\n left: initial;\n }\n }\n\n // Reset code inside Admonition titles\n code {\n margin: initial;\n padding: initial;\n color: currentColor;\n background-color: transparent;\n border-radius: initial;\n box-shadow: none;\n }\n }\n}\n\n// ----------------------------------------------------------------------------\n// Rules: flavours\n// ----------------------------------------------------------------------------\n\n@each $names, $props in $admonitions {\n $name: nth($names, 1);\n $tint: nth($props, 2);\n\n // Define base class\n .md-typeset .admonition.#{$name} {\n border-color: $tint;\n }\n\n // Define base class\n .md-typeset .#{$name} > .admonition-title {\n background-color: transparentize($tint, 0.9);\n\n // Icon\n &::before {\n background-color: $tint;\n mask-image: var(--md-admonition-icon--#{$name});\n }\n }\n\n // Define synonyms for base class\n @if length($names) > 1 {\n @for $n from 2 through length($names) {\n .#{nth($names, $n)} {\n @extend .#{$name};\n }\n }\n }\n}\n","// ==========================================================================\n//\n// Name: UI Color Palette\n// Description: The color palette of material design.\n// Version: 2.3.1\n//\n// Author: Denis Malinochkin\n// Git: https://github.com/mrmlnc/material-color\n//\n// twitter: @mrmlnc\n//\n// ==========================================================================\n\n\n//\n// List of base colors\n//\n\n// $clr-red\n// $clr-pink\n// $clr-purple\n// $clr-deep-purple\n// $clr-indigo\n// $clr-blue\n// $clr-light-blue\n// $clr-cyan\n// $clr-teal\n// $clr-green\n// $clr-light-green\n// $clr-lime\n// $clr-yellow\n// $clr-amber\n// $clr-orange\n// $clr-deep-orange\n// $clr-brown\n// $clr-grey\n// $clr-blue-grey\n// $clr-black\n// $clr-white\n\n\n//\n// Red\n//\n\n$clr-red-list: (\n \"base\": #f44336,\n \"50\": #ffebee,\n \"100\": #ffcdd2,\n \"200\": #ef9a9a,\n \"300\": #e57373,\n \"400\": #ef5350,\n \"500\": #f44336,\n \"600\": #e53935,\n \"700\": #d32f2f,\n \"800\": #c62828,\n \"900\": #b71c1c,\n \"a100\": #ff8a80,\n \"a200\": #ff5252,\n \"a400\": #ff1744,\n \"a700\": #d50000\n);\n\n$clr-red: map-get($clr-red-list, \"base\");\n\n$clr-red-50: map-get($clr-red-list, \"50\");\n$clr-red-100: map-get($clr-red-list, \"100\");\n$clr-red-200: map-get($clr-red-list, \"200\");\n$clr-red-300: map-get($clr-red-list, \"300\");\n$clr-red-400: map-get($clr-red-list, \"400\");\n$clr-red-500: map-get($clr-red-list, \"500\");\n$clr-red-600: map-get($clr-red-list, \"600\");\n$clr-red-700: map-get($clr-red-list, \"700\");\n$clr-red-800: map-get($clr-red-list, \"800\");\n$clr-red-900: map-get($clr-red-list, \"900\");\n$clr-red-a100: map-get($clr-red-list, \"a100\");\n$clr-red-a200: map-get($clr-red-list, \"a200\");\n$clr-red-a400: map-get($clr-red-list, \"a400\");\n$clr-red-a700: map-get($clr-red-list, \"a700\");\n\n\n//\n// Pink\n//\n\n$clr-pink-list: (\n \"base\": #e91e63,\n \"50\": #fce4ec,\n \"100\": #f8bbd0,\n \"200\": #f48fb1,\n \"300\": #f06292,\n \"400\": #ec407a,\n \"500\": #e91e63,\n \"600\": #d81b60,\n \"700\": #c2185b,\n \"800\": #ad1457,\n \"900\": #880e4f,\n \"a100\": #ff80ab,\n \"a200\": #ff4081,\n \"a400\": #f50057,\n \"a700\": #c51162\n);\n\n$clr-pink: map-get($clr-pink-list, \"base\");\n\n$clr-pink-50: map-get($clr-pink-list, \"50\");\n$clr-pink-100: map-get($clr-pink-list, \"100\");\n$clr-pink-200: map-get($clr-pink-list, \"200\");\n$clr-pink-300: map-get($clr-pink-list, \"300\");\n$clr-pink-400: map-get($clr-pink-list, \"400\");\n$clr-pink-500: map-get($clr-pink-list, \"500\");\n$clr-pink-600: map-get($clr-pink-list, \"600\");\n$clr-pink-700: map-get($clr-pink-list, \"700\");\n$clr-pink-800: map-get($clr-pink-list, \"800\");\n$clr-pink-900: map-get($clr-pink-list, \"900\");\n$clr-pink-a100: map-get($clr-pink-list, \"a100\");\n$clr-pink-a200: map-get($clr-pink-list, \"a200\");\n$clr-pink-a400: map-get($clr-pink-list, \"a400\");\n$clr-pink-a700: map-get($clr-pink-list, \"a700\");\n\n\n//\n// Purple\n//\n\n$clr-purple-list: (\n \"base\": #9c27b0,\n \"50\": #f3e5f5,\n \"100\": #e1bee7,\n \"200\": #ce93d8,\n \"300\": #ba68c8,\n \"400\": #ab47bc,\n \"500\": #9c27b0,\n \"600\": #8e24aa,\n \"700\": #7b1fa2,\n \"800\": #6a1b9a,\n \"900\": #4a148c,\n \"a100\": #ea80fc,\n \"a200\": #e040fb,\n \"a400\": #d500f9,\n \"a700\": #aa00ff\n);\n\n$clr-purple: map-get($clr-purple-list, \"base\");\n\n$clr-purple-50: map-get($clr-purple-list, \"50\");\n$clr-purple-100: map-get($clr-purple-list, \"100\");\n$clr-purple-200: map-get($clr-purple-list, \"200\");\n$clr-purple-300: map-get($clr-purple-list, \"300\");\n$clr-purple-400: map-get($clr-purple-list, \"400\");\n$clr-purple-500: map-get($clr-purple-list, \"500\");\n$clr-purple-600: map-get($clr-purple-list, \"600\");\n$clr-purple-700: map-get($clr-purple-list, \"700\");\n$clr-purple-800: map-get($clr-purple-list, \"800\");\n$clr-purple-900: map-get($clr-purple-list, \"900\");\n$clr-purple-a100: map-get($clr-purple-list, \"a100\");\n$clr-purple-a200: map-get($clr-purple-list, \"a200\");\n$clr-purple-a400: map-get($clr-purple-list, \"a400\");\n$clr-purple-a700: map-get($clr-purple-list, \"a700\");\n\n\n//\n// Deep purple\n//\n\n$clr-deep-purple-list: (\n \"base\": #673ab7,\n \"50\": #ede7f6,\n \"100\": #d1c4e9,\n \"200\": #b39ddb,\n \"300\": #9575cd,\n \"400\": #7e57c2,\n \"500\": #673ab7,\n \"600\": #5e35b1,\n \"700\": #512da8,\n \"800\": #4527a0,\n \"900\": #311b92,\n \"a100\": #b388ff,\n \"a200\": #7c4dff,\n \"a400\": #651fff,\n \"a700\": #6200ea\n);\n\n$clr-deep-purple: map-get($clr-deep-purple-list, \"base\");\n\n$clr-deep-purple-50: map-get($clr-deep-purple-list, \"50\");\n$clr-deep-purple-100: map-get($clr-deep-purple-list, \"100\");\n$clr-deep-purple-200: map-get($clr-deep-purple-list, \"200\");\n$clr-deep-purple-300: map-get($clr-deep-purple-list, \"300\");\n$clr-deep-purple-400: map-get($clr-deep-purple-list, \"400\");\n$clr-deep-purple-500: map-get($clr-deep-purple-list, \"500\");\n$clr-deep-purple-600: map-get($clr-deep-purple-list, \"600\");\n$clr-deep-purple-700: map-get($clr-deep-purple-list, \"700\");\n$clr-deep-purple-800: map-get($clr-deep-purple-list, \"800\");\n$clr-deep-purple-900: map-get($clr-deep-purple-list, \"900\");\n$clr-deep-purple-a100: map-get($clr-deep-purple-list, \"a100\");\n$clr-deep-purple-a200: map-get($clr-deep-purple-list, \"a200\");\n$clr-deep-purple-a400: map-get($clr-deep-purple-list, \"a400\");\n$clr-deep-purple-a700: map-get($clr-deep-purple-list, \"a700\");\n\n\n//\n// Indigo\n//\n\n$clr-indigo-list: (\n \"base\": #3f51b5,\n \"50\": #e8eaf6,\n \"100\": #c5cae9,\n \"200\": #9fa8da,\n \"300\": #7986cb,\n \"400\": #5c6bc0,\n \"500\": #3f51b5,\n \"600\": #3949ab,\n \"700\": #303f9f,\n \"800\": #283593,\n \"900\": #1a237e,\n \"a100\": #8c9eff,\n \"a200\": #536dfe,\n \"a400\": #3d5afe,\n \"a700\": #304ffe\n);\n\n$clr-indigo: map-get($clr-indigo-list, \"base\");\n\n$clr-indigo-50: map-get($clr-indigo-list, \"50\");\n$clr-indigo-100: map-get($clr-indigo-list, \"100\");\n$clr-indigo-200: map-get($clr-indigo-list, \"200\");\n$clr-indigo-300: map-get($clr-indigo-list, \"300\");\n$clr-indigo-400: map-get($clr-indigo-list, \"400\");\n$clr-indigo-500: map-get($clr-indigo-list, \"500\");\n$clr-indigo-600: map-get($clr-indigo-list, \"600\");\n$clr-indigo-700: map-get($clr-indigo-list, \"700\");\n$clr-indigo-800: map-get($clr-indigo-list, \"800\");\n$clr-indigo-900: map-get($clr-indigo-list, \"900\");\n$clr-indigo-a100: map-get($clr-indigo-list, \"a100\");\n$clr-indigo-a200: map-get($clr-indigo-list, \"a200\");\n$clr-indigo-a400: map-get($clr-indigo-list, \"a400\");\n$clr-indigo-a700: map-get($clr-indigo-list, \"a700\");\n\n\n//\n// Blue\n//\n\n$clr-blue-list: (\n \"base\": #2196f3,\n \"50\": #e3f2fd,\n \"100\": #bbdefb,\n \"200\": #90caf9,\n \"300\": #64b5f6,\n \"400\": #42a5f5,\n \"500\": #2196f3,\n \"600\": #1e88e5,\n \"700\": #1976d2,\n \"800\": #1565c0,\n \"900\": #0d47a1,\n \"a100\": #82b1ff,\n \"a200\": #448aff,\n \"a400\": #2979ff,\n \"a700\": #2962ff\n);\n\n$clr-blue: map-get($clr-blue-list, \"base\");\n\n$clr-blue-50: map-get($clr-blue-list, \"50\");\n$clr-blue-100: map-get($clr-blue-list, \"100\");\n$clr-blue-200: map-get($clr-blue-list, \"200\");\n$clr-blue-300: map-get($clr-blue-list, \"300\");\n$clr-blue-400: map-get($clr-blue-list, \"400\");\n$clr-blue-500: map-get($clr-blue-list, \"500\");\n$clr-blue-600: map-get($clr-blue-list, \"600\");\n$clr-blue-700: map-get($clr-blue-list, \"700\");\n$clr-blue-800: map-get($clr-blue-list, \"800\");\n$clr-blue-900: map-get($clr-blue-list, \"900\");\n$clr-blue-a100: map-get($clr-blue-list, \"a100\");\n$clr-blue-a200: map-get($clr-blue-list, \"a200\");\n$clr-blue-a400: map-get($clr-blue-list, \"a400\");\n$clr-blue-a700: map-get($clr-blue-list, \"a700\");\n\n\n//\n// Light Blue\n//\n\n$clr-light-blue-list: (\n \"base\": #03a9f4,\n \"50\": #e1f5fe,\n \"100\": #b3e5fc,\n \"200\": #81d4fa,\n \"300\": #4fc3f7,\n \"400\": #29b6f6,\n \"500\": #03a9f4,\n \"600\": #039be5,\n \"700\": #0288d1,\n \"800\": #0277bd,\n \"900\": #01579b,\n \"a100\": #80d8ff,\n \"a200\": #40c4ff,\n \"a400\": #00b0ff,\n \"a700\": #0091ea\n);\n\n$clr-light-blue: map-get($clr-light-blue-list, \"base\");\n\n$clr-light-blue-50: map-get($clr-light-blue-list, \"50\");\n$clr-light-blue-100: map-get($clr-light-blue-list, \"100\");\n$clr-light-blue-200: map-get($clr-light-blue-list, \"200\");\n$clr-light-blue-300: map-get($clr-light-blue-list, \"300\");\n$clr-light-blue-400: map-get($clr-light-blue-list, \"400\");\n$clr-light-blue-500: map-get($clr-light-blue-list, \"500\");\n$clr-light-blue-600: map-get($clr-light-blue-list, \"600\");\n$clr-light-blue-700: map-get($clr-light-blue-list, \"700\");\n$clr-light-blue-800: map-get($clr-light-blue-list, \"800\");\n$clr-light-blue-900: map-get($clr-light-blue-list, \"900\");\n$clr-light-blue-a100: map-get($clr-light-blue-list, \"a100\");\n$clr-light-blue-a200: map-get($clr-light-blue-list, \"a200\");\n$clr-light-blue-a400: map-get($clr-light-blue-list, \"a400\");\n$clr-light-blue-a700: map-get($clr-light-blue-list, \"a700\");\n\n\n//\n// Cyan\n//\n\n$clr-cyan-list: (\n \"base\": #00bcd4,\n \"50\": #e0f7fa,\n \"100\": #b2ebf2,\n \"200\": #80deea,\n \"300\": #4dd0e1,\n \"400\": #26c6da,\n \"500\": #00bcd4,\n \"600\": #00acc1,\n \"700\": #0097a7,\n \"800\": #00838f,\n \"900\": #006064,\n \"a100\": #84ffff,\n \"a200\": #18ffff,\n \"a400\": #00e5ff,\n \"a700\": #00b8d4\n);\n\n$clr-cyan: map-get($clr-cyan-list, \"base\");\n\n$clr-cyan-50: map-get($clr-cyan-list, \"50\");\n$clr-cyan-100: map-get($clr-cyan-list, \"100\");\n$clr-cyan-200: map-get($clr-cyan-list, \"200\");\n$clr-cyan-300: map-get($clr-cyan-list, \"300\");\n$clr-cyan-400: map-get($clr-cyan-list, \"400\");\n$clr-cyan-500: map-get($clr-cyan-list, \"500\");\n$clr-cyan-600: map-get($clr-cyan-list, \"600\");\n$clr-cyan-700: map-get($clr-cyan-list, \"700\");\n$clr-cyan-800: map-get($clr-cyan-list, \"800\");\n$clr-cyan-900: map-get($clr-cyan-list, \"900\");\n$clr-cyan-a100: map-get($clr-cyan-list, \"a100\");\n$clr-cyan-a200: map-get($clr-cyan-list, \"a200\");\n$clr-cyan-a400: map-get($clr-cyan-list, \"a400\");\n$clr-cyan-a700: map-get($clr-cyan-list, \"a700\");\n\n\n//\n// Teal\n//\n\n$clr-teal-list: (\n \"base\": #009688,\n \"50\": #e0f2f1,\n \"100\": #b2dfdb,\n \"200\": #80cbc4,\n \"300\": #4db6ac,\n \"400\": #26a69a,\n \"500\": #009688,\n \"600\": #00897b,\n \"700\": #00796b,\n \"800\": #00695c,\n \"900\": #004d40,\n \"a100\": #a7ffeb,\n \"a200\": #64ffda,\n \"a400\": #1de9b6,\n \"a700\": #00bfa5\n);\n\n$clr-teal: map-get($clr-teal-list, \"base\");\n\n$clr-teal-50: map-get($clr-teal-list, \"50\");\n$clr-teal-100: map-get($clr-teal-list, \"100\");\n$clr-teal-200: map-get($clr-teal-list, \"200\");\n$clr-teal-300: map-get($clr-teal-list, \"300\");\n$clr-teal-400: map-get($clr-teal-list, \"400\");\n$clr-teal-500: map-get($clr-teal-list, \"500\");\n$clr-teal-600: map-get($clr-teal-list, \"600\");\n$clr-teal-700: map-get($clr-teal-list, \"700\");\n$clr-teal-800: map-get($clr-teal-list, \"800\");\n$clr-teal-900: map-get($clr-teal-list, \"900\");\n$clr-teal-a100: map-get($clr-teal-list, \"a100\");\n$clr-teal-a200: map-get($clr-teal-list, \"a200\");\n$clr-teal-a400: map-get($clr-teal-list, \"a400\");\n$clr-teal-a700: map-get($clr-teal-list, \"a700\");\n\n\n//\n// Green\n//\n\n$clr-green-list: (\n \"base\": #4caf50,\n \"50\": #e8f5e9,\n \"100\": #c8e6c9,\n \"200\": #a5d6a7,\n \"300\": #81c784,\n \"400\": #66bb6a,\n \"500\": #4caf50,\n \"600\": #43a047,\n \"700\": #388e3c,\n \"800\": #2e7d32,\n \"900\": #1b5e20,\n \"a100\": #b9f6ca,\n \"a200\": #69f0ae,\n \"a400\": #00e676,\n \"a700\": #00c853\n);\n\n$clr-green: map-get($clr-green-list, \"base\");\n\n$clr-green-50: map-get($clr-green-list, \"50\");\n$clr-green-100: map-get($clr-green-list, \"100\");\n$clr-green-200: map-get($clr-green-list, \"200\");\n$clr-green-300: map-get($clr-green-list, \"300\");\n$clr-green-400: map-get($clr-green-list, \"400\");\n$clr-green-500: map-get($clr-green-list, \"500\");\n$clr-green-600: map-get($clr-green-list, \"600\");\n$clr-green-700: map-get($clr-green-list, \"700\");\n$clr-green-800: map-get($clr-green-list, \"800\");\n$clr-green-900: map-get($clr-green-list, \"900\");\n$clr-green-a100: map-get($clr-green-list, \"a100\");\n$clr-green-a200: map-get($clr-green-list, \"a200\");\n$clr-green-a400: map-get($clr-green-list, \"a400\");\n$clr-green-a700: map-get($clr-green-list, \"a700\");\n\n\n//\n// Light green\n//\n\n$clr-light-green-list: (\n \"base\": #8bc34a,\n \"50\": #f1f8e9,\n \"100\": #dcedc8,\n \"200\": #c5e1a5,\n \"300\": #aed581,\n \"400\": #9ccc65,\n \"500\": #8bc34a,\n \"600\": #7cb342,\n \"700\": #689f38,\n \"800\": #558b2f,\n \"900\": #33691e,\n \"a100\": #ccff90,\n \"a200\": #b2ff59,\n \"a400\": #76ff03,\n \"a700\": #64dd17\n);\n\n$clr-light-green: map-get($clr-light-green-list, \"base\");\n\n$clr-light-green-50: map-get($clr-light-green-list, \"50\");\n$clr-light-green-100: map-get($clr-light-green-list, \"100\");\n$clr-light-green-200: map-get($clr-light-green-list, \"200\");\n$clr-light-green-300: map-get($clr-light-green-list, \"300\");\n$clr-light-green-400: map-get($clr-light-green-list, \"400\");\n$clr-light-green-500: map-get($clr-light-green-list, \"500\");\n$clr-light-green-600: map-get($clr-light-green-list, \"600\");\n$clr-light-green-700: map-get($clr-light-green-list, \"700\");\n$clr-light-green-800: map-get($clr-light-green-list, \"800\");\n$clr-light-green-900: map-get($clr-light-green-list, \"900\");\n$clr-light-green-a100: map-get($clr-light-green-list, \"a100\");\n$clr-light-green-a200: map-get($clr-light-green-list, \"a200\");\n$clr-light-green-a400: map-get($clr-light-green-list, \"a400\");\n$clr-light-green-a700: map-get($clr-light-green-list, \"a700\");\n\n\n//\n// Lime\n//\n\n$clr-lime-list: (\n \"base\": #cddc39,\n \"50\": #f9fbe7,\n \"100\": #f0f4c3,\n \"200\": #e6ee9c,\n \"300\": #dce775,\n \"400\": #d4e157,\n \"500\": #cddc39,\n \"600\": #c0ca33,\n \"700\": #afb42b,\n \"800\": #9e9d24,\n \"900\": #827717,\n \"a100\": #f4ff81,\n \"a200\": #eeff41,\n \"a400\": #c6ff00,\n \"a700\": #aeea00\n);\n\n$clr-lime: map-get($clr-lime-list, \"base\");\n\n$clr-lime-50: map-get($clr-lime-list, \"50\");\n$clr-lime-100: map-get($clr-lime-list, \"100\");\n$clr-lime-200: map-get($clr-lime-list, \"200\");\n$clr-lime-300: map-get($clr-lime-list, \"300\");\n$clr-lime-400: map-get($clr-lime-list, \"400\");\n$clr-lime-500: map-get($clr-lime-list, \"500\");\n$clr-lime-600: map-get($clr-lime-list, \"600\");\n$clr-lime-700: map-get($clr-lime-list, \"700\");\n$clr-lime-800: map-get($clr-lime-list, \"800\");\n$clr-lime-900: map-get($clr-lime-list, \"900\");\n$clr-lime-a100: map-get($clr-lime-list, \"a100\");\n$clr-lime-a200: map-get($clr-lime-list, \"a200\");\n$clr-lime-a400: map-get($clr-lime-list, \"a400\");\n$clr-lime-a700: map-get($clr-lime-list, \"a700\");\n\n\n//\n// Yellow\n//\n\n$clr-yellow-list: (\n \"base\": #ffeb3b,\n \"50\": #fffde7,\n \"100\": #fff9c4,\n \"200\": #fff59d,\n \"300\": #fff176,\n \"400\": #ffee58,\n \"500\": #ffeb3b,\n \"600\": #fdd835,\n \"700\": #fbc02d,\n \"800\": #f9a825,\n \"900\": #f57f17,\n \"a100\": #ffff8d,\n \"a200\": #ffff00,\n \"a400\": #ffea00,\n \"a700\": #ffd600\n);\n\n$clr-yellow: map-get($clr-yellow-list, \"base\");\n\n$clr-yellow-50: map-get($clr-yellow-list, \"50\");\n$clr-yellow-100: map-get($clr-yellow-list, \"100\");\n$clr-yellow-200: map-get($clr-yellow-list, \"200\");\n$clr-yellow-300: map-get($clr-yellow-list, \"300\");\n$clr-yellow-400: map-get($clr-yellow-list, \"400\");\n$clr-yellow-500: map-get($clr-yellow-list, \"500\");\n$clr-yellow-600: map-get($clr-yellow-list, \"600\");\n$clr-yellow-700: map-get($clr-yellow-list, \"700\");\n$clr-yellow-800: map-get($clr-yellow-list, \"800\");\n$clr-yellow-900: map-get($clr-yellow-list, \"900\");\n$clr-yellow-a100: map-get($clr-yellow-list, \"a100\");\n$clr-yellow-a200: map-get($clr-yellow-list, \"a200\");\n$clr-yellow-a400: map-get($clr-yellow-list, \"a400\");\n$clr-yellow-a700: map-get($clr-yellow-list, \"a700\");\n\n\n//\n// amber\n//\n\n$clr-amber-list: (\n \"base\": #ffc107,\n \"50\": #fff8e1,\n \"100\": #ffecb3,\n \"200\": #ffe082,\n \"300\": #ffd54f,\n \"400\": #ffca28,\n \"500\": #ffc107,\n \"600\": #ffb300,\n \"700\": #ffa000,\n \"800\": #ff8f00,\n \"900\": #ff6f00,\n \"a100\": #ffe57f,\n \"a200\": #ffd740,\n \"a400\": #ffc400,\n \"a700\": #ffab00\n);\n\n$clr-amber: map-get($clr-amber-list, \"base\");\n\n$clr-amber-50: map-get($clr-amber-list, \"50\");\n$clr-amber-100: map-get($clr-amber-list, \"100\");\n$clr-amber-200: map-get($clr-amber-list, \"200\");\n$clr-amber-300: map-get($clr-amber-list, \"300\");\n$clr-amber-400: map-get($clr-amber-list, \"400\");\n$clr-amber-500: map-get($clr-amber-list, \"500\");\n$clr-amber-600: map-get($clr-amber-list, \"600\");\n$clr-amber-700: map-get($clr-amber-list, \"700\");\n$clr-amber-800: map-get($clr-amber-list, \"800\");\n$clr-amber-900: map-get($clr-amber-list, \"900\");\n$clr-amber-a100: map-get($clr-amber-list, \"a100\");\n$clr-amber-a200: map-get($clr-amber-list, \"a200\");\n$clr-amber-a400: map-get($clr-amber-list, \"a400\");\n$clr-amber-a700: map-get($clr-amber-list, \"a700\");\n\n\n//\n// Orange\n//\n\n$clr-orange-list: (\n \"base\": #ff9800,\n \"50\": #fff3e0,\n \"100\": #ffe0b2,\n \"200\": #ffcc80,\n \"300\": #ffb74d,\n \"400\": #ffa726,\n \"500\": #ff9800,\n \"600\": #fb8c00,\n \"700\": #f57c00,\n \"800\": #ef6c00,\n \"900\": #e65100,\n \"a100\": #ffd180,\n \"a200\": #ffab40,\n \"a400\": #ff9100,\n \"a700\": #ff6d00\n);\n\n$clr-orange: map-get($clr-orange-list, \"base\");\n\n$clr-orange-50: map-get($clr-orange-list, \"50\");\n$clr-orange-100: map-get($clr-orange-list, \"100\");\n$clr-orange-200: map-get($clr-orange-list, \"200\");\n$clr-orange-300: map-get($clr-orange-list, \"300\");\n$clr-orange-400: map-get($clr-orange-list, \"400\");\n$clr-orange-500: map-get($clr-orange-list, \"500\");\n$clr-orange-600: map-get($clr-orange-list, \"600\");\n$clr-orange-700: map-get($clr-orange-list, \"700\");\n$clr-orange-800: map-get($clr-orange-list, \"800\");\n$clr-orange-900: map-get($clr-orange-list, \"900\");\n$clr-orange-a100: map-get($clr-orange-list, \"a100\");\n$clr-orange-a200: map-get($clr-orange-list, \"a200\");\n$clr-orange-a400: map-get($clr-orange-list, \"a400\");\n$clr-orange-a700: map-get($clr-orange-list, \"a700\");\n\n\n//\n// Deep orange\n//\n\n$clr-deep-orange-list: (\n \"base\": #ff5722,\n \"50\": #fbe9e7,\n \"100\": #ffccbc,\n \"200\": #ffab91,\n \"300\": #ff8a65,\n \"400\": #ff7043,\n \"500\": #ff5722,\n \"600\": #f4511e,\n \"700\": #e64a19,\n \"800\": #d84315,\n \"900\": #bf360c,\n \"a100\": #ff9e80,\n \"a200\": #ff6e40,\n \"a400\": #ff3d00,\n \"a700\": #dd2c00\n);\n\n$clr-deep-orange: map-get($clr-deep-orange-list, \"base\");\n\n$clr-deep-orange-50: map-get($clr-deep-orange-list, \"50\");\n$clr-deep-orange-100: map-get($clr-deep-orange-list, \"100\");\n$clr-deep-orange-200: map-get($clr-deep-orange-list, \"200\");\n$clr-deep-orange-300: map-get($clr-deep-orange-list, \"300\");\n$clr-deep-orange-400: map-get($clr-deep-orange-list, \"400\");\n$clr-deep-orange-500: map-get($clr-deep-orange-list, \"500\");\n$clr-deep-orange-600: map-get($clr-deep-orange-list, \"600\");\n$clr-deep-orange-700: map-get($clr-deep-orange-list, \"700\");\n$clr-deep-orange-800: map-get($clr-deep-orange-list, \"800\");\n$clr-deep-orange-900: map-get($clr-deep-orange-list, \"900\");\n$clr-deep-orange-a100: map-get($clr-deep-orange-list, \"a100\");\n$clr-deep-orange-a200: map-get($clr-deep-orange-list, \"a200\");\n$clr-deep-orange-a400: map-get($clr-deep-orange-list, \"a400\");\n$clr-deep-orange-a700: map-get($clr-deep-orange-list, \"a700\");\n\n\n//\n// Brown\n//\n\n$clr-brown-list: (\n \"base\": #795548,\n \"50\": #efebe9,\n \"100\": #d7ccc8,\n \"200\": #bcaaa4,\n \"300\": #a1887f,\n \"400\": #8d6e63,\n \"500\": #795548,\n \"600\": #6d4c41,\n \"700\": #5d4037,\n \"800\": #4e342e,\n \"900\": #3e2723,\n);\n\n$clr-brown: map-get($clr-brown-list, \"base\");\n\n$clr-brown-50: map-get($clr-brown-list, \"50\");\n$clr-brown-100: map-get($clr-brown-list, \"100\");\n$clr-brown-200: map-get($clr-brown-list, \"200\");\n$clr-brown-300: map-get($clr-brown-list, \"300\");\n$clr-brown-400: map-get($clr-brown-list, \"400\");\n$clr-brown-500: map-get($clr-brown-list, \"500\");\n$clr-brown-600: map-get($clr-brown-list, \"600\");\n$clr-brown-700: map-get($clr-brown-list, \"700\");\n$clr-brown-800: map-get($clr-brown-list, \"800\");\n$clr-brown-900: map-get($clr-brown-list, \"900\");\n\n\n//\n// Grey\n//\n\n$clr-grey-list: (\n \"base\": #9e9e9e,\n \"50\": #fafafa,\n \"100\": #f5f5f5,\n \"200\": #eeeeee,\n \"300\": #e0e0e0,\n \"400\": #bdbdbd,\n \"500\": #9e9e9e,\n \"600\": #757575,\n \"700\": #616161,\n \"800\": #424242,\n \"900\": #212121,\n);\n\n$clr-grey: map-get($clr-grey-list, \"base\");\n\n$clr-grey-50: map-get($clr-grey-list, \"50\");\n$clr-grey-100: map-get($clr-grey-list, \"100\");\n$clr-grey-200: map-get($clr-grey-list, \"200\");\n$clr-grey-300: map-get($clr-grey-list, \"300\");\n$clr-grey-400: map-get($clr-grey-list, \"400\");\n$clr-grey-500: map-get($clr-grey-list, \"500\");\n$clr-grey-600: map-get($clr-grey-list, \"600\");\n$clr-grey-700: map-get($clr-grey-list, \"700\");\n$clr-grey-800: map-get($clr-grey-list, \"800\");\n$clr-grey-900: map-get($clr-grey-list, \"900\");\n\n\n//\n// Blue grey\n//\n\n$clr-blue-grey-list: (\n \"base\": #607d8b,\n \"50\": #eceff1,\n \"100\": #cfd8dc,\n \"200\": #b0bec5,\n \"300\": #90a4ae,\n \"400\": #78909c,\n \"500\": #607d8b,\n \"600\": #546e7a,\n \"700\": #455a64,\n \"800\": #37474f,\n \"900\": #263238,\n);\n\n$clr-blue-grey: map-get($clr-blue-grey-list, \"base\");\n\n$clr-blue-grey-50: map-get($clr-blue-grey-list, \"50\");\n$clr-blue-grey-100: map-get($clr-blue-grey-list, \"100\");\n$clr-blue-grey-200: map-get($clr-blue-grey-list, \"200\");\n$clr-blue-grey-300: map-get($clr-blue-grey-list, \"300\");\n$clr-blue-grey-400: map-get($clr-blue-grey-list, \"400\");\n$clr-blue-grey-500: map-get($clr-blue-grey-list, \"500\");\n$clr-blue-grey-600: map-get($clr-blue-grey-list, \"600\");\n$clr-blue-grey-700: map-get($clr-blue-grey-list, \"700\");\n$clr-blue-grey-800: map-get($clr-blue-grey-list, \"800\");\n$clr-blue-grey-900: map-get($clr-blue-grey-list, \"900\");\n\n\n//\n// Black\n//\n\n$clr-black-list: (\n \"base\": #000\n);\n\n$clr-black: map-get($clr-black-list, \"base\");\n\n\n//\n// White\n//\n\n$clr-white-list: (\n \"base\": #fff\n);\n\n$clr-white: map-get($clr-white-list, \"base\");\n\n\n//\n// List for all Colors for looping\n//\n\n$clr-list-all: (\n \"red\": $clr-red-list,\n \"pink\": $clr-pink-list,\n \"purple\": $clr-purple-list,\n \"deep-purple\": $clr-deep-purple-list,\n \"indigo\": $clr-indigo-list,\n \"blue\": $clr-blue-list,\n \"light-blue\": $clr-light-blue-list,\n \"cyan\": $clr-cyan-list,\n \"teal\": $clr-teal-list,\n \"green\": $clr-green-list,\n \"light-green\": $clr-light-green-list,\n \"lime\": $clr-lime-list,\n \"yellow\": $clr-yellow-list,\n \"amber\": $clr-amber-list,\n \"orange\": $clr-orange-list,\n \"deep-orange\": $clr-deep-orange-list,\n \"brown\": $clr-brown-list,\n \"grey\": $clr-grey-list,\n \"blue-grey\": $clr-blue-grey-list,\n \"black\": $clr-black-list,\n \"white\": $clr-white-list\n);\n\n\n//\n// Typography\n//\n\n$clr-ui-display-4: $clr-grey-600;\n$clr-ui-display-3: $clr-grey-600;\n$clr-ui-display-2: $clr-grey-600;\n$clr-ui-display-1: $clr-grey-600;\n$clr-ui-headline: $clr-grey-900;\n$clr-ui-title: $clr-grey-900;\n$clr-ui-subhead-1: $clr-grey-900;\n$clr-ui-body-2: $clr-grey-900;\n$clr-ui-body-1: $clr-grey-900;\n$clr-ui-caption: $clr-grey-600;\n$clr-ui-menu: $clr-grey-900;\n$clr-ui-button: $clr-grey-900;\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Variables\n// ----------------------------------------------------------------------------\n\n// Operators\n$codehilite-operator: inherit;\n$codehilite-operator-word: inherit;\n\n// Generics\n$codehilite-generic-emph: #000000;\n$codehilite-generic-error: #AA0000;\n$codehilite-generic-heading: #999999;\n$codehilite-generic-output: #888888;\n$codehilite-generic-prompt: #555555;\n$codehilite-generic-strong: inherit;\n$codehilite-generic-subheading: #AAAAAA;\n$codehilite-generic-traceback: #AA0000;\n\n// Diffs\n$codehilite-diff-deleted: #FFDDDD;\n$codehilite-diff-inserted: #DDFFDD;\n\n// Keywords\n$codehilite-keyword: #3B78E7;\n$codehilite-keyword-constant: #A71D5D;\n$codehilite-keyword-declaration: #3B78E7;\n$codehilite-keyword-namespace: #3B78E7;\n$codehilite-keyword-pseudo: #A71D5D;\n$codehilite-keyword-reserved: #3E61A2;\n$codehilite-keyword-type: #3E61A2;\n\n// Comments\n$codehilite-comment: #999999;\n$codehilite-comment-multiline: #999999;\n$codehilite-comment-preproc: #666666;\n$codehilite-comment-single: #999999;\n$codehilite-comment-shebang: #999999;\n$codehilite-comment-special: #999999;\n\n// Names\n$codehilite-name-attribute: #C2185B;\n$codehilite-name-builtin: #C2185B;\n$codehilite-name-builtin-pseudo: #3E61A2;\n$codehilite-name-class: #C2185B;\n$codehilite-name-constant: #3E61A2;\n$codehilite-name-decorator: #666666;\n$codehilite-name-entity: #666666;\n$codehilite-name-exception: #C2185B;\n$codehilite-name-function: #C2185B;\n$codehilite-name-label: #3B5179;\n$codehilite-name-namespace: #EC407A;\n$codehilite-name-tag: #3B78E7;\n$codehilite-name-variable: #3E61A2;\n$codehilite-name-variable-class: #3E61A2;\n$codehilite-name-variable-instance: #3E61A2;\n$codehilite-name-variable-global: #3E61A2;\n$codehilite-name-extension: #EC407A;\n\n// Numbers\n$codehilite-literal-number: #E74C3C;\n$codehilite-literal-number-float: #E74C3C;\n$codehilite-literal-number-hex: #E74C3C;\n$codehilite-literal-number-integer: #E74C3C;\n$codehilite-literal-number-integer-long: #E74C3C;\n$codehilite-literal-number-oct: #E74C3C;\n\n// Strings\n$codehilite-literal-string: #0D904F;\n$codehilite-literal-string-backticks: #0D904F;\n$codehilite-literal-string-char: #0D904F;\n$codehilite-literal-string-doc: #999999;\n$codehilite-literal-string-double: #0D904F;\n$codehilite-literal-string-escape: #183691;\n$codehilite-literal-string-heredoc: #183691;\n$codehilite-literal-string-interpol: #183691;\n$codehilite-literal-string-other: #183691;\n$codehilite-literal-string-regex: #009926;\n$codehilite-literal-string-single: #0D904F;\n$codehilite-literal-string-symbol: #0D904F;\n\n// Miscellaneous\n$codehilite-error: #A61717;\n$codehilite-whitespace: transparent;\n\n// ----------------------------------------------------------------------------\n// Rules: syntax highlighting\n// ----------------------------------------------------------------------------\n\n// Codehilite extension\n.codehilite {\n\n // Operators\n .o { color: $codehilite-operator; }\n .ow { color: $codehilite-operator-word; }\n\n // Generics\n .ge { color: $codehilite-generic-emph; }\n .gr { color: $codehilite-generic-error; }\n .gh { color: $codehilite-generic-heading; }\n .go { color: $codehilite-generic-output; }\n .gp { color: $codehilite-generic-prompt; }\n .gs { color: $codehilite-generic-strong; }\n .gu { color: $codehilite-generic-subheading; }\n .gt { color: $codehilite-generic-traceback; }\n\n // Diffs\n .gd { background-color: $codehilite-diff-deleted; }\n .gi { background-color: $codehilite-diff-inserted; }\n\n // Keywords\n .k { color: $codehilite-keyword; }\n .kc { color: $codehilite-keyword-constant; }\n .kd { color: $codehilite-keyword-declaration; }\n .kn { color: $codehilite-keyword-namespace; }\n .kp { color: $codehilite-keyword-pseudo; }\n .kr { color: $codehilite-keyword-reserved; }\n .kt { color: $codehilite-keyword-type; }\n\n // Comments\n .c { color: $codehilite-comment; }\n .cm { color: $codehilite-comment-multiline; }\n .cp { color: $codehilite-comment-preproc; }\n .c1 { color: $codehilite-comment-single; }\n .ch { color: $codehilite-comment-shebang; }\n .cs { color: $codehilite-comment-special; }\n\n // Names\n .na { color: $codehilite-name-attribute; }\n .nb { color: $codehilite-name-builtin; }\n .bp { color: $codehilite-name-builtin-pseudo; }\n .nc { color: $codehilite-name-class; }\n .no { color: $codehilite-name-constant; }\n .nd { color: $codehilite-name-entity; }\n .ni { color: $codehilite-name-entity; }\n .ne { color: $codehilite-name-exception; }\n .nf { color: $codehilite-name-function; }\n .nl { color: $codehilite-name-label; }\n .nn { color: $codehilite-name-namespace; }\n .nt { color: $codehilite-name-tag; }\n .nv { color: $codehilite-name-variable; }\n .vc { color: $codehilite-name-variable-class; }\n .vg { color: $codehilite-name-variable-global; }\n .vi { color: $codehilite-name-variable-instance; }\n .nx { color: $codehilite-name-extension; }\n\n // Numbers\n .m { color: $codehilite-literal-number; }\n .mf { color: $codehilite-literal-number-float; }\n .mh { color: $codehilite-literal-number-hex; }\n .mi { color: $codehilite-literal-number-integer; }\n .il { color: $codehilite-literal-number-integer-long; }\n .mo { color: $codehilite-literal-number-oct; }\n\n // Strings\n .s { color: $codehilite-literal-string; }\n .sb { color: $codehilite-literal-string-backticks; }\n .sc { color: $codehilite-literal-string-char; }\n .sd { color: $codehilite-literal-string-doc; }\n .s2 { color: $codehilite-literal-string-double; }\n .se { color: $codehilite-literal-string-escape; }\n .sh { color: $codehilite-literal-string-heredoc; }\n .si { color: $codehilite-literal-string-interpol; }\n .sx { color: $codehilite-literal-string-other; }\n .sr { color: $codehilite-literal-string-regex; }\n .s1 { color: $codehilite-literal-string-single; }\n .ss { color: $codehilite-literal-string-symbol; }\n\n // Miscellaneous\n .err { color: $codehilite-error; }\n .w { color: $codehilite-whitespace; }\n\n // Highlighted lines\n .hll {\n display: block;\n margin: 0 px2em(-16px, 13.6px);\n padding: 0 px2em(16px, 13.6px);\n background-color: transparentize($clr-yellow-500, 0.5);\n }\n}\n\n// ----------------------------------------------------------------------------\n// Rules: layout\n// ----------------------------------------------------------------------------\n\n// Block with line numbers\n.codehilitetable {\n display: block;\n overflow: hidden;\n\n // Set table elements to block layout, because otherwise the whole flexbox\n // hacking won't work correctly\n tbody,\n td {\n display: block;\n padding: 0;\n }\n\n // We need to use flexbox layout, because otherwise it's not possible to\n // make the code container scroll while keeping the line numbers static\n tr {\n display: flex;\n }\n\n // The pre tags are nested inside a table, so we need to remove the\n // margin because it collapses below all the overflows\n pre {\n margin: 0;\n }\n\n // Disable user selection, so code can be easily copied without\n // accidentally also copying the line numbers\n .linenos {\n padding: px2rem(10.5px) px2em(16px, 13.6px);\n padding-right: 0;\n font-size: px2em(13.6px);\n background-color: var(--md-code-bg-color);\n user-select: none;\n }\n\n // Add spacing to line number container\n .linenodiv {\n padding-right: px2em(8px, 13.6px);\n box-shadow: inset px2rem(-1px) 0 var(--md-default-fg-color--lightest);\n\n // Reset spacings\n pre {\n color: var(--md-default-fg-color--lighter);\n text-align: right;\n }\n }\n\n // The table cell containing the code container wrapper and code should\n // stretch horizontally to the remaining space\n .code {\n flex: 1;\n overflow: hidden;\n }\n}\n\n// Scoped in typesetted content to match specificity of regular content\n.md-typeset {\n\n // Block with line numbers\n .codehilitetable {\n margin: 1em 0;\n direction: ltr;\n border-radius: px2rem(2px);\n\n // Remove rounded borders\n code {\n border-radius: 0;\n }\n }\n\n // [mobile -]: Stretch to whole width\n @include break-to-device(mobile) {\n\n // Full-width container\n > .codehilite {\n margin: 1em px2rem(-16px);\n\n // Stretch highlighted lines\n .hll {\n margin: 0 px2rem(-16px);\n padding: 0 px2rem(16px);\n }\n\n // Remove rounded borders\n code {\n border-radius: 0;\n }\n }\n\n // Full-width container on top-level\n > .codehilitetable {\n margin: 1em px2rem(-16px);\n border-radius: 0;\n\n // Stretch highlighted lines\n .hll {\n margin: 0 px2rem(-16px);\n padding: 0 px2rem(16px);\n }\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Icon definitions\n:root {\n --md-footnotes-icon: url(\"{{ keyboard-return }}\");\n}\n\n// ----------------------------------------------------------------------------\n\n// Scoped in typesetted content to match specificity of regular content\n.md-typeset {\n\n // All footnote references\n [id^=\"fnref:\"] {\n display: inline-block;\n\n // Targeted anchor\n &:target {\n margin-top: -1 * px2rem(48px + 12px + 16px);\n padding-top: px2rem(48px + 12px + 16px);\n pointer-events: none;\n }\n }\n\n // All footnote back references\n [id^=\"fn:\"] {\n\n // Add spacing to anchor for offset\n &::before {\n display: none;\n height: 0;\n content: \"\";\n }\n\n // Targeted anchor\n &:target::before {\n display: block;\n margin-top: -1 * px2rem(48px + 12px + 10px);\n padding-top: px2rem(48px + 12px + 10px);\n pointer-events: none;\n }\n }\n\n // Footnotes extension\n .footnote {\n color: var(--md-default-fg-color--light);\n font-size: ms(-1);\n\n // Remove additional spacing on footnotes\n ol {\n margin-left: 0;\n }\n\n // Footnote\n li {\n transition: color 125ms;\n\n // Darken color for targeted footnote\n &:target {\n color: var(--md-default-fg-color);\n }\n\n // Remove spacing on first element\n :first-child {\n margin-top: 0;\n }\n\n // Make back references visible on container hover\n &:hover .footnote-backref,\n &:target .footnote-backref {\n transform: translateX(0);\n opacity: 1;\n }\n\n // Hovered back reference\n &:hover .footnote-backref:hover {\n color: var(--md-accent-fg-color);\n }\n }\n }\n\n // Footnote reference\n .footnote-ref {\n display: inline-block;\n pointer-events: initial;\n }\n\n // Footnote back reference\n .footnote-backref {\n display: inline-block;\n color: var(--md-primary-fg-color);\n // Hack: remove Unicode arrow for icon\n font-size: 0;\n vertical-align: text-bottom;\n transform: translateX(px2rem(5px));\n opacity: 0;\n transition:\n color 250ms,\n transform 250ms 250ms,\n opacity 125ms 250ms;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n transform: translateX(px2rem(-5px));\n }\n\n // Back reference icon\n &::before {\n display: inline-block;\n width: px2rem(16px);\n height: px2rem(16px);\n background-color: currentColor;\n mask-image: var(--md-footnotes-icon);\n content: \"\";\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n\n // Flip icon vertically\n svg {\n transform: scaleX(-1)\n }\n }\n }\n\n // Always show for print\n @media print {\n color: var(--md-primary-fg-color);\n transform: translateX(0);\n opacity: 1;\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Scoped in typesetted content to match specificity of regular content\n.md-typeset {\n\n // Permalinks extension\n .headerlink {\n display: inline-block;\n margin-left: px2rem(10px);\n // Hack: if we don't set visibility hidden, the text content of the node\n // will include the headerlink character, which is why Google indexes them.\n visibility: hidden;\n opacity: 0;\n transition:\n color 250ms,\n visibility 0ms 500ms,\n opacity 125ms;\n\n // Adjust for RTL languages\n [dir=\"rtl\"] & {\n margin-right: px2rem(10px);\n margin-left: initial;\n }\n\n // Higher specificity for color due to palettes integration\n html body & {\n color: var(--md-default-fg-color--lighter);\n }\n\n // Hide for print\n @media print {\n display: none;\n }\n }\n\n // Make permalink visible on hover\n :hover > .headerlink,\n :target > .headerlink,\n .headerlink:focus {\n visibility: visible;\n opacity: 1;\n transition:\n color 250ms,\n visibility 0ms,\n opacity 125ms;\n }\n\n // Active or targeted permalink\n :target > .headerlink,\n .headerlink:focus,\n .headerlink:hover {\n color: var(--md-accent-fg-color);\n }\n\n // Correct anchor offset for link blurring\n @each $level, $delta in (\n h1 h2 h3: 8px,\n h4: 9px,\n h5 h6: 12px,\n ) {\n %#{nth($level, 1)} {\n\n // Un-targeted anchor\n &::before {\n display: block;\n margin-top: -1 * px2rem($delta);\n padding-top: px2rem($delta);\n content: \"\";\n }\n\n // Targeted anchor (48px from header, 12px from sidebar offset)\n &:target::before {\n margin-top: -1 * px2rem(48px + 12px + $delta);\n padding-top: px2rem(48px + 12px + $delta);\n }\n }\n\n // Define levels\n @for $n from 1 through length($level) {\n #{nth($level, $n)}[id] {\n @extend %#{nth($level, 1)};\n }\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// stylelint-disable selector-class-pattern\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Scoped in typesetted content to match specificity of regular content\n.md-typeset {\n\n // MathJax integration - add padding to omit vertical scrollbar\n .MJXc-display {\n margin: 0.75em 0;\n padding: 0.75em 0;\n overflow: auto;\n touch-action: auto;\n }\n\n // Stretch top-level containers\n > p > .MJXc-display {\n\n // [mobile -]: Stretch to whole width\n @include break-to-device(mobile) {\n margin: 0.75em px2rem(-16px);\n padding: 0.25em px2rem(16px);\n }\n }\n\n // Remove outline on tab index\n .MathJax_CHTML {\n outline: 0;\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Scoped in typesetted content to match specificity of regular content\n.md-typeset {\n\n // Deletions, additions and comments\n del.critic,\n ins.critic,\n .critic.comment {\n padding: 0 px2em(4px, 16px);\n border-radius: px2rem(2px);\n box-decoration-break: clone;\n }\n\n // Deletion\n del.critic {\n background-color: $codehilite-diff-deleted;\n }\n\n // Addition\n ins.critic {\n background-color: $codehilite-diff-inserted;\n }\n\n // Comment\n .critic.comment {\n color: $codehilite-comment;\n\n // Comment opening mark\n &::before {\n content: \"/* \";\n }\n\n // Comment closing mark\n &::after {\n content: \" */\";\n }\n }\n\n // Block\n .critic.block {\n display: block;\n margin: 1em 0;\n padding-right: px2rem(16px);\n padding-left: px2rem(16px);\n overflow: auto;\n box-shadow: none;\n\n // Decrease spacing on first element\n :first-child {\n margin-top: 0.5em;\n }\n\n // Decrease spacing on last element\n :last-child {\n margin-bottom: 0.5em;\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Icon definitions\n:root {\n --md-details-icon: url(\"{{ chevron-right }}\");\n}\n\n// ----------------------------------------------------------------------------\n\n// Scoped in typesetted content to match specificity of regular content\n.md-typeset {\n\n // Details extension\n details {\n @extend .admonition;\n\n display: block;\n padding-top: 0;\n overflow: visible;\n\n\n // Rotate title icon\n &[open] > summary::after {\n transform: rotate(90deg);\n }\n\n // Remove bottom spacing for closed details\n &:not([open]) {\n padding-bottom: 0;\n\n // We cannot set overflow: hidden, as the outline would not be visible,\n // so we need to correct the border radius\n > summary {\n border-bottom-right-radius: px2rem(2px);\n }\n }\n\n // Hack: omit margin collapse\n &::after {\n display: table;\n content: \"\";\n }\n }\n\n // Details title\n summary {\n @extend .admonition-title;\n\n display: block;\n min-height: px2rem(20px);\n padding: px2rem(8px) px2rem(36px) px2rem(8px) px2rem(40px);\n border-top-right-radius: px2rem(2px);\n cursor: pointer;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n padding: px2rem(8px) px2rem(40px) px2rem(8px) px2rem(36px);\n }\n\n // Remove default details marker\n &::-webkit-details-marker {\n display: none;\n }\n\n // Details marker\n &::after {\n position: absolute;\n top: px2rem(8px);\n right: px2rem(8px);\n width: px2rem(20px);\n height: px2rem(20px);\n background-color: currentColor;\n mask-image: var(--md-details-icon);\n transform: rotate(0deg);\n transition: transform 250ms;\n content: \"\";\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n right: initial;\n left: px2rem(8px);\n transform: rotate(180deg);\n }\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Scoped in typesetted content to match specificity of regular content\n.md-typeset {\n\n // Emojis\n img.emojione,\n img.twemoji,\n img.gemoji {\n width: px2em(18px);\n vertical-align: -15%;\n }\n\n // Inlined SVG icons via mkdocs-material-extensions\n span.twemoji {\n display: inline-block;\n height: px2em(18px);\n vertical-align: text-top;\n\n // Icon\n svg {\n width: px2em(18px);\n fill: currentColor;\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// When pymdownx.superfences is enabled but codehilite is disabled,\n// pymdownx.highlight will be used. When this happens, the outer container\n// and tables get this class names by default\n.highlight {\n @extend .codehilite;\n\n // Inline line numbers\n [data-linenos]::before {\n position: sticky;\n left: px2em(-16px, 13.6px);\n float: left;\n margin-right: px2em(16px, 13.6px);\n margin-left: px2em(-16px, 13.6px);\n padding-left: px2em(16px, 13.6px);\n color: var(--md-default-fg-color--lighter);\n background-color: var(--md-code-bg-color);\n box-shadow: inset px2rem(-1px) 0 var(--md-default-fg-color--lightest);\n content: attr(data-linenos);\n user-select: none;\n }\n}\n\n// Same as above, but for code blocks with line numbers enabled\n.highlighttable {\n @extend .codehilitetable;\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Scoped in typesetted content to match specificity of regular content\n.md-typeset {\n\n // Tabbed block content\n .tabbed-content {\n display: none;\n order: 99;\n width: 100%;\n box-shadow: 0 px2rem(-1px) var(--md-default-fg-color--lightest);\n\n // Mirror old superfences behavior, if there's only a single code block.\n > .codehilite:only-child pre,\n > .codehilitetable:only-child,\n > .highlight:only-child pre,\n > .highlighttable:only-child {\n margin: 0;\n\n // Remove rounded borders at the top\n > code {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n }\n }\n\n // Nested tabs\n > .tabbed-set {\n margin: 0;\n }\n }\n\n // Tabbed block container\n .tabbed-set {\n position: relative;\n display: flex;\n flex-wrap: wrap;\n margin: 1em 0;\n border-radius: px2rem(2px);\n\n // Hide radio buttons\n > input {\n display: none;\n\n // Active tab label\n &:checked + label {\n color: var(--md-accent-fg-color);\n border-color: var(--md-accent-fg-color);\n\n // Show tabbed block content\n & + .tabbed-content {\n display: block;\n }\n }\n }\n\n // Tab label\n > label {\n z-index: 1;\n width: auto;\n padding: px2rem(12px) 1.25em px2rem(10px);\n color: var(--md-default-fg-color--light);\n font-weight: 700;\n font-size: ms(-1);\n border-bottom: px2rem(2px) solid transparent;\n cursor: pointer;\n transition: color 125ms;\n\n // Hovered tab label\n html &:hover {\n color: var(--md-accent-fg-color);\n }\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Rules\n// ----------------------------------------------------------------------------\n\n// Icon definitions\n:root {\n --md-tasklist-icon: url(\"{{ checkbox-blank-circle }}\");\n --md-tasklist-icon--checked: url(\"{{ check-circle }}\");\n}\n\n// ----------------------------------------------------------------------------\n\n// Scoped in typesetted content to match specificity of regular content\n.md-typeset {\n\n // Remove list icon on task items\n .task-list-item {\n position: relative;\n list-style-type: none;\n\n // Make checkbox items align with normal list items, but position\n // everything in ems for correct layout at smaller font sizes\n [type=\"checkbox\"] {\n position: absolute;\n top: 0.45em;\n left: -2em;\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n right: -2em;\n left: initial;\n }\n }\n }\n\n // Wrapper for list controls, in case custom checkboxes are enabled\n .task-list-control {\n\n // Checkbox icon in unchecked state\n .task-list-indicator::before {\n position: absolute;\n top: 0.15em;\n left: px2em(-24px);\n width: px2em(20px);\n height: px2em(20px);\n background-color: var(--md-default-fg-color--lightest);\n mask-image: var(--md-tasklist-icon);\n content: \"\";\n\n // Adjust for right-to-left languages\n [dir=\"rtl\"] & {\n right: px2em(-24px);\n left: initial;\n }\n }\n\n // Checkbox icon in checked state\n [type=\"checkbox\"]:checked + .task-list-indicator::before {\n background-color: $clr-green-a400;\n mask-image: var(--md-tasklist-icon--checked);\n }\n\n // Hide original checkbox behind icon\n [type=\"checkbox\"] {\n z-index: -1;\n opacity: 0;\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Variables\n// ----------------------------------------------------------------------------\n\n///\n/// Device-specific breakpoints\n///\n/// @example\n/// $break-devices: (\n/// mobile: (\n/// portrait: 220px 479px,\n/// landscape: 480px 719px\n/// ),\n/// tablet: (\n/// portrait: 720px 959px,\n/// landscape: 960px 1219px\n/// ),\n/// screen: (\n/// small: 1220px 1599px,\n/// medium: 1600px 1999px,\n/// large: 2000px\n/// )\n/// );\n///\n$break-devices: () !default;\n\n// ----------------------------------------------------------------------------\n// Helpers\n// ----------------------------------------------------------------------------\n\n///\n/// Choose minimum and maximum device widths\n///\n@function break-select-min-max($devices) {\n $min: 1000000;\n $max: 0;\n @each $key, $value in $devices {\n @while type-of($value) == map {\n $value: break-select-min-max($value);\n }\n @if type-of($value) == list {\n @each $number in $value {\n @if type-of($number) == number {\n $min: min($number, $min);\n @if $max != null {\n $max: max($number, $max);\n }\n } @else {\n @error \"Invalid number: #{$number}\";\n }\n }\n } @else if type-of($value) == number {\n $min: min($value, $min);\n $max: null;\n } @else {\n @error \"Invalid value: #{$value}\";\n }\n }\n @return $min, $max;\n}\n\n///\n/// Select minimum and maximum widths for a device breakpoint\n///\n@function break-select-device($device) {\n $current: $break-devices;\n @for $n from 1 through length($device) {\n @if type-of($current) == map {\n $current: map-get($current, nth($device, $n));\n } @else {\n @error \"Invalid device map: #{$devices}\";\n }\n }\n @if type-of($current) == list or type-of($current) == number {\n $current: (default: $current);\n }\n @return break-select-min-max($current);\n}\n\n// ----------------------------------------------------------------------------\n// Mixins\n// ----------------------------------------------------------------------------\n\n///\n/// A minimum-maximum media query breakpoint\n///\n@mixin break-at($breakpoint) {\n @if type-of($breakpoint) == number {\n @media screen and (min-width: $breakpoint) {\n @content;\n }\n } @else if type-of($breakpoint) == list {\n $min: nth($breakpoint, 1);\n $max: nth($breakpoint, 2);\n @if type-of($min) == number and type-of($max) == number {\n @media screen and (min-width: $min) and (max-width: $max) {\n @content;\n }\n } @else {\n @error \"Invalid breakpoint: #{$breakpoint}\";\n }\n } @else {\n @error \"Invalid breakpoint: #{$breakpoint}\";\n }\n}\n\n///\n/// An orientation media query breakpoint\n///\n@mixin break-at-orientation($breakpoint) {\n @if type-of($breakpoint) == string {\n @media screen and (orientation: $breakpoint) {\n @content;\n }\n } @else {\n @error \"Invalid breakpoint: #{$breakpoint}\";\n }\n}\n\n///\n/// A maximum-aspect-ratio media query breakpoint\n///\n@mixin break-at-ratio($breakpoint) {\n @if type-of($breakpoint) == number {\n @media screen and (max-aspect-ratio: $breakpoint) {\n @content;\n }\n } @else {\n @error \"Invalid breakpoint: #{$breakpoint}\";\n }\n}\n\n///\n/// A minimum-maximum media query device breakpoint\n///\n@mixin break-at-device($device) {\n @if type-of($device) == string {\n $device: $device,;\n }\n @if type-of($device) == list {\n $breakpoint: break-select-device($device);\n @if nth($breakpoint, 2) != null {\n $min: nth($breakpoint, 1);\n $max: nth($breakpoint, 2);\n @media screen and (min-width: $min) and (max-width: $max) {\n @content;\n }\n } @else {\n @error \"Invalid device: #{$device}\";\n }\n } @else {\n @error \"Invalid device: #{$device}\";\n }\n}\n\n///\n/// A minimum media query device breakpoint\n///\n@mixin break-from-device($device) {\n @if type-of($device) == string {\n $device: $device,;\n }\n @if type-of($device) == list {\n $breakpoint: break-select-device($device);\n $min: nth($breakpoint, 1);\n @media screen and (min-width: $min) {\n @content;\n }\n } @else {\n @error \"Invalid device: #{$device}\";\n }\n}\n\n///\n/// A maximum media query device breakpoint\n///\n@mixin break-to-device($device) {\n @if type-of($device) == string {\n $device: $device,;\n }\n @if type-of($device) == list {\n $breakpoint: break-select-device($device);\n $max: nth($breakpoint, 2);\n @media screen and (max-width: $max) {\n @content;\n }\n } @else {\n @error \"Invalid device: #{$device}\";\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/docs/assets/stylesheets/palette.b302131d.min.css b/docs/assets/stylesheets/palette.b302131d.min.css new file mode 100644 index 0000000..a26feba --- /dev/null +++ b/docs/assets/stylesheets/palette.b302131d.min.css @@ -0,0 +1,3 @@ +[data-md-color-primary=red]{--md-primary-fg-color: hsla(1deg, 83%, 63%, 1);--md-primary-fg-color--light: hsla(0deg, 73%, 77%, 1);--md-primary-fg-color--dark: hsla(1deg, 77%, 55%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-primary=pink]{--md-primary-fg-color: hsla(340deg, 82%, 52%, 1);--md-primary-fg-color--light: hsla(340deg, 82%, 76%, 1);--md-primary-fg-color--dark: hsla(336deg, 78%, 43%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-primary=purple]{--md-primary-fg-color: hsla(291deg, 47%, 51%, 1);--md-primary-fg-color--light: hsla(291deg, 47%, 71%, 1);--md-primary-fg-color--dark: hsla(287deg, 65%, 40%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-primary=deep-purple]{--md-primary-fg-color: hsla(262deg, 47%, 55%, 1);--md-primary-fg-color--light: hsla(261deg, 46%, 74%, 1);--md-primary-fg-color--dark: hsla(262deg, 52%, 47%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-primary=indigo]{--md-primary-fg-color: hsla(231deg, 48%, 48%, 1);--md-primary-fg-color--light: hsla(231deg, 44%, 74%, 1);--md-primary-fg-color--dark: hsla(232deg, 54%, 41%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-primary=blue]{--md-primary-fg-color: hsla(207deg, 90%, 54%, 1);--md-primary-fg-color--light: hsla(207deg, 90%, 77%, 1);--md-primary-fg-color--dark: hsla(210deg, 79%, 46%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-primary=light-blue]{--md-primary-fg-color: hsla(199deg, 98%, 48%, 1);--md-primary-fg-color--light: hsla(199deg, 92%, 74%, 1);--md-primary-fg-color--dark: hsla(201deg, 98%, 41%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-primary=cyan]{--md-primary-fg-color: hsla(187deg, 100%, 42%, 1);--md-primary-fg-color--light: hsla(187deg, 72%, 71%, 1);--md-primary-fg-color--dark: hsla(186deg, 100%, 33%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-primary=teal]{--md-primary-fg-color: hsla(174deg, 100%, 29%, 1);--md-primary-fg-color--light: hsla(174deg, 42%, 65%, 1);--md-primary-fg-color--dark: hsla(173deg, 100%, 24%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-primary=green]{--md-primary-fg-color: hsla(122deg, 39%, 49%, 1);--md-primary-fg-color--light: hsla(122deg, 37%, 74%, 1);--md-primary-fg-color--dark: hsla(123deg, 43%, 39%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-primary=light-green]{--md-primary-fg-color: hsla(88deg, 50%, 53%, 1);--md-primary-fg-color--light: hsla(88deg, 50%, 76%, 1);--md-primary-fg-color--dark: hsla(92deg, 48%, 42%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-primary=lime]{--md-primary-fg-color: hsla(66deg, 70%, 54%, 1);--md-primary-fg-color--light: hsla(66deg, 71%, 77%, 1);--md-primary-fg-color--dark: hsla(62deg, 61%, 44%, 1);--md-primary-bg-color: var(--md-default-fg-color);--md-primary-bg-color--light: var(--md-default-fg-color--light)}[data-md-color-primary=yellow]{--md-primary-fg-color: hsla(54deg, 100%, 62%, 1);--md-primary-fg-color--light: hsla(54deg, 100%, 81%, 1);--md-primary-fg-color--dark: hsla(43deg, 96%, 58%, 1);--md-primary-bg-color: var(--md-default-fg-color);--md-primary-bg-color--light: var(--md-default-fg-color--light)}[data-md-color-primary=amber]{--md-primary-fg-color: hsla(45deg, 100%, 51%, 1);--md-primary-fg-color--light: hsla(45deg, 100%, 75%, 1);--md-primary-fg-color--dark: hsla(38deg, 100%, 50%, 1);--md-primary-bg-color: var(--md-default-fg-color);--md-primary-bg-color--light: var(--md-default-fg-color--light)}[data-md-color-primary=orange]{--md-primary-fg-color: hsla(36deg, 100%, 57%, 1);--md-primary-fg-color--light: hsla(36deg, 100%, 75%, 1);--md-primary-fg-color--dark: hsla(33deg, 100%, 49%, 1);--md-primary-bg-color: var(--md-default-fg-color);--md-primary-bg-color--light: var(--md-default-fg-color--light)}[data-md-color-primary=deep-orange]{--md-primary-fg-color: hsla(14deg, 100%, 63%, 1);--md-primary-fg-color--light: hsla(14deg, 100%, 78%, 1);--md-primary-fg-color--dark: hsla(14deg, 91%, 54%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-primary=brown]{--md-primary-fg-color: hsla(16deg, 25%, 38%, 1);--md-primary-fg-color--light: hsla(15deg, 15%, 69%, 1);--md-primary-fg-color--dark: hsla(14deg, 26%, 29%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-primary=grey]{--md-primary-fg-color: hsla(0deg, 0%, 46%, 1);--md-primary-fg-color--light: hsla(0deg, 0%, 93%, 1);--md-primary-fg-color--dark: hsla(0deg, 0%, 38%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-primary=blue-grey]{--md-primary-fg-color: hsla(199deg, 18%, 40%, 1);--md-primary-fg-color--light: hsla(200deg, 15%, 73%, 1);--md-primary-fg-color--dark: hsla(199deg, 18%, 33%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-primary=white]{--md-primary-fg-color: hsla(231deg, 48%, 48%, 1);--md-primary-fg-color--light: hsla(230deg, 44%, 64%, 1);--md-primary-fg-color--dark: hsla(232deg, 54%, 41%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-primary=white] .md-header{color:var(--md-default-fg-color);background-color:var(--md-default-bg-color)}[data-md-color-primary=white] .md-hero{color:var(--md-default-fg-color);background-color:var(--md-default-bg-color)}[data-md-color-primary=white] .md-hero--expand{border-bottom:.05rem solid var(--md-default-fg-color--lightest)}[data-md-color-primary=black]{--md-primary-fg-color: hsla(231deg, 48%, 48%, 1);--md-primary-fg-color--light: hsla(230deg, 44%, 64%, 1);--md-primary-fg-color--dark: hsla(232deg, 54%, 41%, 1);--md-primary-bg-color: var(--md-default-bg-color);--md-primary-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-primary=black] .md-header{background-color:#000}[data-md-color-primary=black] .md-hero{background-color:#000}[data-md-color-accent=red]{--md-accent-fg-color: hsla(348deg, 100%, 55%, 1);--md-accent-fg-color--transparent: hsla(348deg, 100%, 55%, 0.1);--md-accent-bg-color: var(--md-default-bg-color);--md-accent-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-accent=pink]{--md-accent-fg-color: hsla(339deg, 100%, 48%, 1);--md-accent-fg-color--transparent: hsla(339deg, 100%, 48%, 0.1);--md-accent-bg-color: var(--md-default-bg-color);--md-accent-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-accent=purple]{--md-accent-fg-color: hsla(291deg, 96%, 62%, 1);--md-accent-fg-color--transparent: hsla(291deg, 96%, 62%, 0.1);--md-accent-bg-color: var(--md-default-bg-color);--md-accent-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-accent=deep-purple]{--md-accent-fg-color: hsla(256deg, 100%, 65%, 1);--md-accent-fg-color--transparent: hsla(256deg, 100%, 65%, 0.1);--md-accent-bg-color: var(--md-default-bg-color);--md-accent-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-accent=indigo]{--md-accent-fg-color: hsla(231deg, 99%, 66%, 1);--md-accent-fg-color--transparent: hsla(231deg, 99%, 66%, 0.1);--md-accent-bg-color: var(--md-default-bg-color);--md-accent-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-accent=blue]{--md-accent-fg-color: hsla(218deg, 100%, 63%, 1);--md-accent-fg-color--transparent: hsla(218deg, 100%, 63%, 0.1);--md-accent-bg-color: var(--md-default-bg-color);--md-accent-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-accent=light-blue]{--md-accent-fg-color: hsla(203deg, 100%, 46%, 1);--md-accent-fg-color--transparent: hsla(203deg, 100%, 46%, 0.1);--md-accent-bg-color: var(--md-default-bg-color);--md-accent-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-accent=cyan]{--md-accent-fg-color: hsla(188deg, 100%, 42%, 1);--md-accent-fg-color--transparent: hsla(188deg, 100%, 42%, 0.1);--md-accent-bg-color: var(--md-default-bg-color);--md-accent-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-accent=teal]{--md-accent-fg-color: hsla(172deg, 100%, 37%, 1);--md-accent-fg-color--transparent: hsla(172deg, 100%, 37%, 0.1);--md-accent-bg-color: var(--md-default-bg-color);--md-accent-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-accent=green]{--md-accent-fg-color: hsla(145deg, 100%, 39%, 1);--md-accent-fg-color--transparent: hsla(145deg, 100%, 39%, 0.1);--md-accent-bg-color: var(--md-default-bg-color);--md-accent-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-accent=light-green]{--md-accent-fg-color: hsla(97deg, 81%, 48%, 1);--md-accent-fg-color--transparent: hsla(97deg, 81%, 48%, 0.1);--md-accent-bg-color: var(--md-default-bg-color);--md-accent-bg-color--light: var(--md-default-bg-color--light)}[data-md-color-accent=lime]{--md-accent-fg-color: hsla(75deg, 100%, 46%, 1);--md-accent-fg-color--transparent: hsla(75deg, 100%, 46%, 0.1);--md-accent-bg-color: var(--md-default-fg-color);--md-accent-bg-color--light: var(--md-default-fg-color--light)}[data-md-color-accent=yellow]{--md-accent-fg-color: hsla(50deg, 100%, 50%, 1);--md-accent-fg-color--transparent: hsla(50deg, 100%, 50%, 0.1);--md-accent-bg-color: var(--md-default-fg-color);--md-accent-bg-color--light: var(--md-default-fg-color--light)}[data-md-color-accent=amber]{--md-accent-fg-color: hsla(40deg, 100%, 50%, 1);--md-accent-fg-color--transparent: hsla(40deg, 100%, 50%, 0.1);--md-accent-bg-color: var(--md-default-fg-color);--md-accent-bg-color--light: var(--md-default-fg-color--light)}[data-md-color-accent=orange]{--md-accent-fg-color: hsla(34deg, 100%, 50%, 1);--md-accent-fg-color--transparent: hsla(34deg, 100%, 50%, 0.1);--md-accent-bg-color: var(--md-default-fg-color);--md-accent-bg-color--light: var(--md-default-fg-color--light)}[data-md-color-accent=deep-orange]{--md-accent-fg-color: hsla(14deg, 100%, 63%, 1);--md-accent-fg-color--transparent: hsla(14deg, 100%, 63%, 0.1);--md-accent-bg-color: var(--md-default-bg-color);--md-accent-bg-color--light: var(--md-default-bg-color--light)}@media screen and (max-width: 59.9375em){[data-md-color-primary=white] .md-nav__source{color:var(--md-default-fg-color);background-color:var(--md-default-fg-color--lightest)}[data-md-color-primary=black] .md-nav__source{background-color:var(--md-default-fg-color)}}@media screen and (min-width: 60em){[data-md-color-primary=white] .md-search__input{background-color:var(--md-default-fg-color--lightest)}[data-md-color-primary=white] .md-search__input+.md-search__icon{color:var(--md-default-fg-color)}[data-md-color-primary=white] .md-search__input::-webkit-input-placeholder{color:var(--md-default-fg-color--light)}[data-md-color-primary=white] .md-search__input::-moz-placeholder{color:var(--md-default-fg-color--light)}[data-md-color-primary=white] .md-search__input::-ms-input-placeholder{color:var(--md-default-fg-color--light)}[data-md-color-primary=white] .md-search__input::placeholder{color:var(--md-default-fg-color--light)}[data-md-color-primary=white] .md-search__input:hover{background-color:var(--md-default-fg-color--lighter)}[data-md-color-primary=black] .md-search__input{background-color:var(--md-default-bg-color--lighter)}[data-md-color-primary=black] .md-search__input:hover{background-color:var(--md-default-bg-color--lightest)}}@media screen and (max-width: 76.1875em){html [data-md-color-primary=white] .md-nav--primary .md-nav__title[for=__drawer]{color:var(--md-default-fg-color);background-color:var(--md-default-bg-color)}[data-md-color-primary=white] .md-hero{border-bottom:.05rem solid var(--md-default-fg-color--lightest)}html [data-md-color-primary=black] .md-nav--primary .md-nav__title[for=__drawer]{background-color:#000}}@media screen and (min-width: 76.25em){[data-md-color-primary=white] .md-tabs{color:var(--md-default-fg-color);background-color:var(--md-default-bg-color);border-bottom:.05rem solid var(--md-default-fg-color--lightest)}[data-md-color-primary=black] .md-tabs{background-color:#000}} + +/*# sourceMappingURL=palette.b302131d.min.css.map*/ \ No newline at end of file diff --git a/docs/assets/stylesheets/palette.b302131d.min.css.map b/docs/assets/stylesheets/palette.b302131d.min.css.map new file mode 100644 index 0000000..d4beebd --- /dev/null +++ b/docs/assets/stylesheets/palette.b302131d.min.css.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///./src/assets/stylesheets/palette.scss","webpack:///./src/assets/stylesheets/utilities/_break.scss"],"names":[],"mappings":"AAiEE,4BACE,+CACA,sDACA,qDAOE,kDACA,gEAXJ,6BACE,iDACA,wDACA,uDAOE,kDACA,gEAXJ,+BACE,iDACA,wDACA,uDAOE,kDACA,gEAXJ,oCACE,iDACA,wDACA,uDAOE,kDACA,gEAXJ,+BACE,iDACA,wDACA,uDAOE,kDACA,gEAXJ,6BACE,iDACA,wDACA,uDAOE,kDACA,gEAXJ,mCACE,iDACA,wDACA,uDAOE,kDACA,gEAXJ,6BACE,kDACA,wDACA,wDAOE,kDACA,gEAXJ,6BACE,kDACA,wDACA,wDAOE,kDACA,gEAXJ,8BACE,iDACA,wDACA,uDAOE,kDACA,gEAXJ,oCACE,gDACA,uDACA,sDAOE,kDACA,gEAXJ,6BACE,gDACA,uDACA,sDAIE,kDACA,gEARJ,+BACE,iDACA,wDACA,sDAIE,kDACA,gEARJ,8BACE,iDACA,wDACA,uDAIE,kDACA,gEARJ,+BACE,iDACA,wDACA,uDAIE,kDACA,gEARJ,oCACE,iDACA,wDACA,sDAOE,kDACA,gEAXJ,8BACE,gDACA,uDACA,sDAOE,kDACA,gEAXJ,6BACE,8CACA,qDACA,oDAOE,kDACA,gEAXJ,kCACE,iDACA,wDACA,uDAOE,kDACA,gEAUN,8BACE,iDACA,wDACA,uDACA,kDACA,gEAGA,yCACE,iCACA,4CAIF,uCACE,iCACA,4CAGA,+CACE,gEAsEN,8BACE,iDACA,wDACA,uDACA,kDACA,gEAGA,yCACE,sBAIF,uCACE,sBAqEF,2BACE,iDACA,gEAOE,iDACA,+DAVJ,4BACE,iDACA,gEAOE,iDACA,+DAVJ,8BACE,gDACA,+DAOE,iDACA,+DAVJ,mCACE,iDACA,gEAOE,iDACA,+DAVJ,8BACE,gDACA,+DAOE,iDACA,+DAVJ,4BACE,iDACA,gEAOE,iDACA,+DAVJ,kCACE,iDACA,gEAOE,iDACA,+DAVJ,4BACE,iDACA,gEAOE,iDACA,+DAVJ,4BACE,iDACA,gEAOE,iDACA,+DAVJ,6BACE,iDACA,gEAOE,iDACA,+DAVJ,mCACE,+CACA,8DAOE,iDACA,+DAVJ,4BACE,gDACA,+DAIE,iDACA,+DAPJ,8BACE,gDACA,+DAIE,iDACA,+DAPJ,6BACE,gDACA,+DAIE,iDACA,+DAPJ,8BACE,gDACA,+DAIE,iDACA,+DAPJ,mCACE,gDACA,+DAOE,iDACA,+DChEF,yCD3FA,8CACE,iCACA,sDAiFF,8CACE,4CAlFA,CCuEF,oCD/DA,gDACE,sDAGA,iEACE,iCAIF,2EACE,wCADF,kEACE,wCADF,uEACE,wCADF,6DACE,wCAIF,sDACE,qDAmEJ,gDACE,qDAGA,sDACE,sDAxEA,CCkEJ,yCDzDA,iFACE,iCACA,4CAIF,uCACE,gEAiEF,iFACE,sBAlEA,CCgCF,uCDxBA,uCACE,iCACA,4CACA,gEA+DF,uCACE,sBAhEA,C","file":"assets/stylesheets/palette.b302131d.min.css","sourcesContent":["////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Dependencies\n// ----------------------------------------------------------------------------\n\n@import \"modularscale\";\n@import \"material-color\";\n\n// ----------------------------------------------------------------------------\n// Local imports\n// ----------------------------------------------------------------------------\n\n@import \"utilities/break\";\n@import \"utilities/convert\";\n\n@import \"config\";\n\n// ----------------------------------------------------------------------------\n// Rules: primary colors\n// ----------------------------------------------------------------------------\n\n@each $name, $colors in (\n \"red\": $clr-red-400 $clr-red-200 $clr-red-600,\n \"pink\": $clr-pink-500 $clr-pink-200 $clr-pink-700,\n \"purple\": $clr-purple-400 $clr-purple-200 $clr-purple-600,\n \"deep-purple\": $clr-deep-purple-400 $clr-deep-purple-200 $clr-deep-purple-500,\n \"indigo\": $clr-indigo-500 $clr-indigo-200 $clr-indigo-700,\n \"blue\": $clr-blue-500 $clr-blue-200 $clr-blue-700,\n \"light-blue\": $clr-light-blue-500 $clr-light-blue-200 $clr-light-blue-700,\n \"cyan\": $clr-cyan-500 $clr-cyan-200 $clr-cyan-700,\n \"teal\": $clr-teal-500 $clr-teal-200 $clr-teal-700,\n \"green\": $clr-green-500 $clr-green-200 $clr-green-700,\n \"light-green\": $clr-light-green-500 $clr-light-green-200 $clr-light-green-700,\n \"lime\": $clr-lime-500 $clr-lime-200 $clr-lime-700,\n \"yellow\": $clr-yellow-500 $clr-yellow-200 $clr-yellow-700,\n \"amber\": $clr-amber-500 $clr-amber-200 $clr-amber-700,\n \"orange\": $clr-orange-400 $clr-orange-200 $clr-orange-600,\n \"deep-orange\": $clr-deep-orange-400 $clr-deep-orange-200 $clr-deep-orange-600,\n \"brown\": $clr-brown-500 $clr-brown-200 $clr-brown-700,\n \"grey\": $clr-grey-600 $clr-grey-200 $clr-grey-700,\n \"blue-grey\": $clr-blue-grey-600 $clr-blue-grey-200 $clr-blue-grey-700\n) {\n\n // Color palette\n [data-md-color-primary=\"#{$name}\"] {\n --md-primary-fg-color: hsla(#{hex2hsl(nth($colors, 1))}, 1);\n --md-primary-fg-color--light: hsla(#{hex2hsl(nth($colors, 2))}, 1);\n --md-primary-fg-color--dark: hsla(#{hex2hsl(nth($colors, 3))}, 1);\n\n // Inverted text for lighter shades\n @if index(\"lime\" \"yellow\" \"amber\" \"orange\", $name) {\n --md-primary-bg-color: var(--md-default-fg-color);\n --md-primary-bg-color--light: var(--md-default-fg-color--light);\n } @else {\n --md-primary-bg-color: var(--md-default-bg-color);\n --md-primary-bg-color--light: var(--md-default-bg-color--light);\n }\n }\n}\n\n// ----------------------------------------------------------------------------\n// Rules: white\n// ----------------------------------------------------------------------------\n\n// Color palette\n[data-md-color-primary=\"white\"] {\n --md-primary-fg-color: hsla(#{hex2hsl($clr-indigo-500)}, 1);\n --md-primary-fg-color--light: hsla(#{hex2hsl($clr-indigo-300)}, 1);\n --md-primary-fg-color--dark: hsla(#{hex2hsl($clr-indigo-700)}, 1);\n --md-primary-bg-color: var(--md-default-bg-color);\n --md-primary-bg-color--light: var(--md-default-bg-color--light);\n\n // Application header (stays always on top)\n .md-header {\n color: var(--md-default-fg-color);\n background-color: var(--md-default-bg-color);\n }\n\n // Hero teaser\n .md-hero {\n color: var(--md-default-fg-color);\n background-color: var(--md-default-bg-color);\n\n // Add a border if there are no tabs\n &--expand {\n border-bottom: px2rem(1px) solid var(--md-default-fg-color--lightest);\n }\n }\n\n // [tablet portrait -]: Layered navigation\n @include break-to-device(tablet portrait) {\n\n // Repository containing source\n .md-nav__source {\n color: var(--md-default-fg-color);\n background-color: var(--md-default-fg-color--lightest);\n }\n }\n\n // [tablet portrait +]: Change color of search input\n @include break-from-device(tablet landscape) {\n\n // Search input\n .md-search__input {\n background-color: var(--md-default-fg-color--lightest);\n\n // Icon color\n + .md-search__icon {\n color: var(--md-default-fg-color);\n }\n\n // Placeholder color\n &::placeholder {\n color: var(--md-default-fg-color--light);\n }\n\n // Hovered search field\n &:hover {\n background-color: var(--md-default-fg-color--lighter);\n }\n }\n }\n\n // [tablet -]: Layered navigation\n @include break-to-device(tablet) {\n\n // Site title in main navigation\n html & .md-nav--primary .md-nav__title[for=\"__drawer\"] {\n color: var(--md-default-fg-color);\n background-color: var(--md-default-bg-color);\n }\n\n // Hero teaser\n .md-hero {\n border-bottom: px2rem(1px) solid var(--md-default-fg-color--lightest);\n }\n }\n\n // [screen +]: Set background color for tabs\n @include break-from-device(screen) {\n\n // Tabs with outline\n .md-tabs {\n color: var(--md-default-fg-color);\n background-color: var(--md-default-bg-color);\n border-bottom: px2rem(1px) solid var(--md-default-fg-color--lightest);\n }\n }\n}\n\n// ----------------------------------------------------------------------------\n// Rules: black\n// ----------------------------------------------------------------------------\n\n// Color palette\n[data-md-color-primary=\"black\"] {\n --md-primary-fg-color: hsla(#{hex2hsl($clr-indigo-500)}, 1);\n --md-primary-fg-color--light: hsla(#{hex2hsl($clr-indigo-300)}, 1);\n --md-primary-fg-color--dark: hsla(#{hex2hsl($clr-indigo-700)}, 1);\n --md-primary-bg-color: var(--md-default-bg-color);\n --md-primary-bg-color--light: var(--md-default-bg-color--light);\n\n // Application header (stays always on top)\n .md-header {\n background-color: hsla(0, 0%, 0%, 1);\n }\n\n // Hero teaser\n .md-hero {\n background-color: hsla(0, 0%, 0%, 1);\n }\n\n // [tablet portrait -]: Layered navigation\n @include break-to-device(tablet portrait) {\n\n // Repository containing source\n .md-nav__source {\n background-color: var(--md-default-fg-color);\n }\n }\n\n // [tablet landscape +]: Header-embedded search\n @include break-from-device(tablet landscape) {\n\n // Search input\n .md-search__input {\n background-color: var(--md-default-bg-color--lighter);\n\n // Hovered search field\n &:hover {\n background-color: var(--md-default-bg-color--lightest);\n }\n }\n }\n\n // [tablet -]: Layered navigation\n @include break-to-device(tablet) {\n\n // Site title in main navigation\n html & .md-nav--primary .md-nav__title[for=\"__drawer\"] {\n background-color: hsla(0, 0%, 0%, 1);\n }\n }\n\n // [screen +]: Set background color for tabs\n @include break-from-device(screen) {\n\n // Tabs with outline\n .md-tabs {\n background-color: hsla(0, 0%, 0%, 1);\n }\n }\n}\n\n// ----------------------------------------------------------------------------\n// Rules: accent colors\n// ----------------------------------------------------------------------------\n\n@each $name, $color in (\n \"red\": $clr-red-a400,\n \"pink\": $clr-pink-a400,\n \"purple\": $clr-purple-a200,\n \"deep-purple\": $clr-deep-purple-a200,\n \"indigo\": $clr-indigo-a200,\n \"blue\": $clr-blue-a200,\n \"light-blue\": $clr-light-blue-a700,\n \"cyan\": $clr-cyan-a700,\n \"teal\": $clr-teal-a700,\n \"green\": $clr-green-a700,\n \"light-green\": $clr-light-green-a700,\n \"lime\": $clr-lime-a700,\n \"yellow\": $clr-yellow-a700,\n \"amber\": $clr-amber-a700,\n \"orange\": $clr-orange-a400,\n \"deep-orange\": $clr-deep-orange-a200\n) {\n\n // Color palette\n [data-md-color-accent=\"#{$name}\"] {\n --md-accent-fg-color: hsla(#{hex2hsl($color)}, 1);\n --md-accent-fg-color--transparent: hsla(#{hex2hsl($color)}, 0.1);\n\n // Inverted text for lighter shades\n @if index(\"lime\" \"yellow\" \"amber\" \"orange\", $name) {\n --md-accent-bg-color: var(--md-default-fg-color);\n --md-accent-bg-color--light: var(--md-default-fg-color--light);\n } @else {\n --md-accent-bg-color: var(--md-default-bg-color);\n --md-accent-bg-color--light: var(--md-default-bg-color--light);\n }\n }\n}\n","////\n/// Copyright (c) 2016-2020 Martin Donath \n///\n/// Permission is hereby granted, free of charge, to any person obtaining a\n/// copy of this software and associated documentation files (the \"Software\"),\n/// to deal in the Software without restriction, including without limitation\n/// the rights to use, copy, modify, merge, publish, distribute, sublicense,\n/// and/or sell copies of the Software, and to permit persons to whom the\n/// Software is furnished to do so, subject to the following conditions:\n///\n/// The above copyright notice and this permission notice shall be included in\n/// all copies or substantial portions of the Software.\n///\n/// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL\n/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n/// DEALINGS\n////\n\n// ----------------------------------------------------------------------------\n// Variables\n// ----------------------------------------------------------------------------\n\n///\n/// Device-specific breakpoints\n///\n/// @example\n/// $break-devices: (\n/// mobile: (\n/// portrait: 220px 479px,\n/// landscape: 480px 719px\n/// ),\n/// tablet: (\n/// portrait: 720px 959px,\n/// landscape: 960px 1219px\n/// ),\n/// screen: (\n/// small: 1220px 1599px,\n/// medium: 1600px 1999px,\n/// large: 2000px\n/// )\n/// );\n///\n$break-devices: () !default;\n\n// ----------------------------------------------------------------------------\n// Helpers\n// ----------------------------------------------------------------------------\n\n///\n/// Choose minimum and maximum device widths\n///\n@function break-select-min-max($devices) {\n $min: 1000000;\n $max: 0;\n @each $key, $value in $devices {\n @while type-of($value) == map {\n $value: break-select-min-max($value);\n }\n @if type-of($value) == list {\n @each $number in $value {\n @if type-of($number) == number {\n $min: min($number, $min);\n @if $max != null {\n $max: max($number, $max);\n }\n } @else {\n @error \"Invalid number: #{$number}\";\n }\n }\n } @else if type-of($value) == number {\n $min: min($value, $min);\n $max: null;\n } @else {\n @error \"Invalid value: #{$value}\";\n }\n }\n @return $min, $max;\n}\n\n///\n/// Select minimum and maximum widths for a device breakpoint\n///\n@function break-select-device($device) {\n $current: $break-devices;\n @for $n from 1 through length($device) {\n @if type-of($current) == map {\n $current: map-get($current, nth($device, $n));\n } @else {\n @error \"Invalid device map: #{$devices}\";\n }\n }\n @if type-of($current) == list or type-of($current) == number {\n $current: (default: $current);\n }\n @return break-select-min-max($current);\n}\n\n// ----------------------------------------------------------------------------\n// Mixins\n// ----------------------------------------------------------------------------\n\n///\n/// A minimum-maximum media query breakpoint\n///\n@mixin break-at($breakpoint) {\n @if type-of($breakpoint) == number {\n @media screen and (min-width: $breakpoint) {\n @content;\n }\n } @else if type-of($breakpoint) == list {\n $min: nth($breakpoint, 1);\n $max: nth($breakpoint, 2);\n @if type-of($min) == number and type-of($max) == number {\n @media screen and (min-width: $min) and (max-width: $max) {\n @content;\n }\n } @else {\n @error \"Invalid breakpoint: #{$breakpoint}\";\n }\n } @else {\n @error \"Invalid breakpoint: #{$breakpoint}\";\n }\n}\n\n///\n/// An orientation media query breakpoint\n///\n@mixin break-at-orientation($breakpoint) {\n @if type-of($breakpoint) == string {\n @media screen and (orientation: $breakpoint) {\n @content;\n }\n } @else {\n @error \"Invalid breakpoint: #{$breakpoint}\";\n }\n}\n\n///\n/// A maximum-aspect-ratio media query breakpoint\n///\n@mixin break-at-ratio($breakpoint) {\n @if type-of($breakpoint) == number {\n @media screen and (max-aspect-ratio: $breakpoint) {\n @content;\n }\n } @else {\n @error \"Invalid breakpoint: #{$breakpoint}\";\n }\n}\n\n///\n/// A minimum-maximum media query device breakpoint\n///\n@mixin break-at-device($device) {\n @if type-of($device) == string {\n $device: $device,;\n }\n @if type-of($device) == list {\n $breakpoint: break-select-device($device);\n @if nth($breakpoint, 2) != null {\n $min: nth($breakpoint, 1);\n $max: nth($breakpoint, 2);\n @media screen and (min-width: $min) and (max-width: $max) {\n @content;\n }\n } @else {\n @error \"Invalid device: #{$device}\";\n }\n } @else {\n @error \"Invalid device: #{$device}\";\n }\n}\n\n///\n/// A minimum media query device breakpoint\n///\n@mixin break-from-device($device) {\n @if type-of($device) == string {\n $device: $device,;\n }\n @if type-of($device) == list {\n $breakpoint: break-select-device($device);\n $min: nth($breakpoint, 1);\n @media screen and (min-width: $min) {\n @content;\n }\n } @else {\n @error \"Invalid device: #{$device}\";\n }\n}\n\n///\n/// A maximum media query device breakpoint\n///\n@mixin break-to-device($device) {\n @if type-of($device) == string {\n $device: $device,;\n }\n @if type-of($device) == list {\n $breakpoint: break-select-device($device);\n $max: nth($breakpoint, 2);\n @media screen and (max-width: $max) {\n @content;\n }\n } @else {\n @error \"Invalid device: #{$device}\";\n }\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/docs/automated-checkout-services/application_services.html b/docs/automated-checkout-services/application_services.html new file mode 100644 index 0000000..e94ca49 --- /dev/null +++ b/docs/automated-checkout-services/application_services.html @@ -0,0 +1,851 @@ + + + + + + + + + + + + + + + + + + Application Services - Automated Checkout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + +
    + +
    + + + + + + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + +
    +
    +
    + + +
    +
    +
    + + +
    +
    + + + + + + +

    Application Services

    +

    The Automated Checkout reference design utilizes two application services that are used to consume event data from the EdgeX framework.

    +

    List of application services

    +
      +
    • Controller Board Status – Handles events coming from the controller board device service.
    • +
    • Vending – The main business logic for the Automated Checkout application. This service handles events directly from the card reader device service and inference engine as well as coordinates data between each of the microservices.
    • +
    +

    Controller Board Status Application Service

    +

    Description

    +

    The as-controller-board-status application service checks the status of the controller board for changes in the state of the door, lock, temperature, and humidity, and triggers notifications if the average temperature and humidity are outside the desired ranges.

    +

    APIs

    +

    This service exposes a few REST API endpoints that are either intended to be interacted with via EdgeX's core services or directly.

    +

    All exposed HTTP responses are of the format:

    +
    {
    +    "content": "",
    +    "contentType": "json|string|<any>",
    +    "statusCode": 200,
    +    "error": false
    +}
    +
    + + +

    This means that you must parse the content field if the contentType field is json.

    +

    This section includes documentation on each API endpoint exposed by this service. Depending on how you've chosen to deploy the service, you may use localhost, as-controller-board-status or some other hostname. This document assumes localhost is used.

    +
    +

    GET: /status

    +

    The GET call will return the current controller board status information. This information can be used by other services trying to get metrics from the controller board or by a test suite to validate the controller board behavior.

    +

    Simple usage example:

    +
    curl -X GET http://localhost:48094/status
    +
    + + +

    Sample response:

    +
    {
    +    "content": "{\"lock1_status\": 0,\"lock2_status\": 0,\"door_closed\": false,\"temperature\": 30.1,\"humidity\": 26.2,\"minTemperatureStatus\": true,\"maxTemperatureStatus\": false}",
    +    "contentType": "json",
    +    "statusCode": 200,
    +    "error": false
    +}
    +
    + + +

    If there is an error marshaling the controller board's state into a JSON response, the error will be an HTTP 500 internal server error in the expected format:

    +
    {
    +    "content": "Failed to serialize the controller board's current state.",
    +    "contentType": "string",
    +    "statusCode": 500,
    +    "error": true
    +}
    +
    + + +
    +

    Vending Application Service

    +

    Description

    +

    The as-vending application service is the central microservice that contains the business logic to handle the following:

    +
      +
    • Coordinates unlocking the cooler upon authentication
    • +
    • Requests inference snap shots (an inventory delta since the cooler was last closed)
    • +
    • Updates the inventory and ledger
    • +
    • Displays transaction data to the LCD
    • +
    +

    This service also implements "maintenance mode" to manage error handling and recovery due to faulty hardware, temperatures outside the desired ranges, or any other actions that disrupt the normal workflow of the vending machine. The functions that execute this logic can be found in as-vending/functions/output.go

    +

    APIs

    +
    +

    POST: /boardStatus

    +

    The POST call will inform the application service on the current state of the instrumentation (temperature, door, lock, humidity) on the controller board so that it can handle the business logic associated with those states. The events are typically posted from the controller board status application service. It is important to highlight that the REST API response will not necessarily be a holistic response of all of the actions taken place by the as-vending service. Please review the service's logs in order to gain a complete view of all changes that occur when interacting with this API endpoint.

    +

    Simple usage example:

    +
    curl -X POST -d '{"lock1_status": 0,"lock2_status": 0,"door_closed": false,"temperature": 30.1,"humidity": 26.2,"minTemperatureStatus": true,"maxTemperatureStatus": false}' http://localhost:48099/boardStatus
    +
    + + +

    A POST without any new information in the body will return the result:

    +
    +

    Success

    +

    Response Status Code 200 OK. +Board status was read

    +
    +

    If the minTemperatureStatus or maxTemperatureStatus values are set to true, maintenance mode will be set and the HTTP API response may be:

    +
    +

    Success

    +

    Response Status Code 200 OK. +Temperature status received and maintenance mode was set

    +
    +

    If the door_closed property is different than what as-vending currently believes it is, this response may be returned:

    +
    +

    Success

    +

    Response Status Code 200 OK. +Door closed change event was received

    +
    +
    +

    POST: /resetDoorLock

    +

    The POST call will simply reset the Automated Checkout's internal vendingState. This API endpoint has no logic to process any input data - it just responds to a simple POST.

    +

    Simple usage example:

    +
    curl -X POST http://localhost:48099/resetDoorLock
    +
    + + +

    The response will always be 200 OK:

    +
    reset the door lock
    +
    + + +
    +

    GET: /maintenanceMode

    +

    The GET call will simply return the boolean state that represents whether or not the vending state is in maintenance mode.

    +

    Simple usage example:

    +
    curl -X GET http://localhost:48099/maintenanceMode
    +
    + + +

    The response will always be 200 OK:

    +
    {
    +    "content": "{\"maintenanceMode\":false}",
    +    "contentType": "json",
    +    "statusCode": 200,
    +    "error": false
    +}
    +
    + + + + + + + +
    +
    +
    +
    + + + + +
    + + + + + + + + + + + \ No newline at end of file diff --git a/docs/automated-checkout-services/device_services.html b/docs/automated-checkout-services/device_services.html new file mode 100644 index 0000000..2d2e0b5 --- /dev/null +++ b/docs/automated-checkout-services/device_services.html @@ -0,0 +1,1191 @@ + + + + + + + + + + + + + + + + + + Device Services - Automated Checkout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + +
    + +
    + + + + + + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + + + + +
    +
    + + + + + + +

    Device Services

    +

    The Automated Checkout reference design utilizes three device services that are used to communicate hardware event data to underlying EdgeX framework.

    +

    List of device services

    +
      +
    • Card reader – Handles the interface between an RFID card reader and EdgeX.
    • +
    • Controller board – Handles the interface between Arduino firmware and EdgeX.
    • +
    • Inference mock – Mock that mimics an actual computer vision inference.
    • +
    +

    Card reader

    +

    Description

    +

    The ds-card-reader device service is an EdgeX device service that allows a USB-based RFID card reader to grant access to the Automated Checkout. At a high level, this device service is responsible for discovering a specific card reader device, watching for input from that device, parsing that input, and then forwarding the input into the EdgeX framework.

    +

    There are two different modes available to this device service:

    +
      +
    1. Physical Mode: for use with a physical controller board device
    2. +
    3. Virtual Mode: used when simulating a physical controller board by using a RESTful endpoint
    4. +
    +

    The EdgeX Core services are required for the ds-card-reader to publish the card ID into the EdgeX bus (zeroMQ). Without the EdgeX core services, this device service will not function.

    +

    Physical Device Functionality

    +

    The ds-card-reader service is much simpler than the ds-controller-board service, because it only requires mounting /dev/input:/dev/input at runtime. However, it still requires root privileges in the container at runtime so that it can interact directly with event/USB drivers.

    +

    APIs

    +
    +

    PUT: http://localhost:48098/api/v1/device/name/ds-card-reader/card-reader-event

    +

    The PUT API endpoint will push the badge ID (which is sent as part of the API request body) into the card reader device service. Once the card reader device service receives the badge ID, the badge ID will be pushed into the EdgeX bus for other application services to utilize.

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"card-reader-event":"0003278200"}' http://localhost:48098/api/v1/device/name/ds-card-reader/card-reader-event
    +
    + + +
    +

    Success

    +

    Response Status Code 200 OK.

    +
    +
    +

    GET: http://localhost:48098/api/v1/device/name/ds-card-reader/card-reader-status

    +

    The GET API endpoint returns data that is not meant to be consumed for any particular purpose. When triggering this endpoint, it will execute a function (in the Go source code) called CardReaderStatus that is used as an auto-remediation mechanism to attempt to "grab" the physical card reader HID device (via evdev). If it succeeds in grabbing the underlying device, that means that the ds-card-reader device service has lost its hold on the card reader, and we need to restart the service. This endpoint is meant to be hit frequently.

    +
    curl -X GET http://localhost:48098/api/v1/device/name/ds-card-reader/card-reader-status
    +
    + + +

    Sample response:

    +
    {"device":"ds-card-reader","origin":1579130994896}
    +
    + + +
    +

    Controller board

    +

    Description

    +

    The ds-controller-board device service is responsible for handling communication with a custom-built Arduino micro-controller board (or virtual board if you don't have physical hardware). It provides functionality for reading the lock status, door status, temperature, and humidity readings, while also sending commands to the controller board to unlock the mag-lock, and display output to the LCD.

    +

    There are two different modes available for this device service:

    +
      +
    1. Physical Mode: for use with a physical controller board device
    2. +
    3. Virtual Mode: used when simulating a physical controller board by using a RESTful endpoint
    4. +
    +

    Physical Device Functionality

    +

    When not running in simulated mode (i.e. a physical controller board device is plugged into your system), the ds-controller-board Docker container service requires /dev/ttyACM0, which is the typically the default serial port for an Arduino microcontroller.

    +

    This may change if you have multiple serial devices plugged in. Please ensure that /dev/ttyACM0 maps to the appropriate serial device if you plan to run the ds-controller-board service with a physical device.

    +

    It is important to note that the ds-controller-board service is capable of automatically finding a TTY port aside from /dev/ttyACM0. It actually looks for the vendor and product ID (VID/PID) values specified in the service's configuration. The problems arise when we have to mount the TTY port via Docker:

    +
      +
    • mounting /dev:/dev to the container at runtime solves the problem, but creates security risks and requires --privileged=true on the container, which is bad practice and can lead to security issues
    • +
    • mounting /dev/ttyACM0:/dev/ttyACM0 solves the problem, assuming there is only one serial device
    • +
    +

    Therefore, if you have multiple serial devices plugged into your system, please manually edit the docker-compose.yml file to mount your /dev/ttyACM_X_ appropriately. You may want to explore creating udev rules to enforce TTY consistency.

    +

    APIs

    +
    +

    PUT: http://localhost:48098/api/v1/device/name/ds-controller-board/command/lock1

    +

    This PUT command will operate magnetic lock1. Depending on the numeric value of lock1 (boolean 0/1), the lock state will either be locked or unlocked.

    +

    Simple usage example:

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"lock1":"0"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/lock1
    +
    + + +

    This will make the request directly to the device service itself instead of proxying through the EdgeX command API:

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"lock1":"0"}' http://localhost:48097/api/v1/device/name/ds-controller-board/lock1
    +
    + + +
    +

    PUT: http://localhost:48098/api/v1/device/name/ds-controller-board/command/lock2

    +

    This PUT command will operate magnetic lock2. Depending on the numeric value of lock2 (boolean 0/1), the lock state will either be locked or unlocked.

    +
    +

    Note

    +

    Currently lock2 has no purpose. During the initial architect/design phase of Automated Checkout, there were two locks. This was later reduced to a single mag-lock.

    +
    +

    Sample usage:

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"lock2":"1"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/lock2
    +
    + + +

    This will make the request directly to the device service itself instead of proxying through the EdgeX command API:

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"lock2":"1"}' http://localhost:48097/api/v1/device/name/ds-controller-board/lock2
    +
    + + +
    +

    Success

    +

    Response Status Code 200 OK.

    +
    +
    +

    Failure

    +

    Response Status Code 400 Bad Request

    +
    +
    +

    PUT: http://localhost:48098/api/v1/device/name/ds-controller-board/command/displayRow0

    +

    This PUT command will operate the display (LCD) and control the text to be put on the first line of the display.

    +

    Simple usage :

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"displayRow0":"The Earth is round"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/displayRow0
    +
    + + +

    This will make the request directly to the device service itself instead of proxying through the EdgeX command API:

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"displayRow0":"The Earth is round"}' http://localhost:48097/api/v1/device/name/ds-controller-board/displayRow0
    +
    + + +
    +

    Info

    +

    On the endpoint URL, Change displayRow0 index to 1, 2, or 3 to display and control the text to be put on the second, third, and forth line accordingly.

    +
    +
    +

    Success

    +

    Response Status Code 200 OK.

    +
    +
    +

    Failure

    +

    Response Status Code 400 Bad Request

    +
    +
    +

    PUT: http://localhost:48098/api/v1/device/name/ds-controller-board/command/setTemperature

    +

    This PUT command will emulate the temperature sensed by the controller board as a persistent value.

    +
    +

    Info

    +

    setTemperature is a float64. Any non-float64 value will be interpreted as '0.00' (do not have to specify decimal values).

    +
    +

    Simple usage :

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"setTemperature":"12.00"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setTemperature
    +
    + + +

    This will make the request directly to the device service itself instead of proxying through the EdgeX command API:

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"setTemperature":"12.00"}' http://localhost:48097/api/v1/device/name/ds-controller-board/setTemperature
    +
    + + +
    +

    Success

    +

    Response Status Code 200 OK.

    +
    +
    +

    Failure

    +

    Response Status Code 400 Bad Request

    +
    +
    +

    PUT: http://localhost:48098/api/v1/device/name/ds-controller-board/command/setHumidity

    +

    This PUT command will emulate the humidity sensed by the controller board as a persistent value.

    +
    +

    Info

    +

    setHumidity is an integer. Any non-integer value will be interpreted as '0'.

    +
    +

    Simple usage example:

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"setHumidity":"12"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setHumidity
    +
    + + +

    This will make the request directly to the device service itself instead of proxying through the EdgeX command API:

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"setHumidity":"12"}' http://localhost:48097/api/v1/device/name/ds-controller-board/setHumidity
    +
    + + +
    +

    Success

    +

    Response Status Code 200 OK.

    +
    +
    +

    Failure

    +

    Response Status Code 400 Bad Request

    +
    +
    +

    PUT: http://localhost:48098/api/v1/device/name/ds-controller-board/command/setDoorClosed

    +

    This PUT command will emulate the "door-closed" state sensed by the controller board as a persistent value.

    +
    +

    Info

    +

    setDoorClosed is a boolean-integer. Any non-boolean-integer value will be interpreted as '0' (and thus 'false'). Only '1' will result in 'true'.

    +
    +

    Simple usage example:

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"setDoorClosed":"0"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setDoorClosed
    +
    + + +

    This will make the request directly to the device service itself instead of proxying through the EdgeX command API:

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"setDoorClosed":"0"}' http://localhost:48097/api/v1/device/name/ds-controller-board/setDoorClosed
    +
    + + +
    +

    Success

    +

    Response Status Code 200 OK.

    +
    +
    +

    Failure

    +

    Response Status Code 400 Bad Request

    +
    +
    +

    Inference mock

    +

    Description

    +

    The ds-inference-mock device service contains two components:

    +
      +
    • A Python implementation of the Automated Checkout inference mock that mimics an actual computer vision inference mechanism by returning a random set of inventory "deltas" after a brief waiting period
    • +
    • An EdgeX MQTT device service that converts MQTT messages into EdgeX event readings
    • +
    +

    The Automated Checkout architecture uses three MQTT topics:

    + + + + + + + + + + + + + + + + + + + + + +
    TopicDescription
    Inference/CommandTopicAll events pushed from EdgeX's command API are fed into this topic. The as-vending and as-controller-board-status are two services that make requests to this API, typically for making door close/open and heartbeat events.
    Inference/ResponseTopicThe Automated Checkout inference mock will respond to published messages on the Inference/CommandTopic topic on the Inference/ResponseTopic topic.
    Inference/DataTopicThe inference mock publishes delta SKUs on this topic, then the MQTT device service converts them into EdgeX event readings, and finally the as-vending service processes the event readings and pushes them to downstream services.
    +

    APIs

    +
    +

    GET: http://localhost:48098/api/v1/device/name/Inference-MQTT-device/command/inferenceHeartbeat

    +

    The GET call to the EdgeX MQTT device service's inferenceHearbeat command will act as a health-check for the Automated Checkout inferencing service. It must return 200 OK upon swiping an RFID card in order for the vending workflow to begin. If it does not, the as-vending service will enter maintenance mode.

    +

    Simple usage example:

    +

    Through EdgeX command API:

    +
    curl -X GET http://localhost:48082/api/v1/device/name/Inference-MQTT-device/command/inferenceHeartbeat
    +
    + + +

    To MQTT device service itself:

    +
    curl -X GET http://localhost:48100/api/v1/device/name/Inference-MQTT-device/inferenceHeartbeat
    +
    + + +

    Sample response, 200 OK:

    +
    {
    +    "device": "Inference-MQTT-device",
    +    "origin": 1579637607912,
    +    "readings": [
    +        {
    +            "origin": 1579637607911,
    +            "device": "Inference-MQTT-device",
    +            "name": "inferenceHeartbeat",
    +            "value": "inferencePong"
    +        }
    +    ]
    +}
    +
    + + +
    +

    PUT: http://localhost:48100/api/v1/device/name/Inference-MQTT-device/command/inferenceDoorStatus

    +

    The PUT call to the EdgeX MQTT device service's inferenceDoorStatus command will cause the inference mock to consume the message, and if the JSON PUT key inferenceDoorStatus has the string value "true", an inference attempt will begin. The mock will subsequently respond with a message containing the inventory delta (aka SKU delta).

    +

    Simple usage example:

    +

    Through EdgeX command API:

    +
    curl -X PUT -d '{"inferenceDoorStatus":"true"}' http://localhost:48082/api/v1/device/name/Inference-MQTT-device/command/inferenceDoorStatus
    +
    + + +

    To MQTT device service itself:

    +
    curl -X PUT -d '{"inferenceDoorStatus":"true"}' http://localhost:48100/api/v1/device/name/Inference-MQTT-device/inferenceDoorStatus
    +
    + + +
    +

    Success

    +

    Response Status Code 200 OK.

    +
    +
    + + + + + + + +
    +
    +
    +
    + + + + +
    + + + + + + + + + + + \ No newline at end of file diff --git a/docs/automated-checkout-services/micro_services.html b/docs/automated-checkout-services/micro_services.html new file mode 100644 index 0000000..23e4a92 --- /dev/null +++ b/docs/automated-checkout-services/micro_services.html @@ -0,0 +1,1605 @@ + + + + + + + + + + + + + + + + + + Other Microservices - Automated Checkout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + +
    + +
    + + + + + + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + + + + +
    +
    + + + + + + +

    Other Microservices

    +

    The Automated Checkout reference design utilizes three services that expose REST API endpoints. These three services handle business logic for the Automated Checkout reference design, and are somewhat generic in their design patterns, so for the purposes of the reference design, we simply refer to them "microservices".

    +

    List of microservices

    +
      +
    • Authentication - Service that takes a card ID number and returns authentication/authorization status for the card number.
    • +
    • Inventory - Service that manages changes to the Automated Checkout's inventory, including storing transactions in an audit log.
    • +
    • Ledger - Service that stores customer financial transactions.
    • +
    +

    Authentication

    +

    Description

    +

    The ms-authentication microservice is a service that works with EdgeX to expose a REST API that takes a simple 10-digit string of digits (presumably corresponding to an RFID card) and responds with a valid or invalid authentication response, as well as the corresponding role for authenticated cards.

    +

    This repository contains logic for working within the following schemas:

    +
      +
    • Card/Cards - swiping a card is what allows the Automated Checkout automation to proceed with its workflow. A card can be associated with one of 3 roles:
        +
      • Consumer - a typical customer; is expected to open the vending machine door, remove an item, close the door and be charged accordingly
      • +
      • Stocker - a person that is authorized to re-stock the vending machine with new products
      • +
      • Maintainer - a person that is authorized to fix the software/hardware
      • +
      +
    • +
    • Account/Accounts - represents a bank account to charge. Multiple people can be associated with an account, such as a married couple
    • +
    • Person/People - a person can carry multiple cards but is only associated with one account
    • +
    +

    The ds-card-reader service is responsible for pushing card "swipe" events to the EdgeX framework, which will then feed into the as-vending microservice that then performs a REST HTTP API call to this microservice. The response is processed by the as-vending microservice and the workflow continues there.

    +

    APIs

    +
    +

    GET: /authentication/{cardid}

    +

    The GET call will return the user information if the cardid URL parameter matches a valid card ID number (according to the file cards.json). If the cardid is not found, an unauthorized response is returned.

    +

    Simple usage example:

    +
    curl -X GET http://localhost:48096/authentication/0003278425
    +
    + + +

    Authorized card sample response:

    +
    {
    +    "content": "{\"accountID\":1,\"personID\":1,\"roleID\":1,\"cardID\":\"0003278425\"}",
    +    "contentType": "json",
    +    "statusCode": 200,
    +    "error": false
    +}
    +
    + + +

    Unauthorized card sample response:

    +
      {
    +      "content": "Card ID is not a valid card",
    +      "contentType": "string",
    +      "statusCode": 401,
    +      "error": false
    +  }
    +
    + + +

    Inventory

    +

    Description

    +

    The ms-inventory microservice is a service that works with EdgeX to expose a REST API that manages the inventory for the vending machine, and keeps an audit log of all transactions (authorized or not).

    +

    This repository contains logic for working within the following schemas:

    +
      +
    • Inventory - an inventory item has the following attributes:
        +
      • sku - the SKU number of the inventory item
      • +
      • itemPrice - the price of the inventory item
      • +
      • productName - the name of the inventory item, will be displayed to users
      • +
      • unitsOnHand - the number of units stored in the vending machine
      • +
      • maxRestockingLevel - the maximum allowable number of units of this type to be stored in the vending machine
      • +
      • minRestockingLevel - the minimum allowable number of units of this type to be stored in the vending machine
      • +
      • createdAt - the date the inventory item was created and catalogued
      • +
      • updatedAt - the date the inventory item was last updated (either via a transaction or something else)
      • +
      • isActive - whether or not the inventory item is "active", which is not currently actively used by the Automated Checkout reference design for any specific purposes
      • +
      +
    • +
    • Audit Log - an audit log entry contains the following attributes:
        +
      • cardId - card number
      • +
      • accountId - account number
      • +
      • roleId - the role
      • +
      • personId - the ID of the person who is associated with the card
      • +
      • inventoryDelta - what was changed in inventory
      • +
      • createdAt - the transaction date
      • +
      • auditEntryId - and a UUID representing the transaction itself uniquely
      • +
      +
    • +
    +

    The ms-inventory microservice receives REST API calls from the upstream as-vending application service during a typical vending workflow. Typically, an individual will swipe a card, the workflow will start, and the inventory will be manipulated after an individual has removed or added items to the vending machine and an inference has completed. REST API calls to this service are not locked behind any authentication mechanism.

    +

    APIs

    +
    +

    GET: /inventory

    +

    The GET call will return the entire inventory in JSON format.

    +

    Simple usage example:

    +
    curl -X GET http://localhost:48095/inventory
    +
    + + +

    Sample response:

    +
    {
    +  "content": "{\"data\":[{\"sku\":\"4900002470\",\"itemPrice\":1.99,\"productName\":\"Sprite (Lemon-Lime) - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200010735\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew (Low Calorie) - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":18,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200050408\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":6,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"7800009257\",\"itemPrice\":1.99,\"productName\":\"Water (Dejablue) - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"4900002762\",\"itemPrice\":1.99,\"productName\":\"Dasani Water - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":32,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200081119\",\"itemPrice\":1.99,\"productName\":\"Pepsi (Wild Cherry) - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":12,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200018402\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew (blue) - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":6,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"4900002469\",\"itemPrice\":1.99,\"productName\":\"Diet Coke - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"490440\",\"itemPrice\":1.99,\"productName\":\"Coca-Cola - 20 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":72,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true}]}",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +
    +

    POST: /inventory

    +

    The POST call will add a list of items into inventory and will return the newly added items as a JSON string in the content field of the response. Will also behave like a PATCH and supports updating the inventory in accordance with the submitted list of objects, each containing the fields to update based on matched SKU values.

    +

    Simple usage example:

    +
    curl -X POST -d '[{"createdAt": "1567787309","isActive": true,"itemPrice": 3.00,"maxRestockingLevel": 24,"minRestockingLevel": 0,"sku": "4900002470","unitsOnHand": 0,"updatedAt": "1567787309"}]' http://localhost:48095/inventory
    +
    + + +

    Sample response:

    +
    {
    +  "content": "[{\"sku\":\"4900002470\",\"itemPrice\":3,\"productName\":\"Sprite (Lemon-Lime) - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1578955062042600972\",\"isActive\":true}]",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +
    +

    OPTIONS: /inventory

    +

    The OPTIONS call will respond with a 200 OK always. This is to enable web browsers to interact with the /inventory API endpoint, in accordance with the expected response for a CORS pre-flight request.

    +

    Simple usage example:

    +
    curl -X OPTIONS http://localhost:48095/inventory
    +
    + + +

    Sample response:

    +
    200 OK
    +
    + + +
    +

    POST: /inventory/delta

    +

    The POST call will increment or decrement inventory item(s) by a provided delta that match the given SKU numbers, and will return a JSON string containing the updated inventory items in the content field of the response.

    +

    Simple usage example:

    +
    curl -X POST -d '[{"SKU":"7800009257","delta":-1000},{"SKU":"7800009257","delta":-1000}]' http://localhost:48095/inventory/delta
    +
    + + +

    Sample response:

    +
    {
    +  "content": "[{\"sku\":\"7800009257\",\"itemPrice\":1.99,\"productName\":\"Water (Dejablue) - 16.9 oz\",\"unitsOnHand\":-1000,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"7800009257\",\"itemPrice\":1.99,\"productName\":\"Water (Dejablue) - 16.9 oz\",\"unitsOnHand\":-2000,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true}]",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +
    +

    OPTIONS: /inventory/delta

    +

    The OPTIONS call will respond with a 200 OK always. This is to enable web browsers to interact with the /inventory/delta API endpoint, in accordance with the expected response for a CORS pre-flight request.

    +

    Simple usage example:

    +
    curl -X OPTIONS http://localhost:48095/inventory/delta
    +
    + + +

    Sample response:

    +
    200 OK
    +
    + + +
    +

    GET: /inventory/{sku}

    +

    The GET call will return a JSON string of a single inventory item whose SKU matches the URL parameter {sku} in the content field of the response.

    +

    Simple usage example:

    +
    curl -X GET http://localhost:48095/inventory/4900002470
    +
    + + +

    Sample response:

    +
    {
    +  "content": "{\"sku\":\"4900002470\",\"itemPrice\":3,\"productName\":\"Sprite (Lemon-Lime) - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1578955062042600972\",\"isActive\":true}",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +

    If the {sku} does not correspond to a known item in the inventory, the response is:

    +
    {
    +  "content": "",
    +  "contentType": "string",
    +  "statusCode": 404,
    +  "error": false
    +}
    +
    + + +
    +

    DELETE: /inventory/{sku}

    +

    The DELETE call will delete an inventory item whose SKU matches the URL parameter {sku} and return the deleted inventory item in the content field of the responses.

    +

    Simple usage example:

    +
    curl -X DELETE http://localhost:48095/inventory/4900002470
    +
    + + +

    Sample response:

    +
    {
    +  "content": "{\"sku\":\"4900002470\",\"itemPrice\":1.99,\"productName\":\"Sprite (Lemon-Lime) - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true}",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +

    If the provided {sku} does not correspond to a known item in the inventory, the response is:

    +
    {
    +  "content": "Item does not exist",
    +  "contentType": "string",
    +  "statusCode": 404,
    +  "error": false
    +}
    +
    + + +
    +

    OPTIONS: /inventory/{sku}

    +

    The OPTIONS call will respond with a 200 OK always. This is to enable web browsers to interact with the /inventory/{sku} API endpoint, in accordance with the expected response for a CORS pre-flight request.

    +

    Simple usage example:

    +
    curl -X OPTIONS http://localhost:48095/inventory/4900002470
    +
    + + +

    Sample response:

    +
    200 OK
    +
    + + +
    +

    GET: /auditlog

    +

    The GET call on this API endpoint will return the entire audit log in JSON format.

    +

    Simple usage example:

    +
    curl -X GET http://localhost:48095/auditlog
    +
    + + +

    Sample response:

    +
    {
    +  "content": "{\"data\":[{\"cardId\":\"0003293374\",\"accountId\":1,\"roleId\":2,\"personId\":1,\"inventoryDelta\":[{\"SKU\":\"4900002470\",\"delta\":24},{\"SKU\":\"1200010735\",\"delta\":18},{\"SKU\":\"1200050408\",\"delta\":6},{\"SKU\":\"7800009257\",\"delta\":24},{\"SKU\":\"4900002762\",\"delta\":32},{\"SKU\":\"1200081119\",\"delta\":12},{\"SKU\":\"1200018402\",\"delta\":6},{\"SKU\":\"4900002469\",\"delta\":24},{\"SKU\":\"490440\",\"delta\":72}],\"createdAt\":\"1588006102888406420\",\"auditEntryId\":\"f944b60b-e389-4054-9643-2a33e4a0b227\"}]}",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +
    +

    POST: /auditlog

    +

    The POST call on this API endpoint will add one entry into the audit log and will return the added entry as a JSON string in the content field of the response.

    +

    Simple usage example:

    +
    curl -X POST -d '{"cardId": "0","roleId": 0,"personId": 0,"inventoryDelta": [{"SKU": "000","delta":-1}],"createdAt": "000"}' http://localhost:48095/auditlog
    +
    + + +

    Sample response:

    +
    {
    +  "content": "{\"cardId\":\"0\",\"accountId\":0,\"roleId\":0,\"personId\":0,\"inventoryDelta\":[{\"SKU\":\"000\",\"delta\":-1}],\"createdAt\":\"1588006208233972031\",\"auditEntryId\":\"b61bed78-da3b-4862-b548-b4ab16574495\"}",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +
    +

    OPTIONS: /auditlog

    +

    The OPTIONS call will respond with a 200 OK always. This is to enable web browsers to interact with the /auditlog API endpoint, in accordance with the expected response for a CORS pre-flight request.

    +

    Simple usage example:

    +
    curl -X OPTIONS http://localhost:48095/auditlog
    +
    + + +

    Sample response:

    +
    200 OK
    +
    + + +
    +

    GET: /auditlog/{auditEntryId}

    +

    The GET call on this API endpoint will will return a JSON string of a single audit log entry whose auditEntryId (which is a UUID) matches the one specified in the URL.

    +

    Simple usage example:

    +
    curl -X GET http://localhost:48095/auditlog/b61bed78-da3b-4862-b548-b4ab16574495
    +
    + + +

    Sample response:

    +
    {
    +  "content": "{\"cardId\":\"0\",\"accountId\":0,\"roleId\":0,\"personId\":0,\"inventoryDelta\":[{\"SKU\":\"000\",\"delta\":-1}],\"createdAt\":\"1588006208233972031\",\"auditEntryId\":\"b61bed78-da3b-4862-b548-b4ab16574495\"}",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +

    If the {auditEntryId} parameter does not correspond to an existing audit log entry, the response is:

    +
    {
    +  "content": "",
    +  "contentType": "string",
    +  "statusCode": 404,
    +  "error": false
    +}
    +
    + + +
    +

    DELETE: /auditlog/{auditEntryId}

    +

    The DELETE call on this API endpoint will delete an audit log entry whose auditEntryId (which is a UUID) matches the URL parameter {auditEntryId} and will return a JSON string containing the deleted audit log entry in the content field of the response

    +

    Simple usage example:

    +
    curl -X DELETE http://localhost:48095/auditlog/b61bed78-da3b-4862-b548-b4ab16574495
    +
    + + +

    Sample response:

    +
    {
    +  "content": "{\"cardId\":\"0\",\"accountId\":0,\"roleId\":0,\"personId\":0,\"inventoryDelta\":[{\"SKU\":\"000\",\"delta\":-1}],\"createdAt\":\"1588014993644633617\",\"auditEntryId\":\"c555d26e-9b3d-4ae8-8053-d2270e40ccf0\"}",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +

    If the {auditEntryId} parameter does not correspond to an existing audit log entry, the response is:

    +
    {
    +  "content": "Item does not exist",
    +  "contentType": "string",
    +  "statusCode": 404,
    +  "error": false
    +}
    +
    + + +
    +

    OPTIONS: /auditlog/{auditEntryId}

    +

    The OPTIONS call will respond with a 200 OK always. This is to enable web browsers to interact with the /auditlog API endpoint, in accordance with the expected response for a CORS pre-flight request.

    +

    Simple usage example:

    +
    curl -X OPTIONS http://localhost:48095/auditlog/f944b60b-e389-4054-9643-2a33e4a0b227
    +
    + + +

    Sample response:

    +
    200 OK
    +
    + + +
    +

    Ledger

    +

    Description

    +

    The ms-ledger microservice updates a ledger with the current transaction information (products purchased, quantity, total price, transaction timestamp). Transactions are added to the consumer's account. Transactions also have an isPaid attribute to designate which transactions have been paid/unpaid.

    +

    This microservice returns the current transaction to the as-vending microservice, which then calls the ds-controller-board microservice to display the items purchased and the total price of the transaction on the LCD.

    +

    APIs

    +

    GET: /ledger

    +

    The GET call will return the entire ledger in JSON format.

    +

    Simple usage example:

    +
    curl -X GET http://localhost:48093/ledger
    +
    + + +

    Sample response:

    +
    {
    +  "content": "{\"data\":[{\"accountID\":1,\"ledgers\":[{\"transactionID\":\"1588006480995452968\",\"txTimeStamp\":\"1588006480995453037\",\"lineTotal\":7.96,\"createdAt\":\"1588006480995453110\",\"updatedAt\":\"1588006480995453171\",\"isPaid\":false,\"lineItems\":[{\"sku\":\"1200050408\",\"productName\":\"Mountain Dew - 16.9 oz\",\"itemPrice\":1.99,\"itemCount\":3},{\"sku\":\"7800009257\",\"productName\":\"Water (Dejablue) - 16.9 oz\",\"itemPrice\":1.99,\"itemCount\":1}]}]},{\"accountID\":2,\"ledgers\":[]},{\"accountID\":3,\"ledgers\":[]},{\"accountID\":4,\"ledgers\":[]},{\"accountID\":5,\"ledgers\":[]},{\"accountID\":6,\"ledgers\":[]}]}",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +
    +

    POST: /ledger

    +

    The POST call will create a transaction and add it to the ledger for the specified accountId in the JSON body.

    +

    Simple usage example:

    +
    curl -X POST -d '{"accountId":1,"deltaSKUs":[{"sku":"1200050408","delta":-1}]}' http://localhost:48093/ledger
    +
    + + +

    Sample response:

    +
    {
    +  "content": "{\"transactionID\":\"1588006579251812793\",\"txTimeStamp\":\"1588006579251812850\",\"lineTotal\":1.99,\"createdAt\":\"1588006579251812909\",\"updatedAt\":\"1588006579251812968\",\"isPaid\":false,\"lineItems\":[{\"sku\":\"1200050408\",\"productName\":\"Mountain Dew - 16.9 oz\",\"itemPrice\":1.99,\"itemCount\":1}]}",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +
    +

    OPTIONS: /ledger

    +

    The OPTIONS call will respond with a 200 OK always. This is to enable web browsers to interact with the /ledger API endpoint, in accordance with the expected response for a CORS pre-flight request.

    +

    Simple usage example:

    +
    curl -X OPTIONS http://localhost:48093/ledger
    +
    + + +

    Sample response:

    +
    200 OK
    +
    + + +
    +

    GET: /ledger/{accountid}

    +

    The GET call will return the ledger for a specified {accountid}.

    +

    Simple usage example:

    +
    curl -X GET http://localhost:48093/ledger/1
    +
    + + +

    Sample response:

    +
    {
    +  "content": "{\"accountID\":1,\"ledgers\":[{\"transactionID\":\"1588006480995452968\",\"txTimeStamp\":\"1588006480995453037\",\"lineTotal\":7.96,\"createdAt\":\"1588006480995453110\",\"updatedAt\":\"1588006480995453171\",\"isPaid\":false,\"lineItems\":[{\"sku\":\"1200050408\",\"productName\":\"Mountain Dew - 16.9 oz\",\"itemPrice\":1.99,\"itemCount\":3},{\"sku\":\"7800009257\",\"productName\":\"Water (Dejablue) - 16.9 oz\",\"itemPrice\":1.99,\"itemCount\":1}]},{\"transactionID\":\"1588006579251812793\",\"txTimeStamp\":\"1588006579251812850\",\"lineTotal\":1.99,\"createdAt\":\"1588006579251812909\",\"updatedAt\":\"1588006579251812968\",\"isPaid\":false,\"lineItems\":[{\"sku\":\"1200050408\",\"productName\":\"Mountain Dew - 16.9 oz\",\"itemPrice\":1.99,\"itemCount\":1}]}]}",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +

    If the provided {accountid} parameter does not correspond to a valid ledger account number, the response is:

    +
    {
    +  "content": "AccountID not found in ledger",
    +  "contentType": "string",
    +  "statusCode": 400,
    +  "error": false
    +}
    +
    + + +
    +

    OPTIONS: /ledger/{accountid}

    +

    The OPTIONS call will respond with a 200 OK always. This is to enable web browsers to interact with the /ledger/{accountid} API endpoint, in accordance with the expected response for a CORS pre-flight request.

    +

    Simple usage example:

    +
    curl -X OPTIONS http://localhost:48093/ledger/1
    +
    + + +

    Sample response:

    +
    200 OK
    +
    + + +
    +

    POST: /ledger/ledgerPaymentUpdate

    +

    The POST call will update the transaction in the ledger of the specified account.

    +

    Simple usage example:

    +
    curl -X POST -d '{"accountId":1,"transactionID":"1588006579251812793","isPaid":true}' http://localhost:48093/ledgerPaymentUpdate
    +
    + + +

    Sample response:

    +
    {
    +  "content": "Updated Payment Status for transaction 1588006579251812793",
    +  "contentType": "string",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +

    If the provided transactionID does not correspond to an existing transaction in the ledger, the response is:

    +
    {
    +  "content": "Could not find Transaction 1588006579251812793",
    +  "contentType": "string",
    +  "statusCode": 400,
    +  "error": true
    +}
    +
    + + +
    +

    OPTIONS: /ledgerPaymentUpdate

    +

    The OPTIONS call will respond with a 200 OK always. This is to enable web browsers to interact with the /ledgerPaymentUpdate API endpoint, in accordance with the expected response for a CORS pre-flight request.

    +

    Simple usage example:

    +
    curl -X OPTIONS http://localhost:48093/ledgerPaymentUpdate
    +
    + + +

    Sample response:

    +
    200 OK
    +
    + + +
    +

    DELETE: /ledger/{accountid}/{transactionid}

    +

    The DELETE call will delete the transaction by its transactionid from the ledger for the specified account by its accountid.

    +

    Simple usage example:

    +
    curl -X DELETE http://localhost:48093/ledger/1/1588006579251812793
    +
    + + +

    Sample response:

    +
    {
    +  "content": "Deleted ledger 1588006579251812793",
    +  "contentType": "string",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +

    If the provided transactionID does not correspond to an existing transaction in the ledger, the response is:

    +
    {
    +  "content": "Could not find Transaction 1588006579251812793",
    +  "contentType": "string",
    +  "statusCode": 400,
    +  "error": true
    +}
    +
    + + +
    +

    OPTIONS: /ledger/{accountid}/{transactionid}

    +

    The OPTIONS call will respond with a 200 OK always. This is to enable web browsers to interact with the /ledger/{accountid}/{transactionid} API endpoint, in accordance with the expected response for a CORS pre-flight request.

    +

    Simple usage example:

    +
    curl -X OPTIONS http://localhost:48093/ledger/1/1588006579251812793
    +
    + + +

    Sample response:

    +
    200 OK
    +
    + + +
    + + + + + + + +
    +
    +
    +
    + + + + +
    + + + + + + + + + + + \ No newline at end of file diff --git a/docs/configuration.html b/docs/configuration.html new file mode 100644 index 0000000..638a54a --- /dev/null +++ b/docs/configuration.html @@ -0,0 +1,793 @@ + + + + + + + + + + + + + + + + + + Configuration - Automated Checkout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + +
    + +
    + + + + + + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + + + + +
    +
    + + + + + + +

    Configuration

    +

    This page lists all of the relevant configuration parameters for each service in the Automated Checkout reference design.

    +
    +

    Info

    +

    Note that this document likely does not cover EdgeX-specific configuration parameters. Application and device service SDK documentation can be found in the EdgeX Foundry GitHub repositories.

    +
    +

    Environment Overrides

    +

    The simplest way to change one of the configuration values described below is via the use of environment variable overrides in the docker compose file. The value of each configuration item in a service's configuration can be overridden with an environment variable specific to that item. The name of the environment variable is the path to the item in the configuration tree with underscores separating the nodes. The character case of each node in the environment variable name must match that found in the service's configuration. Here are a few examples for the Driver section:

    +
    [Driver]
    +  VID = "65535" # 0xFFFF
    +  PID = "53"    # 0x0035
    +
    + + +
    Driver_VID: "256" ** Good **
    +Driver_PID: "26"  ** Good **
    +
    +DRIVER_VID: "256" ** BAD **
    +driver_pid: "26"  ** BAD **
    +
    + + +

    These overrides are placed in the target service's environment section of the compose file. Here is an example:

    +
      ds-card-reader:
    +    user: "2000:2000"
    +    image: "automated-checkout/ds-card-reader:dev"
    +    container_name: automated-checkout_ds-card-reader
    +    environment:
    +      <<: *common-variables
    +      Driver_VID: "256"
    +      Driver_PID: "26"
    +    <<: *logging
    +    depends_on:
    +      - data
    +      - command
    +    restart: always
    +    ipc: none
    +
    + + +

    Card Reader Device Service

    +

    The following items can be configured via the Driver section of the service's configuration.toml file. All values are strings.

    +
      +
    • DeviceName - the name of the device to be associated with EdgeX events and readings originating from this service, if unsure leave default ds-card-reader
    • +
    • DeviceSearchPath - the bash globstar expression to use when searching for the raw input device, default is /dev/input/event*
    • +
    • VID - the uint16 value (as a base-10 string) corresponding to the Vendor ID of the USB device (run lsusb to list VID and PID values of connected USB devices). For example, if the VID is ffff in the output of lsusb, it is "65535" in the configuration file
    • +
    • PID - the uint16 value (as a base-10 string) corresponding to the Product ID of the USB device (run lsusb to list VID and PID values of connected USB devices). For example, if the PID is 0035 in the output of lsusb, it is "53" in the configuration file
    • +
    • SimulateDevice - the boolean value that tells this device service to expect an input device to dictate inputs (false), or if a simulated device will be used (and REST API calls will control it) (true) - if true
    • +
    +

    Controller Board Device Service

    +

    The following items can be configured via the Driver section of the service's configuration.toml file. All values are strings.

    +
      +
    • DisplayTimeout - The value in seconds corresponding to the display timeout length before resetting the display to the status display.
    • +
    • LockTimeout - The value in seconds corresponding to the lock timeout used to automatically lock the door in case no lock command was sent
    • +
    • VID - the string value corresponding to the Vendor ID hexadecimal (base-16) of the USB device (run lsusb to list VID and PID values of connected USB devices). For example, if the VID is 2341 in the output of lsusb, it is "2341" in the configuration file
    • +
    • PID - the string value corresponding to the Product ID hexadecimal (base-16) of the USB device (run lsusb to list VID and PID values of connected USB devices). For example, if the PID is 8037 in the output of lsusb, it is "8037" in the configuration file
    • +
    • VirtualControllerBoard - the boolean value that tells this device service to expect an input device to dictate inputs (false), or if a simulated device will be used (and REST API calls will control it) (true) - if true
    • +
    +

    EdgeX MQTT Device Service

    +

    This reference design uses the MQTT Device Service from EdgeX with custom device profiles. These device profiles YAML files are located here and are volume mounted into the device service's running Docker container.

    +

    The following items can be configured via the DeviceList and Driver section of the service's configuration.toml file. All values are strings.

    +

    DeviceList

    +
      +
    • IncomingSchema - Data schema type, aka protocol
    • +
    • IncomingHost - Host name of the incoming MQTT Broker
    • +
    • IncomingPort - Port number of the incoming MQTT Broker
    • +
    • IncomingUser - Username for the incoming MQTT Broker
    • +
    • IncomingPassword - Password for the incoming MQTT Broker
    • +
    • IncomingQos - Quality of service agreement between sender and receiver
    • +
    • IncomingKeepAlive - Keep alive duration for the incoming MQTT Broker
    • +
    • IncomingClientId - Client ID for the incoming MQTT Broker
    • +
    • IncomingTopic - Subscribe topic for the incoming MQTT Broker
    • +
    +

    Driver

    +
      +
    • ResponseSchema - Data schema type, aka protocol
    • +
    • ResponseHost - Host name of the response MQTT Broker
    • +
    • ResponsePort - Port number of the response MQTT Broker
    • +
    • ResponseUser - Username for the response MQTT Broker
    • +
    • ResponsePassword - Password for the response MQTT Broker
    • +
    • IncomingQos - Quality of service agreement between sender and receiver
    • +
    • ResponseKeepAlive - Keep alive duration for the response MQTT Broker
    • +
    • ResponseClientId - Client ID for the response MQTT Broker
    • +
    • ResponseTopic - Subscribe topic for the response MQTT Broker
    • +
    +

    Controller Board Status Application Service

    +

    The following items can be configured via the ApplicationSettings section of the service's configuration.toml file. All values are strings.

    +
      +
    • AverageTemperatureMeasurementDuration - The time-duration string (i.e. -15s, -10m) value of how long to process temperature measurements for calculating an average temperature. This calculation determines how quickly a "temperature threshold exceeded" notification is sent
    • +
    • DeviceName - The string name of the upstream EdgeX device that will be pushing events & readings to this application service
    • +
    • MaxTemperatureThreshold - The float64 value of the maximum temperature threshold, if the average temperature over the sample AverageTemperatureMeasurementDuration exceeds this value, a notification is sent
    • +
    • MinTemperatureThreshold - The float64 value of the minimum temperature threshold, if the average temperature over the sample AverageTemperatureMeasurementDuration exceeds this value, a notification is sent
    • +
    • MQTTEndpoint - A string containing the full EdgeX core command REST API endpoint corresponding to the inferenceDoorStatus command, registered by the MQTT device service in the inference mock
    • +
    • NotificationCategory - The category for notifications as a string
    • +
    • NotificationEmailAddresses - A comma-separated values (CSV) string of emails to send notifications to
    • +
    • NotificationHost - The full string URL of the EdgeX notifications service API that allows notifications to be sent by submitting an HTTP Post request
    • +
    • NotificationLabels - A comma-separated values (CSV) string of labels to apply to notifications, which are handled by EdgeX
    • +
    • NotificationReceiver - The human-readable string name of the person/entity receiving the notification, such as System Administrator
    • +
    • NotificationSender - The human-readable string name of the person/entity sending the notification, such as Automated Checkout Maintenance Notification
    • +
    • NotificationSeverity - A string tag indicating the severity of the notification, such as CRITICAL
    • +
    • NotificationSlug - A string that is a short label that may be used as part of a URL to delineate the notification subscription, such as sys-admin. The EdgeX official documentation says, "Effectively a name or key that labels the notification". This service creates an EdgeX subscription with a slug value of NotificationSlug.
    • +
    • NotificationSlugPrefix - A string similar to NotificationSlug, except that the NotificationSlugPrefix is appended with the current system time and the actual notification message's slug value is set to that value.
    • +
    • NotificationSubscriptionMaxRESTRetries - The integer value that represents the maximum number of times to try creating a subscription in the EdgeX notification service, such as 10
    • +
    • NotificationSubscriptionRESTRetryInterval - The time-duration string (i.e. 10s) representing how long to wait between each attempt at trying to create a subscription in the EdgeX notification service,
    • +
    • NotificationThrottleDuration - The time-duration string corresponding to how long to snooze notification alerts after sending an alert, such as 1m. Note that this value is stored in memory at runtime and if the service restarts, the time between notifications is not kept.
    • +
    • RESTCommandTimeout - The time-duration string representing how long to wait for any command to an EdgeX command API response before considering it a timed-out request, such as 15s
    • +
    • SubscriptionHost - The URL (as a string) of the EdgeX notification service's subscription API
    • +
    • VendingEndpoint - The URL (as a string) corresponding to the central vending endpoint's /boardStatus API endpoint, which is where events will be Posted when there is a door open/close change event, or a "temperature threshold exceeded" event.
    • +
    +

    Vending Application Service

    +

    The following items can be configured via the ApplicationSettings section of the service's configuration.toml file. All values are strings.

    +
      +
    • DeviceControllerBoardLock1 - EdgeX Command service endpoint for lock 1 events
    • +
    • DeviceControllerBoardLock2 - EdgeX Command service endpoint for lock 2 events
    • +
    • DeviceControllerBoarddisplayRow0 - EdgeX Command service endpoint for Row 0 on LCD
    • +
    • DeviceControllerBoarddisplayRow1 - EdgeX Command service endpoint for Row 1 on LCD
    • +
    • DeviceControllerBoarddisplayRow2 - EdgeX Command service endpoint for Row 2 on LCD
    • +
    • DeviceControllerBoarddisplayRow3 - EdgeX Command service endpoint for Row 3 on LCD
    • +
    • DeviceControllerBoarddisplayReset - EdgeX Command service endpoint for Resetting the LCD text
    • +
    • AuthenticationEndpoint - Endpoint for authentication microservice
    • +
    • InferenceHeartbeat - EdgeX Command service endpoint for Inference Heartbeat
    • +
    • InferenceDoorStatus - EdgeX Command service endpoint for Inference Door status
    • +
    • LedgerService - Endpoint for Ledger Micro Service
    • +
    • InventoryService - Endpoint for Inventory Micro Service
    • +
    • InventoryAuditLogService - Endpoint for Inventory Audit Log Micro Service
    • +
    • DoorOpenStateTimeout - The time-duration string (i.e. -15s, -10m) used for Door Open lockout time delay, in seconds
    • +
    • DoorCloseStateTimeout - The time-duration string (i.e. -15s, -10m) used for Door Close lockout time delay, in seconds
    • +
    • InferenceTimeout - The time-duration string (i.e. -15s, -10m) used for Inference message time delay, in seconds
    • +
    • LCDRowLength - Max number of characters for LCD Rows
    • +
    +

    Authentication microservice

    +

    For this particular microservice, there are no specific configuration options. Future settings would be added under the [ApplicationSettings] section.

    +

    Inventory microservice

    +

    For this particular microservice, there are no specific configuration options. Future settings would be added under the [ApplicationSettings] section.

    +

    Ledger microservice

    +

    The following items can be configured via the ApplicationSettings section of the service's configuration.toml file. All values are strings.

    +
      +
    • InventoryEndpoint - Endpoint that correlates to the Inventory microservice. This is used to query Inventory data used to generate the ledgers.
    • +
    + + + + + + + +
    +
    +
    +
    + + + + +
    + + + + + + + + + + + \ No newline at end of file diff --git a/docs/events.html b/docs/events.html new file mode 100644 index 0000000..68b1db4 --- /dev/null +++ b/docs/events.html @@ -0,0 +1,623 @@ + + + + + + + + + + + + + + + + + + Automated Checkout Events - Automated Checkout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + +
    + +
    + + + + + + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + +
    +
    +
    + + +
    +
    +
    + + +
    +
    + + + + + + +

    Automated Checkout Events

    +

    The following are the different events used in the Automated Checkout reference design.

    +

    Card Reader events

    +

    The ds-card-reader uses the EdgeX events pattern to send the card information into EdgeX Core Data as well as maintain a healthy state.

    +

    card-reader-event is an asynchronous event sent when a card is scanned by the card reader device. The event reading value is a string containing a 10-digit number and is placed into EdgeX Core Data as an event reading.

    +
    "0003293374"
    +
    + + +

    card-reader-status is an auto-event used to check the status of card reader connection. Every x seconds the event will check to see if the card reader is accessible. If the service is unable to verify the connection to the card reader then the service will restart. This event produces no database entry in EdgeX Core Data.

    +

    Controller Board events

    +

    The ds-controller-board uses the EdgeX events pattern to send the card information into EdgeX Core Data.

    +

    controller-board-status is an auto-event used to send the current state of the controller board and all of its periferals to EdgeX Core Data. This data is used by the as-controller-board-status application service to determine the state of the system. The information included in the status are the door lock states, door state, temperature, and humidity. The EdgeX Reading value is a string containing the following JSON:

    +
    {
    +    "lock1_status":1,
    +    "lock2_status":1,
    +    "door_closed":true,
    +    "temperature":78,
    +    "humidity":10
    +}
    +
    + + +

    The following commands are also available to the ds-controller-board. More details can be found here.

    +
      +
    • lock1
    • +
    • lock2
    • +
    • displayRow0
    • +
    • displayRow1
    • +
    • displayRow2
    • +
    • displayRow3
    • +
    • setTemperature
    • +
    • setHumidity
    • +
    • setDoorClosed
    • +
    +

    Computer vision inference events

    +

    The ds-inference-mock uses the EdgeX MQTT Device Service to send status updates and inference deltas to the EdgeX Core Data. The MQTT device service profile can be found in the file ./res/device-mqtt/inference.mqtt.device.profile.yml, in the root of this GitHub repository.

    +

    inferenceHeartbeat is an asynchronous event that is pushed to EdgeX Core Data when the inference is pinged by another service to verify it is functioning. If the inference is working properly the inferencePong response is sent as the event reading.

    +
    {
    +    "inferencePong"
    +}
    +
    + + +

    inferenceSkuDelta is an asynchronous event that pushes the delta data from the inference engine into EdgeX Core Data. The delta data can be used to update the inventory and create ledgers when appropriate. The EdgeX Event Reading contains a string value which is represented by the following JSON example:

    +
    [
    +    {"SKU": "4900002470", "delta": -1},
    +    {"SKU": "1200010735", "delta": -2}
    +]
    +
    + + +

    Finally the inferenceDoorStatus command is defined by the custom device profile for the EdgeX MQTT Device Service which sends the ping request to the computer vision inference mock. More details can be found here.

    + + + + + + + +
    +
    +
    +
    + + + + +
    + + + + + + + + + + + \ No newline at end of file diff --git a/docs/images/MongoDB-contents.png b/docs/images/MongoDB-contents.png new file mode 100644 index 0000000..8a774bb Binary files /dev/null and b/docs/images/MongoDB-contents.png differ diff --git a/docs/images/as-controller-board-status.png b/docs/images/as-controller-board-status.png new file mode 100644 index 0000000..2d69aa7 Binary files /dev/null and b/docs/images/as-controller-board-status.png differ diff --git a/docs/images/automated-checkout-reference-design.png b/docs/images/automated-checkout-reference-design.png new file mode 100644 index 0000000..9b518e7 Binary files /dev/null and b/docs/images/automated-checkout-reference-design.png differ diff --git a/docs/images/automated-checkout.png b/docs/images/automated-checkout.png new file mode 100644 index 0000000..fdbc78f Binary files /dev/null and b/docs/images/automated-checkout.png differ diff --git a/docs/images/card-unlock.png b/docs/images/card-unlock.png new file mode 100644 index 0000000..d7f1cf2 Binary files /dev/null and b/docs/images/card-unlock.png differ diff --git a/docs/images/customer.png b/docs/images/customer.png new file mode 100644 index 0000000..adb6f4a Binary files /dev/null and b/docs/images/customer.png differ diff --git a/docs/images/maintenance-mode.png b/docs/images/maintenance-mode.png new file mode 100644 index 0000000..5c47901 Binary files /dev/null and b/docs/images/maintenance-mode.png differ diff --git a/docs/images/maintenance.png b/docs/images/maintenance.png new file mode 100644 index 0000000..8517cfb Binary files /dev/null and b/docs/images/maintenance.png differ diff --git a/docs/images/open-close-door.png b/docs/images/open-close-door.png new file mode 100644 index 0000000..29ef905 Binary files /dev/null and b/docs/images/open-close-door.png differ diff --git a/docs/images/portainer-device-logs.png b/docs/images/portainer-device-logs.png new file mode 100644 index 0000000..4261842 Binary files /dev/null and b/docs/images/portainer-device-logs.png differ diff --git a/docs/images/portainer-device-services.png b/docs/images/portainer-device-services.png new file mode 100644 index 0000000..a145c94 Binary files /dev/null and b/docs/images/portainer-device-services.png differ diff --git a/docs/images/stocker.png b/docs/images/stocker.png new file mode 100644 index 0000000..1b8aeaa Binary files /dev/null and b/docs/images/stocker.png differ diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..660a28a --- /dev/null +++ b/docs/index.html @@ -0,0 +1,1062 @@ + + + + + + + + + + + + + + + + + + Automated Checkout Reference Design - Automated Checkout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + +
    + +
    + + + + + + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + + + + +
    +
    + + + + + + +

    Automated Checkout Reference Design

    +

    Introduction

    +

    This guide helps you build and run the Automated Checkout Reference Design.

    +

    Upon completing the steps in this guide, you will be ready to integrate sensors and services to build your own complete solution.

    +
    +

    Info

    +

    This guide does not create a complete, ready-to-use solution. Instead, upon completing the steps in this guide, you will be ready to integrate sensors and services to build your own Automated Checkout solution.

    +

    Certain third-party software or hardware identified in this document only may be used upon securing a license directly from the third-party software or hardware owner. The identification of non-Intel software, tools, or services in this document does not constitute a sponsorship, endorsement, or warranty by Intel.

    +
    +

    + +

    + +

    Block diagram

    +

    The high-level diagram below shows the sensors and services used with the Automated Checkout Reference Design. The diagram shows the sensors and services, and how they communicate through EdgeX. Intel provides the services outlined in blue, the purple services are provided by EdgeX, and the black services are either simulated or can interface with real hardware.

    +

    Automated Checkout Reference Design Diagram

    +

    Prerequisites

    +

    The following items are required to build the Automated Checkout Reference Design. You will need additional hardware and software when you are ready to build your own solution.

    +
      +
    • An inferencing solution that integrates with an MQTT broker. Intel provides a simulated inference that produces random inventory changes. See MQTT for information on this process.
    • +
    • A device that allows badging-in to the Automated Checkout. Intel provides a card reader service that can be simulated or integrated with a physical USB device. See the Card Reader device service page for information on this service.
    • +
    • +

      A controller device that locks the door to the Automated Checkout, as well as providing readouts (such as a small text-based LCD screen) to display authorization state, items purchased, and other sensor readings. This could be an Arduino-powered circuit. Intel provides a display service that can run in a simulated mode or with a physical USB/serial interface. See the Controller Board device service page for implementation details.

      +
    • +
    • +

      Ubuntu 18.04

      +
    • +
    • Docker
    • +
    • Docker Compose
    • +
    • Go 1.12+ for development purposes or running without docker.
    • +
    • Git
    • +
    • GNU make
    • +
    • A REST client such as curl or Postman for running through the phases outlined in the documentation.
    • +
    +

    Here's how to install git, curl, and make on an Ubuntu 18.04 system - other operating systems may vary:

    +
    sudo apt-get update -y
    +sudo apt-get install -y git curl build-essential
    +
    + + +

    Hardware

    +

    For Phase 2 - Add Card Reader Device, a USB based RFID card reader or second regular USB keyboard can be used.

    +

    Additionally, frequently throughout this documentation, we will refer to a "cooler" or "cooler door". This is referring to a vending machine or refrigerator with a sealed location for cooling. Inventory/stock are intended to be placed inside the cooler, and the temperature and humidity inside the cooler are monitored.

    + +
      +
    • EdgeX - the Automated Checkout reference design utilizes the EdgeX framework
    • +
    • MQTT
    • +
    • REST
    • +
    • evdev, if reading input events from a USB input device, such as a card reader that inputs key strokes upon scanning a card
    • +
    • Communication over serial on Linux, if using serial devices such as Arduino
    • +
    • Computer Vision concepts, if using CV inferencing components
    • +
    • Basic RFID concepts, if using RFID components (i.e. for badge-in card reader)
    • +
    • Portainer- included with the Automated Checkout reference design. Usage is optional, but this is a highly recommended utility for managing Docker containers, and we provide easy ways to run it.
    • +
    +

    Getting started

    +

    Step 1: Clone the repository

    +
    git clone https://github.com/intel-iot-devkit/automated-checkout.git && cd ./automated-checkout
    +
    + + +

    Step 2: Build the reference design

    +

    You must build the provided component services and create local docker images. To do so, run:

    +
    make build
    +
    + + +
    +

    Note

    +

    This command may take a while to run depending on your internet connection and machine specifications.

    +
    +

    Check for success

    +

    Make sure the command was successful. To do so, run:

    +
    docker images | grep automated-checkout
    +
    + + +
    +

    Success

    +

    The results are:

    +
      +
    • automated-checkout/as-controller-board-status
    • +
    • automated-checkout/as-vending
    • +
    • automated-checkout/build (latest tag)
    • +
    • automated-checkout/ds-card-reader
    • +
    • automated-checkout/ds-controller-board
    • +
    • automated-checkout/ds-inference-mock
    • +
    • automated-checkout/ms-authentication
    • +
    • automated-checkout/ms-inventory
    • +
    • automated-checkout/ms-ledger
    • +
    +
    +
    +

    Failure

    +

    If you do not see all of the above docker images, look through the console output for errors. Sometimes dependencies fail to resolve and must be run again. Address obvious issues. To try again, repeat step 2.

    +
    +

    Step 3: Start the reference design suite

    +

    Use Docker Compose to start the reference design suite. To do so, run:

    +
    make run
    +
    + + +

    This command starts the EdgeX Device Services and then starts all the Automated Checkout Reference Design Services.

    +

    Check for success

    +

    Make sure the command was successful. To do so, run:

    +
    docker ps --format 'table{{.Image}}\t{{.Status}}'
    +
    + + +
    +

    Success

    +

    Your output is as follows:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    IMAGESTATUS
    consul:1.3.1Up 4 minutes
    eclipse-mosquitto:1.6.3Up 3 minutes
    edgexfoundry/docker-core-command-go:1.1.0Up 3 minutes
    edgexfoundry/docker-core-data-go:1.1.0Up 3 minutes
    edgexfoundry/docker-core-metadata-go:1.1.0Up 3 minutes
    edgexfoundry/docker-device-mqtt-go:1.1.0Up 3 minutes
    edgexfoundry/docker-edgex-mongo:1.1.0Up 4 minutes
    edgexfoundry/docker-edgex-volume:1.1.0Up 4 minutes
    edgexfoundry/docker-support-logging-go:1.1.0Up 4 minutes
    edgexfoundry/docker-support-notifications-go:1.1.0Up 3 minutes
    automated-checkout/as-controller-board-status:devUp 3 minutes
    automated-checkout/as-vending:devUp 3 minutes
    automated-checkout/ds-card-reader:devUp 3 minutes
    automated-checkout/ds-controller-board:devUp 3 minutes
    automated-checkout/ds-inference-mock:devUp 3 minutes
    automated-checkout/ms-authentication:devUp 3 minutes
    automated-checkout/ms-inventory:devUp 3 minutes
    automated-checkout/ms-ledger:devUp 3 minutes
    +
    +

    You can also use Portainer to check the status of the services. You must run Portainer service first:

    +
    make run-portainer
    +
    + + +

    Then, navigate to the following Portainer URL and create an admin account:

    +

    + http://127.0.0.1:9000 +

    + +

    After, navigate to the following URL to list all of the containers running under the automated-checkout stack:

    +

    + http://127.0.0.1:9000/#/stacks/automated-checkout?type=2&external=true +

    + +

    Step 4: Dive in

    +

    All of the core components of Automated Checkout are up and running, and you are ready to begin going through the following phases.

    +
      +
    • Phase 1 - Simulate data and inferencing, and simulate events
    • +
    • Phase 2 - Add Card Reader Device
    • +
    • Phase 3 - Bring Your Own Hardware and Software
    • +
    +

    General Guidance

    +

    After completing the steps in the Getting Started section, it may be helpful to read through the remainder of this document for some further guidance on the Automated Checkout reference design.

    +

    How to use the Compose Files

    +

    The docker-compose.yml files are segmented to allow for fine control of physical and simulated devices, as well as allowing you the choice of running Portainer. Use the makefile to manage the various compose files:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Compose filePurposeMakefile Command
    PortainerContainer managementmake run-portainer
    All ServicesAutomated Checkout and EdgeX servicesmake run
    Physical EnvironmentMounts physical devicesmake run-physical
    Physical Card ReaderAllows just the card reader to be physicalmake run-physical-card-reader
    Physical Controller BoardAllows just the controller board to be physicalmake run-physical-controller-board
    +

    Expanding the Reference Design

    +

    The reference design you created is not a complete solution. It provides the base components for creating a framework to run a CV-powered Automated Checkout. It is your choice on how many and which sensors and devices to include. This section provides information about components you might want to include or replace.

    + + + + + + + + + + + + + + + + + + + + + +
    ComponentDescription
    RFID card readerA card reader device service is provided for a USB based RFID card reader. As an alternative, you can also use a regular USB keyboard to enter 10-digit number. See Phase 2 - Add Card Reader Device for more information.
    Micro-controller boardA controller board device service is provided for an Arduino based micro-controller. This micro-controller is in charge of controlling the locks of the automated checkout door and the LED display. Also, it uses modules such as temperature and humidity. See Phase 3 - Bring Your Own Hardware and Software for more information.
    Computer vision inference engineThe Automated Checkout reference design provides a computer vision inference mock service for simulation purposes. See more information here. You can create your own mock service and send events to EdgeX using the EdgeX MQTT Device Service.
    + + + + + + + +
    +
    +
    +
    + + + + +
    + + + + + + + + + + + \ No newline at end of file diff --git a/docs/modifying_source_code.html b/docs/modifying_source_code.html new file mode 100644 index 0000000..a978c19 --- /dev/null +++ b/docs/modifying_source_code.html @@ -0,0 +1,621 @@ + + + + + + + + + + + + + + + + + + Modifying source code - Automated Checkout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + +
    + +
    + + + + + + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + +
    +
    +
    + + +
    +
    +
    + + +
    +
    + + + + + + +

    Modifying source code

    +

    When modifying source code in the Automated Checkout reference design, Docker images need to be rebuilt and services need to be updated to run newly built images. This document contains the steps for accomplishing this.

    +

    Assumptions

    +

    This document assumes the Automated Checkout services are already running. Additionally, it assumes you've already made a code change and saved the changes.

    +

    Building the service's new image

    +

    Once the code change is saved, proceed to build the service's image. In this example, assume that the ds-card-reader service's source code has been altered.

    +

    Start by navigating to the root of this repository:

    +
    cd <repository_root>
    +
    + + +

    Next, build the specific service's image:

    +
    make ds-card-reader
    +
    + + +

    After Docker builds the image (by executing the steps in ds-card-reader/Dockerfile), proceed to the next section.

    +

    Remove and update the running service

    +

    One of the most effective methods of updating a Docker compose service is to remove the running container, and then re-run the make commands to bring up the entire Automated Checkout reference design stack.

    +

    First, identify the running container for the service (again, ds-card-reader in this example):

    +
    docker ps | grep -i ds-card-reader
    +
    + + +

    Using the output from the previous command, remove the container by referring to either its name or ID:

    +
    docker rm -f <name_or_ID_from_previous_command_output>
    +
    + + +

    Once the container has been removed, bring up the entire stack using the Makefile command corresponding to your environment, which is one of the following commands.

    +

    For a standard simulated environment:

    +
    make run
    +
    + + +

    For a physical card reader only, and simulating all other services:

    +
    make run-physical-card-reader
    +
    + + +

    For a physical controller board only, and simulating all other services:

    +
    make run
    +
    + + +

    For all physical device services:

    +
    make run-physical
    +
    + + +

    Once one of the above commands has been run, the modified ds-card-reader service will automatically start up with the newly built image.

    + + + + + + + +
    +
    +
    +
    + + + + +
    + + + + + + + + + + + \ No newline at end of file diff --git a/docs/notifications.html b/docs/notifications.html new file mode 100644 index 0000000..4cabfa4 --- /dev/null +++ b/docs/notifications.html @@ -0,0 +1,610 @@ + + + + + + + + + + + + + + + + + + How to Send Notifications through EdgeX (optional) - Automated Checkout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + +
    + +
    + + + + + + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + + + + +
    +
    + + + + + + +

    How to Send Notifications through EdgeX (optional)

    +

    This section provides instructions to help you configure the EdgeX notifications service to send alerts through SMS, email, REST API calls, and others.

    +

    Notifications work as follows:

    +
      +
    1. +

      When either the minimum or maximum temperature thresholds (defined in as-controller-board-status) have been exceeded (calculated as an average temperature over a configurable duration), the service enters maintenance mode and begins the process of sending an alert

      +
    2. +
    3. +

      The as-controller-board-status service sends these alerts as email messages through the EdgeX notification service using REST API calls

      +
    4. +
    +

    To change the message type from email to a different medium, the as-controller-board-status service should be updated to use a different notification type.

    +

    Step 1: Set Environment Variables

    +

    Set environment variable overrides for Smtp_Host and Smtp_Port in 'config-seed', which will inject these variables into the notification service's registry.

    +

    Additional notification service configuration properties are here.

    +

    Step 2: Add code to the config-seed Environment Section

    +

    The code snippet below is a docker-compose example that sends an email notification. Add this code to the config-seed service's environment section in docker-compose.yml.

    +
    environment:
    +  <<: *common-variables
    +  Smtp_Host: <host name>
    +  Smtp_Port: 25
    +  Smtp_Password: <password if applicable>
    +  Smtp_Sender: <some email>
    +  Smtp_Subject: Automated Checkout Notification
    +
    + + +

    Step 3: Add SMTP Server to compose file (optional)

    +

    The snipped below adds a development SMTP server smtp4dev to your docker-compose.yml. +Skip this step if you want to use Gmail or another server.

    +
    smtp-server:
    +  image: rnwood/smtp4dev:linux-amd64-v3
    +  ports:
    +    - "3000:80"
    +    - "2525:25"
    +  restart: "on-failure:5"
    +  container_name: smtp-server
    +  networks:
    +    - automated-checkout_default # the name of this network may be different for your setup
    +
    + + + + + + + +
    +
    +
    +
    + + + + +
    + + + + + + + + + + + \ No newline at end of file diff --git a/docs/phases/phase1.html b/docs/phases/phase1.html new file mode 100644 index 0000000..0de0732 --- /dev/null +++ b/docs/phases/phase1.html @@ -0,0 +1,1256 @@ + + + + + + + + + + + + + + + + + + Phase 1 - Simulation Mode - Automated Checkout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + +
    + +
    + + + + + + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + +
    +
    +
    + + +
    +
    +
    + + +
    +
    + + + + + + +

    Phase 1 - Simulation Mode

    +

    Overview

    +

    This document aims to help provide a simple introduction to how we interact with the various microservices in the Automated Checkout reference design, as well as demonstrating how EdgeX command API's are leveraged.

    +

    The steps in this guide show how to simulate the automated checkout workflow using curl REST API calls. It is a step-by-step walkthrough with specific commands to run on the command line.

    +

    The documentation in phase 2 and phase 3 will discuss more advanced methods of adding physical hardware and customized device services.

    +

    Scenarios

    +

    This walkthrough completes the following three scenarios:

    +
      +
    1. Stock the Cooler with inventory
        +
      • The cooler is empty - it has no stock in its inventory
      • +
      • A worker swipes their badge
      • +
      • The worker adds stock to the cooler
      • +
      +
    2. +
    3. Purchase from the Cooler as a customer
        +
      • Later, a customer swipes their badge to open the cooler
      • +
      • The customer takes item(s) from the inventory
      • +
      • The customer closes the door and gets billed
      • +
      +
    4. +
    5. The Cooler requires maintenance
        +
      • The internal temperature of the cooler has exceeded the maximum temperature threshold
      • +
      • A maintenance worker resolves the issue
      • +
      +
    6. +
    +

    Getting Started

    +
      +
    1. Complete steps 1-4 in Getting Started.
    2. +
    3. Make sure the containers are all up and running (aside from edgex-config-seed): docker-compose ps
    4. +
    5. Make sure the services are not running in maintenance mode:
    6. +
    +
    curl -X GET http://localhost:48099/maintenanceMode
    +
    + + +

    Verify the output and make sure that maintenanceMode value is set to false.

    +
    {
    +  "content": "{\"maintenanceMode\":false}",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +

    If maintenanceMode is set to true, run the following command to reset maintenance mode back to false:

    +
    docker-compose restart as-vending ds-controller-board as-controller-board-status
    +
    + + +
      +
    1. In a separate terminal window, watch the logs for a few Automated Checkout services, so that incoming events can be seen:
    2. +
    +
    docker-compose logs -f ds-card-reader ds-controller-board ms-authentication as-vending as-controller-board-status device-mqtt
    +
    + + +
    +

    Info

    +

    The output from ds-controller-board and as-controller-board-status may be noisy due to an automated status check occurring every 3 seconds. It may be desirable to try watching logs without those two services.

    +

    Additionally, using Portainer to watch Docker compose service logs can be extremely helpful. Start it by running:

    +

    make run-portainer

    +

    Then, navigate to http://localhost:9000/ in a web browser.

    +
    +

    Continue to the next section to start using curl to run through the simulated scenarios.

    +

    Walkthrough of Scenarios

    +

    Each section below contains specific steps and expected output for each of the scenarios mentioned above.

    +

    1. Stock the Cooler with Inventory

    +

    In order to fill up the cooler with inventory, someone acting as a "stocker" must swipe their card and proceed to fill the Automated Checkout with products.

    +

    However, before we get started, it's important to keep a few things in mind. We will perform a very specific sequence of events:

    +
      +
    1. Swipe badge
    2. +
    3. Open the cooler door
    4. +
    5. Close the cooler door
    6. +
    7. Verify that the cooler's inventory has been populated
    8. +
    9. Verify that the cooler's audit log shows the transaction
    10. +
    +

    That's it! Each of the above actions has a corresponding REST API call that we will run using the curl program on the command line.

    +

    + +

    + +
    +

    Warning

    +

    This sequence of events is time-sensitive. Once started, you must continue the sequence.

    +

    Once someone has swiped their card, the cooler door unlocks, and the person has roughly 20 seconds (configurable) to open the door before it locks again, if unopened. With this in mind, prepare to run this command, and the following commands soon after.

    +

    It's OK to run the commands without critically analyzing them in the moment. You may find it most useful to review them in advance.

    +

    If you mess up, you should start fresh. Run the command make down && make clean-docker && make run to scrub the Automated Checkout data and containers, wait approximately one minute after all services have started, and begin again. This scenario does not have any dependencies on the other scenarios in phase 1.

    +
    +

    The following diagram represents the flow for swiping your badge and unlocking the door:

    +

    + +

    + +

    To simulate this, perform this REST API call to the ds-card-reader service (time sensitive):

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"card-reader-event":"0003293374"}' http://localhost:48098/api/v1/device/name/ds-card-reader/card-reader-event
    +
    + + +
    +

    Note

    +

    There should not be any response message when running this EdgeX command successfully.

    +
    +
    +

    Info

    +

    By default, the card number 0003293374 corresponds to a card in the ms-authentication/cards.json file that has the "stocker" role associated to it.

    +
    +

    JSON object for cardId 0003293374.

    +
    {
    +  "cardId": "0003293374",
    +  "roleId": 2,
    +  "isValid": true,
    +  "personId": 1,
    +  "createdAt": "1560815799",
    +  "updatedAt": "1560815799"
    +}
    +
    + + +

    Immediately after, use the as-controller-board-status /status API endpoint to verify that the lock is unlocked (time sensitive):

    +
    curl -X GET http://localhost:48094/status
    +
    + + +
    +

    Warning

    +

    The lock must have a reading of 0 (unlocked) before proceeding to the next steps. If you attempt to open the door while the lock is engaged the system will assume an error state has occurred and go into maintenance mode.

    +
    +
    + (Click to Expand) Expected Response + +

    + Note that the lock1_status is set to 0, implying that lock1 has been unlocked. It will only stay unlocked for (default) 15 seconds, until the door is opened, at which time an independent timer is started that waits (default) 20 seconds for the stocker (or customer) to close the door after altering inventory. +

    + + +
    {
    +  "content":"{ \"lock1_status\":0,
    +              \"lock2_status\":1,
    +              \"door_closed\":true,
    +              \"temperature\":78,
    +              \"humidity\":10,
    +              \"minTemperatureStatus\":false,
    +              \"maxTemperatureStatus\":false
    +            }",
    +  "contentType":"json","statusCode":200,"error":false
    +}
    +
    + + +
    + +

    Then open the door, and close it afterwards, while waiting approximately 3-4 seconds between each event using the following 2 commands.

    +

    The following command makes a REST API call to the ds-controller-board service to open the door (no response body expected) (time sensitive):

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"setDoorClosed":"0"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setDoorClosed
    +
    + + +

    Wait 3.75 seconds:

    +
    sleep 3.75
    +
    + + +
    +

    Note

    +

    Waiting around 3-4 seconds is necessary because the frequency of "auto-events" that relay readings between some services is set to 3 seconds by default.

    +

    This implies that, for example, if you open and close the cooler door within the span of 1-2 seconds, there is a possibility that the auto-event did not pick up the change in the state of the door since its state did not change from one auto-event to the next.

    +
    +

    The following command makes a REST API call to the ds-controller-board service to close the door (no response body expected) (time sensitive):

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"setDoorClosed":"1"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setDoorClosed
    +
    + + +

    Wait about 20-30 seconds for the inventory to be discovered by the inference (which is being mocked), and also for background processing of events to occur. The time-sensitive sequence has been completed.

    +

    The following diagram represents the flow for opening and closing the door:

    +

    + +

    + +

    After waiting, use the following API calls to check the inventory, audit log, and ledger (not time sensitive):

    +
    curl -X GET http://localhost:48095/inventory
    +
    + + +
    + (Click to Expand) Inventory API Response Example + +

    +The (altered) contents of ms-inventory/inventory.json are contained in the content key below. +

    + + +
    {
    +  "content": "{\"data\":[{\"sku\":\"4900002470\",\"itemPrice\":1.99,\"productName\":\"Sprite (Lemon-Lime) - 16.9 oz\",\"unitsOnHand\":24,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200010735\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew (Low Calorie) - 16.9 oz\",\"unitsOnHand\":18,\"maxRestockingLevel\":18,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200050408\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew - 16.9 oz\",\"unitsOnHand\":6,\"maxRestockingLevel\":6,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"7800009257\",\"itemPrice\":1.99,\"productName\":\"Water (Dejablue) - 16.9 oz\",\"unitsOnHand\":24,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"4900002762\",\"itemPrice\":1.99,\"productName\":\"Dasani Water - 16.9 oz\",\"unitsOnHand\":32,\"maxRestockingLevel\":32,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200081119\",\"itemPrice\":1.99,\"productName\":\"Pepsi (Wild Cherry) - 16.9 oz\",\"unitsOnHand\":12,\"maxRestockingLevel\":12,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200018402\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew (blue) - 16.9 oz\",\"unitsOnHand\":6,\"maxRestockingLevel\":6,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"4900002469\",\"itemPrice\":1.99,\"productName\":\"Diet Coke - 16.9 oz\",\"unitsOnHand\":24,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"490440\",\"itemPrice\":1.99,\"productName\":\"Coca-Cola - 20 oz\",\"unitsOnHand\":72,\"maxRestockingLevel\":72,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true}]}",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +
    + +
    curl -X GET http://localhost:48095/auditlog
    +
    + + +
    + (Click to Expand) Audit Log API Response Example + +

    +The (altered) contents of ms-inventory/auditlog.json are contained in the content key below. +

    + + +
    {
    +  "content": "{\"data\":[{\"cardId\":\"0003293374\",\"accountId\":1,\"roleId\":2,\"personId\":1,\"inventoryDelta\":[{\"SKU\":\"4900002470\",\"delta\":24},{\"SKU\":\"1200010735\",\"delta\":18},{\"SKU\":\"1200050408\",\"delta\":6},{\"SKU\":\"7800009257\",\"delta\":24},{\"SKU\":\"4900002762\",\"delta\":32},{\"SKU\":\"1200081119\",\"delta\":12},{\"SKU\":\"1200018402\",\"delta\":6},{\"SKU\":\"4900002469\",\"delta\":24},{\"SKU\":\"490440\",\"delta\":72}],\"createdAt\":\"1585088126815981442\",\"auditEntryId\":\"4c1bca23-b097-4750-8a3b-43cc09733425\"}]}",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +
    + +
    curl -X GET http://localhost:48093/ledger
    +
    + + +
    + (Click to Expand) Ledger API Response Example + +

    +Since this a stocking event and not a customer transaction, there is no ledger entry for this transaction. Later in this walkthrough, similar steps will be followed that will yield a financial transaction and hence, a ledger entry. +

    + +

    +By default, the ledger service has six registered accounts (accounts 1-6) for consumers. The valid accounts match the account ID's that have authorized access to the cooler through the ms-authentication service (see the ms-authentication/accounts.json file). +

    + +

    +The (unaltered) contents of ms-ledger/ledger.json are contained in the content key below. +

    + + +
    {
    +  "content": "{\"data\":[
    +                          {\"accountID\":1,\"ledgers\":[]},
    +                          {\"accountID\":2,\"ledgers\":[]},
    +                          {\"accountID\":3,\"ledgers\":[]},
    +                          {\"accountID\":4,\"ledgers\":[]},
    +                          {\"accountID\":5,\"ledgers\":[]},
    +                          {\"accountID\":6,\"ledgers\":[]}
    +                       ]
    +              }",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +
    + +

    That's it! The cooler has been populated with inventory, and the audit log and inventory both show evidence of this.

    +

    2. Purchase from the cooler as a Customer

    +

    Now that the cooler's inventory has been stocked, we can simulate a customer swiping their card and removing one or more items from the cooler for purchase. The same time-sensitive disclaimers from the stocking simulation (which was done earlier in this walkthrough) apply here as well, so please review the Stock the Cooler with Inventory section if you have not done so yet.

    +
    +

    Warning

    +

    If you have not already populated the inventory as described in the Stock the Cooler with Inventory section, do not proceed. The mocked inferencing service follows a specific sequence for changes in inventory. The first transaction in the sequence is always a gain of inventory, corresponding to the stocker adding items to inventory. The following transactions are removal of inventory, corresponding to customers taking items from inventory.

    +

    If you mess up, you should start fresh. Run the command make down && make clean-docker && make run to scrub the Automated Checkout data and containers, wait approximately one minute after all services have started, and begin again. This scenario relies on the stocking scenario in phase 1 - if the stocking scenario is skipped, it is still OK, but the randomized sequence of transactions will yield inventory/audit log/ledger changes that differ from the expected examples shown throughout this scenario.

    +
    +

    In a manner similar to the previous section (where we stocked our inventory), the following steps are taken when simulating a customer:

    +
      +
    1. Swipe badge
    2. +
    3. Open the cooler door
    4. +
    5. Close the cooler door
    6. +
    7. Verify that the cooler's inventory has been altered
    8. +
    9. Verify that the cooler's audit log shows the transaction
    10. +
    11. Verify that the cooler's ledger shows the transaction
    12. +
    +

    That's it! Each of the above actions has a corresponding REST API call that we will run using the curl program on the command line.

    +

    + +

    + +

    To begin, start by performing the following REST command to simulate a customer swiping their badge to open the cooler (time sensitive):

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"card-reader-event":"0003278380"}' http://localhost:48098/api/v1/device/name/ds-card-reader/card-reader-event
    +
    + + +
    +

    Note

    +

    There should not be any response message when running this EdgeX command successfully.

    +
    +

    Immediately after, just as before, use the as-controller-board-status /status API endpoint to verify that the lock is unlocked (time sensitive):

    +
    curl -X GET http://localhost:48094/status
    +
    + + +
    + (Click to Expand) Expected Response +

    + Note that the lock1_status is set to 0, implying that lock1 has been unlocked. It will only stay unlocked for (default) 15 seconds, until the door is opened, at which time an independent timer is started that waits (default) 20 seconds for the customer (or stocker) to close the door after altering inventory. +

    + +
    {
    +  "content":"{ \"lock1_status\":0,
    +               \"lock2_status\":1,
    +               \"door_closed\":true,
    +               \"temperature\":78,
    +               \"humidity\":10,
    +               \"minTemperatureStatus\":false,
    +               \"maxTemperatureStatus\":false
    +            }",
    +  "contentType":"json","statusCode":200,"error":false
    +}
    +
    + + +
    + +

    Then open the door, and close it afterwards, while waiting approximately 3-4 seconds between each event using the following 2 commands.

    +

    The following command makes a REST API call to the ds-controller-board service to open the door (no response body expected) (time sensitive):

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"setDoorClosed":"0"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setDoorClosed
    +
    + + +

    Wait 3.75 seconds:

    +
    sleep 3.75
    +
    + + +

    The following command makes a REST API call to the ds-controller-board service to close the door (no response body expected) (time sensitive):

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"setDoorClosed":"1"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setDoorClosed
    +
    + + +

    At this point we are done simulating customer interactions with the Automated Checkout. The next steps are to get the inventory, ledger, and audit logs, and verify that they all show consistent information (not time sensitive, but may need to wait 20-30 seconds for background processing):

    +
    curl -X GET http://localhost:48095/inventory
    +
    + + +
    + (Click to Expand) Inventory API Response Example + +

    +A few items have been removed from the inventory in the below API response. Carefully examine the unitsOnHand and note that some items are no longer fully stocked by also examining the maxRestockingLevel. It may be extra insightful to compare this to the stocker section's inventory API response example, and also even more insightful to take a look at the below audit log and ledger responses for a proper view of the inventory delta that took place. +

    + +

    +The (altered) contents of ms-inventory/inventory.json are contained in the content key below. +

    + + +
    {
    +    "content": "{\"data\":[{\"sku\":\"4900002470\",\"itemPrice\":1.99,\"productName\":\"Sprite (Lemon-Lime) - 16.9 oz\",\"unitsOnHand\":24,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200010735\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew (Low Calorie) - 16.9 oz\",\"unitsOnHand\":18,\"maxRestockingLevel\":18,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200050408\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew - 16.9 oz\",\"unitsOnHand\":3,\"maxRestockingLevel\":6,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"7800009257\",\"itemPrice\":1.99,\"productName\":\"Water (Dejablue) - 16.9 oz\",\"unitsOnHand\":23,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"4900002762\",\"itemPrice\":1.99,\"productName\":\"Dasani Water - 16.9 oz\",\"unitsOnHand\":32,\"maxRestockingLevel\":32,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200081119\",\"itemPrice\":1.99,\"productName\":\"Pepsi (Wild Cherry) - 16.9 oz\",\"unitsOnHand\":12,\"maxRestockingLevel\":12,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200018402\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew (blue) - 16.9 oz\",\"unitsOnHand\":6,\"maxRestockingLevel\":6,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"4900002469\",\"itemPrice\":1.99,\"productName\":\"Diet Coke - 16.9 oz\",\"unitsOnHand\":24,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"490440\",\"itemPrice\":1.99,\"productName\":\"Coca-Cola - 20 oz\",\"unitsOnHand\":72,\"maxRestockingLevel\":72,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true}]}",
    +    "contentType": "json",
    +    "statusCode": 200,
    +    "error": false
    +}
    +
    + + +
    + +

    In this particular example, the customer purchased 1 item of Water (Dejablue) (sku 7800009257) and 3 items of Mountain Dew (sku 1200050408) +You can compare the unitsOnHand of each sku from the previous inventory data in step 1.

    +
    curl -X GET http://localhost:48095/auditlog
    +
    + + +
    + (Click to Expand) Audit Log API Response Example + +

    +The audit log has a new transaction that corresponds to this customer interaction. It also contains the original stocker interaction. +

    + +

    +The (altered) contents of ms-inventory/auditlog.json are contained in the content key below. +

    + + +
    {
    +    "content": "{\"data\":[{\"cardId\":\"0003293374\",\"accountId\":1,\"roleId\":2,\"personId\":1,\"inventoryDelta\":[{\"SKU\":\"4900002470\",\"delta\":24},{\"SKU\":\"1200010735\",\"delta\":18},{\"SKU\":\"1200050408\",\"delta\":6},{\"SKU\":\"7800009257\",\"delta\":24},{\"SKU\":\"4900002762\",\"delta\":32},{\"SKU\":\"1200081119\",\"delta\":12},{\"SKU\":\"1200018402\",\"delta\":6},{\"SKU\":\"4900002469\",\"delta\":24},{\"SKU\":\"490440\",\"delta\":72}],\"createdAt\":\"1585678869586092314\",\"auditEntryId\":\"7b3c2672-ba66-412c-a262-9816f3414eff\"},{\"cardId\":\"0003278380\",\"accountId\":1,\"roleId\":1,\"personId\":1,\"inventoryDelta\":[{\"SKU\":\"1200050408\",\"delta\":-3},{\"SKU\":\"7800009257\",\"delta\":-1}],\"createdAt\":\"1585679067690432556\",\"auditEntryId\":\"c7fa7e2d-a24c-428f-9c03-08460cd69e29\"}]}",
    +    "contentType": "json",
    +    "statusCode": 200,
    +    "error": false
    +}
    +
    + + +
    + +
    curl -X GET http://localhost:48093/ledger
    +
    + + +
    + (Click to Expand) Ledger API Response Example + +

    +Note that this API response now includes a financial transaction indicating what was actually removed from the cooler and associated with the customer's transaction. Other accounts in the ledger are still empty since there have been no transactions. +

    + +

    +The (altered) contents of ms-ledger/ledger.json are contained in the content key below. +

    + + +
    {
    +    "content": "{\"data\":[
    +    {\"accountID\":1,\"ledgers\":[{\"transactionID\":\"1585679067654735828\",\"txTimeStamp\":\"1585679067654735975\",\"lineTotal\":7.96,\"createdAt\":\"1585679067654736044\",\"updatedAt\":\"1585679067654736110\",\"isPaid\":false,\"lineItems\":[{\"sku\":\"1200050408\",\"productName\":\"Mountain Dew - 16.9 oz\",\"itemPrice\":1.99,\"itemCount\":3},{\"sku\":\"7800009257\",\"productName\":\"Water (Dejablue) - 16.9 oz\",\"itemPrice\":1.99,\"itemCount\":1}]}]},
    +    {\"accountID\":2,\"ledgers\":[]},
    +    {\"accountID\":3,\"ledgers\":[]},
    +    {\"accountID\":4,\"ledgers\":[]},
    +    {\"accountID\":5,\"ledgers\":[]},
    +    {\"accountID\":6,\"ledgers\":[]}
    +  ]}",
    +    "contentType": "json",
    +    "statusCode": 200,
    +    "error": false
    +}
    +
    + + +
    + +

    From the ledger data, notice the transaction done by accountID 1.

    +
    "{\"accountID\":1,
    + \"ledgers\":[{\"transactionID\":\"1585679067654735828\",
    +    \"txTimeStamp\":\"1585679067654735975\",
    +    \"lineTotal\":7.96,
    +    \"createdAt\":\"1585679067654736044\",
    +    \"updatedAt\":\"1585679067654736110\",
    +    \"isPaid\":false,
    +    \"lineItems\":[{\"sku\":\"1200050408\",
    +                    \"productName\":\"Mountain Dew - 16.9 oz\",
    +                    \"itemPrice\":1.99,
    +                    \"itemCount\":3},
    +                    {\"sku\":\"7800009257\",
    +                    \"productName\":\"Water (Dejablue) - 16.9 oz\",
    +                    \"itemPrice\":1.99,
    +                    \"itemCount\":1}]
    +            }]}"
    +
    + + +

    3. The Cooler Requires Maintenance

    +

    In this scenario, all Automated Checkout services are operating as usual, except the following conditions are present:

    +
      +
    • The cooler has exceeded the maximum allowable temperature threshold of 83 degrees Fahrenheit
    • +
    • It has stayed at or above this temperature threshold for more than 15 seconds
    • +
    +

    + +

    + +
    + (Click to Expand) Technical note about temperature + +

    +The as-controller-board-status service takes temperature readings regularly and calculates the average temperature over a configurable amount of time. If the average temperature over this duration exceeds the thresholds defined in the as-controller-board-status service's configured value, it will cause the cooler to enter maintenance mode and it will attempt to send a notification. The frequency of notifications can be configured as well. +

    + +

    +If the temperature temporarily exceeds the maximum or minimum allowable temperature thresholds, but does not push the time-averaged temperature above or below the thresholds, no notification will be sent. +

    + +
    + +

    When the Automated Checkout is in an unstable state such as the one presented above, it enters maintenance mode. When the Automated Checkout is in this state, it automatically denies access to everyone except individuals that possess badges that are associated with the maintenance worker role.

    +
    +

    Note

    +

    Maintenance mode is triggered in a few conditions:

    +
      +
    • Minimum or maximum temperature thresholds exceeded over a time-averaged temperature
    • +
    • The cooler door is left open for too long
    • +
    • The inferencing service is not responsive upon badge swipe
    • +
    • The inferencing service is not responsive upon an inferencing request
    • +
    +
    +

    This scenario walks through the following steps:

    +
      +
    1. Set the temperature to a value above the default maximum temperature threshold
    2. +
    3. Continue to set the temperature until the time-averaged temperature is above the default maximum temperature threshold
    4. +
    5. Simulate a maintenance worker swiping their badge to maintain the cooler
    6. +
    7. Reset the temperature back to normal
    8. +
    9. Verify that maintenance mode is no longer active
    10. +
    +
    +

    Warning

    +

    This sequence of events is time-sensitive. Once started, you must continue the sequence.

    +

    This sequence differs from the other scenarios leading up to this point. It does not require the cooler door to be opened.

    +

    It's OK to run the commands without critically analyzing them in the moment. You may find it most useful to review them in advance.

    +

    If you mess up, you should start fresh. Run the command make down && make clean-docker && make run to scrub the Automated Checkout data and containers, wait approximately one minute after all services have started, and begin again. This scenario does not have any dependencies on the other scenarios in phase 1.

    +
    +

    To begin the scenario, first start by setting the temperature of the cooler to 99.00 degrees Fahrenheit. The following command will make a REST API call to the ds-controller-board service (time sensitive):

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"setTemperature":"99.00"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setTemperature
    +
    + + +
    +

    Note

    +

    There should not be any response message when running this EdgeX command successfully.

    +
    +

    Repeat this command once or twice, over a span of 15 seconds to establish an average.

    +

    During this waiting period, periodically check the status of maintenance mode. The following command will make a REST API call to the as-vending service (no longer time sensitive):

    +
    curl -X GET http://localhost:48099/maintenanceMode
    +
    + + +
    + (Click to Expand) Expected Output + +

    +The value of maintenanceMode will switch to true from false once the time-averaged temperature exceeds the maximum temperature threshold (default 83 degrees Fahrenheit): +

    + + +
    {
    +  "content": "{\"maintenanceMode\":true}",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + +
    + +

    The following diagram represents the flow for setting the temperature and setting maintenance mode to true:

    +

    + +

    + +

    The next step involves a maintenance worker swiping their badge to resolve the issue. When a maintenance worker swipes their badge, maintenance mode is reset.

    +

    For the sake of simplicity in this walkthrough, we will first fix the temperature of the cooler and then the maintenance worker will swipe their badge to fix maintenance mode. The reason the maintenance worker would have to swipe their badge twice is because maintenance mode will be set to false immediately, but it will be immediately set back to true once the next temperature reading arrives. So, to avoid swiping the badge twice, the temperature will be reset before swiping.

    +

    First, set the temperature to a normal value (45 degrees) a few times over the span of 15 seconds (minimum) (time sensitive):

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"setTemperature":"45.00"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setTemperature
    +
    + + +
    +

    Note

    +

    There should not be any response message when running this EdgeX command successfully.

    +
    +

    Now that a new, proper average temperature value has been set, the maintenance worker can proceed to swipe their card, fix the cooler, and set the maintenance mode back to false.

    +

    To do this, follow a familiar step, only this time use a card that has been assigned to a maintenance worker role (not time sensitive):

    +
    curl -X PUT -H "Content-Type: application/json" -d '{"card-reader-event":"0003278385"}' http://localhost:48098/api/v1/device/name/ds-card-reader/card-reader-event
    +
    + + +
    +

    Note

    +

    There should not be any response message when running this EdgeX command successfully.

    +
    +
    +

    Info

    +

    The card 0003278385 is assigned to the maintenance worker role, and a person with ID 1. Additionally, if the maintenance worker opens and closes the door, there will be a corresponding audit log entry for that door open/close event.

    +
    +

    Now, check that maintenance mode has been reset using a familiar command (not time sensitive):

    +
    curl -X GET http://localhost:48099/maintenanceMode
    +
    + + +
    + (Click to Expand) Expected Output + +

    +The value of maintenanceMode will switch to true from false once the time-averaged temperature exceeds the maximum temperature threshold (default 83 degrees Fahrenheit): +

    + + +
    {
    +  "content": "{\"maintenanceMode\":false}",
    +  "contentType": "json",
    +  "statusCode": 200,
    +  "error": false
    +}
    +
    + + + +
    + +

    This is the end of the scenario, and should provide an essential understanding of maintenance mode as well as temperature reactions in the Automated Checkout reference design.

    +

    Summary

    +

    You have successfully run through a typical Automated Checkout workflow using simulated interactions and devices. In the other phases of this reference design, we ramp up to using physical devices and provide guidance on writing new services for your custom devices and needs.

    + + + + + + + +
    +
    +
    +
    + + + + +
    + + + + + + + + + + + \ No newline at end of file diff --git a/docs/phases/phase2.html b/docs/phases/phase2.html new file mode 100644 index 0000000..bd562e9 --- /dev/null +++ b/docs/phases/phase2.html @@ -0,0 +1,907 @@ + + + + + + + + + + + + + + + + + + Phase 2 - Add Card Reader Device - Automated Checkout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + +
    + +
    + + + + + + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + + + + +
    +
    + + + + + + +

    Phase 2 - Add Card Reader Device

    +

    In phase 1, the scenarios presented a breakdown of the various modes, events, and services that are working together within the Automated Checkout reference design. Everything in phase 1 was simulated and all interactions were done via REST API calls.

    +

    Phase 2 will be mostly the same, except there will now be a physical card reader device. This device is actually just a keyboard that types 10 digits and then presses enter, which is what a common RFID card reader also might do.

    +

    Setup

    +

    If the Automated Checkout services are still running from phase 1, the services can stay running. The only service that will be terminated and re-created is ds-card-reader (which will be done as part of this guide).

    +

    Start by removing the ds-card-reader service. In order to do this, first identify the container's name using this command:

    +
    docker ps | grep -i ds-card-reader
    +
    + + +

    Use the output of that command to stop the container for ds-card-reader - replace container_name_or_id_from_previous_command with the output from above:

    +
    docker rm -f container_name_or_id_from_previous_command
    +
    + + +
    +

    Note

    +

    If you encounter any issues with the ds-card-reader later in this guide, consider cleaning up all of the Automated Checkout services. The best way to guarantee a clean run through of this phase is to tear down any existing Automated Checkout environment and start from fresh. This can be accomplished by running the following steps.

    +

    Navigate to the root of this repository - this can vary based on where you chose to clone the repository:

    +

    cd <repository_root>

    +

    Run the following commands to clean things up:

    +

    make down && make clean-docker

    +

    This will destroy any existing ledger entries, audit log entries, inventory changes, and EdgeX event readings and data associated with Automated Checkout. However, this will not alter any other non-Automated Checkout Docker images, containers, or volumes. The scope of the above command is limited to only Automated Checkout.

    +
    +

    Plug in the card reader device

    +

    The first step is to simply plug in the card reader device. This can be a regular USB keyboard or a dedicated RFID card reader, or any other HID keyboard-like input device that works with evdev and can be identified via the Linux command lsusb.

    +
    +

    Note

    +

    If you are going to use a keyboard as a card reader device, we suggest plugging in a second keyboard for this purpose.

    +
    +

    Once it's plugged in, proceed to identify the device by running the command:

    +
    lsusb
    +
    + + +

    The output may look like this (this is the output from a virtual machine):

    +
    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    +Bus 001 Device 003: ID ffff:0035
    +Bus 001 Device 002: ID 80ee:0021 VirtualBox USB Tablet
    +Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    +
    + + +

    The particular vendor ID and product ID are spelled out clearly for each USB device. The card reader input device itself has been plugged in and has the vendor ID ffff and the product ID 0035.

    +
    +

    Note

    +

    The VID and PID values are hexadecimal, base 16. A value of ffff is equal to 65535 in decimal, base 10, and 0035 in base 16 is equal to 53 in base 10. The configuration files in the Automated Checkout reference design device services may require some conversion between the two. If needed, consider searching online for a hexadecimal to decimal conversion calculator to make the process easier.

    +
    +

    Once the VID and PID have been identified, the next step is to configure the ds-card-reader device service to grab that device and listen for input events.

    +

    Configure the ds-card-reader service to use the card reader device

    +

    From the root of this repository, with the card reader device plugged in and its VID and PID identified, navigate to the ds-card-reader/res/docker directory:

    +
    cd <repository_root>
    +
    + + +

    Then, modify the docker-compose.physical.card-reader.yml file in your text editor of choice:

    +
    nano docker-compose.physical.card-reader.yml
    +
    + + +

    In this file, you'll see a section that looks like this:

    +
    ds-card-reader:
    +  user: "0:0"
    +  devices:
    +    - /dev/input:/dev/input
    +  environment:
    +    Driver_SimulateDevice: "false"
    +
    + + +

    We will be adding three environment variables to this service:

    +
      +
    • DeviceSearchPath - the path to search for evdev input devices
    • +
    • VID - the base-10 value of the vendor ID associated with the input device
    • +
    • PID - the base-10 value of the product ID associated with the input device
    • +
    +

    First, verify that the default value of DeviceSearchPath="/dev/input/event*" corresponds to an actual path on your Linux system - the vast majority of Linux systems should automatically handle everything in this directory, but it helps to check.

    +
    ls -al /dev/input/event
    +
    + + +
    + (Click to Expand) Example Output + +

    +The output of ls -al /dev/input/event may look like this: +

    + + +
    crw-rw---- 1 root input 13, 64 Apr  9 09:10 /dev/input/event0
    +crw-rw---- 1 root input 13, 65 Apr  9 09:10 /dev/input/event1
    +crw-rw---- 1 root input 13, 66 Apr  9 09:10 /dev/input/event2
    +crw-rw---- 1 root input 13, 67 Apr  9 09:10 /dev/input/event3
    +crw-rw---- 1 root input 13, 68 Apr  9 09:10 /dev/input/event4
    +crw-rw---- 1 root input 13, 69 Apr  9 09:10 /dev/input/event5
    +crw-rw---- 1 root input 13, 70 Apr  9 09:10 /dev/input/event6
    +crw-rw---- 1 root input 13, 71 Apr  9 09:58 /dev/input/event7
    +
    + + + +

    +If you do not see input devices under this path, your Linux kernel or operating system may be configured differently. Consult your operating system's documentation for information regarding the behavior of input devices if possible. +

    + +
    + +

    The resulting section in the configuration file will look something like this:

    +
    ds-card-reader:
    +  user: "0:0"
    +  devices:
    +    - /dev/input:/dev/input
    +  environment:
    +    Driver_SimulateDevice: "false"
    +    Driver_DeviceSearchPath: "/dev/input/event*"
    +    Driver_VID: "65535"
    +    Driver_PID: "53"
    +
    + + +

    Run the Automated Checkout reference design

    +

    Run the Automated Checkout reference design with the physical card reader component included:

    +
    make run-physical-card-reader-dev
    +
    + + +

    After about a minute or so, the card reader device service (ds-card-reader) will be configured to accept inputs from an external card reader device. Follow the steps outlined in phase 1 again, except instead of performing REST API calls to simulate badge swipe events, replace them with a keyboard inputs that correspond to the same cards ID, press enter, and then continue forward with the REST API calls that simulate door open/closure events, temperature changes, etc.

    +
    +

    Note

    +

    You do not need to type the card ID number anywhere specifically. The card reader device service is configured in such a way that it will listen to any inputs from the keyboard at any time.

    +

    The input device is globally grabbed using evdev's GrabDevice mechanism, summarized here:

    +
    +

    GrabDevice: ... Doing so will ensure that no other driver can initialise the same device and it will also stop the device from sending events to /dev/kbd or /dev/input/mice. Events from this device will not be sent to virtual devices (e.g. rfkill or the Macintosh mouse button emulation).

    +
    +
    +

    For example, in phase 1, the card number for the stocker role is 0003293374. This card number can be simulated by typing the digits and pressing the enter key, if you're using a keyboard as your input device.

    +

    Dive deeper

    +

    Now that the card reader is working with a physical device, it may be time to make some changes to the underlying authentication data to allow your own cards to authenticate. The following sections illustrate the steps needed in order to extend the Automated Checkout reference design to work with your cards.

    +

    Extending the card reader

    +

    If the behavior of your particular card reader device's cards does not match the behavior that's been incorporated into this service, you'll need to get your hands dirty with the source code of the ds-card-reader device service.

    +

    In the service, take a look at the file ds-card-reader/device/physical.go. This file contains this function:

    +
    func (reader *CardReaderPhysical) Listen() {
    +    // ...
    +    reader.processDevReadEvents(events)
    +    // ...
    +}
    +
    + + +

    Listen is a Go routine that loops and processes evdev events as they come in from the physical input device. Carefully inspect this section of code as well as the functions called within this Go routine in order to gain an understanding of how to change the behavior of the card reader device service.

    +
    +

    Warning

    +

    Changing the source code may break unit tests and other functionality across services. Ensure that the software development processes used to make code changes include updating unit and integration tests to work with new changes.

    +
    +

    Adding new cards

    +

    The ms-authentication microservice contains an index of all cards, accounts, and authorized individuals (people). To add a new card, person, or account, follow these steps.

    +

    First, navigate to the ms-authentication directory in the root of the repository. These three .json files dictate the ms-authentication service's behavior:

    + +

    In this case, we're only going to add a new card and associate it with the person with ID 1. A typical card will look like this:

    +
    {
    +    "cardId": "0003621892",
    +    "roleId": 1,
    +    "isValid": true,
    +    "personId": 3,
    +    "createdAt": "1560815799",
    +    "updatedAt": "1560815799"
    +}
    +
    + + +

    Let's add a new card to the cards.json file - replace 1234567899 with a 10-digit card that corresponds to one of your cards:

    +
    ...,
    +{
    +    "cardId": "1234567899",
    +    "roleId": 1,
    +    "isValid": true,
    +    "personId": 3,
    +    "createdAt": "1560815799",
    +    "updatedAt": "1560815799"
    +}
    +...
    +
    + + +
    +

    Info

    +

    The createdAt and updatedAt dates do not particularly matter, but should be kept as a Unix timestamp.

    +
    +

    Now that we've added the card to the cards.json file, the service's Docker image must be rebuilt. Navigate to the root of this repository, which should be up a single directory:

    +
    cd ..
    +
    + + +

    Then, use the Makefile to build the ds-card-reader image:

    +
    make ds-card-reader
    +
    + + +
    +

    Info

    +

    At this time, the three .json files are built in to the Docker image for the ms-authentication service. They are not mounted at runtime. This is why image rebuilding is necessary.

    +
    +

    Running the updated service

    +

    If the Automated Checkout services are already running, the best way to update the running ms-authentication service is to remove the ms-authentication container and then re-run the command to bring up the whole stack.

    +

    First, remove the ms-authentication container:

    +
    docker ps -a | grep -i ms-authentication
    +
    + + +

    Use the output of the last command to delete the ms-authentication container. Replace container_name in the below command with the name from the output from the above command to delete it:

    +
    docker rm -f container_name
    +
    + + +

    Then, bring up the services using the same command from before:

    +
    make run-physical-card-reader-dev
    +
    + + +
    +

    Note

    +

    If this fails to properly update the image, it may be worth running

    +

    make down

    +

    And then re-running

    +

    make run-physical-card-reader-dev

    +

    If there are still issues, consider completely cleaning the Automated Checkout containers and volumes by running

    +

    make down && make clean-docker

    +

    And then running

    +

    make run-physical-card-reader-dev

    +
    +

    The ds-card-reader service should be listening for input events. If your card reader device is a proper RFID USB card reader, swipe the card that corresponds to the card we added, or if it's a USB keyboard, type out the keys and press enter when done, and follow the steps in phase 1 while replacing card reader badge-in events with this method.

    +
    +

    Info

    +

    For more generalized information on modifying source code, please review the Modifying source code page.

    +
    +

    Summary

    +

    The usage of a physical card reader device only requires a few changes from the simulated mode. In the ds-card-reader device service, the device's VID and PID are configured, the service's image gets rebuilt, and the service itself gets updated to use the new image. The device's interactions are captured by Go routines running in the device service itself, and EdgeX event readings are propagated throughout a handful of services to ensure a smooth Automated Checkout workflow.

    + + + + + + + +
    +
    +
    +
    + + + + +
    + + + + + + + + + + + \ No newline at end of file diff --git a/docs/phases/phase3.html b/docs/phases/phase3.html new file mode 100644 index 0000000..920874e --- /dev/null +++ b/docs/phases/phase3.html @@ -0,0 +1,636 @@ + + + + + + + + + + + + + + + + + + Phase 3 - Bring Your Own Hardware and Software - Automated Checkout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + +
    + +
    + + + + + + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + +
    +
    +
    + + +
    +
    +
    + + +
    +
    + + + + + + +

    Phase 3 - Bring Your Own Hardware and Software

    +

    Overview

    +

    After phase 2 has been completed, the next step is to integrate physical hardware. This guide will assist you in understanding the pieces of hardware that are needed in the Automated Checkout reference design.

    +

    Getting Started

    +

    Step 1: Arduino micro-controller board

    +

    The first piece of hardware that will control the vast majority of functionality will be an Arduino micro-controller board with multiple sensors.

    +

    Specifically, it handles the following integrations:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ModuleDescription
    Door Sensor (open/close)Instrumentation used to understand if the cooler door is open or closed and take appropriate action.
    Maglock (lock/unlock)Instrumentation is used to lock or unlock the automated checkout to allow for vending of a product.
    LCD DisplayInstrumentation is used for providing feedback to the person that is using the automated checkout.
    LED PanelInstrumentation is used to provide feedback to the developer as to the state of the board lock and door status.
    Temperature/Humidity SensorInstrumentation is used to understand the physical environment inside the automated checkout and take appropriate action.
    +

    We have created a reference design service that will interact with the controller board and EdgeX core services here.

    +

    Step 2: Integrate your own computer vision inference hardware

    +

    Next, in order to be able to provide computer vision capabilities to the Automated Checkout it is necessary to bring your own set of cameras and deep learning model. It is expected by the application services to receive an inventory delta using an MQTT broker. For development and testing purposes, we have created a mock inference device service that mimics what a real computer vision inference engine would do. Please see more details in the device services section here.

    + + + + + + + +
    +
    +
    +
    + + + + +
    + + + + + + + + + + + \ No newline at end of file diff --git a/docs/references.html b/docs/references.html new file mode 100644 index 0000000..a3f2086 --- /dev/null +++ b/docs/references.html @@ -0,0 +1,676 @@ + + + + + + + + + + + + + + + + + + References - Automated Checkout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + +
    + +
    + + + + + + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + +
    +
    +
    + + +
    +
    +
    + + +
    +
    + + + + + + +

    References

    +

    Application Services

    + + + + + + + + + + + + + + + + + + + + +
    Service NameService Abbreviated NameLink
    Controller Board Statusas-controller-board-statushttps://github.com/intel-iot-devkit/automated-checkout/blob/master/as-controller-board-status
    Vendingas-vendinghttps://github.com/intel-iot-devkit/automated-checkout/blob/master/as-vending
    +

    Device Service

    + + + + + + + + + + + + + + + + + + + + + + + + + +
    Service NameService Abbreviated NameLink
    Card Readerds-card-readerhttps://github.com/intel-iot-devkit/automated-checkout/blob/master/ds-card-reader
    Controller Boardds-controller-boardhttps://github.com/intel-iot-devkit/automated-checkout/blob/master/ds-controller-board
    Inference Mockds-inference-mockhttps://github.com/intel-iot-devkit/automated-checkout/blob/master/ds-inference-mock
    +

    Microservices (Business Logic Services)

    + + + + + + + + + + + + + + + + + + + + + + + + + +
    Service NameService Abbreviated NameLink
    Authenticationms-authenticationhttps://github.com/intel-iot-devkit/automated-checkout/blob/master/ms-authentication
    Inventoryms-inventoryhttps://github.com/intel-iot-devkit/automated-checkout/blob/master/ms-inventory
    Ledgerms-ledgerhttps://github.com/intel-iot-devkit/automated-checkout/blob/master/ms-ledger
    +

    Other

    + + + + + + + + + + + + + +
    ComponentLink
    EdgeX GitHub Reposhttps://github.com/edgexfoundry
    + + + + + + + +
    +
    +
    +
    + + + + +
    + + + + + + + + + + + \ No newline at end of file diff --git a/docs/search/search_index.json b/docs/search/search_index.json new file mode 100644 index 0000000..e69de29 diff --git a/docs/sitemap.xml b/docs/sitemap.xml new file mode 100644 index 0000000..cb4f6a5 --- /dev/null +++ b/docs/sitemap.xml @@ -0,0 +1,55 @@ + + + None + 2020-05-19 + daily + + None + 2020-05-19 + daily + + None + 2020-05-19 + daily + + None + 2020-05-19 + daily + + None + 2020-05-19 + daily + + None + 2020-05-19 + daily + + None + 2020-05-19 + daily + + None + 2020-05-19 + daily + + None + 2020-05-19 + daily + + None + 2020-05-19 + daily + + None + 2020-05-19 + daily + + None + 2020-05-19 + daily + + None + 2020-05-19 + daily + + \ No newline at end of file diff --git a/docs/sitemap.xml.gz b/docs/sitemap.xml.gz new file mode 100644 index 0000000..5c3acbf Binary files /dev/null and b/docs/sitemap.xml.gz differ diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css new file mode 100644 index 0000000..e69de29 diff --git a/docs/troubleshooting.html b/docs/troubleshooting.html new file mode 100644 index 0000000..8631028 --- /dev/null +++ b/docs/troubleshooting.html @@ -0,0 +1,605 @@ + + + + + + + + + + + + + + + + + + Troubleshooting - Automated Checkout + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + +
    + +
    + + + + + + +
    +
    + + +
    +
    +
    + +
    +
    +
    + + + + + +
    +
    + + + + + + +

    Troubleshooting

    +

    The following guide will help walk you through the flow of data to address potential issues as they occur. This guide does not comprehensively cover all possible troubleshooting scenarios. It provides guidance on how to leverage a few essential tools to augment all troubleshooting efforts in general.

    +

    Ensuring your Device Services receive data

    +

    All sensor data that is ingested in Automated Checkout flows through a device service as the first step. These device services are the first place we should check to ensure they are both running and ingesting data. One of the best ways to do to this is to leverage Portainer (included in EdgeX Releases).

    +
    +

    Info

    +

    Portainer is a tool to help manage Docker containers. To learn more visit: https://www.portainer.io/overview/

    +
    +

    We have 3 device services of note in Automated Checkout:

    +
      +
    • Controller board – Handles the interface between Arduino firmware and EdgeX.
    • +
    • Card reader – Handles the interface between an RFID card reader and EdgeX.
    • +
    • Inference mock – Mock that mimics an actual computer vision inference.
    • +
    +

    We can type "ds" in the search bar on the Portainer web portal (127.0.0.1:9000) and see all the device service containers that are in our stack (see image below). We can also see their current state which indicates if they are running or not. If a service is not running, or is in a "stopped" state, then this is likely the cause of data not flowing through.

    +

    Portainer Device Services

    +

    However, if the state is "running", we can dig a little deeper by viewing the logs. Though, before we dig into the logs, it is important to call out that we will want to ensure that the logging level is set to "TRACE" for each service we intend to inspect.

    +

    This can be accomplished by doing the following:

    +
      +
    • Navigate to Consul in a browser, which is located at http://localhost:8500.
    • +
    • Click Key/Value at the top navbar.
    • +
    • Click edgex in the list.
    • +
    • Depending on which service you want to inspect, choose either devices, appservices, or core.
        +
      • For a device service, this would be devices.
      • +
      • For all application services, this would be appservices.
      • +
      • For all EdgeX core services, this would be core.
      • +
      +
    • +
    • Click 1.0.
    • +
    • Click on the service that you're interested in changing.
    • +
    • Click Writable.
    • +
    • Click LogLevel.
    • +
    • Set the value in the text box to TRACE, it likely is set to INFO by default.
    • +
    • Click the "Save" button.
    • +
    +

    After following the above steps, proceed to view the logs for the service, and observe that level=TRACE logs begin to appear.

    +

    Portainer Device Logs

    +

    Ensuring EdgeX Core Services have received Data

    +

    After ensuring that data is flowing properly to the device services, the next place to check would be EdgeX’s "core data" service. You can follow the same steps as above to see if data is flowing and check the logs. However, using a tool such as Robo 3T or Mongo Compass to inspect the database is the best way to ensure data has been properly processed by EdgeX's Core Data.

    +
    +

    Info

    +

    Robo 3T is a tool to manage mongodb databases: https://robomongo.org/

    +
    +

    MongoDB contents

    +

    You’ll find the events in the "coredata" database under the "event" collection and more importantly the reading values under the "reading" collection. If you sort by "created" in descending order and filter for the specific device that is giving you trouble, it can help to narrow down the data you are looking for. It is also a good idea to check and make sure all the device names and values are what you expect them to be. It is often the case that a device-name or reading-name may not match what it is intended and this could cause issues in your app service.

    +

    Checking the Controller Board Status (App Service)

    +

    After ensuring data has made it to the database, the next place to check is the Controller Board Status App Service (as-controller-board-status). Similar to what we did in Step 1, let’s check Portainer for the status of this container to ensure it is running and lets also take a look at the logs. After ensuring the logging level is set to ‘TRACE’, we should see something akin to the following:

    +

    Portainer as-controller-board-status

    +

    In the unlikely event that no data is flowing at all to the Controller Board status App Service, this would lead us to an issue with the ZMQ connection from the App Service to Core Data. Double checking the TOML file configuration where the hostname, port, and topic are specified would be a good place to start. You should also check that the App Service is on the same docker network and is accessible via the network.

    +

    Once connectivity issues have been resolved, the next step is to ensure that all filters (i.e. device names) are correct and match what is shown in the database from the previous step. If they do not match, then they will be filtered out and not be processed. One easy way to confirm that data is flowing is to remove filters entirely from the pipeline to see that there is data flowing.

    +

    For further troubleshooting, visit the EdgeX documentation.

    + + + + + + + +
    +
    +
    +
    + + + + +
    + + + + + + + + + + + \ No newline at end of file diff --git a/docs_src/automated-checkout-services/application_services.md b/docs_src/automated-checkout-services/application_services.md new file mode 100644 index 0000000..6756b71 --- /dev/null +++ b/docs_src/automated-checkout-services/application_services.md @@ -0,0 +1,156 @@ + +# Application Services + +The **Automated Checkout** reference design utilizes two application services that are used to consume event data from the EdgeX framework. + +## List of application services + +- Controller Board Status – Handles events coming from the controller board device service. +- Vending – The main business logic for the Automated Checkout application. This service handles events directly from the card reader device service and inference engine as well as coordinates data between each of the microservices. + +## Controller Board Status Application Service + +### Description + +The `as-controller-board-status` application service checks the status of the controller board for changes in the state of the door, lock, temperature, and humidity, and triggers notifications if the average temperature and humidity are outside the desired ranges. + +### APIs + +This service exposes a few REST API endpoints that are either intended to be interacted with via EdgeX's core services or directly. + +All exposed HTTP responses are of the format: + +```json +{ + "content": "", + "contentType": "json|string|", + "statusCode": 200, + "error": false +} +``` + +This means that you must parse the `content` field if the `contentType` field is `json`. + +This section includes documentation on each API endpoint exposed by this service. Depending on how you've chosen to deploy the service, you may use `localhost`, `as-controller-board-status` or some other hostname. This document assumes `localhost` is used. + +--- + +#### `GET`: `/status` + +The `GET` call will return the current controller board status information. This information can be used by other services trying to get metrics from the controller board or by a test suite to validate the controller board behavior. + +Simple usage example: + +```bash +curl -X GET http://localhost:48094/status +``` + +Sample response: + +```json +{ + "content": "{\"lock1_status\": 0,\"lock2_status\": 0,\"door_closed\": false,\"temperature\": 30.1,\"humidity\": 26.2,\"minTemperatureStatus\": true,\"maxTemperatureStatus\": false}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` + +If there is an error marshaling the controller board's state into a JSON response, the error will be an HTTP 500 internal server error in the expected format: + +```json +{ + "content": "Failed to serialize the controller board's current state.", + "contentType": "string", + "statusCode": 500, + "error": true +} +``` + +--- + +## Vending Application Service + +### Description + +The `as-vending` application service is the central microservice that contains the business logic to handle the following: + +- Coordinates unlocking the cooler upon authentication +- Requests inference snap shots (an inventory delta since the cooler was last closed) +- Updates the inventory and ledger +- Displays transaction data to the LCD + +This service also implements **_"maintenance mode"_** to manage error handling and recovery due to faulty hardware, temperatures outside the desired ranges, or any other actions that disrupt the normal workflow of the vending machine. The functions that execute this logic can be found in `as-vending/functions/output.go` + +### APIs + +--- + +#### `POST`: `/boardStatus` + +The `POST` call will inform the application service on the current state of the instrumentation (temperature, door, lock, humidity) on the controller board so that it can handle the business logic associated with those states. The events are typically posted from the controller board status application service. It is important to highlight that the REST API response will not necessarily be a holistic response of all of the actions taken place by the `as-vending` service. Please review the service's logs in order to gain a complete view of all changes that occur when interacting with this API endpoint. + +Simple usage example: + +```bash +curl -X POST -d '{"lock1_status": 0,"lock2_status": 0,"door_closed": false,"temperature": 30.1,"humidity": 26.2,"minTemperatureStatus": true,"maxTemperatureStatus": false}' http://localhost:48099/boardStatus +``` + +A `POST` without any new information in the body will return the result: + +!!! success + Response Status Code 200 OK. + Board status was read + +If the `minTemperatureStatus` or `maxTemperatureStatus` values are set to `true`, maintenance mode will be set and the HTTP API response may be: + +!!! success + Response Status Code 200 OK. + Temperature status received and maintenance mode was set + +If the `door_closed` property is different than what `as-vending` currently believes it is, this response may be returned: + +!!! success + Response Status Code 200 OK. + Door closed change event was received + +--- + +### `POST`: `/resetDoorLock` + +The `POST` call will simply reset the Automated Checkout's internal `vendingState`. This API endpoint has no logic to process any input data - it just responds to a simple `POST`. + +Simple usage example: + +```bash +curl -X POST http://localhost:48099/resetDoorLock +``` + +The response will _always_ be `200 OK`: + +```bash +reset the door lock +``` + +--- + +### `GET`: `/maintenanceMode` + +The `GET` call will simply return the boolean state that represents whether or not the vending state is in maintenance mode. + +Simple usage example: + +```bash +curl -X GET http://localhost:48099/maintenanceMode +``` + +The response will _always_ be `200 OK`: + +```json +{ + "content": "{\"maintenanceMode\":false}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` diff --git a/docs_src/automated-checkout-services/device_services.md b/docs_src/automated-checkout-services/device_services.md new file mode 100644 index 0000000..6379363 --- /dev/null +++ b/docs_src/automated-checkout-services/device_services.md @@ -0,0 +1,321 @@ +# Device Services + +The **Automated Checkout** reference design utilizes three device services that are used to communicate hardware event data to underlying EdgeX framework. + +## List of device services + +- Card reader – Handles the interface between an RFID card reader and EdgeX. +- Controller board – Handles the interface between Arduino firmware and EdgeX. +- Inference mock – Mock that mimics an actual computer vision inference. + +## Card reader + +### Description + +The `ds-card-reader` device service is an EdgeX device service that allows a USB-based RFID card reader to grant access to the Automated Checkout. At a high level, this device service is responsible for discovering a specific card reader device, watching for input from that device, parsing that input, and then forwarding the input into the EdgeX framework. + +There are two different modes available to this device service: + +1. **Physical Mode:** for use with a physical controller board device +1. **Virtual Mode:** used when simulating a physical controller board by using a RESTful endpoint + +The EdgeX Core services are required for the `ds-card-reader` to publish the card ID into the EdgeX bus (zeroMQ). Without the EdgeX core services, this device service will not function. + +### Physical Device Functionality + +The `ds-card-reader` service is much simpler than the `ds-controller-board` service, because it only requires mounting `/dev/input:/dev/input` at runtime. However, it still requires root privileges in the container at runtime so that it can interact directly with event/USB drivers. + +### APIs + +--- + +#### `PUT`: `http://localhost:48098/api/v1/device/name/ds-card-reader/card-reader-event` + +The `PUT` API endpoint will push the badge ID (which is sent as part of the API request body) into the card reader device service. Once the card reader device service receives the badge ID, the badge ID will be pushed into the EdgeX bus for other application services to utilize. + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"card-reader-event":"0003278200"}' http://localhost:48098/api/v1/device/name/ds-card-reader/card-reader-event +``` + +!!! success + Response Status Code 200 OK. + +--- + +#### `GET`: `http://localhost:48098/api/v1/device/name/ds-card-reader/card-reader-status` + +The `GET` API endpoint returns data that is not meant to be consumed for any particular purpose. When triggering this endpoint, it will execute a function (in the Go source code) called `CardReaderStatus` that is used as an auto-remediation mechanism to attempt to "grab" the physical card reader HID device (via [`evdev`](https://en.wikipedia.org/wiki/Evdev)). If it succeeds in grabbing the underlying device, that means that the `ds-card-reader` device service has lost its hold on the card reader, and we need to restart the service. This endpoint is meant to be hit frequently. + +```bash +curl -X GET http://localhost:48098/api/v1/device/name/ds-card-reader/card-reader-status +``` + +Sample response: + +```json +{"device":"ds-card-reader","origin":1579130994896} +``` + +--- + +## Controller board + +### Description + +The `ds-controller-board` device service is responsible for handling communication with a custom-built Arduino micro-controller board (or virtual board if you don't have physical hardware). It provides functionality for reading the lock status, door status, temperature, and humidity readings, while also sending commands to the controller board to unlock the mag-lock, and display output to the LCD. + +There are two different modes available for this device service: + +1. **Physical Mode:** for use with a physical controller board device +2. **Virtual Mode:** used when simulating a physical controller board by using a RESTful endpoint + +### Physical Device Functionality + +When not running in simulated mode (i.e. a physical controller board device is plugged into your system), the `ds-controller-board` Docker container service requires `/dev/ttyACM0`, which is the typically the default serial port for an Arduino microcontroller. + +This may change if you have multiple serial devices plugged in. Please ensure that `/dev/ttyACM0` maps to the appropriate serial device if you plan to run the `ds-controller-board` service with a physical device. + +It is important to note that the `ds-controller-board` service _is_ capable of automatically finding a TTY port _aside_ from `/dev/ttyACM0`. It actually looks for the vendor and product ID (VID/PID) values specified in the service's configuration. The problems arise when we have to mount the TTY port via Docker: + +* mounting `/dev:/dev` to the container at runtime solves the problem, but creates security risks and requires `--privileged=true` on the container, which is bad practice and can lead to security issues +* mounting `/dev/ttyACM0:/dev/ttyACM0` solves the problem, assuming there is only one serial device + +Therefore, if you have multiple serial devices plugged into your system, please manually edit the `docker-compose.yml` file to mount your `/dev/ttyACM_X_` appropriately. You may want to explore creating udev rules to enforce TTY consistency. + +### APIs + +--- + +#### `PUT`: `http://localhost:48098/api/v1/device/name/ds-controller-board/command/lock1` + +This `PUT` command will operate magnetic `lock1`. Depending on the numeric value of `lock1` (boolean `0/1`), the lock state will either be locked or unlocked. + +Simple usage example: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"lock1":"0"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/lock1 +``` + +This will make the request directly to the device service itself instead of proxying through the EdgeX command API: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"lock1":"0"}' http://localhost:48097/api/v1/device/name/ds-controller-board/lock1 +``` + +--- + +#### `PUT`: `http://localhost:48098/api/v1/device/name/ds-controller-board/command/lock2` + +This `PUT` command will operate magnetic `lock2`. Depending on the numeric value of `lock2` (boolean `0/1`), the lock state will either be locked or unlocked. + +!!! note + Currently `lock2` has no purpose. During the initial architect/design phase of Automated Checkout, there were two locks. This was later reduced to a single mag-lock. + +Sample usage: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"lock2":"1"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/lock2 +``` + +This will make the request directly to the device service itself instead of proxying through the EdgeX command API: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"lock2":"1"}' http://localhost:48097/api/v1/device/name/ds-controller-board/lock2 +``` + +!!! success + Response Status Code 200 OK. + +!!! failure + Response Status Code 400 Bad Request + +--- + +#### `PUT`: `http://localhost:48098/api/v1/device/name/ds-controller-board/command/displayRow0` + +This `PUT` command will operate the display (LCD) and control the text to be put on the first line of the display. + +Simple usage : + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"displayRow0":"The Earth is round"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/displayRow0 +``` + +This will make the request directly to the device service itself instead of proxying through the EdgeX command API: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"displayRow0":"The Earth is round"}' http://localhost:48097/api/v1/device/name/ds-controller-board/displayRow0 +``` + +!!!info + On the endpoint URL, Change displayRow**0** index to 1, 2, or 3 to display and control the text to be put on the second, third, and forth line accordingly. + +!!! success + Response Status Code 200 OK. + +!!! failure + Response Status Code 400 Bad Request + +--- + +#### `PUT`: `http://localhost:48098/api/v1/device/name/ds-controller-board/command/setTemperature` + +This `PUT` command will emulate the temperature sensed by the controller board as a persistent value. + +!!!info + *setTemperature* is a float64. Any non-float64 value will be interpreted as '0.00' (do not have to specify decimal values). + +Simple usage : + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"setTemperature":"12.00"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setTemperature +``` + +This will make the request directly to the device service itself instead of proxying through the EdgeX command API: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"setTemperature":"12.00"}' http://localhost:48097/api/v1/device/name/ds-controller-board/setTemperature +``` + +!!! success + Response Status Code 200 OK. + +!!! failure + Response Status Code 400 Bad Request + +--- + +#### `PUT`: `http://localhost:48098/api/v1/device/name/ds-controller-board/command/setHumidity` + +This `PUT` command will emulate the humidity sensed by the controller board as a persistent value. + +!!!info + *setHumidity* is an integer. Any non-integer value will be interpreted as '0'. + +Simple usage example: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"setHumidity":"12"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setHumidity +``` + +This will make the request directly to the device service itself instead of proxying through the EdgeX command API: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"setHumidity":"12"}' http://localhost:48097/api/v1/device/name/ds-controller-board/setHumidity +``` + +!!! success + Response Status Code 200 OK. + +!!! failure + Response Status Code 400 Bad Request + +--- + +#### `PUT`: `http://localhost:48098/api/v1/device/name/ds-controller-board/command/setDoorClosed` + +This `PUT` command will emulate the "door-closed" state sensed by the controller board as a persistent value. + +!!!info + *setDoorClosed* is a boolean-integer. Any non-boolean-integer value will be interpreted as '0' (and thus 'false'). Only '1' will result in 'true'. + +Simple usage example: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"setDoorClosed":"0"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setDoorClosed +``` + +This will make the request directly to the device service itself instead of proxying through the EdgeX command API: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"setDoorClosed":"0"}' http://localhost:48097/api/v1/device/name/ds-controller-board/setDoorClosed +``` + +!!! success + Response Status Code 200 OK. + +!!! failure + Response Status Code 400 Bad Request + +--- + +## Inference mock + +### Description + +The `ds-inference-mock` device service contains two components: + +- A Python implementation of the Automated Checkout inference mock that mimics an actual computer vision inference mechanism by returning a random set of inventory "deltas" after a brief waiting period +- An [EdgeX MQTT device service](https://github.com/edgexfoundry/device-mqtt-go) that converts MQTT messages into EdgeX event readings + +The Automated Checkout architecture uses three MQTT topics: + +| Topic | Description | +| ----------------------------- | ------------------------------------------------------------------------------------------------ | +| Inference/CommandTopic | All events pushed from EdgeX's command API are fed into this topic. The [`as-vending`](https://github.com/intel-iot-devkit/automated-checkout/blob/master/as-vending) and [`as-controller-board-status`](https://github.com/intel-iot-devkit/automated-checkout/blob/master/as-controller-board-status) are two services that make requests to this API, typically for making door close/open and heartbeat events. | +| Inference/ResponseTopic | The Automated Checkout inference mock will respond to published messages on the `Inference/CommandTopic` topic on the `Inference/ResponseTopic` topic. | +| Inference/DataTopic | The inference mock publishes delta SKUs on this topic, then the MQTT device service converts them into EdgeX event readings, and finally the [`as-vending`](https://github.com/intel-iot-devkit/automated-checkout/blob/master/as-vending) service processes the event readings and pushes them to downstream services. | + +### APIs + +--- + +#### `GET`: `http://localhost:48098/api/v1/device/name/Inference-MQTT-device/command/inferenceHeartbeat` + +The `GET` call to the EdgeX MQTT device service's `inferenceHearbeat` command will act as a health-check for the Automated Checkout inferencing service. It must return `200 OK` upon swiping an RFID card in order for the vending workflow to begin. If it does not, the [`as-vending`](https://github.com/intel-iot-devkit/automated-checkout/blob/master/as-vending) service will enter maintenance mode. + +Simple usage example: + +Through EdgeX command API: + +```bash +curl -X GET http://localhost:48082/api/v1/device/name/Inference-MQTT-device/command/inferenceHeartbeat +``` + +To MQTT device service itself: + +```bash +curl -X GET http://localhost:48100/api/v1/device/name/Inference-MQTT-device/inferenceHeartbeat +``` + +Sample response, `200 OK`: + +```json +{ + "device": "Inference-MQTT-device", + "origin": 1579637607912, + "readings": [ + { + "origin": 1579637607911, + "device": "Inference-MQTT-device", + "name": "inferenceHeartbeat", + "value": "inferencePong" + } + ] +} +``` + +--- + +#### `PUT`: `http://localhost:48100/api/v1/device/name/Inference-MQTT-device/command/inferenceDoorStatus` + +The `PUT` call to the EdgeX MQTT device service's `inferenceDoorStatus` command will cause the inference mock to consume the message, and if the JSON `PUT` key `inferenceDoorStatus` has the string value `"true"`, an inference attempt will begin. The mock will subsequently respond with a message containing the inventory delta (aka SKU delta). + +Simple usage example: + +Through EdgeX command API: + +```bash +curl -X PUT -d '{"inferenceDoorStatus":"true"}' http://localhost:48082/api/v1/device/name/Inference-MQTT-device/command/inferenceDoorStatus +``` + +To MQTT device service itself: + +```bash +curl -X PUT -d '{"inferenceDoorStatus":"true"}' http://localhost:48100/api/v1/device/name/Inference-MQTT-device/inferenceDoorStatus +``` + +!!! success + Response Status Code 200 OK. + +--- diff --git a/docs_src/automated-checkout-services/micro_services.md b/docs_src/automated-checkout-services/micro_services.md new file mode 100644 index 0000000..f0c8e45 --- /dev/null +++ b/docs_src/automated-checkout-services/micro_services.md @@ -0,0 +1,666 @@ +# Other Microservices + +The Automated Checkout reference design utilizes three services that expose REST API endpoints. These three services handle business logic for the Automated Checkout reference design, and are somewhat generic in their design patterns, so for the purposes of the reference design, we simply refer to them "microservices". + +## List of microservices + +- [Authentication](#authentication) - Service that takes a card ID number and returns authentication/authorization status for the card number. +- [Inventory](#inventory) - Service that manages changes to the Automated Checkout's inventory, including storing transactions in an audit log. +- [Ledger](#ledger) - Service that stores customer financial transactions. + +## Authentication + +### Description + +The `ms-authentication` microservice is a service that works with EdgeX to expose a REST API that takes a simple 10-digit string of digits (presumably corresponding to an RFID card) and responds with a valid or invalid authentication response, as well as the corresponding role for authenticated cards. + +This repository contains logic for working within the following schemas: + +* _Card/Cards_ - swiping a card is what allows the Automated Checkout automation to proceed with its workflow. A card can be associated with one of 3 roles: + * Consumer - a typical customer; is expected to open the vending machine door, remove an item, close the door and be charged accordingly + * Stocker - a person that is authorized to re-stock the vending machine with new products + * Maintainer - a person that is authorized to fix the software/hardware +* _Account/Accounts_ - represents a bank account to charge. Multiple people can be associated with an account, such as a married couple +* _Person/People_ - a person can carry multiple cards but is only associated with one account + +The [`ds-card-reader`](https://github.com/intel-iot-devkit/automated-checkout/blob/master/ds-card-reader) service is responsible for pushing card "swipe" events to the EdgeX framework, which will then feed into the [`as-vending`](https://github.com/intel-iot-devkit/automated-checkout/blob/master/as-vending) microservice that then performs a REST HTTP API call to this microservice. The response is processed by the [`as-vending`](https://github.com/intel-iot-devkit/automated-checkout/blob/master/as-vending) microservice and the workflow continues there. + +### APIs + +--- + +#### `GET`: `/authentication/{cardid}` + +The `GET` call will return the user information if the `cardid` URL parameter matches a valid card ID number (according to the file `cards.json`). If the `cardid` is not found, an unauthorized response is returned. + +Simple usage example: + +```bash +curl -X GET http://localhost:48096/authentication/0003278425 +``` + +Authorized card sample response: + +```json +{ + "content": "{\"accountID\":1,\"personID\":1,\"roleID\":1,\"cardID\":\"0003278425\"}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` + +Unauthorized card sample response: + +```json + { + "content": "Card ID is not a valid card", + "contentType": "string", + "statusCode": 401, + "error": false + } +``` + +## Inventory + +### Description + +The `ms-inventory` microservice is a service that works with EdgeX to expose a REST API that manages the inventory for the vending machine, and keeps an audit log of all transactions (authorized or not). + +This repository contains logic for working within the following schemas: + +* _Inventory_ - an inventory item has the following attributes: + * `sku` - the SKU number of the inventory item + * `itemPrice` - the price of the inventory item + * `productName` - the name of the inventory item, will be displayed to users + * `unitsOnHand` - the number of units stored in the vending machine + * `maxRestockingLevel` - the maximum allowable number of units of this type to be stored in the vending machine + * `minRestockingLevel` - the minimum allowable number of units of this type to be stored in the vending machine + * `createdAt` - the date the inventory item was created and catalogued + * `updatedAt` - the date the inventory item was last updated (either via a transaction or something else) + * `isActive` - whether or not the inventory item is "active", which is not currently actively used by the Automated Checkout reference design for any specific purposes +* _Audit Log_ - an audit log entry contains the following attributes: + * `cardId` - card number + * `accountId` - account number + * `roleId` - the role + * `personId` - the ID of the person who is associated with the card + * `inventoryDelta` - what was changed in inventory + * `createdAt` - the transaction date + * `auditEntryId` - and a UUID representing the transaction itself uniquely + +The `ms-inventory` microservice receives REST API calls from the upstream [`as-vending`](https://github.com/intel-iot-devkit/automated-checkout/blob/master/as-vending) application service during a typical vending workflow. Typically, an individual will swipe a card, the workflow will start, and the inventory will be manipulated after an individual has removed or added items to the vending machine and an inference has completed. REST API calls to this service are not locked behind any authentication mechanism. + +### APIs + +--- + +#### `GET`: `/inventory` + +The `GET` call will return the entire inventory in JSON format. + +Simple usage example: + +```bash +curl -X GET http://localhost:48095/inventory +``` + +Sample response: + +```json +{ + "content": "{\"data\":[{\"sku\":\"4900002470\",\"itemPrice\":1.99,\"productName\":\"Sprite (Lemon-Lime) - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200010735\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew (Low Calorie) - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":18,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200050408\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":6,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"7800009257\",\"itemPrice\":1.99,\"productName\":\"Water (Dejablue) - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"4900002762\",\"itemPrice\":1.99,\"productName\":\"Dasani Water - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":32,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200081119\",\"itemPrice\":1.99,\"productName\":\"Pepsi (Wild Cherry) - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":12,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200018402\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew (blue) - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":6,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"4900002469\",\"itemPrice\":1.99,\"productName\":\"Diet Coke - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"490440\",\"itemPrice\":1.99,\"productName\":\"Coca-Cola - 20 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":72,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true}]}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` + +--- + +#### `POST`: `/inventory` + +The `POST` call will add a list of items into inventory and will return the newly added items as a JSON string in the `content` field of the response. Will also behave like a `PATCH` and supports updating the inventory in accordance with the submitted list of objects, each containing the fields to update based on matched SKU values. + +Simple usage example: + +```bash +curl -X POST -d '[{"createdAt": "1567787309","isActive": true,"itemPrice": 3.00,"maxRestockingLevel": 24,"minRestockingLevel": 0,"sku": "4900002470","unitsOnHand": 0,"updatedAt": "1567787309"}]' http://localhost:48095/inventory +``` + +Sample response: + +```json +{ + "content": "[{\"sku\":\"4900002470\",\"itemPrice\":3,\"productName\":\"Sprite (Lemon-Lime) - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1578955062042600972\",\"isActive\":true}]", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` + +--- + +#### `OPTIONS`: `/inventory` + +The `OPTIONS` call will respond with a `200 OK` always. This is to enable web browsers to interact with the `/inventory` API endpoint, in accordance with the expected response for a CORS [pre-flight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request). + +Simple usage example: + +```bash +curl -X OPTIONS http://localhost:48095/inventory +``` + +Sample response: + +``` +200 OK +``` + +--- + +#### `POST`: `/inventory/delta` + +The `POST` call will increment or decrement inventory item(s) by a provided `delta` that match the given `SKU` numbers, and will return a JSON string containing the updated inventory items in the `content` field of the response. + +Simple usage example: + +```bash +curl -X POST -d '[{"SKU":"7800009257","delta":-1000},{"SKU":"7800009257","delta":-1000}]' http://localhost:48095/inventory/delta +``` + +Sample response: + +```json +{ + "content": "[{\"sku\":\"7800009257\",\"itemPrice\":1.99,\"productName\":\"Water (Dejablue) - 16.9 oz\",\"unitsOnHand\":-1000,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"7800009257\",\"itemPrice\":1.99,\"productName\":\"Water (Dejablue) - 16.9 oz\",\"unitsOnHand\":-2000,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true}]", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` + +--- + +#### `OPTIONS`: `/inventory/delta` + +The `OPTIONS` call will respond with a `200 OK` always. This is to enable web browsers to interact with the `/inventory/delta` API endpoint, in accordance with the expected response for a CORS [pre-flight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request). + +Simple usage example: + +```bash +curl -X OPTIONS http://localhost:48095/inventory/delta +``` + +Sample response: + +``` +200 OK +``` + +--- + +#### `GET`: `/inventory/{sku}` + +The `GET` call will return a JSON string of a single inventory item whose SKU matches the URL parameter `{sku}` in the `content` field of the response. + +Simple usage example: + +```bash +curl -X GET http://localhost:48095/inventory/4900002470 +``` + +Sample response: + +```json +{ + "content": "{\"sku\":\"4900002470\",\"itemPrice\":3,\"productName\":\"Sprite (Lemon-Lime) - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1578955062042600972\",\"isActive\":true}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` + +If the `{sku}` does not correspond to a known item in the inventory, the response is: + +```json +{ + "content": "", + "contentType": "string", + "statusCode": 404, + "error": false +} +``` + +--- + +#### `DELETE`: `/inventory/{sku}` + +The `DELETE` call will delete an inventory item whose SKU matches the URL parameter `{sku}` and return the deleted inventory item in the `content` field of the responses. + +Simple usage example: + +```bash +curl -X DELETE http://localhost:48095/inventory/4900002470 +``` + +Sample response: + +```json +{ + "content": "{\"sku\":\"4900002470\",\"itemPrice\":1.99,\"productName\":\"Sprite (Lemon-Lime) - 16.9 oz\",\"unitsOnHand\":0,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` + +If the provided `{sku}` does not correspond to a known item in the inventory, the response is: + +```json +{ + "content": "Item does not exist", + "contentType": "string", + "statusCode": 404, + "error": false +} +``` + +--- + +#### `OPTIONS`: `/inventory/{sku}` + +The `OPTIONS` call will respond with a `200 OK` always. This is to enable web browsers to interact with the `/inventory/{sku}` API endpoint, in accordance with the expected response for a CORS [pre-flight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request). + +Simple usage example: + +```bash +curl -X OPTIONS http://localhost:48095/inventory/4900002470 +``` + +Sample response: + +``` +200 OK +``` + +--- + +#### `GET`: `/auditlog` + +The `GET` call on this API endpoint will return the entire audit log in JSON format. + +Simple usage example: + +```bash +curl -X GET http://localhost:48095/auditlog +``` + +Sample response: + +```json +{ + "content": "{\"data\":[{\"cardId\":\"0003293374\",\"accountId\":1,\"roleId\":2,\"personId\":1,\"inventoryDelta\":[{\"SKU\":\"4900002470\",\"delta\":24},{\"SKU\":\"1200010735\",\"delta\":18},{\"SKU\":\"1200050408\",\"delta\":6},{\"SKU\":\"7800009257\",\"delta\":24},{\"SKU\":\"4900002762\",\"delta\":32},{\"SKU\":\"1200081119\",\"delta\":12},{\"SKU\":\"1200018402\",\"delta\":6},{\"SKU\":\"4900002469\",\"delta\":24},{\"SKU\":\"490440\",\"delta\":72}],\"createdAt\":\"1588006102888406420\",\"auditEntryId\":\"f944b60b-e389-4054-9643-2a33e4a0b227\"}]}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` + +--- + +#### `POST`: `/auditlog` + +The `POST` call on this API endpoint will add one entry into the audit log and will return the added entry as a JSON string in the `content` field of the response. + +Simple usage example: + +```bash +curl -X POST -d '{"cardId": "0","roleId": 0,"personId": 0,"inventoryDelta": [{"SKU": "000","delta":-1}],"createdAt": "000"}' http://localhost:48095/auditlog +``` + +Sample response: + +```json +{ + "content": "{\"cardId\":\"0\",\"accountId\":0,\"roleId\":0,\"personId\":0,\"inventoryDelta\":[{\"SKU\":\"000\",\"delta\":-1}],\"createdAt\":\"1588006208233972031\",\"auditEntryId\":\"b61bed78-da3b-4862-b548-b4ab16574495\"}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` + +--- + +#### `OPTIONS`: `/auditlog` + +The `OPTIONS` call will respond with a `200 OK` always. This is to enable web browsers to interact with the `/auditlog` API endpoint, in accordance with the expected response for a CORS [pre-flight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request). + +Simple usage example: + +```bash +curl -X OPTIONS http://localhost:48095/auditlog +``` + +Sample response: + +``` +200 OK +``` + +--- + +#### `GET`: `/auditlog/{auditEntryId}` + +The `GET` call on this API endpoint will will return a JSON string of a single audit log entry whose `auditEntryId` (which is a UUID) matches the one specified in the URL. + +Simple usage example: + +```bash +curl -X GET http://localhost:48095/auditlog/b61bed78-da3b-4862-b548-b4ab16574495 +``` + +Sample response: + +```json +{ + "content": "{\"cardId\":\"0\",\"accountId\":0,\"roleId\":0,\"personId\":0,\"inventoryDelta\":[{\"SKU\":\"000\",\"delta\":-1}],\"createdAt\":\"1588006208233972031\",\"auditEntryId\":\"b61bed78-da3b-4862-b548-b4ab16574495\"}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` + +If the `{auditEntryId}` parameter does not correspond to an existing audit log entry, the response is: + +```json +{ + "content": "", + "contentType": "string", + "statusCode": 404, + "error": false +} +``` + +--- + +#### `DELETE`: `/auditlog/{auditEntryId}` + +The `DELETE` call on this API endpoint will delete an audit log entry whose `auditEntryId` (which is a UUID) matches the URL parameter `{auditEntryId}` and will return a JSON string containing the deleted audit log entry in the `content` field of the response + +Simple usage example: + +```bash +curl -X DELETE http://localhost:48095/auditlog/b61bed78-da3b-4862-b548-b4ab16574495 +``` + +Sample response: + +```json +{ + "content": "{\"cardId\":\"0\",\"accountId\":0,\"roleId\":0,\"personId\":0,\"inventoryDelta\":[{\"SKU\":\"000\",\"delta\":-1}],\"createdAt\":\"1588014993644633617\",\"auditEntryId\":\"c555d26e-9b3d-4ae8-8053-d2270e40ccf0\"}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` + +If the `{auditEntryId}` parameter does not correspond to an existing audit log entry, the response is: + +```json +{ + "content": "Item does not exist", + "contentType": "string", + "statusCode": 404, + "error": false +} +``` + +--- + +#### `OPTIONS`: `/auditlog/{auditEntryId}` + +The `OPTIONS` call will respond with a `200 OK` always. This is to enable web browsers to interact with the `/auditlog` API endpoint, in accordance with the expected response for a CORS [pre-flight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request). + +Simple usage example: + +```bash +curl -X OPTIONS http://localhost:48095/auditlog/f944b60b-e389-4054-9643-2a33e4a0b227 +``` + +Sample response: + +``` +200 OK +``` + +--- + +## Ledger + + +### Description + +The `ms-ledger` microservice updates a ledger with the current transaction information (products purchased, quantity, total price, transaction timestamp). Transactions are added to the consumer's account. Transactions also have an `isPaid` attribute to designate which transactions have been paid/unpaid. + +This microservice returns the current transaction to the [`as-vending`](https://github.com/intel-iot-devkit/automated-checkout/blob/master/as-vending) microservice, which then calls the [`ds-controller-board`](https://github.com/intel-iot-devkit/automated-checkout/blob/master/ds-controller-board) microservice to display the items purchased and the total price of the transaction on the LCD. + +### APIs + +#### `GET`: `/ledger` + +The `GET` call will return the entire ledger in JSON format. + +Simple usage example: + +```bash +curl -X GET http://localhost:48093/ledger +``` + +Sample response: + +```json +{ + "content": "{\"data\":[{\"accountID\":1,\"ledgers\":[{\"transactionID\":\"1588006480995452968\",\"txTimeStamp\":\"1588006480995453037\",\"lineTotal\":7.96,\"createdAt\":\"1588006480995453110\",\"updatedAt\":\"1588006480995453171\",\"isPaid\":false,\"lineItems\":[{\"sku\":\"1200050408\",\"productName\":\"Mountain Dew - 16.9 oz\",\"itemPrice\":1.99,\"itemCount\":3},{\"sku\":\"7800009257\",\"productName\":\"Water (Dejablue) - 16.9 oz\",\"itemPrice\":1.99,\"itemCount\":1}]}]},{\"accountID\":2,\"ledgers\":[]},{\"accountID\":3,\"ledgers\":[]},{\"accountID\":4,\"ledgers\":[]},{\"accountID\":5,\"ledgers\":[]},{\"accountID\":6,\"ledgers\":[]}]}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` + +--- + +#### `POST`: `/ledger` + +The `POST` call will create a transaction and add it to the ledger for the specified `accountId` in the JSON body. + +Simple usage example: + +```bash +curl -X POST -d '{"accountId":1,"deltaSKUs":[{"sku":"1200050408","delta":-1}]}' http://localhost:48093/ledger +``` + +Sample response: + +```json +{ + "content": "{\"transactionID\":\"1588006579251812793\",\"txTimeStamp\":\"1588006579251812850\",\"lineTotal\":1.99,\"createdAt\":\"1588006579251812909\",\"updatedAt\":\"1588006579251812968\",\"isPaid\":false,\"lineItems\":[{\"sku\":\"1200050408\",\"productName\":\"Mountain Dew - 16.9 oz\",\"itemPrice\":1.99,\"itemCount\":1}]}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` + +--- + +#### `OPTIONS`: `/ledger` + +The `OPTIONS` call will respond with a `200 OK` always. This is to enable web browsers to interact with the `/ledger` API endpoint, in accordance with the expected response for a CORS [pre-flight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request). + +Simple usage example: + +```bash +curl -X OPTIONS http://localhost:48093/ledger +``` + +Sample response: + +``` +200 OK +``` + +--- + +#### `GET`: `/ledger/{accountid}` + +The `GET` call will return the ledger for a specified `{accountid}`. + +Simple usage example: + +```bash +curl -X GET http://localhost:48093/ledger/1 +``` + +Sample response: + +```json +{ + "content": "{\"accountID\":1,\"ledgers\":[{\"transactionID\":\"1588006480995452968\",\"txTimeStamp\":\"1588006480995453037\",\"lineTotal\":7.96,\"createdAt\":\"1588006480995453110\",\"updatedAt\":\"1588006480995453171\",\"isPaid\":false,\"lineItems\":[{\"sku\":\"1200050408\",\"productName\":\"Mountain Dew - 16.9 oz\",\"itemPrice\":1.99,\"itemCount\":3},{\"sku\":\"7800009257\",\"productName\":\"Water (Dejablue) - 16.9 oz\",\"itemPrice\":1.99,\"itemCount\":1}]},{\"transactionID\":\"1588006579251812793\",\"txTimeStamp\":\"1588006579251812850\",\"lineTotal\":1.99,\"createdAt\":\"1588006579251812909\",\"updatedAt\":\"1588006579251812968\",\"isPaid\":false,\"lineItems\":[{\"sku\":\"1200050408\",\"productName\":\"Mountain Dew - 16.9 oz\",\"itemPrice\":1.99,\"itemCount\":1}]}]}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` + +If the provided `{accountid}` parameter does not correspond to a valid ledger account number, the response is: + +```json +{ + "content": "AccountID not found in ledger", + "contentType": "string", + "statusCode": 400, + "error": false +} +``` + +--- + +#### `OPTIONS`: `/ledger/{accountid}` + +The `OPTIONS` call will respond with a `200 OK` always. This is to enable web browsers to interact with the `/ledger/{accountid}` API endpoint, in accordance with the expected response for a CORS [pre-flight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request). + +Simple usage example: + +```bash +curl -X OPTIONS http://localhost:48093/ledger/1 +``` + +Sample response: + +``` +200 OK +``` + +--- + +#### `POST`: `/ledger/ledgerPaymentUpdate` + +The `POST` call will update the transaction in the ledger of the specified account. + +Simple usage example: + +```bash +curl -X POST -d '{"accountId":1,"transactionID":"1588006579251812793","isPaid":true}' http://localhost:48093/ledgerPaymentUpdate +``` + +Sample response: + +```json +{ + "content": "Updated Payment Status for transaction 1588006579251812793", + "contentType": "string", + "statusCode": 200, + "error": false +} +``` + +If the provided `transactionID` does not correspond to an existing transaction in the ledger, the response is: + +```json +{ + "content": "Could not find Transaction 1588006579251812793", + "contentType": "string", + "statusCode": 400, + "error": true +} +``` + +--- + +#### `OPTIONS`: `/ledgerPaymentUpdate` + +The `OPTIONS` call will respond with a `200 OK` always. This is to enable web browsers to interact with the `/ledgerPaymentUpdate` API endpoint, in accordance with the expected response for a CORS [pre-flight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request). + +Simple usage example: + +```bash +curl -X OPTIONS http://localhost:48093/ledgerPaymentUpdate +``` + +Sample response: + +``` +200 OK +``` + +--- + +#### `DELETE`: `/ledger/{accountid}/{transactionid}` + +The `DELETE` call will delete the transaction by its `transactionid` from the ledger for the specified account by its `accountid`. + +Simple usage example: + +```bash +curl -X DELETE http://localhost:48093/ledger/1/1588006579251812793 +``` + +Sample response: + +```json +{ + "content": "Deleted ledger 1588006579251812793", + "contentType": "string", + "statusCode": 200, + "error": false +} +``` + +If the provided `transactionID` does not correspond to an existing transaction in the ledger, the response is: + +```json +{ + "content": "Could not find Transaction 1588006579251812793", + "contentType": "string", + "statusCode": 400, + "error": true +} +``` +--- + +#### `OPTIONS`: `/ledger/{accountid}/{transactionid}` + +The `OPTIONS` call will respond with a `200 OK` always. This is to enable web browsers to interact with the `/ledger/{accountid}/{transactionid}` API endpoint, in accordance with the expected response for a CORS [pre-flight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request). + +Simple usage example: + +```bash +curl -X OPTIONS http://localhost:48093/ledger/1/1588006579251812793 +``` + +Sample response: + +``` +200 OK +``` + +--- diff --git a/docs_src/configuration.md b/docs_src/configuration.md new file mode 100644 index 0000000..dea0b41 --- /dev/null +++ b/docs_src/configuration.md @@ -0,0 +1,155 @@ +# Configuration + +This page lists all of the relevant configuration parameters for each service in the Automated Checkout reference design. + +!!!info + Note that this document likely does not cover EdgeX-specific configuration parameters. Application and device service SDK documentation can be found in the [EdgeX Foundry GitHub repositories](https://github.com/edgexfoundry). + +## Environment Overrides + +The simplest way to change one of the configuration values described below is via the use of environment variable overrides in the docker compose file. The value of each configuration item in a service's configuration can be overridden with an environment variable specific to that item. The name of the environment variable is the path to the item in the configuration tree with underscores separating the nodes. The character case of each node in the environment variable name must match that found in the service's configuration. Here are a few examples for the Driver section: + +```toml +[Driver] + VID = "65535" # 0xFFFF + PID = "53" # 0x0035 +``` + +```yaml +Driver_VID: "256" ** Good ** +Driver_PID: "26" ** Good ** + +DRIVER_VID: "256" ** BAD ** +driver_pid: "26" ** BAD ** +``` + +These overrides are placed in the target service's environment section of the compose file. Here is an example: + +```yaml + ds-card-reader: + user: "2000:2000" + image: "automated-checkout/ds-card-reader:dev" + container_name: automated-checkout_ds-card-reader + environment: + <<: *common-variables + Driver_VID: "256" + Driver_PID: "26" + <<: *logging + depends_on: + - data + - command + restart: always + ipc: none +``` + +## Card Reader Device Service + +The following items can be configured via the `Driver` section of the service's [configuration.toml](https://github.com/intel-iot-devkit/automated-checkout/blob/master/ds-card-reader/res/configuration.toml) file. All values are strings. + +- `DeviceName` - the name of the device to be associated with EdgeX events and readings originating from this service, if unsure leave default `ds-card-reader` +- `DeviceSearchPath` - the bash globstar expression to use when searching for the raw input device, default is `/dev/input/event*` +- `VID` - the `uint16` value (as a base-10 string) corresponding to the Vendor ID of the USB device (run `lsusb` to list VID and PID values of connected USB devices). For example, if the VID is `ffff` in the output of `lsusb`, it is `"65535"` in the configuration file +- `PID` - the `uint16` value (as a base-10 string) corresponding to the Product ID of the USB device (run `lsusb` to list VID and PID values of connected USB devices). For example, if the PID is `0035` in the output of `lsusb`, it is `"53"` in the configuration file +- `SimulateDevice` - the boolean value that tells this device service to expect an input device to dictate inputs (`false`), or if a simulated device will be used (and REST API calls will control it) (`true`) - if `true` + +## Controller Board Device Service + +The following items can be configured via the `Driver` section of the service's [configuration.toml](https://github.com/intel-iot-devkit/automated-checkout/blob/master/ds-controller-board/res/configuration.toml) file. All values are strings. + +- `DisplayTimeout` - The value in seconds corresponding to the display timeout length before resetting the display to the status display. +- `LockTimeout` - The value in seconds corresponding to the lock timeout used to automatically lock the door in case no lock command was sent +- `VID` - the `string` value corresponding to the Vendor ID hexadecimal (base-16) of the USB device (run `lsusb` to list VID and PID values of connected USB devices). For example, if the VID is `2341` in the output of `lsusb`, it is `"2341"` in the configuration file +- `PID` - the `string` value corresponding to the Product ID hexadecimal (base-16) of the USB device (run `lsusb` to list VID and PID values of connected USB devices). For example, if the PID is `8037` in the output of `lsusb`, it is `"8037"` in the configuration file +- `VirtualControllerBoard` - the boolean value that tells this device service to expect an input device to dictate inputs (`false`), or if a simulated device will be used (and REST API calls will control it) (`true`) - if `true` + +## EdgeX MQTT Device Service + +This reference design uses the [MQTT Device Service](https://github.com/edgexfoundry/device-mqtt-go) from EdgeX with custom device profiles. These device profiles YAML files are located [here](https://github.com/intel-iot-devkit/automated-checkout/blob/master/res/device-mqtt/docker) and are volume mounted into the device service's running Docker container. + +The following items can be configured via the `DeviceList` and `Driver` section of the service's [configuration.toml](https://github.com/intel-iot-devkit/automated-checkout/blob/master/res/device-mqtt/docker/configuration.toml) file. All values are strings. + +`DeviceList` + +- `IncomingSchema` - Data schema type, aka protocol +- `IncomingHost` - Host name of the incoming MQTT Broker +- `IncomingPort` - Port number of the incoming MQTT Broker +- `IncomingUser` - Username for the incoming MQTT Broker +- `IncomingPassword` - Password for the incoming MQTT Broker +- `IncomingQos` - Quality of service agreement between sender and receiver +- `IncomingKeepAlive` - Keep alive duration for the incoming MQTT Broker +- `IncomingClientId` - Client ID for the incoming MQTT Broker +- `IncomingTopic` - Subscribe topic for the incoming MQTT Broker + +`Driver` + +- `ResponseSchema` - Data schema type, aka protocol +- `ResponseHost` - Host name of the response MQTT Broker +- `ResponsePort` - Port number of the response MQTT Broker +- `ResponseUser` - Username for the response MQTT Broker +- `ResponsePassword` - Password for the response MQTT Broker +- `IncomingQos` - Quality of service agreement between sender and receiver +- `ResponseKeepAlive` - Keep alive duration for the response MQTT Broker +- `ResponseClientId` - Client ID for the response MQTT Broker +- `ResponseTopic` - Subscribe topic for the response MQTT Broker + +## Controller Board Status Application Service + +The following items can be configured via the `ApplicationSettings` section of the service's [configuration.toml](https://github.com/intel-iot-devkit/automated-checkout/blob/master/as-controller-board-status/res/configuration.toml) file. All values are strings. + +- `AverageTemperatureMeasurementDuration` - The time-duration string (i.e. `-15s`, `-10m`) value of how long to process temperature measurements for calculating an average temperature. This calculation determines how quickly a "temperature threshold exceeded" notification is sent +- `DeviceName` - The string name of the upstream EdgeX device that will be pushing events & readings to this application service +- `MaxTemperatureThreshold` - The float64 value of the maximum temperature threshold, if the average temperature over the sample `AverageTemperatureMeasurementDuration` exceeds this value, a notification is sent +- `MinTemperatureThreshold` - The float64 value of the minimum temperature threshold, if the average temperature over the sample `AverageTemperatureMeasurementDuration` exceeds this value, a notification is sent +- `MQTTEndpoint` - A string containing the full EdgeX core command REST API endpoint corresponding to the `inferenceDoorStatus` command, registered by the MQTT device service in the inference mock +- `NotificationCategory` - The category for notifications as a string +- `NotificationEmailAddresses` - A comma-separated values (CSV) string of emails to send notifications to +- `NotificationHost` - The full string URL of the EdgeX notifications service API that allows notifications to be sent by submitting an HTTP Post request +- `NotificationLabels` - A comma-separated values (CSV) string of labels to apply to notifications, which are handled by EdgeX +- `NotificationReceiver` - The human-readable string name of the person/entity receiving the notification, such as `System Administrator` +- `NotificationSender` - The human-readable string name of the person/entity sending the notification, such as `Automated Checkout Maintenance Notification` +- `NotificationSeverity` - A string tag indicating the severity of the notification, such as `CRITICAL` +- `NotificationSlug` - A string that is a short label that may be used as part of a URL to delineate the notification subscription, such as `sys-admin`. The EdgeX official documentation says, _"Effectively a name or key that labels the notification"_. This service creates an EdgeX subscription with a `slug` value of `NotificationSlug`. +- `NotificationSlugPrefix` - A string similar to `NotificationSlug`, except that the `NotificationSlugPrefix` is appended with the current system time and the actual notification message's slug value is set to that value. +- `NotificationSubscriptionMaxRESTRetries` - The integer value that represents the maximum number of times to try creating a subscription in the EdgeX notification service, such as `10` +- `NotificationSubscriptionRESTRetryInterval` - The time-duration string (i.e. `10s`) representing how long to wait between each attempt at trying to create a subscription in the EdgeX notification service, +- `NotificationThrottleDuration` - The time-duration string corresponding to how long to snooze notification alerts after sending an alert, such as `1m`. Note that this value is stored in memory at runtime and if the service restarts, the time between notifications is not kept. +- `RESTCommandTimeout` - The time-duration string representing how long to wait for any command to an EdgeX command API response before considering it a timed-out request, such as `15s` +- `SubscriptionHost` - The URL (as a string) of the EdgeX notification service's subscription API +- `VendingEndpoint` - The URL (as a string) corresponding to the central vending endpoint's `/boardStatus` API endpoint, which is where events will be Posted when there is a door open/close change event, or a "temperature threshold exceeded" event. + +## Vending Application Service + +The following items can be configured via the `ApplicationSettings` section of the service's [configuration.toml](https://github.com/intel-iot-devkit/automated-checkout/blob/master/as-vending/res/configuration.toml) file. All values are strings. + +- `DeviceControllerBoardLock1` - EdgeX Command service endpoint for lock 1 events +- `DeviceControllerBoardLock2` - EdgeX Command service endpoint for lock 2 events +- `DeviceControllerBoarddisplayRow0` - EdgeX Command service endpoint for Row 0 on LCD +- `DeviceControllerBoarddisplayRow1` - EdgeX Command service endpoint for Row 1 on LCD +- `DeviceControllerBoarddisplayRow2` - EdgeX Command service endpoint for Row 2 on LCD +- `DeviceControllerBoarddisplayRow3` - EdgeX Command service endpoint for Row 3 on LCD +- `DeviceControllerBoarddisplayReset` - EdgeX Command service endpoint for Resetting the LCD text +- `AuthenticationEndpoint` - Endpoint for authentication microservice +- `InferenceHeartbeat` - EdgeX Command service endpoint for Inference Heartbeat +- `InferenceDoorStatus` - EdgeX Command service endpoint for Inference Door status +- `LedgerService` - Endpoint for Ledger Micro Service +- `InventoryService` - Endpoint for Inventory Micro Service +- `InventoryAuditLogService` - Endpoint for Inventory Audit Log Micro Service +- `DoorOpenStateTimeout` - The time-duration string (i.e. `-15s`, `-10m`) used for Door Open lockout time delay, in seconds +- `DoorCloseStateTimeout` - The time-duration string (i.e. `-15s`, `-10m`) used for Door Close lockout time delay, in seconds +- `InferenceTimeout` - The time-duration string (i.e. `-15s`, `-10m`) used for Inference message time delay, in seconds +- `LCDRowLength` - Max number of characters for LCD Rows + +## Authentication microservice + +For this particular microservice, there are no specific configuration options. Future settings would be added under the `[ApplicationSettings]` section. + +## Inventory microservice + +For this particular microservice, there are no specific configuration options. Future settings would be added under the `[ApplicationSettings]` section. + +## Ledger microservice + + +The following items can be configured via the `ApplicationSettings` section of the service's [configuration.toml](https://github.com/intel-iot-devkit/automated-checkout/blob/master/ms-ledger/res/configuration.toml) file. All values are strings. + +- `InventoryEndpoint` - Endpoint that correlates to the Inventory microservice. This is used to query Inventory data used to generate the ledgers. diff --git a/docs_src/events.md b/docs_src/events.md new file mode 100644 index 0000000..34e1eed --- /dev/null +++ b/docs_src/events.md @@ -0,0 +1,66 @@ +# Automated Checkout Events + +The following are the different events used in the Automated Checkout reference design. + +## Card Reader events + +The [`ds-card-reader`](./automated-checkout-services/device_services.md#Card-reader) uses the EdgeX events pattern to send the card information into EdgeX Core Data as well as maintain a healthy state. + +`card-reader-event` is an asynchronous event sent when a card is scanned by the card reader device. The event reading value is a string containing a 10-digit number and is placed into EdgeX Core Data as an event reading. + +``` json +"0003293374" +``` + +`card-reader-status` is an auto-event used to check the status of card reader connection. Every x seconds the event will check to see if the card reader is accessible. If the service is unable to verify the connection to the card reader then the service will restart. This event produces no database entry in EdgeX Core Data. + +## Controller Board events + +The [`ds-controller-board`](./automated-checkout-services/device_services.md#Controller-board) uses the EdgeX events pattern to send the card information into EdgeX Core Data. + +`controller-board-status` is an auto-event used to send the current state of the controller board and all of its periferals to EdgeX Core Data. This data is used by the as-controller-board-status application service to determine the state of the system. The information included in the status are the door lock states, door state, temperature, and humidity. The EdgeX Reading value is a string containing the following JSON: + +``` json +{ + "lock1_status":1, + "lock2_status":1, + "door_closed":true, + "temperature":78, + "humidity":10 +} +``` + +The following commands are also available to the ds-controller-board. More details can be found [`here`](./automated-checkout-services/device_services.md#Controller-board). + +- `lock1` +- `lock2` +- `displayRow0` +- `displayRow1` +- `displayRow2` +- `displayRow3` +- `setTemperature` +- `setHumidity` +- `setDoorClosed` + +## Computer vision inference events + +The [`ds-inference-mock`](./automated-checkout-services/device_services.md#Inference-Mock) uses the EdgeX MQTT Device Service to send status updates and inference deltas to the EdgeX Core Data. The MQTT device service profile can be found in the file `./res/device-mqtt/inference.mqtt.device.profile.yml`, in the root of this GitHub repository. + +`inferenceHeartbeat` is an asynchronous event that is pushed to EdgeX Core Data when the inference is pinged by another service to verify it is functioning. If the inference is working properly the `inferencePong` response is sent as the event reading. + +``` json +{ + "inferencePong" +} +``` + +`inferenceSkuDelta` is an asynchronous event that pushes the delta data from the inference engine into EdgeX Core Data. The delta data can be used to update the inventory and create ledgers when appropriate. The EdgeX Event Reading contains a string value which is represented by the following JSON example: + +``` json +[ + {"SKU": "4900002470", "delta": -1}, + {"SKU": "1200010735", "delta": -2} +] +``` + +Finally the `inferenceDoorStatus` command is defined by the custom device profile for the EdgeX MQTT Device Service which sends the ping request to the computer vision inference mock. More details can be found [`here`](./automated-checkout-services/device_services.md#Inference-Mock). diff --git a/docs_src/images/MongoDB-contents.png b/docs_src/images/MongoDB-contents.png new file mode 100644 index 0000000..8a774bb Binary files /dev/null and b/docs_src/images/MongoDB-contents.png differ diff --git a/docs_src/images/as-controller-board-status.png b/docs_src/images/as-controller-board-status.png new file mode 100644 index 0000000..2d69aa7 Binary files /dev/null and b/docs_src/images/as-controller-board-status.png differ diff --git a/docs_src/images/automated-checkout-reference-design.png b/docs_src/images/automated-checkout-reference-design.png new file mode 100644 index 0000000..9b518e7 Binary files /dev/null and b/docs_src/images/automated-checkout-reference-design.png differ diff --git a/docs_src/images/automated-checkout.png b/docs_src/images/automated-checkout.png new file mode 100644 index 0000000..fdbc78f Binary files /dev/null and b/docs_src/images/automated-checkout.png differ diff --git a/docs_src/images/card-unlock.png b/docs_src/images/card-unlock.png new file mode 100644 index 0000000..d7f1cf2 Binary files /dev/null and b/docs_src/images/card-unlock.png differ diff --git a/docs_src/images/customer.png b/docs_src/images/customer.png new file mode 100644 index 0000000..adb6f4a Binary files /dev/null and b/docs_src/images/customer.png differ diff --git a/docs_src/images/maintenance-mode.png b/docs_src/images/maintenance-mode.png new file mode 100644 index 0000000..5c47901 Binary files /dev/null and b/docs_src/images/maintenance-mode.png differ diff --git a/docs_src/images/maintenance.png b/docs_src/images/maintenance.png new file mode 100644 index 0000000..8517cfb Binary files /dev/null and b/docs_src/images/maintenance.png differ diff --git a/docs_src/images/open-close-door.png b/docs_src/images/open-close-door.png new file mode 100644 index 0000000..29ef905 Binary files /dev/null and b/docs_src/images/open-close-door.png differ diff --git a/docs_src/images/portainer-device-logs.png b/docs_src/images/portainer-device-logs.png new file mode 100644 index 0000000..4261842 Binary files /dev/null and b/docs_src/images/portainer-device-logs.png differ diff --git a/docs_src/images/portainer-device-services.png b/docs_src/images/portainer-device-services.png new file mode 100644 index 0000000..a145c94 Binary files /dev/null and b/docs_src/images/portainer-device-services.png differ diff --git a/docs_src/images/stocker.png b/docs_src/images/stocker.png new file mode 100644 index 0000000..1b8aeaa Binary files /dev/null and b/docs_src/images/stocker.png differ diff --git a/docs_src/index.md b/docs_src/index.md new file mode 100644 index 0000000..ed0b4f9 --- /dev/null +++ b/docs_src/index.md @@ -0,0 +1,199 @@ +# Automated Checkout Reference Design + +## Introduction + +This guide helps you build and run the Automated Checkout Reference Design. + +Upon completing the steps in this guide, you will be ready to integrate sensors and services to build your own complete solution. + +!!! info + This guide does not create a complete, ready-to-use solution. Instead, upon completing the steps in this guide, you will be ready to integrate sensors and services to build your own Automated Checkout solution. + + Certain third-party software or hardware identified in this document only may be used upon securing a license directly from the third-party software or hardware owner. The identification of non-Intel software, tools, or services in this document does not constitute a sponsorship, endorsement, or warranty by Intel. + +

    + +

    + +### Block diagram + +The high-level diagram below shows the sensors and services used with the Automated Checkout Reference Design. The diagram shows the sensors and services, and how they communicate through EdgeX. Intel provides the services outlined in blue, the purple services are provided by EdgeX, and the black services are either simulated or can interface with real hardware. + +![Automated Checkout Reference Design Diagram](./images/automated-checkout-reference-design.png) + +### Prerequisites + +The following items are required to build the Automated Checkout Reference Design. You will need additional hardware and software when you are ready to build your own solution. + +- **An inferencing solution that integrates with an MQTT broker.** Intel provides a simulated inference that produces random inventory changes. See [MQTT](./automated-checkout-services/device_services.md#inference-mock) for information on this process. +- **A device that allows badging-in to the Automated Checkout.** Intel provides a card reader service that can be simulated or integrated with a physical USB device. See the [Card Reader](./automated-checkout-services/device_services.md#card-reader) device service page for information on this service. +- **A controller device that locks the door to the Automated Checkout**, as well as providing readouts (such as a small text-based LCD screen) to display authorization state, items purchased, and other sensor readings. This could be an Arduino-powered circuit. Intel provides a display service that can run in a simulated mode or with a physical USB/serial interface. See the [Controller Board](./automated-checkout-services/device_services.md#controller-board) device service page for implementation details. + +- Ubuntu 18.04 +- Docker +- Docker Compose +- Go 1.12+ for development purposes or running without docker. +- Git +- GNU make +- A REST client such as curl or Postman for running through the phases outlined in the documentation. + +Here's how to install `git`, `curl`, and `make` on an Ubuntu 18.04 system - other operating systems may vary: + +```bash +sudo apt-get update -y +sudo apt-get install -y git curl build-essential +``` + +### Hardware + +For [**Phase 2 - Add Card Reader Device**](./phases/phase2.md), a USB based RFID card reader or second regular USB keyboard can be used. + +Additionally, frequently throughout this documentation, we will refer to a "cooler" or "cooler door". This is referring to a vending machine or refrigerator with a sealed location for cooling. Inventory/stock are intended to be placed inside the cooler, and the temperature and humidity inside the cooler are monitored. + +### Recommended domain knowledge + +- EdgeX - the Automated Checkout reference design utilizes the EdgeX framework +- MQTT +- REST +- evdev, if reading input events from a USB input device, such as a card reader that inputs key strokes upon scanning a card +- Communication over serial on Linux, if using serial devices such as Arduino +- Computer Vision concepts, if using CV inferencing components +- Basic RFID concepts, if using RFID components (i.e. for badge-in card reader) +- Portainer- included with the Automated Checkout reference design. Usage is optional, but this is a highly recommended utility for managing Docker containers, and we provide easy ways to run it. + +## Getting started + +### Step 1: Clone the repository + +```bash +git clone https://github.com/intel-iot-devkit/automated-checkout.git && cd ./automated-checkout +``` + +### Step 2: Build the reference design + +You must build the provided component services and create local docker images. To do so, run: + +```bash +make build +``` + +!!! note + This command may take a while to run depending on your internet connection and machine specifications. + +#### Check for success + +Make sure the command was successful. To do so, run: + +```bash +docker images | grep automated-checkout +``` + +!!! success + The results are: + + - `automated-checkout/as-controller-board-status` + - `automated-checkout/as-vending` + - `automated-checkout/build` (latest tag) + - `automated-checkout/ds-card-reader` + - `automated-checkout/ds-controller-board` + - `automated-checkout/ds-inference-mock` + - `automated-checkout/ms-authentication` + - `automated-checkout/ms-inventory` + - `automated-checkout/ms-ledger` + +!!! failure + If you do not see all of the above docker images, look through the console output for errors. Sometimes dependencies fail to resolve and must be run again. Address obvious issues. To try again, repeat step 2. + +### Step 3: Start the reference design suite + +Use Docker Compose to start the reference design suite. To do so, run: + +```bash +make run +``` + +This command starts the EdgeX Device Services and then starts all the Automated Checkout Reference Design Services. + +#### Check for success + +Make sure the command was successful. To do so, run: + +```bash +docker ps --format 'table{{.Image}}\t{{.Status}}' +``` + +!!! success + Your output is as follows: + + | IMAGE | STATUS | + |----------------------------------------------------|--------------| + | consul:1.3.1 | Up 4 minutes | + | eclipse-mosquitto:1.6.3 | Up 3 minutes | + | edgexfoundry/docker-core-command-go:1.1.0 | Up 3 minutes | + | edgexfoundry/docker-core-data-go:1.1.0 | Up 3 minutes | + | edgexfoundry/docker-core-metadata-go:1.1.0 | Up 3 minutes | + | edgexfoundry/docker-device-mqtt-go:1.1.0 | Up 3 minutes | + | edgexfoundry/docker-edgex-mongo:1.1.0 | Up 4 minutes | + | edgexfoundry/docker-edgex-volume:1.1.0 | Up 4 minutes | + | edgexfoundry/docker-support-logging-go:1.1.0 | Up 4 minutes | + | edgexfoundry/docker-support-notifications-go:1.1.0 | Up 3 minutes | + | automated-checkout/as-controller-board-status:dev | Up 3 minutes | + | automated-checkout/as-vending:dev | Up 3 minutes | + | automated-checkout/ds-card-reader:dev | Up 3 minutes | + | automated-checkout/ds-controller-board:dev | Up 3 minutes | + | automated-checkout/ds-inference-mock:dev | Up 3 minutes | + | automated-checkout/ms-authentication:dev | Up 3 minutes | + | automated-checkout/ms-inventory:dev | Up 3 minutes | + | automated-checkout/ms-ledger:dev | Up 3 minutes | + +You can also use Portainer to check the status of the services. You must run Portainer service first: + +```bash +make run-portainer +``` + +Then, navigate to the following Portainer URL and create an admin account: + +

    + http://127.0.0.1:9000 +

    + +After, navigate to the following URL to list all of the containers running under the `automated-checkout` stack: + +

    + http://127.0.0.1:9000/#/stacks/automated-checkout?type=2&external=true +

    + +### Step 4: Dive in + +All of the core components of Automated Checkout are up and running, and you are ready to begin going through the following phases. + +- [Phase 1](./phases/phase1.md) - Simulate data and inferencing, and simulate events +- [Phase 2](./phases/phase2.md) - Add Card Reader Device +- [Phase 3](./phases/phase3.md) - Bring Your Own Hardware and Software + +## General Guidance + +After completing the steps in the Getting Started section, it may be helpful to read through the remainder of this document for some further guidance on the Automated Checkout reference design. + +### How to use the Compose Files + +The `docker-compose.yml` files are segmented to allow for fine control of physical and simulated devices, as well as allowing you the choice of running Portainer. Use the [`makefile`](https://github.com/intel-iot-devkit/automated-checkout/blob/master/Makefile) to manage the various compose files: + +| Compose file | Purpose | Makefile Command | +|---------------------------|-------------------------------------------------|--------------------------------------| +| Portainer | Container management | `make run-portainer` | +| All Services | Automated Checkout and EdgeX services | `make run` | +| Physical Environment | Mounts physical devices | `make run-physical` | +| Physical Card Reader | Allows just the card reader to be physical | `make run-physical-card-reader` | +| Physical Controller Board | Allows just the controller board to be physical | `make run-physical-controller-board` | + +### Expanding the Reference Design + +The reference design you created is not a complete solution. It provides the base components for creating a framework to run a CV-powered Automated Checkout. It is your choice on how many and which sensors and devices to include. This section provides information about components you might want to include or replace. + +| Component | Description | +|----------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| RFID card reader | A card reader device service is provided for a USB based RFID card reader. As an alternative, you can also use a regular USB keyboard to enter 10-digit number. See *[Phase 2 - Add Card Reader Device](./phases/phase2.md)* for more information. | +| Micro-controller board | A controller board device service is provided for an Arduino based micro-controller. This micro-controller is in charge of controlling the locks of the automated checkout door and the LED display. Also, it uses modules such as temperature and humidity. See *[Phase 3 - Bring Your Own Hardware and Software](./phases/phase3.md)* for more information. | +| Computer vision inference engine | The Automated Checkout reference design provides a computer vision inference mock service for simulation purposes. See more information [here](./automated-checkout-services/device_services.md#inference-mock). You can create your own mock service and send events to EdgeX using the [EdgeX MQTT Device Service](https://github.com/edgexfoundry/device-mqtt-go). | diff --git a/docs_src/modifying_source_code.md b/docs_src/modifying_source_code.md new file mode 100644 index 0000000..885eacb --- /dev/null +++ b/docs_src/modifying_source_code.md @@ -0,0 +1,69 @@ +# Modifying source code + +When modifying source code in the Automated Checkout reference design, Docker images need to be rebuilt and services need to be updated to run newly built images. This document contains the steps for accomplishing this. + +## Assumptions + +This document assumes the Automated Checkout services are already running. Additionally, it assumes you've already made a code change and saved the changes. + +## Building the service's new image + +Once the code change is saved, proceed to build the service's image. In this example, assume that the `ds-card-reader` service's source code has been altered. + +Start by navigating to the root of this repository: + +```bash +cd +``` + +Next, build the specific service's image: + +```bash +make ds-card-reader +``` + +After Docker builds the image (by executing the steps in [`ds-card-reader/Dockerfile`](https://github.com/intel-iot-devkit/automated-checkout/blob/master/ds-card-reader/Dockerfile)), proceed to the next section. + +## Remove and update the running service + +One of the most effective methods of updating a Docker compose service is to remove the running container, and then re-run the `make` commands to bring up the entire Automated Checkout reference design stack. + +First, identify the running container for the service (again, `ds-card-reader` in this example): + +```bash +docker ps | grep -i ds-card-reader +``` + +Using the output from the previous command, remove the container by referring to either its name or ID: + +```bash +docker rm -f +``` + +Once the container has been removed, bring up the entire stack using the `Makefile` command corresponding to your environment, which is **one** of the following commands. + +For a standard simulated environment: + +```bash +make run +``` + +For a physical card reader only, and simulating all other services: + +```bash +make run-physical-card-reader +``` + +For a physical controller board only, and simulating all other services: + +```bash +make run +``` + +For all physical device services: + +```bash +make run-physical +``` + +Once **one** of the above commands has been run, the modified `ds-card-reader` service will automatically start up with the newly built image. diff --git a/docs_src/notifications.md b/docs_src/notifications.md new file mode 100644 index 0000000..07b73b1 --- /dev/null +++ b/docs_src/notifications.md @@ -0,0 +1,48 @@ +# How to Send Notifications through EdgeX (optional) + +This section provides instructions to help you configure the EdgeX notifications service to send alerts through SMS, email, REST API calls, and others. + +Notifications work as follows: + +1. When either the minimum or maximum temperature thresholds (defined in `as-controller-board-status`) have been exceeded (calculated as an average temperature over a configurable duration), the service enters maintenance mode and begins the process of sending an alert + +2. The `as-controller-board-status` service sends these alerts as email messages through the EdgeX notification service using REST API calls + +To change the message type from email to a different medium, the `as-controller-board-status` service should be updated to use a different notification type. + +## Step 1: Set Environment Variables + +Set environment variable overrides for `Smtp_Host` and `Smtp_Port` in 'config-seed', which will inject these variables into the notification service's registry. + +Additional notification service configuration properties are [here](https://fuji-docs.edgexfoundry.org/Ch-AlertsNotifications.html#configuration-properties "EdgeX Alerts & Notifications"). + +## Step 2: Add code to the config-seed Environment Section + +The code snippet below is a docker-compose example that sends an email notification. Add this code to the `config-seed` service's environment section in `docker-compose.yml`. + +``` yaml +environment: + <<: *common-variables + Smtp_Host: + Smtp_Port: 25 + Smtp_Password: + Smtp_Sender: + Smtp_Subject: Automated Checkout Notification +``` + +## Step 3: Add SMTP Server to compose file (optional) + +The snipped below adds a development SMTP server smtp4dev to your `docker-compose.yml`. +Skip this step if you want to use Gmail or another server. + +``` yaml +smtp-server: + image: rnwood/smtp4dev:linux-amd64-v3 + ports: + - "3000:80" + - "2525:25" + restart: "on-failure:5" + container_name: smtp-server + networks: + - automated-checkout_default # the name of this network may be different for your setup +``` diff --git a/docs_src/phases/phase1.md b/docs_src/phases/phase1.md new file mode 100644 index 0000000..12eeee0 --- /dev/null +++ b/docs_src/phases/phase1.md @@ -0,0 +1,617 @@ +# Phase 1 - Simulation Mode + +## Overview + +This document aims to help provide a simple introduction to how we interact with the various microservices in the Automated Checkout reference design, as well as demonstrating how EdgeX command API's are leveraged. + +The steps in this guide show how to simulate the automated checkout workflow using [`curl`](https://github.com/curl/curl) REST API calls. It is a step-by-step walkthrough with specific commands to run on the command line. + +The documentation in [phase 2](./phase2.md) and [phase 3](./phase3.md) will discuss more advanced methods of adding physical hardware and customized device services. + +### Scenarios + +This walkthrough completes the following three scenarios: + +1. [**Stock the Cooler with inventory**](#1-stock-the-cooler-with-inventory) + - The cooler is empty - it has no stock in its inventory + - A worker swipes their badge + - The worker adds stock to the cooler +1. [**Purchase from the Cooler as a customer**](#2-purchase-from-the-cooler-as-a-customer) + - Later, a customer swipes their badge to open the cooler + - The customer takes item(s) from the inventory + - The customer closes the door and gets billed +1. [**The Cooler requires maintenance**](#3-the-cooler-requires-maintenance) + - The internal temperature of the cooler has exceeded the maximum temperature threshold + - A maintenance worker resolves the issue + +## Getting Started + +1. Complete steps 1-4 in [Getting Started](../index.md#step-1-clone-the-repository). +1. Make sure the containers are all up and running (aside from `edgex-config-seed`): `docker-compose ps` +1. Make sure the services are not running in maintenance mode: + +```bash +curl -X GET http://localhost:48099/maintenanceMode +``` + +Verify the output and make sure that `maintenanceMode` value is set to false. + +```json +{ + "content": "{\"maintenanceMode\":false}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` + +If `maintenanceMode` is set to true, run the following command to reset maintenance mode back to false: + +``` bash +docker-compose restart as-vending ds-controller-board as-controller-board-status +``` + +1. In a separate terminal window, watch the logs for a few Automated Checkout services, so that incoming events can be seen: + +```bash +docker-compose logs -f ds-card-reader ds-controller-board ms-authentication as-vending as-controller-board-status device-mqtt +``` + +!!! info + The output from `ds-controller-board` and `as-controller-board-status` may be noisy due to an automated status check occurring every 3 seconds. It may be desirable to try watching logs without those two services. + + Additionally, using Portainer to watch Docker compose service logs can be extremely helpful. Start it by running: + + ``` + make run-portainer + ``` + + Then, navigate to `http://localhost:9000/` in a web browser. + +Continue to the next section to start using `curl` to run through the simulated scenarios. + +## Walkthrough of Scenarios + +Each section below contains specific steps and expected output for each of the scenarios mentioned above. + +### 1. Stock the Cooler with Inventory + +In order to fill up the cooler with inventory, someone acting as a "stocker" must swipe their card and proceed to fill the Automated Checkout with products. + +However, before we get started, it's important to keep a few things in mind. We will perform a very specific sequence of events: + +1. Swipe badge +1. Open the cooler door +1. Close the cooler door +1. Verify that the cooler's inventory has been populated +1. Verify that the cooler's audit log shows the transaction + +That's it! Each of the above actions has a corresponding REST API call that we will run using the `curl` program on the command line. + +

    + +

    + +!!! warning + **This sequence of events is time-sensitive. Once started, you must continue the sequence.** + + **Once someone has swiped their card, the cooler door unlocks, and the person has roughly 20 seconds (configurable) to open the door before it locks again, if unopened.** With this in mind, prepare to run this command, and the following commands soon after. + + It's OK to run the commands without critically analyzing them _in the moment_. You may find it most useful to review them in advance. + + If you mess up, you should start fresh. Run the command `make down && make clean-docker && make run` to scrub the Automated Checkout data and containers, wait approximately one minute after all services have started, and begin again. This scenario does not have any dependencies on the other scenarios in phase 1. + +The following diagram represents the flow for swiping your badge and unlocking the door: + +

    + +

    + +To simulate this, perform this REST API call to the `ds-card-reader` service ***(time sensitive)***: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"card-reader-event":"0003293374"}' http://localhost:48098/api/v1/device/name/ds-card-reader/card-reader-event +``` + +!!! note + There should not be any response message when running this EdgeX command successfully. + +!!! info + By default, the card number `0003293374` corresponds to a card in the [`ms-authentication/cards.json`](https://github.com/intel-iot-devkit/automated-checkout/blob/master/ms-authentication/cards.json) file that has the "stocker" role associated to it. + +JSON object for `cardId` 0003293374. + +```json +{ + "cardId": "0003293374", + "roleId": 2, + "isValid": true, + "personId": 1, + "createdAt": "1560815799", + "updatedAt": "1560815799" +} +``` + +Immediately after, use the `as-controller-board-status` `/status` API endpoint to verify that the lock is unlocked ***(time sensitive)***: + +```bash +curl -X GET http://localhost:48094/status +``` + +!!! warning + The lock must have a reading of 0 (unlocked) before proceeding to the next steps. If you attempt to open the door while the lock is engaged the system will assume an error state has occurred and go into maintenance mode. + +
    + (Click to Expand) Expected Response + +

    + Note that the lock1_status is set to 0, implying that lock1 has been unlocked. It will only stay unlocked for (default) 15 seconds, until the door is opened, at which time an independent timer is started that waits (default) 20 seconds for the stocker (or customer) to close the door after altering inventory. +

    + +```json +{ + "content":"{ \"lock1_status\":0, + \"lock2_status\":1, + \"door_closed\":true, + \"temperature\":78, + \"humidity\":10, + \"minTemperatureStatus\":false, + \"maxTemperatureStatus\":false + }", + "contentType":"json","statusCode":200,"error":false +} +``` +
    + +Then open the door, and close it afterwards, while waiting approximately 3-4 seconds between each event using the following 2 commands. + +The following command makes a REST API call to the `ds-controller-board` service to open the door (no response body expected) ***(time sensitive)***: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"setDoorClosed":"0"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setDoorClosed +``` + +Wait 3.75 seconds: + +```bash +sleep 3.75 +``` + +!!! note + Waiting around 3-4 seconds is necessary because the frequency of "auto-events" that relay readings between some services is set to 3 seconds by default. + + This implies that, for example, if you open and close the cooler door within the span of 1-2 seconds, there is a possibility that the auto-event did not pick up the change in the state of the door since its state did not change _from one auto-event to the next_. + +The following command makes a REST API call to the `ds-controller-board` service to close the door (no response body expected) ***(time sensitive)***: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"setDoorClosed":"1"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setDoorClosed +``` + +Wait about 20-30 seconds for the inventory to be discovered by the inference (which is being mocked), and also for background processing of events to occur. **The time-sensitive sequence has been completed.** + +The following diagram represents the flow for opening and closing the door: + +

    + +

    + +After waiting, use the following API calls to check the inventory, audit log, and ledger ***(not time sensitive)***: + +```bash +curl -X GET http://localhost:48095/inventory +``` + +
    + (Click to Expand) Inventory API Response Example + +

    +The (altered) contents of ms-inventory/inventory.json are contained in the content key below. +

    + +```json +{ + "content": "{\"data\":[{\"sku\":\"4900002470\",\"itemPrice\":1.99,\"productName\":\"Sprite (Lemon-Lime) - 16.9 oz\",\"unitsOnHand\":24,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200010735\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew (Low Calorie) - 16.9 oz\",\"unitsOnHand\":18,\"maxRestockingLevel\":18,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200050408\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew - 16.9 oz\",\"unitsOnHand\":6,\"maxRestockingLevel\":6,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"7800009257\",\"itemPrice\":1.99,\"productName\":\"Water (Dejablue) - 16.9 oz\",\"unitsOnHand\":24,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"4900002762\",\"itemPrice\":1.99,\"productName\":\"Dasani Water - 16.9 oz\",\"unitsOnHand\":32,\"maxRestockingLevel\":32,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200081119\",\"itemPrice\":1.99,\"productName\":\"Pepsi (Wild Cherry) - 16.9 oz\",\"unitsOnHand\":12,\"maxRestockingLevel\":12,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200018402\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew (blue) - 16.9 oz\",\"unitsOnHand\":6,\"maxRestockingLevel\":6,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"4900002469\",\"itemPrice\":1.99,\"productName\":\"Diet Coke - 16.9 oz\",\"unitsOnHand\":24,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"490440\",\"itemPrice\":1.99,\"productName\":\"Coca-Cola - 20 oz\",\"unitsOnHand\":72,\"maxRestockingLevel\":72,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true}]}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` +
    + +```bash +curl -X GET http://localhost:48095/auditlog +``` + +
    + (Click to Expand) Audit Log API Response Example + +

    +The (altered) contents of ms-inventory/auditlog.json are contained in the content key below. +

    + +```json +{ + "content": "{\"data\":[{\"cardId\":\"0003293374\",\"accountId\":1,\"roleId\":2,\"personId\":1,\"inventoryDelta\":[{\"SKU\":\"4900002470\",\"delta\":24},{\"SKU\":\"1200010735\",\"delta\":18},{\"SKU\":\"1200050408\",\"delta\":6},{\"SKU\":\"7800009257\",\"delta\":24},{\"SKU\":\"4900002762\",\"delta\":32},{\"SKU\":\"1200081119\",\"delta\":12},{\"SKU\":\"1200018402\",\"delta\":6},{\"SKU\":\"4900002469\",\"delta\":24},{\"SKU\":\"490440\",\"delta\":72}],\"createdAt\":\"1585088126815981442\",\"auditEntryId\":\"4c1bca23-b097-4750-8a3b-43cc09733425\"}]}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` +
    + + +```bash +curl -X GET http://localhost:48093/ledger +``` + +
    + (Click to Expand) Ledger API Response Example + +

    +Since this a stocking event and not a customer transaction, there is no ledger entry for this transaction. Later in this walkthrough, similar steps will be followed that will yield a financial transaction and hence, a ledger entry. +

    + +

    +By default, the ledger service has six registered accounts (accounts 1-6) for consumers. The valid accounts match the account ID's that have authorized access to the cooler through the ms-authentication service (see the ms-authentication/accounts.json file). +

    + +

    +The (unaltered) contents of ms-ledger/ledger.json are contained in the content key below. +

    + +```json +{ + "content": "{\"data\":[ + {\"accountID\":1,\"ledgers\":[]}, + {\"accountID\":2,\"ledgers\":[]}, + {\"accountID\":3,\"ledgers\":[]}, + {\"accountID\":4,\"ledgers\":[]}, + {\"accountID\":5,\"ledgers\":[]}, + {\"accountID\":6,\"ledgers\":[]} + ] + }", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` +
    + +**That's it!** The cooler has been populated with inventory, and the audit log and inventory both show evidence of this. + +### 2. Purchase from the cooler as a Customer + +Now that the cooler's inventory has been stocked, we can simulate a customer swiping their card and removing one or more items from the cooler for purchase. The same time-sensitive disclaimers from the stocking simulation (which was done earlier in this walkthrough) apply here as well, so please review the [Stock the Cooler with Inventory](#Stock-the-cooler-with-Inventory) section if you have not done so yet. + +!!! warning + If you have not already populated the inventory as described in the [Stock the Cooler with Inventory](#Stock-the-Cooler-with-Inventory) section, do not proceed. The mocked inferencing service follows a specific sequence for changes in inventory. The first transaction in the sequence is always a _gain_ of inventory, corresponding to the stocker adding items to inventory. The following transactions are _removal_ of inventory, corresponding to customers _taking_ items from inventory. + + If you mess up, you should start fresh. Run the command `make down && make clean-docker && make run` to scrub the Automated Checkout data and containers, wait approximately one minute after all services have started, and begin again. This scenario relies on the stocking scenario in phase 1 - if the stocking scenario is skipped, it is still OK, but the randomized sequence of transactions will yield inventory/audit log/ledger changes that differ from the expected examples shown throughout this scenario. + +In a manner similar to the previous section (where we stocked our inventory), the following steps are taken when simulating a customer: + +1. Swipe badge +1. Open the cooler door +1. Close the cooler door +1. Verify that the cooler's inventory has been altered +1. Verify that the cooler's audit log shows the transaction +1. Verify that the cooler's ledger shows the transaction + +That's it! Each of the above actions has a corresponding REST API call that we will run using the `curl` program on the command line. + +

    + +

    + +To begin, start by performing the following REST command to simulate a customer swiping their badge to open the cooler ***(time sensitive)***: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"card-reader-event":"0003278380"}' http://localhost:48098/api/v1/device/name/ds-card-reader/card-reader-event +``` + +!!! note + There should not be any response message when running this EdgeX command successfully. + +Immediately after, just as before, use the `as-controller-board-status` `/status` API endpoint to verify that the lock is unlocked ***(time sensitive)***: + +```bash +curl -X GET http://localhost:48094/status +``` + +
    + (Click to Expand) Expected Response +

    + Note that the lock1_status is set to 0, implying that lock1 has been unlocked. It will only stay unlocked for (default) 15 seconds, until the door is opened, at which time an independent timer is started that waits (default) 20 seconds for the customer (or stocker) to close the door after altering inventory. +

    + +```json +{ + "content":"{ \"lock1_status\":0, + \"lock2_status\":1, + \"door_closed\":true, + \"temperature\":78, + \"humidity\":10, + \"minTemperatureStatus\":false, + \"maxTemperatureStatus\":false + }", + "contentType":"json","statusCode":200,"error":false +} +``` +
    + +Then open the door, and close it afterwards, while waiting approximately 3-4 seconds between each event using the following 2 commands. + +The following command makes a REST API call to the `ds-controller-board` service to open the door (no response body expected) ***(time sensitive)***: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"setDoorClosed":"0"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setDoorClosed +``` + +Wait 3.75 seconds: + +```bash +sleep 3.75 +``` + +The following command makes a REST API call to the `ds-controller-board` service to close the door (no response body expected) ***(time sensitive)***: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"setDoorClosed":"1"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setDoorClosed +``` + +At this point we are done simulating customer interactions with the Automated Checkout. The next steps are to get the inventory, ledger, and audit logs, and verify that they all show consistent information ***(not time sensitive, but may need to wait 20-30 seconds for background processing)***: + +```bash +curl -X GET http://localhost:48095/inventory +``` + +
    + (Click to Expand) Inventory API Response Example + +

    +A few items have been removed from the inventory in the below API response. Carefully examine the unitsOnHand and note that some items are no longer fully stocked by also examining the maxRestockingLevel. It may be extra insightful to compare this to the stocker section's inventory API response example, and also even more insightful to take a look at the below audit log and ledger responses for a proper view of the inventory delta that took place. +

    + +

    +The (altered) contents of ms-inventory/inventory.json are contained in the content key below. +

    + +```json +{ + "content": "{\"data\":[{\"sku\":\"4900002470\",\"itemPrice\":1.99,\"productName\":\"Sprite (Lemon-Lime) - 16.9 oz\",\"unitsOnHand\":24,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200010735\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew (Low Calorie) - 16.9 oz\",\"unitsOnHand\":18,\"maxRestockingLevel\":18,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200050408\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew - 16.9 oz\",\"unitsOnHand\":3,\"maxRestockingLevel\":6,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"7800009257\",\"itemPrice\":1.99,\"productName\":\"Water (Dejablue) - 16.9 oz\",\"unitsOnHand\":23,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"4900002762\",\"itemPrice\":1.99,\"productName\":\"Dasani Water - 16.9 oz\",\"unitsOnHand\":32,\"maxRestockingLevel\":32,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200081119\",\"itemPrice\":1.99,\"productName\":\"Pepsi (Wild Cherry) - 16.9 oz\",\"unitsOnHand\":12,\"maxRestockingLevel\":12,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"1200018402\",\"itemPrice\":1.99,\"productName\":\"Mountain Dew (blue) - 16.9 oz\",\"unitsOnHand\":6,\"maxRestockingLevel\":6,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"4900002469\",\"itemPrice\":1.99,\"productName\":\"Diet Coke - 16.9 oz\",\"unitsOnHand\":24,\"maxRestockingLevel\":24,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true},{\"sku\":\"490440\",\"itemPrice\":1.99,\"productName\":\"Coca-Cola - 20 oz\",\"unitsOnHand\":72,\"maxRestockingLevel\":72,\"minRestockingLevel\":0,\"createdAt\":\"1567787309\",\"updatedAt\":\"1567787309\",\"isActive\":true}]}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` +
    + +In this particular example, the customer purchased `1 item of Water (Dejablue) (sku 7800009257)` and `3 items of Mountain Dew (sku 1200050408)` +You can compare the `unitsOnHand` of each sku from the previous inventory data in step 1. + +```bash +curl -X GET http://localhost:48095/auditlog +``` + +
    + (Click to Expand) Audit Log API Response Example + +

    +The audit log has a new transaction that corresponds to this customer interaction. It also contains the original stocker interaction. +

    + +

    +The (altered) contents of ms-inventory/auditlog.json are contained in the content key below. +

    + +```json +{ + "content": "{\"data\":[{\"cardId\":\"0003293374\",\"accountId\":1,\"roleId\":2,\"personId\":1,\"inventoryDelta\":[{\"SKU\":\"4900002470\",\"delta\":24},{\"SKU\":\"1200010735\",\"delta\":18},{\"SKU\":\"1200050408\",\"delta\":6},{\"SKU\":\"7800009257\",\"delta\":24},{\"SKU\":\"4900002762\",\"delta\":32},{\"SKU\":\"1200081119\",\"delta\":12},{\"SKU\":\"1200018402\",\"delta\":6},{\"SKU\":\"4900002469\",\"delta\":24},{\"SKU\":\"490440\",\"delta\":72}],\"createdAt\":\"1585678869586092314\",\"auditEntryId\":\"7b3c2672-ba66-412c-a262-9816f3414eff\"},{\"cardId\":\"0003278380\",\"accountId\":1,\"roleId\":1,\"personId\":1,\"inventoryDelta\":[{\"SKU\":\"1200050408\",\"delta\":-3},{\"SKU\":\"7800009257\",\"delta\":-1}],\"createdAt\":\"1585679067690432556\",\"auditEntryId\":\"c7fa7e2d-a24c-428f-9c03-08460cd69e29\"}]}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` +
    + +```bash +curl -X GET http://localhost:48093/ledger +``` + +
    + (Click to Expand) Ledger API Response Example + +

    +Note that this API response now includes a financial transaction indicating what was actually removed from the cooler and associated with the customer's transaction. Other accounts in the ledger are still empty since there have been no transactions. +

    + +

    +The (altered) contents of ms-ledger/ledger.json are contained in the content key below. +

    + +```json +{ + "content": "{\"data\":[ + {\"accountID\":1,\"ledgers\":[{\"transactionID\":\"1585679067654735828\",\"txTimeStamp\":\"1585679067654735975\",\"lineTotal\":7.96,\"createdAt\":\"1585679067654736044\",\"updatedAt\":\"1585679067654736110\",\"isPaid\":false,\"lineItems\":[{\"sku\":\"1200050408\",\"productName\":\"Mountain Dew - 16.9 oz\",\"itemPrice\":1.99,\"itemCount\":3},{\"sku\":\"7800009257\",\"productName\":\"Water (Dejablue) - 16.9 oz\",\"itemPrice\":1.99,\"itemCount\":1}]}]}, + {\"accountID\":2,\"ledgers\":[]}, + {\"accountID\":3,\"ledgers\":[]}, + {\"accountID\":4,\"ledgers\":[]}, + {\"accountID\":5,\"ledgers\":[]}, + {\"accountID\":6,\"ledgers\":[]} + ]}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` +
    + +From the ledger data, notice the transaction done by accountID 1. + +```json +"{\"accountID\":1, + \"ledgers\":[{\"transactionID\":\"1585679067654735828\", + \"txTimeStamp\":\"1585679067654735975\", + \"lineTotal\":7.96, + \"createdAt\":\"1585679067654736044\", + \"updatedAt\":\"1585679067654736110\", + \"isPaid\":false, + \"lineItems\":[{\"sku\":\"1200050408\", + \"productName\":\"Mountain Dew - 16.9 oz\", + \"itemPrice\":1.99, + \"itemCount\":3}, + {\"sku\":\"7800009257\", + \"productName\":\"Water (Dejablue) - 16.9 oz\", + \"itemPrice\":1.99, + \"itemCount\":1}] + }]}" +``` + +### 3. The Cooler Requires Maintenance + +In this scenario, all Automated Checkout services are operating as usual, except the following conditions are present: + +* The cooler has exceeded the maximum allowable temperature threshold of 83 degrees Fahrenheit +* It has stayed at or above this temperature threshold for more than 15 seconds + +

    + +

    + +
    + (Click to Expand) Technical note about temperature + +

    +The as-controller-board-status service takes temperature readings regularly and calculates the average temperature over a configurable amount of time. If the average temperature over this duration exceeds the thresholds defined in the as-controller-board-status service's configured value, it will cause the cooler to enter maintenance mode and it will attempt to send a notification. The frequency of notifications can be configured as well. +

    + +

    +If the temperature temporarily exceeds the maximum or minimum allowable temperature thresholds, but does not push the time-averaged temperature above or below the thresholds, no notification will be sent. +

    + +
    + +When the Automated Checkout is in an unstable state such as the one presented above, it enters _maintenance mode_. When the Automated Checkout is in this state, it automatically denies access to everyone except individuals that possess badges that are associated with the maintenance worker role. + +!!! note + Maintenance mode is triggered in a few conditions: + + * Minimum or maximum temperature thresholds exceeded over a time-averaged temperature + * The cooler door is left open for too long + * The inferencing service is not responsive upon badge swipe + * The inferencing service is not responsive upon an inferencing request + +This scenario walks through the following steps: + +1. Set the temperature to a value above the default maximum temperature threshold +1. Continue to set the temperature until the time-averaged temperature is above the default maximum temperature threshold +1. Simulate a maintenance worker swiping their badge to maintain the cooler +1. Reset the temperature back to normal +1. Verify that maintenance mode is no longer active + +!!! warning + **This sequence of events is time-sensitive. Once started, you must continue the sequence.** + + This sequence differs from the other scenarios leading up to this point. It does not require the cooler door to be opened. + + It's OK to run the commands without critically analyzing them _in the moment_. You may find it most useful to review them in advance. + + If you mess up, you should start fresh. Run the command `make down && make clean-docker && make run` to scrub the Automated Checkout data and containers, wait approximately one minute after all services have started, and begin again. This scenario does not have any dependencies on the other scenarios in phase 1. + +To begin the scenario, first start by setting the temperature of the cooler to `99.00` degrees Fahrenheit. The following command will make a REST API call to the `ds-controller-board` service ***(time sensitive)***: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"setTemperature":"99.00"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setTemperature +``` + +!!! note + There should not be any response message when running this EdgeX command successfully. + +Repeat this command once or twice, over a span of 15 seconds to establish an average. + +During this waiting period, periodically check the status of maintenance mode. The following command will make a REST API call to the `as-vending` service ***(no longer time sensitive)***: + +```bash +curl -X GET http://localhost:48099/maintenanceMode +``` + +
    + (Click to Expand) Expected Output + +

    +The value of maintenanceMode will switch to true from false once the time-averaged temperature exceeds the maximum temperature threshold (default 83 degrees Fahrenheit): +

    + +```json +{ + "content": "{\"maintenanceMode\":true}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` +
    + +The following diagram represents the flow for setting the temperature and setting maintenance mode to true: + +

    + +

    + +The next step involves a maintenance worker swiping their badge to resolve the issue. When a maintenance worker swipes their badge, maintenance mode is reset. + +For the sake of simplicity in this walkthrough, we will first fix the temperature of the cooler and _then_ the maintenance worker will swipe their badge to fix maintenance mode. The reason the maintenance worker would have to swipe their badge twice is because maintenance mode will be set to `false` immediately, but it will be immediately set back to `true` once the next temperature reading arrives. So, to avoid swiping the badge twice, the temperature will be reset before swiping. + +First, set the temperature to a normal value (45 degrees) a few times over the span of 15 seconds (minimum) ***(time sensitive)***: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"setTemperature":"45.00"}' http://localhost:48082/api/v1/device/name/ds-controller-board/command/setTemperature +``` + +!!! note + There should not be any response message when running this EdgeX command successfully. + +Now that a new, proper average temperature value has been set, the maintenance worker can proceed to swipe their card, fix the cooler, and set the maintenance mode back to false. + +To do this, follow a familiar step, only this time use a card that has been assigned to a maintenance worker role ***(not time sensitive)***: + +```bash +curl -X PUT -H "Content-Type: application/json" -d '{"card-reader-event":"0003278385"}' http://localhost:48098/api/v1/device/name/ds-card-reader/card-reader-event +``` + +!!! note + There should not be any response message when running this EdgeX command successfully. + +!!! info + The card 0003278385 is assigned to the maintenance worker role, and a person with ID 1. Additionally, if the maintenance worker opens and closes the door, there will be a corresponding audit log entry for that door open/close event. + +Now, check that maintenance mode has been reset using a familiar command ***(not time sensitive)***: + +```bash +curl -X GET http://localhost:48099/maintenanceMode +``` + +
    + (Click to Expand) Expected Output + +

    +The value of maintenanceMode will switch to true from false once the time-averaged temperature exceeds the maximum temperature threshold (default 83 degrees Fahrenheit): +

    + +```json +{ + "content": "{\"maintenanceMode\":false}", + "contentType": "json", + "statusCode": 200, + "error": false +} +``` + +
    + +This is the end of the scenario, and should provide an essential understanding of maintenance mode as well as temperature reactions in the Automated Checkout reference design. + +## Summary + +You have successfully run through a typical Automated Checkout workflow using simulated interactions and devices. In the other phases of this reference design, we ramp up to using physical devices and provide guidance on writing new services for your custom devices and needs. diff --git a/docs_src/phases/phase2.md b/docs_src/phases/phase2.md new file mode 100644 index 0000000..29e40aa --- /dev/null +++ b/docs_src/phases/phase2.md @@ -0,0 +1,296 @@ +# Phase 2 - Add Card Reader Device + +In [phase 1](./phase1.md), the scenarios presented a breakdown of the various modes, events, and services that are working together within the Automated Checkout reference design. Everything in phase 1 was simulated and all interactions were done via REST API calls. + +Phase 2 will be mostly the same, except there will now be a physical card reader device. This device is actually just a keyboard that types 10 digits and then presses enter, which is what a common RFID card reader also might do. + +## Setup + +If the Automated Checkout services are still running from phase 1, the services can stay running. The only service that will be terminated and re-created is `ds-card-reader` (which will be done as part of this guide). + +Start by removing the `ds-card-reader` service. In order to do this, first identify the container's name using this command: + +```bash +docker ps | grep -i ds-card-reader +``` + +Use the output of that command to stop the container for `ds-card-reader` - replace `container_name_or_id_from_previous_command` with the output from above: + +```bash +docker rm -f container_name_or_id_from_previous_command +``` + +!!! note + If you encounter any issues with the `ds-card-reader` later in this guide, consider cleaning up all of the Automated Checkout services. The best way to guarantee a clean run through of this phase is to tear down any existing Automated Checkout environment and start from fresh. This can be accomplished by running the following steps. + + Navigate to the root of this repository - this can vary based on where you chose to clone the repository: + + ``` + cd + ``` + + Run the following commands to clean things up: + + ``` + make down && make clean-docker + ``` + + This will destroy any existing ledger entries, audit log entries, inventory changes, and EdgeX event readings and data associated with Automated Checkout. However, this will not alter any other non-Automated Checkout Docker images, containers, or volumes. The scope of the above command is limited to only Automated Checkout. + +## Plug in the card reader device + +The first step is to simply plug in the card reader device. This can be a regular USB keyboard or a dedicated RFID card reader, or any other HID keyboard-like input device that works with [`evdev`](https://en.wikipedia.org/wiki/Evdev) and can be identified via the Linux command `lsusb`. + +!!! note + If you are going to use a keyboard as a card reader device, we suggest plugging in a second keyboard for this purpose. + +Once it's plugged in, proceed to identify the device by running the command: + +```bash +lsusb +``` + +The output may look like this (this is the output from a virtual machine): + +``` +Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub +Bus 001 Device 003: ID ffff:0035 +Bus 001 Device 002: ID 80ee:0021 VirtualBox USB Tablet +Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub +``` + +The particular _vendor ID_ and _product ID_ are spelled out clearly for each USB device. The card reader input device itself has been plugged in and has the vendor ID `ffff` and the product ID `0035`. + +!!! note + The VID and PID values are hexadecimal, base 16. A value of `ffff` is equal to `65535` in decimal, base 10, and `0035` in base 16 is equal to `53` in base 10. The configuration files in the Automated Checkout reference design device services may require some conversion between the two. If needed, consider searching online for a hexadecimal to decimal conversion calculator to make the process easier. + +Once the VID and PID have been identified, the next step is to configure the `ds-card-reader` device service to grab that device and listen for input events. + +## Configure the `ds-card-reader` service to use the card reader device + +From the root of this repository, with the card reader device plugged in and its VID and PID identified, navigate to the `ds-card-reader/res/docker` directory: + +```bash +cd +``` + +Then, modify the `docker-compose.physical.card-reader.yml` file in your text editor of choice: + +```bash +nano docker-compose.physical.card-reader.yml +``` + +In this file, you'll see a section that looks like this: + +```yaml +ds-card-reader: + user: "0:0" + devices: + - /dev/input:/dev/input + environment: + Driver_SimulateDevice: "false" +``` + +We will be adding three environment variables to this service: + +* `DeviceSearchPath` - the path to search for `evdev` input devices +* `VID` - the base-10 value of the vendor ID associated with the input device +* `PID` - the base-10 value of the product ID associated with the input device + +First, verify that the default value of `DeviceSearchPath="/dev/input/event*"` corresponds to an actual path on your Linux system - the vast majority of Linux systems should automatically handle everything in this directory, but it helps to check. + +```bash +ls -al /dev/input/event +``` + +
    + (Click to Expand) Example Output + +

    +The output of ls -al /dev/input/event may look like this: +

    + +``` +crw-rw---- 1 root input 13, 64 Apr 9 09:10 /dev/input/event0 +crw-rw---- 1 root input 13, 65 Apr 9 09:10 /dev/input/event1 +crw-rw---- 1 root input 13, 66 Apr 9 09:10 /dev/input/event2 +crw-rw---- 1 root input 13, 67 Apr 9 09:10 /dev/input/event3 +crw-rw---- 1 root input 13, 68 Apr 9 09:10 /dev/input/event4 +crw-rw---- 1 root input 13, 69 Apr 9 09:10 /dev/input/event5 +crw-rw---- 1 root input 13, 70 Apr 9 09:10 /dev/input/event6 +crw-rw---- 1 root input 13, 71 Apr 9 09:58 /dev/input/event7 +``` + +

    +If you do not see input devices under this path, your Linux kernel or operating system may be configured differently. Consult your operating system's documentation for information regarding the behavior of input devices if possible. +

    + +
    + +The resulting section in the configuration file will look something like this: + +```yaml +ds-card-reader: + user: "0:0" + devices: + - /dev/input:/dev/input + environment: + Driver_SimulateDevice: "false" + Driver_DeviceSearchPath: "/dev/input/event*" + Driver_VID: "65535" + Driver_PID: "53" +``` + +## Run the Automated Checkout reference design + +Run the Automated Checkout reference design with the physical card reader component included: + +```bash +make run-physical-card-reader-dev +``` + +After about a minute or so, the card reader device service (ds-card-reader) will be configured to accept inputs from an external card reader device. Follow the steps outlined in [phase 1](./phase1.md#walkthrough-of-scenarios) again, **except** instead of performing REST API calls to simulate badge swipe events, replace them with a keyboard inputs that correspond to the same cards ID, press `enter`, and then continue forward with the REST API calls that simulate door open/closure events, temperature changes, etc. + +!!! note + You do not need to type the card ID number anywhere specifically. The card reader device service is configured in such a way that it will listen to any inputs from the keyboard at any time. + + The input device is globally grabbed using [evdev's `GrabDevice`](https://www.x.org/releases/X11R7.6/doc/man/man4/evdev.4.xhtml) mechanism, summarized here: + + > **GrabDevice**: ... Doing so will ensure that no other driver can initialise the same device and it will also stop the device from sending events to /dev/kbd or /dev/input/mice. Events from this device will not be sent to virtual devices (e.g. rfkill or the Macintosh mouse button emulation). + +For example, in [phase 1](./phase1.md#walkthrough-of-scenarios), the card number for the stocker role is `0003293374`. This card number can be simulated by typing the digits and pressing the enter key, if you're using a keyboard as your input device. + +## Dive deeper + +Now that the card reader is working with a physical device, it may be time to make some changes to the underlying authentication data to allow your own cards to authenticate. The following sections illustrate the steps needed in order to extend the Automated Checkout reference design to work with your cards. + +### Extending the card reader + +If the behavior of your particular card reader device's cards does not match the behavior that's been incorporated into this service, you'll need to get your hands dirty with the source code of the `ds-card-reader` device service. + +In the service, take a look at the file `ds-card-reader/device/physical.go`. This file contains this function: + +```go +func (reader *CardReaderPhysical) Listen() { + // ... + reader.processDevReadEvents(events) + // ... +} +``` + +`Listen` is a Go routine that loops and processes `evdev` events as they come in from the physical input device. Carefully inspect this section of code as well as the functions called within this Go routine in order to gain an understanding of how to change the behavior of the card reader device service. + +!!! warning + Changing the source code may break unit tests and other functionality across services. Ensure that the software development processes used to make code changes include updating unit and integration tests to work with new changes. + +### Adding new cards + +The `ms-authentication` microservice contains an index of all cards, accounts, and authorized individuals (people). To add a new card, person, or account, follow these steps. + +First, navigate to the `ms-authentication` directory in the root of the repository. These three `.json` files dictate the `ms-authentication` service's behavior: + +- [`people.json`](https://github.com/intel-iot-devkit/automated-checkout/blob/master/ms-authentication/people.json) +- [`accounts.json`](https://github.com/intel-iot-devkit/automated-checkout/blob/master/ms-authentication/accounts.json) +- [`cards.json`](https://github.com/intel-iot-devkit/automated-checkout/blob/master/ms-authentication/cards.json) + +In this case, we're only going to add a new card and associate it with the person with ID 1. A typical card will look like this: + +```json +{ + "cardId": "0003621892", + "roleId": 1, + "isValid": true, + "personId": 3, + "createdAt": "1560815799", + "updatedAt": "1560815799" +} +``` + +Let's add a new card to the `cards.json` file - replace `1234567899` with a 10-digit card that corresponds to one of your cards: + +```json +..., +{ + "cardId": "1234567899", + "roleId": 1, + "isValid": true, + "personId": 3, + "createdAt": "1560815799", + "updatedAt": "1560815799" +} +... +``` + +!!! info + The `createdAt` and `updatedAt` dates do not particularly matter, but should be kept as a Unix timestamp. + +Now that we've added the card to the `cards.json` file, the service's Docker image must be rebuilt. Navigate to the root of this repository, which should be up a single directory: + +```bash +cd .. +``` + +Then, use the `Makefile` to build the `ds-card-reader` image: + +```bash +make ds-card-reader +``` + +!!! info + At this time, the three `.json` files are built in to the Docker image for the `ms-authentication` service. They are not mounted at runtime. This is why image rebuilding is necessary. + +### Running the updated service + +If the Automated Checkout services are already running, the best way to update the running `ms-authentication` service is to remove the `ms-authentication` container and then re-run the command to bring up the whole stack. + +First, remove the `ms-authentication` container: + +```bash +docker ps -a | grep -i ms-authentication +``` + +Use the output of the last command to delete the `ms-authentication` container. Replace `container_name` in the below command with the name from the output from the above command to delete it: + +```bash +docker rm -f container_name +``` + +Then, bring up the services using the same command from before: + +```bash +make run-physical-card-reader-dev +``` + +!!! note + If this fails to properly update the image, it may be worth running + + ``` + make down + ``` + + And then re-running + + ``` + make run-physical-card-reader-dev + ``` + + If there are still issues, consider completely cleaning the Automated Checkout containers and volumes by running + + ``` + make down && make clean-docker + ``` + + And then running + + ``` + make run-physical-card-reader-dev + ``` + +The `ds-card-reader` service should be listening for input events. If your card reader device is a proper RFID USB card reader, swipe the card that corresponds to the card we added, or if it's a USB keyboard, type out the keys and press enter when done, and follow the steps in phase 1 while replacing card reader badge-in events with this method. + +!!! info + For more generalized information on modifying source code, please review the [Modifying source code](../modifying_source_code.md) page. + +## Summary + +The usage of a physical card reader device only requires a few changes from the simulated mode. In the `ds-card-reader` device service, the device's VID and PID are configured, the service's image gets rebuilt, and the service itself gets updated to use the new image. The device's interactions are captured by Go routines running in the device service itself, and EdgeX event readings are propagated throughout a handful of services to ensure a smooth Automated Checkout workflow. diff --git a/docs_src/phases/phase3.md b/docs_src/phases/phase3.md new file mode 100644 index 0000000..53c3b90 --- /dev/null +++ b/docs_src/phases/phase3.md @@ -0,0 +1,27 @@ +# Phase 3 - Bring Your Own Hardware and Software + +## Overview + +After [phase 2](../phases/phase2.md) has been completed, the next step is to integrate physical hardware. This guide will assist you in understanding the pieces of hardware that are needed in the Automated Checkout reference design. + +## Getting Started + +### Step 1: Arduino micro-controller board + +The first piece of hardware that will control the vast majority of functionality will be an Arduino micro-controller board with multiple sensors. + +Specifically, it handles the following integrations: + +| Module | Description | +| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------- | +| Door Sensor (open/close) | Instrumentation used to understand if the cooler door is open or closed and take appropriate action. | +| Maglock (lock/unlock) | Instrumentation is used to lock or unlock the automated checkout to allow for vending of a product. | +| LCD Display | Instrumentation is used for providing feedback to the person that is using the automated checkout. | +| LED Panel | Instrumentation is used to provide feedback to the developer as to the state of the board lock and door status. | +| Temperature/Humidity Sensor | Instrumentation is used to understand the physical environment inside the automated checkout and take appropriate action. | + +We have created a reference design service that will interact with the controller board and EdgeX core services [here](../automated-checkout-services/device_services.md#card-reader). + +### Step 2: Integrate your own computer vision inference hardware + +Next, in order to be able to provide computer vision capabilities to the Automated Checkout it is necessary to bring your own set of cameras and deep learning model. It is expected by the application services to receive an inventory delta using an MQTT broker. For development and testing purposes, we have created a mock inference device service that mimics what a real computer vision inference engine would do. Please see more details in the device services section [here](../automated-checkout-services/device_services.md#inference-mock). diff --git a/docs_src/references.md b/docs_src/references.md new file mode 100644 index 0000000..4d06e2c --- /dev/null +++ b/docs_src/references.md @@ -0,0 +1,30 @@ +# References + +## Application Services + +| Service Name | Service Abbreviated Name | Link | +|-------------------------|------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Controller Board Status | `as-controller-board-status` | [https://github.com/intel-iot-devkit/automated-checkout/blob/master/as-controller-board-status](https://github.com/intel-iot-devkit/automated-checkout/blob/master/as-controller-board-status) | +| Vending | `as-vending` | [https://github.com/intel-iot-devkit/automated-checkout/blob/master/as-vending](https://github.com/intel-iot-devkit/automated-checkout/blob/master/as-vending) | + +## Device Service + +| Service Name | Service Abbreviated Name | Link | +|------------------|--------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Card Reader | `ds-card-reader` | [https://github.com/intel-iot-devkit/automated-checkout/blob/master/ds-card-reader](https://github.com/intel-iot-devkit/automated-checkout/blob/master/ds-card-reader) | +| Controller Board | `ds-controller-board` | [https://github.com/intel-iot-devkit/automated-checkout/blob/master/ds-controller-board](https://github.com/intel-iot-devkit/automated-checkout/blob/master/ds-controller-board) | +| Inference Mock | `ds-inference-mock` | [https://github.com/intel-iot-devkit/automated-checkout/blob/master/ds-inference-mock](https://github.com/intel-iot-devkit/automated-checkout/blob/master/ds-inference-mock) | + +## Microservices (Business Logic Services) + +| Service Name | Service Abbreviated Name | Link | +|----------------|--------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Authentication | `ms-authentication` | [https://github.com/intel-iot-devkit/automated-checkout/blob/master/ms-authentication](https://github.com/intel-iot-devkit/automated-checkout/blob/master/ms-authentication) | +| Inventory | `ms-inventory` | [https://github.com/intel-iot-devkit/automated-checkout/blob/master/ms-inventory](https://github.com/intel-iot-devkit/automated-checkout/blob/master/ms-inventory) | +| Ledger | `ms-ledger` | [https://github.com/intel-iot-devkit/automated-checkout/blob/master/ms-ledger](https://github.com/intel-iot-devkit/automated-checkout/blob/master/ms-ledger) | + +## Other + +| Component | Link | +| --------------------- | -------------------------------------------------------------------- | +| EdgeX GitHub Repos | [https://github.com/edgexfoundry](https://github.com/edgexfoundry) | diff --git a/docs_src/search/search_index.json b/docs_src/search/search_index.json new file mode 100644 index 0000000..e69de29 diff --git a/docs_src/stylesheets/extra.css b/docs_src/stylesheets/extra.css new file mode 100644 index 0000000..e69de29 diff --git a/docs_src/troubleshooting.md b/docs_src/troubleshooting.md new file mode 100644 index 0000000..a9edb56 --- /dev/null +++ b/docs_src/troubleshooting.md @@ -0,0 +1,65 @@ +# Troubleshooting + +The following guide will help walk you through the flow of data to address potential issues as they occur. This guide does not comprehensively cover all possible troubleshooting scenarios. It provides guidance on how to leverage a few essential tools to augment all troubleshooting efforts in general. + +## Ensuring your Device Services receive data + +All sensor data that is ingested in Automated Checkout flows through a device service as the first step. These device services are the first place we should check to ensure they are both running and ingesting data. One of the best ways to do to this is to leverage Portainer (included in EdgeX Releases). + +!!!info + *Portainer is a tool to help manage Docker containers. To learn more visit: [https://www.portainer.io/overview/](https://www.portainer.io/overview/)* + +We have 3 device services of note in Automated Checkout: + +- Controller board – Handles the interface between Arduino firmware and EdgeX. +- Card reader – Handles the interface between an RFID card reader and EdgeX. +- Inference mock – Mock that mimics an actual computer vision inference. + +We can type "ds" in the search bar on the Portainer web portal ([127.0.0.1:9000](http://127.0.0.1:9000)) and see all the device service containers that are in our stack (see image below). We can also see their current state which indicates if they are running or not. If a service is not running, or is in a "stopped" state, then this is likely the cause of data not flowing through. + +![Portainer Device Services](./images/portainer-device-services.png) + +However, if the state is "running", we can dig a little deeper by viewing the logs. Though, before we dig into the logs, it is important to call out that we will want to ensure that the logging level is set to "TRACE" for each service we intend to inspect. + +This can be accomplished by doing the following: + +* Navigate to Consul in a browser, which is located at [http://localhost:8500](http://localhost:8500/). +* Click `Key/Value` at the top navbar. +* Click `edgex` in the list. +* Depending on which service you want to inspect, choose either `devices`, `appservices`, or `core`. + * For a device service, this would be `devices`. + * For all application services, this would be `appservices`. + * For all EdgeX core services, this would be `core`. +* Click `1.0`. +* Click on the service that you're interested in changing. +* Click `Writable`. +* Click `LogLevel`. +* Set the value in the text box to `TRACE`, it likely is set to `INFO` by default. +* Click the "Save" button. + +After following the above steps, proceed to view the logs for the service, and observe that `level=TRACE` logs begin to appear. + +![Portainer Device Logs](./images/portainer-device-logs.png) + +## Ensuring EdgeX Core Services have received Data + +After ensuring that data is flowing properly to the device services, the next place to check would be EdgeX’s *"core data"* service. You can follow the same steps as above to see if data is flowing and check the logs. However, using a tool such as Robo 3T or Mongo Compass to inspect the database is the best way to ensure data has been properly processed by EdgeX's Core Data. + +!!!info + *Robo 3T is a tool to manage mongodb databases: [https://robomongo.org/](https://robomongo.org/)* + +![MongoDB contents](./images/MongoDB-contents.png) + +You’ll find the events in the **"coredata"** database under the **"event"** collection and more importantly the reading values under the **"reading"** collection. If you sort by *"created"* in descending order and filter for the specific device that is giving you trouble, it can help to narrow down the data you are looking for. It is also a good idea to check and make sure all the device names and values are what you expect them to be. It is often the case that a device-name or reading-name may not match what it is intended and this could cause issues in your app service. + +## Checking the Controller Board Status (App Service) + +After ensuring data has made it to the database, the next place to check is the Controller Board Status App Service (`as-controller-board-status`). Similar to what we did in Step 1, let’s check Portainer for the status of this container to ensure it is running and lets also take a look at the logs. After ensuring the logging level is set to ‘TRACE’, we should see something akin to the following: + +![Portainer as-controller-board-status](./images/as-controller-board-status.png) + +In the unlikely event that no data is flowing at all to the Controller Board status App Service, this would lead us to an issue with the ZMQ connection from the App Service to Core Data. Double checking the TOML file configuration where the hostname, port, and topic are specified would be a good place to start. You should also check that the App Service is on the same docker network and is accessible via the network. + +Once connectivity issues have been resolved, the next step is to ensure that all filters (i.e. device names) are correct and match what is shown in the database from the previous step. If they do not match, then they will be filtered out and not be processed. One easy way to confirm that data is flowing is to remove filters entirely from the pipeline to see that there is data flowing. + +For further troubleshooting, visit the EdgeX documentation. diff --git a/ds-card-reader/.gitignore b/ds-card-reader/.gitignore new file mode 100644 index 0000000..9f22e3d --- /dev/null +++ b/ds-card-reader/.gitignore @@ -0,0 +1,24 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, build with `go test -c` +*.test +main +device-card-reader + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out +go.sum + +# files created in test cases +driver/target +device/target + +*/*.log +*.log + +.vscode diff --git a/ds-card-reader/.golangci.yml b/ds-card-reader/.golangci.yml new file mode 100644 index 0000000..00ec54e --- /dev/null +++ b/ds-card-reader/.golangci.yml @@ -0,0 +1,28 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +run: + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 5m +linters-settings: + misspell: + locale: US +linters: + enable: + - bodyclose + - errcheck + - goconst + - golint + - govet + - gosimple + - ineffassign + - misspell + - staticcheck + - structcheck + - typecheck + - unused + - unconvert + - unparam + - varcheck + disable-all: true + fast: true diff --git a/ds-card-reader/Dockerfile b/ds-card-reader/Dockerfile new file mode 100644 index 0000000..19734bb --- /dev/null +++ b/ds-card-reader/Dockerfile @@ -0,0 +1,26 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +FROM automated-checkout/build:latest AS builder + +LABEL license='SPDX-License-Identifier: BSD-3-Clause' \ + copyright='Copyright (c) 2020: Intel' + +RUN mkdir ds-card-reader +WORKDIR /usr/local/bin/ds-card-reader/ +COPY . . + +# Compile the code +RUN make gobuild + +# Next image - Copy built Go binary into new workspace +FROM alpine + +LABEL license='SPDX-License-Identifier: BSD-3-Clause' \ + copyright='Copyright (c) 2020: Intel' + +COPY --from=builder /usr/local/bin/ds-card-reader/res/ds-card-reader.yaml /res/ds-card-reader.yaml +COPY --from=builder /usr/local/bin/ds-card-reader/res/docker/configuration.toml /res/docker/configuration.toml +COPY --from=builder /usr/local/bin/ds-card-reader/main /ds-card-reader + +CMD [ "/ds-card-reader","--profile=docker","--confdir=/res", "-r", "consul://edgex-core-consul:8500"] diff --git a/ds-card-reader/LICENSE b/ds-card-reader/LICENSE new file mode 100644 index 0000000..dbff156 --- /dev/null +++ b/ds-card-reader/LICENSE @@ -0,0 +1,31 @@ +BSD 3-Clause License + +Copyright © 2020, Intel Corporation +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/ds-card-reader/Makefile b/ds-card-reader/Makefile new file mode 100644 index 0000000..577f7ef --- /dev/null +++ b/ds-card-reader/Makefile @@ -0,0 +1,80 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +.PHONY: build gobuild run gorun stop test lint + +MICROSERVICE=automated-checkout/ds-card-reader + +build: + docker build --rm \ + --build-arg http_proxy \ + --build-arg https_proxy \ + -f Dockerfile \ + -t $(MICROSERVICE):dev \ + . + +gobuild: + CGO_ENABLED=1 GOOS=linux go build -ldflags='-s -w' -a -installsuffix cgo main.go + +run: + docker run \ + --rm \ + -p 48098:48098 \ + $(MICROSERVICE):dev + +gorun: + ./main + +stop: + docker rm -f $(MICROSERVICE):dev + +test: + go test -test.v \ + -cover \ + ./... + +testHTML: + go test \ + -test.v \ + -coverprofile=test_coverage.out \ + ./... && \ + go tool cover -html=test_coverage.out + +testPhysical: + sudo -E go test -test.v \ + -cover \ + -tags=physical \ + ./... + +testPhysicalHTML: + sudo -E go test \ + -tags=physical \ + -test.v \ + -coverprofile=test_coverage_physical.out \ + ./... && \ + go tool cover -html=test_coverage_physical.out + +testAll: + sudo -E go test \ + -test.v \ + -cover \ + -tags=all \ + ./... + +testAllHTML: + sudo -E go test \ + -tags=all \ + -test.v \ + -coverprofile=test_coverage_all.out \ + ./... && \ + go tool cover \ + -html=test_coverage_all.out + +GOLANGCI_VERSION := $(shell golangci-lint --version 2>/dev/null) + +lint: +ifdef GOLANGCI_VERSION + golangci-lint run +else + @echo "golangci-lint not found. Please refer to the README documentation for proper installation" +endif diff --git a/ds-card-reader/common/common.go b/ds-card-reader/common/common.go new file mode 100644 index 0000000..707e4d3 --- /dev/null +++ b/ds-card-reader/common/common.go @@ -0,0 +1,22 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package common + +// CardReaderConfig holds the configurable options for a automated checkout +// card reader device +type CardReaderConfig struct { + DeviceName string + DeviceSearchPath string + VID uint16 + PID uint16 + SimulateDevice bool +} + +// CommandCardReaderStatus is the string value of the command that will be +// sent to the card reader driver that performs a health check of the underlying +// device +const ( + CommandCardReaderStatus = "card-reader-status" + CommandCardReaderEvent = "card-reader-event" +) diff --git a/ds-card-reader/device/device.go b/ds-card-reader/device/device.go new file mode 100644 index 0000000..0c9e492 --- /dev/null +++ b/ds-card-reader/device/device.go @@ -0,0 +1,67 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package device + +import ( + "fmt" + + dsModels "github.com/edgexfoundry/device-sdk-go/pkg/models" + "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" +) + +// CardReader is an abstraction that allows for operations to be performed on +// either a virtual or physical card reader, without explicitly passing around +// a virtual or physical card reader struct +type CardReader interface { + Write(string, string) + Status() error + Listen() + Release() error +} + +// InitializeCardReader gets called by the EdgeX entry point, Initialize(), and +// is responsible for spawning Go routines that await & handle incoming events +// +// simulateDevice dictates whether the device is a physical or virtual card +// reader +// +// mockDevice is used for tests, and dictates whether or not the Listen +// loop goes forever. This should be false unless running unit tests +func InitializeCardReader(lc logger.LoggingClient, asyncCh chan<- *dsModels.AsyncValues, deviceSearchPath string, deviceName string, vid uint16, pid uint16, simulateDevice bool, mockDevice bool) (cardReader CardReader, err error) { + // check if we are configured to only simulate a physical card reader + // device, or if we are allowed to use an actual physical card reader device + if !simulateDevice { + dev, err := GrabCardReader(deviceSearchPath, vid, pid) + if err != nil { + return cardReader, fmt.Errorf("failed to grab card reader under search path %v with VID %v and PID %v: %v", deviceSearchPath, vid, pid, err) + } + + // initialize the physical card reader device + cardReader = &CardReaderPhysical{ + AsyncCh: asyncCh, + CardNumber: "", + Device: dev, + DeviceName: deviceName, + LoggingClient: lc, + VID: vid, + PID: pid, + DeviceSearchPath: deviceSearchPath, + StableDevice: true, + } + + if !mockDevice { + // spawn a go routine to handle events from the raw device + go cardReader.Listen() + } + } else { + // initialize the virtual card reader device + cardReader = &CardReaderVirtual{ + AsyncCh: asyncCh, + DeviceName: deviceName, + LoggingClient: lc, + } + } + + return cardReader, nil +} diff --git a/ds-card-reader/device/physical.go b/ds-card-reader/device/physical.go new file mode 100644 index 0000000..65d432f --- /dev/null +++ b/ds-card-reader/device/physical.go @@ -0,0 +1,235 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package device + +import ( + "fmt" + "time" + + common "ds-card-reader/common" + dsModels "github.com/edgexfoundry/device-sdk-go/pkg/models" + logger "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + evdev "github.com/gvalkov/golang-evdev" +) + +// CardReaderPhysical follows some EdgeX standards for implementing a device +// that creates events & readings in an EdgeX device service. +type CardReaderPhysical struct { + AsyncCh chan<- *dsModels.AsyncValues + Device *evdev.InputDevice + DeviceName string + DeviceSearchPath string + LoggingClient logger.LoggingClient + PID uint16 + VID uint16 + CardNumber string + Mocked bool // used for unit testing + StableDevice bool +} + +// Listen is called by the EdgeX driver for this device service, it listens +// for raw input from the device itself and facilitates relaying the data +// back up to EdgeX. It is intended to be called as a Go routine. +// This function is not feasibly unit tested because it relies on a live +// feed of events from an input device. It is best to perform integration +// tests instead, by simply unplugging & plugging in the device +// and observing graceful handling +func (reader *CardReaderPhysical) Listen() { + for { + if reader.StableDevice { + // warning: the below line will panic if the device is not first + // initialized. However, this function should never be reached if + // that is the case, because the initialization sequence is done + // upon startup + events, err := reader.Device.Read() + if err != nil { + reader.LoggingClient.Error(fmt.Sprintf("device read event error: %v", err.Error())) + reader.StableDevice = false + continue + } + reader.processDevReadEvents(events) + } else { + // needed because go syntax will not allow := below + var err error + + reader.Device, err = GrabCardReader(reader.DeviceSearchPath, reader.VID, reader.PID) + if err != nil { + reader.LoggingClient.Error(fmt.Sprintf("failed to re-grab card reader device, retry in 3s: %v", err.Error())) + time.Sleep(3 * time.Second) + continue + } + + reader.LoggingClient.Info(fmt.Sprintf("successfully re-grabbed device")) + reader.StableDevice = true + } + } +} + +// Status is called frequently by the driver (as an auto-event) to check the +// "grab" state of the card reader device +func (reader *CardReaderPhysical) Status() error { + // if the ReadValues thread is working properly, the GrabCardReader + // function should actually fail, hence why err == nil is checked + _, err := GrabCardReader(reader.DeviceSearchPath, reader.VID, reader.PID) + if err == nil { + errMsg := fmt.Sprintf("failure: physical card reader is not locked") + reader.LoggingClient.Error(errMsg) + return fmt.Errorf(errMsg) + } + + return nil +} + +// Write grants the physical card reader device the ability to respond to +// EdgeX commands to create a card reader "badge-in" event, and push the event +// through the EdgeX framework. Both the physical and virtual card reader +// have this code, and as a result, they both can respond to REST API calls +// to "badge-in", but only the physical card reader is listening for input +// events from a real device +func (reader *CardReaderPhysical) Write(commandName string, cardNumber string) { + // assemble the values that will be propagated throughout the + // device service + result := []*dsModels.CommandValue{ + dsModels.NewStringValue( + commandName, + time.Now().UnixNano()/int64(time.Millisecond), + cardNumber, + ), + } + + asyncValues := &dsModels.AsyncValues{ + DeviceName: reader.DeviceName, + CommandValues: result, + } + + // push the async value to the async channel, causing an event + // to be created within EdgeX, which will go to the central + // as-vending service for processing + // Note: this will loop indefinitely in unit testing, so we have to respect + // a mocked environment + if !reader.Mocked { + reader.AsyncCh <- asyncValues + } + + // reset the card number after pushing to the async channel + reader.CardNumber = "" + + reader.LoggingClient.Info(fmt.Sprintf("received event with card number %v", cardNumber)) +} + +// processDevReadEvents handles an incoming evdev device event and pushes it +// into the EdgeX framework +func (reader *CardReaderPhysical) processDevReadEvents(events []evdev.InputEvent) { + for i := range events { + // process the input event from the evdev device + keyValue, err := GetKeyValueFromEvent(&events[i]) + if err != nil { + continue + } + + // check if the key that was pressed is the enter key + if keyValue != evdev.KEY_ENTER { + reader.CardNumber = reader.CardNumber + fmt.Sprintf("%v", keyValue) + continue + } + + reader.Write(common.CommandCardReaderEvent, reader.CardNumber) + } +} + +// GetKeyValueFromEvent is responsible for handling key stroke events +// from the physical card reader and ensuring that only a digit/keystroke we +// care about is returned (note that it does not necessarily return the +// corresponding evdev key code value) +// +// for reference, please visit: +// https://github.com/gvalkov/golang-evdev/blob/master/ecodes.go +func GetKeyValueFromEvent(ev *evdev.InputEvent) (result int, err error) { + // check if the event type is a key stroke + if ev.Type == evdev.EV_KEY && ev.Value == int32(evdev.KeyDown) { + switch ev.Code { + case evdev.KEY_1: + return 1, nil + case evdev.KEY_2: + return 2, nil + case evdev.KEY_3: + return 3, nil + case evdev.KEY_4: + return 4, nil + case evdev.KEY_5: + return 5, nil + case evdev.KEY_6: + return 6, nil + case evdev.KEY_7: + return 7, nil + case evdev.KEY_8: + return 8, nil + case evdev.KEY_9: + return 9, nil + case evdev.KEY_0: + return 0, nil + case evdev.KEY_ENTER: + return int(evdev.KEY_ENTER), nil + default: + return result, fmt.Errorf("received an undesired or unexpected key code: %v", ev.Code) + } + } + + return result, fmt.Errorf("event created by the physical card reader was not a key press event") +} + +// findInputDevice returns the path of an input device under a given +// (bash globstar) path, with a corresponding vendor ID and product ID +// +// the Linux command "lsusb" can help identify VID and PID values +func findInputDevice(path string, VID uint16, PID uint16) (string, error) { + // get a list of input devices by scanning + devices, _ := evdev.ListInputDevices(path) + + // see if the card reader shows up in the list of devices in evdev + for _, dev := range devices { + if dev.Product == PID && dev.Vendor == VID { + // return the file path of the found input device + return dev.Fn, nil + } + } + + return "", fmt.Errorf("failed to find card reader under path \"%v\" with VID %v and PID %v", path, VID, PID) +} + +// GrabCardReader attempts to grab the physical card reader device. +// Any time the device hold is lost, it will simply type badge numbers to the +// focused window (it basically behaves like a regular keyboard). +// Depending on circumstances, it may be necessary to run dev.Release() after +// +// The searchPath parameter is a bash globstar expression that will be passed +// to evdev so that it knows where to look for the input device that represents +// the card reader. +func GrabCardReader(searchPath string, VID uint16, PID uint16) (dev *evdev.InputDevice, err error) { + // attempt to find the reader in the given search path + deviceFilePath, err := findInputDevice(searchPath, VID, PID) + if err != nil { + return dev, fmt.Errorf("unable to find the card reader: %w", err) + } + + // attempt to open the card reader device, should succeed if it exists + dev, err = evdev.Open(deviceFilePath) + if err != nil { + return dev, fmt.Errorf("unable to open the card reader: %w", err) + } + + // attempting to grab device should fail in normal conditions, because it + // should already be locked from another go routine (ReadValues function) + err = dev.Grab() + if err != nil { + return dev, fmt.Errorf("failed to grab the card reader device: %w", err) + } + + return dev, nil +} + +// Release attempts to release the grab on the device +func (reader *CardReaderPhysical) Release() error { + return reader.Device.Release() +} diff --git a/ds-card-reader/device/physical_test.go b/ds-card-reader/device/physical_test.go new file mode 100644 index 0000000..1531acb --- /dev/null +++ b/ds-card-reader/device/physical_test.go @@ -0,0 +1,440 @@ +// +build all physical + +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package device + +import ( + "bufio" + "fmt" + "io/ioutil" + "os" + "strings" + "testing" + + dsModels "github.com/edgexfoundry/device-sdk-go/pkg/models" + "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + evdev "github.com/gvalkov/golang-evdev" + assert "github.com/stretchr/testify/assert" + require "github.com/stretchr/testify/require" +) + +const ( + physicalLogFile = "physical_test.log" + physicalCardReaderDeviceServiceName = "ds-card-reader" + physicalDeviceSearchPath = "/dev/input/event*" + physicalInvalidDeviceSearchPath = "/dev/input/invalid-device*" + physicalDeviceName = "ds-card-reader" + physicalVID = uint16(0xFFFF) + physicalPID = uint16(0x0035) + expectedCardNumberPhysical = "0123456789" +) + +func clearLogs() error { + return ioutil.WriteFile(physicalLogFile, []byte{}, 0644) +} + +func doesLogFileContainString(input string) (bool, error) { + // attempt to open the log file + file, err := os.Open(physicalLogFile) + if err != nil { + return false, err + } + + // defer closing the file open buffer + defer file.Close() + + scanner := bufio.NewScanner(file) + + // iterate over every line in the log file + for scanner.Scan() { + line := scanner.Text() + if strings.Contains(line, input) { + return true, nil + } + } + + // check for residual errors in the scanner + err = scanner.Err() + if err != nil { + return false, err + } + + return false, nil +} + +// TestInitializeCardReader validates that the InitializeCardReader +// and the physical functions work as expected for a physical card reader +func TestInitializeCardReader(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + require := require.New(t) + + // create a few essential variables for facilitating tests + lc := logger.NewClient(physicalCardReaderDeviceServiceName, false, physicalLogFile, "DEBUG") + expectedAsyncCh := make(chan<- *dsModels.AsyncValues, 16) + var notExpectedCardReader CardReader + + // run the function + cardReader, err := InitializeCardReader( + lc, + expectedAsyncCh, + physicalDeviceSearchPath, + physicalDeviceName, + physicalVID, + physicalPID, + false, + true, + ) + + // perform assertions + require.NoError(err) + assert.NotEqual(notExpectedCardReader, cardReader) + + // release the device so that other testing routines can use it + err = cardReader.Release() + require.NoError(err) +} + +// TestGrabCardReader validates that the GrabCardReader function handles +// acquiring (or failing to acquire) a lock on the input event device +func TestGrabCardReader(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + + // build tests + tests := []struct { + Name string + VID uint16 + PID uint16 + searchPath string + expectedErrMsg string + }{ + { + "failure to find card reader in search path", + physicalVID, + physicalPID, + physicalInvalidDeviceSearchPath, + "unable to find the card reader:", + }, + { + "failure to find card by VID/PID", + uint16(0xABCD), + uint16(0xABCD), + physicalDeviceSearchPath, + "unable to find the card reader:", + }, + { + "successfully grabbed card reader", + physicalVID, + physicalPID, + physicalDeviceSearchPath, + "", + }, + } + + for _, test := range tests { + t.Run(test.Name, func(t *testing.T) { + dev, err := GrabCardReader(test.searchPath, test.VID, test.PID) + if err == nil { + assert.Empty(test.expectedErrMsg) + + assert.Equal(test.VID, dev.Vendor) + assert.Equal(test.PID, dev.Product) + + require.NoError(t, dev.Release()) + } else { + assert.Contains(err.Error(), test.expectedErrMsg) + } + }) + } +} + +// TestGetKeyValueFromEvent validates that the GetKeyValueFromEvent function +// parses the data from an evdev input event and returns a key value according +// to what is required for this service to operate +func TestGetKeyValueFromEvent(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + require := require.New(t) + + // construct the test cases + tests := []struct { + Name string + InputEvent *evdev.InputEvent + ExpectedValue int + ExpectedError error + }{ + { + Name: "key down 1", + InputEvent: &evdev.InputEvent{ + Code: evdev.KEY_1, + Type: evdev.EV_KEY, + Value: int32(evdev.KeyDown), + }, + ExpectedValue: 1, + ExpectedError: nil, + }, + { + Name: "key down 2", + InputEvent: &evdev.InputEvent{ + Code: evdev.KEY_2, + Type: evdev.EV_KEY, + Value: int32(evdev.KeyDown), + }, + ExpectedValue: 2, + ExpectedError: nil, + }, + { + Name: "key down 3", + InputEvent: &evdev.InputEvent{ + Code: evdev.KEY_3, + Type: evdev.EV_KEY, + Value: int32(evdev.KeyDown), + }, + ExpectedValue: 3, + ExpectedError: nil, + }, + { + Name: "key down 4", + InputEvent: &evdev.InputEvent{ + Code: evdev.KEY_4, + Type: evdev.EV_KEY, + Value: int32(evdev.KeyDown), + }, + ExpectedValue: 4, + ExpectedError: nil, + }, + { + Name: "key down 5", + InputEvent: &evdev.InputEvent{ + Code: evdev.KEY_5, + Type: evdev.EV_KEY, + Value: int32(evdev.KeyDown), + }, + ExpectedValue: 5, + ExpectedError: nil, + }, + { + Name: "key down 6", + InputEvent: &evdev.InputEvent{ + Code: evdev.KEY_6, + Type: evdev.EV_KEY, + Value: int32(evdev.KeyDown), + }, + ExpectedValue: 6, + ExpectedError: nil, + }, + { + Name: "key down 7", + InputEvent: &evdev.InputEvent{ + Code: evdev.KEY_7, + Type: evdev.EV_KEY, + Value: int32(evdev.KeyDown), + }, + ExpectedValue: 7, + ExpectedError: nil, + }, + { + Name: "key down 8", + InputEvent: &evdev.InputEvent{ + Code: evdev.KEY_8, + Type: evdev.EV_KEY, + Value: int32(evdev.KeyDown), + }, + ExpectedValue: 8, + ExpectedError: nil, + }, + { + Name: "key down 9", + InputEvent: &evdev.InputEvent{ + Code: evdev.KEY_9, + Type: evdev.EV_KEY, + Value: int32(evdev.KeyDown), + }, + ExpectedValue: 9, + ExpectedError: nil, + }, + { + Name: "key down 0", + InputEvent: &evdev.InputEvent{ + Code: evdev.KEY_0, + Type: evdev.EV_KEY, + Value: int32(evdev.KeyDown), + }, + ExpectedValue: 0, + ExpectedError: nil, + }, + { + Name: "key down ENTER", + InputEvent: &evdev.InputEvent{ + Code: evdev.KEY_ENTER, + Type: evdev.EV_KEY, + Value: int32(evdev.KeyDown), + }, + ExpectedValue: int(evdev.KEY_ENTER), + ExpectedError: nil, + }, + { + Name: "error key up 1", + InputEvent: &evdev.InputEvent{ + Code: evdev.KEY_1, + Type: evdev.EV_KEY, + Value: int32(evdev.KeyUp), + }, + ExpectedError: fmt.Errorf("event created by the physical card reader was not a key press event"), + }, + { + Name: "error key down on an evdev event type that is not intended to be handled (EV_LED)", + InputEvent: &evdev.InputEvent{ + Code: evdev.KEY_A, + Type: evdev.EV_LED, + Value: int32(evdev.KeyDown), + }, + ExpectedError: fmt.Errorf("event created by the physical card reader was not a key press event"), + }, + { + Name: "error key down on a key that is not intended to be handled (A)", + InputEvent: &evdev.InputEvent{ + Code: evdev.KEY_A, + Type: evdev.EV_KEY, + Value: int32(evdev.KeyDown), + }, + ExpectedError: fmt.Errorf("received an undesired or unexpected key code: %v", evdev.KEY_A), + }, + } + + // iterate over test cases and run each test + for _, test := range tests { + // run individual tests + t.Run(test.Name, func(t *testing.T) { + // run the function in question + actualExpectedValue, actualExpectedError := GetKeyValueFromEvent(test.InputEvent) + // perform assertions + require.Equal(test.ExpectedError, actualExpectedError) + assert.Equal(test.ExpectedValue, actualExpectedValue) + }) + } +} + +// TestStatus is very similar to the GrabCardReader functionality, except +// the logic is reversed. A successful grab of the input device means that +// the device is not grabbed by our service, so an error is returned +func TestStatus(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + + lc := logger.NewClient(physicalCardReaderDeviceServiceName, false, physicalLogFile, "DEBUG") + + // build tests + tests := []struct { + Name string + reader *CardReaderPhysical + expectedErrMsg string + }{ + { + "Status successfully grab physical card reader", + &CardReaderPhysical{ + DeviceSearchPath: physicalDeviceSearchPath, + VID: physicalVID, + PID: physicalPID, + LoggingClient: lc, + }, + "failure: physical card reader is not locked", + }, + { + "Status unsuccessfully grab card reader", + &CardReaderPhysical{ + DeviceSearchPath: physicalInvalidDeviceSearchPath, + VID: physicalVID, + PID: physicalPID, + LoggingClient: lc, + }, + "", + }, + } + + for _, test := range tests { + t.Run(test.Name, func(t *testing.T) { + err := test.reader.Status() + if err == nil { + assert.Empty(test.expectedErrMsg) + } else { + assert.Contains(err.Error(), test.expectedErrMsg) + } + }) + } +} + +// TestProcessDevReadEvents tests that the processDevReadEvents function +// properly handles input events +func TestProcessDevReadEvents(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + require := require.New(t) + + lc := logger.NewClient(physicalCardReaderDeviceServiceName, false, physicalLogFile, "DEBUG") + + tests := []struct { + Name string + InputEvents []evdev.InputEvent + InputCardReaderPhysical *CardReaderPhysical + ExpectedCardReaderCardNumber string + ExpectedLogLines []string + }{ + { + Name: "successful test", + InputEvents: []evdev.InputEvent{ + {Code: evdev.KEY_0, Type: evdev.EV_KEY, Value: int32(evdev.KeyDown)}, + {Code: evdev.KEY_A, Type: evdev.EV_KEY, Value: int32(evdev.KeyDown)}, + {Code: evdev.KEY_1, Type: evdev.EV_KEY, Value: int32(evdev.KeyDown)}, + {Code: evdev.KEY_2, Type: evdev.EV_KEY, Value: int32(evdev.KeyDown)}, + {Code: evdev.KEY_3, Type: evdev.EV_KEY, Value: int32(evdev.KeyDown)}, + {Code: evdev.KEY_4, Type: evdev.EV_KEY, Value: int32(evdev.KeyDown)}, + {Code: evdev.KEY_5, Type: evdev.EV_KEY, Value: int32(evdev.KeyDown)}, + {Code: evdev.KEY_6, Type: evdev.EV_KEY, Value: int32(evdev.KeyDown)}, + {Code: evdev.KEY_7, Type: evdev.EV_KEY, Value: int32(evdev.KeyDown)}, + {Code: evdev.KEY_8, Type: evdev.EV_KEY, Value: int32(evdev.KeyDown)}, + {Code: evdev.KEY_9, Type: evdev.EV_KEY, Value: int32(evdev.KeyDown)}, + {Code: evdev.KEY_ENTER, Type: evdev.EV_KEY, Value: int32(evdev.KeyDown)}, + }, + InputCardReaderPhysical: &CardReaderPhysical{ + DeviceName: physicalDeviceName, + LoggingClient: lc, + Mocked: true, + CardNumber: "", + }, + ExpectedCardReaderCardNumber: "", // card number gets cleared + ExpectedLogLines: []string{ + fmt.Sprintf("received event with card number %v", expectedCardNumberPhysical), + }, + }, + } + + // run the tests + for _, test := range tests { + t.Run(test.Name, func(t *testing.T) { + // clear the log file + err := clearLogs() + require.NoError(err) + + // run the function in question + test.InputCardReaderPhysical.processDevReadEvents(test.InputEvents) + + // perform assertions + assert.Equal(test.ExpectedCardReaderCardNumber, test.InputCardReaderPhysical.CardNumber) + + // check if the expected log output is in the log file + for _, str := range test.ExpectedLogLines { + result, err := doesLogFileContainString(str) + require.NoError(err) + assert.True(result) + } + }) + } + + // clear the logs as a last step + err := clearLogs() + require.NoError(err) +} diff --git a/ds-card-reader/device/virtual.go b/ds-card-reader/device/virtual.go new file mode 100644 index 0000000..5f89c36 --- /dev/null +++ b/ds-card-reader/device/virtual.go @@ -0,0 +1,67 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package device + +import ( + "fmt" + "time" + + dsModels "github.com/edgexfoundry/device-sdk-go/pkg/models" + logger "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" +) + +// CardReaderVirtual allows for the emulation of a physical card reader device +type CardReaderVirtual struct { + AsyncCh chan<- *dsModels.AsyncValues + DeviceName string + LoggingClient logger.LoggingClient + MockFailStatusCheck bool // mocks an error message on status() +} + +// Write grants the virtual card reader device the ability to respond to +// EdgeX commands to create a card reader "badge-in" event, and push the event +// through the EdgeX framework +func (reader *CardReaderVirtual) Write(commandName string, cardNumber string) { + // assemble the values that will be propagated throughout the + // device service + result := []*dsModels.CommandValue{ + dsModels.NewStringValue( + commandName, + time.Now().UnixNano()/int64(time.Millisecond), + cardNumber, + ), + } + + asyncValues := &dsModels.AsyncValues{ + DeviceName: reader.DeviceName, + CommandValues: result, + } + + // push the async value to the async channel, causing an event + // to be created within EdgeX, which will go to the central + // as-vending service for processing + reader.AsyncCh <- asyncValues + + reader.LoggingClient.Info(fmt.Sprintf("received event with card number %v", cardNumber)) +} + +// Status is a health check function that alays returns true for the virtual +// card reader +func (reader *CardReaderVirtual) Status() error { + if reader.MockFailStatusCheck { + return fmt.Errorf("status check failed") + } + return nil +} + +// Listen is a function that is only needed for the physical card reader, +// but has to be implemented +func (reader *CardReaderVirtual) Listen() { +} + +// Release is a function that is only needed for the physical card reader, +// but has to be implemented +func (reader *CardReaderVirtual) Release() error { + return nil +} diff --git a/ds-card-reader/device/virtual_test.go b/ds-card-reader/device/virtual_test.go new file mode 100644 index 0000000..18f0986 --- /dev/null +++ b/ds-card-reader/device/virtual_test.go @@ -0,0 +1,180 @@ +// +build all !physical + +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package device + +import ( + "bufio" + "fmt" + "io/ioutil" + "os" + "strings" + "testing" + + "ds-card-reader/common" + dsModels "github.com/edgexfoundry/device-sdk-go/pkg/models" + logger "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + assert "github.com/stretchr/testify/assert" + require "github.com/stretchr/testify/require" +) + +const ( + virtualLogFile = "virtual_test.log" + virtualCardReaderDeviceServiceName = "ds-card-reader" + virtualDeviceSearchPath = "" + virtualDeviceName = "ds-card-reader" + virtualVID = uint16(0x0000) + virtualPID = uint16(0x0000) + expectedCardNumberVirtual = "0123456789" +) + +func clearVirtualLogs() error { + return ioutil.WriteFile(virtualLogFile, []byte{}, 0644) +} + +func doesVirtualLogFileContainString(input string) (bool, error) { + // attempt to open the log file + file, err := os.Open(virtualLogFile) + if err != nil { + return false, err + } + + // defer closing the file open buffer + defer file.Close() + + scanner := bufio.NewScanner(file) + + // iterate over every line in the log file + for scanner.Scan() { + line := scanner.Text() + if strings.Contains(line, input) { + return true, nil + } + } + + // check for residual errors in the scanner + err = scanner.Err() + if err != nil { + return false, err + } + + return false, nil +} + +// TestVirtualCardReader validates that the InitializeCardReader +// and the virtual functions work as expected for a virtual card reader +func TestVirtualCardReader(t *testing.T) { + + // prepare a few needed interfaces for use in tests + lc := logger.NewClient(virtualCardReaderDeviceServiceName, false, virtualLogFile, "DEBUG") + expectedAsyncCh := make(chan<- *dsModels.AsyncValues, 16) + + // we will expect the result of our tests to have a CardReader interface + // that does not equal an uninitialized CardReader interface, hence + // why it is "unexpected" - it is _not_ the expected value in our test + var unexpectedCardReader CardReader + + // run the function + cardReader, err := InitializeCardReader( + lc, + expectedAsyncCh, + virtualDeviceSearchPath, + virtualDeviceName, + virtualVID, + virtualPID, + true, + true, + ) + + // perform assertions + require.NoError(t, err) + assert.NotEqual(t, unexpectedCardReader, cardReader) +} + +// TestVirtualListen validates that the Listen() function properly +// does nothing. The function has to be implemented in order to follow +// the virtual/physical abstraction interface +func TestVirtualListen(t *testing.T) { + reader := &CardReaderVirtual{} + + reader.Listen() +} + +// TestVirtualRelease validates that the Release() function properly +// returns a nil error. The function has to be implemented in order to follow +// the virtual/physical abstraction interface +func TestVirtualRelease(t *testing.T) { + reader := &CardReaderVirtual{} + + err := reader.Release() + assert.NoError(t, err) +} + +// TestVirtualStatus validates that the Status() function properly +// returns a nil error. The function has to be implemented in order to follow +// the virtual/physical abstraction interface +func TestVirtualStatus(t *testing.T) { + tests := []struct { + reader *CardReaderVirtual + expectedError error + }{ + { + &CardReaderVirtual{}, + nil, + }, + { + &CardReaderVirtual{MockFailStatusCheck: true}, + fmt.Errorf("status check failed"), + }, + } + + for _, test := range tests { + assert.Equal(t, test.reader.Status(), test.expectedError) + } +} + +// TestWrite validates that the virtual device's Write function pushes +// a valid command value to the async channel of the device +func TestWrite(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + require := require.New(t) + + err := clearVirtualLogs() + require.NoError(err) + + // note: it is critical to create a two-way channel and then pass in the + // one-way component of this channel to the CardReaderVirtual below. + // In order to receive values from the channel, the original channel + // must be used, not the channel that was passed to the CardReaderVirtual, + // since it only takes the one-way component + asyncCh := make(chan *dsModels.AsyncValues, 16) + + loggingClient := logger.NewClient(virtualCardReaderDeviceServiceName, false, virtualLogFile, "DEBUG") + + reader := CardReaderVirtual{ + AsyncCh: asyncCh, + DeviceName: virtualDeviceName, + LoggingClient: loggingClient, + } + + reader.Write(common.CommandCardReaderEvent, expectedCardNumberVirtual) + + actual := <-asyncCh + require.NotNil(actual.DeviceName) // "actual" is a pointer, must not be nil + assert.Equal(virtualDeviceName, actual.DeviceName) + + actualStringValue, err := actual.CommandValues[0].StringValue() + require.NoError(err) + + assert.Equal(expectedCardNumberVirtual, actualStringValue) + + actualLogPresence, err := doesVirtualLogFileContainString(fmt.Sprintf("received event with card number %v", expectedCardNumberVirtual)) + require.NoError(err) + assert.True(actualLogPresence) + + err = clearVirtualLogs() + require.NoError(err) +} diff --git a/ds-card-reader/driver/driver.go b/ds-card-reader/driver/driver.go new file mode 100644 index 0000000..2d3a96c --- /dev/null +++ b/ds-card-reader/driver/driver.go @@ -0,0 +1,141 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package driver + +import ( + "fmt" + + common "ds-card-reader/common" + device "ds-card-reader/device" + sdk "github.com/edgexfoundry/device-sdk-go" + dsModels "github.com/edgexfoundry/device-sdk-go/pkg/models" + "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/models" + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +// CardReaderDriver represents the EdgeX driver that interfaces with the +// underlying device +type CardReaderDriver struct { + LoggingClient logger.LoggingClient + CardReader device.CardReader + Config common.CardReaderConfig +} + +// Initialize initializes the card reader device within EdgeX. This is the +// main entrypoint of this application +func (drv *CardReaderDriver) Initialize(lc logger.LoggingClient, asyncCh chan<- *dsModels.AsyncValues) error { + // propagate the logging client to the driver so it can use it too + drv.LoggingClient = lc + + // parse the device's configuration into a proper struct + err := utilities.MarshalSettings(sdk.DriverConfigs(), &drv.Config, false) + if err != nil { + return fmt.Errorf("failed to process card reader settings, check configuration.toml: %w", err) + } + + // initialize the card reader device so that it can be controlled by our + // EdgeX driver, and so that it can store configuration values + drv.CardReader, err = device.InitializeCardReader( + lc, + asyncCh, + drv.Config.DeviceSearchPath, + drv.Config.DeviceName, + drv.Config.VID, + drv.Config.PID, + drv.Config.SimulateDevice, + false, + ) + if err != nil { + return fmt.Errorf("failed to initialize card reader: %w", err) + } + + return nil +} + +// HandleReadCommands is responsible for handling read commands from EdgeX +func (drv *CardReaderDriver) HandleReadCommands(deviceName string, protocols map[string]models.ProtocolProperties, reqs []dsModels.CommandRequest) (result []*dsModels.CommandValue, err error) { + deviceResourceName := reqs[0].DeviceResourceName + + switch deviceResourceName { + // the "card reader status" auto event is intended to be a frequent health + // check that ensures we have a lock on the underlying device + case common.CommandCardReaderStatus: + drv.LoggingClient.Debug(fmt.Sprintf("read command: %v, verifying lock on device", common.CommandCardReaderStatus)) + + err := drv.CardReader.Status() + if err != nil { + errMsg := fmt.Sprintf("read command: %v, failed to verify lock on device: %v", common.CommandCardReaderStatus, err.Error()) + drv.LoggingClient.Error(errMsg) + return result, fmt.Errorf(errMsg) + } + + drv.LoggingClient.Debug(fmt.Sprintf("read command: %v, device ok", common.CommandCardReaderStatus)) + return result, nil + } + + errMsg := fmt.Sprintf("read command \"%v\" is not handled by this device service", deviceResourceName) + drv.LoggingClient.Error(errMsg) + return result, fmt.Errorf(errMsg) +} + +// HandleWriteCommands implements a standard EdgeX device service function to +// handle incoming EdgeX write commands that come from other services +// connected to EdgeX. Write commands are intended to be used by the virtual +// device service only, but works in either physical or virtual conditions. +func (drv *CardReaderDriver) HandleWriteCommands(deviceName string, protocols map[string]models.ProtocolProperties, reqs []dsModels.CommandRequest, params []*dsModels.CommandValue) error { + if len(params) == 0 { + return fmt.Errorf("no params were passed into the write command handler for device %v", deviceName) + } + + commandName := params[0].DeviceResourceName + + switch commandName { + case common.CommandCardReaderEvent: + { + // parse the card number from the event + cardNumber, err := params[0].StringValue() + if err != nil { + errMsg := fmt.Sprintf("write command \"%v\" received non-string value: %v", commandName, err.Error()) + drv.LoggingClient.Debug(errMsg) + return fmt.Errorf(errMsg) + } + + drv.CardReader.Write(common.CommandCardReaderEvent, cardNumber) + + return nil + } + } + errMsg := fmt.Sprintf("write command \"%v\" is not handled by this device service", commandName) + drv.LoggingClient.Error(errMsg) + return fmt.Errorf(errMsg) +} + +// AddDevice responds to when a device is added. +func (drv *CardReaderDriver) AddDevice(deviceName string, protocols map[string]models.ProtocolProperties, adminState models.AdminState) error { + // Nothing to do + return nil +} + +// UpdateDevice responds to when a device is updated. +func (drv *CardReaderDriver) UpdateDevice(deviceName string, protocols map[string]models.ProtocolProperties, adminState models.AdminState) error { + // Nothing to do + return nil +} + +// RemoveDevice responds to when a device is removed. +func (drv *CardReaderDriver) RemoveDevice(deviceName string, protocols map[string]models.ProtocolProperties) error { + // Nothing to do + return nil +} + +// Stop allows EdgeX to emulate stopping the device +func (drv *CardReaderDriver) Stop(force bool) error { + return nil +} + +// DisconnectDevice allows EdgeX to emulate disconnection +func (drv *CardReaderDriver) DisconnectDevice(deviceName string, protocols map[string]models.ProtocolProperties) error { + return nil +} diff --git a/ds-card-reader/driver/driver_test.go b/ds-card-reader/driver/driver_test.go new file mode 100644 index 0000000..71a4b8f --- /dev/null +++ b/ds-card-reader/driver/driver_test.go @@ -0,0 +1,377 @@ +// +build all physical !physical + +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +// notes on why physical and !physical build tags are present: + +// this file requires !physical tag so it can be run when *no* tags are passed +// into the test tool (i.e. running simulated mode tests) + +// this file also requires the physical tag so that it can be run when the +// "physical" tag is passed into the test tool + +package driver + +import ( + "bufio" + "ds-card-reader/common" + "ds-card-reader/device" + "fmt" + "io/ioutil" + "os" + "strings" + "sync" + "testing" + + sdk "github.com/edgexfoundry/device-sdk-go" + dsModels "github.com/edgexfoundry/device-sdk-go/pkg/models" + "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/models" + assert "github.com/stretchr/testify/assert" + require "github.com/stretchr/testify/require" +) + +var once sync.Once + +const ( + invalid = "invalid" + logFile = "driver_test.log" + cardReaderDeviceServiceName = "ds-card-reader" + expectedCardNumber = "0003292356" +) + +func clearLogs() error { + return ioutil.WriteFile(logFile, []byte{}, 0644) +} + +func doesLogFileContainString(input string) (bool, error) { + // attempt to open the log file + file, err := os.Open(logFile) + if err != nil { + return false, err + } + + // defer closing the file open buffer + defer file.Close() + + scanner := bufio.NewScanner(file) + + // iterate over every line in the log file + for scanner.Scan() { + line := scanner.Text() + if strings.Contains(line, input) { + return true, nil + } + } + + // check for residual errors in the scanner + err = scanner.Err() + if err != nil { + return false, err + } + + return false, nil +} + +// getDefaultCardReaderConfig returns a CardReaderConfig that contains the +// same values as the current default values in configuration.toml +// +// WARNING: If changing the default values in configuration.toml, please +// update this function +func getDefaultCardReaderConfig() common.CardReaderConfig { + return common.CardReaderConfig{ + DeviceName: cardReaderDeviceServiceName, + DeviceSearchPath: "/dev/input/event*", + VID: 0xffff, + PID: 0x0035, + SimulateDevice: true, + } +} + +// TestInitialize validates that the device service interacts with the driver +// as expected. Due to the way that the EdgeX device service relies on a +// the singleton function "sdk.NewService()", we have to put most tests in +// a specific order and parallelizing them might cause the SDK to yield +// bad results +func TestInitialize(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + + driver := CardReaderDriver{} + lc := logger.NewClient(cardReaderDeviceServiceName, false, logFile, "DEBUG") + + // create an empty logging client/card reader device to compare against + var emptyLogger logger.LoggingClient + var emptyCardReaderDevice device.CardReader + + // create a new service in the device services SDK + // this can only be called once or else it will throw errors + once.Do( + func() { + _, err := sdk.NewService("TestService", "0.1", "", `../res`, "", &driver) + require.NoError(t, err) + }, + ) + + err := driver.Initialize( + lc, + make(chan *dsModels.AsyncValues, 16), + ) + + require.NoError(t, err) + assert.NotEqual(emptyLogger, driver.LoggingClient) + assert.Equal(getDefaultCardReaderConfig(), driver.Config) + assert.NotEqual(emptyCardReaderDevice, driver.CardReader) +} + +// TestStop validates that the driver Stop function is implemented without +// throwing any errors +func TestStop(t *testing.T) { + driver := CardReaderDriver{ + Config: common.CardReaderConfig{DeviceName: cardReaderDeviceServiceName}, + } + + err := driver.Stop(false) + assert.NoError(t, err) +} + +// TestDisconnectDevice validates that the driver DisconnectDevice function is +// implemented without throwing any errors +func TestDisconnectDevice(t *testing.T) { + driver := CardReaderDriver{ + Config: common.CardReaderConfig{DeviceName: cardReaderDeviceServiceName}, + } + + err := driver.DisconnectDevice( + driver.Config.DeviceName, + map[string]models.ProtocolProperties{}, + ) + + assert.NoError(t, err) +} + +// TestHandleReadCommands validates that the HandleReadCommands function +// properly handles incoming EdgeX read commands +func TestHandleReadCommands(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + require := require.New(t) + + lc := logger.NewClient(cardReaderDeviceServiceName, false, logFile, "DEBUG") + + tests := []struct { + Name string + DeviceResourceName string + ExpectedLogLines []string + ExpectedResult []*dsModels.CommandValue + ExpectedError error + driver *CardReaderDriver + }{ + { + Name: "HandleReadCommands successful status test", + DeviceResourceName: common.CommandCardReaderStatus, + ExpectedLogLines: []string{ + fmt.Sprintf("read command: %v, verifying lock on device", common.CommandCardReaderStatus), + fmt.Sprintf("read command: %v, device ok", common.CommandCardReaderStatus), + }, + ExpectedError: nil, + driver: &CardReaderDriver{ + LoggingClient: lc, + CardReader: &device.CardReaderVirtual{ + AsyncCh: make(chan *dsModels.AsyncValues, 16), + LoggingClient: lc, + }, + Config: common.CardReaderConfig{DeviceName: cardReaderDeviceServiceName}, + }, + }, + { + Name: "HandleReadCommands unsuccessful status test", + DeviceResourceName: common.CommandCardReaderStatus, + ExpectedLogLines: []string{ + fmt.Sprintf("read command: %v, verifying lock on device", common.CommandCardReaderStatus), + fmt.Sprintf("read command: %v, failed to verify lock on device: status check failed", common.CommandCardReaderStatus), + }, + ExpectedError: fmt.Errorf("read command: %v, failed to verify lock on device: status check failed", common.CommandCardReaderStatus), + driver: &CardReaderDriver{ + LoggingClient: lc, + CardReader: &device.CardReaderVirtual{ + LoggingClient: lc, + MockFailStatusCheck: true, + }, + Config: common.CardReaderConfig{DeviceName: cardReaderDeviceServiceName}, + }, + }, + { + Name: "HandleReadCommands unhandled device resource name", + DeviceResourceName: invalid, + ExpectedLogLines: []string{}, + ExpectedError: fmt.Errorf("read command \"%v\" is not handled by this device service", invalid), + driver: &CardReaderDriver{ + LoggingClient: lc, + CardReader: &device.CardReaderVirtual{ + LoggingClient: lc, + }, + Config: common.CardReaderConfig{DeviceName: cardReaderDeviceServiceName}, + }, + }, + } + + // run the tests to handle read commands + for _, test := range tests { + t.Run(test.Name, func(t *testing.T) { + // clear the log file + err := clearLogs() + require.NoError(err) + + result, err := test.driver.HandleReadCommands( + test.driver.Config.DeviceName, + map[string]models.ProtocolProperties{}, + []dsModels.CommandRequest{ + { + DeviceResourceName: test.DeviceResourceName, + }, + }, + ) + + // perform assertions + require.Equal(test.ExpectedError, err) + assert.Equal(test.ExpectedResult, result) + + // check if the expected log output is in the log file + for _, str := range test.ExpectedLogLines { + result, err := doesLogFileContainString(str) + require.NoError(err) + assert.True(result) + } + }) + } + + // clear the logs as a last step + err := clearLogs() + require.NoError(err) +} + +// TestHandleWriteCommands validates that the HandleWriteCommands behaves +// as expected +func TestHandleWriteCommands(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + require := require.New(t) + + // prepare some variables for usage in the below tests + protocolProperties := map[string]models.ProtocolProperties{} + lc := logger.NewClient(cardReaderDeviceServiceName, false, logFile, "DEBUG") + + successfulCommandVal, err := dsModels.NewCommandValue(common.CommandCardReaderEvent, 0, expectedCardNumber, 1) + require.NoError(err) + + invalidCommandVal, err := dsModels.NewCommandValue(invalid, 0, expectedCardNumber, 1) + require.NoError(err) + + nonStringCommandVal, err := dsModels.NewCommandValue(common.CommandCardReaderEvent, 0, 0.01, dsModels.ParseValueType("float64")) + require.NoError(err) + + tests := []struct { + name string + inputParams []*dsModels.CommandValue + inputReqs []dsModels.CommandRequest + expectedLogLines []string + expectedError error + driver *CardReaderDriver + }{ + { + "HandleWriteCommands empty input params (command values)", + []*dsModels.CommandValue{}, + []dsModels.CommandRequest{{}}, + []string{}, + fmt.Errorf("no params were passed into the write command handler for device %v", cardReaderDeviceServiceName), + &CardReaderDriver{ + LoggingClient: lc, + CardReader: &device.CardReaderVirtual{ + AsyncCh: make(chan *dsModels.AsyncValues, 16), + LoggingClient: lc, + }, + Config: common.CardReaderConfig{DeviceName: cardReaderDeviceServiceName}, + }, + }, + { + "HandleWriteCommands input param with non-string type", + []*dsModels.CommandValue{nonStringCommandVal}, + []dsModels.CommandRequest{{}}, + []string{fmt.Sprintf("write command \\\"%v\\\" received non-string value: %v", common.CommandCardReaderEvent, "the data type is not string")}, + fmt.Errorf("write command \"%v\" received non-string value: %v", common.CommandCardReaderEvent, "the data type is not string"), + &CardReaderDriver{ + LoggingClient: lc, + CardReader: &device.CardReaderVirtual{ + AsyncCh: make(chan *dsModels.AsyncValues, 16), + LoggingClient: lc, + }, + Config: common.CardReaderConfig{DeviceName: cardReaderDeviceServiceName}, + }, + }, + { + "HandleWriteCommands unhandled device resource name", + []*dsModels.CommandValue{invalidCommandVal}, + []dsModels.CommandRequest{{DeviceResourceName: invalid}}, + []string{fmt.Sprintf("write command \\\"%v\\\" is not handled by this device service", invalid)}, + fmt.Errorf("write command \"%v\" is not handled by this device service", invalid), + &CardReaderDriver{ + LoggingClient: lc, + CardReader: &device.CardReaderVirtual{ + AsyncCh: make(chan *dsModels.AsyncValues, 16), + LoggingClient: lc, + }, + Config: common.CardReaderConfig{DeviceName: cardReaderDeviceServiceName}, + }, + }, + { + "HandleWriteCommands successful write test", + []*dsModels.CommandValue{successfulCommandVal}, + []dsModels.CommandRequest{{DeviceResourceName: common.CommandCardReaderStatus}}, + []string{}, + nil, + &CardReaderDriver{ + LoggingClient: lc, + CardReader: &device.CardReaderVirtual{ + AsyncCh: make(chan *dsModels.AsyncValues, 16), + LoggingClient: lc, + }, + Config: common.CardReaderConfig{DeviceName: cardReaderDeviceServiceName}, + }, + }, + } + + // run the tests to handle read commands + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + // clear the log file + err := clearLogs() + require.NoError(err) + + // run the handle write commands function + err = test.driver.HandleWriteCommands( + test.driver.Config.DeviceName, + protocolProperties, + test.inputReqs, + test.inputParams, + ) + + // perform assertions + require.Equal(test.expectedError, err) + + // check if the expected log output is in the log file + for _, str := range test.expectedLogLines { + result, err := doesLogFileContainString(str) + require.NoError(err) + // this log output is confusing when it errors out, so + // a message describing the assertion clearly has been added + assert.True(result, fmt.Sprintf("test named \"%v\" expects log file to contain log string \"%v\"", test.name, str)) + } + }) + } + + // clear the log file + err = clearLogs() + require.NoError(err) +} diff --git a/ds-card-reader/go.mod b/ds-card-reader/go.mod new file mode 100644 index 0000000..13ee21c --- /dev/null +++ b/ds-card-reader/go.mod @@ -0,0 +1,14 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +module ds-card-reader + +go 1.12 + +require ( + github.com/edgexfoundry/device-sdk-go v1.1.1 + github.com/edgexfoundry/go-mod-core-contracts v0.1.31 + github.com/gvalkov/golang-evdev v0.0.0-20180516222720-b6f418b1fe5a + github.com/intel-iot-devkit/automated-checkout-utilities v1.0.0 + github.com/stretchr/testify v1.5.1 +) diff --git a/ds-card-reader/main.go b/ds-card-reader/main.go new file mode 100644 index 0000000..9ad3829 --- /dev/null +++ b/ds-card-reader/main.go @@ -0,0 +1,19 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package main + +import ( + "ds-card-reader/driver" + + "github.com/edgexfoundry/device-sdk-go/pkg/startup" +) + +const ( + version string = "1.0" + serviceName string = "ds-card-reader" +) + +func main() { + startup.Bootstrap(serviceName, version, new(driver.CardReaderDriver)) +} diff --git a/ds-card-reader/res/configuration.toml b/ds-card-reader/res/configuration.toml new file mode 100644 index 0000000..0e14d5a --- /dev/null +++ b/ds-card-reader/res/configuration.toml @@ -0,0 +1,80 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +[Writable] +LogLevel = "INFO" + +[Service] +Host = "localhost" +Port = 48098 +ConnectRetries = 100 +Labels = [] +OpenMsg = "Card Reader device service started" +ReadMaxLimit = 256 +Timeout = 5000 +EnableAsyncReadings = true +AsyncBufferSize = 16 + +[Registry] +Host = "localhost" +Port = 8500 +CheckInterval = "10s" +FailLimit = 3 +FailWaitTime = 10 +Type = "consul" + +[Logging] +EnableRemote = true + +[Clients] + [Clients.Data] + Name = "edgex-core-data" + Protocol = "http" + Host = "localhost" + Port = 48080 + Timeout = 5000 + + [Clients.Metadata] + Name = "edgex-core-metadata" + Protocol = "http" + Host = "localhost" + Port = 48081 + Timeout = 5000 + + [Clients.Logging] + Name = "edgex-support-logging" + Protocol = "http" + Host = "localhost" + Port = 48061 + +[Device] + DataTransform = true + InitCmd = "" + InitCmdArgs = "" + MaxCmdOps = 128 + MaxCmdValueLen = 256 + RemoveCmd = "" + RemoveCmdArgs = "" + ProfilesDir = "./res" + +[Driver] + DeviceName = "ds-card-reader" + DeviceSearchPath = "/dev/input/event*" + VID = "65535" # 0xFFFF + PID = "53" # 0x0035 + SimulateDevice = "true" + +# Pre-define Devices +[[DeviceList]] + Name = "ds-card-reader" + Profile = "ds-card-reader" + Description = "ds-card-reader-description" + Labels = [ "ds-card-reader-label" ] + [DeviceList.Protocols] + [DeviceList.Protocols.other] + Address = "device-ds-card-reader01" + Port = "300" + [[DeviceList.AutoEvents]] + Frequency = "3s" + OnChange = true + Resource = "card-reader-status" diff --git a/ds-card-reader/res/docker/configuration.toml b/ds-card-reader/res/docker/configuration.toml new file mode 100644 index 0000000..80a3c32 --- /dev/null +++ b/ds-card-reader/res/docker/configuration.toml @@ -0,0 +1,77 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +[Writable] +LogLevel = "INFO" + +[Service] +Host = "ds-card-reader" +Port = 48098 +ConnectRetries = 100 +Labels = [] +OpenMsg = "Card Reader device service started" +ReadMaxLimit = 256 +Timeout = 5000 +EnableAsyncReadings = true +AsyncBufferSize = 16 + +[Registry] +Host = "edgex-core-consul" +Port = 8500 +CheckInterval = "10s" +FailLimit = 3 +FailWaitTime = 10 +Type = "consul" + +[Logging] +EnableRemote = true + +[Clients] + [Clients.Data] + Host = "edgex-core-data" + Protocol = "http" + Port = 48080 + Timeout = 5000 + + [Clients.Metadata] + Host = "edgex-core-metadata" + Protocol = "http" + Port = 48081 + Timeout = 5000 + + [Clients.Logging] + Host = "edgex-support-logging" + Protocol = "http" + Port = 48061 + +[Device] + DataTransform = true + InitCmd = "" + InitCmdArgs = "" + MaxCmdOps = 128 + MaxCmdValueLen = 256 + RemoveCmd = "" + RemoveCmdArgs = "" + ProfilesDir = "./res" + +[Driver] + DeviceName = "ds-card-reader" + DeviceSearchPath = "/dev/input/event*" + VID = "65535" # 0xFFFF + PID = "53" # 0x0035 + SimulateDevice = "true" + +# Pre-define Devices +[[DeviceList]] + Name = "ds-card-reader" + Profile = "ds-card-reader" + Description = "ds-card-reader-description" + Labels = [ "ds-card-reader-label" ] + [DeviceList.Protocols] + [DeviceList.Protocols.other] + Address = "device-ds-card-reader01" + Port = "300" + [[DeviceList.AutoEvents]] + Frequency = "3s" + OnChange = true + Resource = "card-reader-status" diff --git a/ds-card-reader/res/ds-card-reader.yaml b/ds-card-reader/res/ds-card-reader.yaml new file mode 100644 index 0000000..b573b56 --- /dev/null +++ b/ds-card-reader/res/ds-card-reader.yaml @@ -0,0 +1,41 @@ +--- + +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +name: "ds-card-reader" +manufacturer: "Intel" +model: "rfid-ds-card-reader" +labels: +- "ds-card-reader-label" +description: "A device for reading from serial scales" + +deviceResources: +- name: "card-reader-event" + description: "" + properties: + value: + { type: "string", readWrite: "RW", defaultValue: ""} + units: + { type: "string", readWrite: "RW", defaultValue: ""} + +- name: "card-reader-status" + description: "Read card-reader-status" + properties: + value: + { type: "string", readWrite: "RW", defaultValue: "" } + units: + { type: "string", readWrite: "RW", defaultValue: "" } + +deviceCommands: +- name: "card-reader-status" + get: + - { operation: "get", object: "card-reader-status", property: "value", parameter: "card-reader-status" } + set: + - { operation: "set", object: "card-reader-status", property: "value", parameter: "card-reader-status" } + +- name: "card-reader-event" + set: + - { operation: "set", object: "card-reader-event", property: "value", parameter: "card-reader-event" } + get: + - { operation: "get", object: "card-reader-event", property: "value", parameter: "card-reader-event" } diff --git a/ds-controller-board/.dockerignore b/ds-controller-board/.dockerignore new file mode 100644 index 0000000..3a92235 --- /dev/null +++ b/ds-controller-board/.dockerignore @@ -0,0 +1,7 @@ +Dockerfile* +docker-compose* +.dockerignore +.git +.gitignore +go.sum +.vscode \ No newline at end of file diff --git a/ds-controller-board/.gitignore b/ds-controller-board/.gitignore new file mode 100644 index 0000000..58d2dde --- /dev/null +++ b/ds-controller-board/.gitignore @@ -0,0 +1,17 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib +.vscode +*.log + +# Test binary, build with `go test -c` +*.test +go.sum +main +ds-controller-board + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out diff --git a/ds-controller-board/.golangci.yml b/ds-controller-board/.golangci.yml new file mode 100644 index 0000000..5be4558 --- /dev/null +++ b/ds-controller-board/.golangci.yml @@ -0,0 +1,27 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause +run: + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 5m +linters-settings: + misspell: + locale: US +linters: + enable: + - bodyclose + - errcheck + - goconst + - golint + - govet + - gosimple + - ineffassign + - misspell + - staticcheck + - structcheck + - typecheck + - unused + - unconvert + - unparam + - varcheck + disable-all: true + fast: true diff --git a/ds-controller-board/Dockerfile b/ds-controller-board/Dockerfile new file mode 100644 index 0000000..977e0ac --- /dev/null +++ b/ds-controller-board/Dockerfile @@ -0,0 +1,25 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +FROM automated-checkout/build:latest AS builder + +LABEL license='SPDX-License-Identifier: BSD-3-Clause' \ + copyright='Copyright (c) 2019: Intel' + +WORKDIR /app +COPY . . + +# Compile the code +RUN make gobuild + +# Next image - Copy built Go binary into new workspace +FROM alpine + +LABEL license='SPDX-License-Identifier: BSD-3-Clause' \ + copyright='Copyright (c) 2019: Intel' + +COPY --from=builder /app/res/ds-controller-board.yaml /res/ds-controller-board.yaml +COPY --from=builder /app/res/docker/configuration.toml /res/docker/configuration.toml +COPY --from=builder /app/ds-controller-board /ds-controller-board + +CMD [ "/ds-controller-board","--profile=docker","--confdir=/res", "-r", "consul://edgex-core-consul:8500"] diff --git a/ds-controller-board/LICENSE b/ds-controller-board/LICENSE new file mode 100644 index 0000000..105f619 --- /dev/null +++ b/ds-controller-board/LICENSE @@ -0,0 +1,31 @@ +BSD 3-Clause License + +Copyright © 2020, Intel Corporation +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/ds-controller-board/Makefile b/ds-controller-board/Makefile new file mode 100644 index 0000000..52b6957 --- /dev/null +++ b/ds-controller-board/Makefile @@ -0,0 +1,82 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +.PHONY: build gobuild run gorun stop test lint + + +MICROSERVICE=automated-checkout/ds-controller-board + +build: + docker build --rm \ + --build-arg http_proxy \ + --build-arg https_proxy \ + -f Dockerfile \ + -t $(MICROSERVICE):dev \ + . + +gobuild: + CGO_ENABLED=1 GOOS=linux go build -ldflags='-s -w' -a -installsuffix cgo -o ds-controller-board + +run: + docker run \ + --rm \ + -p 48097:48097 \ + $(MICROSERVICE):dev + +gorun: + ./main + +stop: + docker rm -f $(MICROSERVICE):dev + +test: + go test -test.v \ + -cover \ + ./... + +testHTML: + go test \ + -test.v \ + -coverprofile=test_coverage.out \ + ./... && \ + go tool cover -html=test_coverage.out + +testPhysical: + sudo -E go test -test.v \ + -cover \ + -tags=physical \ + ./... + +testPhysicalHTML: + sudo -E go test \ + -tags=physical \ + -test.v \ + -coverprofile=test_coverage_physical.out \ + ./... && \ + go tool cover -html=test_coverage_physical.out + +testAll: + sudo -E go test \ + -test.v \ + -cover \ + -tags=all \ + ./... + +testAllHTML: + sudo -E go test \ + -tags=all \ + -test.v \ + -coverprofile=test_coverage_all.out \ + ./... && \ + go tool cover \ + -html=test_coverage_all.out + + +GOLANGCI_VERSION := $(shell golangci-lint --version 2>/dev/null) + +lint: +ifdef GOLANGCI_VERSION + golangci-lint run +else + @echo "golangci-lint not found. Please refer to the README documentation for proper installation" +endif diff --git a/ds-controller-board/device/common.go b/ds-controller-board/device/common.go new file mode 100644 index 0000000..cdb6aab --- /dev/null +++ b/ds-controller-board/device/common.go @@ -0,0 +1,91 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package device + +import ( + "fmt" + "strconv" + "strings" +) + +// Command is an enumeration of the commands accepted through the +// controller board's serial interface +var Command = struct { + Lock1 string + Lock2 string + UnLock1 string + UnLock2 string + Status string + GetStatus string + DefaultDisp string + Message0 string + Message1 string + Message2 string + Message3 string +}{ + Lock1: "L1\n", + Lock2: "L2\n", + UnLock1: "U1\n", + UnLock2: "U2\n", + Status: "Status\n", + GetStatus: "S\n", + DefaultDisp: "D\n", + Message0: "M0", + Message1: "M1", + Message2: "M2", + Message3: "M3", +} + +// StatusEvent is a struct to handle the mapping of status event values to their +// respective JSON values in a JSON object +type StatusEvent struct { + Lock1Status int `json:"lock1_status"` + Lock2Status int `json:"lock2_status"` + DoorClosed bool `json:"door_closed"` // true means the door is closed and false means the door is open + Temperature float64 `json:"temperature"` + Humidity float64 `json:"humidity"` +} + +// ParseStatus is a function used to marshal the serial output from the +// controller board into a StatusEvent struct +func ParseStatus(status string) (StatusEvent, error) { + var sEvent StatusEvent // STATUS,L1,0,L2,0,D,0,T,78.58,H,19.54 + var err error + s1 := strings.Split(status, ",") + + if len(s1) == 11 { + sEvent.Lock1Status, err = strconv.Atoi(s1[2]) + if err != nil { + return sEvent, fmt.Errorf("unable to parse Lock1 status: %v", err) + } + + sEvent.Lock2Status, err = strconv.Atoi(s1[4]) + if err != nil { + return sEvent, fmt.Errorf("unable to parse Lock2 status: %v", err) + } + + sEvent.DoorClosed, err = strconv.ParseBool(s1[6]) + if err != nil { + return sEvent, fmt.Errorf("unable to parse DoorClosed status: %v", err) + } + + var temp float64 + temp, err = strconv.ParseFloat(s1[8], 64) + sEvent.Temperature = temp + if err != nil { + return sEvent, fmt.Errorf("unable to parse Temperature status: %v", err) + } + + // Remove "\r\n" from end of the line before calling strconv.ParseFloat + s1[10] = strings.TrimSuffix(s1[10], "\r\n") + var hum float64 + hum, err = strconv.ParseFloat(s1[10], 64) + sEvent.Humidity = hum + if err != nil { + return sEvent, fmt.Errorf("unable to parse Humidity status: %v", err) + } + } + + return sEvent, nil +} diff --git a/ds-controller-board/device/common_test.go b/ds-controller-board/device/common_test.go new file mode 100644 index 0000000..8686a6e --- /dev/null +++ b/ds-controller-board/device/common_test.go @@ -0,0 +1,51 @@ +// +build all +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package device + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestParseStatus(t *testing.T) { + expected := StatusEvent{ + Lock1Status: 1, + Lock2Status: 1, + DoorClosed: true, + Temperature: 78.58, + Humidity: 19.54, + } + + testCases := []struct { + Name string + Status string + Expected *StatusEvent + ErrorExpected bool + ErrorContains string + }{ + {"Success", "STATUS,L1,1,L2,1,D,1,T,78.58,H,19.54", &expected, false, ""}, + {"Lock1 error", "STATUS,L1,a,L2,1,D,1,T,78.58,H,19.54", nil, true, "unable to parse Lock1 status"}, + {"Lock2 error", "STATUS,L1,0,L2,b,D,1,T,78.58,H,19.54", nil, true, "unable to parse Lock2 status"}, + {"DoorClosed error", "STATUS,L1,0,L2,0,D,c,T,78.58,H,19.54", nil, true, "unable to parse DoorClosed status"}, + {"Temperature error", "STATUS,L1,0,L2,0,D,0,T,temp,H,19.54", nil, true, "unable to parse Temperature status"}, + {"Humidity error", "STATUS,L1,0,L2,0,D,0,T,0.0,H,hum", nil, true, "unable to parse Humidity status"}, + } + + for _, testCase := range testCases { + t.Run(testCase.Name, func(t *testing.T) { + actual, err := ParseStatus(testCase.Status) + if testCase.ErrorExpected { + require.Error(t, err) + assert.Contains(t, err.Error(), testCase.ErrorContains) + return // test complete + } + + require.NoError(t, err) + assert.Equal(t, testCase.Expected, &actual) + }) + } +} diff --git a/ds-controller-board/device/config.go b/ds-controller-board/device/config.go new file mode 100644 index 0000000..0b6b78f --- /dev/null +++ b/ds-controller-board/device/config.go @@ -0,0 +1,18 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package device + +import ( + "time" +) + +// Config is the global device configuration, which is populated by values in +// the "Driver" section of res/configuration.toml +type Config struct { + VirtualControllerBoard bool + PID string + VID string + DisplayTimeout time.Duration + LockTimeout time.Duration +} diff --git a/ds-controller-board/device/device.go b/ds-controller-board/device/device.go new file mode 100644 index 0000000..a2b223b --- /dev/null +++ b/ds-controller-board/device/device.go @@ -0,0 +1,62 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package device + +import ( + "fmt" + + dsModels "github.com/edgexfoundry/device-sdk-go/pkg/models" + "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" +) + +// ControllerBoard is a common interface for controller boards to implement +type ControllerBoard interface { + Read() + Write(string) error + GetStatus() string +} + +// NewControllerBoard is used to determine the ControllerBoard type +// (i.e. Device or Virtual), and perform the necessary steps to initialize +// a new ControllerBoard +func NewControllerBoard(lc logger.LoggingClient, asyncCh chan<- *dsModels.AsyncValues, config *Config) (ControllerBoard, error) { + var controllerBoard ControllerBoard + + if !config.VirtualControllerBoard { + + // Find the port name (like /dev/ttyACM0) connected to Controller Board + ttyPort, err := FindControllerBoard(config.VID, config.PID) + if err != nil { + return nil, fmt.Errorf("can't find controller board, check if it is connected: %s", err.Error()) + } + + devSerialPort, err := OpenAndConfigureSerialPort(ttyPort) + if err != nil { + return nil, fmt.Errorf("can't open or configure serial port %s: %s", ttyPort, err.Error()) + } + + lc.Info(fmt.Sprintf("Successfully opened and configured controller board on %s", ttyPort)) + + controllerBoard = &ControllerBoardPhysical{ + AsyncCh: asyncCh, + DevStatus: "", + LoggingClient: lc, + DevSerialPort: devSerialPort, + TTYPort: ttyPort, + } + } else { + controllerBoard = &ControllerBoardVirtual{ + AsyncCh: asyncCh, + DevStatus: "", + LoggingClient: lc, + L1: 1, + L2: 1, + DoorClosed: 1, + Temperature: 78.00, + Humidity: 10, + } + } + + return controllerBoard, nil +} diff --git a/ds-controller-board/device/device_test.go b/ds-controller-board/device/device_test.go new file mode 100644 index 0000000..b976000 --- /dev/null +++ b/ds-controller-board/device/device_test.go @@ -0,0 +1,41 @@ +// +build all physical +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package device + +import ( + "fmt" + "testing" + + "github.com/edgexfoundry/device-sdk-go/pkg/models" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestNewControllerBoardError(t *testing.T) { + config := &Config{ + VirtualControllerBoard: false, + } + + testCases := []struct { + Name string + VID string + PID string + ExpectedErrorMessage string + }{ + // Not testing success since it is handled in physical_test.go and will fail here due to port already in use. + {"Wrong VID", badVID, validPID, fmt.Sprintf("no USB port found matching VID=%s & PID=%s", badVID, validPID)}, + {"Wrong PID", validVID,badPID, fmt.Sprintf("no USB port found matching VID=%s & PID=%s", validVID, badPID)}, + } + + for _, testCase := range testCases { + t.Run(testCase.Name, func(t *testing.T) { + config.VID = testCase.VID + config.PID = testCase.PID + _, err := NewControllerBoard(lc, make(chan *models.AsyncValues), config) + require.Error(t, err) + assert.Contains(t, err.Error(),testCase.ExpectedErrorMessage) + }) + } +} diff --git a/ds-controller-board/device/physical.go b/ds-controller-board/device/physical.go new file mode 100644 index 0000000..62c4695 --- /dev/null +++ b/ds-controller-board/device/physical.go @@ -0,0 +1,146 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package device + +import ( + "encoding/json" + "fmt" + "strings" + "time" + + dsModels "github.com/edgexfoundry/device-sdk-go/pkg/models" + "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + + "go.bug.st/serial.v1" + "go.bug.st/serial.v1/enumerator" +) + +const ( + deviceName = "ds-controller-board" + deviceResource = "controller-board-status" +) + +//ControllerBoardPhysical : A physical ControllerBoard that leverages an Arduino Micro-Controller for reading/writing sensor and input values. +type ControllerBoardPhysical struct { + AsyncCh chan<- *dsModels.AsyncValues + DevStatus string // uC -> Host : STATUS,L1,0,L2,0,D,0,T,78.58,H,19.54 + LoggingClient logger.LoggingClient + DevSerialPort serial.Port + TTYPort string // typically is /dev/ttyACM0 +} + +// Write is used to handle commands being written to the +// controller board. It also forwards commands to the controller board via +// its serial interface. +func (board *ControllerBoardPhysical) Write(cmd string) error { + n, err := board.DevSerialPort.Write([]byte(cmd)) + if err != nil { + return err + } + board.LoggingClient.Debug("Sent %v bytes\n", n) + return nil +} + +// Read is a continuous loop that reads the controller board's +// serial status messages and forwards them to EdgeX as a reading +func (board *ControllerBoardPhysical) Read() { + board.LoggingClient.Debug("ControllerBoard Read Listening for events ...\n") + + var serialString string + + buff := make([]byte, 100) + for { + n, err := board.DevSerialPort.Read(buff) + if err != nil { + board.LoggingClient.Error(fmt.Sprintf("Error reading from serial port '%s'", board.TTYPort), "error", err) + break + } + + if n == 0 { + board.LoggingClient.Warn(fmt.Sprintf("Read: No data read from serial port '%s'", board.TTYPort)) + break + } + + board.LoggingClient.Info(fmt.Sprintf("Read: '%s' status read from ControllerBoard.", string(buff[:n]))) + + // Must build up the complete string read until all of it is received + serialString = serialString + string(buff[:n]) + if !strings.ContainsAny(serialString,"\r\n") { + continue + } + + board.LoggingClient.Info(fmt.Sprintf("Read: Processing '%s'", serialString)) + + if strings.Contains(serialString, "STATUS") { + parsedStatus, err := ParseStatus(serialString) + if err != nil { + board.LoggingClient.Error("unable to parse status", "error", err) + break + } + + parsedStatusBytes, err := json.Marshal(parsedStatus) + if err != nil { + board.LoggingClient.Error("unable to marshal parsed status", "error", err) + break + } + + board.DevStatus = string(parsedStatusBytes) //string(buff[:n]) + now := time.Now().UnixNano() / int64(time.Millisecond) + result := dsModels.NewStringValue(deviceResource, now, board.DevStatus) + + asyncValues := &dsModels.AsyncValues{ + DeviceName: deviceName, + CommandValues: []*dsModels.CommandValue{result}, + } + + board.AsyncCh <- asyncValues + } + + serialString = "" + } +} + +//GetStatus : Returns the ControllerBoard's JSON 'DevStatus' field as a String. +func (board *ControllerBoardPhysical) GetStatus() string { + return board.DevStatus +} + +//FindControllerBoard : Finds the ControllerBoards TTY URI (e.g. /dev/ttyACM0) based off of its PID and VID values. +func FindControllerBoard(vid string, pid string) (string, error) { + ports, err := enumerator.GetDetailedPortsList() + if err != nil { + return "", err + } + + for _, port := range ports { + if port.IsUSB { + if port.VID == vid && port.PID == pid { + return port.Name, nil + } + } + } + + return "", fmt.Errorf("no USB port found matching VID=%s & PID=%s", vid, pid) +} + +//OpenAndConfigureSerialPort : Opens the TTY URI (e.g. /dev/ttyACM0) as a Serial connection with the appropriate configuration (e.g. baud-rate, parity, data-bits, stop-bits, etc.). +func OpenAndConfigureSerialPort(ttyPort string) (serial.Port, error) { + port, err := serial.Open(ttyPort, &serial.Mode{}) + + if err != nil { + return nil, err + } + + mode := &serial.Mode{ + BaudRate: 115200, + Parity: serial.NoParity, + DataBits: 8, + StopBits: serial.OneStopBit, + } + if err := port.SetMode(mode); err != nil { + return nil, err + } + + return port, nil +} diff --git a/ds-controller-board/device/physical_test.go b/ds-controller-board/device/physical_test.go new file mode 100644 index 0000000..3df2e1f --- /dev/null +++ b/ds-controller-board/device/physical_test.go @@ -0,0 +1,113 @@ +// +build all physical +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package device + +import ( + "fmt" + "os" + "testing" + + "github.com/edgexfoundry/device-sdk-go/pkg/models" + "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +const ( + validVID = "2341" + validPID = "8037" + badVID = "9999" + badPID = "0000" +) + +var defaultConfig = Config { + VirtualControllerBoard: false, + PID: validPID, + VID: validVID, + DisplayTimeout: 10000, + LockTimeout: 30000, +} + +var lc logger.LoggingClient +var target ControllerBoard +var asyncChan chan *models.AsyncValues + +func TestMain(m *testing.M) { + var err error + asyncChan = make(chan *models.AsyncValues,16) // need at least buffer so writes to channel don't block + + lc = logger.NewClient("TestInitialize",false, "./unit-test.log", "DEBUG") + target, err = NewControllerBoard(lc, asyncChan, &defaultConfig ) + if err != nil { + fmt.Println("Failed to create ControllerBoard: " + err.Error()) + os.Exit(-1) + } + + os.Exit(m.Run()) +} + +func TestFindControllerBoard(t *testing.T) { + testCases := []struct { + Name string + VID string + PID string + ExpectedError error + }{ + {"Success", validVID, validPID, nil}, + {"Wrong VID", badVID, validPID, fmt.Errorf("no USB port found matching VID=%s & PID=%s", badVID, validPID)}, + {"Wrong PID", validVID,badPID, fmt.Errorf("no USB port found matching VID=%s & PID=%s", validVID, badPID)}, + } + + for _, testCase := range testCases { + t.Run(testCase.Name, func(t *testing.T) { + actual, err := FindControllerBoard(testCase.VID, testCase.PID) + if testCase.ExpectedError != nil { + require.Equal(t, testCase.ExpectedError, err) + return // test is complete + } else { + require.NoError(t, err) + } + + // The actual port name can vary so can only validate that we have a non-empty port name + require.True(t, len(actual) > 0, "Port returned is empty") + }) + } +} + +func TestGetStatus(t *testing.T) { + expected := "" + actual := target.GetStatus() + assert.Equal(t, expected, actual) +} + +func TestPhysicalRead(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + require := require.New(t) + + expectedDeviceName := deviceName + // Since temperature & humidity are not static, have to look just for the labels for them + expectedStatusContains := []string {`"lock1_status":1,`,`"lock2_status":1,`,`"door_closed":false,`, `"temperature":`, `"humidity":` } + + // Send a command so there is something to read + _ = target.Write(Command.GetStatus) + go target.Read() + actual := <- asyncChan + assert.NotNil(actual) + assert.Equal(expectedDeviceName, actual.DeviceName) + actualStatus, err := actual.CommandValues[0].StringValue() + require.NoError(err) + for _, expectedStatus := range expectedStatusContains { + assert.Contains(actualStatus, expectedStatus) + } +} + +func TestPhysicalWrite(t *testing.T) { + notExpected := new(ControllerBoardPhysical) + require.NotEqual(t, notExpected, target) + + err := target.Write(Command.Lock1) + require.NoError(t, err) +} diff --git a/ds-controller-board/device/virtual.go b/ds-controller-board/device/virtual.go new file mode 100644 index 0000000..bb01e46 --- /dev/null +++ b/ds-controller-board/device/virtual.go @@ -0,0 +1,105 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package device + +import ( + "encoding/json" + "fmt" + "time" + + dsModels "github.com/edgexfoundry/device-sdk-go/pkg/models" + "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" +) + +// ControllerBoardVirtual is a virtualized controller board that locally handles +// its 'sensor' and 'input' devices in a mocked fashion +type ControllerBoardVirtual struct { + AsyncCh chan<- *dsModels.AsyncValues + DevStatus string // uC -> Host : STATUS,L1,0,L2,0,D,0,T,78.58,H,19.54 + LoggingClient logger.LoggingClient + L1 int + L2 int + DoorClosed int + Temperature float64 + Humidity int64 +} + +// Read : A continuous loop that reads ControllerBoard Status and forwards it to the EdgeX stack as a Reading. +func (board *ControllerBoardVirtual) Read() { + board.LoggingClient.Debug("Virtual ControllerBoard Read Listening for events ...\n") + + for { + time.Sleep(3 * time.Second) + now := time.Now().UnixNano() / int64(time.Millisecond) + + parsedStatus, err := ParseStatus(board.getRawStatus()) + if err != nil { + board.LoggingClient.Error("unable to parse status", "error", err) + break + } + + parsedStatusBytes, err := json.Marshal(parsedStatus) + if err != nil { + board.LoggingClient.Error("unable to marshal parsed status", "error", err) + break + } + + board.DevStatus = string(parsedStatusBytes) + result := dsModels.NewStringValue(deviceResource, now, board.DevStatus) + + asyncValues := &dsModels.AsyncValues{ + DeviceName: deviceName, + CommandValues: []*dsModels.CommandValue{result}, + } + board.AsyncCh <- asyncValues + } +} + +// Write : Used to handle Commands being written to the ControllerBoard. +func (board *ControllerBoardVirtual) Write(cmd string) error { + board.LoggingClient.Info(fmt.Sprintf("Write: '%s' command issued.\n", cmd)) + switch cmd { + case Command.Lock1: + board.L1 = 1 + board.LoggingClient.Info("Locked Lock1") + case Command.Lock2: + board.L2 = 1 + board.LoggingClient.Info("Locked Lock2") + case Command.UnLock1: + board.L1 = 0 + board.LoggingClient.Info("Unlocked Lock1") + case Command.UnLock2: + board.L2 = 0 + board.LoggingClient.Info("Unlocked Lock2") + } + + return nil +} + +// GetStatus : Returns the ControllerBoard's JSON 'DevStatus' field as a String. +func (board *ControllerBoardVirtual) GetStatus() string { + return board.DevStatus +} + +func (board *ControllerBoardVirtual) getRawStatus() string { + return fmt.Sprintf("STATUS,L1,%d,L2,%d,D,%d,T,%.2f,H,%d", board.L1, board.L2, board.DoorClosed, board.Temperature, board.Humidity) +} + +// SetHumidity allows the controller board to emulate readings of an arbitrary +// humidity value +func (board *ControllerBoardVirtual) SetHumidity(humidity int64) { + board.Humidity = humidity +} + +// SetTemperature allows the controller board to emulate readings of +// an arbitrary temperature value +func (board *ControllerBoardVirtual) SetTemperature(temperature float64) { + board.Temperature = temperature +} + +// SetDoorClosed allows the controller board to emulate the condition that the +// door is closed +func (board *ControllerBoardVirtual) SetDoorClosed(closed int) { + board.DoorClosed = closed +} diff --git a/ds-controller-board/device/virtual_test.go b/ds-controller-board/device/virtual_test.go new file mode 100644 index 0000000..d42551d --- /dev/null +++ b/ds-controller-board/device/virtual_test.go @@ -0,0 +1,76 @@ +// +build all !physical +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package device + +import ( + "github.com/edgexfoundry/device-sdk-go/pkg/models" + "testing" + + "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestVirtualRead(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + require := require.New(t) + + expectedDeviceName := deviceName + // Since temperature & humidity are not static, have to look just for the labels for them + expectedStatus := `{"lock1_status":0,"lock2_status":0,"door_closed":false,"temperature":0,"humidity":0}` + + asyncChan := make(chan *models.AsyncValues, 16) + + target := ControllerBoardVirtual{ + LoggingClient: logger.NewClient("UnitTest", false, "./unit-test.log", "DEBUG"), + AsyncCh: asyncChan, + } + + // Send a command so there is something to read + _ = target.Write(Command.GetStatus) + go target.Read() + actual := <-asyncChan + assert.NotNil(actual) + assert.Equal(expectedDeviceName, actual.DeviceName) + actualStatus, err := actual.CommandValues[0].StringValue() + require.NoError(err) + assert.Equal(expectedStatus, actualStatus) +} + +func TestVirtualWrite(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + require := require.New(t) + + expected := "STATUS,L1,1,L2,1,D,0,T,0.00,H,0" + + target := ControllerBoardVirtual{ + LoggingClient: logger.NewClient("UnitTest", false, "./unit-test.log", "DEBUG"), + } + + err := target.Write(Command.Lock1) + require.NoError(err) + + err = target.Write(Command.Lock2) + require.NoError(err) + + actual := target.getRawStatus() + assert.Equal(expected, actual) + + expected = "STATUS,L1,0,L2,1,D,0,T,0.00,H,0" + err = target.Write(Command.UnLock1) + require.NoError(err) + + actual = target.getRawStatus() + assert.Equal(expected, actual) + + expected = "STATUS,L1,0,L2,0,D,0,T,0.00,H,0" + err = target.Write(Command.UnLock2) + require.NoError(err) + + actual = target.getRawStatus() + assert.Equal(expected, actual) +} diff --git a/ds-controller-board/driver/driver.go b/ds-controller-board/driver/driver.go new file mode 100644 index 0000000..9e2b531 --- /dev/null +++ b/ds-controller-board/driver/driver.go @@ -0,0 +1,251 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package driver + +import ( + "fmt" + "strconv" + "time" + + "ds-controller-board/device" + sdk "github.com/edgexfoundry/device-sdk-go" + dsModels "github.com/edgexfoundry/device-sdk-go/pkg/models" + "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/edgexfoundry/go-mod-core-contracts/models" + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +const ( + lock1 = "lock1" + lock2 = "lock2" + getStatus = "getStatus" + displayRow0 = "displayRow0" + displayRow1 = "displayRow1" + displayRow2 = "displayRow2" + displayRow3 = "displayRow3" + displayReset = "displayReset" + setHumidity = "setHumidity" + setTemperature= "setTemperature" + setDoorClosed= "setDoorClosed" + +) +// ControllerBoardDriver follows EdgeX standards for a device struct. +type ControllerBoardDriver struct { + lc logger.LoggingClient + StopChannel chan int + controllerBoard device.ControllerBoard + config *device.Config +} + +// NewControllerBoardDeviceDriver allows EdgeX to initialize the +// ControllerBoardDriver instance +func NewControllerBoardDeviceDriver() dsModels.ProtocolDriver { + return new(ControllerBoardDriver) +} + +// Initialize is an EdgeX function that initializes the device +func (drv *ControllerBoardDriver) Initialize(lc logger.LoggingClient, asyncCh chan<- *dsModels.AsyncValues) (err error) { + drv.lc = lc + + // Only setting if nil allows for unit testing with VirtualBoard enabled + if drv.config == nil { + drv.config = new(device.Config) + if err = utilities.MarshalSettings(sdk.DriverConfigs(), drv.config, true); err != nil { + return err + } + } + + drv.StopChannel = make(chan int) + + drv.controllerBoard, err = device.NewControllerBoard(lc, asyncCh, drv.config) + if err != nil { + return err + } + + go drv.controllerBoard.Read() + + return nil +} + +// HandleReadCommands handles AutoEvents and other read events from EdgeX. +func (drv *ControllerBoardDriver) HandleReadCommands(deviceName string, protocols map[string]models.ProtocolProperties, reqs []dsModels.CommandRequest) (res []*dsModels.CommandValue, err error) { + err = drv.controllerBoard.Write(device.Command.GetStatus) + if err != nil { + return nil, err + } + + now := time.Now().UnixNano() / int64(time.Millisecond) + result := dsModels.NewStringValue(reqs[0].DeviceResourceName, now, drv.controllerBoard.GetStatus()) + + return []*dsModels.CommandValue{result}, nil +} + +// HandleWriteCommands handles incoming write commands from EdgeX. +func (drv *ControllerBoardDriver) HandleWriteCommands(deviceName string, protocols map[string]models.ProtocolProperties, reqs []dsModels.CommandRequest, params []*dsModels.CommandValue) error { + + deviceType := params[0].DeviceResourceName + drv.lc.Info(fmt.Sprintf("---Received PUT Command: '%s'", deviceType)) + switch deviceType { + + case lock1: + cmdType := params[0].NumericValue[0] + switch cmdType { + case 1: + if err := drv.controllerBoard.Write(device.Command.UnLock1); err != nil { + return err + } + go func() { + time.Sleep(drv.config.LockTimeout) + _ = drv.controllerBoard.Write(device.Command.Lock1) + }() + case 0: + if err := drv.controllerBoard.Write(device.Command.Lock1); err != nil { + return err + } + default: + return fmt.Errorf("unknown Command Type: '%d'", cmdType) + } + + case lock2: + cmdType := params[0].NumericValue[0] + switch cmdType { + case 1: + if err := drv.controllerBoard.Write(device.Command.UnLock2); err != nil { + return err + } + go func() { + time.Sleep(drv.config.LockTimeout) + _ = drv.controllerBoard.Write(device.Command.Lock2) + }() + case 0: + if err := drv.controllerBoard.Write(device.Command.Lock2); err != nil { + return err + } + default: + return fmt.Errorf("unknown Command Type: '%d'", cmdType) + } + + case getStatus: + if err := drv.controllerBoard.Write(device.Command.Status); err != nil { + return err + } + + case displayRow0: + + cmdType, _ := params[0].StringValue() + message := device.Command.Message0 + cmdType + "\n" + drv.displayText(message) + + case displayRow1: + + cmdType, _ := params[0].StringValue() + message := device.Command.Message1 + cmdType + "\n" + drv.displayText(message) + + case displayRow2: + + cmdType, _ := params[0].StringValue() + message := device.Command.Message2 + cmdType + "\n" + drv.displayText(message) + + case displayRow3: + + cmdType, _ := params[0].StringValue() + message := device.Command.Message3 + cmdType + "\n" + drv.displayText(message) + + case displayReset: + drv.displayReset() + + case setHumidity: + cmdType, _ := params[0].StringValue() + newHumidity, _ := strconv.ParseInt(cmdType, 10, 64) + _, ok := (drv.controllerBoard).(*device.ControllerBoardVirtual) + if ok { + drv.lc.Info(fmt.Sprintf("ControllerBoardVirtual: 'setHumidity' is being set to %d%% Humidity.", newHumidity)) + drv.controllerBoard.(*device.ControllerBoardVirtual).SetHumidity(newHumidity) + } else { + drv.lc.Error("Command 'setHumidity' is only available to Virtual ControllerBoard.") + } + + case setTemperature: + cmdType, _ := params[0].StringValue() + newTemperature, _ := strconv.ParseFloat(cmdType, 64) + _, ok := (drv.controllerBoard).(*device.ControllerBoardVirtual) + if ok { + drv.lc.Info(fmt.Sprintf("ControllerBoardVirtual: 'setTemperature' is being set to %.2f degrees Fahrenheit.", newTemperature)) + drv.controllerBoard.(*device.ControllerBoardVirtual).SetTemperature(newTemperature) + } else { + drv.lc.Error("Command 'setTemperature' is only available to Virtual ControllerBoard.") + } + + case setDoorClosed: + cmdType, _ := params[0].StringValue() + newDoorClosed, _ := strconv.ParseInt(cmdType, 10, 64) + _, ok := (drv.controllerBoard).(*device.ControllerBoardVirtual) + if ok { + drv.lc.Info(fmt.Sprintf("ControllerBoardVirtual: 'setDoorClosed' is being set to %t.", !(newDoorClosed == 0))) + drv.controllerBoard.(*device.ControllerBoardVirtual).SetDoorClosed(int(newDoorClosed)) + } else { + drv.lc.Error("Command 'setDoorClosed' is only available to Virtual ControllerBoard.") + } + + default: + return fmt.Errorf("unknown command received: '%s'", deviceType) + } + + return nil +} + +func (drv *ControllerBoardDriver) displayText(message string) { + drv.lc.Info(message) + _ = drv.controllerBoard.Write(message) + // Stop the display reset thread and restart the timeout + close(drv.StopChannel) + drv.StopChannel = make(chan int) + + go func() { + for { + select { + case <-time.After(drv.config.DisplayTimeout): + drv.displayReset() + return + case <-drv.StopChannel: + drv.lc.Info("Reset the display reset thread") + return + } + } + }() +} + +func (drv *ControllerBoardDriver) displayReset() { + _ = drv.controllerBoard.Write(device.Command.Message0 + " " + "\n") + _ = drv.controllerBoard.Write(device.Command.Message1 + " " + "\n") + _ = drv.controllerBoard.Write(device.Command.Message2 + " " + "\n") + _ = drv.controllerBoard.Write(device.Command.Message3 + " " + "\n") + _ = drv.controllerBoard.Write(device.Command.DefaultDisp) +} + +// AddDevice responds to when a device is added. +func (drv *ControllerBoardDriver) AddDevice(deviceName string, protocols map[string]models.ProtocolProperties, adminState models.AdminState) error { + // Nothing to do + return nil +} + +// UpdateDevice responds to when a device is updated. +func (drv *ControllerBoardDriver) UpdateDevice(deviceName string, protocols map[string]models.ProtocolProperties, adminState models.AdminState) error { + // Nothing to do + return nil +} + +// RemoveDevice responds to when a device is removed. +func (drv *ControllerBoardDriver) RemoveDevice(deviceName string, protocols map[string]models.ProtocolProperties) error { + // Nothing to do + return nil +} + +// Stop stops a device +func (drv *ControllerBoardDriver) Stop(force bool) error { + return nil +} diff --git a/ds-controller-board/driver/driver_test.go b/ds-controller-board/driver/driver_test.go new file mode 100644 index 0000000..04d4431 --- /dev/null +++ b/ds-controller-board/driver/driver_test.go @@ -0,0 +1,158 @@ +// +build all !physical +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package driver + +import ( + "fmt" + "os" + "reflect" + "testing" + + "ds-controller-board/device" + "github.com/edgexfoundry/device-sdk-go/pkg/models" + "github.com/edgexfoundry/go-mod-core-contracts/clients/logger" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +var lc logger.LoggingClient + +func TestMain(m *testing.M) { + lc = logger.NewClient("UnitTest", false, "./unit-test.log", "DEBUG") + os.Exit(m.Run()) +} + +func TestNewControllerBoardDeviceDriver(t *testing.T) { + expected := &ControllerBoardDriver{} + actual := NewControllerBoardDeviceDriver() + assert.Equal(t, expected, actual) +} + +func TestDisconnectDevice(t *testing.T) { + target := CreateControllerBoardDriver(t, true, false, "") + actual := target.Stop(true) + assert.Nil(t, actual) +} + +func TestInitialize(t *testing.T) { + target := CreateControllerBoardDriver(t, true, false, "") + err := target.Initialize(lc, make(chan *models.AsyncValues)) + assert.NoError(t, err) +} + +func TestHandleReadCommands(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + require := require.New(t) + + expectedValue := "STATUS,L1,0,L2,0,D,0,T,78.58,H,19.54" + expectedType := models.String + + target := CreateControllerBoardDriver(t, true, true, expectedValue) + + request := models.CommandRequest{ + DeviceResourceName: "L1", + Attributes: nil, + Type: 0, + } + + actual, err := target.HandleReadCommands("ControllerBoard", nil, []models.CommandRequest{request}) + require.NoError(err) + require.NotNil(actual) + require.True(len(actual) > 0, "No results returned") + assert.Equal(expectedType, actual[0].Type) + + actualValue, err := actual[0].StringValue() + require.NoError(err) + assert.Equal(expectedValue, actualValue) +} + +func TestHandleWriteCommands(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + require := require.New(t) + + testCases := []struct { + Name string + Resource string + CommandValue interface{} + ExpectedError error + }{ + {Name: "HandleWriteCommands - lock1 with 1", Resource: lock1, CommandValue: int32(0x01000000), ExpectedError: nil}, + {Name: "HandleWriteCommands - lock2 with 1", Resource: lock2, CommandValue: int32(0x01000000), ExpectedError: nil}, + {Name: "HandleWriteCommands - lock1 with 0", Resource: lock1, CommandValue: int32(0x00000000), ExpectedError: nil}, + {Name: "HandleWriteCommands - lock2 with 0", Resource: lock2, CommandValue: int32(0x00000000), ExpectedError: nil}, + {Name: "HandleWriteCommands - getStatus", Resource: getStatus, CommandValue: nil, ExpectedError: nil}, + {Name: "HandleWriteCommands - displayRow0", Resource: displayRow0, CommandValue: "Row 0", ExpectedError: nil}, + {Name: "HandleWriteCommands - displayRow1", Resource: displayRow1, CommandValue: "Row 1", ExpectedError: nil}, + {Name: "HandleWriteCommands - displayRow2", Resource: displayRow2, CommandValue: "Row 2", ExpectedError: nil}, + {Name: "HandleWriteCommands - displayRow3", Resource: displayRow3, CommandValue: "Row 3", ExpectedError: nil}, + {Name: "HandleWriteCommands - displayReset", Resource: displayReset, CommandValue: nil, ExpectedError: nil}, + {Name: "HandleWriteCommands - setHumidity", Resource: setHumidity, CommandValue: "86", ExpectedError: nil}, + {Name: "HandleWriteCommands - setTemperature", Resource: setTemperature, CommandValue: "102", ExpectedError: nil}, + {Name: "HandleWriteCommands - setDoorClosed", Resource: setDoorClosed, CommandValue: "Yes", ExpectedError: nil}, + {Name: "HandleWriteCommands - Unknown Command", Resource: "unknown", ExpectedError: fmt.Errorf("unknown command received: 'unknown'")}, + } + + target := CreateControllerBoardDriver(t, true, true, "") + + for _, testCase := range testCases { + t.Run(testCase.Name, func(t *testing.T) { + var params []*models.CommandValue + var commandValue *models.CommandValue + var err error + + if testCase.CommandValue != nil { + if reflect.TypeOf(testCase.CommandValue).Kind() == reflect.String { + commandValue = models.NewStringValue(testCase.Resource, 0, testCase.CommandValue.(string)) + } else { + value, ok := testCase.CommandValue.(int32) + require.True(ok) + commandValue, err = models.NewInt32Value(testCase.Resource, 0, value) + require.NoError(err) + } + } else { + commandValue = &models.CommandValue{ + DeviceResourceName: testCase.Resource, + } + } + + params = append(params, commandValue) + + actualError := target.HandleWriteCommands("ControllerBoard", nil, nil, params) + + if testCase.ExpectedError != nil { + require.Error(actualError) + assert.Equal(testCase.ExpectedError, actualError) + } else { + require.NoError(actualError) + } + }) + } +} + +func CreateControllerBoardDriver(t *testing.T, virtual bool, initialize bool, expectedStatus string) *ControllerBoardDriver { + var err error + // use community-recommended shorthand (known name clash) + require := require.New(t) + + target := &ControllerBoardDriver{ + lc: lc, + config: &device.Config{ + VirtualControllerBoard: virtual, + }, + } + + if initialize { + err = target.Initialize(lc, make(chan *models.AsyncValues)) + require.NoError(err) + + virtual, ok := target.controllerBoard.(*device.ControllerBoardVirtual) + require.True(ok) + virtual.DevStatus = expectedStatus + } + + return target +} diff --git a/ds-controller-board/go.mod b/ds-controller-board/go.mod new file mode 100644 index 0000000..96781a1 --- /dev/null +++ b/ds-controller-board/go.mod @@ -0,0 +1,15 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +module ds-controller-board + +go 1.12 + +require ( + github.com/creack/goselect v0.1.0 // indirect + github.com/edgexfoundry/device-sdk-go v1.1.1 + github.com/edgexfoundry/go-mod-core-contracts v0.1.31 + github.com/intel-iot-devkit/automated-checkout-utilities v1.0.0 + github.com/stretchr/testify v1.5.1 + go.bug.st/serial.v1 v0.0.0-20180827123349-5f7892a7bb45 +) diff --git a/ds-controller-board/main.go b/ds-controller-board/main.go new file mode 100644 index 0000000..5bf10ba --- /dev/null +++ b/ds-controller-board/main.go @@ -0,0 +1,21 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + + +package main + +import ( + "ds-controller-board/driver" + + "github.com/edgexfoundry/device-sdk-go/pkg/startup" +) + +const ( + version string = "1.0" + serviceName string = "ds-controller-board" +) + +func main() { + d := driver.NewControllerBoardDeviceDriver() + startup.Bootstrap(serviceName, version, d) +} diff --git a/ds-controller-board/res/configuration.toml b/ds-controller-board/res/configuration.toml new file mode 100644 index 0000000..b80eb75 --- /dev/null +++ b/ds-controller-board/res/configuration.toml @@ -0,0 +1,78 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +[Writable] +LogLevel = "INFO" + +[Service] +Host = "localhost" +Port = 8080 +ConnectRetries = 100 +Labels = [] +OpenMsg = "device controller board started" +ReadMaxLimit = 256 +Timeout = 5000 +EnableAsyncReadings = true +AsyncBufferSize = 16 + +[Registry] +Host = "localhost" +Port = 8500 +CheckInterval = "10s" +FailLimit = 3 +FailWaitTime = 10 +Type = "consul" + +[Logging] +EnableRemote = true +File = "/edgex/logs/device-random.log" + +[Clients] + [Clients.Data] + Protocol = "http" + Host = "localhost" + Port = 48080 + Timeout = 5000 + + [Clients.Metadata] + Protocol = "http" + Host = "localhost" + Port = 48081 + Timeout = 5000 + + [Clients.Logging] + Protocol = "http" + Host = "localhost" + Port = 48061 + +[Device] + DataTransform = true + InitCmd = "" + InitCmdArgs = "" + MaxCmdOps = 128 + MaxCmdValueLen = 256 + RemoveCmd = "" + RemoveCmdArgs = "" + ProfilesDir = "./res" + +[Driver] + VID = "2341" + PID = "8037" + DisplayTimeout = "10s" + LockTimeout = "30s" + VirtualControllerBoard = "true" + +# Pre-define Devices +[[DeviceList]] + Name = "ds-controller-board" + Profile = "ds-controller-board" + Description = "ds-controller-board-description" + Labels = [ "ds-controller-board-label" ] + [DeviceList.Protocols] + [DeviceList.Protocols.other] + Address = "device-scale-01" + Port = "300" + [[DeviceList.AutoEvents]] + Frequency = "3s" + OnChange = true + Resource = "controller-board-status" diff --git a/ds-controller-board/res/docker/configuration.toml b/ds-controller-board/res/docker/configuration.toml new file mode 100644 index 0000000..f842e16 --- /dev/null +++ b/ds-controller-board/res/docker/configuration.toml @@ -0,0 +1,77 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +[Writable] +LogLevel = "INFO" + +[Service] +Host = "ds-controller-board" +Port = 48097 +ConnectRetries = 100 +Labels = [] +OpenMsg = "device controller board started" +ReadMaxLimit = 256 +Timeout = 5000 +EnableAsyncReadings = true +AsyncBufferSize = 16 + +[Registry] +Host = "edgex-core-consul" +Port = 8500 +CheckInterval = "10s" +FailLimit = 3 +FailWaitTime = 10 +Type = "consul" + +[Logging] +EnableRemote = true + +[Clients] + [Clients.Data] + Host = "edgex-core-data" + Protocol = "http" + Port = 48080 + Timeout = 5000 + + [Clients.Metadata] + Host = "edgex-core-metadata" + Protocol = "http" + Port = 48081 + Timeout = 5000 + + [Clients.Logging] + Host = "edgex-support-logging" + Protocol = "http" + Port = 48061 + +[Device] + DataTransform = true + InitCmd = "" + InitCmdArgs = "" + MaxCmdOps = 128 + MaxCmdValueLen = 256 + RemoveCmd = "" + RemoveCmdArgs = "" + ProfilesDir = "./res" + +[Driver] + VID = "2341" + PID = "8037" + DisplayTimeout = "10s" + LockTimeout = "30s" + VirtualControllerBoard = "true" + +# Pre-define Devices +[[DeviceList]] + Name = "ds-controller-board" + Profile = "ds-controller-board" + Description = "ds-controller-board-description" + Labels = [ "ds-controller-board-label" ] + [DeviceList.Protocols] + [DeviceList.Protocols.other] + Address = "device-scale-01" + Port = "300" + [[DeviceList.AutoEvents]] + Frequency = "3s" + OnChange = true + Resource = "controller-board-status" diff --git a/ds-controller-board/res/ds-controller-board.yaml b/ds-controller-board/res/ds-controller-board.yaml new file mode 100644 index 0000000..3f2920d --- /dev/null +++ b/ds-controller-board/res/ds-controller-board.yaml @@ -0,0 +1,291 @@ +--- +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +name: "ds-controller-board" +manufacturer: "Intel" +model: "ds-controller-board-simulator" +labels: +- "ds-controller-board-label" +description: "A device for reading from controller board" + +deviceResources: +- name: "controller-board-status" + description: "Read controller-board-status" + properties: + value: + { type: "string", readWrite: "RW", defaultValue: "" } + units: + { type: "string", readWrite: "RW", defaultValue: "" } + +- name: "getStatus" + description: "getStatus from controller" + properties: + value: + { type: "string", readWrite: "RW", defaultValue: "" } + units: + { type: "string", readWrite: "RW", defaultValue: "" } + +- name: "lock1" + description: "Read and set lock1" + properties: + value: + { type: "bool", readWrite: "RW", defaultValue: "" } + units: + { type: "bool", readWrite: "RW", defaultValue: "" } + +- name: "lock2" + description: "Read and set lock2" + properties: + value: + { type: "bool", readWrite: "RW", defaultValue: "" } + units: + { type: "bool", readWrite: "RW", defaultValue: "" } + +- name: "displayRow0" + description: "Read and set displayRow0" + properties: + value: + { type: "string", readWrite: "RW", defaultValue: "" } + units: + { type: "string", readWrite: "RW", defaultValue: "" } + +- name: "displayRow1" + description: "Read and set displayRow1" + properties: + value: + { type: "string", readWrite: "RW", defaultValue: "" } + units: + { type: "string", readWrite: "RW", defaultValue: "" } + +- name: "displayRow2" + description: "Read and set displayRow2" + properties: + value: + { type: "string", readWrite: "RW", defaultValue: "" } + units: + { type: "string", readWrite: "RW", defaultValue: "" } + +- name: "displayRow3" + description: "Read and set displayRow3" + properties: + value: + { type: "string", readWrite: "RW", defaultValue: "" } + units: + { type: "string", readWrite: "RW", defaultValue: "" } + +- name: "displayReset" + description: "Reset the display" + properties: + value: + { type: "string", readWrite: "RW", defaultValue: "" } + units: + { type: "string", readWrite: "RW", defaultValue: "" } + +- name: "setHumidity" + description: "Set the humidity value in a Virtual ControllerBoard." + properties: + value: + { type: "string", readWrite: "RW", defaultValue: "" } + units: + { type: "string", readWrite: "RW", defaultValue: "" } + +- name: "setTemperature" + description: "Set the temperature value in a Virtual ControllerBoard." + properties: + value: + { type: "string", readWrite: "RW", defaultValue: "" } + units: + { type: "string", readWrite: "RW", defaultValue: "" } + +- name: "setDoorClosed" + description: "Set the door-closed value in a Virtual ControllerBoard." + properties: + value: + { type: "string", readWrite: "RW", defaultValue: "" } + units: + { type: "string", readWrite: "RW", defaultValue: "" } + +deviceCommands: +- name: "controller-board-status" + get: + - { operation: "get", object: "controller-board-status", property: "value", parameter: "controller-board-status" } + set: + - { operation: "set", object: "controller-board-status", property: "value", parameter: "controller-board-status" } + +- name: "getStatus" + set: + - { operation: "set", object: "getStatus", property: "value", parameter: "getStatus" } + +- name: "lock1" + set: + - { operation: "set", object: "lock1", property: "value", parameter: "lock1" } + +- name: "lock2" + set: + - { operation: "set", object: "lock2", property: "value", parameter: "lock2" } + +- name: "displayRow0" + set: + - { operation: "set", object: "displayRow0", property: "value", parameter: "displayRow0" } + +- name: "displayRow1" + set: + - { operation: "set", object: "displayRow1", property: "value", parameter: "displayRow1" } + +- name: "displayRow2" + set: + - { operation: "set", object: "displayRow2", property: "value", parameter: "displayRow2" } + +- name: "displayRow3" + set: + - { operation: "set", object: "displayRow3", property: "value", parameter: "displayRow3" } + +- name: "displayReset" + set: + - { operation: "set", object: "displayReset", property: "value", parameter: "displayReset" } + +- name: "setHumidity" + set: + - { operation: "set", object: "setHumidity", property: "value", parameter: "setHumidity" } + +- name: "setTemperature" + set: + - { operation: "set", object: "setTemperature", property: "value", parameter: "setTemperature" } + +- name: "setDoorClosed" + set: + - { operation: "set", object: "setDoorClosed", property: "value", parameter: "setDoorClosed" } + +coreCommands: +- name: "getStatus" + put: + path: "/api/v1/device/{deviceId}/getStatus" + parameterNames: ["getStatus"] + responses: + - + code: "200" + description: "" + - + code: "503" + description: "service unavailable" + +- name: "lock1" + put: + path: "/api/v1/device/{deviceId}/lock1" + parameterNames: ["lock1"] + responses: + - + code: "200" + description: "" + - + code: "503" + description: "service unavailable" + +- name: "lock2" + put: + path: "/api/v1/device/{deviceId}/lock2" + parameterNames: ["lock2"] + responses: + - + code: "200" + description: "" + - + code: "503" + description: "service unavailable" + +- name: "displayRow0" + put: + path: "/api/v1/device/{deviceId}/displayRow0" + parameterNames: ["displayRow0"] + responses: + - + code: "200" + description: "" + - + code: "503" + description: "service unavailable" + +- name: "displayRow1" + put: + path: "/api/v1/device/{deviceId}/displayRow1" + parameterNames: ["displayRow1"] + responses: + - + code: "200" + description: "" + - + code: "503" + description: "service unavailable" + +- name: "displayRow2" + put: + path: "/api/v1/device/{deviceId}/displayRow2" + parameterNames: ["displayRow2"] + responses: + - + code: "200" + description: "" + - + code: "503" + description: "service unavailable" + +- name: "displayRow3" + put: + path: "/api/v1/device/{deviceId}/displayRow3" + parameterNames: ["displayRow3"] + responses: + - + code: "200" + description: "" + - + code: "503" + description: "service unavailable" + +- name: "displayReset" + put: + path: "/api/v1/device/{deviceId}/displayReset" + parameterNames: ["displayReset"] + responses: + - + code: "200" + description: "" + - + code: "503" + description: "service unavailable" + +- name: "setHumidity" + put: + path: "/api/v1/device/{deviceId}/setHumidity" + parameterNames: ["setHumidity"] + responses: + - + code: "200" + description: "" + - + code: "503" + description: "service unavailable" + +- name: "setTemperature" + put: + path: "/api/v1/device/{deviceId}/setTemperature" + parameterNames: ["setTemperature"] + responses: + - + code: "200" + description: "" + - + code: "503" + description: "service unavailable" + +- name: "setDoorClosed" + put: + path: "/api/v1/device/{deviceId}/setDoorClosed" + parameterNames: ["setDoorClosed"] + responses: + - + code: "200" + description: "" + - + code: "503" + description: "service unavailable" \ No newline at end of file diff --git a/ds-inference-mock/.gitignore b/ds-inference-mock/.gitignore new file mode 100644 index 0000000..5a6636d --- /dev/null +++ b/ds-inference-mock/.gitignore @@ -0,0 +1,16 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, build with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Backups created by vscode +*.py~ +*~ diff --git a/ds-inference-mock/Dockerfile b/ds-inference-mock/Dockerfile new file mode 100644 index 0000000..4e9115d --- /dev/null +++ b/ds-inference-mock/Dockerfile @@ -0,0 +1,9 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +FROM python:alpine3.9 + +RUN pip install paho-mqtt +COPY inference_mock.py /inference_mock.py + +ENTRYPOINT ["/inference_mock.py"] diff --git a/ds-inference-mock/LICENSE b/ds-inference-mock/LICENSE new file mode 100644 index 0000000..dbff156 --- /dev/null +++ b/ds-inference-mock/LICENSE @@ -0,0 +1,31 @@ +BSD 3-Clause License + +Copyright © 2020, Intel Corporation +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/ds-inference-mock/Makefile b/ds-inference-mock/Makefile new file mode 100644 index 0000000..6052049 --- /dev/null +++ b/ds-inference-mock/Makefile @@ -0,0 +1,28 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +# HTTPS_PROXY=http://proxy-chain.site.com:912 +# HTTP_PROXY=http://proxy-chain.site.com:911 + +MICROSERVICE=automated-checkout/ds-inference-mock + +DOCKERS=ds-inference-mock + +.PHONY: $(DOCKERS) + +build: $(DOCKERS) + +build: + docker build \ + --build-arg http_proxy \ + --build-arg https_proxy \ + -f Dockerfile \ + -t $(MICROSERVICE):dev \ + . + +run: $(DOCKERS) + docker run \ + -ti --rm \ + --name inference-mock \ + --mount type=bind,source="$(PWD)"/sku_delta_sequence.json,target=/sku_delta_sequence.json \ + $(MICROSERVICE):dev --broker mqtt-broker --port 1883 --test_sequence sku_delta_sequence.json diff --git a/ds-inference-mock/inference_mock.py b/ds-inference-mock/inference_mock.py new file mode 100755 index 0000000..b2bebb9 --- /dev/null +++ b/ds-inference-mock/inference_mock.py @@ -0,0 +1,137 @@ +#!/usr/bin/env python3 + +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +import os +import sys +import time +import json +import sched +import random +import collections +from argparse import ArgumentParser + +import paho.mqtt.client as mqtt + +CMD_HEARTBEAT='inferenceHeartbeat' +CMD_HEARTBEAT_RESPONSE='inferencePong' +CMD_CV_TRIGGER='inferenceDoorStatus' +CMD_SKU_DELTA='inferenceSkuDelta' +STATUS_DOOR_OPEN='false' +STATUS_DOOR_CLOSE='true' + +def build_argparser(): + parser = ArgumentParser() + parser.add_argument("-b", "--broker", help="MQTT broker IP", required=True, type=str) + parser.add_argument("-p", "--port", help="MQTT broker port", required=True, type=int) + parser.add_argument("-s", "--test_sequence", help="JSON file specifying the sequence of responses to send back to EdgeX", required=True, type=str) + parser.add_argument("-k", "--keepalive", help="MQTT keepalive", default=60, type=int) + parser.add_argument("-c", "--command_topic", help="Command topic. MQTT topic from which EdgeX commands are received.", \ + default="Inference/CommandTopic", type=str) + parser.add_argument("-r", "--response_topic", help="Response topic. MQTT topic to which EdgeX commands are acknowledged.", \ + default="Inference/ResponseTopic", type=str) + parser.add_argument("-d", "--data_topic", help="Response topic. MQTT topic to which SKU delta are published.", \ + default="Inference/DataTopic", type=str) + parser.add_argument("-D", "--delay", help="Number of seconds to delay SKU delta response", + default=5, type=int) + + return parser + +class SKU_Deltas(): + def __init__(self, filename): + with open(filename, 'r') as fdin: + try: + self.sku_deltas = json.load(fdin) + except json.JSONDecodeError as e: + print(f'Error parsing {filename}!') + print(f'{e.msg} at position {e.pos}') + sys.exit(-1) + if not isinstance(self.sku_deltas, list): + self.sku_deltas = [self.sku_deltas] + self.idx = 0 + def __next__(self): + item_list = [] + for k, v in self.sku_deltas[self.idx].items(): + item_list.append({'SKU':k, 'delta':v}) + self.idx = (self.idx + 1)%len(self.sku_deltas) + return item_list + +def main(): + + sch = sched.scheduler(time.time, time.sleep) + args = build_argparser().parse_args() + sku_deltas = SKU_Deltas(args.test_sequence) + + def on_connect(client, userdata, flags, rc): + print(f"Connected to broker {args.broker}:{args.port}") + client.subscribe(args.command_topic) + + def publish_sku_delta(): + """ + Publish SKU delta to EdgeX + """ + sku_delta_json = json.dumps(next(sku_deltas)) + + msg_dict = { + "name":"Inference-MQTT-device", + "cmd":CMD_SKU_DELTA, + "method":"get", + CMD_SKU_DELTA: sku_delta_json + } + print(f"Sending SKU Delta on {args.data_topic} {msg_dict}") + client.publish(args.data_topic, payload=json.dumps(msg_dict)) + + def handle_ping(msg_dict): + """ + Response to heartbeat messages + """ + msg_dict[CMD_HEARTBEAT] = CMD_HEARTBEAT_RESPONSE + return msg_dict + + def handle_trigger(msg_dict): + """ + Response to the trigger command and schedule the + SKU delta message for args.delay seconds + """ + # Only send SKU delta on door close + if msg_dict[CMD_CV_TRIGGER] == STATUS_DOOR_CLOSE: + sch.enter(args.delay, 1, publish_sku_delta) + msg_dict[CMD_CV_TRIGGER] = "Got it!" + return msg_dict + + def on_message(client, userdata, msg): + """ + This callback is invoke for every MQTT messages we received + """ + if msg.topic == args.command_topic: + msg_dict = json.loads(msg.payload) + print(f"Message received on {msg.topic} {str(msg.payload)}") + + if msg_dict["cmd"] == CMD_HEARTBEAT: + msg_dict2 = handle_ping(msg_dict) + elif msg_dict["cmd"] == CMD_CV_TRIGGER: + msg_dict2 = handle_trigger(msg_dict) + + print(f"Sending response on {args.response_topic} {msg_dict2}") + client.publish(args.response_topic, payload=json.dumps(msg_dict2)) + + client = mqtt.Client() + client.on_connect = on_connect + client.on_message = on_message + + print(f"Trying to connect to {args.broker}:{args.port}") + client.connect(args.broker, args.port, args.keepalive) + + while True: + try: + client.loop() + sch.run(blocking=False) + except KeyboardInterrupt: + break + + client.disconnect() + print('Done!') + +if __name__ == "__main__": + main() diff --git a/ds-inference-mock/sku_delta_sequence.json b/ds-inference-mock/sku_delta_sequence.json new file mode 100644 index 0000000..806d9d0 --- /dev/null +++ b/ds-inference-mock/sku_delta_sequence.json @@ -0,0 +1 @@ +[{"4900002470":24,"1200010735":18,"1200050408":6,"7800009257":24,"4900002762":32,"1200081119":12,"1200018402":6,"4900002469":24,"490440":72},{"1200050408":-3,"7800009257":-1},{"1200081119":-2},{"1200081119":-6},{"7800009257":-1,"1200010735":-2},{"4900002469":-1},{"490440":-10},{"490440":-1,"1200081119":-3,"4900002762":-5}] \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..e489334 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,32 @@ +site_name: Automated Checkout +docs_dir: ./docs_src +site_dir: ./docs +use_directory_urls: false +theme: + name: 'material' +plugins: [] +nav: + - 'index.md' + - Phases: + - './phases/phase1.md' + - './phases/phase2.md' + - './phases/phase3.md' + - Additional Documentation: + - Automated Checkout Services: + - './automated-checkout-services/device_services.md' + - './automated-checkout-services/application_services.md' + - './automated-checkout-services/micro_services.md' + - 'events.md' + - 'configuration.md' + - 'modifying_source_code.md' + - 'notifications.md' + - 'references.md' + - 'troubleshooting.md' +extra_css: + - 'https://fonts.googleapis.com/icon?family=Material+Icons' + - './stylesheets/extra.css' +extra_javascript: + - 'https://unpkg.com/lunr/lunr.js' +markdown_extensions: + - codehilite + - admonition diff --git a/ms-authentication/.gitignore b/ms-authentication/.gitignore new file mode 100644 index 0000000..0a2b352 --- /dev/null +++ b/ms-authentication/.gitignore @@ -0,0 +1,23 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, build with `go test -c` +*.test +main +ms-authentication +test.txt +go.sum +.vscode/* + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +ms-authentication +main +logs + +routes/*.json diff --git a/ms-authentication/.golangci.yml b/ms-authentication/.golangci.yml new file mode 100644 index 0000000..00ec54e --- /dev/null +++ b/ms-authentication/.golangci.yml @@ -0,0 +1,28 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +run: + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 5m +linters-settings: + misspell: + locale: US +linters: + enable: + - bodyclose + - errcheck + - goconst + - golint + - govet + - gosimple + - ineffassign + - misspell + - staticcheck + - structcheck + - typecheck + - unused + - unconvert + - unparam + - varcheck + disable-all: true + fast: true diff --git a/ms-authentication/Dockerfile b/ms-authentication/Dockerfile new file mode 100644 index 0000000..3a86b24 --- /dev/null +++ b/ms-authentication/Dockerfile @@ -0,0 +1,29 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +FROM automated-checkout/build:latest AS builder + +LABEL license='SPDX-License-Identifier: BSD-3-Clause' \ + copyright='Copyright (c) 2020: Intel' + +RUN mkdir ms-authentication +WORKDIR /usr/local/bin/ms-authentication/ +COPY . . + +# Compile the code +RUN make gobuild + +# Next image - Copy built Go binary into new workspace +FROM alpine + +LABEL license='SPDX-License-Identifier: BSD-3-Clause' \ + copyright='Copyright (c) 2020: Intel' + +RUN apk --no-cache add zeromq +COPY --from=builder /usr/local/bin/ms-authentication/res/docker/configuration.toml /res/docker/configuration.toml +COPY --from=builder /usr/local/bin/ms-authentication/main /ms-authentication +COPY --from=builder /usr/local/bin/ms-authentication/cards.json /cards.json +COPY --from=builder /usr/local/bin/ms-authentication/accounts.json /accounts.json +COPY --from=builder /usr/local/bin/ms-authentication/people.json /people.json + +CMD [ "/ms-authentication","--profile=docker","--confdir=/res", "-r"] diff --git a/ms-authentication/LICENSE b/ms-authentication/LICENSE new file mode 100644 index 0000000..dbff156 --- /dev/null +++ b/ms-authentication/LICENSE @@ -0,0 +1,31 @@ +BSD 3-Clause License + +Copyright © 2020, Intel Corporation +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/ms-authentication/Makefile b/ms-authentication/Makefile new file mode 100644 index 0000000..6675ed6 --- /dev/null +++ b/ms-authentication/Makefile @@ -0,0 +1,45 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +.PHONY: build gobuild run gorun stop test lint + +MICROSERVICE=automated-checkout/ms-authentication + +build: + docker build --rm \ + --build-arg http_proxy \ + --build-arg https_proxy \ + -f Dockerfile \ + -t $(MICROSERVICE):dev \ + . + +gobuild: + CGO_ENABLED=1 GOOS=linux go build -ldflags='-s -w' -a -installsuffix cgo main.go + +run: + docker run \ + --rm \ + -p 48096:48096 \ + $(MICROSERVICE):dev + +gorun: + ./main + +stop: + docker rm -f $(MICROSERVICE):dev + +test: + go test -test.v -cover ./... + +testHTML: + go test -test.v -coverprofile=test_coverage.out ./... && \ + go tool cover -html=test_coverage.out + +GOLANGCI_VERSION := $(shell golangci-lint --version 2>/dev/null) + +lint: +ifdef GOLANGCI_VERSION + golangci-lint run +else + @echo "golangci-lint not found. Please refer to the README documentation for proper installation" +endif diff --git a/ms-authentication/accounts.json b/ms-authentication/accounts.json new file mode 100644 index 0000000..22e9e3e --- /dev/null +++ b/ms-authentication/accounts.json @@ -0,0 +1,39 @@ +{ + "accounts": [{ + "accountID": 1, + "address": "1234 Somewhere Blvd", + "creditCardNumber": "1234123412341234", + "phoneNumber": "5554441234", + "emailAddress": "someone@site.com", + "createdAt": "1560815799", + "updatedAt": "1560815799", + "isActive": true + }, { + "accountID": 2, + "address": "1234 Somewhere Blvd", + "creditCardNumber": "1234123412341234", + "phoneNumber": "5554441234", + "emailAddress": "someone@site.com", + "createdAt": "1560815799", + "updatedAt": "1560815799", + "isActive": true + }, { + "accountID": 3, + "address": "1234 Somewhere Blvd", + "creditCardNumber": "1234123412341234", + "phoneNumber": "5554441234", + "emailAddress": "someone@site.com", + "createdAt": "1560815799", + "updatedAt": "1560815799", + "isActive": true + }, { + "accountID": 4, + "address": "1234 Somewhere Blvd", + "creditCardNumber": "1234123412341234", + "phoneNumber": "5554441234", + "emailAddress": "someone@site.com", + "createdAt": "1560815799", + "updatedAt": "1560815799", + "isActive": true + }] +} \ No newline at end of file diff --git a/ms-authentication/cards.json b/ms-authentication/cards.json new file mode 100644 index 0000000..0395fa2 --- /dev/null +++ b/ms-authentication/cards.json @@ -0,0 +1,208 @@ +{ + "cards": [{ + "cardId": "0003292356", + "roleId": 1, + "isValid": true, + "personId": 5, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003292371", + "roleId": 1, + "isValid": true, + "personId": 2, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003621873", + "roleId": 1, + "isValid": true, + "personId": 3, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003621895", + "roleId": 1, + "isValid": true, + "personId": 2, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003621892", + "roleId": 1, + "isValid": true, + "personId": 3, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003278363", + "roleId": 3, + "isValid": true, + "personId": 7, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003278380", + "roleId": 1, + "isValid": true, + "personId": 1, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003278384", + "roleId": 2, + "isValid": true, + "personId": 7, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003278385", + "roleId": 3, + "isValid": true, + "personId": 1, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003278403", + "roleId": 3, + "isValid": true, + "personId": 6, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003278408", + "roleId": 1, + "isValid": true, + "personId": 1, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003278425", + "roleId": 1, + "isValid": true, + "personId": 1, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003292115", + "roleId": 3, + "isValid": true, + "personId": 1, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003292312", + "roleId": 1, + "isValid": true, + "personId": 1, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003292378", + "roleId": 1, + "isValid": true, + "personId": 1, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003293374", + "roleId": 2, + "isValid": true, + "personId": 1, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003293419", + "roleId": 2, + "isValid": true, + "personId": 1, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003293622", + "roleId": 1, + "isValid": true, + "personId": 1, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003293641", + "roleId": 1, + "isValid": true, + "personId": 1, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003293644", + "roleId": 3, + "isValid": true, + "personId": 1, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003278200", + "roleId": 1, + "isValid": true, + "personId": 1, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003621888", + "roleId": 2, + "isValid": true, + "personId": 2, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003621866", + "roleId": 2, + "isValid": true, + "personId": 1, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003278359", + "roleId": 1, + "isValid": true, + "personId": 2, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003219615", + "roleId": 1, + "isValid": true, + "personId": 2, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0003287028", + "roleId": 1, + "isValid": true, + "personId": 2, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0000000001", + "roleId": 0, + "isValid": true, + "personId": 2, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0000000002", + "roleId": 1, + "isValid": false, + "personId": 2, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0000000003", + "roleId": 1, + "isValid": true, + "personId": 0, + "createdAt": "1560815799", + "updatedAt": "1560815799" + }, { + "cardId": "0000000004" + }] +} \ No newline at end of file diff --git a/ms-authentication/go.mod b/ms-authentication/go.mod new file mode 100644 index 0000000..b96acb1 --- /dev/null +++ b/ms-authentication/go.mod @@ -0,0 +1,14 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +module ms-authentication + +go 1.12 + +require ( + github.com/edgexfoundry/app-functions-sdk-go v1.0.0 + github.com/edgexfoundry/go-mod-core-contracts v0.1.25 + github.com/gorilla/mux v1.7.2 + github.com/intel-iot-devkit/automated-checkout-utilities v1.0.0 + github.com/stretchr/testify v1.5.1 +) diff --git a/ms-authentication/main.go b/ms-authentication/main.go new file mode 100644 index 0000000..f677153 --- /dev/null +++ b/ms-authentication/main.go @@ -0,0 +1,49 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package main + +import ( + "fmt" + "os" + + "ms-authentication/routes" + + "github.com/edgexfoundry/app-functions-sdk-go/appsdk" +) + +const ( + serviceKey = "ms-authentication" +) + +func main() { + // Create an instance of the EdgeX SDK and initialize it. + edgexSdk := &appsdk.AppFunctionsSDK{ServiceKey: serviceKey} + if err := edgexSdk.Initialize(); err != nil { + edgexSdk.LoggingClient.Error(fmt.Sprintf("SDK initialization failed: %v\n", err)) + os.Exit(-1) + } + + // How to access the application's specific configuration settings. + appSettings := edgexSdk.ApplicationSettings() + if appSettings == nil { + edgexSdk.LoggingClient.Error("No application settings found") + os.Exit(-1) + } + + if err := edgexSdk.AddRoute("/authentication/{cardid}", routes.AuthenticationGet, "GET"); err != nil { + edgexSdk.LoggingClient.Error(fmt.Sprintf("Unable to add /authentication/{cardid} GET route: %v\n", err)) + os.Exit(-1) + } + + // Tell the SDK to "start" and begin listening for events to trigger the pipeline. + err := edgexSdk.MakeItRun() + if err != nil { + edgexSdk.LoggingClient.Error("MakeItRun returned error: ", err.Error()) + os.Exit(-1) + } + + // Do any required cleanup here + + os.Exit(0) +} diff --git a/ms-authentication/people.json b/ms-authentication/people.json new file mode 100644 index 0000000..c033f6e --- /dev/null +++ b/ms-authentication/people.json @@ -0,0 +1,52 @@ +{ + "people": [{ + "personID": 1, + "accountID": 1, + "fullName": "Test Person 1", + "createdAt": "1560815799", + "updatedAt": "1560815799", + "IsActive": true + }, { + "personID": 2, + "accountID": 2, + "fullName": "Test Person 2", + "createdAt": "1560815799", + "updatedAt": "1560815799", + "IsActive": true + }, { + "personID": 3, + "accountID": 3, + "fullName": "Test Person 3", + "createdAt": "1560815799", + "updatedAt": "1560815799", + "IsActive": true + }, { + "personID": 4, + "accountID": 4, + "fullName": "Test Person 4", + "createdAt": "1560815799", + "updatedAt": "1560815799", + "IsActive": true + }, { + "personID": 5, + "accountID": 5, + "fullName": "Test Person 5", + "createdAt": "1560815799", + "updatedAt": "1560815799", + "IsActive": true + }, { + "personID": 6, + "accountID": 6, + "fullName": "Test Person 6", + "createdAt": "1560815799", + "updatedAt": "1560815799", + "IsActive": true + }, { + "personID": 7, + "accountID": 7, + "fullName": "Test Person 7", + "createdAt": "1560815799", + "updatedAt": "1560815799", + "IsActive": true + }] +} \ No newline at end of file diff --git a/ms-authentication/res/configuration.toml b/ms-authentication/res/configuration.toml new file mode 100644 index 0000000..894cb98 --- /dev/null +++ b/ms-authentication/res/configuration.toml @@ -0,0 +1,43 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +[Writable] +LogLevel = 'INFO' + +[Service] +BootTimeout = '30s' +ClientMonitor = '15s' +CheckInterval = '10s' +Host = 'localhost' +Port = 48096 +Protocol = 'http' +ReadMaxLimit = 100 +StartupMsg = 'This microservice checks if ID numbers from REST requests are authenticated' +Timeout = '30s' + +[Registry] +Host = "localhost" +Port = 8500 +Type = 'consul' + +[MessageBus] +Type = 'zero' + [MessageBus.PublishHost] + Host = '*' + Port = 5564 + Protocol = 'tcp' + [MessageBus.SubscribeHost] + Host = 'localhost' + Port = 5563 + Protocol = 'tcp' + +[Logging] +EnableRemote = false +File = './logs/ms-authentication-publish.log' + +[Binding] +Type="http" +SubscribeTopic="" +PublishTopic="" + +[ApplicationSettings] diff --git a/ms-authentication/res/docker/configuration.toml b/ms-authentication/res/docker/configuration.toml new file mode 100644 index 0000000..d7a7e67 --- /dev/null +++ b/ms-authentication/res/docker/configuration.toml @@ -0,0 +1,48 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +[Writable] +LogLevel = 'INFO' + +[Service] +BootTimeout = '30s' +ClientMonitor = '15s' +CheckInterval = '10s' +Host = 'ms-authentication' +Port = 48096 +Protocol = 'http' +ReadMaxLimit = 100 +StartupMsg = 'This microservice checks if ID numbers from REST requests are authenticated' +Timeout = '30s' + +[Clients] + [Clients.Logging] + Host = "edgex-support-logging" + Protocol = "http" + Port = 48061 + +[Registry] +Host = "edgex-core-consul" +Port = 8500 +Type = 'consul' + +[MessageBus] +Type = 'zero' + [MessageBus.PublishHost] + Host = '*' + Port = 5564 + Protocol = 'tcp' + [MessageBus.SubscribeHost] + Host = 'edgex-core-data' + Port = 5563 + Protocol = 'tcp' + +[Logging] +EnableRemote = true + +[Binding] +Type="http" +SubscribeTopic="" +PublishTopic="" + +[ApplicationSettings] diff --git a/ms-authentication/routes/common.go b/ms-authentication/routes/common.go new file mode 100644 index 0000000..0cb501e --- /dev/null +++ b/ms-authentication/routes/common.go @@ -0,0 +1,225 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "errors" + + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +// PeopleFileName is the name of the respective struct data file that +// contains sample authentication data +const PeopleFileName = "people.json" + +// AccountsFileName is the name of the respective struct data file that +// contains sample authentication data +const AccountsFileName = "accounts.json" + +// CardsFileName is the name of the respective struct data file that +// contains sample authentication data +const CardsFileName = "cards.json" + +// WritePeople writes data to the respective JSON file +func (people *People) WritePeople() (err error) { + return utilities.WriteToJSONFile(PeopleFileName, people, 0644) +} + +// WriteAccounts writes data to the respective JSON file +func (accounts *Accounts) WriteAccounts() (err error) { + return utilities.WriteToJSONFile(AccountsFileName, accounts, 0644) +} + +// WriteCards writes data to the respective JSON file +func (cards *Cards) WriteCards() (err error) { + return utilities.WriteToJSONFile(CardsFileName, cards, 0644) +} + +// DeletePeople writes an empty list to the respective JSON file +func DeletePeople() (err error) { + return utilities.WriteToJSONFile(PeopleFileName, People{People: []Person{}}, 0644) +} + +// DeleteAccounts writes an empty list to the respective JSON file +func DeleteAccounts() (err error) { + return utilities.WriteToJSONFile(AccountsFileName, Accounts{Accounts: []Account{}}, 0644) +} + +// DeleteCards writes an empty list to the respective JSON file +func DeleteCards() (err error) { + return utilities.WriteToJSONFile(CardsFileName, Cards{Cards: []Card{}}, 0644) +} + +// DeletePerson deletes from the list +func (people *People) DeletePerson(personToDelete Person) { + for i, person := range people.People { + if personToDelete.PersonID == person.PersonID { + people.People = append(people.People[:i], people.People[i+1:]...) + return + } + } +} + +// DeleteAccount deletes from the list +func (accounts *Accounts) DeleteAccount(accountToDelete Account) { + for i, account := range accounts.Accounts { + if accountToDelete.AccountID == account.AccountID { + accounts.Accounts = append(accounts.Accounts[:i], accounts.Accounts[i+1:]...) + return + } + } +} + +// DeleteCard deletes from the list +func (cards *Cards) DeleteCard(cardToDelete Card) { + for i, card := range cards.Cards { + if cardToDelete.CardID == card.CardID { + cards.Cards = append(cards.Cards[:i], cards.Cards[i+1:]...) + return + } + } +} + +// GetPeopleData reads the data from the respective JSON file +func GetPeopleData() (people People, err error) { + err = utilities.LoadFromJSONFile(PeopleFileName, &people) + if err != nil { + return people, errors.New( + "Failed to load people from JSON file: " + err.Error(), + ) + } + return +} + +// GetAccountsData reads the data from the respective JSON file +func GetAccountsData() (accounts Accounts, err error) { + err = utilities.LoadFromJSONFile(AccountsFileName, &accounts) + if err != nil { + return accounts, errors.New( + "Failed to load accounts from JSON file: " + err.Error(), + ) + } + return +} + +// GetCardsData reads the data from the respective JSON file +func GetCardsData() (cards Cards, err error) { + err = utilities.LoadFromJSONFile(CardsFileName, &cards) + if err != nil { + return cards, errors.New( + "Failed to load cards from JSON file: " + err.Error(), + ) + } + return +} + +// GetPersonByPersonID queries and returns the respective data +func (people *People) GetPersonByPersonID(personID int) (person Person) { + for _, person := range people.People { + if person.PersonID == personID { + return person + } + } + return +} + +// GetPersonByAccountID queries and returns the respective data +func (people *People) GetPersonByAccountID(accountID int) (person Person) { + for _, person := range people.People { + if person.AccountID == accountID { + return person + } + } + return +} + +// GetPersonByFullName queries and returns the respective data +func (people *People) GetPersonByFullName(fullName string) (person Person) { + for _, person := range people.People { + if person.FullName == fullName { + return person + } + } + return +} + +// GetAccountByAccountID queries and returns the respective data +func (accounts *Accounts) GetAccountByAccountID(accountID int) (account Account) { + for _, account := range accounts.Accounts { + if account.AccountID == accountID { + return account + } + } + return +} + +// GetAccountByAddress queries and returns the respective data +func (accounts *Accounts) GetAccountByAddress(address string) (account Account) { + for _, account := range accounts.Accounts { + if account.Address == address { + return account + } + } + return +} + +// GetAccountByCreditCardNumber queries and returns the respective data +func (accounts *Accounts) GetAccountByCreditCardNumber(creditCardNumber string) (account Account) { + for _, account := range accounts.Accounts { + if account.CreditCardNumber == creditCardNumber { + return account + } + } + return +} + +// GetAccountByPhoneNumber queries and returns the respective data +func (accounts *Accounts) GetAccountByPhoneNumber(phoneNumber string) (account Account) { + for _, account := range accounts.Accounts { + if account.PhoneNumber == phoneNumber { + return account + } + } + return +} + +// GetAccountByEmailAddress queries and returns the respective data +func (accounts *Accounts) GetAccountByEmailAddress(emailAddress string) (account Account) { + for _, account := range accounts.Accounts { + if account.EmailAddress == emailAddress { + return account + } + } + return +} + +// GetCardByCardID queries and returns the respective data +func (cards *Cards) GetCardByCardID(cardID string) (card Card) { + for _, card := range cards.Cards { + if card.CardID == cardID { + return card + } + } + return +} + +// GetCardByRoleID queries and returns the respective data +func (cards *Cards) GetCardByRoleID(roleID int) (card Card) { + for _, card := range cards.Cards { + if card.RoleID == roleID { + return card + } + } + return +} + +// GetCardByPersonID queries and returns the respective data +func (cards *Cards) GetCardByPersonID(personID int) (card Card) { + for _, card := range cards.Cards { + if card.PersonID == personID { + return card + } + } + return +} diff --git a/ms-authentication/routes/common_test.go b/ms-authentication/routes/common_test.go new file mode 100644 index 0000000..7121d80 --- /dev/null +++ b/ms-authentication/routes/common_test.go @@ -0,0 +1,577 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "io/ioutil" + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +// TestWritePeople tests the ability to write people +func TestWritePeople(t *testing.T) { + // use community-recommended shorthand (known name clash) + require := require.New(t) + + expectedPeople := setupPeople() + writePeople := expectedPeople.WritePeople() + require.NoError(writePeople, "Failed WritePeople() function") + + actualPeople := People{} + loadJSONFileErr := utilities.LoadFromJSONFile(PeopleFileName, &actualPeople) + require.NoError(loadJSONFileErr, "Failed to load people from file") + + assert.Equal(t, expectedPeople, actualPeople, "Output JSON content mismatch in "+PeopleFileName) +} + +// TestGetPeople tests the ability to get people +func TestGetPeople(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + + expectedPeople := setupPeople() + writePeople := expectedPeople.WritePeople() + require.NoError(t, writePeople, "Failed WritePeople() function") + + actualPeople, err := GetPeopleData() + assert.NoError(err, "Error getting actualPeople") + + assert.Equal(expectedPeople, actualPeople, "Output JSON content mismatch in "+PeopleFileName) +} + +// TestGetPeopleByPersonIDQueryFunctions tests the get people by person ID function +func TestGetPeopleByPersonIDQueryFunctions(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + + expectedPeople := setupPeople() + writePeople := expectedPeople.WritePeople() + require.NoError(t, writePeople, "Failed WritePeople() function") + + tests := []struct { + Name string + PersonID int + ExpectedPerson Person + ShouldMatch bool + }{ + {"Test ByPersonID", 1, expectedPeople.People[0], true}, + {"Test ByPersonID Non Existent Person", -1, expectedPeople.People[0], false}, + } + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + returnedPerson := expectedPeople.GetPersonByPersonID(currentTest.PersonID) + if currentTest.ShouldMatch { + assert.Equal(currentTest.ExpectedPerson, returnedPerson, "Person should match") + } else { + assert.NotEqual(currentTest.ExpectedPerson, returnedPerson, "Person should Not match") + } + }) + } +} + +// TestGetPeopleByAccountIDQueryFunctions tests the get people by account ID function +func TestGetPeopleByAccountIDQueryFunctions(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + + expectedPeople := setupPeople() + writePeople := expectedPeople.WritePeople() + require.NoError(t, writePeople, "Failed WritePeople() function") + + tests := []struct { + Name string + AccountID int + ExpectedPerson Person + ShouldMatch bool + }{ + {"Test ByAccountID", 2, expectedPeople.People[1], true}, + {"Test ByAccountID Non Existent Account", -2, expectedPeople.People[1], false}, + } + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + returnedPerson := expectedPeople.GetPersonByAccountID(currentTest.AccountID) + if currentTest.ShouldMatch { + assert.Equal(currentTest.ExpectedPerson, returnedPerson, "Person should match") + } else { + assert.NotEqual(currentTest.ExpectedPerson, returnedPerson, "Person should Not match") + } + }) + } +} + +// TestGetPeopleByFullNameQueryFunctions tests the get people by full name function +func TestGetPeopleByFullNameQueryFunctions(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + + expectedPeople := setupPeople() + writePeople := expectedPeople.WritePeople() + require.NoError(t, writePeople, "Failed WritePeople() function") + + tests := []struct { + Name string + FullName string + ExpectedPerson Person + ShouldMatch bool + }{ + {"Test ByFullName", "Test Person 3", expectedPeople.People[2], true}, + {"Test ByFullName Non Existent Person", "Non-Existent Test Person 3", expectedPeople.People[2], false}, + } + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + returnedPerson := expectedPeople.GetPersonByFullName(currentTest.FullName) + if currentTest.ShouldMatch { + assert.Equal(currentTest.ExpectedPerson, returnedPerson, "Person should match") + } else { + assert.NotEqual(currentTest.ExpectedPerson, returnedPerson, "Person should Not match") + } + }) + } +} + +// TestDeletePerson tests the ability to delete a person +func TestDeletePerson(t *testing.T) { + expectedPeople := setupPeople() + writePeople := expectedPeople.WritePeople() + require.NoError(t, writePeople, "Failed WritePeople() function") + + deletedPerson := expectedPeople.People[0] + expectedPeople.DeletePerson(expectedPeople.People[0]) + + assert.NotEqual(t, expectedPeople.People[0], deletedPerson, "Deleted person with ID "+strconv.Itoa(expectedPeople.People[0].PersonID)+" but it still exists in the test list") +} + +// TestDeletePeople tests the ability to delete people +func TestDeletePeople(t *testing.T) { + expectedPeople := setupPeople() + writePeople := expectedPeople.WritePeople() + require.NoError(t, writePeople, "Failed WritePeople() function") + + deleteErr := DeletePeople() + assert.NoError(t, deleteErr, "Failed DeletePeople() function") + + actualPeople := People{People: []Person{}} + loadJSONFileErr := utilities.LoadFromJSONFile(PeopleFileName, &actualPeople) + require.NoError(t, loadJSONFileErr, "Failed to load people from file") + + assert.Equal(t, actualPeople, People{People: []Person{}}, "Output JSON content mismatch in "+PeopleFileName) +} + +// TestGetPeopleDataError tests error case for get people data +func TestGetPeopleDataError(t *testing.T) { + expectedPeople := setupPeople() + writePeople := expectedPeople.WritePeople() + require.NoError(t, writePeople, "Failed WritePeople() function") + + writeErr := ioutil.WriteFile(PeopleFileName, []byte("invalid json test"), 0644) + require.NoError(t, writeErr, "Failed to write to test file") + _, err := GetPeopleData() + assert.Error(t, err, "Expected failure calling GetPeopleData() for invalid JSON contents but did not get one") +} + +// TestWriteAccounts tests the ability to write accounts +func TestWriteAccounts(t *testing.T) { + // use community-recommended shorthand (known name clash) + require := require.New(t) + + expectedAccounts := setupAccounts() + writeAccounts := expectedAccounts.WriteAccounts() + require.NoError(writeAccounts, "Failed WriteAccounts() function") + + // load accounts from file to validate + accountsFromFile := Accounts{} + loadJSONFileErr := utilities.LoadFromJSONFile(AccountsFileName, &accountsFromFile) + require.NoError(loadJSONFileErr, "Failed to load accounts from file") + + assert.Equal(t, expectedAccounts, accountsFromFile, "Output JSON content mismatch in "+AccountsFileName) +} + +// TestGetAccounts tests the ability to write accounts +func TestGetAccounts(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + + expectedAccounts := setupAccounts() + writeAccounts := expectedAccounts.WriteAccounts() + require.NoError(t, writeAccounts, "Failed WriteAccounts() function") + + // run GetAccountsData and get the result as JSON + accountsFromFile, err := GetAccountsData() + assert.NoError(err, "Error getting accountsFromFile") + + assert.Equal(expectedAccounts, accountsFromFile, "Output JSON content mismatch in "+AccountsFileName) +} + +// TestGetAccountByAccountIDQueryFunctions tests the get account by account ID functions +func TestGetAccountByAccountIDQueryFunctions(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + + expectedAccounts := setupAccounts() + writeAccounts := expectedAccounts.WriteAccounts() + require.NoError(t, writeAccounts, "Failed WriteAccounts() function") + + tests := []struct { + Name string + AccountID int + ExpectedOutput Account + ShouldMatch bool + }{ + {"Test ByAccountID", 1, expectedAccounts.Accounts[0], true}, + {"Test ByAccountID Non Existent Account", -1, expectedAccounts.Accounts[0], false}, + } + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + returnedAccount := expectedAccounts.GetAccountByAccountID(currentTest.AccountID) + if currentTest.ShouldMatch { + assert.Equal(currentTest.ExpectedOutput, returnedAccount, "Accounts should match") + } else { + assert.NotEqual(currentTest.ExpectedOutput, returnedAccount, "Accounts should Not match") + } + }) + } +} + +// TestGetAccountByAddressQueryFunctions tests the get account by address functions +func TestGetAccountByAddressQueryFunctions(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + + expectedAccounts := setupAccounts() + writeAccounts := expectedAccounts.WriteAccounts() + require.NoError(t, writeAccounts, "Failed WriteAccounts() function") + + tests := []struct { + Name string + Address string + ExpectedOutput Account + ShouldMatch bool + }{ + {"Test ByAddress", "2 Test Lane", expectedAccounts.Accounts[1], true}, + {"Test ByAddress Non Existent Account", "-1 Test Lane", expectedAccounts.Accounts[1], false}, + } + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + returnedAccount := expectedAccounts.GetAccountByAddress(currentTest.Address) + if currentTest.ShouldMatch { + assert.Equal(currentTest.ExpectedOutput, returnedAccount, "Accounts should match") + } else { + assert.NotEqual(currentTest.ExpectedOutput, returnedAccount, "Accounts should Not match") + } + }) + } +} + +// TestGetAccountByCreditCardNumberQueryFunctions tests the get account by credit card number functions +func TestGetAccountByCreditCardNumberQueryFunctions(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + + expectedAccounts := setupAccounts() + writeAccounts := expectedAccounts.WriteAccounts() + require.NoError(t, writeAccounts, "Failed WriteAccounts() function") + + tests := []struct { + Name string + CreditCardNumber string + ExpectedOutput Account + ShouldMatch bool + }{ + {"Test ByCreditCardNumber", "3234 4567 9012 3456", expectedAccounts.Accounts[2], true}, + {"Test ByCreditCardNumber Non Existent Account", "-3234 4567 9012 3456", expectedAccounts.Accounts[2], false}, + } + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + returnedAccount := expectedAccounts.GetAccountByCreditCardNumber(currentTest.CreditCardNumber) + if currentTest.ShouldMatch { + assert.Equal(currentTest.ExpectedOutput, returnedAccount, "Accounts should match") + } else { + assert.NotEqual(currentTest.ExpectedOutput, returnedAccount, "Accounts should Not match") + } + }) + } +} + +// TestGetAccountByPhoneNumberQueryFunctions tests the get account by phone number functions +func TestGetAccountByPhoneNumberQueryFunctions(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + + expectedAccounts := setupAccounts() + writeAccounts := expectedAccounts.WriteAccounts() + require.NoError(t, writeAccounts, "Failed WriteAccounts() function") + + tests := []struct { + Name string + PhoneNumber string + ExpectedOutput Account + ShouldMatch bool + }{ + {"Test ByPhoneNumber", "4234567890", expectedAccounts.Accounts[3], true}, + {"Test ByPhoneNumber Non Existent Account", "-4234567890", expectedAccounts.Accounts[3], false}, + } + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + returnedAccount := expectedAccounts.GetAccountByPhoneNumber(currentTest.PhoneNumber) + if currentTest.ShouldMatch { + assert.Equal(currentTest.ExpectedOutput, returnedAccount, "Accounts should match") + } else { + assert.NotEqual(currentTest.ExpectedOutput, returnedAccount, "Accounts should Not match") + } + }) + } +} + +// TestGetAccountByEmailAddressQueryFunctions tests the get account by Email address functions +func TestGetAccountByEmailAddressQueryFunctions(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + + expectedAccounts := setupAccounts() + writeAccounts := expectedAccounts.WriteAccounts() + require.NoError(t, writeAccounts, "Failed WriteAccounts() function") + + tests := []struct { + Name string + EmailAddress string + ExpectedOutput Account + ShouldMatch bool + }{ + {"Test ByEmailAddress", "test5@example.com", expectedAccounts.Accounts[4], true}, + {"Test ByEmailAddress Non Existent Account", "test-5@example.com", expectedAccounts.Accounts[4], false}, + } + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + returnedAccount := expectedAccounts.GetAccountByEmailAddress(currentTest.EmailAddress) + if currentTest.ShouldMatch { + assert.Equal(currentTest.ExpectedOutput, returnedAccount, "Accounts should match") + } else { + assert.NotEqual(currentTest.ExpectedOutput, returnedAccount, "Accounts should Not match") + } + }) + } +} + +// TestDeleteAccount tests the ability to delete account +func TestDeleteAccount(t *testing.T) { + expectedAccounts := setupAccounts() + writeAccounts := expectedAccounts.WriteAccounts() + require.NoError(t, writeAccounts, "Failed WriteAccounts() function") + + deletedAccount := expectedAccounts.Accounts[0] + expectedAccounts.DeleteAccount(expectedAccounts.Accounts[0]) + + assert.NotEqual(t, expectedAccounts.Accounts[0], deletedAccount, "Deleted account with ID "+strconv.Itoa(expectedAccounts.Accounts[0].AccountID)+" but it still exists in the test list") +} + +// TestDeleteAccounts tests the ability to delete accounts +func TestDeleteAccounts(t *testing.T) { + expectedAccounts := setupAccounts() + writeAccounts := expectedAccounts.WriteAccounts() + require.NoError(t, writeAccounts, "Failed WriteAccounts() function") + + deleteErr := DeleteAccounts() + assert.NoError(t, deleteErr, "Failed DeleteAccounts() function") + + // load accounts from file to validate + accountsFromFile := Accounts{Accounts: []Account{}} + loadJSONFileErr := utilities.LoadFromJSONFile(AccountsFileName, &accountsFromFile) + require.NoError(t, loadJSONFileErr, "Failed to load accounts from file") + + assert.Equal(t, accountsFromFile, Accounts{Accounts: []Account{}}, "Output JSON content mismatch in "+AccountsFileName) +} + +// TestGetAccountsDataError tests error case for get accounts data +func TestGetAccountsDataError(t *testing.T) { + expectedAccounts := setupAccounts() + writeAccounts := expectedAccounts.WriteAccounts() + require.NoError(t, writeAccounts, "Failed WriteAccounts() function") + + writeErr := ioutil.WriteFile(AccountsFileName, []byte("invalid json test"), 0644) + require.NoError(t, writeErr, "Failed to write to test file") + _, err := GetAccountsData() + assert.Error(t, err, "Expected failure calling GetAccountsData() for invalid JSON contents but did not get one") +} + +// TestWriteCards tests the ability to write cards +func TestWriteCards(t *testing.T) { + // use community-recommended shorthand (known name clash) + require := require.New(t) + + expectedCards := setupCards() + writeCards := expectedCards.WriteCards() + require.NoError(writeCards, "Failed WriteCards() function") + + // load cards from file to validate + cardsFromFile := Cards{} + loadJSONFileErr := utilities.LoadFromJSONFile(CardsFileName, &cardsFromFile) + require.NoError(loadJSONFileErr, "Failed to load cards from file") + + assert.Equal(t, expectedCards, cardsFromFile, "Output JSON content mismatch in "+CardsFileName) +} + +// TestGetCards tests the ability to write cards +func TestGetCards(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + + expectedCards := setupCards() + writeCards := expectedCards.WriteCards() + require.NoError(t, writeCards, "Failed WriteCards() function") + + // load cards from file to validate + cardsFromFile, err := GetCardsData() + assert.NoError(err, "Error getting cardsFromFile") + + assert.Equal(expectedCards, cardsFromFile, "Output JSON content mismatch in "+CardsFileName) +} + +// TestGetCardByCardIDQueryFunctions tests the get card by card ID functions +func TestGetCardByCardIDQueryFunctions(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + + expectedCards := setupCards() + writeCards := expectedCards.WriteCards() + require.NoError(t, writeCards, "Failed WriteCards() function") + + tests := []struct { + Name string + CardID string + ExpectedOutput Card + ShouldMatch bool + }{ + {"Test ByPersonID", "0001230001", expectedCards.Cards[0], true}, + {"Test ByPersonID Non Existent Account", "000123000-1", expectedCards.Cards[0], false}, + } + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + returnedCard := expectedCards.GetCardByCardID(currentTest.CardID) + if currentTest.ShouldMatch { + assert.Equal(currentTest.ExpectedOutput, returnedCard, "Accounts should match") + } else { + assert.NotEqual(currentTest.ExpectedOutput, returnedCard, "Accounts should Not match") + } + }) + } +} + +// TestGetCardByRoleIDQueryFunctions tests the get card by role ID functions +func TestGetCardByRoleIDQueryFunctions(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + + expectedCards := setupCards() + writeCards := expectedCards.WriteCards() + require.NoError(t, writeCards, "Failed WriteCards() function") + + tests := []struct { + Name string + RoleID int + ExpectedOutput Card + ShouldMatch bool + }{ + {"Test ByAccountID", 2, expectedCards.Cards[1], true}, + {"Test ByAccountID Non Existent Account", -2, expectedCards.Cards[1], false}, + } + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + returnedCard := expectedCards.GetCardByRoleID(currentTest.RoleID) + if currentTest.ShouldMatch { + assert.Equal(currentTest.ExpectedOutput, returnedCard, "Accounts should match") + } else { + assert.NotEqual(currentTest.ExpectedOutput, returnedCard, "Accounts should Not match") + } + }) + } +} + +// TestGetCardByPersonIDQueryFunctions tests the get card by person ID functions +func TestGetCardByPersonIDQueryFunctions(t *testing.T) { + // use community-recommended shorthand (known name clash) + assert := assert.New(t) + + expectedCards := setupCards() + writeCards := expectedCards.WriteCards() + require.NoError(t, writeCards, "Failed WriteCards() function") + + tests := []struct { + Name string + PersonID int + ExpectedOutput Card + ShouldMatch bool + }{ + {"Test ByFullName", 3, expectedCards.Cards[2], true}, + {"Test ByFullName Non Existent Account", -3, expectedCards.Cards[2], false}, + } + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + returnedCard := expectedCards.GetCardByPersonID(currentTest.PersonID) + if currentTest.ShouldMatch { + assert.Equal(currentTest.ExpectedOutput, returnedCard, "Accounts should match") + } else { + assert.NotEqual(currentTest.ExpectedOutput, returnedCard, "Accounts should Not match") + } + }) + } +} + +// TestDeleteCard tests the ability to delete card +func TestDeleteCard(t *testing.T) { + expectedCards := setupCards() + writeCards := expectedCards.WriteCards() + require.NoError(t, writeCards, "Failed WriteCards() function") + + deletedCard := expectedCards.Cards[0] + expectedCards.DeleteCard(expectedCards.Cards[0]) + + assert.NotEqual(t, expectedCards.Cards[0], deletedCard, "Deleted card with ID "+expectedCards.Cards[0].CardID+" but it still exists in the test list") +} + +// TestDeleteCards tests the ability to delete cards +func TestDeleteCards(t *testing.T) { + // use community-recommended shorthand (known name clash) + require := require.New(t) + + expectedCards := setupCards() + writeCards := expectedCards.WriteCards() + require.NoError(writeCards, "Failed WriteCards() function") + + deleteErr := DeleteCards() + require.NoError(deleteErr, "Failed DeleteCards() function") + + // load cards from file to validate + cardsFromFile := Cards{Cards: []Card{}} + loadJSONFileErr := utilities.LoadFromJSONFile(CardsFileName, &cardsFromFile) + require.NoError(loadJSONFileErr, "Failed to load cards from file") + + assert.Equal(t, cardsFromFile, Cards{Cards: []Card{}}, "Output JSON content mismatch in "+CardsFileName) +} + +// TestGetCardsDataError tests error case for get cards data +func TestGetCardsDataError(t *testing.T) { + expectedCards := setupCards() + writeCards := expectedCards.WriteCards() + require.NoError(t, writeCards, "Failed WriteCards() function") + + writeErr := ioutil.WriteFile(CardsFileName, []byte("invalid json test"), 0644) + require.NoError(t, writeErr, "Failed to write to test file") + _, err := GetCardsData() + assert.Error(t, err, "Expected failure calling GetCardsData() for invalid JSON contents but did not get one") +} diff --git a/ms-authentication/routes/gets.go b/ms-authentication/routes/gets.go new file mode 100644 index 0000000..1afcf44 --- /dev/null +++ b/ms-authentication/routes/gets.go @@ -0,0 +1,105 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "net/http" + + "github.com/gorilla/mux" + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +// AuthenticationGet accepts a 10-character URL parameter in the form: +// /authentication/0001230001 +// It will look up the associated Person and Account for the given card and +// return an instance of AuthData +func AuthenticationGet(writer http.ResponseWriter, req *http.Request) { + utilities.ProcessCORS(writer, req, func(writer http.ResponseWriter, req *http.Request) { + vars := mux.Vars(req) + cardID := vars["cardid"] + // check if the passed cardID is valid + if cardID == "" || len(cardID) != 10 { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Please pass in a 10-character card ID as a URL parameter, like this: /authentication/0001230001", false) + return + } + + // load up all card data so we can find our card + cards, err := GetCardsData() + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to read authentication data", true) + return + } + + // check if the card's ID matches our given cardID + card := cards.GetCardByCardID(cardID) + if card.CardID != cardID { + utilities.WriteStringHTTPResponse(writer, req, http.StatusUnauthorized, "Card ID is not an authorized card", false) + return + } + if !card.IsValid { + utilities.WriteStringHTTPResponse(writer, req, http.StatusUnauthorized, "Card ID is not a valid card", false) + return + } + + // card is found, get the cardholder's AccountID, RoleID, and PersonID + accounts, err := GetAccountsData() + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to read accounts data", true) + return + } + people, err := GetPeopleData() + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to read people data", true) + return + } + + // begin to store the output AuthData + authData := AuthData{CardID: cardID, RoleID: card.RoleID} + + // check if the associated person is valid + person := people.GetPersonByPersonID(card.PersonID) + if person.PersonID != card.PersonID { + utilities.WriteStringHTTPResponse(writer, req, http.StatusUnauthorized, "Card ID is associated with an unknown person", false) + return + } + if !person.IsActive { + utilities.WriteStringHTTPResponse(writer, req, http.StatusUnauthorized, "Card ID is associated with an inactive person", false) + return + } + + // store the personID in the output AuthData + authData.PersonID = person.PersonID + + // check if the associated account is valid + account := accounts.GetAccountByAccountID(person.AccountID) + if account.AccountID != person.AccountID { + utilities.WriteStringHTTPResponse(writer, req, http.StatusUnauthorized, "Card ID is associated with an unknown account", false) + return + } + if !account.IsActive { + utilities.WriteStringHTTPResponse(writer, req, http.StatusUnauthorized, "Card ID is associated with an inactive account", false) + return + } + + // store the accountID in the output AuthData + authData.AccountID = account.AccountID + + authDataJSON, _ := utilities.GetAsJSON(authData) + + // Because of how type-safe Go is, it's actually impossible to + // reach this error condition based on how this function is written + // Generally json.Marshal can throw errors if you pass a chan + // or something unmarshalable, but since authData is simply a struct + // with only ints and strings, we can't actually _not_ marshal it ever + // (I did some searching and that is my conclusion, I'm not stating this + // as fact) + + // if err != nil { + // utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to return authentication data properly", true) + // return + // } + + utilities.WriteJSONHTTPResponse(writer, req, http.StatusOK, authDataJSON, false) + }) +} diff --git a/ms-authentication/routes/gets_test.go b/ms-authentication/routes/gets_test.go new file mode 100644 index 0000000..f51f57b --- /dev/null +++ b/ms-authentication/routes/gets_test.go @@ -0,0 +1,282 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "net/http/httptest" + "strconv" + "testing" + + "github.com/gorilla/mux" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +func setupPeople() People { + return People{ + People: []Person{ + { + PersonID: 1, + AccountID: 1, + FullName: "Test Person 1", + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + IsActive: true, + }, { + PersonID: 2, + AccountID: 2, + FullName: "Test Person 2", + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + IsActive: false, + }, { + PersonID: 3, + AccountID: 3, + FullName: "Test Person 3", + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + IsActive: true, + }, { + PersonID: 4, + AccountID: 4, + FullName: "Test Person 4", + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + IsActive: false, + }, { + PersonID: 5, + AccountID: -1, + FullName: "Test Person 5", + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + IsActive: true, + }, { + PersonID: 6, + AccountID: 6, + FullName: "Test Person 6", + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + IsActive: true, + }, { + PersonID: 7, + AccountID: 7, + FullName: "Test Person 7", + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + IsActive: false, + }, + }, + } +} + +func setupAccounts() Accounts { + return Accounts{ + Accounts: []Account{ + { + AccountID: 1, + Address: "1 Test Lane", + CreditCardNumber: "1234 4567 9012 3456", + PhoneNumber: "1234567890", + EmailAddress: "test1@example.com", + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + IsActive: true, + }, { + AccountID: 2, + Address: "2 Test Lane", + CreditCardNumber: "2234 4567 9012 3456", + PhoneNumber: "2234567890", + EmailAddress: "test2@example.com", + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + IsActive: true, + }, { + AccountID: 3, + Address: "3 Test Lane", + CreditCardNumber: "3234 4567 9012 3456", + PhoneNumber: "3234567890", + EmailAddress: "test3@example.com", + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + IsActive: false, + }, { + AccountID: 4, + Address: "4 Test Lane", + CreditCardNumber: "4234 4567 9012 3456", + PhoneNumber: "4234567890", + EmailAddress: "test4@example.com", + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + IsActive: true, + }, { + AccountID: 5, + Address: "5 Test Lane", + CreditCardNumber: "5234 4567 9012 3456", + PhoneNumber: "5234567890", + EmailAddress: "test5@example.com", + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + IsActive: true, + }, + }, + } +} + +func setupCards() Cards { + return Cards{ + Cards: []Card{ + { + CardID: "0001230001", + RoleID: 1, + IsValid: true, + PersonID: 1, + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + }, { + CardID: "0001230002", + RoleID: 2, + IsValid: true, + PersonID: 2, + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + }, { + CardID: "0001230003", + RoleID: 3, + IsValid: true, + PersonID: 3, + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + }, { + CardID: "0001230004", + RoleID: 1, + IsValid: false, + PersonID: 4, + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + }, { + CardID: "0001230005", + RoleID: 1, + IsValid: true, + PersonID: -1, + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + }, { + CardID: "0001230006", + RoleID: 1, + IsValid: true, + PersonID: 5, + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + }, { + CardID: "TEST000000", + RoleID: 1, + IsValid: true, + PersonID: 1, + CreatedAt: 1560815799, + UpdatedAt: 1560815799, + }, + }, + } +} + +func writeJSONFiles(people People, accounts Accounts, cards Cards) error { + err := people.WritePeople() + if err != nil { + return fmt.Errorf("Failed to write people to JSON file: %s", err.Error()) + } + err = accounts.WriteAccounts() + if err != nil { + return fmt.Errorf("Failed to write accounts to JSON file: " + err.Error()) + } + err = cards.WriteCards() + if err != nil { + return fmt.Errorf("Failed to write cards to JSON file: " + err.Error()) + } + return nil +} + +// TestAuthenticationGet tests the function AuthenticationGet, which +// is the primary endpoint of this application +func TestAuthenticationGet(t *testing.T) { + // use community-recommended shorthand (known name clash) + require := require.New(t) + assert := assert.New(t) + + people := setupPeople() + accounts := setupAccounts() + cards := setupCards() + + validAuthData := AuthData{ + AccountID: accounts.Accounts[0].AccountID, + PersonID: people.People[0].PersonID, + RoleID: cards.Cards[0].RoleID, + CardID: cards.Cards[0].CardID, + } + + tests := []struct { + Name string + WriteFiles bool + WriteInvalidFile string + AuthData AuthData + StatusCode int + CompareValues bool + }{ + {"cardID length not eq 10", true, "", AuthData{CardID: "00"}, http.StatusBadRequest, false}, + {"Successful auth sequence", true, "", validAuthData, http.StatusOK, true}, + {"Test inactive person", true, "", AuthData{CardID: cards.Cards[1].CardID}, http.StatusUnauthorized, false}, + {"Test inactive account", true, "", AuthData{CardID: cards.Cards[2].CardID}, http.StatusUnauthorized, false}, + {"Test inactive card", true, "", AuthData{CardID: cards.Cards[3].CardID}, http.StatusUnauthorized, false}, + {"Test unknown card", true, "", AuthData{CardID: "ffffffffff"}, http.StatusUnauthorized, false}, + {"Test unknown person", true, "", AuthData{CardID: "0001230005"}, http.StatusUnauthorized, false}, + {"Test unknown account", true, "", AuthData{CardID: "0001230006"}, http.StatusUnauthorized, false}, + {"TestAuthenticationGet invalid cards JSON", true, CardsFileName, validAuthData, http.StatusInternalServerError, false}, + {"TestAuthenticationGet invalid accounts JSON", true, AccountsFileName, validAuthData, http.StatusInternalServerError, false}, + {"TestAuthenticationGet invalid people JSON", true, PeopleFileName, validAuthData, http.StatusInternalServerError, false}, + } + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + if currentTest.WriteFiles { + err := writeJSONFiles(people, accounts, cards) + require.NoError(err, "Failed to write to test file") + } + + if currentTest.WriteInvalidFile != "" { + err := ioutil.WriteFile(currentTest.WriteInvalidFile, []byte("invalid json test"), 0644) + require.NoError(err, "Failed to write to test file") + } + + req := httptest.NewRequest("GET", "/authentication/"+currentTest.AuthData.CardID, nil) + w := httptest.NewRecorder() + req = mux.SetURLVars(req, map[string]string{"cardid": currentTest.AuthData.CardID}) + AuthenticationGet(w, req) + resp := w.Result() + defer resp.Body.Close() + + body, err := ioutil.ReadAll(resp.Body) + require.NoError(err, "Failed to read response body") + + responseContent := utilities.HTTPResponse{} + err = json.Unmarshal(body, &responseContent) + require.NoError(err, "Failed to unmarshal response") + + assert.Equal(resp.StatusCode, currentTest.StatusCode, "Expected status code to be OK: "+strconv.Itoa(resp.StatusCode)) + + if currentTest.CompareValues { + // Unmarshal the string contents of request into a proper structure + responseAuthData := AuthData{} + err := json.Unmarshal([]byte(responseContent.Content.(string)), &responseAuthData) + assert.NoError(err, "Failed to unmarshal the authentication data") + + assert.False(responseContent.Error, "Expected error to be false") + assert.Equal(responseAuthData, currentTest.AuthData) + } + }) + } +} diff --git a/ms-authentication/routes/models.go b/ms-authentication/routes/models.go new file mode 100644 index 0000000..bab5cd5 --- /dev/null +++ b/ms-authentication/routes/models.go @@ -0,0 +1,68 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +// Cards is a struct that simply holds a list of Cards (things used to +// authenticate a person for a role) +type Cards struct { + Cards []Card `json:"cards"` +} + +// People is a struct that simply holds a list of people +type People struct { + People []Person `json:"people"` +} + +// Accounts is a struct that simply holds a list of accounts +type Accounts struct { + Accounts []Account `json:"accounts"` +} + +// Card contains role, person and card associations. A person can have multiple +// cards, but a card can only be associated with one role. If a person needs to +// take on a different role, they must use a different card with the desired +// role +type Card struct { + CardID string `json:"cardID"` + RoleID int `json:"roleID"` + IsValid bool `json:"isValid"` + PersonID int `json:"personID"` + CreatedAt int64 `json:"createdAt,string"` + UpdatedAt int64 `json:"updatedAt,string"` +} + +// Person contains person, account, and full name associations. A person +// is associated to one account, and multiple people can be associated to one +// account +type Person struct { + PersonID int `json:"personID"` + AccountID int `json:"accountID"` + FullName string `json:"fullName"` + CreatedAt int64 `json:"createdAt,string"` + UpdatedAt int64 `json:"updatedAt,string"` + IsActive bool `json:"isActive"` +} + +// Account contains payment and billing information. Multiple people can +// be associated with a single account +type Account struct { + AccountID int `json:"accountID"` + Address string `json:"address"` + CreditCardNumber string `json:"creditCardNumber"` + PhoneNumber string `json:"phoneNumber"` + EmailAddress string `json:"emailAddress"` + CreatedAt int64 `json:"createdAt,string"` + UpdatedAt int64 `json:"updatedAt,string"` + IsActive bool `json:"isActive"` +} + +// AuthData is what is expected to be sent back as a response when something +// hits this endpoint. A card number is passed in, and this code will +// resolve the card's corresponding role, person, and account +type AuthData struct { + AccountID int `json:"accountID"` + PersonID int `json:"personID"` + RoleID int `json:"roleID"` + CardID string `json:"cardID"` +} diff --git a/ms-inventory/.gitignore b/ms-inventory/.gitignore new file mode 100644 index 0000000..2e34e5e --- /dev/null +++ b/ms-inventory/.gitignore @@ -0,0 +1,20 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, build with `go test -c` +*.test +main +ms-inventory +test.txt +go.sum +.vscode/* + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +logs/* +routes/*.json diff --git a/ms-inventory/.golangci.yml b/ms-inventory/.golangci.yml new file mode 100644 index 0000000..00ec54e --- /dev/null +++ b/ms-inventory/.golangci.yml @@ -0,0 +1,28 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +run: + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 5m +linters-settings: + misspell: + locale: US +linters: + enable: + - bodyclose + - errcheck + - goconst + - golint + - govet + - gosimple + - ineffassign + - misspell + - staticcheck + - structcheck + - typecheck + - unused + - unconvert + - unparam + - varcheck + disable-all: true + fast: true diff --git a/ms-inventory/Dockerfile b/ms-inventory/Dockerfile new file mode 100644 index 0000000..62679eb --- /dev/null +++ b/ms-inventory/Dockerfile @@ -0,0 +1,31 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +FROM automated-checkout/build:latest AS builder + +LABEL license='SPDX-License-Identifier: BSD-3-Clause' \ + copyright='Copyright (c) 2020: Intel' + +RUN mkdir ms-inventory +WORKDIR /usr/local/bin/ms-inventory/ +COPY . . + +# Compile the code +RUN make gobuild + +# Next image - Copy built Go binary into new workspace +FROM alpine + +LABEL license='SPDX-License-Identifier: BSD-3-Clause' \ + copyright='Copyright (c) 2020: Intel' + +RUN apk --no-cache add zeromq +COPY --from=builder /usr/local/bin/ms-inventory/res/docker/configuration.toml /res/docker/configuration.toml +COPY --from=builder /usr/local/bin/ms-inventory/main /ms-inventory +COPY --from=builder /usr/local/bin/ms-inventory/inventory.json /inventory.json +COPY --from=builder /usr/local/bin/ms-inventory/auditlog.json /auditlog.json + +RUN chmod 640 /inventory.json /auditlog.json && \ + chown 2000 /inventory.json /auditlog.json + +CMD [ "/ms-inventory","--profile=docker","--confdir=/res", "-r"] diff --git a/ms-inventory/LICENSE b/ms-inventory/LICENSE new file mode 100644 index 0000000..dbff156 --- /dev/null +++ b/ms-inventory/LICENSE @@ -0,0 +1,31 @@ +BSD 3-Clause License + +Copyright © 2020, Intel Corporation +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/ms-inventory/Makefile b/ms-inventory/Makefile new file mode 100644 index 0000000..ed6d0d8 --- /dev/null +++ b/ms-inventory/Makefile @@ -0,0 +1,45 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +.PHONY: build gobuild run gorun stop test lint + +MICROSERVICE=automated-checkout/ms-inventory + +build: + docker build --rm \ + --build-arg http_proxy \ + --build-arg https_proxy \ + -f Dockerfile \ + -t $(MICROSERVICE):dev \ + . + +gobuild: + CGO_ENABLED=1 GOOS=linux go build -ldflags='-s -w' -a -installsuffix cgo main.go + +run: + docker run \ + --rm \ + -p 48095:48095 \ + $(MICROSERVICE):dev + +gorun: + ./main + +stop: + docker rm -f $(MICROSERVICE):dev + +test: + go test -test.v -cover ./... + +testHTML: + go test -test.v -coverprofile=test_coverage.out ./... && \ + go tool cover -html=test_coverage.out + +GOLANGCI_VERSION := $(shell golangci-lint --version 2>/dev/null) + +lint: +ifdef GOLANGCI_VERSION + golangci-lint run +else + @echo "golangci-lint not found. Please refer to the README documentation for proper installation" +endif diff --git a/ms-inventory/auditlog.json b/ms-inventory/auditlog.json new file mode 100644 index 0000000..ccb5621 --- /dev/null +++ b/ms-inventory/auditlog.json @@ -0,0 +1 @@ +{"data":[]} \ No newline at end of file diff --git a/ms-inventory/go.mod b/ms-inventory/go.mod new file mode 100644 index 0000000..d45444f --- /dev/null +++ b/ms-inventory/go.mod @@ -0,0 +1,14 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +module ms-inventory + +go 1.12 + +require ( + github.com/edgexfoundry/app-functions-sdk-go v1.0.0 + github.com/google/uuid v1.1.1 + github.com/gorilla/mux v1.7.2 + github.com/intel-iot-devkit/automated-checkout-utilities v1.0.0 + github.com/stretchr/testify v1.5.1 +) diff --git a/ms-inventory/inventory.json b/ms-inventory/inventory.json new file mode 100644 index 0000000..cf18474 --- /dev/null +++ b/ms-inventory/inventory.json @@ -0,0 +1,93 @@ +{ + "data": [{ + "createdAt": "1567787309", + "isActive": true, + "itemPrice": 1.99, + "maxRestockingLevel": 24, + "minRestockingLevel": 0, + "productName": "Sprite (Lemon-Lime) - 16.9 oz", + "sku": "4900002470", + "unitsOnHand": 0, + "updatedAt": "1567787309" + }, { + "createdAt": "1567787309", + "isActive": true, + "itemPrice": 1.99, + "maxRestockingLevel": 18, + "minRestockingLevel": 0, + "productName": "Mountain Dew (Low Calorie) - 16.9 oz", + "sku": "1200010735", + "unitsOnHand": 0, + "updatedAt": "1567787309" + }, { + "createdAt": "1567787309", + "isActive": true, + "itemPrice": 1.99, + "maxRestockingLevel": 6, + "minRestockingLevel": 0, + "productName": "Mountain Dew - 16.9 oz", + "sku": "1200050408", + "unitsOnHand": 0, + "updatedAt": "1567787309" + }, { + "createdAt": "1567787309", + "isActive": true, + "itemPrice": 1.99, + "maxRestockingLevel": 24, + "minRestockingLevel": 0, + "productName": "Water (Dejablue) - 16.9 oz", + "sku": "7800009257", + "unitsOnHand": 0, + "updatedAt": "1567787309" + }, { + "createdAt": "1567787309", + "isActive": true, + "itemPrice": 1.99, + "maxRestockingLevel": 32, + "minRestockingLevel": 0, + "productName": "Dasani Water - 16.9 oz", + "sku": "4900002762", + "unitsOnHand": 0, + "updatedAt": "1567787309" + }, { + "createdAt": "1567787309", + "isActive": true, + "itemPrice": 1.99, + "maxRestockingLevel": 12, + "minRestockingLevel": 0, + "productName": "Pepsi (Wild Cherry) - 16.9 oz", + "sku": "1200081119", + "unitsOnHand": 0, + "updatedAt": "1567787309" + }, { + "createdAt": "1567787309", + "isActive": true, + "itemPrice": 1.99, + "maxRestockingLevel": 6, + "minRestockingLevel": 0, + "productName": "Mountain Dew (blue) - 16.9 oz", + "sku": "1200018402", + "unitsOnHand": 0, + "updatedAt": "1567787309" + }, { + "createdAt": "1567787309", + "isActive": true, + "itemPrice": 1.99, + "maxRestockingLevel": 24, + "minRestockingLevel": 0, + "productName": "Diet Coke - 16.9 oz", + "sku": "4900002469", + "unitsOnHand": 0, + "updatedAt": "1567787309" + }, { + "createdAt": "1567787309", + "isActive": true, + "itemPrice": 1.99, + "maxRestockingLevel": 72, + "minRestockingLevel": 0, + "productName": "Coca-Cola - 20 oz", + "sku": "490440", + "unitsOnHand": 0, + "updatedAt": "1567787309" + }] +} \ No newline at end of file diff --git a/ms-inventory/main.go b/ms-inventory/main.go new file mode 100644 index 0000000..f3ef27b --- /dev/null +++ b/ms-inventory/main.go @@ -0,0 +1,77 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package main + +import ( + "ms-inventory/routes" + + "fmt" + "os" + + "github.com/edgexfoundry/app-functions-sdk-go/appsdk" +) + +const ( + serviceKey = "ms-inventory" +) + +func main() { + // Create an instance of the EdgeX SDK and initialize it. + edgexSdk := &appsdk.AppFunctionsSDK{ServiceKey: serviceKey} + if err := edgexSdk.Initialize(); err != nil { + edgexSdk.LoggingClient.Error(fmt.Sprintf("SDK initialization failed: %v\n", err)) + os.Exit(-1) + } + + // Retrieve the application settings from configuration.toml + appSettings := edgexSdk.ApplicationSettings() + if appSettings == nil { + edgexSdk.LoggingClient.Error("No application settings found") + os.Exit(-1) + } + + var err error + err = edgexSdk.AddRoute("/inventory", routes.InventoryGet, "GET") + errorAddRouteHandler(edgexSdk, err) + + err = edgexSdk.AddRoute("/inventory", routes.InventoryPost, "POST", "OPTIONS") + errorAddRouteHandler(edgexSdk, err) + + err = edgexSdk.AddRoute("/inventory/delta", routes.DeltaInventorySKUPost, "POST", "OPTIONS") + errorAddRouteHandler(edgexSdk, err) + + err = edgexSdk.AddRoute("/inventory/{sku}", routes.InventoryItemGet, "GET") + errorAddRouteHandler(edgexSdk, err) + + err = edgexSdk.AddRoute("/inventory/{sku}", routes.InventoryDelete, "DELETE", "OPTIONS") + errorAddRouteHandler(edgexSdk, err) + + err = edgexSdk.AddRoute("/auditlog", routes.AuditLogGetAll, "GET", "OPTIONS") + errorAddRouteHandler(edgexSdk, err) + err = edgexSdk.AddRoute("/auditlog", routes.AuditLogPost, "POST") + errorAddRouteHandler(edgexSdk, err) + + err = edgexSdk.AddRoute("/auditlog/{entry}", routes.AuditLogGetEntry, "GET", "OPTIONS") + errorAddRouteHandler(edgexSdk, err) + err = edgexSdk.AddRoute("/auditlog/{entry}", routes.AuditLogDelete, "DELETE") + errorAddRouteHandler(edgexSdk, err) + + // Tell the SDK to "start" and begin listening for events to trigger the pipeline + err = edgexSdk.MakeItRun() + if err != nil { + edgexSdk.LoggingClient.Error("MakeItRun returned error: ", err.Error()) + os.Exit(-1) + } + + // Do any required cleanup here + + os.Exit(0) +} + +func errorAddRouteHandler(edgexSdk *appsdk.AppFunctionsSDK, err error) { + if err != nil { + edgexSdk.LoggingClient.Error("Error adding route: %v", err.Error()) + os.Exit(-1) + } +} diff --git a/ms-inventory/res/configuration.toml b/ms-inventory/res/configuration.toml new file mode 100644 index 0000000..f029fe4 --- /dev/null +++ b/ms-inventory/res/configuration.toml @@ -0,0 +1,43 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +[Writable] +LogLevel = 'INFO' + +[Service] +BootTimeout = '30' +ClientMonitor = '15s' +CheckInterval = '10s' +Host = 'localhost' +Port = 48095 +Protocol = 'http' +ReadMaxLimit = 100 +StartupMsg = 'This microservice exposes a CRUD interface for an inventory of items in a Automated Checkout' +Timeout = '30s' + +[Registry] +Host = "localhost" +Port = 8500 +Type = 'consul' + +[MessageBus] +Type = 'zero' + [MessageBus.PublishHost] + Host = '*' + Port = 5564 + Protocol = 'tcp' + [MessageBus.SubscribeHost] + Host = 'localhost' + Port = 5563 + Protocol = 'tcp' + +[Logging] +EnableRemote = false +File = './logs/ms-inventory-publish.log' + +[Binding] +Type="http" +SubscribeTopic="" +PublishTopic="" + +[ApplicationSettings] \ No newline at end of file diff --git a/ms-inventory/res/docker/configuration.toml b/ms-inventory/res/docker/configuration.toml new file mode 100644 index 0000000..2b684ca --- /dev/null +++ b/ms-inventory/res/docker/configuration.toml @@ -0,0 +1,48 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +[Writable] +LogLevel = 'INFO' + +[Service] +BootTimeout = '30s' +ClientMonitor = '15s' +CheckInterval = '10s' +Host = 'ms-inventory' +Port = 48095 +Protocol = 'http' +ReadMaxLimit = 100 +StartupMsg = 'This microservice exposes a CRUD interface for an inventory of items in a Automated Checkout' +Timeout = '30s' + +[Clients] + [Clients.Logging] + Host = "edgex-support-logging" + Protocol = "http" + Port = 48061 + +[Registry] +Host = "edgex-core-consul" +Port = 8500 +Type = 'consul' + +[MessageBus] +Type = 'zero' + [MessageBus.PublishHost] + Host = '*' + Port = 5564 + Protocol = 'tcp' + [MessageBus.SubscribeHost] + Host = 'edgex-core-data' + Port = 5563 + Protocol = 'tcp' + +[Logging] +EnableRemote = true + +[Binding] +Type="http" +SubscribeTopic="" +PublishTopic="" + +[ApplicationSettings] diff --git a/ms-inventory/routes/common.go b/ms-inventory/routes/common.go new file mode 100644 index 0000000..81a02c7 --- /dev/null +++ b/ms-inventory/routes/common.go @@ -0,0 +1,125 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "errors" + + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +// AuditLogFileName is the name of the file that will store the audit log +var AuditLogFileName = "auditlog.json" + +// InventoryFileName is the name of the file that will store the inventory +var InventoryFileName = "inventory.json" + +// DeleteAllQueryString is a string used across this module to enable +// CRUD operations on "all" items in inventory or audit log +const DeleteAllQueryString = "all" + +// GetInventoryItems returns a list of InventoryItems by reading the inventory +// JSON file +func GetInventoryItems() (inventoryItems Products, err error) { + err = utilities.LoadFromJSONFile(InventoryFileName, &inventoryItems) + if err != nil { + return inventoryItems, errors.New( + "Failed to load inventory JSON file: " + err.Error(), + ) + } + return +} + +// GetInventoryItemBySKU returns an inventory item by reading from the +// inventory JSON file +func GetInventoryItemBySKU(SKU string) (inventoryItem Product, inventoryItems Products, err error) { + inventoryItems, err = GetInventoryItems() + if err != nil { + return Product{}, Products{}, errors.New( + "Failed to get inventory items: " + err.Error(), + ) + } + for _, inventoryItem := range inventoryItems.Data { + if SKU == inventoryItem.SKU { + return inventoryItem, inventoryItems, nil + } + } + return Product{SKU: ""}, inventoryItems, nil +} + +// GetAuditLog returns a list of audit log entries by reading from the +// audit log JSON file +func GetAuditLog() (auditLog AuditLog, err error) { + err = utilities.LoadFromJSONFile(AuditLogFileName, &auditLog) + if err != nil { + return auditLog, errors.New( + "Failed to load audit log JSON file: " + err.Error(), + ) + } + return +} + +// GetAuditLogEntryByID returns an audit log entry by reading from the +// audit log JSON file +func GetAuditLogEntryByID(auditEntryID string) (auditLogEntry AuditLogEntry, auditLogEntries AuditLog, err error) { + auditLogEntries, err = GetAuditLog() + if err != nil { + return AuditLogEntry{}, AuditLog{}, errors.New( + "Failed to get audit log items: " + err.Error(), + ) + } + for _, auditLogEntry := range auditLogEntries.Data { + if auditEntryID == auditLogEntry.AuditEntryID { + return auditLogEntry, auditLogEntries, nil + } + } + return AuditLogEntry{}, auditLogEntries, nil +} + +// DeleteInventory will reset the content of the inventory JSON file +func DeleteInventory() error { + return WriteJSON(InventoryFileName, Products{Data: []Product{}}) +} + +// DeleteAuditLog will reset the content of the audit log JSON file +func DeleteAuditLog() error { + return WriteJSON(AuditLogFileName, AuditLog{Data: []AuditLogEntry{}}) +} + +// WriteJSON is a shorthand for writing an interface to JSON +func WriteJSON(fileName string, content interface{}) error { + return utilities.WriteToJSONFile(fileName, content, 0644) +} + +// WriteInventory is a shorthand for writing the inventory quickly +func (inventoryItems *Products) WriteInventory() error { + return WriteJSON(InventoryFileName, inventoryItems) +} + +// WriteAuditLog is a shorthand for writing the audit log quickly +func (auditLog *AuditLog) WriteAuditLog() error { + return WriteJSON(AuditLogFileName, auditLog) +} + +// DeleteInventoryItem deletes an inventory item matching the +// specified SKU +func (inventoryItems *Products) DeleteInventoryItem(inventoryItem Product) { + for i, item := range inventoryItems.Data { + if item.SKU == inventoryItem.SKU { + inventoryItems.Data = append(inventoryItems.Data[:i], inventoryItems.Data[i+1:]...) + break + } + } +} + +// DeleteAuditLogEntry deletes an audit log entry item matching the +// specified EntryID +func (auditLog *AuditLog) DeleteAuditLogEntry(auditLogEntry AuditLogEntry) { + for i, item := range auditLog.Data { + if item.AuditEntryID == auditLogEntry.AuditEntryID { + auditLog.Data = append(auditLog.Data[:i], auditLog.Data[i+1:]...) + break + } + } +} diff --git a/ms-inventory/routes/common_test.go b/ms-inventory/routes/common_test.go new file mode 100644 index 0000000..118bcec --- /dev/null +++ b/ms-inventory/routes/common_test.go @@ -0,0 +1,365 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "io/ioutil" + "testing" + + "github.com/stretchr/testify/require" + + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +func getDefaultProductsList() Products { + return Products{ + Data: []Product{{ + CreatedAt: 1567787309, + IsActive: true, + ItemPrice: 1.99, + MaxRestockingLevel: 24, + MinRestockingLevel: 0, + ProductName: "Sprite (Lemon-Lime) - 16.9 oz", + SKU: "4900002470", + UnitsOnHand: 0, + UpdatedAt: 1567787309, + }, { + CreatedAt: 1567787309, + IsActive: true, + ItemPrice: 1.99, + MaxRestockingLevel: 18, + MinRestockingLevel: 0, + ProductName: "Mountain Dew (Low Calorie) - 16.9 oz", + SKU: "1200010735", + UnitsOnHand: 0, + UpdatedAt: 1567787309, + }, { + CreatedAt: 1567787309, + IsActive: true, + ItemPrice: 1.99, + MaxRestockingLevel: 6, + MinRestockingLevel: 0, + ProductName: "Mountain Dew - 16.9 oz", + SKU: "1200050408", + UnitsOnHand: 0, + UpdatedAt: 1567787309, + }}} +} + +// TestWriteInventory tests the ability to write inventory items +// related functions +func TestWriteInventory(t *testing.T) { + // Product slice + products := getDefaultProductsList() + err := products.WriteInventory() + require.NoError(t, err) + + // load product from file to validate + productsFromFile := Products{} + err = utilities.LoadFromJSONFile(InventoryFileName, &productsFromFile) + require.NoError(t, err) + + // Check to make sure items match + require.Equal(t, products, productsFromFile, "Products should match") +} + +// TestGetInventoryItems tests the ability to get all inventory items +// related functions +func TestGetInventoryItems(t *testing.T) { + // Product slice + products := getDefaultProductsList() + err := products.WriteInventory() + require.NoError(t, err) + + // run GetInventoryItems and get the result as JSON + productsFromFile, err := GetInventoryItems() + require.NoError(t, err) + + // Check to make sure items do not match + require.Equal(t, products, productsFromFile, "Products should match") +} + +// TestGetInventoryItemBySKU tests the ability to get inventory item based on SKU +// related functions +func TestGetInventoryItemBySKU(t *testing.T) { + // Product slice + products := getDefaultProductsList() + // variables + missingSKUToReturn := "0000000000" + + tests := []struct { + Name string + InventorySKU string + FoundProduct bool + }{ + {"valid SKU", products.Data[0].SKU, true}, + {"missing SKU", missingSKUToReturn, false}, + } + + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + err := DeleteInventory() + require.NoError(t, err) + + err = products.WriteInventory() + require.NoError(t, err) + + // run GetInventoryItems and get the result as JSON + productBySKU, productsFromFile, err := GetInventoryItemBySKU(currentTest.InventorySKU) + require.NoError(t, err) + + for _, product := range productsFromFile.Data { + if product.SKU == currentTest.InventorySKU { + if currentTest.FoundProduct { + require.Equal(t, productBySKU, product, "Expected products to match") + } else { + require.NotEqual(t, productBySKU, product, "Expected no products to match") + } + } + } + }) + } +} + +// TestDeleteInventoryItem tests the ability to delete inventory items +// related functions +func TestDeleteInventoryItem(t *testing.T) { + // Product slice + products := getDefaultProductsList() + err := products.WriteInventory() + require.NoError(t, err) + + deletedProductID := products.Data[0].SKU + products.DeleteInventoryItem(products.Data[0]) + + for _, product := range products.Data { + if product.SKU == deletedProductID { + t.Fatalf("Deleted person with ID " + (product.SKU) + " but it still exists in the test list") + } + } +} + +// TestGetInventoryItemErrors tests the error checking on the GetInventoryItems function +// related functions +func TestGetInventoryItemErrors(t *testing.T) { + // Product slice + products := getDefaultProductsList() + err := products.WriteInventory() + require.NoError(t, err) + + t.Run("Test GetInventoryItems Error", func(t *testing.T) { + err := ioutil.WriteFile(InventoryFileName, []byte("invalid json test"), 0644) + require.NoError(t, err) + + _, err = GetInventoryItems() + require.NotNil(t, err, "Expected inventory get to fail") + }) + t.Run("Test GetInventoryItemBySKU Error", func(t *testing.T) { + err := ioutil.WriteFile(InventoryFileName, []byte("invalid json test"), 0644) + require.NoError(t, err) + + _, _, err = GetInventoryItemBySKU(products.Data[0].SKU) + require.NotNil(t, err, "Expected inventory get to fail") + }) + t.Run("Test DeleteInventory", func(t *testing.T) { + err := DeleteInventory() + require.NoError(t, err) + + productsFromFile, err := GetInventoryItems() + require.NoError(t, err) + require.LessOrEqual(t, len(productsFromFile.Data), 0, "Expected products list to be empty but it contained 1 or more entry") + }) +} + +func getDefaultAuditsList() AuditLog { + return AuditLog{ + Data: []AuditLogEntry{{ + CardID: "0003292356", + AccountID: 1, + RoleID: 1, + PersonID: 1, + InventoryDelta: []DeltaInventorySKU{ + { + SKU: "4900002470", + Delta: 5, + }, { + SKU: "1200010735", + Delta: 5, + }, + }, + CreatedAt: 1567787309, + AuditEntryID: "1", + }, { + CardID: "0003292371", + AccountID: 2, + RoleID: 2, + PersonID: 2, + InventoryDelta: []DeltaInventorySKU{ + { + SKU: "4900002470", + Delta: -1, + }, { + SKU: "1200010735", + Delta: -1, + }, + }, + CreatedAt: 1567787309, + AuditEntryID: "2", + }, { + CardID: "0003621873", + AccountID: 3, + RoleID: 3, + PersonID: 3, + InventoryDelta: []DeltaInventorySKU{ + { + SKU: "4900002470", + Delta: -2, + }, { + SKU: "1200010735", + Delta: -2, + }, + }, + CreatedAt: 1567787309, + AuditEntryID: "3", + }}} +} + +// TestWriteAuditLog tests the ability to get all audit logs +// related functions +func TestWriteAuditLog(t *testing.T) { + // Audit slice + audits := getDefaultAuditsList() + err := audits.WriteAuditLog() + require.NoError(t, err) + + // load audits from file to validate + auditsFromFile := AuditLog{} + err = utilities.LoadFromJSONFile(AuditLogFileName, &auditsFromFile) + require.NoError(t, err) + + // Check to make sure audit entries match + require.Equal(t, audits, auditsFromFile, "Audits should match") +} + +// TestGetAuditLog tests the ability to get all inventory items +// related functions +func TestGetAuditLog(t *testing.T) { + // Audit slice + audits := getDefaultAuditsList() + err := audits.WriteAuditLog() + require.NoError(t, err) + + // run GetInventoryItems and get the result as JSON + auditsFromFile, err := GetAuditLog() + require.NoError(t, err) + + // Check to make sure audit entries match + require.Equal(t, audits, auditsFromFile, "Audits should match") +} + +// TestGetAuditLogEntryByID tests the ability to get all audit logs +// related functions +func TestGetAuditLogEntryByID(t *testing.T) { + // Audit slice + audits := getDefaultAuditsList() + err := audits.WriteAuditLog() + require.NoError(t, err) + + // variables + entryIDToReturn := "1" + invalidEntryIDToReturn := "100" + + t.Run("Test GetAuditLogEntryByID", func(t *testing.T) { + // run GetAuditLogEntryByID and get the result as JSON + auditLogEntry, auditsFromFile, err := GetAuditLogEntryByID(entryIDToReturn) + require.NoError(t, err) + + // Check to make sure audit entries match + require.Equal(t, audits, auditsFromFile, "Audits should match") + + foundAudit := false + for _, audit := range auditsFromFile.Data { + if audit.AuditEntryID == entryIDToReturn { + if auditLogEntry.AuditEntryID == audit.AuditEntryID { + foundAudit = true + // Check to make sure audit entries match + } + } + } + require.True(t, foundAudit, "Did not find expected audit") + }) + t.Run("Test GetAuditLogEntryByID invalid entry ID", func(t *testing.T) { + // run GetAuditLogEntryByID and get the result as JSON + auditLogEntry, auditsFromFile, err := GetAuditLogEntryByID(invalidEntryIDToReturn) + require.NoError(t, err) + + // Check to make sure audit entries match + require.Equal(t, audits, auditsFromFile, "Audits should match") + + foundAudit := false + for _, audit := range auditsFromFile.Data { + if audit.AuditEntryID == entryIDToReturn { + if auditLogEntry.AuditEntryID == audit.AuditEntryID { + foundAudit = true + // Check to make sure audit entries match + } + } + } + require.False(t, foundAudit, "Found unexpected audit") + }) +} + +// TestDeleteAuditLogEntry tests the ability to get all audit logs +// related functions +func TestDeleteAuditLogEntry(t *testing.T) { + // Audit slice + audits := getDefaultAuditsList() + err := audits.WriteAuditLog() + require.NoError(t, err) + + deletedAuditID := audits.Data[0].AuditEntryID + audits.DeleteAuditLogEntry(audits.Data[0]) + + for _, audit := range audits.Data { + if audit.AuditEntryID == deletedAuditID { + t.Fatalf("Deleted person with ID " + (audit.AuditEntryID) + " but it still exists in the test list") + } + } +} + +// TestGetAuditLogErrors tests the ability to get all audit logs +// related functions +func TestGetAuditLogErrors(t *testing.T) { + // Audit slice + audits := getDefaultAuditsList() + err := audits.WriteAuditLog() + require.NoError(t, err) + + // variables + entryIDToReturn := "1" + + t.Run("Test GetAuditLog Error", func(t *testing.T) { + err := ioutil.WriteFile(AuditLogFileName, []byte("invalid json test"), 0644) + require.NoError(t, err) + + _, err = GetAuditLog() + require.NotNil(t, err, "Expected audit log get to fail") + }) + t.Run("Test GetAuditLogEntryByID Error", func(t *testing.T) { + err := ioutil.WriteFile(AuditLogFileName, []byte("invalid json test"), 0644) + require.NoError(t, err) + + _, _, err = GetAuditLogEntryByID(entryIDToReturn) + require.NotNil(t, err, "Expected audit log get to fail") + }) + t.Run("Test DeleteAuditLog", func(t *testing.T) { + err := DeleteAuditLog() + require.NoError(t, err) + + auditsFromFile, err := GetAuditLog() + require.NoError(t, err) + require.LessOrEqual(t, len(auditsFromFile.Data), 0, "Expected audits list to be empty but it contained 1 or more entry") + }) +} diff --git a/ms-inventory/routes/deletes.go b/ms-inventory/routes/deletes.go new file mode 100644 index 0000000..26b56b3 --- /dev/null +++ b/ms-inventory/routes/deletes.go @@ -0,0 +1,116 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "net/http" + "fmt" + + "github.com/gorilla/mux" + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +// InventoryDelete allows deletion of an inventory item or multiple items +func InventoryDelete(writer http.ResponseWriter, req *http.Request) { + utilities.ProcessCORS(writer, req, func(writer http.ResponseWriter, req *http.Request) { + // find the requested SKU and exit if it's invalid + vars := mux.Vars(req) + SKU := vars["sku"] + if SKU == "" { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Please enter a valid inventory item in the form of /inventory/{sku}", true) + return + } + // if the user wants to delete all inventory, do it + if SKU == DeleteAllQueryString { + err := DeleteInventory() + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to properly reset inventory: "+err.Error(), true) + return + } + emptyInventoryResponseJSON, err := utilities.GetAsJSON(Products{Data: []Product{}}) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to serialize empty inventory response: "+err.Error(), true) + return + } + + utilities.WriteJSONHTTPResponse(writer, req, http.StatusOK, emptyInventoryResponseJSON, false) + return + } + // look up the requested inventory item by SKU + inventoryItemToDelete, inventoryItems, err := GetInventoryItemBySKU(SKU) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to get requested inventory item by SKU: "+err.Error(), true) + return + } + + // check if GetInventoryItemBySKU found an inventory item to delete + if inventoryItemToDelete.SKU == "" { + utilities.WriteStringHTTPResponse(writer, req, http.StatusNotFound, "Item does not exist", false) + return + } + // delete the inventory item & write the modified inventory + inventoryItems.DeleteInventoryItem(inventoryItemToDelete) + err = inventoryItems.WriteInventory() + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to write updated inventory", true) + return + } + inventoryItemToDeleteJSON, err := utilities.GetAsJSON(inventoryItemToDelete) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, fmt.Sprintf("Successfully deleted the item from inventory, but failed to serialize it so that it could be sent back to the requester: %v", err.Error()), true) + } + utilities.WriteJSONHTTPResponse(writer, req, http.StatusOK, inventoryItemToDeleteJSON, false) + }) +} + +// AuditLogDelete allows deletion of one or more audit log entry items +func AuditLogDelete(writer http.ResponseWriter, req *http.Request) { + utilities.ProcessCORS(writer, req, func(writer http.ResponseWriter, req *http.Request) { + // find the requested SKU and exit if it's invalid + vars := mux.Vars(req) + entryID := vars["entry"] + if entryID == "" { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Please enter a valid audit log entry ID in the form of /auditlog/{entryId}", true) + return + } + // if the user wants to delete all inventory, do it + if entryID == DeleteAllQueryString { + err := DeleteAuditLog() + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to properly reset audit log: "+err.Error(), true) + return + } + emptyAuditLogResponseJSON, err := utilities.GetAsJSON(AuditLog{Data: []AuditLogEntry{}}) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, fmt.Sprintf("Failed to serialize empty audit log response: %v", err.Error()), true) + } + utilities.WriteJSONHTTPResponse(writer, req, http.StatusOK, emptyAuditLogResponseJSON, false) + return + } + // look up the requested audit log entry by EntryID + auditLogEntryToDelete, auditLog, err := GetAuditLogEntryByID(entryID) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to get requested audit log entry by ID: "+err.Error(), true) + return + } + + // check if GetAuditLogEntryByID found an audit log entry to delete + if auditLogEntryToDelete.AuditEntryID == "" { + utilities.WriteStringHTTPResponse(writer, req, http.StatusNotFound, "Item does not exist", false) + return + } + // delete the audit log entry & write the modified audit log + auditLog.DeleteAuditLogEntry(auditLogEntryToDelete) + err = auditLog.WriteAuditLog() + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to write updated audit log", true) + return + } + auditLogEntryToDeleteJSON, err := utilities.GetAsJSON(auditLogEntryToDelete) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, fmt.Sprintf("Successfully deleted item from audit log, but failed to serialize information back to the requester: %v", err.Error()), true) + } + utilities.WriteJSONHTTPResponse(writer, req, http.StatusOK, auditLogEntryToDeleteJSON, false) + }) +} diff --git a/ms-inventory/routes/deletes_test.go b/ms-inventory/routes/deletes_test.go new file mode 100644 index 0000000..e1ee264 --- /dev/null +++ b/ms-inventory/routes/deletes_test.go @@ -0,0 +1,139 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "bytes" + "io/ioutil" + "net/http" + "net/http/httptest" + "testing" + + "github.com/gorilla/mux" + "github.com/stretchr/testify/require" +) + +// TestInventoryDelete tests the function InventoryDelete +func TestInventoryDelete(t *testing.T) { + // Product slice + products := getDefaultProductsList() + + tests := []struct { + Name string + BadInventory bool + InventorySKU string + ExpectedStatusCode int + ProductsMatch bool + InventoryPath string + }{ + {"with valid SKU", false, products.Data[0].SKU, http.StatusOK, false, "inventory.json"}, + {"with invalid SKU", false, "0000000000", http.StatusNotFound, true, "inventory.json"}, + {"with missing SKU", false, "", http.StatusBadRequest, true, "inventory.json"}, + {"with all parameter", false, "all", http.StatusOK, false, "inventory.json"}, + {"with invalid inventory json", true, products.Data[0].SKU, http.StatusInternalServerError, true, "inventory.json"}, + {"with all parameter and invalid inventory json path", false, "all", http.StatusInternalServerError, true, "tests/inventory.json"}, + } + + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + err := DeleteInventory() + require.NoError(t, err) + + if currentTest.BadInventory { + err := ioutil.WriteFile(InventoryFileName, []byte("invalid json test"), 0644) + require.NoError(t, err) + } else { + err := products.WriteInventory() + require.NoError(t, err) + } + InventoryFileName = currentTest.InventoryPath + + req := httptest.NewRequest("DELETE", "http://localhost:48096/inventory/", bytes.NewBuffer([]byte(currentTest.InventorySKU))) + w := httptest.NewRecorder() + req = mux.SetURLVars(req, map[string]string{"sku": currentTest.InventorySKU}) + req.Header.Set("Content-Type", "application/json") + InventoryDelete(w, req) + resp := w.Result() + defer resp.Body.Close() + + require.Equal(t, currentTest.ExpectedStatusCode, resp.StatusCode, "invalid status code") + + InventoryFileName = "inventory.json" + if !currentTest.BadInventory { + // run GetInventoryItems and get the result as JSON + productsFromFile, err := GetInventoryItems() + require.NoError(t, err) + + if currentTest.ProductsMatch { + require.Equal(t, products, productsFromFile, "Products should match") + } else { + require.NotEqual(t, products, productsFromFile, "Products should not match") + } + } + }) + } +} + +// TestAuditLogDelete tests the function InventoryDelete +func TestAuditLogDelete(t *testing.T) { + // Audit slice + audits := getDefaultAuditsList() + + tests := []struct { + Name string + BadAuditID bool + AuditEntryID string + ExpectedStatusCode int + ProductsMatch bool + AuditLogPath string + }{ + {"with valid Entry ID", false, audits.Data[0].AuditEntryID, http.StatusOK, false, "auditlog.json"}, + {"with invalid Entry ID", false, "0000000000", http.StatusNotFound, true, "auditlog.json"}, + {"with missing Entry ID", false, "", http.StatusBadRequest, true, "auditlog.json"}, + {"with all parameter", false, "all", http.StatusOK, false, "auditlog.json"}, + {"with invalid auditlog json", true, audits.Data[0].AuditEntryID, http.StatusInternalServerError, true, "auditlog.json"}, + {"with all parameter and invalid auditlog json path", false, "all", http.StatusInternalServerError, true, "tests/auditlog.json"}, + } + + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + err := DeleteAuditLog() + require.NoError(t, err) + + if currentTest.BadAuditID { + err := ioutil.WriteFile(AuditLogFileName, []byte("invalid json test"), 0644) + require.NoError(t, err) + } else { + err := audits.WriteAuditLog() + require.NoError(t, err) + } + AuditLogFileName = currentTest.AuditLogPath + + req := httptest.NewRequest("DELETE", "http://localhost:48096/auditlog/", bytes.NewBuffer([]byte(currentTest.AuditEntryID))) + w := httptest.NewRecorder() + req = mux.SetURLVars(req, map[string]string{"entry": currentTest.AuditEntryID}) + req.Header.Set("Content-Type", "application/json") + AuditLogDelete(w, req) + resp := w.Result() + defer resp.Body.Close() + + require.Equal(t, currentTest.ExpectedStatusCode, resp.StatusCode, "invalid status code") + + AuditLogFileName = "auditlog.json" + if !currentTest.BadAuditID { + // run GetAuditLog and get the result as JSON + auditsFromFile, err := GetAuditLog() + require.NoError(t, err) + + if currentTest.ProductsMatch { + require.Equal(t, audits, auditsFromFile, "Products should match") + } else { + require.NotEqual(t, audits, auditsFromFile, "Products should not match") + } + } + }) + } +} diff --git a/ms-inventory/routes/gets.go b/ms-inventory/routes/gets.go new file mode 100644 index 0000000..fd46a12 --- /dev/null +++ b/ms-inventory/routes/gets.go @@ -0,0 +1,110 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "net/http" + + "github.com/gorilla/mux" + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +// InventoryGet allows for the retrieval of the entire inventory +func InventoryGet(writer http.ResponseWriter, req *http.Request) { + utilities.ProcessCORS(writer, req, func(writer http.ResponseWriter, req *http.Request) { + inventoryItems, err := GetInventoryItems() + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to retrieve all inventory items: "+err.Error(), true) + return + } + + // No logic needs to be done here, since we are just reading the file + // and writing it back out. Simply marshaling it will validate its structure + inventoryItemsJSON, err := utilities.GetAsJSON(inventoryItems) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to process inventory items: "+err.Error(), true) + return + } + + utilities.WriteJSONHTTPResponse(writer, req, http.StatusOK, inventoryItemsJSON, false) + }) +} + +// InventoryItemGet allows for a single inventory item to be retrieved by SKU +func InventoryItemGet(writer http.ResponseWriter, req *http.Request) { + utilities.ProcessCORS(writer, req, func(writer http.ResponseWriter, req *http.Request) { + vars := mux.Vars(req) + sku := vars["sku"] + if sku != "" { + inventoryItem, _, err := GetInventoryItemBySKU(sku) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to get inventory item by SKU: "+err.Error(), true) + return + } + if inventoryItem.SKU == "" { + utilities.WriteStringHTTPResponse(writer, req, http.StatusNotFound, "", false) + return + } + outputInventoryItemJSON, err := utilities.GetAsJSON(inventoryItem) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to process the requested inventory item "+sku+":"+err.Error(), true) + return + } + utilities.WriteJSONHTTPResponse(writer, req, http.StatusOK, outputInventoryItemJSON, false) + return + } + + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Please enter a valid inventory item in the form of /inventory/{sku}", false) + }) +} + +// AuditLogGetAll allows all audit log entries to be retrieved +func AuditLogGetAll(writer http.ResponseWriter, req *http.Request) { + utilities.ProcessCORS(writer, req, func(writer http.ResponseWriter, req *http.Request) { + auditLog, err := GetAuditLog() + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to retrieve all audit log entries: "+err.Error(), true) + return + } + + // No logic needs to be done here, since we are just reading the file + // and writing it back out. Simply marshaling it will validate its structure + auditLogJSON, err := utilities.GetAsJSON(auditLog) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to process audit log entries: "+err.Error(), true) + return + } + + utilities.WriteJSONHTTPResponse(writer, req, http.StatusOK, auditLogJSON, false) + }) +} + +// AuditLogGetEntry allows a single audit log entry to be retrieved by its +// UUID +func AuditLogGetEntry(writer http.ResponseWriter, req *http.Request) { + utilities.ProcessCORS(writer, req, func(writer http.ResponseWriter, req *http.Request) { + vars := mux.Vars(req) + entryID := vars["entry"] + if entryID != "" { + auditLogEntry, _, err := GetAuditLogEntryByID(entryID) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to get audit log entry by ID: "+err.Error(), true) + return + } + if auditLogEntry.AuditEntryID == "" { + utilities.WriteStringHTTPResponse(writer, req, http.StatusNotFound, "", false) + return + } + outputAuditLogEntryJSON, err := utilities.GetAsJSON(auditLogEntry) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to process the requested audit log entry item "+entryID+":"+err.Error(), true) + return + } + utilities.WriteJSONHTTPResponse(writer, req, http.StatusOK, outputAuditLogEntryJSON, false) + return + } + + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Please enter a valid entry ID in the form of /auditlog/{entry}", false) + }) +} diff --git a/ms-inventory/routes/gets_test.go b/ms-inventory/routes/gets_test.go new file mode 100644 index 0000000..01cbe10 --- /dev/null +++ b/ms-inventory/routes/gets_test.go @@ -0,0 +1,189 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "io/ioutil" + "net/http" + "net/http/httptest" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/gorilla/mux" +) + +// TestInventoryGet tests the function InventoryGet +func TestInventoryGet(t *testing.T) { + // Product slice + products := getDefaultProductsList() + + tests := []struct { + Name string + BadInventory bool + ExpectedStatusCode int + }{ + {"InventoryGet", false, http.StatusOK}, + {"with invalid inventory json with", true, http.StatusInternalServerError}, + } + + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + err := DeleteInventory() + require.NoError(t, err) + + if currentTest.BadInventory { + err := ioutil.WriteFile(InventoryFileName, []byte("invalid json test"), 0644) + require.NoError(t, err) + } else { + err := products.WriteInventory() + require.NoError(t, err) + } + + req := httptest.NewRequest("GET", "http://localhost:48096/inventory", nil) + w := httptest.NewRecorder() + InventoryGet(w, req) + resp := w.Result() + defer resp.Body.Close() + + require.Equal(t, currentTest.ExpectedStatusCode, resp.StatusCode, "invalid status code") + }) + } +} + +// TestInventoryItemGet tests the function InventoryGet +func TestInventoryItemGet(t *testing.T) { + // Product slice + products := getDefaultProductsList() + + tests := []struct { + Name string + WriteInventory bool + BadInventory bool + URLPath string + ExpectedStatusCode int + }{ + {"with valid SKU", true, false, products.Data[0].SKU, http.StatusOK}, + {"with missing sku in url", true, false, "", http.StatusBadRequest}, + {"with missing items", false, false, products.Data[0].SKU, http.StatusNotFound}, + {"with invalid inventory json", true, true, products.Data[0].SKU, http.StatusInternalServerError}, + } + + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + err := DeleteInventory() + require.NoError(t, err) + + if currentTest.WriteInventory { + if currentTest.BadInventory { + err := ioutil.WriteFile(InventoryFileName, []byte("invalid json test"), 0644) + require.NoError(t, err) + } else { + err := products.WriteInventory() + require.NoError(t, err) + } + } + + req := httptest.NewRequest("GET", "http://localhost:48096/inventory/"+test.URLPath, nil) + w := httptest.NewRecorder() + req = mux.SetURLVars(req, map[string]string{"sku": currentTest.URLPath}) + InventoryItemGet(w, req) + resp := w.Result() + defer resp.Body.Close() + + require.Equal(t, currentTest.ExpectedStatusCode, resp.StatusCode, "invalid status code") + }) + } +} + +// TestAuditLogGetAll tests the ability to get all audit logs +// related functions +func TestAuditLogGetAll(t *testing.T) { + // Audit slice + audits := getDefaultAuditsList() + + tests := []struct { + Name string + BadInventory bool + ExpectedStatusCode int + }{ + {"AuditLogGetAll", false, http.StatusOK}, + {"with invalid audit log json", true, http.StatusInternalServerError}, + } + + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + err := DeleteAuditLog() + require.NoError(t, err) + + if currentTest.BadInventory { + err := ioutil.WriteFile(AuditLogFileName, []byte("invalid json test"), 0644) + require.NoError(t, err) + } else { + err := audits.WriteAuditLog() + require.NoError(t, err) + } + + req := httptest.NewRequest("GET", "http://localhost:48096/auditlog", nil) + w := httptest.NewRecorder() + AuditLogGetAll(w, req) + resp := w.Result() + defer resp.Body.Close() + + require.Equal(t, currentTest.ExpectedStatusCode, resp.StatusCode, "invalid status code") + }) + } +} + +// TestAuditLogGetEntry tests the ability to get all audit logs +// related functions +func TestAuditLogGetEntry(t *testing.T) { + // Audit slice + audits := getDefaultAuditsList() + err := audits.WriteAuditLog() + require.NoError(t, err) + + tests := []struct { + Name string + WriteAuditLog bool + BadAuditLog bool + URLPath string + ExpectedStatusCode int + }{ + {"with valid Audit ID", true, false, audits.Data[0].AuditEntryID, http.StatusOK}, + {"with missing entry ID in url", true, false, "", http.StatusBadRequest}, + {"with missing items", false, false, audits.Data[0].AuditEntryID, http.StatusNotFound}, + {"with invalid audit log json", true, true, audits.Data[0].AuditEntryID, http.StatusInternalServerError}, + } + + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + err := DeleteAuditLog() + require.NoError(t, err) + + if currentTest.WriteAuditLog { + if currentTest.BadAuditLog { + err := ioutil.WriteFile(AuditLogFileName, []byte("invalid json test"), 0644) + require.NoError(t, err) + } else { + err := audits.WriteAuditLog() + require.NoError(t, err) + } + } + + req := httptest.NewRequest("GET", "http://localhost:48096/auditlog/"+test.URLPath, nil) + w := httptest.NewRecorder() + req = mux.SetURLVars(req, map[string]string{"entry": currentTest.URLPath}) + AuditLogGetEntry(w, req) + resp := w.Result() + defer resp.Body.Close() + + require.Equal(t, currentTest.ExpectedStatusCode, resp.StatusCode, "invalid status code") + }) + } +} diff --git a/ms-inventory/routes/models.go b/ms-inventory/routes/models.go new file mode 100644 index 0000000..2819729 --- /dev/null +++ b/ms-inventory/routes/models.go @@ -0,0 +1,47 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +// Products is the schema for the data that will be returned to the user +// when hitting the inventory endpoint +type Products struct { + Data []Product `json:"data"` +} + +// Product is the schema for a single inventory item +type Product struct { + SKU string `json:"sku"` + ItemPrice float64 `json:"itemPrice"` + ProductName string `json:"productName"` + UnitsOnHand int `json:"unitsOnHand"` + MaxRestockingLevel int `json:"maxRestockingLevel"` + MinRestockingLevel int `json:"minRestockingLevel"` + CreatedAt int64 `json:"createdAt,string"` + UpdatedAt int64 `json:"updatedAt,string"` + IsActive bool `json:"isActive"` +} + +// DeltaInventorySKU is required because we cannot unmarshal a delta +// into Product struct, and the API endpoints needs to accept a delta +type DeltaInventorySKU struct { + SKU string `json:"SKU"` + Delta int `json:"delta"` +} + +// AuditLog is similar to Products in that it is the schema for the data +// that will be returned to the user when hitting the audit log endpoint +type AuditLog struct { + Data []AuditLogEntry `json:"data"` +} + +// AuditLogEntry represents the schema for a single audit log entry +type AuditLogEntry struct { + CardID string `json:"cardId"` + AccountID int `json:"accountId"` + RoleID int `json:"roleId"` + PersonID int `json:"personId"` + InventoryDelta []DeltaInventorySKU `json:"inventoryDelta"` + CreatedAt int64 `json:"createdAt,string"` + AuditEntryID string `json:"auditEntryId"` +} diff --git a/ms-inventory/routes/sets.go b/ms-inventory/routes/sets.go new file mode 100644 index 0000000..e1135c3 --- /dev/null +++ b/ms-inventory/routes/sets.go @@ -0,0 +1,341 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "encoding/json" + "fmt" + "io" + "net/http" + "time" + + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +// DeltaInventorySKUPost allows a change in inventory (a delta), via HTTP Post +// REST requests to occur +func DeltaInventorySKUPost(writer http.ResponseWriter, req *http.Request) { + // Use the ProcessCORS "decorator" function to reduce code repetition + utilities.ProcessCORS(writer, req, func(writer http.ResponseWriter, req *http.Request) { + response := utilities.GetHTTPResponseTemplate() + + // Read request body + body := make([]byte, req.ContentLength) + if _, err := io.ReadFull(req.Body, body); err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Failed to process the posted delta inventory item(s): "+err.Error(), true) + return + } + + // Unmarshal the string contents of request into a proper structure + var deltaInventorySKUList []DeltaInventorySKU + err := json.Unmarshal(body, &deltaInventorySKUList) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Failed to process the posted delta inventory item(s): "+err.Error(), true) + return + } + + // load the inventory.json file + var inventoryItems Products + err = utilities.LoadFromJSONFile(InventoryFileName, &inventoryItems) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to retrieve all inventory items: "+err.Error(), true) + return + } + + // iterate over all deltaInventorySKU's and find their corresponding SKU in inventory + // then update the inventory with the delta + var updatedInventoryItems []Product // will return the inventory items that got updated + performedUpdate := false + for _, deltaInventorySKU := range deltaInventorySKUList { + for i, inventoryItem := range inventoryItems.Data { + if deltaInventorySKU.SKU == inventoryItem.SKU { + inventoryItems.Data[i].UnitsOnHand += deltaInventorySKU.Delta + updatedInventoryItems = append(updatedInventoryItems, inventoryItems.Data[i]) + performedUpdate = true + break + } + } + } + + // Nothing was done, so return "Not Modified" status + if !performedUpdate { + utilities.WriteStringHTTPResponse(writer, req, http.StatusNotModified, "", false) + return + } + + // Write the updated inventory to the inventory json file + err = utilities.WriteToJSONFile(InventoryFileName, inventoryItems, 0644) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to write inventory: "+err.Error(), true) + return + } + // return the new/updated items as JSON, or if for some reason it cannot be processed back into + // JSON for returning to the user, fallback to a simple string + updatedInventoryItemsJSON, err := utilities.GetAsJSON(updatedInventoryItems) + if err != nil { + response.SetStringHTTPResponseFields(http.StatusOK, "Updated inventory successfully", false) + } else { + response.SetJSONHTTPResponseFields(http.StatusOK, updatedInventoryItemsJSON, false) + } + response.WriteHTTPResponse(writer, req) + }) +} + +// InventoryPost allows new items to be added to inventory, as well as updating +// existing items +func InventoryPost(writer http.ResponseWriter, req *http.Request) { + // Use the ProcessCORS "decorator" function to reduce code repetition + utilities.ProcessCORS(writer, req, func(writer http.ResponseWriter, req *http.Request) { + response := utilities.GetHTTPResponseTemplate() + + // Read request body + body := make([]byte, req.ContentLength) + if _, err := io.ReadFull(req.Body, body); err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Failed to process the posted inventory item(s): "+err.Error(), true) + return + } + + // deltaInventoryList is created as a map[string]interface{} because we are being + // passed in _fields_ to update, not entire structs. If we attempt to use structs, + // golang will automatically populate fields that were not modified by the user. + // You can play with this using this Go playground URL: + // https://play.golang.org/p/XJ0wiE629z8 + deltaInventoryList := make([]map[string]interface{}, 0) + + err := json.Unmarshal(body, &deltaInventoryList) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Failed to process the posted inventory item(s): "+err.Error(), true) + return + } + + // load the inventory.json file + var inventoryItems Products + err = utilities.LoadFromJSONFile(InventoryFileName, &inventoryItems) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to retrieve all inventory items: "+err.Error(), true) + return + } + + // Keep track of the items that get added so that the user can be informed of them in our response + var newInventoryItems []Product + + // Loop through the posted inventory item list to find matching SKUs + inventoryChanged := false + for _, postedInventoryItem := range deltaInventoryList { + postedInventoryItemFound := false + for i := range inventoryItems.Data { + // If the SKU matches update that item + if postedInventoryItem["sku"] == inventoryItems.Data[i].SKU { + postedInventoryItemFound = true + if postedInventoryItem["itemPrice"] != nil { + switch postedInventoryItem["itemPrice"].(type) { + case float64: + inventoryItems.Data[i].ItemPrice = postedInventoryItem["itemPrice"].(float64) + } + } + if postedInventoryItem["maxRestockingLevel"] != nil { + switch postedInventoryItem["maxRestockingLevel"].(type) { + case float64: + inventoryItems.Data[i].MaxRestockingLevel = int(postedInventoryItem["maxRestockingLevel"].(float64)) + } + } + if postedInventoryItem["minRestockingLevel"] != nil { + switch postedInventoryItem["minRestockingLevel"].(type) { + case float64: + inventoryItems.Data[i].MinRestockingLevel = int(postedInventoryItem["minRestockingLevel"].(float64)) + } + } + if postedInventoryItem["isActive"] != nil { + switch postedInventoryItem["isActive"].(type) { + case bool: + inventoryItems.Data[i].IsActive = postedInventoryItem["isActive"].(bool) + } + } + if postedInventoryItem["unitsOnHand"] != nil { + switch postedInventoryItem["unitsOnHand"].(type) { + case float64: + inventoryItems.Data[i].UnitsOnHand = inventoryItems.Data[i].UnitsOnHand + int(postedInventoryItem["unitsOnHand"].(float64)) + } + + // Need to send an error if the product units on hand is below 0 + if inventoryItems.Data[i].UnitsOnHand < 0 { + fmt.Printf("Product %s on hand is less than 0 which was caused by a bad delta value", postedInventoryItem["sku"]) + } + // Item is under minimum stock level. Send notification + if inventoryItems.Data[i].UnitsOnHand <= inventoryItems.Data[i].MinRestockingLevel { + fmt.Printf("Product %s needs to be restocked\n", postedInventoryItem["sku"]) + } + // Item is under maximum stock level. Send notification + if inventoryItems.Data[i].UnitsOnHand > inventoryItems.Data[i].MaxRestockingLevel { + fmt.Printf("Product %s is overstocked\n", postedInventoryItem["sku"]) + } + } + inventoryItems.Data[i].UpdatedAt = time.Now().UnixNano() + inventoryChanged = true + newInventoryItems = append(newInventoryItems, inventoryItems.Data[i]) + response.SetStringHTTPResponseFields(http.StatusOK, "Updated inventory", false) + } + } + if !postedInventoryItemFound { + newProduct := Product{ + SKU: postedInventoryItem["sku"].(string), + CreatedAt: time.Now().UnixNano(), + UpdatedAt: time.Now().UnixNano(), + IsActive: true, + } + // Set the ItemPrice. If the ItemPrice isn't provided set a default value + if postedInventoryItem["itemPrice"] != nil { + switch postedInventoryItem["itemPrice"].(type) { + case float64: + newProduct.ItemPrice = postedInventoryItem["itemPrice"].(float64) + default: + newProduct.ItemPrice = 0 + } + } else { + newProduct.ItemPrice = 0 + } + // Set the UnitsOnHand. If the UnitsOnHand isn't provided set a default value + if postedInventoryItem["unitsOnHand"] != nil { + switch postedInventoryItem["unitsOnHand"].(type) { + case float64: + newProduct.UnitsOnHand = int(postedInventoryItem["unitsOnHand"].(float64)) + default: + newProduct.UnitsOnHand = 0 + } + } else { + newProduct.UnitsOnHand = 0 + } + // Set the maxRestockingLevel. If the maxRestockingLevel isn't provided set a default value + if postedInventoryItem["maxRestockingLevel"] != nil { + switch postedInventoryItem["maxRestockingLevel"].(type) { + case float64: + newProduct.MaxRestockingLevel = int(postedInventoryItem["maxRestockingLevel"].(float64)) + default: + newProduct.MaxRestockingLevel = 5 + } + } else { + newProduct.MaxRestockingLevel = 5 + } + // Set the minRestockingLevel. If the minRestockingLevel isn't provided set a default value + if postedInventoryItem["minRestockingLevel"] != nil { + switch postedInventoryItem["minRestockingLevel"].(type) { + case float64: + newProduct.MinRestockingLevel = int(postedInventoryItem["minRestockingLevel"].(float64)) + default: + newProduct.MinRestockingLevel = 0 + } + } else { + newProduct.MinRestockingLevel = 0 + } + // Add new product to the product List + inventoryItems.Data = append(inventoryItems.Data, newProduct) + inventoryChanged = true + newInventoryItems = append(newInventoryItems, newProduct) + response.SetStringHTTPResponseFields(http.StatusOK, "Updated inventory", false) + } + } + + if inventoryChanged { + // Write the updated audit log to the audit log json file + err = utilities.WriteToJSONFile(InventoryFileName, inventoryItems, 0644) + if err != nil { + + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to write inventory: "+err.Error(), true) + return + } + // return the new/updated items as JSON, or if for some reason it cannot be processed back into + // JSON for returning to the user, fallback to a simple string + newInventoryItemsJSON, err := utilities.GetAsJSON(newInventoryItems) + if err != nil { + response.SetStringHTTPResponseFields(http.StatusOK, "Updated inventory successfully", false) + } else { + response.SetJSONHTTPResponseFields(http.StatusOK, newInventoryItemsJSON, false) + } + } + response.WriteHTTPResponse(writer, req) + }) +} + +// AuditLogPost allows for a new audit log entry to be added +func AuditLogPost(writer http.ResponseWriter, req *http.Request) { + // Use the ProcessCORS "decorator" function to reduce code repetition + utilities.ProcessCORS(writer, req, func(writer http.ResponseWriter, req *http.Request) { + response := utilities.GetHTTPResponseTemplate() + + // Read request body + body := make([]byte, req.ContentLength) + if _, err := io.ReadFull(req.Body, body); err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Failed to process the posted audit log entry: "+err.Error(), true) + return + } + + // Unmarshal the string contents of request into an AuditLogEntry struct + var postedAuditLogEntry AuditLogEntry + err := json.Unmarshal(body, &postedAuditLogEntry) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Failed to process the posted audit log entry: "+err.Error(), true) + return + } + + // Check if an existing UUID has been specified, + // and reject it if it has + if postedAuditLogEntry.AuditEntryID != "" { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "The submitted audit log entry must not have an auditEntryId defined.", true) + return + } + + // assign a new UUID to our new audit log entry + postedAuditLogEntry.AuditEntryID = utilities.GenUUID() + + // assign the CreatedAt value to right now, if the user hasn't passed it + if postedAuditLogEntry.CreatedAt == 0 { + postedAuditLogEntry.CreatedAt = time.Now().UnixNano() + } + + // load the auditlog.json file + var auditLog AuditLog + err = utilities.LoadFromJSONFile(AuditLogFileName, &auditLog) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to retrieve all audit log entries: "+err.Error(), true) + return + } + + // the odds of matching a UUID are either: + // * nearly impossible, mathematically + // * high due to developer / user error + // So we have to check for it. + foundEntry := false + for _, auditLogEntry := range auditLog.Data { + if postedAuditLogEntry.AuditEntryID == auditLogEntry.AuditEntryID { + foundEntry = true + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to process the requested audit log entry "+postedAuditLogEntry.AuditEntryID+" as it already exists", true) + break + } + } + // Happy path + // If we haven't found any conflicting UUID's and there have been no errors, + // proceed to update the list + if !foundEntry && !response.Error { + // write the result + auditLog.Data = append(auditLog.Data, postedAuditLogEntry) + + err = utilities.WriteToJSONFile(AuditLogFileName, auditLog, 0644) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to write the audit log entry "+postedAuditLogEntry.AuditEntryID+": "+err.Error(), true) + return + } + + // return the posted audit log entry to the user once added + result, err := utilities.GetAsJSON(postedAuditLogEntry) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to return the requested audit log entry to the user "+postedAuditLogEntry.AuditEntryID+": "+err.Error(), true) + return + } + + // Happy path HTTP response + response.SetJSONHTTPResponseFields(http.StatusOK, result, false) + } + response.WriteHTTPResponse(writer, req) + }) +} diff --git a/ms-inventory/routes/sets_test.go b/ms-inventory/routes/sets_test.go new file mode 100644 index 0000000..b792c88 --- /dev/null +++ b/ms-inventory/routes/sets_test.go @@ -0,0 +1,218 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "bytes" + "io/ioutil" + "net/http" + "net/http/httptest" + "testing" + + "github.com/stretchr/testify/require" +) + +// TestInventoryPost tests the function InventoryPost +func TestInventoryPost(t *testing.T) { + // Product slice + products := getDefaultProductsList() + + tests := []struct { + Name string + BadInventory bool + ProductUpdateString string + ExpectedStatusCode int + ProductsMatch bool + }{ + {"modify first inventory item price", false, `[{"sku": "4900002470","itemPrice": 10.5,"unitsOnHand": 2,"maxRestockingLevel": 9,"minRestockingLevel": 1,"isActive": false}]`, http.StatusOK, false}, + {"add new inventory item", false, `[{"sku": "9999999999","itemPrice": 10.5,"unitsOnHand": 2,"maxRestockingLevel": 9,"minRestockingLevel": 1,"isActive": false}]`, http.StatusOK, false}, + {"add new inventory item with default items", false, `[{"sku": "8888888888","isActive": false}]`, http.StatusOK, false}, + {"modify inventory item with strings instead of float values", false, `[{"sku": "7777777777","itemPrice": "zero","unitsOnHand": "zero","maxRestockingLevel": "zero","minRestockingLevel": "zero","isActive": false}]`, http.StatusOK, false}, + {"reduce inventory below 0", false, `[{"sku": "4900002470","itemPrice": 10.5,"unitsOnHand": -10,"maxRestockingLevel": 9,"minRestockingLevel": 1,"isActive": false}]`, http.StatusOK, false}, + {"raise inventory above max threshold", false, `[{"sku": "4900002470","itemPrice": 10.5,"unitsOnHand": 20,"maxRestockingLevel": 9,"minRestockingLevel": 1,"isActive": false}]`, http.StatusOK, false}, + {"invalid inventory item", false, `invalid item`, http.StatusBadRequest, true}, + {"invalid inventory item", true, `[{"sku": "4900002470","itemPrice": 10.5,"unitsOnHand": 2,"maxRestockingLevel": 9,"minRestockingLevel": 1,"isActive": false}]`, http.StatusInternalServerError, true}, + } + + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + err := DeleteInventory() + require.NoError(t, err) + + if currentTest.BadInventory { + err := ioutil.WriteFile(InventoryFileName, []byte("invalid json test"), 0644) + require.NoError(t, err) + } else { + err := products.WriteInventory() + require.NoError(t, err) + } + + req := httptest.NewRequest("POST", "http://localhost:48096/inventory", bytes.NewBuffer([]byte(currentTest.ProductUpdateString))) + w := httptest.NewRecorder() + req.Header.Set("Content-Type", "application/json") + InventoryPost(w, req) + resp := w.Result() + defer resp.Body.Close() + + require.Equal(t, currentTest.ExpectedStatusCode, resp.StatusCode, "invalid status code") + + if !test.BadInventory { + // run GetInventoryItems and get the result as JSON + productsFromFile, err := GetInventoryItems() + require.NoError(t, err) + + if currentTest.ProductsMatch { + require.Equal(t, products, productsFromFile, "Products should match") + } else { + require.NotEqual(t, products, productsFromFile, "Products should not match") + } + } + }) + } +} + +// TestAuditLogPost tests the function AuditLogPost +// related functions +func TestAuditLogPost(t *testing.T) { + // Audit slice + audits := getDefaultAuditsList() + + tests := []struct { + Name string + BadAuditLog bool + AuditLogUpdate string + ExpectedStatusCode int + AuditsMatch bool + }{ + {"Test AuditLogPost add new audit log entry with no CreatdAt field", false, `{"CardID":"0003292356","AccountID":1,"RoleID":1,"PersonID":1,"InventoryDelta":[{"SKU":"4900002470","Delta": 5},{"SKU":"1200010735","Delta": 5}]}`, http.StatusOK, false}, + {"Test AuditLogPost with an entry id", false, `{"CardID":"0003292356","AccountID":1,"RoleID":1,"PersonID":1,"AuditEntryID":"1","InventoryDelta":[{"SKU":"4900002470","Delta": 5},{"SKU":"1200010735","Delta": 5}]}`, http.StatusBadRequest, true}, + {"Test InventoryPost invalid audit log item", false, "This is an invalid string", http.StatusBadRequest, true}, + {"Test InventoryPost invalid audit log list json", true, `{"CardID":"0003292356","AccountID":1,"RoleID":1,"PersonID":1,"InventoryDelta":[{"SKU":"4900002470","Delta": 5},{"SKU":"1200010735","Delta": 5}]}`, http.StatusInternalServerError, false}, + } + + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + err := DeleteAuditLog() + require.NoError(t, err) + + if currentTest.BadAuditLog { + err := ioutil.WriteFile(AuditLogFileName, []byte("invalid json test"), 0644) + require.NoError(t, err) + } else { + err := audits.WriteAuditLog() + require.NoError(t, err) + } + + req := httptest.NewRequest("POST", "http://localhost:48096/auditlog", bytes.NewBuffer([]byte(currentTest.AuditLogUpdate))) + w := httptest.NewRecorder() + req.Header.Set("Content-Type", "application/json") + AuditLogPost(w, req) + resp := w.Result() + defer resp.Body.Close() + + require.Equal(t, currentTest.ExpectedStatusCode, resp.StatusCode, "invalid status code") + + if !currentTest.BadAuditLog { + // run GetAuditLog and get the result as JSON + auditsFromFile, err := GetAuditLog() + require.NoError(t, err) + + if currentTest.AuditsMatch { + require.Equal(t, audits, auditsFromFile, "Audits should match") + } else { + require.NotEqual(t, audits, auditsFromFile, "Audits should not match") + } + } + }) + } +} + +// TestDeltaInventorySKUPost tests the function DeltaInventorySKUPost +func TestDeltaInventorySKUPost(t *testing.T) { + // Product slice + products := Products{ + Data: []Product{{ + CreatedAt: 1567787309, + IsActive: true, + ItemPrice: 1.99, + MaxRestockingLevel: 24, + MinRestockingLevel: 0, + ProductName: "Sprite (Lemon-Lime) - 16.9 oz", + SKU: "4900002470", + UnitsOnHand: 5, + UpdatedAt: 1567787309, + }, { + CreatedAt: 1567787309, + IsActive: true, + ItemPrice: 1.99, + MaxRestockingLevel: 18, + MinRestockingLevel: 0, + ProductName: "Mountain Dew (Low Calorie) - 16.9 oz", + SKU: "1200010735", + UnitsOnHand: 5, + UpdatedAt: 1567787309, + }, { + CreatedAt: 1567787309, + IsActive: true, + ItemPrice: 1.99, + MaxRestockingLevel: 6, + MinRestockingLevel: 0, + ProductName: "Mountain Dew - 16.9 oz", + SKU: "1200050408", + UnitsOnHand: 5, + UpdatedAt: 1567787309, + }}} + + tests := []struct { + Name string + BadInventory bool + DeltaUpdateString string + ExpectedStatusCode int + ProductsMatch bool + }{ + {"subtracting 1 item from existing SKU", false, `[{"SKU": "4900002470","Delta": -1}]`, http.StatusOK, false}, + {"missing SKU and no delta change", false, `[{"SKU": "0000000000","Delta": 0}]`, http.StatusNotModified, true}, + {"invalid delta json", false, `This is an invalid string`, http.StatusBadRequest, true}, + {"subtracting 1 item from existing SKU with invalid inventory", true, `[{"SKU": "4900002470","Delta": -1}]`, http.StatusInternalServerError, false}, + } + + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + err := DeleteInventory() + require.NoError(t, err) + + if currentTest.BadInventory { + err := ioutil.WriteFile(InventoryFileName, []byte("invalid json test"), 0644) + require.NoError(t, err) + } else { + err := products.WriteInventory() + require.NoError(t, err) + } + + req := httptest.NewRequest("POST", "http://localhost:48096/inventory/delta", bytes.NewBuffer([]byte(currentTest.DeltaUpdateString))) + w := httptest.NewRecorder() + req.Header.Set("Content-Type", "application/json") + DeltaInventorySKUPost(w, req) + resp := w.Result() + defer resp.Body.Close() + + require.Equal(t, currentTest.ExpectedStatusCode, resp.StatusCode, "invalid status code") + + if !currentTest.BadInventory { + // run GetInventoryItems and get the result as JSON + productsFromFile, err := GetInventoryItems() + require.NoError(t, err) + + if currentTest.ProductsMatch { + require.Equal(t, products, productsFromFile, "Products should match") + } else { + require.NotEqual(t, products, productsFromFile, "Products should not match") + } + } + }) + } +} diff --git a/ms-ledger/.gitignore b/ms-ledger/.gitignore new file mode 100644 index 0000000..3994203 --- /dev/null +++ b/ms-ledger/.gitignore @@ -0,0 +1,19 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, build with `go test -c` +*.test +main +ms-ledger +test.txt +go.sum +.vscode/* + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out +logs/* +logs/ \ No newline at end of file diff --git a/ms-ledger/.golangci.yml b/ms-ledger/.golangci.yml new file mode 100644 index 0000000..00ec54e --- /dev/null +++ b/ms-ledger/.golangci.yml @@ -0,0 +1,28 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +run: + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 5m +linters-settings: + misspell: + locale: US +linters: + enable: + - bodyclose + - errcheck + - goconst + - golint + - govet + - gosimple + - ineffassign + - misspell + - staticcheck + - structcheck + - typecheck + - unused + - unconvert + - unparam + - varcheck + disable-all: true + fast: true diff --git a/ms-ledger/Dockerfile b/ms-ledger/Dockerfile new file mode 100644 index 0000000..da86100 --- /dev/null +++ b/ms-ledger/Dockerfile @@ -0,0 +1,30 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +FROM automated-checkout/build:latest AS builder + +LABEL license='SPDX-License-Identifier: BSD-3-Clause' \ + copyright='Copyright (c) 2019: Intel' + +RUN mkdir ms-ledger +WORKDIR /usr/local/bin/ms-ledger/ +COPY . . + +# Compile the code +RUN make gobuild + +# Next image - Copy built Go binary into new workspace +FROM alpine + +LABEL license='SPDX-License-Identifier: BSD-3-Clause' \ + copyright='Copyright (c) 2019: Intel' + +RUN apk --no-cache add zeromq +COPY --from=builder /usr/local/bin/ms-ledger/res/docker/configuration.toml /res/docker/configuration.toml +COPY --from=builder /usr/local/bin/ms-ledger/main /ms-ledger +COPY --from=builder /usr/local/bin/ms-ledger/ledger.json /ledger.json + +RUN chmod 640 /ledger.json && \ + chown 2000 /ledger.json + +CMD [ "/ms-ledger","--profile=docker","--confdir=/res", "-r" ] diff --git a/ms-ledger/LICENSE b/ms-ledger/LICENSE new file mode 100644 index 0000000..dbff156 --- /dev/null +++ b/ms-ledger/LICENSE @@ -0,0 +1,31 @@ +BSD 3-Clause License + +Copyright © 2020, Intel Corporation +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/ms-ledger/Makefile b/ms-ledger/Makefile new file mode 100644 index 0000000..9f87e0a --- /dev/null +++ b/ms-ledger/Makefile @@ -0,0 +1,46 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + + +.PHONY: build gobuild run gorun stop test lint + +MICROSERVICE=automated-checkout/ms-ledger + +build: + docker build --rm \ + --build-arg http_proxy \ + --build-arg https_proxy \ + -f Dockerfile \ + -t $(MICROSERVICE):dev \ + . + +gobuild: + CGO_ENABLED=1 GOOS=linux go build -ldflags='-s -w' -a -installsuffix cgo main.go + +run: + docker run \ + --rm \ + -p 48093:48093 \ + $(MICROSERVICE):dev + +gorun: + ./main + +stop: + docker rm -f $(MICROSERVICE):dev + +test: + go test -test.v -cover ./... + +testHTML: + go test -test.v -coverprofile=test_coverage.out ./... && \ + go tool cover -html=test_coverage.out + +GOLANGCI_VERSION := $(shell golangci-lint --version 2>/dev/null) + +lint: +ifdef GOLANGCI_VERSION + golangci-lint run +else + @echo "golangci-lint not found. Please refer to the README documentation for proper installation" +endif diff --git a/ms-ledger/go.mod b/ms-ledger/go.mod new file mode 100644 index 0000000..6c22b69 --- /dev/null +++ b/ms-ledger/go.mod @@ -0,0 +1,13 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +module ms-ledger + +go 1.12 + +require ( + github.com/edgexfoundry/app-functions-sdk-go v1.0.0 + github.com/gorilla/mux v1.7.2 + github.com/intel-iot-devkit/automated-checkout-utilities v1.0.0 + github.com/stretchr/testify v1.5.1 +) diff --git a/ms-ledger/ledger.json b/ms-ledger/ledger.json new file mode 100644 index 0000000..6bac701 --- /dev/null +++ b/ms-ledger/ledger.json @@ -0,0 +1,21 @@ +{ + "data": [{ + "accountID": 1, + "ledgers": [] + }, { + "accountID": 2, + "ledgers": [] + }, { + "accountID": 3, + "ledgers": [] + }, { + "accountID": 4, + "ledgers": [] + }, { + "accountID": 5, + "ledgers": [] + }, { + "accountID": 6, + "ledgers": [] + }] +} \ No newline at end of file diff --git a/ms-ledger/main.go b/ms-ledger/main.go new file mode 100644 index 0000000..3d30348 --- /dev/null +++ b/ms-ledger/main.go @@ -0,0 +1,76 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package main + +import ( + "context" + "fmt" + "ms-ledger/routes" + nethttp "net/http" + "os" + + "github.com/edgexfoundry/app-functions-sdk-go/appsdk" +) + +const ( + serviceKey = "ms-ledger" +) + +func main() { + // Create an instance of the EdgeX SDK and initialize it. + edgexSdk := &appsdk.AppFunctionsSDK{ServiceKey: serviceKey} + if err := edgexSdk.Initialize(); err != nil { + edgexSdk.LoggingClient.Error(fmt.Sprintf("SDK initialization failed: %v\n", err)) + os.Exit(-1) + } + + // How to access the application's specific configuration settings. + appSettings := edgexSdk.ApplicationSettings() + if appSettings == nil { + edgexSdk.LoggingClient.Error("No application settings found") + os.Exit(-1) + } + + var err error + + err = edgexSdk.AddRoute("/ledger", routes.AllAccountsGet, "OPTIONS", "GET") + errorAddRouteHandler(edgexSdk, err) + + err = edgexSdk.AddRoute("/ledger/{accountid}", routes.LedgerAccountGet, "OPTIONS", "GET") + errorAddRouteHandler(edgexSdk, err) + + err = edgexSdk.AddRoute("/ledger", addAppSettingsToContext(appSettings, routes.LedgerAddTransaction), "OPTIONS", "POST") + errorAddRouteHandler(edgexSdk, err) + + err = edgexSdk.AddRoute("/ledgerPaymentUpdate", routes.SetPaymentStatus, "OPTIONS", "POST") + errorAddRouteHandler(edgexSdk, err) + + err = edgexSdk.AddRoute("/ledger/{accountid}/{tid}", routes.LedgerDelete, "DELETE", "OPTIONS") + errorAddRouteHandler(edgexSdk, err) + + // Tell the SDK to "start" and begin listening for events to trigger the pipeline. + err = edgexSdk.MakeItRun() + if err != nil { + edgexSdk.LoggingClient.Error("MakeItRun returned error: ", err.Error()) + os.Exit(-1) + } + + // Do any required cleanup here + + os.Exit(0) +} + +func addAppSettingsToContext(appSettings map[string]string, next func(nethttp.ResponseWriter, *nethttp.Request)) func(nethttp.ResponseWriter, *nethttp.Request) { + return func(w nethttp.ResponseWriter, r *nethttp.Request) { + ctx := context.WithValue(r.Context(), routes.AppSettingsKey, appSettings) + next(w, r.WithContext(ctx)) + } +} + +func errorAddRouteHandler(edgexSdk *appsdk.AppFunctionsSDK, err error) { + if err != nil { + edgexSdk.LoggingClient.Error("Error adding route: %v", err.Error()) + os.Exit(-1) + } +} diff --git a/ms-ledger/res/configuration.toml b/ms-ledger/res/configuration.toml new file mode 100644 index 0000000..260477e --- /dev/null +++ b/ms-ledger/res/configuration.toml @@ -0,0 +1,45 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + + +[Writable] +LogLevel = 'INFO' + +[Service] +BootTimeout = '30s' +ClientMonitor = '15s' +CheckInterval = '10s' +Host = 'localhost' +Port = 8080 +Protocol = 'http' +ReadMaxLimit = 100 +StartupMsg = 'This microservice exposes a CRUD interface for financial transactions in a ledger' +Timeout = '30s' + +[Registry] +Host = "localhost" +Port = 8500 +Type = 'consul' + +[MessageBus] +Type = 'zero' + [MessageBus.PublishHost] + Host = '*' + Port = 5564 + Protocol = 'tcp' + [MessageBus.SubscribeHost] + Host = 'localhost' + Port = 5563 + Protocol = 'tcp' + +[Logging] +EnableRemote = false +File = './logs/ms-ledger-publish.log' + +[Binding] +Type="http" +SubscribeTopic="" +PublishTopic="" + +[ApplicationSettings] +InventoryEndpoint = "http://localhost:48095/inventory" diff --git a/ms-ledger/res/docker/configuration.toml b/ms-ledger/res/docker/configuration.toml new file mode 100644 index 0000000..56fb5f3 --- /dev/null +++ b/ms-ledger/res/docker/configuration.toml @@ -0,0 +1,50 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + + +[Writable] +LogLevel = 'INFO' + +[Service] +BootTimeout = '30s' +ClientMonitor = '15s' +CheckInterval = '10s' +Host = 'ms-ledger' +Port = 48093 +Protocol = 'http' +ReadMaxLimit = 100 +StartupMsg = 'This microservice exposes a CRUD interface for financial transactions in a ledger' +Timeout = '30s' + +[Clients] + [Clients.Logging] + Host = "edgex-support-logging" + Protocol = "http" + Port = 48061 + +[Registry] +Host = "edgex-core-consul" +Port = 8500 +Type = 'consul' + +[MessageBus] +Type = 'zero' + [MessageBus.PublishHost] + Host = '*' + Port = 5564 + Protocol = 'tcp' + [MessageBus.SubscribeHost] + Host = 'edgex-core-data' + Port = 5563 + Protocol = 'tcp' + +[Logging] +EnableRemote = true + +[Binding] +Type="http" +SubscribeTopic="" +PublishTopic="" + +[ApplicationSettings] +InventoryEndpoint = "http://ms-inventory:48095/inventory" diff --git a/ms-ledger/routes/common.go b/ms-ledger/routes/common.go new file mode 100644 index 0000000..e0697e9 --- /dev/null +++ b/ms-ledger/routes/common.go @@ -0,0 +1,59 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "bytes" + "errors" + "fmt" + "net/http" + "time" + + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +// LedgerFileName is the filename for ledger.json file +var LedgerFileName = "ledger.json" +var connectionTimeout = 15 + +// GetAllLedgers is a common function to get all ledgers for all accounts +func GetAllLedgers() (Accounts, error) { + var accountLedgers Accounts + + err := utilities.LoadFromJSONFile(LedgerFileName, &accountLedgers) + if err != nil { + return Accounts{}, errors.New( + "Failed to load ledger JSON file: " + err.Error(), + ) + } + return accountLedgers, nil +} + +// DeleteAllLedgers will reset the content of the inventory JSON file +func DeleteAllLedgers() error { + return utilities.WriteToJSONFile(LedgerFileName, Accounts{Data: []Account{}}, 0644) +} + +// TODO: refactor this into the utilities package +func sendCommand(method string, commandURL string, inputBytes []byte) (*http.Response, error) { + // Create the http request based on the parameters + request, _ := http.NewRequest(method, commandURL, bytes.NewBuffer(inputBytes)) + timeout := time.Duration(connectionTimeout) * time.Second + client := &http.Client{ + Timeout: timeout, + } + + // Execute the http request + resp, err := client.Do(request) + if err != nil { + return nil, fmt.Errorf("Error sending data: %v", err.Error()) + } + + // Check the status code and return any errors + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("Error sending request: Received status code %v", resp.Status) + } + + return resp, nil +} diff --git a/ms-ledger/routes/common_test.go b/ms-ledger/routes/common_test.go new file mode 100644 index 0000000..fab5d9c --- /dev/null +++ b/ms-ledger/routes/common_test.go @@ -0,0 +1,90 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "testing" + + "github.com/stretchr/testify/require" + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +func getDefaultAccountLedgers() Accounts { + return Accounts{ + Data: []Account{{ + AccountID: 1, + Ledgers: []Ledger{{ + TransactionID: 1579215712984890248, + TxTimeStamp: 1579215712984890363, + LineTotal: 1.99, + CreatedAt: 1579215712984890443, + UpdatedAt: 1579215712984890517, + IsPaid: false, + LineItems: []LineItem{{ + SKU: "1200050408", + ProductName: "Mountain Dew - 16.9 oz", + ItemPrice: 1.99, + ItemCount: 1, + }}, + }}, + }, { + AccountID: 2, + Ledgers: []Ledger{{ + TransactionID: 2579215712984890248, + TxTimeStamp: 2579215712984890363, + LineTotal: 2.99, + CreatedAt: 2579215712984890443, + UpdatedAt: 2579215712984890517, + IsPaid: false, + LineItems: []LineItem{{ + SKU: "2200050408", + ProductName: "Mountain Blue - 16.9 oz", + ItemPrice: 2.99, + ItemCount: 1, + }}, + }}, + }}} +} + +func TestGetAllLedgers(t *testing.T) { + // Use community-recommended shorthand (known name clash) + + require := require.New(t) + // Accounts slice + accountLedgers := getDefaultAccountLedgers() + + // Write the ledger + err := utilities.WriteToJSONFile(LedgerFileName, &accountLedgers, 0644) + require.NoError(err) + + // run GetAllLedgers and get the result as JSON + actualAccountLedgers, err := GetAllLedgers() + require.NoError(err) + + // Check to make sure items match + require.Equal(accountLedgers, actualAccountLedgers, "Ledgers should match") +} + +func TestDeleteAllLedgers(t *testing.T) { + // Use community-recommended shorthand (known name clash) + + require := require.New(t) + // Accounts slice + accountLedgers := getDefaultAccountLedgers() + + expectedLedger := Accounts{Data: []Account{}} + + // Write the ledger + err := utilities.WriteToJSONFile(LedgerFileName, &accountLedgers, 0644) + require.NoError(err) + + // Delete Ledger + err = DeleteAllLedgers() + require.NoError(err) + updatedLedger, err := GetAllLedgers() + require.NoError(err) + + // Check that deleted Ledger has no ledger data + require.Equal(updatedLedger, expectedLedger, "Ledger should have no data") +} diff --git a/ms-ledger/routes/deletes.go b/ms-ledger/routes/deletes.go new file mode 100644 index 0000000..1ebda7d --- /dev/null +++ b/ms-ledger/routes/deletes.go @@ -0,0 +1,66 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "net/http" + "strconv" + + "github.com/gorilla/mux" + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +// LedgerDelete will delete a specific ledger for an account +func LedgerDelete(writer http.ResponseWriter, req *http.Request) { + utilities.ProcessCORS(writer, req, func(writer http.ResponseWriter, req *http.Request) { + + //Get all ledgers for all accounts + accountLedgers, err := GetAllLedgers() + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to retrieve all ledgers for accounts "+err.Error(), true) + return + } + + // Get variables from HTTP request + vars := mux.Vars(req) + tidstr := vars["tid"] + tid, tiderr := strconv.ParseInt(tidstr, 10, 64) + if tiderr != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "transactionID contains bad data", true) + return + } + + accountIDstr := vars["accountid"] + accountID, accountIDerr := strconv.Atoi(accountIDstr) + if accountIDerr != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "accountID contains bad data", true) + return + } + + //Iterate through accounts + if tid > 0 && accountID >= 0 { + for accountIndex, account := range accountLedgers.Data { + if accountID == account.AccountID { + for ledgerIndex, ledger := range account.Ledgers { + if tid == ledger.TransactionID { + accountLedgers.Data[accountIndex].Ledgers = append(account.Ledgers[:ledgerIndex], account.Ledgers[ledgerIndex+1:]...) + + err := utilities.WriteToJSONFile(LedgerFileName, &accountLedgers, 0644) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to update ledger with deleted transaction", true) + return + } + utilities.WriteStringHTTPResponse(writer, req, http.StatusOK, "Deleted ledger "+tidstr, false) + return + } + } + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Could not find Transaction "+strconv.FormatInt(tid, 10), true) + return + } + } + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Could not find account "+strconv.Itoa(accountID), true) + return + } + }) +} diff --git a/ms-ledger/routes/deletes_test.go b/ms-ledger/routes/deletes_test.go new file mode 100644 index 0000000..195e7d3 --- /dev/null +++ b/ms-ledger/routes/deletes_test.go @@ -0,0 +1,90 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "bytes" + "io/ioutil" + "net/http" + "net/http/httptest" + "testing" + + "github.com/gorilla/mux" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +func TestLedgerDelete(t *testing.T) { + // Use community-recommended shorthand (known name clash) + require := require.New(t) + assert := assert.New(t) + + // Accounts slice + accountLedgers := getDefaultAccountLedgers() + // Default variables + defaultAccountID := "1" + InvalidAccountID := "10" + defaultTransactionID := "1579215712984890248" + InvalidTransactionID := "1579215712984890249" + + tests := []struct { + Name string + InvalidLedger bool + AccountID string + TransactionID string + TransactionDeleted bool + ExpectedStatusCode int + }{ + {"Valid AccountID and TransactionID", false, defaultAccountID, defaultTransactionID, true, http.StatusOK}, + {"Bad data AccountID", false, "badformat", defaultTransactionID, false, http.StatusBadRequest}, + {"Nonexistent AccountID", false, InvalidAccountID, defaultTransactionID, false, http.StatusBadRequest}, + {"Bad data TransactionID", false, defaultAccountID, "badformat", false, http.StatusBadRequest}, + {"Nonexistent TransactionID", false, defaultAccountID, InvalidTransactionID, false, http.StatusBadRequest}, + {"Invalid Ledger Endpoint", true, defaultAccountID, defaultTransactionID, false, http.StatusInternalServerError}, + } + + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + err := DeleteAllLedgers() + require.NoError(err) + + if currentTest.InvalidLedger { + err = ioutil.WriteFile(LedgerFileName, []byte("invalid json test"), 0644) + } else { + err = utilities.WriteToJSONFile(LedgerFileName, &accountLedgers, 0644) + } + require.NoError(err) + + req := httptest.NewRequest("DELETE", "http://localhost:48093/ledger", bytes.NewBuffer([]byte(currentTest.AccountID+"/"+currentTest.TransactionID))) + w := httptest.NewRecorder() + + URLVars := map[string]string{ + "accountid": currentTest.AccountID, + "tid": currentTest.TransactionID, + } + + req = mux.SetURLVars(req, URLVars) + req.Header.Set("Content-Type", "application/json") + LedgerDelete(w, req) + resp := w.Result() + defer resp.Body.Close() + + assert.Equal(currentTest.ExpectedStatusCode, resp.StatusCode, "invalid status code") + + if !currentTest.InvalidLedger { + // run GetAllLedgers and get the result as JSON + accountsFromFile, err := GetAllLedgers() + require.NoError(err) + + if currentTest.TransactionDeleted { + assert.NotEqual(accountLedgers, accountsFromFile, "Ledgers should not match") + } else { + assert.Equal(accountLedgers, accountsFromFile, "Ledgers should match") + } + } + }) + } +} diff --git a/ms-ledger/routes/gets.go b/ms-ledger/routes/gets.go new file mode 100644 index 0000000..ea50236 --- /dev/null +++ b/ms-ledger/routes/gets.go @@ -0,0 +1,71 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "net/http" + "strconv" + + "github.com/gorilla/mux" + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +// LedgerAccountGet will get the transaction ledger for a specific account +func LedgerAccountGet(writer http.ResponseWriter, req *http.Request) { + utilities.ProcessCORS(writer, req, func(writer http.ResponseWriter, req *http.Request) { + //Get all ledgers for all accounts + accountLedgers, err := GetAllLedgers() + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to retrieve all ledgers for accounts "+err.Error(), true) + return + } + + // Get the current accountID from the request + vars := mux.Vars(req) + accountIDstr := vars["accountid"] + accountID, err := strconv.Atoi(accountIDstr) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "AccountID is invalid "+err.Error(), true) + return + } + + if accountID >= 0 { + for _, account := range accountLedgers.Data { + if accountID == account.AccountID { + accountLedger, err := utilities.GetAsJSON(account) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to retrieve account ledger "+err.Error(), true) + return + } + utilities.WriteJSONHTTPResponse(writer, req, http.StatusOK, accountLedger, false) + return + } + } + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "AccountID not found in ledger", false) + return + } + }) +} + +// AllAccountsGet will get the entire ledger with transactions for all accounts +func AllAccountsGet(writer http.ResponseWriter, req *http.Request) { + utilities.ProcessCORS(writer, req, func(writer http.ResponseWriter, req *http.Request) { + + // Get the list of accounts with all ledgers + accountLedgers, err := GetAllLedgers() + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to retrieve all ledgers for accounts "+err.Error(), true) + return + } + + // No logic needs to be done here, since we are just reading the file + // and writing it back out. Simply marshaling it will validate its structure + accountLedgersJSON, err := utilities.GetAsJSON(accountLedgers) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to unmarshal accountLedgers", true) + return + } + utilities.WriteJSONHTTPResponse(writer, req, http.StatusOK, accountLedgersJSON, false) + }) +} diff --git a/ms-ledger/routes/gets_test.go b/ms-ledger/routes/gets_test.go new file mode 100644 index 0000000..038fd19 --- /dev/null +++ b/ms-ledger/routes/gets_test.go @@ -0,0 +1,100 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "io/ioutil" + "net/http" + "net/http/httptest" + "strconv" + "testing" + + "github.com/gorilla/mux" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +func TestAllAccountsGet(t *testing.T) { + // Use community-recommended shorthand (known name clash) + require := require.New(t) + + // Accounts slice + accountLedgers := getDefaultAccountLedgers() + + tests := []struct { + Name string + InvalidLedger bool + ExpectedStatusCode int + }{ + {"Valid Ledger", false, http.StatusOK}, + {"Invalid Ledger ", true, http.StatusInternalServerError}, + } + + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + err := DeleteAllLedgers() + require.NoError(err) + if currentTest.InvalidLedger { + err = ioutil.WriteFile(LedgerFileName, []byte("invalid json test"), 0644) + } else { + err = utilities.WriteToJSONFile(LedgerFileName, &accountLedgers, 0644) + } + require.NoError(err) + + req := httptest.NewRequest("GET", "http://localhost:48093/ledger", nil) + w := httptest.NewRecorder() + AllAccountsGet(w, req) + resp := w.Result() + defer resp.Body.Close() + + assert.Equal(t, currentTest.ExpectedStatusCode, resp.StatusCode, "invalid status code") + }) + } +} + +func TestLedgerAccountGet(t *testing.T) { + // Use community-recommended shorthand (known name clash) + require := require.New(t) + + // Accounts slice + accountLedgers := getDefaultAccountLedgers() + invalidAccountID := "0" + + tests := []struct { + Name string + InvalidLedger bool + AccountID string + ExpectedStatusCode int + }{ + {"Valid Account ID", false, strconv.Itoa(accountLedgers.Data[0].AccountID), http.StatusOK}, + {"Bad data Account ID", false, "invalidAccountSyntax", http.StatusBadRequest}, + {"Nonexistent AccountID ", false, invalidAccountID, http.StatusBadRequest}, + {"Invalid Ledger", true, strconv.Itoa(accountLedgers.Data[0].AccountID), http.StatusInternalServerError}, + } + + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + err := DeleteAllLedgers() + require.NoError(err) + if currentTest.InvalidLedger { + err = ioutil.WriteFile(LedgerFileName, []byte("invalid json test"), 0644) + } else { + err = utilities.WriteToJSONFile(LedgerFileName, &accountLedgers, 0644) + } + require.NoError(err) + + req := httptest.NewRequest("GET", "http://localhost:48093/ledger/"+test.AccountID, nil) + w := httptest.NewRecorder() + req = mux.SetURLVars(req, map[string]string{"accountid": currentTest.AccountID}) + LedgerAccountGet(w, req) + resp := w.Result() + defer resp.Body.Close() + + assert.Equal(t, currentTest.ExpectedStatusCode, resp.StatusCode, "invalid status code") + }) + } +} diff --git a/ms-ledger/routes/ledger.json b/ms-ledger/routes/ledger.json new file mode 100644 index 0000000..9b96b0c --- /dev/null +++ b/ms-ledger/routes/ledger.json @@ -0,0 +1 @@ +invalid json test \ No newline at end of file diff --git a/ms-ledger/routes/models.go b/ms-ledger/routes/models.go new file mode 100644 index 0000000..4f4ff2b --- /dev/null +++ b/ms-ledger/routes/models.go @@ -0,0 +1,65 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +type key string + +const ( + // AppSettingsKey is used to store the appSetting in the handler's request context + AppSettingsKey key = "appSetting" +) + +type Accounts struct { + Data []Account `json:"data"` +} + +type Ledger struct { + TransactionID int64 `json:"transactionID,string"` + TxTimeStamp int64 `json:"txTimeStamp,string"` + LineTotal float64 `json:"lineTotal"` + CreatedAt int64 `json:"createdAt,string"` + UpdatedAt int64 `json:"updatedAt,string"` + IsPaid bool `json:"isPaid"` + LineItems []LineItem `json:"lineItems"` +} + +type LineItem struct { + SKU string `json:"sku"` + ProductName string `json:"productName"` + ItemPrice float64 `json:"itemPrice"` + ItemCount int `json:"itemCount"` +} + +type Account struct { + AccountID int `json:"accountID"` + Ledgers []Ledger `json:"ledgers"` +} + +type Product struct { + SKU string `json:"sku"` + ItemPrice float64 `json:"itemPrice"` + ProductName string `json:"productName"` + UnitsOnHand int `json:"unitsOnHand"` + MaxRestockingLevel int `json:"maxRestockingLevel"` + MinRestockingLevel int `json:"minRestockingLevel"` + CreatedAt int64 `json:"createdAt,string"` + UpdatedAt int64 `json:"updatedAt,string"` + IsActive bool `json:"isActive"` +} + +type paymentInfo struct { + AccountID int `json:"accountID"` + TransactionID int64 `json:"transactionID,string"` + IsPaid bool `json:"isPaid"` +} + +type deltaLedger struct { + AccountID int `json:"accountId"` + DeltaSKUs []deltaSKU `json:"deltaSKUs"` +} + +type deltaSKU struct { + SKU string `json:"sku"` + Delta int `json:"delta"` +} diff --git a/ms-ledger/routes/sets.go b/ms-ledger/routes/sets.go new file mode 100644 index 0000000..be1742e --- /dev/null +++ b/ms-ledger/routes/sets.go @@ -0,0 +1,207 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "encoding/json" + "fmt" + "io" + "io/ioutil" + "math" + "net/http" + "strconv" + "time" + + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +// SetPaymentStatus sets the `isPaid` field for a transaction to true/false +func SetPaymentStatus(writer http.ResponseWriter, req *http.Request) { + utilities.ProcessCORS(writer, req, func(writer http.ResponseWriter, req *http.Request) { + + // Read request body + body := make([]byte, req.ContentLength) + _, err := io.ReadFull(req.Body, body) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Failed to parse request body", true) + return + } + + // Unmarshal the string contents of request into a proper structure + var paymentStatus paymentInfo + if err := json.Unmarshal(body, &paymentStatus); err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Failed to unmarshal body", true) + return + } + + //Get all ledgers for all accounts + accountLedgers, err := GetAllLedgers() + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to retrieve all ledgers for accounts "+err.Error(), true) + return + } + + for accountIndex, account := range accountLedgers.Data { + if paymentStatus.AccountID == account.AccountID { + for transactionIndex, transaction := range account.Ledgers { + if paymentStatus.TransactionID == transaction.TransactionID { + accountLedgers.Data[accountIndex].Ledgers[transactionIndex].IsPaid = paymentStatus.IsPaid + + err := utilities.WriteToJSONFile(LedgerFileName, &accountLedgers, 0644) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to update ledger", true) + return + } + + utilities.WriteStringHTTPResponse(writer, req, http.StatusOK, "Updated Payment Status for transaction "+strconv.FormatInt(paymentStatus.TransactionID, 10), false) + return + } + } + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Could not find Transaction "+strconv.FormatInt(paymentStatus.TransactionID, 10), true) + return + } + } + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Could not find account "+strconv.Itoa(paymentStatus.AccountID), true) + }) +} + +// LedgerAddTransaction adds a new transaction to the Account Ledger +func LedgerAddTransaction(writer http.ResponseWriter, req *http.Request) { + utilities.ProcessCORS(writer, req, func(writer http.ResponseWriter, req *http.Request) { + + response := utilities.GetHTTPResponseTemplate() + + appSettings, ok := req.Context().Value(AppSettingsKey).(map[string]string) + if !ok { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to read appSettings value", true) + return + } + + // Read request body (this is the inference data) + body := make([]byte, req.ContentLength) + _, err := io.ReadFull(req.Body, body) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Failed to parse request body", true) + return + } + + // Unmarshal the string contents of request for inference data into a proper structure + // deltaLedger is accountID and list of Sku:delta + var updateLedger deltaLedger + if err := json.Unmarshal(body, &updateLedger); err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Failed to unmarshal request body", true) + return + } + + //Get all ledgers for all accounts + accountLedgers, err := GetAllLedgers() + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to retrieve all ledgers for accounts "+err.Error(), true) + return + } + + ledgerChanged := false + var newLedger Ledger + + for accountIndex, account := range accountLedgers.Data { + if updateLedger.AccountID == account.AccountID { + newLedger = Ledger{ + TransactionID: time.Now().UnixNano(), + TxTimeStamp: time.Now().UnixNano(), + LineTotal: 0, + CreatedAt: time.Now().UnixNano(), + UpdatedAt: time.Now().UnixNano(), + IsPaid: false, + LineItems: []LineItem{}, + } + + for _, deltaSKU := range updateLedger.DeltaSKUs { + itemInfo, err := getInventoryItemInfo(appSettings, deltaSKU.SKU) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Could not find product Info for "+deltaSKU.SKU+" "+err.Error(), true) + return + } + newLineItem := LineItem{ + SKU: deltaSKU.SKU, + ProductName: itemInfo.ProductName, + ItemPrice: itemInfo.ItemPrice, + ItemCount: int(math.Abs(float64(deltaSKU.Delta))), + } + newLedger.LineItems = append(newLedger.LineItems, newLineItem) + newLedger.LineTotal = newLedger.LineTotal + (newLineItem.ItemPrice * float64(newLineItem.ItemCount)) + } + + // Add new Ledger to array of Ledgers for that account + accountLedgers.Data[accountIndex].Ledgers = append(accountLedgers.Data[accountIndex].Ledgers, newLedger) + ledgerChanged = true + } + } + + if !ledgerChanged { + utilities.WriteStringHTTPResponse(writer, req, http.StatusBadRequest, "Account not found", true) + return + } + + err = utilities.WriteToJSONFile(LedgerFileName, &accountLedgers, 0644) + if err != nil { + utilities.WriteStringHTTPResponse(writer, req, http.StatusInternalServerError, "Failed to update ledger", true) + return + } + + // return the new ledger as JSON, or if for some reason it cannot be processed back into + // JSON for returning to the user, fallback to a simple string + newLedgerJSON, err := utilities.GetAsJSON(newLedger) + if err != nil { + response.SetStringHTTPResponseFields(http.StatusOK, "Updated ledger successfully", false) + } else { + response.SetJSONHTTPResponseFields(http.StatusOK, newLedgerJSON, false) + } + response.WriteHTTPResponse(writer, req) + }) +} + +// getInventoryItemInfo is a helper function that will take the inference data (SKU) +// and return product details for a transaction to be recorded in the ledger +func getInventoryItemInfo(appSettings map[string]string, SKU string) (Product, error) { + + inventoryEndpoint, ok := appSettings["InventoryEndpoint"] + if !ok { + return Product{}, fmt.Errorf("InventoryEndpoint App Setting not found") + } + + resp, err := sendCommand("GET", inventoryEndpoint+"/"+SKU, []byte("")) + if err != nil { + return Product{}, fmt.Errorf("Could not hit inventoryEndpoint, SKU may not exist") + } + + defer resp.Body.Close() + + // Read the HTTP Response Body + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return Product{}, fmt.Errorf("Could not read response body from InventoryEndpoint") + } + + // Prepare to store the http response in this variable + var HTTPResponse utilities.HTTPResponse + + // Unmarshal the http response + err = json.Unmarshal(body, &HTTPResponse) + if err != nil { + return Product{}, fmt.Errorf("Received an invalid data structure from InventoryEndpoint") + } + // Check the HTTP response error condition + if HTTPResponse.Error { + return Product{}, fmt.Errorf("Received an error response from the inventory service: " + HTTPResponse.Content.(string)) + } + + // Prepare to unmarshal the desired inventory item from the HTTP response's body (json) + var inventoryItem Product + err = json.Unmarshal([]byte(HTTPResponse.Content.(string)), &inventoryItem) + if err != nil { + return Product{}, fmt.Errorf("Received an invalid data structure from InventoryEndpoint") + } + + return inventoryItem, nil +} diff --git a/ms-ledger/routes/sets_test.go b/ms-ledger/routes/sets_test.go new file mode 100644 index 0000000..ed79876 --- /dev/null +++ b/ms-ledger/routes/sets_test.go @@ -0,0 +1,214 @@ +// Copyright © 2020 Intel Corporation. All rights reserved. +// SPDX-License-Identifier: BSD-3-Clause + +package routes + +import ( + "bytes" + "context" + "encoding/json" + "io/ioutil" + "net/http" + "net/http/httptest" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + utilities "github.com/intel-iot-devkit/automated-checkout-utilities" +) + +func getDefaultProduct() Product { + return Product{ + CreatedAt: 1567787309, + IsActive: true, + ItemPrice: 1.99, + MaxRestockingLevel: 24, + MinRestockingLevel: 0, + ProductName: "Sprite (Lemon-Lime) - 16.9 oz", + SKU: "4900002470", + UnitsOnHand: 0, + UpdatedAt: 1567787309, + } +} + +func newInventoryTestServer(t *testing.T) *httptest.Server { + + inventoryServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + + expectedResponse := utilities.HTTPResponse{ + Content: "", + ContentType: "", + StatusCode: 200, + Error: false, + } + + // vars + defaultProduct := getDefaultProduct() + sku := r.RequestURI + + if sku == "/"+defaultProduct.SKU { + w.WriteHeader(http.StatusOK) + jsonProduct, _ := json.Marshal(defaultProduct) + expectedResponse.Content = string(jsonProduct) + jsonResponse, _ := json.Marshal(expectedResponse) + _, err := w.Write(jsonResponse) + if err != nil { + t.Fatal(err.Error()) + } + } else { + w.WriteHeader(http.StatusNotFound) + _, err := w.Write([]byte("Could not find product for SKU")) + if err != nil { + t.Fatal(err.Error()) + } + } + })) + + return inventoryServer +} + +func TestLedgerAddTransaction(t *testing.T) { + // Use community-recommended shorthand (known name clash) + require := require.New(t) + + // Accounts slice + accountLedgers := getDefaultAccountLedgers() + + appSettings := make(map[string]string) + + inventoryServer := newInventoryTestServer(t) + + appSettings["InventoryEndpoint"] = inventoryServer.URL + + tests := []struct { + Name string + InvalidLedger bool + UpdateLedger string + ExpectedStatusCode int + }{ + {"Valid SKU and accountID", false, `{"accountId":2,"deltaSKUs":[{"sku":"4900002470","delta":-1}]}`, http.StatusOK}, + {"Incorrect type for accountID", false, `{"accountId":"2","deltaSKUs":[{"sku":"4900002470","delta":-1}]}`, http.StatusBadRequest}, + {"Nonexistent accountID", false, `{"accountId":10,"deltaSKUs":[{"sku":"4900002470","delta":-1}]}`, http.StatusBadRequest}, + {"bad data for SKU", false, `{"accountId":2,"deltaSKUs":[{"sku":"badSKU","delta":-1}]}`, http.StatusBadRequest}, + {"Nonexistent SKU in inventory", false, `{"accountId":2,"deltaSKUs":[{"sku":"4900002479","delta":-1}]}`, http.StatusBadRequest}, + {"Invalid Ledger", true, `{"accountId":2,"deltaSKUs":[{"sku":"4900002470","delta":-1}]}`, http.StatusInternalServerError}, + } + + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + err := DeleteAllLedgers() + require.NoError(err) + if currentTest.InvalidLedger { + err = ioutil.WriteFile(LedgerFileName, []byte("invalid json test"), 0644) + } else { + err = utilities.WriteToJSONFile(LedgerFileName, &accountLedgers, 0644) + } + require.NoError(err) + + req := httptest.NewRequest("POST", "http://localhost:48093/ledger", bytes.NewBuffer([]byte(currentTest.UpdateLedger))) + w := httptest.NewRecorder() + req.Header.Set("Content-Type", "application/json") + ctx := req.Context() + ctx = context.WithValue(ctx, AppSettingsKey, appSettings) + req = req.WithContext(ctx) + req.Context() + LedgerAddTransaction(w, req) + + resp := w.Result() + defer resp.Body.Close() + + assert.Equal(t, currentTest.ExpectedStatusCode, resp.StatusCode, "invalid status code") + }) + } +} + +func TestGetInventoryItemInfo(t *testing.T) { + + appSettings := make(map[string]string) + // Default variables + defaultProduct := getDefaultProduct() + defaultSKU := "4900002470" + + inventoryServer := newInventoryTestServer(t) + + tests := []struct { + Name string + MissingAppSetting bool + InventoryEndpoint string + SKU string + ProductMatch bool + Error bool + }{ + {"Valid SKU", false, inventoryServer.URL, defaultSKU, true, false}, + {"Nonexistent SKU", false, inventoryServer.URL, "123", false, true}, + {"Missing AppSetting", true, inventoryServer.URL, defaultSKU, false, true}, + {"Invalid InventoryEndpoint", false, "badURL", defaultSKU, false, true}, + } + + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + if currentTest.MissingAppSetting { + badAppSettings := make(map[string]string) + _, err := getInventoryItemInfo(badAppSettings, currentTest.SKU) + require.Error(t, err) + return + } + + appSettings["InventoryEndpoint"] = currentTest.InventoryEndpoint + inventoryItem, err := getInventoryItemInfo(appSettings, currentTest.SKU) + if currentTest.Error { + require.Error(t, err) + return + } + assert.NoError(t, err) + + if currentTest.ProductMatch { + assert.Equal(t, defaultProduct, inventoryItem, "Products should match") + } + }) + } +} + +func TestSetPaymentStatus(t *testing.T) { + // Use community-recommended shorthand (known name clash) + require := require.New(t) + + // Accounts slice + accountLedgers := getDefaultAccountLedgers() + + tests := []struct { + Name string + InvalidLedger bool + PaymentInfo string + ExpectedStatusCode int + }{ + {"Valid Payment Info", false, `{"accountId":1,"transactionID":"1579215712984890248","isPaid": true }`, http.StatusOK}, + {"Nonexistent accountID", false, `{"accountId":10,"transactionID":"1579215712984890248","isPaid": true }`, http.StatusBadRequest}, + {"Nonexistent transactionID", false, `{"accountId":1,"transactionID":"1579215712984890249","isPaid": true }`, http.StatusBadRequest}, + {"Bad data in Payment Info", false, `{"accountId":1,"transactionID":"improperFormat","isPaid": true }`, http.StatusBadRequest}, + {"Invalid ledger", true, `{"accountId":1,"transactionID":"1579215712984890248","isPaid": true }`, http.StatusInternalServerError}, + } + for _, test := range tests { + currentTest := test + t.Run(currentTest.Name, func(t *testing.T) { + err := DeleteAllLedgers() + require.NoError(err) + if currentTest.InvalidLedger { + err = ioutil.WriteFile(LedgerFileName, []byte("invalid json test"), 0644) + } else { + err = utilities.WriteToJSONFile(LedgerFileName, &accountLedgers, 0644) + } + require.NoError(err) + + req := httptest.NewRequest("POST", "http://localhost:48093/ledger/ledgerPaymentUpdate", bytes.NewBuffer([]byte(currentTest.PaymentInfo))) + w := httptest.NewRecorder() + SetPaymentStatus(w, req) + resp := w.Result() + defer resp.Body.Close() + + assert.Equal(t, currentTest.ExpectedStatusCode, resp.StatusCode, "invalid status code") + }) + } +} diff --git a/res/device-mqtt/docker/configuration.toml b/res/device-mqtt/docker/configuration.toml new file mode 100644 index 0000000..44afbcd --- /dev/null +++ b/res/device-mqtt/docker/configuration.toml @@ -0,0 +1,100 @@ +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +[Service] +Host = "edgex-device-mqtt" +Port = 48100 +ConnectRetries = 100 +Labels = [] +OpenMsg = "device simple started" +Timeout = 5000 +EnableAsyncReadings = true +AsyncBufferSize = 16 + +[Registry] +Host = "edgex-core-consul" +Port = 8500 +CheckInterval = "10s" +FailLimit = 3 +FailWaitTime = 10 +Type = "consul" + +[Clients] + [Clients.Data] + Name = "edgex-core-data" + Protocol = "http" + Host = "edgex-core-data" + Port = 48080 + Timeout = 50000 + + [Clients.Metadata] + Name = "edgex-core-metadata" + Protocol = "http" + Host = "edgex-core-metadata" + Port = 48081 + Timeout = 50000 + + [Clients.Logging] + Name = "edgex-support-logging" + Protocol = "http" + Host = "edgex-support-logging" + Port = 48061 + +[Device] + DataTransform = true + InitCmd = "" + InitCmdArgs = "" + MaxCmdOps = 128 + MaxCmdValueLen = 256 + RemoveCmd = "" + RemoveCmdArgs = "" + ProfilesDir = "/res" + +[Logging] +EnableRemote = true +File = "./inference-mqtt-device.log" + +[Writable] +LogLevel = "DEBUG" + +# Pre-define Devices +[[DeviceList]] + Name = "Inference-MQTT-device" + Profile = "Inference.MQTT.Device.Profile" + Description = "Inference CV Module over MQTT" + Labels = [ "MQTT", "Inference" ] + [DeviceList.Protocols] + [DeviceList.Protocols.mqtt] + Schema = "tcp" + Host = "mqtt-broker" + Port = "1883" + ClientId = "InferenceCommandPublisher" + User = "" + Password = "" + Topic = "Inference/CommandTopic" + # [[DeviceList.AutoEvents]] + # Frequency = "20s" + # OnChange = false + # Resource = "inferenceHeartbeat" + +# Driver configs +[Driver] +IncomingSchema = "tcp" +IncomingHost = "mqtt-broker" +IncomingPort = "1883" +IncomingUser = "admin" +IncomingPassword = "public" +IncomingQos = "0" +IncomingKeepAlive = "3600" +IncomingClientId = "InferenceIncomingDataSubscriber" +IncomingTopic = "Inference/DataTopic" + +ResponseSchema = "tcp" +ResponseHost = "mqtt-broker" +ResponsePort = "1883" +ResponseUser = "admin" +ResponsePassword = "public" +ResponseQos = "0" +ResponseKeepAlive = "3600" +ResponseClientId = "InferenceCommandResponseSubscriber" +ResponseTopic = "Inference/ResponseTopic" diff --git a/res/device-mqtt/inference.mqtt.device.profile.yml b/res/device-mqtt/inference.mqtt.device.profile.yml new file mode 100644 index 0000000..977ac0d --- /dev/null +++ b/res/device-mqtt/inference.mqtt.device.profile.yml @@ -0,0 +1,84 @@ +--- + +# Copyright © 2020 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +name: "Inference.MQTT.Device.Profile" +manufacturer: "Inference" +model: "MQTT-2" +description: "Inference CV Module over MQTT device profile" +labels: +- "MQTT" +- "Inference" +deviceResources: +- name: "inferenceDoorStatus" + description: "Trigger Inference's CV algo to compute SKU delta" + properties: + value: + { type: "String", readWrite: "R" } + units: + { type: "String", readWrite: "R" } + +- name: "inferenceSkuDelta" + description: "SKU added or removed since last inference" + properties: + value: + { type: "String", readWrite: "R", defaultValue: ""} + units: + { type: "String", readWrite: "R", defaultValue: ""} + +- name: "inferenceHeartbeat" + description: "Device heartbeat" + properties: + value: + { type: "String", size: "0", readWrite: "R", defaultValue: "" } + units: + { type: "String", readWrite: "R", defaultValue: "" } + +deviceCommands: +- name: "inferenceDoorStatus" + set: + - { operation: "set", object: "inferenceDoorStatus", parameter: "inferenceDoorStatus" } +- name: "inferenceSkuDelta" + get: + - { operation: "get", object: "inferenceSkuDelta", parameter: "inferenceSkuDelta" } +- name: "inferenceHeartbeat" + get: + - { operation: "get", object: "inferenceHeartbeat", parameter: "inferenceHeartbeat" } + +coreCommands: +- name: "inferenceDoorStatus" + put: + path: "/api/v1/device/{deviceId}/inferenceDoorStatus" + parameterNames: ["inferenceDoorStatus"] + responses: + - + code: "200" + description: "CV trigger received" + expectedValues: [] + - + code: "503" + description: "service unavailable" + expectedValues: [] +- name: "inferenceSkuDelta" + get: + path: "/api/v1/device/{deviceId}/inferenceSkuDelta" + responses: + - code: "200" + description: "SKU delta computed" + expectedValues: ["inferenceSkuDelta"] + - code: "503" + description: "service unavailable" + expectedValues: [] +- name: "inferenceHeartbeat" + get: + path: "/api/v1/device/{deviceId}/inferenceHeartbeat" + responses: + - + code: "200" + description: "Ping sent" + expectedValues: ["inferenceHeartbeat"] + - + code: "503" + description: "service unavailable" + expectedValues: [] diff --git a/res/mqtt/mosquitto.conf b/res/mqtt/mosquitto.conf new file mode 100644 index 0000000..4a21b2b --- /dev/null +++ b/res/mqtt/mosquitto.conf @@ -0,0 +1,3 @@ +persistence true +persistence_location /mosquitto/data/ +log_dest file /mosquitto/log/mosquitto.log