/*!
 * surveyjs - Survey JavaScript library v1.11.13
 * Copyright (c) 2015-2024 Devsoft Baltic OÜ  - http://surveyjs.io/
 * License: MIT (http://www.opensource.org/licenses/mit-license.php)
 */
(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define("survey-core", [], factory);
	else if(typeof exports === 'object')
		exports["survey-core"] = factory();
	else
		root["Survey"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = "./src/entries/core.ts");
/******/ })
/************************************************************************/
/******/ ({

/***/ "./packages/survey-core/src/images sync \\.svg$":
/*!******************************************************************!*\
  !*** ./packages/survey-core/src/images sync nonrecursive \.svg$ ***!
  \******************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports, __webpack_require__) {

var map = {
	"./ArrowDown_34x34.svg": "./packages/survey-core/src/images/ArrowDown_34x34.svg",
	"./ArrowLeft.svg": "./packages/survey-core/src/images/ArrowLeft.svg",
	"./ArrowRight.svg": "./packages/survey-core/src/images/ArrowRight.svg",
	"./Arrow_downGREY_10x10.svg": "./packages/survey-core/src/images/Arrow_downGREY_10x10.svg",
	"./ChangeCamera.svg": "./packages/survey-core/src/images/ChangeCamera.svg",
	"./ChooseFile.svg": "./packages/survey-core/src/images/ChooseFile.svg",
	"./Clear.svg": "./packages/survey-core/src/images/Clear.svg",
	"./CloseCamera.svg": "./packages/survey-core/src/images/CloseCamera.svg",
	"./DefaultFile.svg": "./packages/survey-core/src/images/DefaultFile.svg",
	"./Delete.svg": "./packages/survey-core/src/images/Delete.svg",
	"./Down_34x34.svg": "./packages/survey-core/src/images/Down_34x34.svg",
	"./Left.svg": "./packages/survey-core/src/images/Left.svg",
	"./ModernBooleanCheckChecked.svg": "./packages/survey-core/src/images/ModernBooleanCheckChecked.svg",
	"./ModernBooleanCheckInd.svg": "./packages/survey-core/src/images/ModernBooleanCheckInd.svg",
	"./ModernBooleanCheckUnchecked.svg": "./packages/survey-core/src/images/ModernBooleanCheckUnchecked.svg",
	"./ModernCheck.svg": "./packages/survey-core/src/images/ModernCheck.svg",
	"./ModernRadio.svg": "./packages/survey-core/src/images/ModernRadio.svg",
	"./More.svg": "./packages/survey-core/src/images/More.svg",
	"./NavMenu_24x24.svg": "./packages/survey-core/src/images/NavMenu_24x24.svg",
	"./ProgressButton.svg": "./packages/survey-core/src/images/ProgressButton.svg",
	"./ProgressButtonV2.svg": "./packages/survey-core/src/images/ProgressButtonV2.svg",
	"./RemoveFile.svg": "./packages/survey-core/src/images/RemoveFile.svg",
	"./Right.svg": "./packages/survey-core/src/images/Right.svg",
	"./SearchClear.svg": "./packages/survey-core/src/images/SearchClear.svg",
	"./ShowCamera.svg": "./packages/survey-core/src/images/ShowCamera.svg",
	"./TakePicture.svg": "./packages/survey-core/src/images/TakePicture.svg",
	"./TakePicture_24x24.svg": "./packages/survey-core/src/images/TakePicture_24x24.svg",
	"./TimerCircle.svg": "./packages/survey-core/src/images/TimerCircle.svg",
	"./V2Check.svg": "./packages/survey-core/src/images/V2Check.svg",
	"./V2Check_24x24.svg": "./packages/survey-core/src/images/V2Check_24x24.svg",
	"./V2DragElement_16x16.svg": "./packages/survey-core/src/images/V2DragElement_16x16.svg",
	"./back-to-panel_16x16.svg": "./packages/survey-core/src/images/back-to-panel_16x16.svg",
	"./chevron.svg": "./packages/survey-core/src/images/chevron.svg",
	"./clear_16x16.svg": "./packages/survey-core/src/images/clear_16x16.svg",
	"./close_16x16.svg": "./packages/survey-core/src/images/close_16x16.svg",
	"./collapseDetail.svg": "./packages/survey-core/src/images/collapseDetail.svg",
	"./drag-n-drop.svg": "./packages/survey-core/src/images/drag-n-drop.svg",
	"./expandDetail.svg": "./packages/survey-core/src/images/expandDetail.svg",
	"./full-screen_16x16.svg": "./packages/survey-core/src/images/full-screen_16x16.svg",
	"./loading.svg": "./packages/survey-core/src/images/loading.svg",
	"./minimize_16x16.svg": "./packages/survey-core/src/images/minimize_16x16.svg",
	"./next_16x16.svg": "./packages/survey-core/src/images/next_16x16.svg",
	"./no-image.svg": "./packages/survey-core/src/images/no-image.svg",
	"./ranking-arrows.svg": "./packages/survey-core/src/images/ranking-arrows.svg",
	"./ranking-dash.svg": "./packages/survey-core/src/images/ranking-dash.svg",
	"./rating-star-2.svg": "./packages/survey-core/src/images/rating-star-2.svg",
	"./rating-star-small-2.svg": "./packages/survey-core/src/images/rating-star-small-2.svg",
	"./rating-star-small.svg": "./packages/survey-core/src/images/rating-star-small.svg",
	"./rating-star.svg": "./packages/survey-core/src/images/rating-star.svg",
	"./restore_16x16.svg": "./packages/survey-core/src/images/restore_16x16.svg",
	"./search.svg": "./packages/survey-core/src/images/search.svg"
};


function webpackContext(req) {
	var id = webpackContextResolve(req);
	return __webpack_require__(id);
}
function webpackContextResolve(req) {
	if(!__webpack_require__.o(map, req)) {
		var e = new Error("Cannot find module '" + req + "'");
		e.code = 'MODULE_NOT_FOUND';
		throw e;
	}
	return map[req];
}
webpackContext.keys = function webpackContextKeys() {
	return Object.keys(map);
};
webpackContext.resolve = webpackContextResolve;
module.exports = webpackContext;
webpackContext.id = "./packages/survey-core/src/images sync \\.svg$";

/***/ }),

/***/ "./packages/survey-core/src/images/ArrowDown_34x34.svg":
/*!*************************************************************!*\
  !*** ./packages/survey-core/src/images/ArrowDown_34x34.svg ***!
  \*************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\" viewBox=\"0 0 34 34\" xml:space=\"preserve\"><polygon class=\"st0\" points=\"12,16 14,14 17,17 20,14 22,16 17,21 \"></polygon></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/ArrowLeft.svg":
/*!*******************************************************!*\
  !*** ./packages/survey-core/src/images/ArrowLeft.svg ***!
  \*******************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M15 8.99999H4.39998L8.69998 13.3L7.29998 14.7L0.599976 7.99999L7.29998 1.29999L8.69998 2.69999L4.39998 6.99999H15V8.99999Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/ArrowRight.svg":
/*!********************************************************!*\
  !*** ./packages/survey-core/src/images/ArrowRight.svg ***!
  \********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M1 6.99999H11.6L7.3 2.69999L8.7 1.29999L15.4 7.99999L8.7 14.7L7.3 13.3L11.6 8.99999H1V6.99999Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/Arrow_downGREY_10x10.svg":
/*!******************************************************************!*\
  !*** ./packages/survey-core/src/images/Arrow_downGREY_10x10.svg ***!
  \******************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\" viewBox=\"0 0 10 10\" xml:space=\"preserve\"><polygon class=\"st0\" points=\"2,2 0,4 5,9 10,4 8,2 5,5 \"></polygon></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/ChangeCamera.svg":
/*!**********************************************************!*\
  !*** ./packages/survey-core/src/images/ChangeCamera.svg ***!
  \**********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M23 12.0037C23 14.2445 21.7794 16.3052 19.5684 17.8257C19.3984 17.9458 19.1983 18.0058 19.0082 18.0058C18.688 18.0058 18.3779 17.8557 18.1778 17.5756C17.8677 17.1155 17.9777 16.4953 18.4379 16.1852C20.0887 15.0448 21.0091 13.5643 21.0091 12.0138C21.0091 8.70262 16.9673 6.01171 12.005 6.01171C11.4948 6.01171 10.9945 6.04172 10.5043 6.09173L11.7149 7.30215C12.105 7.69228 12.105 8.32249 11.7149 8.71263C11.5148 8.9127 11.2647 9.00273 11.0045 9.00273C10.7444 9.00273 10.4943 8.90269 10.2942 8.71263L6.58254 5.00136L10.2842 1.2901C10.6744 0.899964 11.3047 0.899964 11.6949 1.2901C12.085 1.68023 12.085 2.31045 11.6949 2.70058L10.3042 4.09105C10.8545 4.03103 11.4147 4.00102 11.985 4.00102C18.0578 4.00102 22.99 7.59225 22.99 12.0037H23ZM12.2851 15.2949C11.895 15.685 11.895 16.3152 12.2851 16.7054L13.4957 17.9158C13.0055 17.9758 12.4952 17.9958 11.995 17.9958C7.03274 17.9958 2.99091 15.3049 2.99091 11.9937C2.99091 10.4332 3.90132 8.95271 5.56207 7.82232C6.02228 7.51222 6.13233 6.89201 5.82219 6.43185C5.51205 5.97169 4.89177 5.86166 4.43156 6.17176C2.22055 7.69228 1 9.76299 1 11.9937C1 16.4052 5.93224 19.9965 12.005 19.9965C12.5753 19.9965 13.1355 19.9665 13.6858 19.9064L12.2951 21.2969C11.905 21.6871 11.905 22.3173 12.2951 22.7074C12.4952 22.9075 12.7453 22.9975 13.0055 22.9975C13.2656 22.9975 13.5157 22.8975 13.7158 22.7074L17.4275 18.9961L13.7158 15.2849C13.3256 14.8947 12.6953 14.8947 12.3051 15.2849L12.2851 15.2949Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/ChooseFile.svg":
/*!********************************************************!*\
  !*** ./packages/survey-core/src/images/ChooseFile.svg ***!
  \********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M22 9V7C22 5.9 21.1 5 20 5H12L10 3H4C2.9 3 2 3.9 2 5V9V10V21H22L24 9H22ZM4 5H9.2L10.6 6.4L11.2 7H12H20V9H4V5ZM20.3 19H4V11H21.6L20.3 19Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/Clear.svg":
/*!***************************************************!*\
  !*** ./packages/survey-core/src/images/Clear.svg ***!
  \***************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M22.6 8.6L16.4 2.4C16 2 15.5 1.8 15 1.8C14.5 1.8 14 2 13.6 2.4L1.4 14.6C0.600003 15.4 0.600003 16.6 1.4 17.4L6 22H12L22.6 11.4C23.3 10.6 23.3 9.3 22.6 8.6ZM11.1 20H6.8L2.8 16L6.2 12.6L12.4 18.8L11.1 20ZM13.8 17.4L7.6 11.2L15 3.8L21.2 10L13.8 17.4ZM16 20H23V22H14L16 20Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/CloseCamera.svg":
/*!*********************************************************!*\
  !*** ./packages/survey-core/src/images/CloseCamera.svg ***!
  \*********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M13.41 12L20.7 4.71C21.09 4.32 21.09 3.69 20.7 3.3C20.31 2.91 19.68 2.91 19.29 3.3L12 10.59L4.71 3.29C4.32 2.9 3.68 2.9 3.29 3.29C2.9 3.68 2.9 4.32 3.29 4.71L10.58 12L3.29 19.29C2.9 19.68 2.9 20.31 3.29 20.7C3.49 20.9 3.74 20.99 4 20.99C4.26 20.99 4.51 20.89 4.71 20.7L12 13.41L19.29 20.7C19.49 20.9 19.74 20.99 20 20.99C20.26 20.99 20.51 20.89 20.71 20.7C21.1 20.31 21.1 19.68 20.71 19.29L13.42 12H13.41Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/DefaultFile.svg":
/*!*********************************************************!*\
  !*** ./packages/survey-core/src/images/DefaultFile.svg ***!
  \*********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 56 68\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><g clip-path=\"url(#clip0_9011_41219)\"><path d=\"M54.83 10.83L45.17 1.17C44.7982 0.798664 44.357 0.504208 43.8714 0.303455C43.3858 0.102703 42.8654 -0.000411943 42.34 1.2368e-06H6C4.4087 1.2368e-06 2.88257 0.632142 1.75735 1.75736C0.632136 2.88258 0 4.4087 0 6V62C0 63.5913 0.632136 65.1174 1.75735 66.2426C2.88257 67.3679 4.4087 68 6 68H50C51.5913 68 53.1174 67.3679 54.2426 66.2426C55.3679 65.1174 56 63.5913 56 62V13.66C56.0004 13.1346 55.8973 12.6142 55.6965 12.1286C55.4958 11.643 55.2013 11.2018 54.83 10.83ZM44 2.83L53.17 12H48C46.9391 12 45.9217 11.5786 45.1716 10.8284C44.4214 10.0783 44 9.06087 44 8V2.83ZM54 62C54 63.0609 53.5786 64.0783 52.8284 64.8284C52.0783 65.5786 51.0609 66 50 66H6C4.93913 66 3.92172 65.5786 3.17157 64.8284C2.42142 64.0783 2 63.0609 2 62V6C2 4.93914 2.42142 3.92172 3.17157 3.17157C3.92172 2.42143 4.93913 2 6 2H42V8C42 9.5913 42.6321 11.1174 43.7574 12.2426C44.8826 13.3679 46.4087 14 48 14H54V62ZM14 24H42V26H14V24ZM14 30H42V32H14V30ZM14 36H42V38H14V36ZM14 42H42V44H14V42Z\" fill=\"#909090\"></path></g><defs><clipPath id=\"clip0_9011_41219\"><rect width=\"56\" height=\"68\" fill=\"white\"></rect></clipPath></defs></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/Delete.svg":
/*!****************************************************!*\
  !*** ./packages/survey-core/src/images/Delete.svg ***!
  \****************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M22 4H20H16V2C16 0.9 15.1 0 14 0H10C8.9 0 8 0.9 8 2V4H4H2V6H4V20C4 21.1 4.9 22 6 22H18C19.1 22 20 21.1 20 20V6H22V4ZM10 2H14V4H10V2ZM18 20H6V6H8H16H18V20ZM14 8H16V18H14V8ZM11 8H13V18H11V8ZM8 8H10V18H8V8Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/Down_34x34.svg":
/*!********************************************************!*\
  !*** ./packages/survey-core/src/images/Down_34x34.svg ***!
  \********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\" viewBox=\"0 0 34 34\" xml:space=\"preserve\"><g><path class=\"st0\" d=\"M33,34H0V0h33c0.6,0,1,0.4,1,1v32C34,33.6,33.6,34,33,34z\"></path><polygon class=\"st1\" points=\"12,16 14,14 17,17 20,14 22,16 17,21 \"></polygon></g></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/Left.svg":
/*!**************************************************!*\
  !*** ./packages/survey-core/src/images/Left.svg ***!
  \**************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\" viewBox=\"0 0 16 16\" xml:space=\"preserve\"><polygon points=\"11,12 9,14 3,8 9,2 11,4 7,8 \"></polygon></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/ModernBooleanCheckChecked.svg":
/*!***********************************************************************!*\
  !*** ./packages/survey-core/src/images/ModernBooleanCheckChecked.svg ***!
  \***********************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 24 24\"><polygon points=\"19,10 14,10 14,5 10,5 10,10 5,10 5,14 10,14 10,19 14,19 14,14 19,14 \"></polygon></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/ModernBooleanCheckInd.svg":
/*!*******************************************************************!*\
  !*** ./packages/survey-core/src/images/ModernBooleanCheckInd.svg ***!
  \*******************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 24 24\"><path d=\"M22,0H2C0.9,0,0,0.9,0,2v20c0,1.1,0.9,2,2,2h20c1.1,0,2-0.9,2-2V2C24,0.9,23.1,0,22,0z M21,18L6,3h15V18z M3,6l15,15H3V6z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/ModernBooleanCheckUnchecked.svg":
/*!*************************************************************************!*\
  !*** ./packages/survey-core/src/images/ModernBooleanCheckUnchecked.svg ***!
  \*************************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 24 24\"><rect x=\"5\" y=\"10\" width=\"14\" height=\"4\"></rect></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/ModernCheck.svg":
/*!*********************************************************!*\
  !*** ./packages/survey-core/src/images/ModernCheck.svg ***!
  \*********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\"><path d=\"M5,13l2-2l3,3l7-7l2,2l-9,9L5,13z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/ModernRadio.svg":
/*!*********************************************************!*\
  !*** ./packages/survey-core/src/images/ModernRadio.svg ***!
  \*********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"-12 -12 24 24\"><circle r=\"6\" cx=\"0\" cy=\"0\"></circle></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/More.svg":
/*!**************************************************!*\
  !*** ./packages/survey-core/src/images/More.svg ***!
  \**************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M6 12C6 13.1 5.1 14 4 14C2.9 14 2 13.1 2 12C2 10.9 2.9 10 4 10C5.1 10 6 10.9 6 12ZM12 10C10.9 10 10 10.9 10 12C10 13.1 10.9 14 12 14C13.1 14 14 13.1 14 12C14 10.9 13.1 10 12 10ZM20 10C18.9 10 18 10.9 18 12C18 13.1 18.9 14 20 14C21.1 14 22 13.1 22 12C22 10.9 21.1 10 20 10Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/NavMenu_24x24.svg":
/*!***********************************************************!*\
  !*** ./packages/survey-core/src/images/NavMenu_24x24.svg ***!
  \***********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M16 7H2V5H16V7ZM2 11V13H22V11H2ZM2 19H10V17H2V19Z\" fill=\"black\" fill-opacity=\"0.45\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/ProgressButton.svg":
/*!************************************************************!*\
  !*** ./packages/survey-core/src/images/ProgressButton.svg ***!
  \************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 10 10\"><polygon points=\"2,2 0,4 5,9 10,4 8,2 5,5 \"></polygon></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/ProgressButtonV2.svg":
/*!**************************************************************!*\
  !*** ./packages/survey-core/src/images/ProgressButtonV2.svg ***!
  \**************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 16 16\"><path d=\"M15 8.99999H4.39998L8.69998 13.3L7.29998 14.7L0.599976 7.99999L7.29998 1.29999L8.69998 2.69999L4.39998 6.99999H15V8.99999Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/RemoveFile.svg":
/*!********************************************************!*\
  !*** ./packages/survey-core/src/images/RemoveFile.svg ***!
  \********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 16 16\"><path d=\"M8,2C4.7,2,2,4.7,2,8s2.7,6,6,6s6-2.7,6-6S11.3,2,8,2z M11,10l-1,1L8,9l-2,2l-1-1l2-2L5,6l1-1l2,2l2-2l1,1L9,8 L11,10z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/Right.svg":
/*!***************************************************!*\
  !*** ./packages/survey-core/src/images/Right.svg ***!
  \***************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\" viewBox=\"0 0 16 16\" xml:space=\"preserve\"><polygon points=\"5,4 7,2 13,8 7,14 5,12 9,8 \"></polygon></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/SearchClear.svg":
/*!*********************************************************!*\
  !*** ./packages/survey-core/src/images/SearchClear.svg ***!
  \*********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M13.35 3.34999L12.65 2.64999L8.05002 7.24999L3.35002 2.64999L2.65002 3.34999L7.25002 8.04999L2.65002 12.65L3.35002 13.35L8.05002 8.74999L12.65 13.35L13.35 12.65L8.75002 8.04999L13.35 3.34999Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/ShowCamera.svg":
/*!********************************************************!*\
  !*** ./packages/survey-core/src/images/ShowCamera.svg ***!
  \********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M20.01 4H18.4C18.2 4 18.01 3.9 17.9 3.73L16.97 2.34C16.41 1.5 15.48 1 14.47 1H9.54C8.53 1 7.6 1.5 7.04 2.34L6.11 3.73C6 3.9 5.81 4 5.61 4H4C2.35 4 1 5.35 1 7V19C1 20.65 2.35 22 4 22H20C21.65 22 23 20.65 23 19V7C23 5.35 21.65 4 20 4H20.01ZM21.01 19C21.01 19.55 20.56 20 20.01 20H4.01C3.46 20 3.01 19.55 3.01 19V7C3.01 6.45 3.46 6 4.01 6H5.62C6.49 6 7.3 5.56 7.79 4.84L8.72 3.45C8.91 3.17 9.22 3 9.55 3H14.48C14.81 3 15.13 3.17 15.31 3.45L16.24 4.84C16.72 5.56 17.54 6 18.41 6H20.02C20.57 6 21.02 6.45 21.02 7V19H21.01ZM12.01 6C8.7 6 6.01 8.69 6.01 12C6.01 15.31 8.7 18 12.01 18C15.32 18 18.01 15.31 18.01 12C18.01 8.69 15.32 6 12.01 6ZM12.01 16C9.8 16 8.01 14.21 8.01 12C8.01 9.79 9.8 8 12.01 8C14.22 8 16.01 9.79 16.01 12C16.01 14.21 14.22 16 12.01 16ZM13.01 10C13.01 10.55 12.56 11 12.01 11C11.46 11 11.01 11.45 11.01 12C11.01 12.55 10.56 13 10.01 13C9.46 13 9.01 12.55 9.01 12C9.01 10.35 10.36 9 12.01 9C12.56 9 13.01 9.45 13.01 10Z\" fill=\"black\" fill-opacity=\"0.45\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/TakePicture.svg":
/*!*********************************************************!*\
  !*** ./packages/survey-core/src/images/TakePicture.svg ***!
  \*********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 32 32\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M27 6H23.8C23.34 6 22.92 5.77 22.66 5.39L22.25 4.78C21.51 3.66 20.26 3 18.92 3H13.06C11.72 3 10.48 3.67 9.73 4.78L9.32 5.39C9.07 5.77 8.64 6 8.18 6H4.98C2.79 6 1 7.79 1 10V24C1 26.21 2.79 28 5 28H27C29.21 28 31 26.21 31 24V10C31 7.79 29.21 6 27 6ZM29 24C29 25.1 28.1 26 27 26H5C3.9 26 3 25.1 3 24V10C3 8.9 3.9 8 5 8H8.2C9.33 8 10.38 7.44 11 6.5L11.41 5.89C11.78 5.33 12.41 5 13.07 5H18.93C19.6 5 20.22 5.33 20.59 5.89L21 6.5C21.62 7.44 22.68 8 23.8 8H27C28.1 8 29 8.9 29 10V24ZM16 9C12.13 9 9 12.13 9 16C9 19.87 12.13 23 16 23C19.87 23 23 19.87 23 16C23 12.13 19.87 9 16 9ZM16 21C13.24 21 11 18.76 11 16C11 13.24 13.24 11 16 11C18.76 11 21 13.24 21 16C21 18.76 18.76 21 16 21ZM17 13C17 13.55 16.55 14 16 14C14.9 14 14 14.9 14 16C14 16.55 13.55 17 13 17C12.45 17 12 16.55 12 16C12 13.79 13.79 12 16 12C16.55 12 17 12.45 17 13Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/TakePicture_24x24.svg":
/*!***************************************************************!*\
  !*** ./packages/survey-core/src/images/TakePicture_24x24.svg ***!
  \***************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M20.01 4H18.4C18.2 4 18.01 3.9 17.9 3.73L16.97 2.34C16.41 1.5 15.48 1 14.47 1H9.54C8.53 1 7.6 1.5 7.04 2.34L6.11 3.73C6 3.9 5.81 4 5.61 4H4C2.35 4 1 5.35 1 7V19C1 20.65 2.35 22 4 22H20C21.65 22 23 20.65 23 19V7C23 5.35 21.65 4 20 4H20.01ZM21.01 19C21.01 19.55 20.56 20 20.01 20H4.01C3.46 20 3.01 19.55 3.01 19V7C3.01 6.45 3.46 6 4.01 6H5.62C6.49 6 7.3 5.56 7.79 4.84L8.72 3.45C8.91 3.17 9.22 3 9.55 3H14.48C14.81 3 15.13 3.17 15.31 3.45L16.24 4.84C16.72 5.56 17.54 6 18.41 6H20.02C20.57 6 21.02 6.45 21.02 7V19H21.01ZM12.01 6C8.7 6 6.01 8.69 6.01 12C6.01 15.31 8.7 18 12.01 18C15.32 18 18.01 15.31 18.01 12C18.01 8.69 15.32 6 12.01 6ZM12.01 16C9.8 16 8.01 14.21 8.01 12C8.01 9.79 9.8 8 12.01 8C14.22 8 16.01 9.79 16.01 12C16.01 14.21 14.22 16 12.01 16ZM13.01 10C13.01 10.55 12.56 11 12.01 11C11.46 11 11.01 11.45 11.01 12C11.01 12.55 10.56 13 10.01 13C9.46 13 9.01 12.55 9.01 12C9.01 10.35 10.36 9 12.01 9C12.56 9 13.01 9.45 13.01 10Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/TimerCircle.svg":
/*!*********************************************************!*\
  !*** ./packages/survey-core/src/images/TimerCircle.svg ***!
  \*********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 160 160\"><circle cx=\"80\" cy=\"80\" r=\"70\" style=\"stroke: var(--sd-timer-stroke-background-color); stroke-width: var(--sd-timer-stroke-background-width)\" stroke-dasharray=\"none\" stroke-dashoffset=\"none\"></circle><circle cx=\"80\" cy=\"80\" r=\"70\"></circle></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/V2Check.svg":
/*!*****************************************************!*\
  !*** ./packages/survey-core/src/images/V2Check.svg ***!
  \*****************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M8.00001 15.8L2.60001 10.4L4.00001 9L8.00001 13L16 5L17.4 6.4L8.00001 15.8Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/V2Check_24x24.svg":
/*!***********************************************************!*\
  !*** ./packages/survey-core/src/images/V2Check_24x24.svg ***!
  \***********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M9 20.1L1 12L3.1 9.9L9 15.9L20.9 4L23 6.1L9 20.1Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/V2DragElement_16x16.svg":
/*!*****************************************************************!*\
  !*** ./packages/survey-core/src/images/V2DragElement_16x16.svg ***!
  \*****************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M2 4C2 3.73478 2.10536 3.48043 2.29289 3.29289C2.48043 3.10536 2.73478 3 3 3H13C13.2652 3 13.5196 3.10536 13.7071 3.29289C13.8946 3.48043 14 3.73478 14 4C14 4.26522 13.8946 4.51957 13.7071 4.70711C13.5196 4.89464 13.2652 5 13 5H3C2.73478 5 2.48043 4.89464 2.29289 4.70711C2.10536 4.51957 2 4.26522 2 4ZM13 7H3C2.73478 7 2.48043 7.10536 2.29289 7.29289C2.10536 7.48043 2 7.73478 2 8C2 8.26522 2.10536 8.51957 2.29289 8.70711C2.48043 8.89464 2.73478 9 3 9H13C13.2652 9 13.5196 8.89464 13.7071 8.70711C13.8946 8.51957 14 8.26522 14 8C14 7.73478 13.8946 7.48043 13.7071 7.29289C13.5196 7.10536 13.2652 7 13 7ZM13 11H3C2.73478 11 2.48043 11.1054 2.29289 11.2929C2.10536 11.4804 2 11.7348 2 12C2 12.2652 2.10536 12.5196 2.29289 12.7071C2.48043 12.8946 2.73478 13 3 13H13C13.2652 13 13.5196 12.8946 13.7071 12.7071C13.8946 12.5196 14 12.2652 14 12C14 11.7348 13.8946 11.4804 13.7071 11.2929C13.5196 11.1054 13.2652 11 13 11Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/back-to-panel_16x16.svg":
/*!*****************************************************************!*\
  !*** ./packages/survey-core/src/images/back-to-panel_16x16.svg ***!
  \*****************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M15.0001 6C15.0001 6.55 14.5501 7 14.0001 7H10.0001C9.45006 7 9.00006 6.55 9.00006 6V2C9.00006 1.45 9.45006 1 10.0001 1C10.5501 1 11.0001 1.45 11.0001 2V3.59L13.2901 1.29C13.4901 1.09 13.7401 1 14.0001 1C14.2601 1 14.5101 1.1 14.7101 1.29C15.1001 1.68 15.1001 2.31 14.7101 2.7L12.4201 4.99H14.0101C14.5601 4.99 15.0101 5.44 15.0101 5.99L15.0001 6ZM6.00006 9H2.00006C1.45006 9 1.00006 9.45 1.00006 10C1.00006 10.55 1.45006 11 2.00006 11H3.59006L1.29006 13.29C0.900059 13.68 0.900059 14.31 1.29006 14.7C1.68006 15.09 2.31006 15.09 2.70006 14.7L4.99006 12.41V14C4.99006 14.55 5.44006 15 5.99006 15C6.54006 15 6.99006 14.55 6.99006 14V10C6.99006 9.45 6.54006 9 5.99006 9H6.00006Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/chevron.svg":
/*!*****************************************************!*\
  !*** ./packages/survey-core/src/images/chevron.svg ***!
  \*****************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 15L17 10H7L12 15Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/clear_16x16.svg":
/*!*********************************************************!*\
  !*** ./packages/survey-core/src/images/clear_16x16.svg ***!
  \*********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M13.35 3.34999L12.65 2.64999L8.05002 7.24999L3.35002 2.64999L2.65002 3.34999L7.25002 8.04999L2.65002 12.65L3.35002 13.35L8.05002 8.74999L12.65 13.35L13.35 12.65L8.75002 8.04999L13.35 3.34999Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/close_16x16.svg":
/*!*********************************************************!*\
  !*** ./packages/survey-core/src/images/close_16x16.svg ***!
  \*********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M9.43 8.0025L13.7 3.7225C14.09 3.3325 14.09 2.6925 13.7 2.2925C13.31 1.9025 12.67 1.9025 12.27 2.2925L7.99 6.5725L3.72 2.3025C3.33 1.9025 2.69 1.9025 2.3 2.3025C1.9 2.6925 1.9 3.3325 2.3 3.7225L6.58 8.0025L2.3 12.2825C1.91 12.6725 1.91 13.3125 2.3 13.7125C2.69 14.1025 3.33 14.1025 3.73 13.7125L8.01 9.4325L12.29 13.7125C12.68 14.1025 13.32 14.1025 13.72 13.7125C14.11 13.3225 14.11 12.6825 13.72 12.2825L9.44 8.0025H9.43Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/collapseDetail.svg":
/*!************************************************************!*\
  !*** ./packages/survey-core/src/images/collapseDetail.svg ***!
  \************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M13 7H3V9H13V7Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/drag-n-drop.svg":
/*!*********************************************************!*\
  !*** ./packages/survey-core/src/images/drag-n-drop.svg ***!
  \*********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 10 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M6 2C6 0.9 6.9 0 8 0C9.1 0 10 0.9 10 2C10 3.1 9.1 4 8 4C6.9 4 6 3.1 6 2ZM2 0C0.9 0 0 0.9 0 2C0 3.1 0.9 4 2 4C3.1 4 4 3.1 4 2C4 0.9 3.1 0 2 0ZM8 6C6.9 6 6 6.9 6 8C6 9.1 6.9 10 8 10C9.1 10 10 9.1 10 8C10 6.9 9.1 6 8 6ZM2 6C0.9 6 0 6.9 0 8C0 9.1 0.9 10 2 10C3.1 10 4 9.1 4 8C4 6.9 3.1 6 2 6ZM8 12C6.9 12 6 12.9 6 14C6 15.1 6.9 16 8 16C9.1 16 10 15.1 10 14C10 12.9 9.1 12 8 12ZM2 12C0.9 12 0 12.9 0 14C0 15.1 0.9 16 2 16C3.1 16 4 15.1 4 14C4 12.9 3.1 12 2 12Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/expandDetail.svg":
/*!**********************************************************!*\
  !*** ./packages/survey-core/src/images/expandDetail.svg ***!
  \**********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M13 7H9V3H7V7H3V9H7V13H9V9H13V7Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/full-screen_16x16.svg":
/*!***************************************************************!*\
  !*** ./packages/survey-core/src/images/full-screen_16x16.svg ***!
  \***************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M6.71 10.71L4.42 13H6.01C6.56 13 7.01 13.45 7.01 14C7.01 14.55 6.56 15 6.01 15H2C1.45 15 1 14.55 1 14V10C1 9.45 1.45 9 2 9C2.55 9 3 9.45 3 10V11.59L5.29 9.3C5.68 8.91 6.31 8.91 6.7 9.3C7.09 9.69 7.09 10.32 6.7 10.71H6.71ZM14 1H10C9.45 1 9 1.45 9 2C9 2.55 9.45 3 10 3H11.59L9.3 5.29C8.91 5.68 8.91 6.31 9.3 6.7C9.5 6.9 9.75 6.99 10.01 6.99C10.27 6.99 10.52 6.89 10.72 6.7L13.01 4.41V6C13.01 6.55 13.46 7 14.01 7C14.56 7 15.01 6.55 15.01 6V2C15.01 1.45 14.56 1 14.01 1H14Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/loading.svg":
/*!*****************************************************!*\
  !*** ./packages/survey-core/src/images/loading.svg ***!
  \*****************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 48 48\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><g clip-path=\"url(#clip0_885_24957)\"><path opacity=\"0.1\" d=\"M24 40C15.18 40 8 32.82 8 24C8 15.18 15.18 8 24 8C32.82 8 40 15.18 40 24C40 32.82 32.82 40 24 40ZM24 12C17.38 12 12 17.38 12 24C12 30.62 17.38 36 24 36C30.62 36 36 30.62 36 24C36 17.38 30.62 12 24 12Z\" fill=\"black\" fill-opacity=\"0.91\"></path><path d=\"M10 26C8.9 26 8 25.1 8 24C8 15.18 15.18 8 24 8C25.1 8 26 8.9 26 10C26 11.1 25.1 12 24 12C17.38 12 12 17.38 12 24C12 25.1 11.1 26 10 26Z\" fill=\"#19B394\"></path></g><defs><clipPath id=\"clip0_885_24957\"><rect width=\"32\" height=\"32\" fill=\"white\" transform=\"translate(8 8)\"></rect></clipPath></defs></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/minimize_16x16.svg":
/*!************************************************************!*\
  !*** ./packages/survey-core/src/images/minimize_16x16.svg ***!
  \************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M13 9H3C2.45 9 2 8.55 2 8C2 7.45 2.45 7 3 7H13C13.55 7 14 7.45 14 8C14 8.55 13.55 9 13 9Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/next_16x16.svg":
/*!********************************************************!*\
  !*** ./packages/survey-core/src/images/next_16x16.svg ***!
  \********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M5.64648 12.6465L6.34648 13.3465L11.7465 8.04648L6.34648 2.64648L5.64648 3.34648L10.2465 8.04648L5.64648 12.6465Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/no-image.svg":
/*!******************************************************!*\
  !*** ./packages/survey-core/src/images/no-image.svg ***!
  \******************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 48 48\"><g opacity=\"0.5\"><path d=\"M14 17.01C14 16.4167 14.1759 15.8366 14.5056 15.3433C14.8352 14.8499 15.3038 14.4654 15.8519 14.2384C16.4001 14.0113 17.0033 13.9519 17.5853 14.0676C18.1672 14.1834 18.7018 14.4691 19.1213 14.8887C19.5409 15.3082 19.8266 15.8428 19.9424 16.4247C20.0581 17.0067 19.9987 17.6099 19.7716 18.1581C19.5446 18.7062 19.1601 19.1748 18.6667 19.5044C18.1734 19.8341 17.5933 20.01 17 20.01C16.2044 20.01 15.4413 19.6939 14.8787 19.1313C14.3161 18.5687 14 17.8056 14 17.01ZM27.09 24.14L20 36.01H36L27.09 24.14ZM36.72 8.14L35.57 10.01H36C36.5304 10.01 37.0391 10.2207 37.4142 10.5958C37.7893 10.9709 38 11.4796 38 12.01V36.01C38 36.5404 37.7893 37.0491 37.4142 37.4242C37.0391 37.7993 36.5304 38.01 36 38.01H18.77L17.57 40.01H36C37.0609 40.01 38.0783 39.5886 38.8284 38.8384C39.5786 38.0883 40 37.0709 40 36.01V12.01C39.9966 11.0765 39.6668 10.1737 39.0678 9.45778C38.4688 8.74188 37.6382 8.25802 36.72 8.09V8.14ZM36.86 4.5L12.86 44.5L11.14 43.5L13.23 40.01H12C10.9391 40.01 9.92172 39.5886 9.17157 38.8384C8.42143 38.0883 8 37.0709 8 36.01V12.01C8 10.9491 8.42143 9.93172 9.17157 9.18157C9.92172 8.43143 10.9391 8.01 12 8.01H32.43L35.14 3.5L36.86 4.5ZM14.43 38.01L15.63 36.01H12L19 27.01L20.56 27.8L31.23 10.01H12C11.4696 10.01 10.9609 10.2207 10.5858 10.5958C10.2107 10.9709 10 11.4796 10 12.01V36.01C10 36.5404 10.2107 37.0491 10.5858 37.4242C10.9609 37.7993 11.4696 38.01 12 38.01H14.43Z\"></path></g></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/ranking-arrows.svg":
/*!************************************************************!*\
  !*** ./packages/survey-core/src/images/ranking-arrows.svg ***!
  \************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 10 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M10 5L5 0L0 5H4V9H6V5H10Z\"></path><path d=\"M6 19V15H4V19H0L5 24L10 19H6Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/ranking-dash.svg":
/*!**********************************************************!*\
  !*** ./packages/survey-core/src/images/ranking-dash.svg ***!
  \**********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M13 7H3V9H13V7Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/rating-star-2.svg":
/*!***********************************************************!*\
  !*** ./packages/survey-core/src/images/rating-star-2.svg ***!
  \***********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 48 48\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M24 39.5057L11.7226 45.9839C10.4095 46.6739 8.87606 45.5622 9.12525 44.096L11.4734 30.373L1.54411 20.6556C0.480254 19.6207 1.06489 17.8095 2.53128 17.5986L16.2559 15.5957L22.3994 3.10891C23.0512 1.77685 24.9488 1.77685 25.6102 3.10891L31.7441 15.5957L45.4687 17.5986C46.9351 17.8095 47.5197 19.6207 46.4559 20.6556L36.5266 30.373L38.8748 44.096C39.1239 45.5622 37.5905 46.6835 36.2774 45.9839L24 39.5057Z\" fill=\"none\" stroke-width=\"2\"></path><path d=\"M24.3981 33.1305L24 32.9206L23.6019 33.1305L15.8715 37.2059L17.3542 28.5663L17.43 28.1246L17.1095 27.8113L10.83 21.6746L19.4965 20.4049L19.9405 20.3399L20.1387 19.9373L24 12.0936L27.8613 19.9373L28.0595 20.3399L28.5035 20.4049L37.17 21.6746L30.8905 27.8113L30.57 28.1246L30.6458 28.5663L32.1285 37.2059L24.3981 33.1305Z\" stroke-width=\"1.70746\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/rating-star-small-2.svg":
/*!*****************************************************************!*\
  !*** ./packages/survey-core/src/images/rating-star-small-2.svg ***!
  \*****************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 19.3373L6.13001 22.4373C5.50001 22.7673 4.77001 22.2373 4.89001 21.5373L6.01001 14.9773L1.26001 10.3273C0.750007 9.83728 1.03001 8.96728 1.73001 8.86728L8.29001 7.90728L11.23 1.93728C11.54 1.29728 12.45 1.29728 12.77 1.93728L15.7 7.90728L22.26 8.86728C22.96 8.96728 23.24 9.83728 22.73 10.3273L17.98 14.9773L19.1 21.5373C19.22 22.2373 18.49 22.7773 17.86 22.4373L11.99 19.3373H12Z\" fill=\"none\" stroke-width=\"2\"></path><path d=\"M12 15.9472L8.58001 17.7572L9.23001 13.9272L6.45001 11.2072L10.29 10.6472L12 7.17725L13.71 10.6472L17.55 11.2072L14.77 13.9272L15.42 17.7572L12 15.9472Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/rating-star-small.svg":
/*!***************************************************************!*\
  !*** ./packages/survey-core/src/images/rating-star-small.svg ***!
  \***************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><g><path d=\"M12 19.3373L6.13001 22.4373C5.50001 22.7673 4.77001 22.2373 4.89001 21.5373L6.01001 14.9773L1.26001 10.3273C0.750007 9.83728 1.03001 8.96728 1.73001 8.86728L8.29001 7.90728L11.23 1.93728C11.54 1.29728 12.45 1.29728 12.77 1.93728L15.7 7.90728L22.26 8.86728C22.96 8.96728 23.24 9.83728 22.73 10.3273L17.98 14.9773L19.1 21.5373C19.22 22.2373 18.49 22.7773 17.86 22.4373L11.99 19.3373H12Z\"></path></g></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/rating-star.svg":
/*!*********************************************************!*\
  !*** ./packages/survey-core/src/images/rating-star.svg ***!
  \*********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 48 48\" xmlns=\"http://www.w3.org/2000/svg\"><g><path d=\"M24 39.5057L11.7226 45.9839C10.4095 46.6739 8.87606 45.5622 9.12525 44.096L11.4734 30.373L1.54411 20.6556C0.480254 19.6207 1.06489 17.8095 2.53128 17.5986L16.2559 15.5957L22.3994 3.10891C23.0512 1.77685 24.9488 1.77685 25.6102 3.10891L31.7441 15.5957L45.4687 17.5986C46.9351 17.8095 47.5197 19.6207 46.4559 20.6556L36.5266 30.373L38.8748 44.096C39.1239 45.5622 37.5905 46.6835 36.2774 45.9839L24 39.5057Z\"></path></g></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/restore_16x16.svg":
/*!***********************************************************!*\
  !*** ./packages/survey-core/src/images/restore_16x16.svg ***!
  \***********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 13H4C2.9 13 2 12.1 2 11V5C2 3.9 2.9 3 4 3H12C13.1 3 14 3.9 14 5V11C14 12.1 13.1 13 12 13ZM4 5V11H12V5H4Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/search.svg":
/*!****************************************************!*\
  !*** ./packages/survey-core/src/images/search.svg ***!
  \****************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M14 2C9.6 2 6 5.6 6 10C6 11.8 6.6 13.5 7.7 14.9L2.3 20.3C1.9 20.7 1.9 21.3 2.3 21.7C2.5 21.9 2.7 22 3 22C3.3 22 3.5 21.9 3.7 21.7L9.1 16.3C10.5 17.4 12.2 18 14 18C18.4 18 22 14.4 22 10C22 5.6 18.4 2 14 2ZM14 16C10.7 16 8 13.3 8 10C8 6.7 10.7 4 14 4C17.3 4 20 6.7 20 10C20 13.3 17.3 16 14 16Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/smiley sync \\.svg$":
/*!*************************************************************************!*\
  !*** ./packages/survey-core/src/images/smiley sync nonrecursive \.svg$ ***!
  \*************************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports, __webpack_require__) {

var map = {
	"./average.svg": "./packages/survey-core/src/images/smiley/average.svg",
	"./excellent.svg": "./packages/survey-core/src/images/smiley/excellent.svg",
	"./good.svg": "./packages/survey-core/src/images/smiley/good.svg",
	"./normal.svg": "./packages/survey-core/src/images/smiley/normal.svg",
	"./not-good.svg": "./packages/survey-core/src/images/smiley/not-good.svg",
	"./perfect.svg": "./packages/survey-core/src/images/smiley/perfect.svg",
	"./poor.svg": "./packages/survey-core/src/images/smiley/poor.svg",
	"./terrible.svg": "./packages/survey-core/src/images/smiley/terrible.svg",
	"./very-good.svg": "./packages/survey-core/src/images/smiley/very-good.svg",
	"./very-poor.svg": "./packages/survey-core/src/images/smiley/very-poor.svg"
};


function webpackContext(req) {
	var id = webpackContextResolve(req);
	return __webpack_require__(id);
}
function webpackContextResolve(req) {
	if(!__webpack_require__.o(map, req)) {
		var e = new Error("Cannot find module '" + req + "'");
		e.code = 'MODULE_NOT_FOUND';
		throw e;
	}
	return map[req];
}
webpackContext.keys = function webpackContextKeys() {
	return Object.keys(map);
};
webpackContext.resolve = webpackContextResolve;
module.exports = webpackContext;
webpackContext.id = "./packages/survey-core/src/images/smiley sync \\.svg$";

/***/ }),

/***/ "./packages/survey-core/src/images/smiley/average.svg":
/*!************************************************************!*\
  !*** ./packages/survey-core/src/images/smiley/average.svg ***!
  \************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M7.00572 7C6.45572 7 6.00572 6.55 6.00572 6V2C6.00572 1.45 6.45572 1 7.00572 1C7.55572 1 8.00572 1.45 8.00572 2V6C8.00572 6.55 7.55572 7 7.00572 7ZM18.0057 6V2C18.0057 1.45 17.5557 1 17.0057 1C16.4557 1 16.0057 1.45 16.0057 2V6C16.0057 6.55 16.4557 7 17.0057 7C17.5557 7 18.0057 6.55 18.0057 6ZM19.9457 21.33C20.1257 20.81 19.8557 20.24 19.3357 20.05C14.5457 18.35 9.45572 18.35 4.66572 20.05C4.14572 20.23 3.87572 20.81 4.05572 21.33C4.23572 21.85 4.80572 22.12 5.33572 21.94C9.69572 20.4 14.3057 20.4 18.6657 21.94C18.7757 21.98 18.8857 22 18.9957 22C19.4057 22 19.7957 21.74 19.9357 21.33H19.9457Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/smiley/excellent.svg":
/*!**************************************************************!*\
  !*** ./packages/survey-core/src/images/smiley/excellent.svg ***!
  \**************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12.01 24C6.85767 24 1.15509 20.96 0.0145752 14.16C-0.0354475 13.87 0.0445888 13.57 0.234675 13.35C0.424761 13.13 0.704888 13 0.995019 13H23.005C23.2951 13 23.5752 13.13 23.7653 13.35C23.9554 13.57 24.0354 13.87 23.9854 14.16C22.8549 20.95 17.1423 24 11.99 24H12.01ZM2.25559 15C3.61621 19.82 8.0182 22 12.01 22C16.0018 22 20.4038 19.82 21.7644 15H2.25559ZM8.00819 6V2C8.00819 1.45 7.55799 1 7.00774 1C6.45749 1 6.00729 1.45 6.00729 2V6C6.00729 6.55 6.45749 7 7.00774 7C7.55799 7 8.00819 6.55 8.00819 6ZM18.0127 6V2C18.0127 1.45 17.5625 1 17.0123 1C16.462 1 16.0118 1.45 16.0118 2V6C16.0118 6.55 16.462 7 17.0123 7C17.5625 7 18.0127 6.55 18.0127 6Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/smiley/good.svg":
/*!*********************************************************!*\
  !*** ./packages/survey-core/src/images/smiley/good.svg ***!
  \*********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12.0022 23.99C11.452 23.99 11.0018 23.5402 11.0018 22.9904C11.0018 22.4407 11.452 21.9909 12.0022 21.9909C16.3137 21.9909 21.0755 19.472 22.0158 13.8344C22.1058 13.2947 22.616 12.9248 23.1662 13.0148C23.7064 13.1047 24.0765 13.6245 23.9865 14.1643C22.8561 20.9513 17.144 24 11.9922 24L12.0022 23.99ZM8.00072 5.99783V1.99957C8.00072 1.4498 7.55056 1 7.00036 1C6.45016 1 6 1.4498 6 1.99957V5.99783C6 6.54759 6.45016 6.99739 7.00036 6.99739C7.55056 6.99739 8.00072 6.54759 8.00072 5.99783ZM18.0043 5.99783V1.99957C18.0043 1.4498 17.5542 1 17.004 1C16.4538 1 16.0036 1.4498 16.0036 1.99957V5.99783C16.0036 6.54759 16.4538 6.99739 17.004 6.99739C17.5542 6.99739 18.0043 6.54759 18.0043 5.99783Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/smiley/normal.svg":
/*!***********************************************************!*\
  !*** ./packages/survey-core/src/images/smiley/normal.svg ***!
  \***********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M7 7C6.45 7 6 6.55 6 6V2C6 1.45 6.45 1 7 1C7.55 1 8 1.45 8 2V6C8 6.55 7.55 7 7 7ZM18 6V2C18 1.45 17.55 1 17 1C16.45 1 16 1.45 16 2V6C16 6.55 16.45 7 17 7C17.55 7 18 6.55 18 6ZM21 21C21 20.45 20.55 20 20 20H4C3.45 20 3 20.45 3 21C3 21.55 3.45 22 4 22H20C20.55 22 21 21.55 21 21Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/smiley/not-good.svg":
/*!*************************************************************!*\
  !*** ./packages/survey-core/src/images/smiley/not-good.svg ***!
  \*************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M7.06927 7C6.51927 7 6.06927 6.55 6.06927 6V2C6.06927 1.45 6.51927 1 7.06927 1C7.61927 1 8.06927 1.45 8.06927 2V6C8.06927 6.55 7.61927 7 7.06927 7ZM18.0693 6V2C18.0693 1.45 17.6193 1 17.0693 1C16.5193 1 16.0693 1.45 16.0693 2V6C16.0693 6.55 16.5193 7 17.0693 7C17.6193 7 18.0693 6.55 18.0693 6ZM22.5693 21.9C23.0693 21.66 23.2793 21.07 23.0393 20.57C21.1093 16.52 16.9093 14 12.0693 14C7.22927 14 3.02927 16.52 1.09927 20.57C0.859273 21.07 1.06927 21.67 1.56927 21.9C2.06927 22.14 2.65927 21.93 2.89927 21.43C4.49927 18.08 8.00927 16 12.0593 16C16.1093 16 19.6293 18.08 21.2193 21.43C21.3893 21.79 21.7493 22 22.1193 22C22.2593 22 22.4093 21.97 22.5493 21.9H22.5693Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/smiley/perfect.svg":
/*!************************************************************!*\
  !*** ./packages/survey-core/src/images/smiley/perfect.svg ***!
  \************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12.01 23C6.85721 23 1.15412 19.9621 0.0134987 13.1669C-0.0765501 12.6272 0.293651 12.1076 0.833944 12.0177C1.38424 11.9277 1.89452 12.2975 1.98457 12.8371C2.92508 18.4732 7.69767 20.9914 12 20.9914C16.3023 20.9914 21.0749 18.4732 22.0154 12.8371C22.1055 12.2975 22.6158 11.9277 23.1661 12.0177C23.7063 12.1076 24.0765 12.6272 23.9865 13.1669C22.8559 19.9521 17.1428 23 11.99 23H12.01ZM21.165 6.15177C22.3056 5.01257 22.3056 3.16386 21.165 2.02465L21.0049 1.85477C19.9143 0.765533 18.1633 0.725561 17.0227 1.71487C15.8821 0.715568 14.1312 0.765533 13.0406 1.85477L12.8705 2.01466C11.7299 3.15386 11.7299 5.00257 12.8705 6.14178L17.0227 10.2889L21.175 6.14178L21.165 6.15177ZM15.742 3.27378L17.0127 4.54289L18.2834 3.27378C18.6436 2.91403 19.2239 2.91403 19.5841 3.27378L19.7442 3.43367C20.1044 3.79342 20.1044 4.37301 19.7442 4.73276L17.0127 7.46086L14.2812 4.73276C13.921 4.37301 13.921 3.79342 14.2812 3.43367L14.4413 3.27378C14.6214 3.09391 14.8515 3.00397 15.0917 3.00397C15.3318 3.00397 15.5619 3.09391 15.742 3.27378ZM11.1595 6.15177C12.3002 5.01257 12.3002 3.16386 11.1595 2.02465L10.9995 1.85477C9.90886 0.765533 8.15792 0.725561 7.0173 1.71487C5.87668 0.715568 4.12573 0.765533 3.03514 1.85477L2.86505 2.01466C1.72443 3.15386 1.72443 5.00257 2.86505 6.14178L7.0173 10.2889L11.1695 6.14178L11.1595 6.15177ZM5.7366 3.27378L7.00729 4.54289L8.27798 3.27378C8.63818 2.91403 9.21849 2.91403 9.57869 3.27378L9.73877 3.43367C10.099 3.79342 10.099 4.37301 9.73877 4.73276L7.00729 7.46086L4.27581 4.73276C3.91562 4.37301 3.91562 3.79342 4.27581 3.43367L4.4359 3.27378C4.61599 3.09391 4.84612 3.00397 5.08625 3.00397C5.32638 3.00397 5.5565 3.09391 5.7366 3.27378Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/smiley/poor.svg":
/*!*********************************************************!*\
  !*** ./packages/survey-core/src/images/smiley/poor.svg ***!
  \*********************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M7.01915 7C6.46961 7 6.01998 6.55 6.01998 6V2C6.01998 1.45 6.46961 1 7.01915 1C7.56869 1 8.01832 1.45 8.01832 2V6C8.01832 6.55 7.56869 7 7.01915 7ZM18.01 6V2C18.01 1.45 17.5604 1 17.0108 1C16.4613 1 16.0117 1.45 16.0117 2V6C16.0117 6.55 16.4613 7 17.0108 7C17.5604 7 18.01 6.55 18.01 6ZM16.4213 21.58L18.01 19.99L19.2989 21.28C19.6886 21.67 20.3181 21.67 20.7077 21.28C21.0974 20.89 21.0974 20.26 20.7077 19.87L19.4188 18.58C18.6395 17.8 17.3705 17.8 16.5912 18.58L15.0025 20.17L13.4138 18.58C12.6345 17.8 11.3655 17.8 10.5862 18.58L8.9975 20.17L7.40883 18.58C6.62948 17.8 5.36053 17.8 4.58118 18.58L3.29226 19.87C2.90258 20.26 2.90258 20.89 3.29226 21.28C3.68193 21.67 4.31141 21.67 4.70108 21.28L5.99001 19.99L7.57868 21.58C8.35803 22.36 9.62698 22.36 10.4063 21.58L11.995 19.99L13.5837 21.58C13.9734 21.97 14.4829 22.16 14.9925 22.16C15.5021 22.16 16.0117 21.97 16.4013 21.58H16.4213Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/smiley/terrible.svg":
/*!*************************************************************!*\
  !*** ./packages/survey-core/src/images/smiley/terrible.svg ***!
  \*************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M4 4.9938C4 4.44362 4.45 3.99348 5 3.99348H6.59L5.3 2.70306C4.91 2.31293 4.91 1.68272 5.3 1.2926C5.69 0.902468 6.32 0.902468 6.71 1.2926L9.71 4.29357C9.8 4.3836 9.88 4.49364 9.93 4.62368C10.03 4.86376 10.03 5.14385 9.93 5.38393C9.88 5.50397 9.81 5.614 9.71 5.71404L6.71 8.71501C6.51 8.91508 6.26 9.00511 6 9.00511C5.74 9.00511 5.49 8.90508 5.29 8.71501C4.9 8.32489 4.9 7.69468 5.29 7.30456L6.58 6.01413H4.99C4.44 6.01413 3.99 5.56399 3.99 5.01381L4 4.9938ZM14.08 5.37393C14.13 5.49397 14.2 5.604 14.3 5.70403L17.3 8.70501C17.5 8.90508 17.75 8.99511 18.01 8.99511C18.27 8.99511 18.52 8.89507 18.72 8.70501C19.11 8.31488 19.11 7.68468 18.72 7.29455L17.43 6.00413H19.02C19.57 6.00413 20.02 5.55399 20.02 5.00381C20.02 4.45363 19.57 4.00348 19.02 4.00348H17.43L18.72 2.71306C19.11 2.32293 19.11 1.69273 18.72 1.3026C18.33 0.912471 17.7 0.912471 17.31 1.3026L14.31 4.30358C14.22 4.39361 14.14 4.50364 14.09 4.63368C13.99 4.87376 13.99 5.15385 14.09 5.39393L14.08 5.37393ZM22 14.9971V20.999C22 22.6496 20.65 24 19 24H5C3.35 24 2 22.6496 2 20.999V14.9971C2 13.3465 3.35 11.9961 5 11.9961H19C20.65 11.9961 22 13.3465 22 14.9971ZM19 13.9967H16V16.9977H20V14.9971C20 14.4469 19.55 13.9967 19 13.9967ZM14 16.9977V13.9967H10V16.9977H14ZM10 18.9984V21.9993H14V18.9984H10ZM4 14.9971V16.9977H8V13.9967H5C4.45 13.9967 4 14.4469 4 14.9971ZM5 21.9993H8V18.9984H4V20.999C4 21.5492 4.45 21.9993 5 21.9993ZM20 20.999V18.9984H16V21.9993H19C19.55 21.9993 20 21.5492 20 20.999Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/smiley/very-good.svg":
/*!**************************************************************!*\
  !*** ./packages/survey-core/src/images/smiley/very-good.svg ***!
  \**************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12.01 24C6.85721 24 1.15412 20.96 0.0134987 14.16C-0.0765501 13.62 0.293651 13.1 0.833944 13.01C1.38424 12.92 1.89452 13.29 1.98457 13.83C2.92508 19.47 7.69767 21.99 12 21.99C16.3023 21.99 21.0749 19.47 22.0154 13.83C22.1055 13.29 22.6158 12.92 23.1661 13.01C23.7063 13.1 24.0765 13.62 23.9865 14.16C22.8559 20.95 17.1428 24 11.99 24H12.01ZM8.00783 6V2C8.00783 1.45 7.55759 1 7.00729 1C6.45699 1 6.00675 1.45 6.00675 2V6C6.00675 6.55 6.45699 7 7.00729 7C7.55759 7 8.00783 6.55 8.00783 6ZM18.0133 6V2C18.0133 1.45 17.563 1 17.0127 1C16.4624 1 16.0122 1.45 16.0122 2V6C16.0122 6.55 16.4624 7 17.0127 7C17.563 7 18.0133 6.55 18.0133 6Z\"></path></svg>"

/***/ }),

/***/ "./packages/survey-core/src/images/smiley/very-poor.svg":
/*!**************************************************************!*\
  !*** ./packages/survey-core/src/images/smiley/very-poor.svg ***!
  \**************************************************************/
/*! no static exports found */
/*! ModuleConcatenation bailout: Module is not an ECMAScript module */
/***/ (function(module, exports) {

module.exports = "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><g clip-path=\"url(#clip0_15894_140103)\"><path d=\"M4.88291 4.50999C4.47291 4.50999 4.08291 4.24999 3.94291 3.83999C3.76291 3.31999 4.03291 2.74999 4.55291 2.56999L8.32291 1.24999C8.84291 1.05999 9.41291 1.33999 9.59291 1.85999C9.77291 2.37999 9.50291 2.94999 8.98291 3.12999L5.20291 4.44999C5.09291 4.48999 4.98291 4.50999 4.87291 4.50999H4.88291ZM19.8129 3.88999C20.0229 3.37999 19.7729 2.78999 19.2629 2.58999L15.5529 1.06999C15.0429 0.859992 14.4529 1.10999 14.2529 1.61999C14.0429 2.12999 14.2929 2.71999 14.8029 2.91999L18.5029 4.42999C18.6229 4.47999 18.7529 4.49999 18.8829 4.49999C19.2729 4.49999 19.6529 4.26999 19.8129 3.87999V3.88999ZM3.50291 5.99999C2.64291 6.36999 1.79291 6.87999 1.00291 7.47999C0.79291 7.63999 0.64291 7.86999 0.59291 8.13999C0.48291 8.72999 0.87291 9.28999 1.45291 9.39999C2.04291 9.50999 2.60291 9.11999 2.71291 8.53999C2.87291 7.68999 3.12291 6.82999 3.50291 5.98999V5.99999ZM21.0429 8.54999C21.6029 10.48 24.2429 8.83999 22.7529 7.47999C21.9629 6.87999 21.1129 6.36999 20.2529 5.99999C20.6329 6.83999 20.8829 7.69999 21.0429 8.54999ZM21.5729 13.2C21.2529 14.2 22.5429 15.09 23.3629 14.39C23.8529 14 23.9229 13.29 23.5429 12.81C21.7429 10.67 22.1329 10.55 21.5829 13.2H21.5729ZM1.75291 11C1.22291 11.79 -0.14709 12.64 0.0129102 13.75C0.15291 14.36 0.75291 14.74 1.35291 14.6C2.98291 14.1 1.80291 12.22 1.75291 11ZM19.8829 17C19.8829 13.14 16.2929 9.99999 11.8829 9.99999C7.47291 9.99999 3.88291 13.14 3.88291 17C3.88291 20.86 7.47291 24 11.8829 24C16.2929 24 19.8829 20.86 19.8829 17ZM17.8829 17C17.8829 19.76 15.1929 22 11.8829 22C8.57291 22 5.88291 19.76 5.88291 17C5.88291 14.24 8.57291 12 11.8829 12C15.1929 12 17.8829 14.24 17.8829 17Z\"></path></g><defs><clipPath id=\"clip0_15894_140103\"><rect width=\"24\" height=\"24\" fill=\"white\"></rect></clipPath></defs></svg>"

/***/ }),

/***/ "./src/entries/core.ts":
/*!*******************************************!*\
  !*** ./src/entries/core.ts + 126 modules ***!
  \*******************************************/
/*! exports provided: Version, ReleaseDate, checkLibraryVersion, setLicenseKey, slk, hasLicense, settings, Helpers, AnswerCountValidator, EmailValidator, NumericValidator, RegexValidator, SurveyValidator, TextValidator, ValidatorResult, ExpressionValidator, ValidatorRunner, ItemValue, Base, Event, EventBase, ArrayChanges, ComputedUpdater, SurveyError, SurveyElementCore, SurveyElement, DragTypeOverMeEnum, CalculatedValue, CustomError, AnswerRequiredError, OneAnswerRequiredError, RequreNumericError, ExceedSizeError, LocalizableString, LocalizableStrings, HtmlConditionItem, UrlConditionItem, ChoicesRestful, ChoicesRestfull, FunctionFactory, registerFunction, ConditionRunner, ExpressionRunner, ExpressionExecutor, Operand, Const, BinaryOperand, Variable, FunctionOperand, ArrayOperand, UnaryOperand, ConditionsParser, ProcessValue, JsonError, JsonIncorrectTypeError, JsonMetadata, JsonMetadataClass, JsonMissingTypeError, JsonMissingTypeErrorBase, JsonObject, JsonObjectProperty, JsonRequiredPropertyError, JsonUnknownPropertyError, Serializer, property, propertyArray, MatrixDropdownCell, MatrixDropdownRowModelBase, QuestionMatrixDropdownModelBase, MatrixDropdownColumn, matrixDropdownColumnTypes, QuestionMatrixDropdownRenderedCell, QuestionMatrixDropdownRenderedRow, QuestionMatrixDropdownRenderedErrorRow, QuestionMatrixDropdownRenderedTable, MatrixDropdownRowModel, QuestionMatrixDropdownModel, MatrixDynamicRowModel, QuestionMatrixDynamicModel, MatrixRowModel, MatrixCells, QuestionMatrixModel, QuestionMatrixBaseModel, MultipleTextItemModel, MultipleTextCell, MultipleTextErrorCell, MutlipleTextErrorRow, MutlipleTextRow, QuestionMultipleTextModel, MultipleTextEditorModel, PanelModel, PanelModelBase, QuestionRowModel, FlowPanelModel, PageModel, DefaultTitleModel, Question, QuestionNonValue, QuestionEmptyModel, QuestionCheckboxBase, QuestionSelectBase, QuestionCheckboxModel, QuestionTagboxModel, QuestionRankingModel, QuestionCommentModel, QuestionDropdownModel, QuestionFactory, ElementFactory, QuestionFileModel, QuestionHtmlModel, QuestionRadiogroupModel, QuestionRatingModel, RenderedRatingItem, QuestionExpressionModel, QuestionTextBase, CharacterCounter, QuestionTextModel, QuestionBooleanModel, QuestionImagePickerModel, ImageItemValue, QuestionImageModel, QuestionSignaturePadModel, QuestionPanelDynamicModel, QuestionPanelDynamicItem, SurveyTimer, SurveyTimerModel, tryFocusPage, createTOCListModel, getTocRootCss, TOCModel, SurveyProgressModel, ProgressButtons, ProgressButtonsResponsivityManager, SurveyModel, SurveyTrigger, SurveyTriggerComplete, SurveyTriggerSetValue, SurveyTriggerVisible, SurveyTriggerCopyValue, SurveyTriggerRunExpression, SurveyTriggerSkip, Trigger, PopupSurveyModel, SurveyWindowModel, TextPreProcessor, Notifier, Cover, CoverCell, dxSurveyService, englishStrings, surveyLocalization, surveyStrings, QuestionCustomWidget, CustomWidgetCollection, QuestionCustomModel, QuestionCompositeModel, ComponentQuestionJSON, ComponentCollection, ListModel, MultiSelectListModel, PopupModel, createDialogOptions, PopupBaseViewModel, PopupDropdownViewModel, PopupModalViewModel, createPopupViewModel, createPopupModalViewModel, DropdownListModel, DropdownMultiSelectListModel, QuestionButtonGroupModel, ButtonGroupItemModel, ButtonGroupItemValue, IsMobile, IsTouch, _setIsTouch, confirmAction, confirmActionAsync, detectIEOrEdge, doKey2ClickUp, doKey2ClickDown, doKey2ClickBlur, loadFileFromBase64, increaseHeightByContent, createSvg, chooseFiles, sanitizeEditableContent, InputMaskBase, InputMaskPattern, InputMaskNumeric, InputMaskDateTime, InputMaskCurrency, CssClassBuilder, surveyCss, defaultV2Css, defaultV2ThemeName, DragDropCore, DragDropChoices, DragDropRankingSelectToRank, StylesManager, defaultStandardCss, modernCss, SvgIconRegistry, SvgRegistry, SvgBundleViewModel, RendererFactory, ResponsivityManager, VerticalResponsivityManager, unwrap, getOriginalEvent, getElement, createDropdownActionModel, createDropdownActionModelAdvanced, createPopupModelWithListModel, getActionDropdownButtonTarget, BaseAction, Action, ActionDropdownViewModel, AnimationUtils, AnimationPropertyUtils, AnimationGroupUtils, AnimationProperty, AnimationBoolean, AnimationGroup, AnimationTab, AdaptiveActionContainer, defaultActionBarCss, ActionContainer, DragOrClickHelper, Model */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

// EXPORTS
__webpack_require__.d(__webpack_exports__, "Version", function() { return /* reexport */ Version; });
__webpack_require__.d(__webpack_exports__, "ReleaseDate", function() { return /* reexport */ ReleaseDate; });
__webpack_require__.d(__webpack_exports__, "checkLibraryVersion", function() { return /* reexport */ checkLibraryVersion; });
__webpack_require__.d(__webpack_exports__, "setLicenseKey", function() { return /* reexport */ setLicenseKey; });
__webpack_require__.d(__webpack_exports__, "slk", function() { return /* reexport */ slk; });
__webpack_require__.d(__webpack_exports__, "hasLicense", function() { return /* reexport */ hasLicense; });
__webpack_require__.d(__webpack_exports__, "settings", function() { return /* reexport */ settings; });
__webpack_require__.d(__webpack_exports__, "Helpers", function() { return /* reexport */ helpers_Helpers; });
__webpack_require__.d(__webpack_exports__, "AnswerCountValidator", function() { return /* reexport */ AnswerCountValidator; });
__webpack_require__.d(__webpack_exports__, "EmailValidator", function() { return /* reexport */ EmailValidator; });
__webpack_require__.d(__webpack_exports__, "NumericValidator", function() { return /* reexport */ validator_NumericValidator; });
__webpack_require__.d(__webpack_exports__, "RegexValidator", function() { return /* reexport */ RegexValidator; });
__webpack_require__.d(__webpack_exports__, "SurveyValidator", function() { return /* reexport */ validator_SurveyValidator; });
__webpack_require__.d(__webpack_exports__, "TextValidator", function() { return /* reexport */ TextValidator; });
__webpack_require__.d(__webpack_exports__, "ValidatorResult", function() { return /* reexport */ ValidatorResult; });
__webpack_require__.d(__webpack_exports__, "ExpressionValidator", function() { return /* reexport */ validator_ExpressionValidator; });
__webpack_require__.d(__webpack_exports__, "ValidatorRunner", function() { return /* reexport */ ValidatorRunner; });
__webpack_require__.d(__webpack_exports__, "ItemValue", function() { return /* reexport */ itemvalue_ItemValue; });
__webpack_require__.d(__webpack_exports__, "Base", function() { return /* reexport */ base_Base; });
__webpack_require__.d(__webpack_exports__, "Event", function() { return /* reexport */ Event; });
__webpack_require__.d(__webpack_exports__, "EventBase", function() { return /* reexport */ EventBase; });
__webpack_require__.d(__webpack_exports__, "ArrayChanges", function() { return /* reexport */ ArrayChanges; });
__webpack_require__.d(__webpack_exports__, "ComputedUpdater", function() { return /* reexport */ ComputedUpdater; });
__webpack_require__.d(__webpack_exports__, "SurveyError", function() { return /* reexport */ survey_error_SurveyError; });
__webpack_require__.d(__webpack_exports__, "SurveyElementCore", function() { return /* reexport */ survey_element_SurveyElementCore; });
__webpack_require__.d(__webpack_exports__, "SurveyElement", function() { return /* reexport */ survey_element_SurveyElement; });
__webpack_require__.d(__webpack_exports__, "DragTypeOverMeEnum", function() { return /* reexport */ DragTypeOverMeEnum; });
__webpack_require__.d(__webpack_exports__, "CalculatedValue", function() { return /* reexport */ calculatedValue_CalculatedValue; });
__webpack_require__.d(__webpack_exports__, "CustomError", function() { return /* reexport */ CustomError; });
__webpack_require__.d(__webpack_exports__, "AnswerRequiredError", function() { return /* reexport */ AnswerRequiredError; });
__webpack_require__.d(__webpack_exports__, "OneAnswerRequiredError", function() { return /* reexport */ OneAnswerRequiredError; });
__webpack_require__.d(__webpack_exports__, "RequreNumericError", function() { return /* reexport */ RequreNumericError; });
__webpack_require__.d(__webpack_exports__, "ExceedSizeError", function() { return /* reexport */ error_ExceedSizeError; });
__webpack_require__.d(__webpack_exports__, "LocalizableString", function() { return /* reexport */ localizablestring_LocalizableString; });
__webpack_require__.d(__webpack_exports__, "LocalizableStrings", function() { return /* reexport */ localizablestring_LocalizableStrings; });
__webpack_require__.d(__webpack_exports__, "HtmlConditionItem", function() { return /* reexport */ HtmlConditionItem; });
__webpack_require__.d(__webpack_exports__, "UrlConditionItem", function() { return /* reexport */ UrlConditionItem; });
__webpack_require__.d(__webpack_exports__, "ChoicesRestful", function() { return /* reexport */ choicesRestful_ChoicesRestful; });
__webpack_require__.d(__webpack_exports__, "ChoicesRestfull", function() { return /* reexport */ choicesRestful_ChoicesRestfull; });
__webpack_require__.d(__webpack_exports__, "FunctionFactory", function() { return /* reexport */ functionsfactory_FunctionFactory; });
__webpack_require__.d(__webpack_exports__, "registerFunction", function() { return /* reexport */ registerFunction; });
__webpack_require__.d(__webpack_exports__, "ConditionRunner", function() { return /* reexport */ ConditionRunner; });
__webpack_require__.d(__webpack_exports__, "ExpressionRunner", function() { return /* reexport */ ExpressionRunner; });
__webpack_require__.d(__webpack_exports__, "ExpressionExecutor", function() { return /* reexport */ conditions_ExpressionExecutor; });
__webpack_require__.d(__webpack_exports__, "Operand", function() { return /* reexport */ Operand; });
__webpack_require__.d(__webpack_exports__, "Const", function() { return /* reexport */ expressions_Const; });
__webpack_require__.d(__webpack_exports__, "BinaryOperand", function() { return /* reexport */ BinaryOperand; });
__webpack_require__.d(__webpack_exports__, "Variable", function() { return /* reexport */ expressions_Variable; });
__webpack_require__.d(__webpack_exports__, "FunctionOperand", function() { return /* reexport */ expressions_FunctionOperand; });
__webpack_require__.d(__webpack_exports__, "ArrayOperand", function() { return /* reexport */ ArrayOperand; });
__webpack_require__.d(__webpack_exports__, "UnaryOperand", function() { return /* reexport */ UnaryOperand; });
__webpack_require__.d(__webpack_exports__, "ConditionsParser", function() { return /* reexport */ conditionsParser_ConditionsParser; });
__webpack_require__.d(__webpack_exports__, "ProcessValue", function() { return /* reexport */ conditionProcessValue_ProcessValue; });
__webpack_require__.d(__webpack_exports__, "JsonError", function() { return /* reexport */ JsonError; });
__webpack_require__.d(__webpack_exports__, "JsonIncorrectTypeError", function() { return /* reexport */ JsonIncorrectTypeError; });
__webpack_require__.d(__webpack_exports__, "JsonMetadata", function() { return /* reexport */ JsonMetadata; });
__webpack_require__.d(__webpack_exports__, "JsonMetadataClass", function() { return /* reexport */ jsonobject_JsonMetadataClass; });
__webpack_require__.d(__webpack_exports__, "JsonMissingTypeError", function() { return /* reexport */ JsonMissingTypeError; });
__webpack_require__.d(__webpack_exports__, "JsonMissingTypeErrorBase", function() { return /* reexport */ JsonMissingTypeErrorBase; });
__webpack_require__.d(__webpack_exports__, "JsonObject", function() { return /* reexport */ jsonobject_JsonObject; });
__webpack_require__.d(__webpack_exports__, "JsonObjectProperty", function() { return /* reexport */ jsonobject_JsonObjectProperty; });
__webpack_require__.d(__webpack_exports__, "JsonRequiredPropertyError", function() { return /* reexport */ JsonRequiredPropertyError; });
__webpack_require__.d(__webpack_exports__, "JsonUnknownPropertyError", function() { return /* reexport */ JsonUnknownPropertyError; });
__webpack_require__.d(__webpack_exports__, "Serializer", function() { return /* reexport */ Serializer; });
__webpack_require__.d(__webpack_exports__, "property", function() { return /* reexport */ jsonobject_property; });
__webpack_require__.d(__webpack_exports__, "propertyArray", function() { return /* reexport */ propertyArray; });
__webpack_require__.d(__webpack_exports__, "MatrixDropdownCell", function() { return /* reexport */ question_matrixdropdownbase_MatrixDropdownCell; });
__webpack_require__.d(__webpack_exports__, "MatrixDropdownRowModelBase", function() { return /* reexport */ question_matrixdropdownbase_MatrixDropdownRowModelBase; });
__webpack_require__.d(__webpack_exports__, "QuestionMatrixDropdownModelBase", function() { return /* reexport */ question_matrixdropdownbase_QuestionMatrixDropdownModelBase; });
__webpack_require__.d(__webpack_exports__, "MatrixDropdownColumn", function() { return /* reexport */ question_matrixdropdowncolumn_MatrixDropdownColumn; });
__webpack_require__.d(__webpack_exports__, "matrixDropdownColumnTypes", function() { return /* reexport */ matrixDropdownColumnTypes; });
__webpack_require__.d(__webpack_exports__, "QuestionMatrixDropdownRenderedCell", function() { return /* reexport */ question_matrixdropdownrendered_QuestionMatrixDropdownRenderedCell; });
__webpack_require__.d(__webpack_exports__, "QuestionMatrixDropdownRenderedRow", function() { return /* reexport */ question_matrixdropdownrendered_QuestionMatrixDropdownRenderedRow; });
__webpack_require__.d(__webpack_exports__, "QuestionMatrixDropdownRenderedErrorRow", function() { return /* reexport */ question_matrixdropdownrendered_QuestionMatrixDropdownRenderedErrorRow; });
__webpack_require__.d(__webpack_exports__, "QuestionMatrixDropdownRenderedTable", function() { return /* reexport */ question_matrixdropdownrendered_QuestionMatrixDropdownRenderedTable; });
__webpack_require__.d(__webpack_exports__, "MatrixDropdownRowModel", function() { return /* reexport */ MatrixDropdownRowModel; });
__webpack_require__.d(__webpack_exports__, "QuestionMatrixDropdownModel", function() { return /* reexport */ question_matrixdropdown_QuestionMatrixDropdownModel; });
__webpack_require__.d(__webpack_exports__, "MatrixDynamicRowModel", function() { return /* reexport */ MatrixDynamicRowModel; });
__webpack_require__.d(__webpack_exports__, "QuestionMatrixDynamicModel", function() { return /* reexport */ question_matrixdynamic_QuestionMatrixDynamicModel; });
__webpack_require__.d(__webpack_exports__, "MatrixRowModel", function() { return /* reexport */ question_matrix_MatrixRowModel; });
__webpack_require__.d(__webpack_exports__, "MatrixCells", function() { return /* reexport */ question_matrix_MatrixCells; });
__webpack_require__.d(__webpack_exports__, "QuestionMatrixModel", function() { return /* reexport */ question_matrix_QuestionMatrixModel; });
__webpack_require__.d(__webpack_exports__, "QuestionMatrixBaseModel", function() { return /* reexport */ martixBase_QuestionMatrixBaseModel; });
__webpack_require__.d(__webpack_exports__, "MultipleTextItemModel", function() { return /* reexport */ question_multipletext_MultipleTextItemModel; });
__webpack_require__.d(__webpack_exports__, "MultipleTextCell", function() { return /* reexport */ question_multipletext_MultipleTextCell; });
__webpack_require__.d(__webpack_exports__, "MultipleTextErrorCell", function() { return /* reexport */ question_multipletext_MultipleTextErrorCell; });
__webpack_require__.d(__webpack_exports__, "MutlipleTextErrorRow", function() { return /* reexport */ MutlipleTextErrorRow; });
__webpack_require__.d(__webpack_exports__, "MutlipleTextRow", function() { return /* reexport */ question_multipletext_MutlipleTextRow; });
__webpack_require__.d(__webpack_exports__, "QuestionMultipleTextModel", function() { return /* reexport */ question_multipletext_QuestionMultipleTextModel; });
__webpack_require__.d(__webpack_exports__, "MultipleTextEditorModel", function() { return /* reexport */ MultipleTextEditorModel; });
__webpack_require__.d(__webpack_exports__, "PanelModel", function() { return /* reexport */ panel_PanelModel; });
__webpack_require__.d(__webpack_exports__, "PanelModelBase", function() { return /* reexport */ panel_PanelModelBase; });
__webpack_require__.d(__webpack_exports__, "QuestionRowModel", function() { return /* reexport */ panel_QuestionRowModel; });
__webpack_require__.d(__webpack_exports__, "FlowPanelModel", function() { return /* reexport */ flowpanel_FlowPanelModel; });
__webpack_require__.d(__webpack_exports__, "PageModel", function() { return /* reexport */ page_PageModel; });
__webpack_require__.d(__webpack_exports__, "DefaultTitleModel", function() { return /* reexport */ defaultTitle_DefaultTitleModel; });
__webpack_require__.d(__webpack_exports__, "Question", function() { return /* reexport */ question_Question; });
__webpack_require__.d(__webpack_exports__, "QuestionNonValue", function() { return /* reexport */ QuestionNonValue; });
__webpack_require__.d(__webpack_exports__, "QuestionEmptyModel", function() { return /* reexport */ QuestionEmptyModel; });
__webpack_require__.d(__webpack_exports__, "QuestionCheckboxBase", function() { return /* reexport */ QuestionCheckboxBase; });
__webpack_require__.d(__webpack_exports__, "QuestionSelectBase", function() { return /* reexport */ question_baseselect_QuestionSelectBase; });
__webpack_require__.d(__webpack_exports__, "QuestionCheckboxModel", function() { return /* reexport */ question_checkbox_QuestionCheckboxModel; });
__webpack_require__.d(__webpack_exports__, "QuestionTagboxModel", function() { return /* reexport */ question_tagbox_QuestionTagboxModel; });
__webpack_require__.d(__webpack_exports__, "QuestionRankingModel", function() { return /* reexport */ question_ranking_QuestionRankingModel; });
__webpack_require__.d(__webpack_exports__, "QuestionCommentModel", function() { return /* reexport */ question_comment_QuestionCommentModel; });
__webpack_require__.d(__webpack_exports__, "QuestionDropdownModel", function() { return /* reexport */ question_dropdown_QuestionDropdownModel; });
__webpack_require__.d(__webpack_exports__, "QuestionFactory", function() { return /* reexport */ questionfactory_QuestionFactory; });
__webpack_require__.d(__webpack_exports__, "ElementFactory", function() { return /* reexport */ questionfactory_ElementFactory; });
__webpack_require__.d(__webpack_exports__, "QuestionFileModel", function() { return /* reexport */ question_file_QuestionFileModel; });
__webpack_require__.d(__webpack_exports__, "QuestionHtmlModel", function() { return /* reexport */ question_html_QuestionHtmlModel; });
__webpack_require__.d(__webpack_exports__, "QuestionRadiogroupModel", function() { return /* reexport */ question_radiogroup_QuestionRadiogroupModel; });
__webpack_require__.d(__webpack_exports__, "QuestionRatingModel", function() { return /* reexport */ question_rating_QuestionRatingModel; });
__webpack_require__.d(__webpack_exports__, "RenderedRatingItem", function() { return /* reexport */ question_rating_RenderedRatingItem; });
__webpack_require__.d(__webpack_exports__, "QuestionExpressionModel", function() { return /* reexport */ question_expression_QuestionExpressionModel; });
__webpack_require__.d(__webpack_exports__, "QuestionTextBase", function() { return /* reexport */ question_textbase_QuestionTextBase; });
__webpack_require__.d(__webpack_exports__, "CharacterCounter", function() { return /* reexport */ question_textbase_CharacterCounter; });
__webpack_require__.d(__webpack_exports__, "QuestionTextModel", function() { return /* reexport */ question_text_QuestionTextModel; });
__webpack_require__.d(__webpack_exports__, "QuestionBooleanModel", function() { return /* reexport */ question_boolean_QuestionBooleanModel; });
__webpack_require__.d(__webpack_exports__, "QuestionImagePickerModel", function() { return /* reexport */ question_imagepicker_QuestionImagePickerModel; });
__webpack_require__.d(__webpack_exports__, "ImageItemValue", function() { return /* reexport */ question_imagepicker_ImageItemValue; });
__webpack_require__.d(__webpack_exports__, "QuestionImageModel", function() { return /* reexport */ question_image_QuestionImageModel; });
__webpack_require__.d(__webpack_exports__, "QuestionSignaturePadModel", function() { return /* reexport */ question_signaturepad_QuestionSignaturePadModel; });
__webpack_require__.d(__webpack_exports__, "QuestionPanelDynamicModel", function() { return /* reexport */ question_paneldynamic_QuestionPanelDynamicModel; });
__webpack_require__.d(__webpack_exports__, "QuestionPanelDynamicItem", function() { return /* reexport */ question_paneldynamic_QuestionPanelDynamicItem; });
__webpack_require__.d(__webpack_exports__, "SurveyTimer", function() { return /* reexport */ surveytimer_SurveyTimer; });
__webpack_require__.d(__webpack_exports__, "SurveyTimerModel", function() { return /* reexport */ surveyTimerModel_SurveyTimerModel; });
__webpack_require__.d(__webpack_exports__, "tryFocusPage", function() { return /* reexport */ tryFocusPage; });
__webpack_require__.d(__webpack_exports__, "createTOCListModel", function() { return /* reexport */ createTOCListModel; });
__webpack_require__.d(__webpack_exports__, "getTocRootCss", function() { return /* reexport */ getTocRootCss; });
__webpack_require__.d(__webpack_exports__, "TOCModel", function() { return /* reexport */ surveyToc_TOCModel; });
__webpack_require__.d(__webpack_exports__, "SurveyProgressModel", function() { return /* reexport */ surveyProgress_SurveyProgressModel; });
__webpack_require__.d(__webpack_exports__, "ProgressButtons", function() { return /* reexport */ progress_buttons_ProgressButtons; });
__webpack_require__.d(__webpack_exports__, "ProgressButtonsResponsivityManager", function() { return /* reexport */ ProgressButtonsResponsivityManager; });
__webpack_require__.d(__webpack_exports__, "SurveyModel", function() { return /* reexport */ survey_SurveyModel; });
__webpack_require__.d(__webpack_exports__, "SurveyTrigger", function() { return /* reexport */ SurveyTrigger; });
__webpack_require__.d(__webpack_exports__, "SurveyTriggerComplete", function() { return /* reexport */ trigger_SurveyTriggerComplete; });
__webpack_require__.d(__webpack_exports__, "SurveyTriggerSetValue", function() { return /* reexport */ SurveyTriggerSetValue; });
__webpack_require__.d(__webpack_exports__, "SurveyTriggerVisible", function() { return /* reexport */ SurveyTriggerVisible; });
__webpack_require__.d(__webpack_exports__, "SurveyTriggerCopyValue", function() { return /* reexport */ SurveyTriggerCopyValue; });
__webpack_require__.d(__webpack_exports__, "SurveyTriggerRunExpression", function() { return /* reexport */ trigger_SurveyTriggerRunExpression; });
__webpack_require__.d(__webpack_exports__, "SurveyTriggerSkip", function() { return /* reexport */ trigger_SurveyTriggerSkip; });
__webpack_require__.d(__webpack_exports__, "Trigger", function() { return /* reexport */ trigger_Trigger; });
__webpack_require__.d(__webpack_exports__, "PopupSurveyModel", function() { return /* reexport */ popup_survey_PopupSurveyModel; });
__webpack_require__.d(__webpack_exports__, "SurveyWindowModel", function() { return /* reexport */ SurveyWindowModel; });
__webpack_require__.d(__webpack_exports__, "TextPreProcessor", function() { return /* reexport */ textPreProcessor_TextPreProcessor; });
__webpack_require__.d(__webpack_exports__, "Notifier", function() { return /* reexport */ notifier_Notifier; });
__webpack_require__.d(__webpack_exports__, "Cover", function() { return /* reexport */ header_Cover; });
__webpack_require__.d(__webpack_exports__, "CoverCell", function() { return /* reexport */ CoverCell; });
__webpack_require__.d(__webpack_exports__, "dxSurveyService", function() { return /* reexport */ dxSurveyService_dxSurveyService; });
__webpack_require__.d(__webpack_exports__, "englishStrings", function() { return /* reexport */ englishStrings; });
__webpack_require__.d(__webpack_exports__, "surveyLocalization", function() { return /* reexport */ surveyLocalization; });
__webpack_require__.d(__webpack_exports__, "surveyStrings", function() { return /* reexport */ surveyStrings; });
__webpack_require__.d(__webpack_exports__, "QuestionCustomWidget", function() { return /* reexport */ QuestionCustomWidget; });
__webpack_require__.d(__webpack_exports__, "CustomWidgetCollection", function() { return /* reexport */ questionCustomWidgets_CustomWidgetCollection; });
__webpack_require__.d(__webpack_exports__, "QuestionCustomModel", function() { return /* reexport */ question_custom_QuestionCustomModel; });
__webpack_require__.d(__webpack_exports__, "QuestionCompositeModel", function() { return /* reexport */ question_custom_QuestionCompositeModel; });
__webpack_require__.d(__webpack_exports__, "ComponentQuestionJSON", function() { return /* reexport */ question_custom_ComponentQuestionJSON; });
__webpack_require__.d(__webpack_exports__, "ComponentCollection", function() { return /* reexport */ question_custom_ComponentCollection; });
__webpack_require__.d(__webpack_exports__, "ListModel", function() { return /* reexport */ list_ListModel; });
__webpack_require__.d(__webpack_exports__, "MultiSelectListModel", function() { return /* reexport */ multiSelectListModel_MultiSelectListModel; });
__webpack_require__.d(__webpack_exports__, "PopupModel", function() { return /* reexport */ popup_PopupModel; });
__webpack_require__.d(__webpack_exports__, "createDialogOptions", function() { return /* reexport */ createDialogOptions; });
__webpack_require__.d(__webpack_exports__, "PopupBaseViewModel", function() { return /* reexport */ popup_view_model_PopupBaseViewModel; });
__webpack_require__.d(__webpack_exports__, "PopupDropdownViewModel", function() { return /* reexport */ popup_dropdown_view_model_PopupDropdownViewModel; });
__webpack_require__.d(__webpack_exports__, "PopupModalViewModel", function() { return /* reexport */ PopupModalViewModel; });
__webpack_require__.d(__webpack_exports__, "createPopupViewModel", function() { return /* reexport */ createPopupViewModel; });
__webpack_require__.d(__webpack_exports__, "createPopupModalViewModel", function() { return /* reexport */ createPopupModalViewModel; });
__webpack_require__.d(__webpack_exports__, "DropdownListModel", function() { return /* reexport */ dropdownListModel_DropdownListModel; });
__webpack_require__.d(__webpack_exports__, "DropdownMultiSelectListModel", function() { return /* reexport */ dropdownMultiSelectListModel_DropdownMultiSelectListModel; });
__webpack_require__.d(__webpack_exports__, "QuestionButtonGroupModel", function() { return /* reexport */ QuestionButtonGroupModel; });
__webpack_require__.d(__webpack_exports__, "ButtonGroupItemModel", function() { return /* reexport */ question_buttongroup_ButtonGroupItemModel; });
__webpack_require__.d(__webpack_exports__, "ButtonGroupItemValue", function() { return /* reexport */ question_buttongroup_ButtonGroupItemValue; });
__webpack_require__.d(__webpack_exports__, "IsMobile", function() { return /* reexport */ IsMobile; });
__webpack_require__.d(__webpack_exports__, "IsTouch", function() { return /* reexport */ IsTouch; });
__webpack_require__.d(__webpack_exports__, "_setIsTouch", function() { return /* reexport */ _setIsTouch; });
__webpack_require__.d(__webpack_exports__, "confirmAction", function() { return /* reexport */ confirmAction; });
__webpack_require__.d(__webpack_exports__, "confirmActionAsync", function() { return /* reexport */ confirmActionAsync; });
__webpack_require__.d(__webpack_exports__, "detectIEOrEdge", function() { return /* reexport */ detectIEOrEdge; });
__webpack_require__.d(__webpack_exports__, "doKey2ClickUp", function() { return /* reexport */ doKey2ClickUp; });
__webpack_require__.d(__webpack_exports__, "doKey2ClickDown", function() { return /* reexport */ doKey2ClickDown; });
__webpack_require__.d(__webpack_exports__, "doKey2ClickBlur", function() { return /* reexport */ doKey2ClickBlur; });
__webpack_require__.d(__webpack_exports__, "loadFileFromBase64", function() { return /* reexport */ loadFileFromBase64; });
__webpack_require__.d(__webpack_exports__, "increaseHeightByContent", function() { return /* reexport */ increaseHeightByContent; });
__webpack_require__.d(__webpack_exports__, "createSvg", function() { return /* reexport */ createSvg; });
__webpack_require__.d(__webpack_exports__, "chooseFiles", function() { return /* reexport */ chooseFiles; });
__webpack_require__.d(__webpack_exports__, "sanitizeEditableContent", function() { return /* reexport */ sanitizeEditableContent; });
__webpack_require__.d(__webpack_exports__, "InputMaskBase", function() { return /* reexport */ mask_base_InputMaskBase; });
__webpack_require__.d(__webpack_exports__, "InputMaskPattern", function() { return /* reexport */ mask_pattern_InputMaskPattern; });
__webpack_require__.d(__webpack_exports__, "InputMaskNumeric", function() { return /* reexport */ mask_numeric_InputMaskNumeric; });
__webpack_require__.d(__webpack_exports__, "InputMaskDateTime", function() { return /* reexport */ mask_datetime_InputMaskDateTime; });
__webpack_require__.d(__webpack_exports__, "InputMaskCurrency", function() { return /* reexport */ mask_currency_InputMaskCurrency; });
__webpack_require__.d(__webpack_exports__, "CssClassBuilder", function() { return /* reexport */ CssClassBuilder; });
__webpack_require__.d(__webpack_exports__, "surveyCss", function() { return /* reexport */ surveyCss; });
__webpack_require__.d(__webpack_exports__, "defaultV2Css", function() { return /* reexport */ defaultV2Css; });
__webpack_require__.d(__webpack_exports__, "defaultV2ThemeName", function() { return /* reexport */ defaultV2ThemeName; });
__webpack_require__.d(__webpack_exports__, "DragDropCore", function() { return /* reexport */ core_DragDropCore; });
__webpack_require__.d(__webpack_exports__, "DragDropChoices", function() { return /* reexport */ choices_DragDropChoices; });
__webpack_require__.d(__webpack_exports__, "DragDropRankingSelectToRank", function() { return /* reexport */ DragDropRankingSelectToRank; });
__webpack_require__.d(__webpack_exports__, "StylesManager", function() { return /* reexport */ stylesmanager_StylesManager; });
__webpack_require__.d(__webpack_exports__, "defaultStandardCss", function() { return /* reexport */ defaultStandardCss; });
__webpack_require__.d(__webpack_exports__, "modernCss", function() { return /* reexport */ modernCss; });
__webpack_require__.d(__webpack_exports__, "SvgIconRegistry", function() { return /* reexport */ svgbundle_SvgIconRegistry; });
__webpack_require__.d(__webpack_exports__, "SvgRegistry", function() { return /* reexport */ SvgRegistry; });
__webpack_require__.d(__webpack_exports__, "SvgBundleViewModel", function() { return /* reexport */ SvgBundleViewModel; });
__webpack_require__.d(__webpack_exports__, "RendererFactory", function() { return /* reexport */ RendererFactory; });
__webpack_require__.d(__webpack_exports__, "ResponsivityManager", function() { return /* reexport */ responsivity_manager_ResponsivityManager; });
__webpack_require__.d(__webpack_exports__, "VerticalResponsivityManager", function() { return /* reexport */ VerticalResponsivityManager; });
__webpack_require__.d(__webpack_exports__, "unwrap", function() { return /* reexport */ unwrap; });
__webpack_require__.d(__webpack_exports__, "getOriginalEvent", function() { return /* reexport */ getOriginalEvent; });
__webpack_require__.d(__webpack_exports__, "getElement", function() { return /* reexport */ getElement; });
__webpack_require__.d(__webpack_exports__, "createDropdownActionModel", function() { return /* reexport */ createDropdownActionModel; });
__webpack_require__.d(__webpack_exports__, "createDropdownActionModelAdvanced", function() { return /* reexport */ createDropdownActionModelAdvanced; });
__webpack_require__.d(__webpack_exports__, "createPopupModelWithListModel", function() { return /* reexport */ createPopupModelWithListModel; });
__webpack_require__.d(__webpack_exports__, "getActionDropdownButtonTarget", function() { return /* reexport */ getActionDropdownButtonTarget; });
__webpack_require__.d(__webpack_exports__, "BaseAction", function() { return /* reexport */ action_BaseAction; });
__webpack_require__.d(__webpack_exports__, "Action", function() { return /* reexport */ action_Action; });
__webpack_require__.d(__webpack_exports__, "ActionDropdownViewModel", function() { return /* reexport */ ActionDropdownViewModel; });
__webpack_require__.d(__webpack_exports__, "AnimationUtils", function() { return /* reexport */ animation_AnimationUtils; });
__webpack_require__.d(__webpack_exports__, "AnimationPropertyUtils", function() { return /* reexport */ AnimationPropertyUtils; });
__webpack_require__.d(__webpack_exports__, "AnimationGroupUtils", function() { return /* reexport */ AnimationGroupUtils; });
__webpack_require__.d(__webpack_exports__, "AnimationProperty", function() { return /* reexport */ animation_AnimationProperty; });
__webpack_require__.d(__webpack_exports__, "AnimationBoolean", function() { return /* reexport */ AnimationBoolean; });
__webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return /* reexport */ animation_AnimationGroup; });
__webpack_require__.d(__webpack_exports__, "AnimationTab", function() { return /* reexport */ AnimationTab; });
__webpack_require__.d(__webpack_exports__, "AdaptiveActionContainer", function() { return /* reexport */ adaptive_container_AdaptiveActionContainer; });
__webpack_require__.d(__webpack_exports__, "defaultActionBarCss", function() { return /* reexport */ defaultActionBarCss; });
__webpack_require__.d(__webpack_exports__, "ActionContainer", function() { return /* reexport */ container_ActionContainer; });
__webpack_require__.d(__webpack_exports__, "DragOrClickHelper", function() { return /* reexport */ dragOrClickHelper_DragOrClickHelper; });
__webpack_require__.d(__webpack_exports__, "Model", function() { return /* reexport */ survey_SurveyModel; });

// CONCATENATED MODULE: ./packages/survey-core/src/global_variables_utils.ts
/* eslint-disable no-restricted-globals */
var DomWindowHelper = /** @class */ (function () {
    function DomWindowHelper() {
    }
    DomWindowHelper.isAvailable = function () {
        return "undefined" !== typeof window;
    };
    DomWindowHelper.isFileReaderAvailable = function () {
        if (!DomWindowHelper.isAvailable())
            return false;
        return !!window["FileReader"];
    };
    DomWindowHelper.getLocation = function () {
        if (!DomWindowHelper.isAvailable())
            return;
        return window.location;
    };
    DomWindowHelper.getVisualViewport = function () {
        if (!DomWindowHelper.isAvailable())
            return null;
        return window.visualViewport;
    };
    DomWindowHelper.getInnerWidth = function () {
        if (!DomWindowHelper.isAvailable())
            return;
        return window.innerWidth;
    };
    DomWindowHelper.getInnerHeight = function () {
        if (!DomWindowHelper.isAvailable())
            return null;
        return window.innerHeight;
    };
    DomWindowHelper.getWindow = function () {
        if (!DomWindowHelper.isAvailable())
            return;
        return window;
    };
    DomWindowHelper.hasOwn = function (propertyName) {
        if (!DomWindowHelper.isAvailable())
            return;
        return propertyName in window;
    };
    DomWindowHelper.getSelection = function () {
        if (DomWindowHelper.isAvailable() && window.getSelection) {
            return window.getSelection();
        }
    };
    DomWindowHelper.requestAnimationFrame = function (callback) {
        if (DomWindowHelper.isAvailable()) {
            return window.requestAnimationFrame(callback);
        }
    };
    DomWindowHelper.addEventListener = function (type, listener) {
        if (!DomWindowHelper.isAvailable())
            return;
        window.addEventListener(type, listener);
    };
    DomWindowHelper.removeEventListener = function (type, listener) {
        if (!DomWindowHelper.isAvailable())
            return;
        window.removeEventListener(type, listener);
    };
    DomWindowHelper.matchMedia = function (mediaQueryString) {
        if (!DomWindowHelper.isAvailable() || typeof window.matchMedia === "undefined")
            return null;
        return window.matchMedia(mediaQueryString);
    };
    return DomWindowHelper;
}());

var DomDocumentHelper = /** @class */ (function () {
    function DomDocumentHelper() {
    }
    DomDocumentHelper.isAvailable = function () {
        return "undefined" !== typeof document;
    };
    DomDocumentHelper.getBody = function () {
        if (!DomDocumentHelper.isAvailable())
            return;
        return document.body;
    };
    DomDocumentHelper.getDocumentElement = function () {
        if (!DomDocumentHelper.isAvailable())
            return;
        return document.documentElement;
    };
    DomDocumentHelper.getDocument = function () {
        if (!DomDocumentHelper.isAvailable())
            return;
        return document;
    };
    DomDocumentHelper.getCookie = function () {
        if (!DomDocumentHelper.isAvailable())
            return;
        return document.cookie;
    };
    DomDocumentHelper.setCookie = function (newCookie) {
        if (!DomDocumentHelper.isAvailable())
            return;
        document.cookie = newCookie;
    };
    DomDocumentHelper.activeElementBlur = function () {
        if (!DomDocumentHelper.isAvailable())
            return;
        var activeElement = document.activeElement;
        if (!!activeElement && !!activeElement.blur) {
            activeElement.blur();
        }
    };
    DomDocumentHelper.createElement = function (tagName) {
        if (!DomDocumentHelper.isAvailable())
            return;
        return document.createElement(tagName);
    };
    DomDocumentHelper.getComputedStyle = function (elt) {
        if (!DomDocumentHelper.isAvailable())
            return new CSSStyleDeclaration();
        return document.defaultView.getComputedStyle(elt);
    };
    DomDocumentHelper.addEventListener = function (type, listener) {
        if (!DomDocumentHelper.isAvailable())
            return;
        document.addEventListener(type, listener);
    };
    DomDocumentHelper.removeEventListener = function (type, listener) {
        if (!DomDocumentHelper.isAvailable())
            return;
        document.removeEventListener(type, listener);
    };
    return DomDocumentHelper;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/helpers.ts

var helpers_Helpers = /** @class */ (function () {
    function Helpers() {
    }
    /**
     * A static methods that returns true if a value undefined, null, empty string or empty array.
     * @param value
     */
    Helpers.isValueEmpty = function (value) {
        if (Array.isArray(value) && value.length === 0)
            return true;
        if (!!value && Helpers.isValueObject(value) && value.constructor === Object) {
            for (var key in value) {
                if (!Helpers.isValueEmpty(value[key]))
                    return false;
            }
            return true;
        }
        return !value && value !== 0 && value !== false;
    };
    Helpers.isArrayContainsEqual = function (x, y) {
        if (!Array.isArray(x) || !Array.isArray(y))
            return false;
        if (x.length !== y.length)
            return false;
        for (var i = 0; i < x.length; i++) {
            var j = 0;
            for (; j < y.length; j++) {
                if (Helpers.isTwoValueEquals(x[i], y[j]))
                    break;
            }
            if (j === y.length)
                return false;
        }
        return true;
    };
    Helpers.isArraysEqual = function (x, y, ignoreOrder, caseSensitive, trimStrings) {
        if (ignoreOrder === void 0) { ignoreOrder = false; }
        if (!Array.isArray(x) || !Array.isArray(y))
            return false;
        if (x.length !== y.length)
            return false;
        if (ignoreOrder) {
            var xSorted = [];
            var ySorted = [];
            for (var i = 0; i < x.length; i++) {
                xSorted.push(x[i]);
                ySorted.push(y[i]);
            }
            xSorted.sort();
            ySorted.sort();
            x = xSorted;
            y = ySorted;
        }
        for (var i = 0; i < x.length; i++) {
            if (!Helpers.isTwoValueEquals(x[i], y[i], ignoreOrder, caseSensitive, trimStrings))
                return false;
        }
        return true;
    };
    Helpers.compareStrings = function (x, y) {
        var normalize = settings.comparator.normalizeTextCallback;
        if (!!x)
            x = normalize(x, "compare").trim();
        if (!!y)
            y = normalize(y, "compare").trim();
        if (!x && !y)
            return 0;
        if (!x)
            return -1;
        if (!y)
            return 1;
        if (x === y)
            return 0;
        var digitIndex = -1;
        for (var i = 0; i < x.length && i < y.length; i++) {
            if (this.isCharDigit(x[i]) && this.isCharDigit(y[i])) {
                digitIndex = i;
                break;
            }
            if (x[i] !== y[i])
                break;
        }
        if (digitIndex > -1) {
            var nX = this.getNumberFromStr(x, digitIndex);
            var nY = this.getNumberFromStr(y, digitIndex);
            if (!Number.isNaN(nX) && !Number.isNaN(nY) && nX !== nY) {
                return nX > nY ? 1 : -1;
            }
        }
        return x > y ? 1 : -1;
    };
    Helpers.isTwoValueEquals = function (x, y, ignoreOrder, caseSensitive, trimStrings) {
        if (ignoreOrder === void 0) { ignoreOrder = false; }
        if (x === y)
            return true;
        if (Array.isArray(x) && x.length === 0 && typeof y === "undefined")
            return true;
        if (Array.isArray(y) && y.length === 0 && typeof x === "undefined")
            return true;
        if ((x === undefined || x === null) && y === "")
            return true;
        if ((y === undefined || y === null) && x === "")
            return true;
        if (trimStrings === undefined)
            trimStrings = settings.comparator.trimStrings;
        if (caseSensitive === undefined)
            caseSensitive = settings.comparator.caseSensitive;
        if (typeof x === "string" && typeof y === "string") {
            var normalize = settings.comparator.normalizeTextCallback;
            x = normalize(x, "compare");
            y = normalize(y, "compare");
            if (trimStrings) {
                x = x.trim();
                y = y.trim();
            }
            if (!caseSensitive) {
                x = x.toLowerCase();
                y = y.toLowerCase();
            }
            return x === y;
        }
        if (x instanceof Date && y instanceof Date)
            return x.getTime() == y.getTime();
        if (Helpers.isConvertibleToNumber(x) && Helpers.isConvertibleToNumber(y)) {
            if (parseInt(x) === parseInt(y) && parseFloat(x) === parseFloat(y)) {
                return true;
            }
        }
        if ((!Helpers.isValueEmpty(x) && Helpers.isValueEmpty(y)) ||
            (Helpers.isValueEmpty(x) && !Helpers.isValueEmpty(y)))
            return false;
        if ((x === true || x === false) && typeof y == "string") {
            return x.toString() === y.toLocaleLowerCase();
        }
        if ((y === true || y === false) && typeof x == "string") {
            return y.toString() === x.toLocaleLowerCase();
        }
        if (!Helpers.isValueObject(x) && !Helpers.isValueObject(y))
            return x == y;
        if (!Helpers.isValueObject(x) || !Helpers.isValueObject(y))
            return false;
        if (x["equals"] && y["equals"])
            return x.equals(y);
        if (Array.isArray(x) && Array.isArray(y)) {
            return Helpers.isArraysEqual(x, y, ignoreOrder, caseSensitive, trimStrings);
        }
        for (var p in x) {
            if (!x.hasOwnProperty(p))
                continue;
            if (!y.hasOwnProperty(p))
                return false;
            if (!this.isTwoValueEquals(x[p], y[p], ignoreOrder, caseSensitive, trimStrings))
                return false;
        }
        for (p in y) {
            if (y.hasOwnProperty(p) && !x.hasOwnProperty(p))
                return false;
        }
        return true;
    };
    Helpers.randomizeArray = function (array) {
        for (var i = array.length - 1; i > 0; i--) {
            var j = Math.floor(Math.random() * (i + 1));
            var temp = array[i];
            array[i] = array[j];
            array[j] = temp;
        }
        return array;
    };
    Helpers.getUnbindValue = function (value) {
        if (Array.isArray(value)) {
            var res = [];
            for (var i = 0; i < value.length; i++) {
                res.push(Helpers.getUnbindValue(value[i]));
            }
            return res;
        }
        if (!!value && Helpers.isValueObject(value) && !(value instanceof Date)) {
            return JSON.parse(JSON.stringify(value));
        }
        return value;
    };
    Helpers.createCopy = function (obj) {
        var res = {};
        if (!obj)
            return res;
        for (var key in obj) {
            res[key] = obj[key];
        }
        return res;
    };
    Helpers.isConvertibleToNumber = function (value) {
        return (value !== undefined &&
            value !== null &&
            !Array.isArray(value) &&
            !isNaN(value));
    };
    Helpers.isValueObject = function (val, excludeArray) {
        return val instanceof Object && (!excludeArray || !Array.isArray(val));
    };
    Helpers.isNumber = function (value) {
        return !isNaN(this.getNumber(value));
    };
    Helpers.getNumber = function (value) {
        var newValue = Helpers.getNumberCore(value);
        return settings.parseNumber(value, newValue);
    };
    Helpers.getNumberCore = function (value) {
        if (typeof value == "string") {
            if (!value.trim())
                return NaN;
            if (value.indexOf("0x") == 0) {
                if (value.length > 32)
                    return NaN;
                return parseInt(value);
            }
            if (Helpers.isStringHasOperator(value))
                return NaN;
        }
        value = this.prepareStringToNumber(value);
        var res = parseFloat(value);
        if (isNaN(res) || !isFinite(value))
            return NaN;
        return res;
    };
    Helpers.isStringHasOperator = function (str) {
        if (str.lastIndexOf("-") > 0)
            return false;
        if (str.lastIndexOf("+") > 0)
            return false;
        var operators = "*^/%";
        for (var i = 0; i < operators.length; i++) {
            if (str.indexOf(operators[i]) > -1)
                return true;
        }
        return false;
    };
    Helpers.prepareStringToNumber = function (val) {
        if (typeof val !== "string" || !val)
            return val;
        var i = val.indexOf(",");
        if (i > -1 && val.indexOf(",", i + 1) < 0) {
            return val.replace(",", ".");
        }
        return val;
    };
    Helpers.getMaxLength = function (maxLength, surveyLength) {
        if (maxLength < 0) {
            maxLength = surveyLength;
        }
        return maxLength > 0 ? maxLength : null;
    };
    Helpers.getRemainingCharacterCounterText = function (newValue, maxLength) {
        if (!maxLength || maxLength <= 0 || !settings.showMaxLengthIndicator) {
            return "";
        }
        var value = newValue ? newValue.length : "0";
        return [value, maxLength].join("/");
    };
    Helpers.getNumberByIndex = function (index, startIndexStr) {
        if (index < 0)
            return "";
        var startIndex = 1;
        var prefix = "";
        var postfix = ".";
        var isNumeric = true;
        var strIndex = "A";
        var str = "";
        if (!!startIndexStr) {
            str = startIndexStr;
            var ind = str.length - 1;
            var hasDigit = false;
            for (var i = 0; i < str.length; i++) {
                if (Helpers.isCharDigit(str[i])) {
                    hasDigit = true;
                    break;
                }
            }
            var checkLetter = function () {
                return ((hasDigit && !Helpers.isCharDigit(str[ind])) ||
                    Helpers.isCharNotLetterAndDigit(str[ind]));
            };
            while (ind >= 0 && checkLetter())
                ind--;
            var newPostfix = "";
            if (ind < str.length - 1) {
                newPostfix = str.substring(ind + 1);
                str = str.substring(0, ind + 1);
            }
            ind = str.length - 1;
            while (ind >= 0) {
                if (checkLetter())
                    break;
                ind--;
                if (!hasDigit)
                    break;
            }
            strIndex = str.substring(ind + 1);
            prefix = str.substring(0, ind + 1);
            if (parseInt(strIndex))
                startIndex = parseInt(strIndex);
            else if (strIndex.length == 1)
                isNumeric = false;
            if (!!newPostfix || !!prefix) {
                postfix = newPostfix;
            }
        }
        if (isNumeric) {
            var val = (index + startIndex).toString();
            while (val.length < strIndex.length)
                val = "0" + val;
            return prefix + val + postfix;
        }
        return (prefix + String.fromCharCode(strIndex.charCodeAt(0) + index) + postfix);
    };
    Helpers.isCharNotLetterAndDigit = function (ch) {
        return ch.toUpperCase() == ch.toLowerCase() && !Helpers.isCharDigit(ch);
    };
    Helpers.isCharDigit = function (ch) {
        return ch >= "0" && ch <= "9";
    };
    Helpers.getNumberFromStr = function (str, index) {
        if (!this.isCharDigit(str[index]))
            return NaN;
        var nStr = "";
        while (index < str.length && this.isCharDigit(str[index])) {
            nStr += str[index];
            index++;
        }
        if (!nStr)
            return NaN;
        return this.getNumber(nStr);
    };
    Helpers.countDecimals = function (value) {
        if (Helpers.isNumber(value) && Math.floor(value) !== value) {
            var strs = value.toString().split(".");
            return strs.length > 1 && strs[1].length || 0;
        }
        return 0;
    };
    Helpers.correctAfterPlusMinis = function (a, b, res) {
        var digitsA = Helpers.countDecimals(a);
        var digitsB = Helpers.countDecimals(b);
        if (digitsA > 0 || digitsB > 0) {
            var digits = Math.max(digitsA, digitsB);
            res = parseFloat(res.toFixed(digits));
        }
        return res;
    };
    Helpers.sumAnyValues = function (a, b) {
        if (!Helpers.isNumber(a) || !Helpers.isNumber(b)) {
            if (Array.isArray(a) && Array.isArray(b))
                return [].concat(a).concat(b);
            if (Array.isArray(a) || Array.isArray(b)) {
                var arr = Array.isArray(a) ? a : b;
                var val = arr === a ? b : a;
                if (typeof val === "string") {
                    var str = arr.join(", ");
                    return arr === a ? str + val : val + str;
                }
                if (typeof val === "number") {
                    var res = 0;
                    for (var i = 0; i < arr.length; i++) {
                        if (typeof arr[i] === "number") {
                            res = Helpers.correctAfterPlusMinis(res, arr[i], res + arr[i]);
                        }
                    }
                    return Helpers.correctAfterPlusMinis(res, val, res + val);
                }
            }
            return a + b;
        }
        if (typeof a === "string" || typeof b === "string")
            return a + b;
        return Helpers.correctAfterPlusMinis(a, b, a + b);
    };
    Helpers.correctAfterMultiple = function (a, b, res) {
        var digits = Helpers.countDecimals(a) + Helpers.countDecimals(b);
        if (digits > 0) {
            res = parseFloat(res.toFixed(digits));
        }
        return res;
    };
    Helpers.convertArrayValueToObject = function (src, propName, dest) {
        if (dest === void 0) { dest = undefined; }
        var res = new Array();
        if (!src || !Array.isArray(src))
            return res;
        for (var i = 0; i < src.length; i++) {
            var item = void 0;
            if (Array.isArray(dest)) {
                item = Helpers.findObjByPropValue(dest, propName, src[i]);
            }
            if (!item) {
                item = {};
                item[propName] = src[i];
            }
            res.push(item);
        }
        return res;
    };
    Helpers.findObjByPropValue = function (arr, propName, val) {
        for (var i = 0; i < arr.length; i++) {
            if (Helpers.isTwoValueEquals(arr[i][propName], val))
                return arr[i];
        }
        return undefined;
    };
    Helpers.convertArrayObjectToValue = function (src, propName) {
        var res = new Array();
        if (!src || !Array.isArray(src))
            return res;
        for (var i = 0; i < src.length; i++) {
            var itemVal = !!src[i] ? src[i][propName] : undefined;
            if (!Helpers.isValueEmpty(itemVal))
                res.push(itemVal);
        }
        return res;
    };
    Helpers.convertDateToString = function (date) {
        var toStr = function (val) {
            if (val < 10)
                return "0" + val.toString();
            return val.toString();
        };
        return date.getFullYear() + "-" + toStr(date.getMonth() + 1) + "-" + toStr(date.getDate());
    };
    Helpers.convertDateTimeToString = function (date) {
        var toStr = function (val) {
            if (val < 10)
                return "0" + val.toString();
            return val.toString();
        };
        return this.convertDateToString(date) + " " + toStr(date.getHours()) + ":" + toStr(date.getMinutes());
    };
    Helpers.convertValToQuestionVal = function (val, inputType) {
        if (val instanceof Date) {
            if (inputType === "datetime-local")
                return Helpers.convertDateTimeToString(val);
            return Helpers.convertDateToString(val);
        }
        return val;
    };
    Helpers.compareVerions = function (ver1, ver2) {
        if (!ver1 && !ver2)
            return 0;
        var ver1Ar = ver1.split(".");
        var ver2Ar = ver2.split(".");
        var len1 = ver1Ar.length;
        var len2 = ver2Ar.length;
        for (var i = 0; i < len1 && i < len2; i++) {
            var str1 = ver1Ar[i];
            var str2 = ver2Ar[i];
            if (str1.length === str2.length) {
                if (str1 !== str2) {
                    return str1 < str2 ? -1 : 1;
                }
            }
            else {
                return str1.length < str2.length ? -1 : 1;
            }
        }
        return len1 === len2 ? 0 : (len1 < len2 ? -1 : 1);
    };
    return Helpers;
}());

if (!String.prototype["format"]) {
    String.prototype["format"] = function () {
        var args = arguments;
        return this.replace(/{(\d+)}/g, function (match, number) {
            return typeof args[number] != "undefined" ? args[number] : match;
        });
    };
}

// CONCATENATED MODULE: ./packages/survey-core/src/localization/english.ts
// Uncomment the line below if you create a custom dictionary
// import { surveyLocalization } from "survey-core";
var englishStrings = {
    pagePrevText: "Previous",
    pageNextText: "Next",
    completeText: "Complete",
    previewText: "Preview",
    editText: "Edit",
    startSurveyText: "Start",
    otherItemText: "Other (describe)",
    noneItemText: "None",
    refuseItemText: "Refuse to answer",
    dontKnowItemText: "Don't know",
    selectAllItemText: "Select All",
    progressText: "Page {0} of {1}",
    indexText: "{0} of {1}",
    panelDynamicProgressText: "{0} of {1}",
    panelDynamicTabTextFormat: "Panel {panelIndex}",
    questionsProgressText: "Answered {0}/{1} questions",
    emptySurvey: "The survey doesn't contain any visible elements.",
    completingSurvey: "Thank you for completing the survey",
    completingSurveyBefore: "You have already completed this survey.",
    loadingSurvey: "Loading Survey...",
    placeholder: "Select...",
    ratingOptionsCaption: "Select...",
    value: "value",
    requiredError: "Response required.",
    requiredErrorInPanel: "Response required: answer at least one question.",
    requiredInAllRowsError: "Response required: answer questions in all rows.",
    eachRowUniqueError: "Each row must have a unique value.",
    numericError: "The value should be numeric.",
    minError: "The value should not be less than {0}",
    maxError: "The value should not be greater than {0}",
    textMinLength: "Please enter at least {0} character(s).",
    textMaxLength: "Please enter no more than {0} character(s).",
    textMinMaxLength: "Please enter at least {0} and no more than {1} characters.",
    minRowCountError: "Please fill in at least {0} row(s).",
    minSelectError: "Please select at least {0} option(s).",
    maxSelectError: "Please select no more than {0} option(s).",
    numericMinMax: "The '{0}' should be at least {1} and at most {2}",
    numericMin: "The '{0}' should be at least {1}",
    numericMax: "The '{0}' should be at most {1}",
    invalidEmail: "Please enter a valid e-mail address.",
    invalidExpression: "The expression: {0} should return 'true'.",
    urlRequestError: "The request returned error '{0}'. {1}",
    urlGetChoicesError: "The request returned empty data or the 'path' property is incorrect",
    exceedMaxSize: "The file size should not exceed {0}.",
    noUploadFilesHandler: "Files cannot be uploaded. Please add a handler for the 'onUploadFiles' event.",
    otherRequiredError: "Response required: enter another value.",
    uploadingFile: "Your file is uploading. Please wait several seconds and try again.",
    loadingFile: "Loading...",
    chooseFile: "Choose file(s)...",
    noFileChosen: "No file selected",
    filePlaceholder: "Drag and drop a file here or click the button below to select a file to upload.",
    confirmDelete: "Are you sure you want to delete this record?",
    keyDuplicationError: "This value should be unique.",
    addColumn: "Add Column",
    addRow: "Add Row",
    removeRow: "Remove",
    emptyRowsText: "There are no rows.",
    addPanel: "Add new",
    removePanel: "Remove",
    showDetails: "Show Details",
    hideDetails: "Hide Details",
    choices_Item: "item",
    matrix_column: "Column",
    matrix_row: "Row",
    multipletext_itemname: "text",
    savingData: "The results are being saved on the server...",
    savingDataError: "An error occurred and we could not save the results.",
    savingDataSuccess: "The results were saved successfully!",
    savingExceedSize: "Your response exceeds 64KB. Please reduce the size of your file(s) and try again or contact the survey owner.",
    saveAgainButton: "Try again",
    timerMin: "min",
    timerSec: "sec",
    timerSpentAll: "You have spent {0} on this page and {1} in total.",
    timerSpentPage: "You have spent {0} on this page.",
    timerSpentSurvey: "You have spent {0} in total.",
    timerLimitAll: "You have spent {0} of {1} on this page and {2} of {3} in total.",
    timerLimitPage: "You have spent {0} of {1} on this page.",
    timerLimitSurvey: "You have spent {0} of {1} in total.",
    clearCaption: "Clear",
    signaturePlaceHolder: "Sign here",
    signaturePlaceHolderReadOnly: "No signature",
    chooseFileCaption: "Select File",
    takePhotoCaption: "Take Photo",
    photoPlaceholder: "Click the button below to take a photo using the camera.",
    fileOrPhotoPlaceholder: "Drag and drop or select a file to upload or take a photo using the camera.",
    replaceFileCaption: "Replace file",
    removeFileCaption: "Remove this file",
    booleanCheckedLabel: "Yes",
    booleanUncheckedLabel: "No",
    confirmRemoveFile: "Are you sure that you want to remove this file: {0}?",
    confirmRemoveAllFiles: "Are you sure that you want to remove all files?",
    questionTitlePatternText: "Question Title",
    modalCancelButtonText: "Cancel",
    modalApplyButtonText: "Apply",
    filterStringPlaceholder: "Type to search...",
    emptyMessage: "No data to display",
    noEntriesText: "No entries yet.\nClick the button below to add a new entry.",
    noEntriesReadonlyText: "No entries",
    tabTitlePlaceholder: "New Panel",
    more: "More",
    tagboxDoneButtonCaption: "OK",
    selectToRankEmptyRankedAreaText: "All choices are selected for ranking",
    selectToRankEmptyUnrankedAreaText: "Drag choices here to rank them",
    ok: "OK",
    cancel: "Cancel",
};
// Uncomment the lines below if you create a custom dictionary.
// Replace "en" with a custom locale code (for example, "fr" or "de"),
// Replace `englishStrings` with the name of the variable that contains the custom dictionary.
//surveyLocalization.setupLocale("en", englishStrings, "English", "English");

// CONCATENATED MODULE: ./packages/survey-core/src/surveyStrings.ts

var surveyLocalization = {
    currentLocaleValue: "",
    defaultLocaleValue: "en",
    locales: {},
    localeNames: {},
    localeNamesInEnglish: {},
    localeDirections: {},
    supportedLocales: [],
    useEnglishNames: false,
    //TODO remove on next week
    get showNamesInEnglish() { return this.useEnglishNames; },
    set showNamesInEnglish(val) { this.useEnglishNames = val; },
    setupLocale: function (loc, strings, name, nameInEngish, direction) {
        this.locales[loc] = strings;
        this.localeNames[loc] = name;
        this.localeNamesInEnglish[loc] = nameInEngish;
        if (direction !== undefined) {
            this.localeDirections[loc] = direction;
        }
    },
    get currentLocale() {
        return this.currentLocaleValue === this.defaultLocaleValue ? "" : this.currentLocaleValue;
    },
    set currentLocale(val) {
        if (val === "cz")
            val = "cs";
        this.currentLocaleValue = val;
    },
    get defaultLocale() {
        return this.defaultLocaleValue;
    },
    set defaultLocale(val) {
        if (val === "cz")
            val = "cs";
        this.defaultLocaleValue = val;
    },
    getLocaleStrings: function (loc) {
        return this.locales[loc];
    },
    getString: function (strName, locale) {
        var _this = this;
        if (locale === void 0) { locale = null; }
        var locs = new Array();
        var addLocaleCore = function (locName) {
            var strs = _this.locales[locName];
            if (!!strs)
                locs.push(strs);
        };
        var addLocale = function (locName) {
            if (!locName)
                return;
            addLocaleCore(locName);
            var index = locName.indexOf("-");
            if (index < 1)
                return;
            locName = locName.substring(0, index);
            addLocaleCore(locName);
        };
        addLocale(locale);
        addLocale(this.currentLocale);
        addLocale(this.defaultLocale);
        if (this.defaultLocale !== "en") {
            addLocaleCore("en");
        }
        for (var i = 0; i < locs.length; i++) {
            var res = locs[i][strName];
            if (res !== undefined)
                return res;
        }
        return this.onGetExternalString(strName, locale);
    },
    getLocaleName: function (loc, inEnglish) {
        if (!loc)
            return "";
        if (inEnglish === undefined)
            inEnglish = this.showNamesInEnglish;
        var firstNames = inEnglish ? this.localeNamesInEnglish : this.localeNames;
        var secondNames = inEnglish ? this.localeNames : this.localeNamesInEnglish;
        return firstNames[loc] || secondNames[loc] || loc;
    },
    getLocales: function (removeDefaultLoc) {
        var _this = this;
        if (removeDefaultLoc === void 0) { removeDefaultLoc = false; }
        var res = [];
        res.push("");
        var locs = this.locales;
        if (this.supportedLocales && this.supportedLocales.length > 0) {
            locs = {};
            for (var i = 0; i < this.supportedLocales.length; i++) {
                locs[this.supportedLocales[i]] = true;
            }
        }
        for (var key in locs) {
            if (removeDefaultLoc && key == this.defaultLocale)
                continue;
            res.push(key);
        }
        var locName = function (loc) {
            return _this.getLocaleName(loc).toLowerCase();
        };
        res.sort(function (a, b) {
            var str1 = locName(a);
            var str2 = locName(b);
            if (str1 === str2)
                return 0;
            return str1 < str2 ? -1 : 1;
        });
        return res;
    },
    onGetExternalString: function (name, locale) { return undefined; }
};
var surveyStrings = englishStrings;
surveyLocalization.locales["en"] = englishStrings;
surveyLocalization.localeNames["en"] = "english";

// CONCATENATED MODULE: ./packages/survey-core/src/jsonobject.ts
var __extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
    for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
        to[j] = from[i];
    return to;
};



function ensureLocString(target, options, key) {
    var locString = target.getLocalizableString(key);
    if (!locString) {
        var defaultStr = void 0;
        if (typeof options.localizable === "object" && options.localizable.defaultStr) {
            defaultStr = options.localizable.defaultStr;
        }
        locString = target.createLocalizableString(key, target, true, defaultStr);
        if (typeof options.localizable === "object" &&
            typeof options.localizable.onGetTextCallback === "function") {
            locString.onGetTextCallback = options.localizable.onGetTextCallback;
        }
    }
}
function getLocStringValue(target, options, key) {
    ensureLocString(target, options, key);
    var res = target.getLocalizableStringText(key);
    if (!!res)
        return res;
    if (typeof options.localizable === "object" && options.localizable.defaultStr) {
        var loc = !!target.getLocale ? target.getLocale() : "";
        return surveyLocalization.getString(options.localizable.defaultStr, loc);
    }
    return "";
}
function jsonobject_property(options) {
    if (options === void 0) { options = {}; }
    // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
    return function (target, key) {
        var processComputedUpdater = function (obj, val) {
            if (!!val && typeof val === "object" && val.type === ComputedUpdater.ComputedUpdaterType) {
                base_Base.startCollectDependencies(function () { return obj[key] = val.updater(); }, obj, key);
                var result = val.updater();
                var dependencies = base_Base.finishCollectDependencies();
                val.setDependencies(dependencies);
                if (obj.dependencies[key]) {
                    obj.dependencies[key].dispose();
                }
                obj.dependencies[key] = val;
                return result;
            }
            return val;
        };
        if (!options || !options.localizable) {
            Object.defineProperty(target, key, {
                get: function () {
                    // const serializationProperty = Serializer.getProperty(target.getType(), key);
                    // if(!!serializationProperty && options.defaultValue !== undefined) {
                    //   ConsoleWarnings.error("remove defaultValue from @property for class " + target.getType() + " property name is " + key);
                    // }
                    var defaultVal = null;
                    if (!!options) {
                        if (typeof options.getDefaultValue === "function") {
                            defaultVal = options.getDefaultValue(this);
                        }
                        if (options.defaultValue !== undefined) {
                            defaultVal = options.defaultValue;
                        }
                    }
                    return this.getPropertyValue(key, defaultVal);
                },
                set: function (val) {
                    var newValue = processComputedUpdater(this, val);
                    var prevValue = this.getPropertyValue(key);
                    this.setPropertyValue(key, newValue);
                    if (!!options && options.onSet) {
                        options.onSet(newValue, this, prevValue);
                    }
                },
            });
        }
        else {
            Object.defineProperty(target, key, {
                get: function () {
                    return getLocStringValue(this, options, key);
                },
                set: function (val) {
                    ensureLocString(this, options, key);
                    var newValue = processComputedUpdater(this, val);
                    this.setLocalizableStringText(key, newValue);
                    if (!!options && options.onSet) {
                        options.onSet(newValue, this);
                    }
                },
            });
            Object.defineProperty(target, typeof options.localizable === "object" && !!options.localizable.name ?
                options.localizable.name : "loc" + key.charAt(0).toUpperCase() + key.slice(1), {
                get: function () {
                    ensureLocString(this, options, key);
                    return this.getLocalizableString(key);
                },
            });
        }
    };
}
function ensureArray(target, options, key) {
    target.ensureArray(key, function (item, index) {
        var handler = !!options ? options.onPush : null;
        handler && handler(item, index, target);
    }, function (item, index) {
        var handler = !!options ? options.onRemove : null;
        handler && handler(item, index, target);
    });
}
function propertyArray(options) {
    return function (target, key) {
        Object.defineProperty(target, key, {
            get: function () {
                ensureArray(this, options, key);
                return this.getPropertyValue(key);
            },
            set: function (val) {
                ensureArray(this, options, key);
                var arr = this.getPropertyValue(key);
                if (val === arr) {
                    return;
                }
                if (arr) {
                    arr.splice.apply(arr, __spreadArray([0, arr.length], (val || [])));
                }
                else {
                    this.setPropertyValue(key, val);
                }
                if (!!options && options.onSet) {
                    options.onSet(val, this);
                }
            },
        });
    };
}
/**
 * Contains information about a property of a survey element (page, panel, questions, and etc).
 * @see addProperty
 * @see removeProperty
 * @see [Add Properties](https://surveyjs.io/Documentation/Survey-Creator#addproperties)
 * @see [Remove Properties](https://surveyjs.io/Documentation/Survey-Creator#removeproperties)
 */
var jsonobject_JsonObjectProperty = /** @class */ (function () {
    function JsonObjectProperty(classInfo, name, isRequired) {
        if (isRequired === void 0) { isRequired = false; }
        this.name = name;
        this.isRequiredValue = false;
        this.isUniqueValue = false;
        this.isSerializable = true;
        this.isLightSerializable = true;
        this.isCustom = false;
        this.isDynamicChoices = false; //TODO obsolete, use dependsOn attribute
        this.isBindable = false;
        this.category = "";
        this.categoryIndex = -1;
        this.visibleIndex = -1;
        this.maxLength = -1;
        this.isArray = false;
        this.classInfoValue = classInfo;
        this.isRequiredValue = isRequired;
        this.idValue = JsonObjectProperty.Index++;
    }
    Object.defineProperty(JsonObjectProperty.prototype, "id", {
        get: function () {
            return this.idValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(JsonObjectProperty.prototype, "classInfo", {
        get: function () {
            return this.classInfoValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(JsonObjectProperty.prototype, "type", {
        get: function () {
            return this.typeValue ? this.typeValue : "string";
        },
        set: function (value) {
            if (value === "itemvalues")
                value = "itemvalue[]";
            if (value === "textitems")
                value = "textitem[]";
            this.typeValue = value;
            if (this.typeValue.indexOf("[]") === this.typeValue.length - 2) {
                this.isArray = true;
                this.className = this.typeValue.substring(0, this.typeValue.length - 2);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(JsonObjectProperty.prototype, "isRequired", {
        get: function () {
            return this.isRequiredValue;
        },
        set: function (val) {
            if (val !== this.isRequired) {
                this.isRequiredValue = val;
                if (!!this.classInfo) {
                    this.classInfo.resetAllProperties();
                }
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(JsonObjectProperty.prototype, "isUnique", {
        get: function () {
            return this.isUniqueValue;
        },
        set: function (val) {
            this.isUniqueValue = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(JsonObjectProperty.prototype, "uniquePropertyName", {
        get: function () {
            return this.uniquePropertyValue;
        },
        set: function (val) {
            this.uniquePropertyValue = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(JsonObjectProperty.prototype, "hasToUseGetValue", {
        get: function () {
            return this.onGetValue || this.serializationProperty;
        },
        enumerable: false,
        configurable: true
    });
    JsonObjectProperty.prototype.getDefaultValue = function (obj) {
        var result = !!this.defaultValueFunc ? this.defaultValueFunc(obj) : this.defaultValueValue;
        if (!!JsonObjectProperty.getItemValuesDefaultValue &&
            Serializer.isDescendantOf(this.className, "itemvalue")) {
            result = JsonObjectProperty.getItemValuesDefaultValue(this.defaultValueValue || [], this.className);
        }
        return result;
    };
    Object.defineProperty(JsonObjectProperty.prototype, "defaultValue", {
        get: function () {
            return this.getDefaultValue(undefined);
        },
        set: function (newValue) {
            this.defaultValueValue = newValue;
        },
        enumerable: false,
        configurable: true
    });
    JsonObjectProperty.prototype.isDefaultValue = function (value) {
        return this.isDefaultValueByObj(undefined, value);
    };
    JsonObjectProperty.prototype.isDefaultValueByObj = function (obj, value) {
        var dValue = this.getDefaultValue(obj);
        if (!helpers_Helpers.isValueEmpty(dValue)) {
            return helpers_Helpers.isTwoValueEquals(value, dValue, false, true, false);
        }
        if (this.isLocalizable)
            return value === null || value === undefined;
        return ((value === false && (this.type == "boolean" || this.type == "switch") && !this.defaultValueFunc) ||
            value === "" || helpers_Helpers.isValueEmpty(value));
    };
    JsonObjectProperty.prototype.getSerializableValue = function (obj) {
        if (!!this.onSerializeValue)
            return this.onSerializeValue(obj);
        return this.getValue(obj);
    };
    JsonObjectProperty.prototype.getValue = function (obj) {
        if (this.onGetValue)
            return this.onGetValue(obj);
        if (this.serializationProperty && !!obj[this.serializationProperty])
            return obj[this.serializationProperty].getJson();
        return obj[this.name];
    };
    JsonObjectProperty.prototype.getPropertyValue = function (obj) {
        if (this.isLocalizable) {
            return !!obj[this.serializationProperty]
                ? obj[this.serializationProperty].text
                : null;
        }
        return this.getValue(obj);
    };
    Object.defineProperty(JsonObjectProperty.prototype, "hasToUseSetValue", {
        get: function () {
            return this.onSetValue || this.serializationProperty;
        },
        enumerable: false,
        configurable: true
    });
    JsonObjectProperty.prototype.settingValue = function (obj, value) {
        if (!this.onSettingValue || obj.isLoadingFromJson)
            return value;
        return this.onSettingValue(obj, value);
    };
    JsonObjectProperty.prototype.setValue = function (obj, value, jsonConv) {
        if (this.onSetValue) {
            this.onSetValue(obj, value, jsonConv);
        }
        else {
            if (this.serializationProperty && !!obj[this.serializationProperty])
                obj[this.serializationProperty].setJson(value);
            else {
                if (value && typeof value === "string") {
                    if (this.type == "number") {
                        value = parseInt(value);
                    }
                    if (this.type == "boolean" || this.type == "switch") {
                        value = value.toLowerCase() === "true";
                    }
                }
                obj[this.name] = value;
            }
        }
    };
    JsonObjectProperty.prototype.validateValue = function (value) {
        var choices = this.choices;
        if (!Array.isArray(choices) || choices.length === 0)
            return true;
        return choices.indexOf(value) > -1;
    };
    JsonObjectProperty.prototype.getObjType = function (objType) {
        if (!this.classNamePart)
            return objType;
        return objType.replace(this.classNamePart, "");
    };
    Object.defineProperty(JsonObjectProperty.prototype, "choices", {
        /**
         * Depricated, please use getChoices
         */
        get: function () {
            return this.getChoices(null);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(JsonObjectProperty.prototype, "hasChoices", {
        get: function () {
            return !!this.choicesValue || !!this.choicesfunc;
        },
        enumerable: false,
        configurable: true
    });
    JsonObjectProperty.prototype.getChoices = function (obj, choicesCallback) {
        if (choicesCallback === void 0) { choicesCallback = null; }
        if (this.choicesValue != null)
            return this.choicesValue;
        if (this.choicesfunc != null)
            return this.choicesfunc(obj, choicesCallback);
        return null;
    };
    JsonObjectProperty.prototype.setChoices = function (value, valueFunc) {
        if (valueFunc === void 0) { valueFunc = null; }
        this.choicesValue = value;
        this.choicesfunc = valueFunc;
    };
    JsonObjectProperty.prototype.getBaseValue = function () {
        if (!this.baseValue)
            return "";
        if (typeof this.baseValue == "function")
            return this.baseValue();
        return this.baseValue;
    };
    JsonObjectProperty.prototype.setBaseValue = function (val) {
        this.baseValue = val;
    };
    Object.defineProperty(JsonObjectProperty.prototype, "readOnly", {
        get: function () {
            return this.readOnlyValue != null ? this.readOnlyValue : false;
        },
        set: function (val) {
            this.readOnlyValue = val;
        },
        enumerable: false,
        configurable: true
    });
    JsonObjectProperty.prototype.isEnable = function (obj) {
        if (this.readOnly)
            return false;
        if (!obj || !this.enableIf)
            return true;
        return this.enableIf(this.getOriginalObj(obj));
    };
    JsonObjectProperty.prototype.isVisible = function (layout, obj) {
        if (obj === void 0) { obj = null; }
        var isLayout = !this.layout || this.layout == layout;
        if (!this.visible || !isLayout)
            return false;
        if (!!this.visibleIf && !!obj) {
            return this.visibleIf(this.getOriginalObj(obj));
        }
        return true;
    };
    JsonObjectProperty.prototype.getOriginalObj = function (obj) {
        if (obj && obj.getOriginalObj) {
            var orjObj = obj.getOriginalObj();
            if (orjObj && Serializer.findProperty(orjObj.getType(), this.name)) {
                return orjObj;
            }
        }
        return obj;
    };
    Object.defineProperty(JsonObjectProperty.prototype, "visible", {
        get: function () {
            return this.visibleValue != null ? this.visibleValue : true;
        },
        set: function (val) {
            this.visibleValue = val;
        },
        enumerable: false,
        configurable: true
    });
    JsonObjectProperty.prototype.isAvailableInVersion = function (ver) {
        if (!!this.alternativeName || this.oldName)
            return true;
        return this.isAvailableInVersionCore(ver);
    };
    JsonObjectProperty.prototype.getSerializedName = function (ver) {
        if (!this.alternativeName)
            return this.name;
        return this.isAvailableInVersionCore(ver) ? this.name : this.alternativeName || this.oldName;
    };
    JsonObjectProperty.prototype.getSerializedProperty = function (obj, ver) {
        if (!this.oldName || this.isAvailableInVersionCore(ver))
            return this;
        if (!obj || !obj.getType)
            return null;
        return Serializer.findProperty(obj.getType(), this.oldName);
    };
    JsonObjectProperty.prototype.isAvailableInVersionCore = function (ver) {
        if (!ver || !this.version)
            return true;
        return helpers_Helpers.compareVerions(this.version, ver) <= 0;
    };
    Object.defineProperty(JsonObjectProperty.prototype, "isLocalizable", {
        get: function () {
            return this.isLocalizableValue != null ? this.isLocalizableValue : false;
        },
        set: function (val) {
            this.isLocalizableValue = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(JsonObjectProperty.prototype, "dataList", {
        get: function () {
            return Array.isArray(this.dataListValue) ? this.dataListValue : [];
        },
        set: function (val) {
            this.dataListValue = val;
        },
        enumerable: false,
        configurable: true
    });
    JsonObjectProperty.prototype.mergeWith = function (prop) {
        var valuesNames = JsonObjectProperty.mergableValues;
        for (var i = 0; i < valuesNames.length; i++) {
            this.mergeValue(prop, valuesNames[i]);
        }
    };
    JsonObjectProperty.prototype.addDependedProperty = function (name) {
        if (!this.dependedProperties) {
            this.dependedProperties = [];
        }
        if (this.dependedProperties.indexOf(name) < 0) {
            this.dependedProperties.push(name);
        }
    };
    JsonObjectProperty.prototype.getDependedProperties = function () {
        return !!this.dependedProperties ? this.dependedProperties : [];
    };
    JsonObjectProperty.prototype.schemaType = function () {
        if (this.className === "choicesByUrl")
            return undefined;
        if (this.className === "string")
            return this.className;
        if (!!this.className)
            return "array";
        if (!!this.baseClassName)
            return "array";
        if (this.type == "switch")
            return "boolean";
        if (this.type == "boolean" || this.type == "number")
            return this.type;
        return "string";
    };
    JsonObjectProperty.prototype.schemaRef = function () {
        if (!!this.className)
            return this.className;
        return undefined;
    };
    JsonObjectProperty.prototype.mergeValue = function (prop, valueName) {
        if (this[valueName] == null && prop[valueName] != null) {
            this[valueName] = prop[valueName];
        }
    };
    JsonObjectProperty.Index = 1;
    JsonObjectProperty.mergableValues = [
        "typeValue",
        "choicesValue",
        "baseValue",
        "readOnlyValue",
        "visibleValue",
        "isSerializable",
        "isLightSerializable",
        "isCustom",
        "isBindable",
        "isUnique",
        "uniquePropertyName",
        "isDynamicChoices",
        "isLocalizableValue",
        "className",
        "alternativeName",
        "oldName",
        "layout",
        "version",
        "classNamePart",
        "baseClassName",
        "defaultValue",
        "defaultValueFunc",
        "serializationProperty",
        "onGetValue",
        "onSetValue",
        "onSettingValue",
        "displayName",
        "category",
        "categoryIndex",
        "visibleIndex",
        "nextToProperty",
        "overridingProperty",
        "showMode",
        "dependedProperties",
        "visibleIf",
        "enableIf",
        "onExecuteExpression",
        "onPropertyEditorUpdate",
        "maxLength",
        "maxValue",
        "minValue",
        "dataListValue",
    ];
    return JsonObjectProperty;
}());

var CustomPropertiesCollection = /** @class */ (function () {
    function CustomPropertiesCollection() {
    }
    CustomPropertiesCollection.addProperty = function (className, property) {
        className = className.toLowerCase();
        var props = CustomPropertiesCollection.properties;
        if (!props[className]) {
            props[className] = [];
        }
        props[className].push(property);
    };
    CustomPropertiesCollection.removeProperty = function (className, propertyName) {
        className = className.toLowerCase();
        var props = CustomPropertiesCollection.properties;
        if (!props[className])
            return;
        var properties = props[className];
        for (var i = 0; i < properties.length; i++) {
            if (properties[i].name == propertyName) {
                props[className].splice(i, 1);
                break;
            }
        }
    };
    CustomPropertiesCollection.removeAllProperties = function (className) {
        className = className.toLowerCase();
        delete CustomPropertiesCollection.properties[className];
    };
    CustomPropertiesCollection.addClass = function (className, parentClassName) {
        className = className.toLowerCase();
        if (parentClassName) {
            parentClassName = parentClassName.toLowerCase();
        }
        CustomPropertiesCollection.parentClasses[className] = parentClassName;
    };
    CustomPropertiesCollection.getProperties = function (className) {
        className = className.toLowerCase();
        var res = [];
        var props = CustomPropertiesCollection.properties;
        while (className) {
            var properties = props[className];
            if (properties) {
                for (var i = 0; i < properties.length; i++) {
                    res.push(properties[i]);
                }
            }
            className = CustomPropertiesCollection.parentClasses[className];
        }
        return res;
    };
    CustomPropertiesCollection.createProperties = function (obj) {
        if (!obj || !obj.getType)
            return;
        CustomPropertiesCollection.createPropertiesCore(obj, obj.getType());
    };
    CustomPropertiesCollection.createPropertiesCore = function (obj, className) {
        var props = CustomPropertiesCollection.properties;
        if (props[className]) {
            CustomPropertiesCollection.createPropertiesInObj(obj, props[className]);
        }
        var parentClass = CustomPropertiesCollection.parentClasses[className];
        if (parentClass) {
            CustomPropertiesCollection.createPropertiesCore(obj, parentClass);
        }
    };
    CustomPropertiesCollection.createPropertiesInObj = function (obj, properties) {
        for (var i = 0; i < properties.length; i++) {
            CustomPropertiesCollection.createPropertyInObj(obj, properties[i]);
        }
    };
    CustomPropertiesCollection.createPropertyInObj = function (obj, prop) {
        if (CustomPropertiesCollection.checkIsPropertyExists(obj, prop.name))
            return;
        if (!!prop.serializationProperty && CustomPropertiesCollection.checkIsPropertyExists(obj, prop.serializationProperty))
            return;
        if (prop.isLocalizable &&
            prop.serializationProperty &&
            obj.createCustomLocalizableObj) {
            var locStr = obj.createCustomLocalizableObj(prop.name);
            locStr.defaultValue = prop.defaultValue;
            var locDesc = {
                get: function () {
                    return obj.getLocalizableString(prop.name);
                },
            };
            Object.defineProperty(obj, prop.serializationProperty, locDesc);
            var desc = {
                get: function () {
                    return obj.getLocalizableStringText(prop.name);
                },
                set: function (v) {
                    obj.setLocalizableStringText(prop.name, v);
                },
            };
            Object.defineProperty(obj, prop.name, desc);
        }
        else {
            var defaultValue = prop.defaultValue;
            var isArrayProp = prop.isArray || prop.type === "multiplevalues";
            if (typeof obj.createNewArray === "function") {
                if (Serializer.isDescendantOf(prop.className, "itemvalue")) {
                    obj.createNewArray(prop.name, function (item) {
                        item.locOwner = obj;
                        item.ownerPropertyName = prop.name;
                    });
                    isArrayProp = true;
                }
                else {
                    //It is a simple array property
                    if (isArrayProp) {
                        obj.createNewArray(prop.name);
                    }
                }
                if (isArrayProp) {
                    if (Array.isArray(defaultValue)) {
                        obj.setPropertyValue(prop.name, defaultValue);
                    }
                    defaultValue = null;
                }
            }
            if (!!obj.getPropertyValue && !!obj.setPropertyValue) {
                var desc = {
                    get: function () {
                        if (!!prop.onGetValue) {
                            return prop.onGetValue(obj);
                        }
                        return obj.getPropertyValue(prop.name, defaultValue);
                    },
                    set: function (v) {
                        if (!!prop.onSetValue) {
                            prop.onSetValue(obj, v, null);
                        }
                        else {
                            obj.setPropertyValue(prop.name, v);
                        }
                    },
                };
                Object.defineProperty(obj, prop.name, desc);
            }
        }
        if (prop.type === "condition" || prop.type === "expression") {
            if (!!prop.onExecuteExpression) {
                obj.addExpressionProperty(prop.name, prop.onExecuteExpression);
            }
        }
    };
    CustomPropertiesCollection.checkIsPropertyExists = function (obj, name) {
        return obj.hasOwnProperty(name) || obj[name];
    };
    CustomPropertiesCollection.properties = {};
    CustomPropertiesCollection.parentClasses = {};
    return CustomPropertiesCollection;
}());

var jsonobject_JsonMetadataClass = /** @class */ (function () {
    function JsonMetadataClass(name, properties, creator, parentName) {
        if (creator === void 0) { creator = null; }
        if (parentName === void 0) { parentName = null; }
        this.name = name;
        this.creator = creator;
        this.parentName = parentName;
        name = name.toLowerCase();
        this.isCustomValue = !creator && name !== "survey";
        if (this.parentName) {
            this.parentName = this.parentName.toLowerCase();
            CustomPropertiesCollection.addClass(name, this.parentName);
            if (!!creator) {
                this.makeParentRegularClass();
            }
        }
        this.properties = new Array();
        for (var i = 0; i < properties.length; i++) {
            this.createProperty(properties[i], this.isCustom);
        }
    }
    //Obsolete
    JsonMetadataClass.prototype.find = function (name) {
        for (var i = 0; i < this.properties.length; i++) {
            if (this.properties[i].name == name)
                return this.properties[i];
        }
        return null;
    };
    JsonMetadataClass.prototype.findProperty = function (name) {
        this.fillAllProperties();
        return this.hashProperties[name];
    };
    JsonMetadataClass.prototype.getAllProperties = function () {
        this.fillAllProperties();
        return this.allProperties;
    };
    JsonMetadataClass.prototype.getRequiredProperties = function () {
        if (!!this.requiredProperties)
            return this.requiredProperties;
        this.requiredProperties = [];
        var props = this.getAllProperties();
        for (var i = 0; i < props.length; i++) {
            if (props[i].isRequired)
                this.requiredProperties.push(props[i]);
        }
        return this.requiredProperties;
    };
    JsonMetadataClass.prototype.resetAllProperties = function () {
        this.allProperties = undefined;
        this.requiredProperties = undefined;
        this.hashProperties = undefined;
        var childClasses = Serializer.getChildrenClasses(this.name);
        for (var i = 0; i < childClasses.length; i++) {
            childClasses[i].resetAllProperties();
        }
    };
    Object.defineProperty(JsonMetadataClass.prototype, "isCustom", {
        get: function () { return this.isCustomValue; },
        enumerable: false,
        configurable: true
    });
    JsonMetadataClass.prototype.fillAllProperties = function () {
        var _this = this;
        if (!!this.allProperties)
            return;
        this.allProperties = [];
        this.hashProperties = {};
        var localProperties = {};
        this.properties.forEach(function (prop) { return localProperties[prop.name] = prop; });
        var parentClass = !!this.parentName ? Serializer.findClass(this.parentName) : null;
        if (!!parentClass) {
            var parentProperties = parentClass.getAllProperties();
            parentProperties.forEach(function (prop) {
                var overridedProp = localProperties[prop.name];
                if (!!overridedProp) {
                    overridedProp.mergeWith(prop);
                    _this.addPropCore(overridedProp);
                }
                else {
                    _this.addPropCore(prop);
                }
            });
        }
        this.properties.forEach(function (prop) {
            if (!_this.hashProperties[prop.name]) {
                _this.addPropCore(prop);
            }
        });
    };
    JsonMetadataClass.prototype.addPropCore = function (prop) {
        this.allProperties.push(prop);
        this.hashProperties[prop.name] = prop;
        if (!!prop.alternativeName) {
            this.hashProperties[prop.alternativeName] = prop;
        }
    };
    JsonMetadataClass.prototype.isOverridedProp = function (propName) {
        return !!this.parentName && !!Serializer.findProperty(this.parentName, propName);
    };
    JsonMetadataClass.prototype.hasRegularChildClass = function () {
        if (!this.isCustom)
            return;
        this.isCustomValue = false;
        for (var i = 0; i < this.properties.length; i++) {
            this.properties[i].isCustom = false;
        }
        CustomPropertiesCollection.removeAllProperties(this.name);
        this.makeParentRegularClass();
    };
    JsonMetadataClass.prototype.makeParentRegularClass = function () {
        if (!this.parentName)
            return;
        var parent = Serializer.findClass(this.parentName);
        if (!!parent) {
            parent.hasRegularChildClass();
        }
    };
    JsonMetadataClass.prototype.createProperty = function (propInfo, isCustom) {
        if (isCustom === void 0) { isCustom = false; }
        var propertyName = typeof propInfo === "string" ? propInfo : propInfo.name;
        if (!propertyName)
            return;
        var propertyType = null;
        var typeIndex = propertyName.indexOf(JsonMetadataClass.typeSymbol);
        if (typeIndex > -1) {
            propertyType = propertyName.substring(typeIndex + 1);
            propertyName = propertyName.substring(0, typeIndex);
        }
        var isRequired = this.getIsPropertyNameRequired(propertyName) || !!propInfo.isRequired;
        propertyName = this.getPropertyName(propertyName);
        var prop = new jsonobject_JsonObjectProperty(this, propertyName, isRequired);
        if (propertyType) {
            prop.type = propertyType;
        }
        if (typeof propInfo === "object") {
            if (propInfo.type) {
                prop.type = propInfo.type;
            }
            if (propInfo.default !== undefined) {
                prop.defaultValue = propInfo.default;
            }
            if (propInfo.defaultFunc !== undefined) {
                prop.defaultValueFunc = propInfo.defaultFunc;
            }
            if (!helpers_Helpers.isValueEmpty(propInfo.isSerializable)) {
                prop.isSerializable = propInfo.isSerializable;
            }
            if (!helpers_Helpers.isValueEmpty(propInfo.isLightSerializable)) {
                prop.isLightSerializable = propInfo.isLightSerializable;
            }
            if (!helpers_Helpers.isValueEmpty(propInfo.maxLength)) {
                prop.maxLength = propInfo.maxLength;
            }
            if (propInfo.displayName !== undefined) {
                prop.displayName = propInfo.displayName;
            }
            if (!helpers_Helpers.isValueEmpty(propInfo.category)) {
                prop.category = propInfo.category;
            }
            if (!helpers_Helpers.isValueEmpty(propInfo.categoryIndex)) {
                prop.categoryIndex = propInfo.categoryIndex;
            }
            if (!helpers_Helpers.isValueEmpty(propInfo.nextToProperty)) {
                prop.nextToProperty = propInfo.nextToProperty;
            }
            if (!helpers_Helpers.isValueEmpty(propInfo.overridingProperty)) {
                prop.overridingProperty = propInfo.overridingProperty;
            }
            if (!helpers_Helpers.isValueEmpty(propInfo.visibleIndex)) {
                prop.visibleIndex = propInfo.visibleIndex;
            }
            if (!helpers_Helpers.isValueEmpty(propInfo.showMode)) {
                prop.showMode = propInfo.showMode;
            }
            if (!helpers_Helpers.isValueEmpty(propInfo.maxValue)) {
                prop.maxValue = propInfo.maxValue;
            }
            if (!helpers_Helpers.isValueEmpty(propInfo.minValue)) {
                prop.minValue = propInfo.minValue;
            }
            if (!helpers_Helpers.isValueEmpty(propInfo.dataList)) {
                prop.dataList = propInfo.dataList;
            }
            if (!helpers_Helpers.isValueEmpty(propInfo.isDynamicChoices)) {
                prop.isDynamicChoices = propInfo.isDynamicChoices;
            }
            if (!helpers_Helpers.isValueEmpty(propInfo.isBindable)) {
                prop.isBindable = propInfo.isBindable;
            }
            if (!helpers_Helpers.isValueEmpty(propInfo.isUnique)) {
                prop.isUnique = propInfo.isUnique;
            }
            if (!helpers_Helpers.isValueEmpty(propInfo.uniqueProperty)) {
                prop.uniquePropertyName = propInfo.uniqueProperty;
            }
            if (!helpers_Helpers.isValueEmpty(propInfo.isArray)) {
                prop.isArray = propInfo.isArray;
            }
            if (propInfo.visible === true || propInfo.visible === false) {
                prop.visible = propInfo.visible;
            }
            if (!!propInfo.visibleIf) {
                prop.visibleIf = propInfo.visibleIf;
            }
            if (!!propInfo.enableIf) {
                prop.enableIf = propInfo.enableIf;
            }
            if (!!propInfo.onExecuteExpression) {
                prop.onExecuteExpression = propInfo.onExecuteExpression;
            }
            if (!!propInfo.onPropertyEditorUpdate) {
                prop.onPropertyEditorUpdate = propInfo.onPropertyEditorUpdate;
            }
            if (propInfo.readOnly === true) {
                prop.readOnly = true;
            }
            if (propInfo.choices) {
                var choicesFunc = typeof propInfo.choices === "function" ? propInfo.choices : null;
                var choicesValue = typeof propInfo.choices !== "function" ? propInfo.choices : null;
                prop.setChoices(choicesValue, choicesFunc);
            }
            if (!!propInfo.baseValue) {
                prop.setBaseValue(propInfo.baseValue);
            }
            if (propInfo.onSerializeValue) {
                prop.onSerializeValue = propInfo.onSerializeValue;
            }
            if (propInfo.onGetValue) {
                prop.onGetValue = propInfo.onGetValue;
            }
            if (propInfo.onSetValue) {
                prop.onSetValue = propInfo.onSetValue;
            }
            if (propInfo.onSettingValue) {
                prop.onSettingValue = propInfo.onSettingValue;
            }
            if (propInfo.isLocalizable) {
                propInfo.serializationProperty = "loc" + prop.name;
            }
            if (propInfo.serializationProperty) {
                prop.serializationProperty = propInfo.serializationProperty;
                var s;
                if (prop.serializationProperty &&
                    prop.serializationProperty.indexOf("loc") == 0) {
                    prop.isLocalizable = true;
                }
            }
            if (propInfo.isLocalizable) {
                prop.isLocalizable = propInfo.isLocalizable;
            }
            if (propInfo.className) {
                prop.className = propInfo.className;
            }
            if (propInfo.baseClassName) {
                prop.baseClassName = propInfo.baseClassName;
                prop.isArray = true;
            }
            if (prop.isArray === true) {
                prop.isArray = true;
            }
            if (propInfo.classNamePart) {
                prop.classNamePart = propInfo.classNamePart;
            }
            if (propInfo.alternativeName) {
                prop.alternativeName = propInfo.alternativeName;
            }
            if (propInfo.oldName) {
                prop.oldName = propInfo.oldName;
            }
            if (propInfo.layout) {
                prop.layout = propInfo.layout;
            }
            if (propInfo.version) {
                prop.version = propInfo.version;
            }
            if (propInfo.dependsOn) {
                this.addDependsOnProperties(prop, propInfo.dependsOn);
            }
        }
        this.properties.push(prop);
        if (isCustom && !this.isOverridedProp(prop.name)) {
            prop.isCustom = true;
            CustomPropertiesCollection.addProperty(this.name, prop);
        }
        return prop;
    };
    JsonMetadataClass.prototype.addDependsOnProperties = function (prop, dependsOn) {
        var dArray = Array.isArray(dependsOn) ? dependsOn : [dependsOn];
        prop.dependsOn = dArray;
        for (var i = 0; i < dArray.length; i++) {
            this.addDependsOnProperty(prop, dArray[i]);
        }
    };
    JsonMetadataClass.prototype.addDependsOnProperty = function (prop, dependsOn) {
        var property = this.find(dependsOn);
        if (!property) {
            property = Serializer.findProperty(this.parentName, dependsOn);
        }
        if (!property)
            return;
        property.addDependedProperty(prop.name);
    };
    JsonMetadataClass.prototype.getIsPropertyNameRequired = function (propertyName) {
        return (propertyName.length > 0 &&
            propertyName[0] == JsonMetadataClass.requiredSymbol);
    };
    JsonMetadataClass.prototype.getPropertyName = function (propertyName) {
        if (!this.getIsPropertyNameRequired(propertyName))
            return propertyName;
        propertyName = propertyName.slice(1);
        return propertyName;
    };
    JsonMetadataClass.requiredSymbol = "!";
    JsonMetadataClass.typeSymbol = ":";
    return JsonMetadataClass;
}());

/**
 * The metadata object. It contains object properties' runtime information and allows you to modify it.
 */
var JsonMetadata = /** @class */ (function () {
    function JsonMetadata() {
        this.classes = {};
        this.alternativeNames = {};
        this.childrenClasses = {};
        this.dynamicPropsCache = {};
    }
    JsonMetadata.prototype.getObjPropertyValue = function (obj, name) {
        if (this.isObjWrapper(obj) && this.isNeedUseObjWrapper(obj, name)) {
            var orignalObj = obj.getOriginalObj();
            var prop_1 = Serializer.findProperty(orignalObj.getType(), name);
            if (!!prop_1)
                return this.getObjPropertyValueCore(orignalObj, prop_1);
        }
        var prop = Serializer.findProperty(obj.getType(), name);
        if (!prop)
            return obj[name];
        return this.getObjPropertyValueCore(obj, prop);
    };
    JsonMetadata.prototype.setObjPropertyValue = function (obj, name, val) {
        if (obj[name] === val)
            return;
        if (!!obj[name] && !!obj[name].setJson) {
            obj[name].setJson(val);
        }
        else {
            if (Array.isArray(val)) {
                var newVal = [];
                for (var i = 0; i < val.length; i++)
                    newVal.push(val[i]);
                val = newVal;
            }
            obj[name] = val;
        }
    };
    JsonMetadata.prototype.getObjPropertyValueCore = function (obj, prop) {
        if (!prop.isSerializable)
            return obj[prop.name];
        if (prop.isLocalizable) {
            if (prop.isArray)
                return obj[prop.name];
            if (!!prop.serializationProperty)
                return obj[prop.serializationProperty].text;
        }
        return obj.getPropertyValue(prop.name);
    };
    JsonMetadata.prototype.isObjWrapper = function (obj) {
        return !!obj.getOriginalObj && !!obj.getOriginalObj();
    };
    JsonMetadata.prototype.isNeedUseObjWrapper = function (obj, name) {
        if (!obj.getDynamicProperties)
            return true;
        var props = obj.getDynamicProperties();
        if (!Array.isArray(props))
            return false;
        for (var i = 0; i < props.length; i++) {
            if (props[i].name === name)
                return true;
        }
        return false;
    };
    JsonMetadata.prototype.addClass = function (name, properties, creator, parentName) {
        if (creator === void 0) { creator = null; }
        if (parentName === void 0) { parentName = null; }
        name = name.toLowerCase();
        var metaDataClass = new jsonobject_JsonMetadataClass(name, properties, creator, parentName);
        this.classes[name] = metaDataClass;
        if (parentName) {
            parentName = parentName.toLowerCase();
            var children = this.childrenClasses[parentName];
            if (!children) {
                this.childrenClasses[parentName] = [];
            }
            this.childrenClasses[parentName].push(metaDataClass);
        }
        return metaDataClass;
    };
    JsonMetadata.prototype.removeClass = function (name) {
        var metaClass = this.findClass(name);
        if (!metaClass)
            return;
        delete this.classes[metaClass.name];
        if (!!metaClass.parentName) {
            var index = this.childrenClasses[metaClass.parentName].indexOf(metaClass);
            if (index > -1) {
                this.childrenClasses[metaClass.parentName].splice(index, 1);
            }
        }
    };
    JsonMetadata.prototype.overrideClassCreatore = function (name, creator) {
        this.overrideClassCreator(name, creator);
    };
    JsonMetadata.prototype.overrideClassCreator = function (name, creator) {
        name = name.toLowerCase();
        var metaDataClass = this.findClass(name);
        if (metaDataClass) {
            metaDataClass.creator = creator;
        }
    };
    JsonMetadata.prototype.getProperties = function (className) {
        var metaClass = this.findClass(className);
        if (!metaClass)
            return [];
        return metaClass.getAllProperties();
    };
    JsonMetadata.prototype.getPropertiesByObj = function (obj) {
        var type = !!obj && !!obj.getType ? obj.getType() : undefined;
        if (!type)
            return [];
        var props = this.getProperties(type);
        var dynamicProps = this.getDynamicPropertiesByObj(obj);
        for (var i = dynamicProps.length - 1; i >= 0; i--) {
            if (this.findProperty(type, dynamicProps[i].name)) {
                dynamicProps.splice(i, 1);
            }
        }
        if (dynamicProps.length === 0)
            return props;
        return [].concat(props).concat(dynamicProps);
    };
    JsonMetadata.prototype.addDynamicPropertiesIntoObj = function (dest, src, props) {
        var _this = this;
        props.forEach(function (prop) {
            _this.addDynamicPropertyIntoObj(dest, src, prop.name, false);
            if (prop.serializationProperty) {
                _this.addDynamicPropertyIntoObj(dest, src, prop.serializationProperty, true);
            }
            if (prop.alternativeName) {
                _this.addDynamicPropertyIntoObj(dest, src, prop.alternativeName, false);
            }
        });
    };
    JsonMetadata.prototype.addDynamicPropertyIntoObj = function (dest, src, propName, isReadOnly) {
        var desc = {
            configurable: true,
            get: function () {
                return src[propName];
            },
        };
        if (!isReadOnly) {
            desc["set"] = function (v) {
                src[propName] = v;
            };
        }
        Object.defineProperty(dest, propName, desc);
    };
    JsonMetadata.prototype.getDynamicPropertiesByObj = function (obj, dynamicType) {
        if (dynamicType === void 0) { dynamicType = null; }
        if (!obj || !obj.getType)
            return [];
        if (!!obj.getDynamicProperties)
            return obj.getDynamicProperties();
        if (!obj.getDynamicType && !dynamicType)
            return [];
        var dType = !!dynamicType ? dynamicType : obj.getDynamicType();
        return this.getDynamicPropertiesByTypes(obj.getType(), dType);
    };
    JsonMetadata.prototype.getDynamicPropertiesByTypes = function (objType, dynamicType, invalidNames) {
        if (!dynamicType)
            return [];
        var cacheType = dynamicType + "-" + objType;
        if (this.dynamicPropsCache[cacheType])
            return this.dynamicPropsCache[cacheType];
        var dynamicProps = this.getProperties(dynamicType);
        if (!dynamicProps || dynamicProps.length == 0)
            return [];
        var hash = {};
        var props = this.getProperties(objType);
        for (var i = 0; i < props.length; i++) {
            hash[props[i].name] = props[i];
        }
        var res = [];
        if (!invalidNames)
            invalidNames = [];
        for (var i_1 = 0; i_1 < dynamicProps.length; i_1++) {
            var dProp = dynamicProps[i_1];
            if (!hash[dProp.name] && invalidNames.indexOf(dProp.name) < 0) {
                res.push(dProp);
            }
        }
        this.dynamicPropsCache[cacheType] = res;
        return res;
    };
    JsonMetadata.prototype.hasOriginalProperty = function (obj, propName) {
        return !!this.getOriginalProperty(obj, propName);
    };
    JsonMetadata.prototype.getOriginalProperty = function (obj, propName) {
        var res = this.findProperty(obj.getType(), propName);
        if (!!res)
            return res;
        if (this.isObjWrapper(obj))
            return this.findProperty(obj.getOriginalObj().getType(), propName);
        return null;
    };
    JsonMetadata.prototype.getProperty = function (className, propertyName) {
        var prop = this.findProperty(className, propertyName);
        if (!prop)
            return prop;
        var classInfo = this.findClass(className);
        if (prop.classInfo === classInfo)
            return prop;
        var newProp = new jsonobject_JsonObjectProperty(classInfo, prop.name, prop.isRequired);
        newProp.mergeWith(prop);
        newProp.isArray = prop.isArray;
        classInfo.properties.push(newProp);
        classInfo.resetAllProperties();
        return newProp;
    };
    JsonMetadata.prototype.findProperty = function (className, propertyName) {
        var cl = this.findClass(className);
        return !!cl ? cl.findProperty(propertyName) : null;
    };
    JsonMetadata.prototype.findProperties = function (className, propertyNames) {
        var result = new Array();
        var cl = this.findClass(className);
        if (!cl)
            return result;
        for (var i = 0; i < propertyNames.length; i++) {
            var prop = cl.findProperty(propertyNames[i]);
            if (prop) {
                result.push(prop);
            }
        }
        return result;
    };
    JsonMetadata.prototype.getAllPropertiesByName = function (propertyName) {
        var res = new Array();
        var classes = this.getAllClasses();
        for (var i = 0; i < classes.length; i++) {
            var classInfo = this.findClass(classes[i]);
            for (var j = 0; j < classInfo.properties.length; j++) {
                if (classInfo.properties[j].name == propertyName) {
                    res.push(classInfo.properties[j]);
                    break;
                }
            }
        }
        return res;
    };
    JsonMetadata.prototype.getAllClasses = function () {
        var res = new Array();
        for (var name in this.classes) {
            res.push(name);
        }
        return res;
    };
    JsonMetadata.prototype.createClass = function (name, json) {
        if (json === void 0) { json = undefined; }
        name = name.toLowerCase();
        var metaDataClass = this.findClass(name);
        if (!metaDataClass)
            return null;
        if (metaDataClass.creator)
            return metaDataClass.creator(json);
        var parentName = metaDataClass.parentName;
        while (parentName) {
            metaDataClass = this.findClass(parentName);
            if (!metaDataClass)
                return null;
            parentName = metaDataClass.parentName;
            if (metaDataClass.creator)
                return this.createCustomType(name, metaDataClass.creator, json);
        }
        return null;
    };
    JsonMetadata.prototype.createCustomType = function (name, creator, json) {
        if (json === void 0) { json = undefined; }
        name = name.toLowerCase();
        var res = creator(json);
        var customTypeName = name;
        var customTemplateName = res.getTemplate
            ? res.getTemplate()
            : res.getType();
        res.getType = function () {
            return customTypeName;
        };
        res.getTemplate = function () {
            return customTemplateName;
        };
        CustomPropertiesCollection.createProperties(res);
        return res;
    };
    JsonMetadata.prototype.getChildrenClasses = function (name, canBeCreated) {
        if (canBeCreated === void 0) { canBeCreated = false; }
        name = name.toLowerCase();
        var result = [];
        this.fillChildrenClasses(name, canBeCreated, result);
        return result;
    };
    JsonMetadata.prototype.getRequiredProperties = function (name) {
        var metaClass = this.findClass(name);
        if (!metaClass)
            return [];
        var props = metaClass.getRequiredProperties();
        var res = [];
        for (var i = 0; i < props.length; i++) {
            res.push(props[i].name);
        }
        return res;
    };
    JsonMetadata.prototype.addProperties = function (className, propertiesInfos) {
        className = className.toLowerCase();
        var metaDataClass = this.findClass(className);
        for (var i = 0; i < propertiesInfos.length; i++) {
            this.addCustomPropertyCore(metaDataClass, propertiesInfos[i]);
        }
    };
    JsonMetadata.prototype.addProperty = function (className, propertyInfo) {
        return this.addCustomPropertyCore(this.findClass(className), propertyInfo);
    };
    JsonMetadata.prototype.addCustomPropertyCore = function (metaDataClass, propertyInfo) {
        if (!metaDataClass)
            return null;
        var property = metaDataClass.createProperty(propertyInfo, true);
        if (property) {
            this.clearDynamicPropsCache(metaDataClass);
            metaDataClass.resetAllProperties();
        }
        return property;
    };
    JsonMetadata.prototype.removeProperty = function (className, propertyName) {
        var metaDataClass = this.findClass(className);
        if (!metaDataClass)
            return false;
        var property = metaDataClass.find(propertyName);
        if (property) {
            this.clearDynamicPropsCache(metaDataClass);
            this.removePropertyFromClass(metaDataClass, property);
            metaDataClass.resetAllProperties();
            CustomPropertiesCollection.removeProperty(metaDataClass.name, propertyName);
        }
    };
    JsonMetadata.prototype.clearDynamicPropsCache = function (metaDataClass) {
        this.dynamicPropsCache = {};
    };
    JsonMetadata.prototype.removePropertyFromClass = function (metaDataClass, property) {
        var index = metaDataClass.properties.indexOf(property);
        if (index < 0)
            return;
        metaDataClass.properties.splice(index, 1);
    };
    JsonMetadata.prototype.fillChildrenClasses = function (name, canBeCreated, result) {
        var children = this.childrenClasses[name];
        if (!children)
            return;
        for (var i = 0; i < children.length; i++) {
            if (!canBeCreated || children[i].creator) {
                result.push(children[i]);
            }
            this.fillChildrenClasses(children[i].name, canBeCreated, result);
        }
    };
    JsonMetadata.prototype.findClass = function (name) {
        name = name.toLowerCase();
        var res = this.classes[name];
        if (!res) {
            var newName = this.alternativeNames[name];
            if (!!newName && newName != name)
                return this.findClass(newName);
        }
        return res;
    };
    JsonMetadata.prototype.isDescendantOf = function (className, ancestorClassName) {
        if (!className || !ancestorClassName) {
            return false;
        }
        className = className.toLowerCase();
        ancestorClassName = ancestorClassName.toLowerCase();
        var class_ = this.findClass(className);
        if (!class_) {
            return false;
        }
        var parentClass = class_;
        do {
            if (parentClass.name === ancestorClassName) {
                return true;
            }
            parentClass = this.classes[parentClass.parentName];
        } while (!!parentClass);
        return false;
    };
    JsonMetadata.prototype.addAlterNativeClassName = function (name, alternativeName) {
        this.alternativeNames[alternativeName.toLowerCase()] = name.toLowerCase();
    };
    JsonMetadata.prototype.generateSchema = function (className) {
        if (className === void 0) { className = undefined; }
        if (!className)
            className = "survey";
        var classInfo = this.findClass(className);
        if (!classInfo)
            return null;
        var res = {
            $schema: "http://json-schema.org/draft-07/schema#",
            title: "SurveyJS Library json schema",
            type: "object",
            properties: {},
            definitions: { locstring: this.generateLocStrClass() },
        };
        this.generateSchemaProperties(classInfo, res, res.definitions, true);
        return res;
    };
    JsonMetadata.prototype.generateLocStrClass = function () {
        var props = {};
        var locProp = Serializer.findProperty("survey", "locale");
        if (!!locProp) {
            var choices = locProp.getChoices(null);
            if (Array.isArray(choices)) {
                if (choices.indexOf("en") < 0) {
                    choices.splice(0, 0, "en");
                }
                choices.splice(0, 0, "default");
                choices.forEach(function (l) { if (!!l) {
                    props[l] = { type: "string" };
                } });
            }
        }
        return {
            $id: "locstring",
            type: "object",
            properties: props
        };
    };
    JsonMetadata.prototype.generateSchemaProperties = function (classInfo, classSchema, schemaDef, isRoot) {
        if (!classInfo)
            return;
        var schemaProperties = classSchema.properties;
        var requiredProps = [];
        if (classInfo.name === "question" || classInfo.name === "panel") {
            schemaProperties.type = { type: "string" };
            requiredProps.push("type");
        }
        for (var i = 0; i < classInfo.properties.length; i++) {
            var prop = classInfo.properties[i];
            if (!!classInfo.parentName && !!Serializer.findProperty(classInfo.parentName, prop.name))
                continue;
            schemaProperties[prop.name] = this.generateSchemaProperty(prop, schemaDef, isRoot);
            if (prop.isRequired)
                requiredProps.push(prop.name);
        }
        if (requiredProps.length > 0) {
            classSchema.required = requiredProps;
        }
    };
    JsonMetadata.prototype.generateSchemaProperty = function (prop, schemaDef, isRoot) {
        if (prop.isLocalizable) {
            return { oneOf: [
                    { "type": "string" },
                    { "$ref": this.getChemeRefName("locstring", isRoot) }
                ] };
        }
        var propType = prop.schemaType();
        var refType = prop.schemaRef();
        var res = {};
        if (!!propType) {
            res.type = propType;
        }
        if (prop.hasChoices) {
            var enumRes = prop.getChoices(null);
            if (Array.isArray(enumRes) && enumRes.length > 0) {
                res.enum = this.getChoicesValues(enumRes);
            }
        }
        if (!!refType) {
            if (propType === "array") {
                if (prop.className === "string") {
                    res.items = { type: prop.className };
                }
                else {
                    res.items = { $ref: this.getChemeRefName(prop.className, isRoot) };
                }
            }
            else {
                res["$ref"] = this.getChemeRefName(refType, isRoot);
            }
            this.generateChemaClass(prop.className, schemaDef, false);
        }
        if (!!prop.baseClassName) {
            var usedClasses = this.getChildrenClasses(prop.baseClassName, true);
            if (prop.baseClassName == "question") {
                usedClasses.push(this.findClass("panel"));
            }
            res.items = { anyOf: [] };
            for (var i = 0; i < usedClasses.length; i++) {
                var className = usedClasses[i].name;
                res.items.anyOf.push({ $ref: this.getChemeRefName(className, isRoot) });
                this.generateChemaClass(className, schemaDef, false);
            }
        }
        return res;
    };
    JsonMetadata.prototype.getChemeRefName = function (className, isRoot) {
        //Fix for #6486, according to https://niem.github.io/json/reference/json-schema/references/#:~:text=In%20a%20JSON%20schema%2C%20a,%2C%20an%20in%2Dschema%20reference
        //Checked by https://www.jsonschemavalidator.net/
        return isRoot ? "#/definitions/" + className : className;
    };
    JsonMetadata.prototype.generateChemaClass = function (className, schemaDef, isRoot) {
        if (!!schemaDef[className])
            return;
        var classInfo = this.findClass(className);
        if (!classInfo)
            return;
        var hasParent = !!classInfo.parentName && classInfo.parentName != "base";
        if (hasParent) {
            this.generateChemaClass(classInfo.parentName, schemaDef, isRoot);
        }
        var res = { type: "object", $id: className };
        schemaDef[className] = res;
        var chemaProps = { properties: {} };
        this.generateSchemaProperties(classInfo, chemaProps, schemaDef, isRoot);
        if (hasParent) {
            res.allOf = [
                { $ref: this.getChemeRefName(classInfo.parentName, isRoot) },
                { properties: chemaProps.properties },
            ];
        }
        else {
            res.properties = chemaProps.properties;
        }
        if (Array.isArray(chemaProps.required)) {
            res.required = chemaProps.required;
        }
    };
    JsonMetadata.prototype.getChoicesValues = function (enumRes) {
        var res = new Array();
        enumRes.forEach(function (item) {
            if (typeof item === "object" && item.value !== undefined) {
                res.push(item.value);
            }
            else {
                res.push(item);
            }
        });
        return res;
    };
    return JsonMetadata;
}());

var JsonError = /** @class */ (function () {
    function JsonError(type, message) {
        this.type = type;
        this.message = message;
        this.description = "";
        this.at = -1;
        this.end = -1;
    }
    JsonError.prototype.getFullDescription = function () {
        return this.message + (this.description ? "\n" + this.description : "");
    };
    return JsonError;
}());

var JsonUnknownPropertyError = /** @class */ (function (_super) {
    __extends(JsonUnknownPropertyError, _super);
    function JsonUnknownPropertyError(propertyName, className) {
        var _this = _super.call(this, "unknownproperty", "Unknown property in class '" + className + "': '" + propertyName + "'.") || this;
        _this.propertyName = propertyName;
        _this.className = className;
        return _this;
    }
    return JsonUnknownPropertyError;
}(JsonError));

var JsonMissingTypeErrorBase = /** @class */ (function (_super) {
    __extends(JsonMissingTypeErrorBase, _super);
    function JsonMissingTypeErrorBase(baseClassName, type, message) {
        var _this = _super.call(this, type, message) || this;
        _this.baseClassName = baseClassName;
        _this.type = type;
        _this.message = message;
        return _this;
    }
    return JsonMissingTypeErrorBase;
}(JsonError));

var JsonMissingTypeError = /** @class */ (function (_super) {
    __extends(JsonMissingTypeError, _super);
    function JsonMissingTypeError(propertyName, baseClassName) {
        var _this = _super.call(this, baseClassName, "missingtypeproperty", "The property type is missing in the object. Please take a look at property: '" +
            propertyName +
            "'.") || this;
        _this.propertyName = propertyName;
        _this.baseClassName = baseClassName;
        return _this;
    }
    return JsonMissingTypeError;
}(JsonMissingTypeErrorBase));

var JsonIncorrectTypeError = /** @class */ (function (_super) {
    __extends(JsonIncorrectTypeError, _super);
    function JsonIncorrectTypeError(propertyName, baseClassName) {
        var _this = _super.call(this, baseClassName, "incorrecttypeproperty", "The property type is incorrect in the object. Please take a look at property: '" +
            propertyName +
            "'.") || this;
        _this.propertyName = propertyName;
        _this.baseClassName = baseClassName;
        return _this;
    }
    return JsonIncorrectTypeError;
}(JsonMissingTypeErrorBase));

var JsonRequiredPropertyError = /** @class */ (function (_super) {
    __extends(JsonRequiredPropertyError, _super);
    function JsonRequiredPropertyError(propertyName, className) {
        var _this = _super.call(this, "requiredproperty", "The property '" +
            propertyName +
            "' is required in class '" +
            className +
            "'.") || this;
        _this.propertyName = propertyName;
        _this.className = className;
        return _this;
    }
    return JsonRequiredPropertyError;
}(JsonError));

var JsonRequiredArrayPropertyError = /** @class */ (function (_super) {
    __extends(JsonRequiredArrayPropertyError, _super);
    function JsonRequiredArrayPropertyError(propertyName, className) {
        var _this = _super.call(this, "arrayproperty", "The property '" + propertyName + "' should be an array in '" + className + "'.") || this;
        _this.propertyName = propertyName;
        _this.className = className;
        return _this;
    }
    return JsonRequiredArrayPropertyError;
}(JsonError));

var JsonIncorrectPropertyValueError = /** @class */ (function (_super) {
    __extends(JsonIncorrectPropertyValueError, _super);
    function JsonIncorrectPropertyValueError(property, value) {
        var _this = _super.call(this, "incorrectvalue", "The property value: '" + value + "' is incorrect for property '" + property.name + "'.") || this;
        _this.property = property;
        _this.value = value;
        return _this;
    }
    return JsonIncorrectPropertyValueError;
}(JsonError));

var jsonobject_JsonObject = /** @class */ (function () {
    function JsonObject() {
        this.errors = new Array();
        this.lightSerializing = false;
    }
    Object.defineProperty(JsonObject, "metaData", {
        get: function () {
            return JsonObject.metaDataValue;
        },
        enumerable: false,
        configurable: true
    });
    JsonObject.prototype.toJsonObject = function (obj, options) {
        return this.toJsonObjectCore(obj, null, options);
    };
    JsonObject.prototype.toObject = function (jsonObj, obj, options) {
        this.toObjectCore(jsonObj, obj, options);
        var error = this.getRequiredError(obj, jsonObj);
        if (!!error) {
            this.addNewError(error, jsonObj, obj);
        }
    };
    JsonObject.prototype.toObjectCore = function (jsonObj, obj, options) {
        if (!jsonObj)
            return;
        var properties = null;
        var objType = undefined;
        var needAddErrors = true;
        if (obj.getType) {
            objType = obj.getType();
            properties = Serializer.getProperties(objType);
            needAddErrors =
                !!objType && !Serializer.isDescendantOf(objType, "itemvalue");
        }
        if (!properties)
            return;
        if (obj.startLoadingFromJson) {
            obj.startLoadingFromJson(jsonObj);
        }
        properties = this.addDynamicProperties(obj, jsonObj, properties);
        this.options = options;
        var processedProps = {};
        processedProps[JsonObject.typePropertyName] = true;
        var parentProps = {};
        for (var key in jsonObj) {
            this.setPropertyValueToObj(jsonObj, obj, key, properties, processedProps, parentProps, objType, needAddErrors, options);
        }
        this.options = undefined;
        if (obj.endLoadingFromJson) {
            obj.endLoadingFromJson();
        }
    };
    JsonObject.prototype.setPropertyValueToObj = function (jsonObj, obj, key, properties, processedProps, parentProps, objType, needAddErrors, options) {
        var _this = this;
        if (processedProps[key])
            return;
        if (key === JsonObject.positionPropertyName) {
            obj[key] = jsonObj[key];
            return;
        }
        var property = this.findProperty(properties, key);
        if (!property && needAddErrors) {
            this.addNewError(new JsonUnknownPropertyError(key.toString(), objType), jsonObj, obj);
        }
        if (property) {
            var dProps = property.dependsOn;
            if (Array.isArray(dProps)) {
                parentProps[key] = true;
                dProps.forEach(function (propKey) {
                    if (!parentProps[propKey]) {
                        _this.setPropertyValueToObj(jsonObj, obj, propKey, properties, processedProps, parentProps, objType, needAddErrors, options);
                    }
                });
            }
            this.valueToObj(jsonObj[key], obj, property, jsonObj, options);
            processedProps[key] = true;
        }
    };
    JsonObject.prototype.toJsonObjectCore = function (obj, property, options) {
        if (!obj || !obj.getType)
            return obj;
        if (!obj.isSurvey && typeof obj.getData === "function")
            return obj.getData();
        var result = {};
        if (property != null && !property.className) {
            result[JsonObject.typePropertyName] = property.getObjType(obj.getType());
        }
        var storeDefaults = options === true;
        if (!options || options === true) {
            options = {};
        }
        if (storeDefaults) {
            options.storeDefaults = storeDefaults;
        }
        this.propertiesToJson(obj, Serializer.getProperties(obj.getType()), result, options);
        this.propertiesToJson(obj, this.getDynamicProperties(obj), result, options);
        return result;
    };
    JsonObject.prototype.getDynamicProperties = function (obj) {
        return Serializer.getDynamicPropertiesByObj(obj);
    };
    JsonObject.prototype.addDynamicProperties = function (obj, jsonObj, props) {
        if (!obj.getDynamicPropertyName && !obj.getDynamicProperties)
            return props;
        if (obj.getDynamicPropertyName) {
            var dynamicPropName = obj.getDynamicPropertyName();
            if (!dynamicPropName)
                return props;
            if (dynamicPropName && jsonObj[dynamicPropName]) {
                obj[dynamicPropName] = jsonObj[dynamicPropName];
            }
        }
        var dynamicProps = this.getDynamicProperties(obj);
        return dynamicProps.length === 0 ? props : [].concat(props).concat(dynamicProps);
    };
    JsonObject.prototype.propertiesToJson = function (obj, properties, json, options) {
        for (var i = 0; i < properties.length; i++) {
            this.valueToJson(obj, json, properties[i], options);
        }
    };
    JsonObject.prototype.valueToJson = function (obj, result, prop, options) {
        if (!options)
            options = {};
        if (prop.isSerializable === false || (prop.isLightSerializable === false && this.lightSerializing))
            return;
        if (options.version && !prop.isAvailableInVersion(options.version))
            return;
        this.valueToJsonCore(obj, result, prop, options);
    };
    JsonObject.prototype.valueToJsonCore = function (obj, result, prop, options) {
        var serProp = prop.getSerializedProperty(obj, options.version);
        if (serProp && serProp !== prop) {
            this.valueToJsonCore(obj, result, serProp, options);
            return;
        }
        var value = prop.getSerializableValue(obj);
        if (!options.storeDefaults && prop.isDefaultValueByObj(obj, value))
            return;
        if (this.isValueArray(value)) {
            var arrValue = [];
            for (var i = 0; i < value.length; i++) {
                arrValue.push(this.toJsonObjectCore(value[i], prop, options));
            }
            value = arrValue.length > 0 ? arrValue : null;
        }
        else {
            value = this.toJsonObjectCore(value, prop, options);
        }
        if (value === undefined || value === null)
            return;
        var name = prop.getSerializedName(options.version);
        var hasValue = typeof obj["getPropertyValue"] === "function" &&
            obj["getPropertyValue"](name, null) !== null;
        if ((options.storeDefaults && hasValue) || !prop.isDefaultValueByObj(obj, value)) {
            if (!Serializer.onSerializingProperty || !Serializer.onSerializingProperty(obj, prop, value, result)) {
                result[name] = this.removePosOnValueToJson(prop, value);
            }
        }
    };
    JsonObject.prototype.valueToObj = function (value, obj, property, jsonObj, options) {
        if (value === null || value === undefined)
            return;
        this.removePos(property, value);
        if (property != null && property.hasToUseSetValue) {
            property.setValue(obj, value, this);
            return;
        }
        if (property.isArray && !Array.isArray(value) && !!value) {
            value = [value];
            var propName = !!jsonObj && property.alternativeName && !!jsonObj[property.alternativeName] ? property.alternativeName : property.name;
            this.addNewError(new JsonRequiredArrayPropertyError(propName, obj.getType()), !!jsonObj ? jsonObj : value, obj);
        }
        if (this.isValueArray(value)) {
            this.valueToArray(value, obj, property.name, property, options);
            return;
        }
        var newObj = this.createNewObj(value, property);
        if (newObj.newObj) {
            this.toObjectCore(value, newObj.newObj, options);
            value = newObj.newObj;
        }
        if (!newObj.error) {
            if (property != null) {
                property.setValue(obj, value, this);
                if (!!options && options.validatePropertyValues) {
                    if (!property.validateValue(value)) {
                        this.addNewError(new JsonIncorrectPropertyValueError(property, value), jsonObj, obj);
                    }
                }
            }
            else {
                obj[property.name] = value;
            }
        }
    };
    JsonObject.prototype.removePosOnValueToJson = function (property, value) {
        if (!property.isCustom || !value)
            return value;
        this.removePosFromObj(value);
        return value;
    };
    JsonObject.prototype.removePos = function (property, value) {
        if (!property || !property.type || property.type.indexOf("value") < 0)
            return;
        this.removePosFromObj(value);
    };
    JsonObject.prototype.removePosFromObj = function (obj) {
        if (!obj || typeof obj.getType === "function")
            return;
        if (Array.isArray(obj)) {
            for (var i = 0; i < obj.length; i++) {
                this.removePosFromObj(obj[i]);
            }
        }
        if (typeof obj !== "object")
            return;
        if (!!obj[JsonObject.positionPropertyName]) {
            delete obj[JsonObject.positionPropertyName];
        }
        for (var key in obj) {
            this.removePosFromObj(obj[key]);
        }
    };
    JsonObject.prototype.isValueArray = function (value) {
        return value && Array.isArray(value);
    };
    JsonObject.prototype.createNewObj = function (value, property) {
        var result = { newObj: null, error: null };
        var className = this.getClassNameForNewObj(value, property);
        result.newObj = className
            ? Serializer.createClass(className, value)
            : null;
        result.error = this.checkNewObjectOnErrors(result.newObj, value, property, className);
        return result;
    };
    JsonObject.prototype.getClassNameForNewObj = function (value, property) {
        var res = property != null && property.className ? property.className : undefined;
        if (!res) {
            res = value[JsonObject.typePropertyName];
        }
        if (!res)
            return res;
        res = res.toLowerCase();
        var classNamePart = property.classNamePart;
        if (classNamePart && res.indexOf(classNamePart) < 0) {
            res += classNamePart;
        }
        return res;
    };
    JsonObject.prototype.checkNewObjectOnErrors = function (newObj, value, property, className) {
        var error = null;
        if (newObj) {
            error = this.getRequiredError(newObj, value);
        }
        else {
            if (property.baseClassName) {
                if (!className) {
                    error = new JsonMissingTypeError(property.name, property.baseClassName);
                }
                else {
                    error = new JsonIncorrectTypeError(property.name, property.baseClassName);
                }
            }
        }
        if (error) {
            this.addNewError(error, value, newObj);
        }
        return error;
    };
    JsonObject.prototype.getRequiredError = function (obj, jsonValue) {
        if (!obj.getType || typeof obj.getData === "function")
            return null;
        var metaClass = Serializer.findClass(obj.getType());
        if (!metaClass)
            return null;
        var props = metaClass.getRequiredProperties();
        if (!Array.isArray(props))
            return null;
        for (var i = 0; i < props.length; i++) {
            var prop = props[i];
            if (!helpers_Helpers.isValueEmpty(prop.defaultValue))
                continue;
            if (!jsonValue[prop.name]) {
                return new JsonRequiredPropertyError(prop.name, obj.getType());
            }
        }
        return null;
    };
    JsonObject.prototype.addNewError = function (error, jsonObj, element) {
        error.jsonObj = jsonObj;
        error.element = element;
        this.errors.push(error);
        if (!jsonObj)
            return;
        var posObj = jsonObj[JsonObject.positionPropertyName];
        if (!posObj)
            return;
        error.at = posObj.start;
        error.end = posObj.end;
    };
    JsonObject.prototype.valueToArray = function (value, obj, key, property, options) {
        if (obj[key] && !this.isValueArray(obj[key]))
            return;
        if (obj[key] && value.length > 0)
            obj[key].splice(0, obj[key].length);
        var valueRes = obj[key] ? obj[key] : [];
        this.addValuesIntoArray(value, valueRes, property, options);
        if (!obj[key])
            obj[key] = valueRes;
    };
    JsonObject.prototype.addValuesIntoArray = function (value, result, property, options) {
        for (var i = 0; i < value.length; i++) {
            var newValue = this.createNewObj(value[i], property);
            if (newValue.newObj) {
                if (!!value[i].name) {
                    newValue.newObj.name = value[i].name;
                }
                if (!!value[i].valueName) {
                    newValue.newObj.valueName = value[i].valueName.toString();
                }
                result.push(newValue.newObj);
                this.toObjectCore(value[i], newValue.newObj, options);
            }
            else {
                if (!newValue.error) {
                    result.push(value[i]);
                }
            }
        }
    };
    JsonObject.prototype.findProperty = function (properties, key) {
        if (!properties)
            return null;
        for (var i = 0; i < properties.length; i++) {
            var prop = properties[i];
            if (prop.name == key || prop.alternativeName == key)
                return prop;
        }
        return null;
    };
    JsonObject.typePropertyName = "type";
    JsonObject.positionPropertyName = "pos";
    JsonObject.metaDataValue = new JsonMetadata();
    return JsonObject;
}());

/**
 * An alias for the metadata object. It contains object properties' runtime information and allows you to modify it.
 * @see JsonMetadata
 */
var Serializer = jsonobject_JsonObject.metaData;

// CONCATENATED MODULE: ./packages/survey-core/src/conditionProcessValue.ts

var surveyBuiltInVarible = "@survey";
var conditionProcessValue_ProcessValue = /** @class */ (function () {
    function ProcessValue() {
        this.values = null;
        this.properties = null;
    }
    ProcessValue.prototype.getFirstName = function (text, obj) {
        if (obj === void 0) { obj = null; }
        if (!text)
            return text;
        var res = "";
        if (!!obj) {
            res = this.getFirstPropertyName(text, obj);
            if (!!res)
                return res;
        }
        for (var i = 0; i < text.length; i++) {
            var ch = text[i];
            if (ch == "." || ch == "[")
                break;
            res += ch;
        }
        return res;
    };
    ProcessValue.prototype.hasValue = function (text, values) {
        if (values === void 0) { values = null; }
        if (!values)
            values = this.values;
        var res = this.getValueCore(text, values);
        return res.hasValue;
    };
    ProcessValue.prototype.getValue = function (text, values) {
        if (values === void 0) { values = null; }
        if (!values)
            values = this.values;
        var res = this.getValueCore(text, values);
        return res.value;
    };
    ProcessValue.prototype.setValue = function (obj, text, value) {
        if (!text)
            return;
        var nonNestedObj = this.getNonNestedObject(obj, text, true);
        if (!nonNestedObj)
            return;
        obj = nonNestedObj.value;
        text = nonNestedObj.text;
        if (!!obj && !!text) {
            obj[text] = value;
        }
    };
    ProcessValue.prototype.getValueInfo = function (valueInfo) {
        if (!!valueInfo.path) {
            valueInfo.value = this.getValueFromPath(valueInfo.path, this.values);
            valueInfo.hasValue =
                valueInfo.value !== null && !helpers_Helpers.isValueEmpty(valueInfo.value);
            if (!valueInfo.hasValue &&
                valueInfo.path.length > 1 &&
                valueInfo.path[valueInfo.path.length - 1] == "length") {
                valueInfo.hasValue = true;
                valueInfo.value = 0;
            }
            return;
        }
        var res = this.getValueCore(valueInfo.name, this.values);
        valueInfo.value = res.value;
        valueInfo.hasValue = res.hasValue;
        valueInfo.path = res.hasValue ? res.path : null;
        valueInfo.sctrictCompare = res.sctrictCompare;
    };
    ProcessValue.prototype.isAnyKeyChanged = function (keys, usedNames) {
        for (var i = 0; i < usedNames.length; i++) {
            var name_1 = usedNames[i];
            if (!name_1)
                continue;
            var lowerName = name_1.toLowerCase();
            if (keys.hasOwnProperty(name_1))
                return true;
            if (name_1 !== lowerName && keys.hasOwnProperty(lowerName))
                return true;
            var firstName = this.getFirstName(name_1);
            if (!keys.hasOwnProperty(firstName))
                continue;
            if (name_1 === firstName)
                return true;
            var keyValue = keys[firstName];
            if (keyValue == undefined)
                continue;
            if (!keyValue.hasOwnProperty("oldValue") ||
                !keyValue.hasOwnProperty("newValue"))
                return true;
            var v = {};
            v[firstName] = keyValue["oldValue"];
            var oldValue = this.getValue(name_1, v);
            v[firstName] = keyValue["newValue"];
            var newValue = this.getValue(name_1, v);
            if (!helpers_Helpers.isTwoValueEquals(oldValue, newValue, false, false, false))
                return true;
        }
        return false;
    };
    ProcessValue.prototype.getValueFromPath = function (path, values) {
        if (path.length === 2 && path[0] === surveyBuiltInVarible) {
            return this.getValueFromSurvey(path[1]);
        }
        var index = 0;
        while (!!values && index < path.length) {
            var ind_name = path[index];
            if (helpers_Helpers.isNumber(ind_name) &&
                Array.isArray(values) &&
                ind_name >= values.length)
                return null;
            values = values[ind_name];
            index++;
        }
        return values;
    };
    ProcessValue.prototype.getValueCore = function (text, values) {
        var question = this.getQuestionDirectly(text);
        if (question) {
            return { hasValue: true, value: question.value, path: [text], sctrictCompare: question.requireStrictCompare };
        }
        var res = this.getValueFromValues(text, values);
        if (!!text && !res.hasValue) {
            var val = this.getValueFromSurvey(text);
            if (val !== undefined) {
                res.hasValue = true;
                res.value = val;
                res.path = [surveyBuiltInVarible, text];
            }
        }
        return res;
    };
    ProcessValue.prototype.getQuestionDirectly = function (name) {
        if (!!this.properties && !!this.properties.survey)
            return this.properties.survey.getQuestionByValueName(name);
        return undefined;
    };
    ProcessValue.prototype.getValueFromSurvey = function (name) {
        if (!!this.properties && !!this.properties.survey)
            return this.properties.survey.getBuiltInVariableValue(name.toLocaleLowerCase());
        return undefined;
    };
    ProcessValue.prototype.getValueFromValues = function (text, values) {
        var res = { hasValue: false, value: null, path: null };
        var curValue = values;
        if (!curValue && curValue !== 0 && curValue !== false)
            return res;
        if (text &&
            text.lastIndexOf(".length") > -1 &&
            text.lastIndexOf(".length") === text.length - ".length".length) {
            res.value = 0;
            res.hasValue = true;
        }
        var nonNestedObj = this.getNonNestedObject(curValue, text, false);
        if (!nonNestedObj)
            return res;
        res.path = nonNestedObj.path;
        res.value = !!nonNestedObj.text
            ? this.getObjectValue(nonNestedObj.value, nonNestedObj.text)
            : nonNestedObj.value;
        res.hasValue = !helpers_Helpers.isValueEmpty(res.value);
        return res;
    };
    ProcessValue.prototype.getNonNestedObject = function (obj, text, createPath) {
        var checkedKeys = new Array();
        var len = 0;
        var res = this.getNonNestedObjectCore(obj, text, createPath, checkedKeys);
        while (!res && len < checkedKeys.length) {
            len = checkedKeys.length;
            res = this.getNonNestedObjectCore(obj, text, createPath, checkedKeys);
        }
        return res;
    };
    ProcessValue.prototype.getNonNestedObjectCore = function (obj, text, createPath, checkedKeys) {
        var curName = this.getFirstPropertyName(text, obj, createPath, checkedKeys);
        if (!!curName) {
            checkedKeys.push(curName);
        }
        var path = !!curName ? [curName] : null;
        while (text != curName && !!obj) {
            var isArray = text[0] == "[";
            if (!isArray) {
                if (!curName && text == this.getFirstName(text))
                    return { value: obj, text: text, path: path };
                obj = this.getObjectValue(obj, curName);
                if (helpers_Helpers.isValueEmpty(obj) && !createPath)
                    return null;
                text = text.substring(curName.length);
            }
            else {
                var objInArray = this.getObjInArray(obj, text);
                if (!objInArray)
                    return null;
                obj = objInArray.value;
                text = objInArray.text;
                path.push(objInArray.index);
            }
            if (!!text && text[0] == ".") {
                text = text.substring(1);
            }
            curName = this.getFirstPropertyName(text, obj, createPath, checkedKeys);
            if (!!curName) {
                path.push(curName);
            }
        }
        return { value: obj, text: text, path: path };
    };
    ProcessValue.prototype.getObjInArray = function (curValue, text) {
        if (!Array.isArray(curValue))
            return null;
        var index = 1;
        var str = "";
        while (index < text.length && text[index] != "]") {
            str += text[index];
            index++;
        }
        text = index < text.length ? text.substring(index + 1) : "";
        index = this.getIntValue(str);
        if (index < 0 || index >= curValue.length)
            return null;
        return { value: curValue[index], text: text, index: index };
    };
    ProcessValue.prototype.getFirstPropertyName = function (name, obj, createProp, checkedKeys) {
        if (createProp === void 0) { createProp = false; }
        if (checkedKeys === void 0) { checkedKeys = undefined; }
        if (!name)
            return name;
        if (!obj)
            obj = {};
        if (obj.hasOwnProperty(name))
            return name;
        var nameInLow = name.toLowerCase();
        var A = nameInLow[0];
        var a = A.toUpperCase();
        for (var key in obj) {
            if (Array.isArray(checkedKeys) && checkedKeys.indexOf(key) > -1)
                continue;
            var first = key[0];
            if (first === a || first === A) {
                var keyName = key.toLowerCase();
                if (keyName == nameInLow)
                    return key;
                if (nameInLow.length <= keyName.length)
                    continue;
                var ch = nameInLow[keyName.length];
                if (ch != "." && ch != "[")
                    continue;
                if (keyName == nameInLow.substring(0, keyName.length))
                    return key;
            }
        }
        if (createProp && name[0] !== "[") {
            var ind = name.indexOf(".");
            if (ind > -1) {
                name = name.substring(0, ind);
                obj[name] = {};
            }
            return name;
        }
        return "";
    };
    ProcessValue.prototype.getObjectValue = function (obj, name) {
        if (!name)
            return null;
        return obj[name];
    };
    ProcessValue.prototype.getIntValue = function (str) {
        if (str == "0" || ((str | 0) > 0 && str % 1 == 0))
            return Number(str);
        return -1;
    };
    return ProcessValue;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/console-warnings.ts
var ConsoleWarnings = /** @class */ (function () {
    function ConsoleWarnings() {
    }
    ConsoleWarnings.disposedObjectChangedProperty = function (propName, objType) {
        ConsoleWarnings.warn("An attempt to set a property \"" + propName + "\" of a disposed object \"" + objType + "\"");
    };
    ConsoleWarnings.inCorrectQuestionValue = function (questionName, val) {
        var valStr = JSON.stringify(val, null, 3);
        ConsoleWarnings.warn("An attempt to assign an incorrect value" + valStr + " to the following question: \"" + questionName + "\"");
    };
    ConsoleWarnings.warn = function (text) {
        // eslint-disable-next-line no-console
        console.warn(text);
    };
    ConsoleWarnings.error = function (text) {
        // eslint-disable-next-line no-console
        console.error(text);
    };
    return ConsoleWarnings;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/functionsfactory.ts




var functionsfactory_FunctionFactory = /** @class */ (function () {
    function FunctionFactory() {
        this.functionHash = {};
        this.isAsyncHash = {};
    }
    FunctionFactory.prototype.register = function (name, func, isAsync) {
        if (isAsync === void 0) { isAsync = false; }
        this.functionHash[name] = func;
        if (isAsync)
            this.isAsyncHash[name] = true;
    };
    FunctionFactory.prototype.unregister = function (name) {
        delete this.functionHash[name];
        delete this.isAsyncHash[name];
    };
    FunctionFactory.prototype.hasFunction = function (name) {
        return !!this.functionHash[name];
    };
    FunctionFactory.prototype.isAsyncFunction = function (name) {
        return !!this.isAsyncHash[name];
    };
    FunctionFactory.prototype.clear = function () {
        this.functionHash = {};
    };
    FunctionFactory.prototype.getAll = function () {
        var result = [];
        for (var key in this.functionHash) {
            result.push(key);
        }
        return result.sort();
    };
    FunctionFactory.prototype.run = function (name, params, properties, originalParams) {
        if (properties === void 0) { properties = null; }
        var func = this.functionHash[name];
        if (!func) {
            ConsoleWarnings.warn("Unknown function name: " + name);
            return null;
        }
        var classRunner = {
            func: func,
        };
        if (properties) {
            for (var key in properties) {
                classRunner[key] = properties[key];
            }
        }
        return classRunner.func(params, originalParams);
    };
    FunctionFactory.Instance = new FunctionFactory();
    return FunctionFactory;
}());

var registerFunction = functionsfactory_FunctionFactory.Instance.register;
function getParamsAsArray(value, arr) {
    if (value === undefined || value === null)
        return;
    if (Array.isArray(value)) {
        for (var i = 0; i < value.length; i++) {
            getParamsAsArray(value[i], arr);
        }
    }
    else {
        if (helpers_Helpers.isNumber(value)) {
            value = helpers_Helpers.getNumber(value);
        }
        arr.push(value);
    }
}
function sum(params) {
    var arr = [];
    getParamsAsArray(params, arr);
    var res = 0;
    for (var i = 0; i < arr.length; i++) {
        res = helpers_Helpers.correctAfterPlusMinis(res, arr[i], res + arr[i]);
    }
    return res;
}
functionsfactory_FunctionFactory.Instance.register("sum", sum);
function min_max(params, isMin) {
    var arr = [];
    getParamsAsArray(params, arr);
    var res = undefined;
    for (var i = 0; i < arr.length; i++) {
        if (res === undefined) {
            res = arr[i];
        }
        if (isMin) {
            if (res > arr[i])
                res = arr[i];
        }
        else {
            if (res < arr[i])
                res = arr[i];
        }
    }
    return res;
}
function functionsfactory_min(params) {
    return min_max(params, true);
}
functionsfactory_FunctionFactory.Instance.register("min", functionsfactory_min);
function functionsfactory_max(params) {
    return min_max(params, false);
}
functionsfactory_FunctionFactory.Instance.register("max", functionsfactory_max);
function count(params) {
    var arr = [];
    getParamsAsArray(params, arr);
    return arr.length;
}
functionsfactory_FunctionFactory.Instance.register("count", count);
function avg(params) {
    var arr = [];
    getParamsAsArray(params, arr);
    var res = sum(params);
    return arr.length > 0 ? res / arr.length : 0;
}
functionsfactory_FunctionFactory.Instance.register("avg", avg);
function getInArrayParams(params, originalParams) {
    if (params.length < 2 || params.length > 3)
        return null;
    var arr = params[0];
    if (!arr)
        return null;
    if (!Array.isArray(arr) && !Array.isArray(Object.keys(arr)))
        return null;
    var name = params[1];
    if (typeof name !== "string" && !(name instanceof String))
        return null;
    var expression = params.length > 2 ? params[2] : undefined;
    if (typeof expression !== "string" && !(expression instanceof String)) {
        expression = undefined;
    }
    if (!expression) {
        var operand = Array.isArray(originalParams) && originalParams.length > 2 ? originalParams[2] : undefined;
        if (operand && !!operand.toString()) {
            expression = operand.toString();
        }
    }
    return { data: arr, name: name, expression: expression };
}
function convertToNumber(val) {
    if (typeof val === "string")
        return helpers_Helpers.isNumber(val) ? helpers_Helpers.getNumber(val) : undefined;
    return val;
}
function processItemInArray(item, name, res, func, needToConvert, condition) {
    if (!item || helpers_Helpers.isValueEmpty(item[name]))
        return res;
    if (condition && !condition.run(item))
        return res;
    var val = needToConvert ? convertToNumber(item[name]) : 1;
    return func(res, val);
}
function calcInArray(params, originalParams, func, needToConvert) {
    if (needToConvert === void 0) { needToConvert = true; }
    var v = getInArrayParams(params, originalParams);
    if (!v)
        return undefined;
    var condition = !!v.expression ? new ConditionRunner(v.expression) : undefined;
    if (condition && condition.isAsync) {
        condition = undefined;
    }
    var res = undefined;
    if (Array.isArray(v.data)) {
        for (var i = 0; i < v.data.length; i++) {
            res = processItemInArray(v.data[i], v.name, res, func, needToConvert, condition);
        }
    }
    else {
        for (var key in v.data) {
            res = processItemInArray(v.data[key], v.name, res, func, needToConvert, condition);
        }
    }
    return res;
}
function sumInArray(params, originalParams) {
    var res = calcInArray(params, originalParams, function (res, val) {
        if (res == undefined)
            res = 0;
        if (val == undefined || val == null)
            return res;
        return helpers_Helpers.correctAfterPlusMinis(res, val, res + val);
    });
    return res !== undefined ? res : 0;
}
functionsfactory_FunctionFactory.Instance.register("sumInArray", sumInArray);
function minInArray(params, originalParams) {
    return calcInArray(params, originalParams, function (res, val) {
        if (res == undefined)
            return val;
        if (val == undefined || val == null)
            return res;
        return res < val ? res : val;
    });
}
functionsfactory_FunctionFactory.Instance.register("minInArray", minInArray);
function maxInArray(params, originalParams) {
    return calcInArray(params, originalParams, function (res, val) {
        if (res == undefined)
            return val;
        if (val == undefined || val == null)
            return res;
        return res > val ? res : val;
    });
}
functionsfactory_FunctionFactory.Instance.register("maxInArray", maxInArray);
function countInArray(params, originalParams) {
    var res = calcInArray(params, originalParams, function (res, val) {
        if (res == undefined)
            res = 0;
        if (val == undefined || val == null)
            return res;
        return res + 1;
    }, false);
    return res !== undefined ? res : 0;
}
functionsfactory_FunctionFactory.Instance.register("countInArray", countInArray);
function avgInArray(params, originalParams) {
    var count = countInArray(params, originalParams);
    if (count == 0)
        return 0;
    return sumInArray(params, originalParams) / count;
}
functionsfactory_FunctionFactory.Instance.register("avgInArray", avgInArray);
function iif(params) {
    if (!params && params.length !== 3)
        return "";
    return params[0] ? params[1] : params[2];
}
functionsfactory_FunctionFactory.Instance.register("iif", iif);
function getDate(params) {
    if (!params && params.length < 1)
        return null;
    if (!params[0])
        return null;
    return new Date(params[0]);
}
functionsfactory_FunctionFactory.Instance.register("getDate", getDate);
function dateDiffMonths(date1Param, date2Param, type) {
    if (type === "days")
        return diffDays([date1Param, date2Param]);
    var date1 = !!date1Param ? new Date(date1Param) : new Date();
    var date2 = !!date2Param ? new Date(date2Param) : new Date();
    var age = date2.getFullYear() - date1.getFullYear();
    type = type || "years";
    var ageInMonths = age * 12 + date2.getMonth() - date1.getMonth();
    if (date2.getDate() < date1.getDate()) {
        ageInMonths -= 1;
    }
    return type === "months" ? ageInMonths : ~~(ageInMonths / 12);
}
function age(params) {
    if (!Array.isArray(params) || params.length < 1 || !params[0])
        return null;
    return dateDiffMonths(params[0], undefined, (params.length > 1 ? params[1] : "") || "years");
}
functionsfactory_FunctionFactory.Instance.register("age", age);
function dateDiff(params) {
    if (!Array.isArray(params) || params.length < 2 || !params[0] || !params[1])
        return null;
    return dateDiffMonths(params[0], params[1], (params.length > 2 ? params[2] : "") || "days");
}
functionsfactory_FunctionFactory.Instance.register("dateDiff", dateDiff);
function isContainerReadyCore(container) {
    if (!container)
        return false;
    var questions = container.questions;
    for (var i = 0; i < questions.length; i++) {
        if (!questions[i].validate(false))
            return false;
    }
    return true;
}
function isContainerReady(params) {
    if (!params && params.length < 1)
        return false;
    if (!params[0] || !this.survey)
        return false;
    var name = params[0];
    var container = this.survey.getPageByName(name);
    if (!container)
        container = this.survey.getPanelByName(name);
    if (!container) {
        var question = this.survey.getQuestionByName(name);
        if (!question || !Array.isArray(question.panels))
            return false;
        if (params.length > 1) {
            if (params[1] < question.panels.length) {
                container = question.panels[params[1]];
            }
        }
        else {
            for (var i = 0; i < question.panels.length; i++) {
                if (!isContainerReadyCore(question.panels[i]))
                    return false;
            }
            return true;
        }
    }
    return isContainerReadyCore(container);
}
functionsfactory_FunctionFactory.Instance.register("isContainerReady", isContainerReady);
function isDisplayMode() {
    return this.survey && this.survey.isDisplayMode;
}
functionsfactory_FunctionFactory.Instance.register("isDisplayMode", isDisplayMode);
function currentDate() {
    return new Date();
}
functionsfactory_FunctionFactory.Instance.register("currentDate", currentDate);
function today(params) {
    var res = new Date();
    if (settings.localization.useLocalTimeZone) {
        res.setHours(0, 0, 0, 0);
    }
    else {
        res.setUTCHours(0, 0, 0, 0);
    }
    if (Array.isArray(params) && params.length == 1) {
        res.setDate(res.getDate() + params[0]);
    }
    return res;
}
functionsfactory_FunctionFactory.Instance.register("today", today);
function getYear(params) {
    if (params.length !== 1 || !params[0])
        return undefined;
    return new Date(params[0]).getFullYear();
}
functionsfactory_FunctionFactory.Instance.register("getYear", getYear);
function currentYear() {
    return new Date().getFullYear();
}
functionsfactory_FunctionFactory.Instance.register("currentYear", currentYear);
function diffDays(params) {
    if (!Array.isArray(params) || params.length !== 2)
        return 0;
    if (!params[0] || !params[1])
        return 0;
    var date1 = new Date(params[0]);
    var date2 = new Date(params[1]);
    var diffTime = Math.abs(date2 - date1);
    return Math.ceil(diffTime / (1000 * 60 * 60 * 24));
}
functionsfactory_FunctionFactory.Instance.register("diffDays", diffDays);
function dateFromFirstParameterOrToday(params) {
    var date = today(undefined);
    if (params && params[0]) {
        date = new Date(params[0]);
    }
    return date;
}
function year(params) {
    var date = dateFromFirstParameterOrToday(params);
    return date.getFullYear();
}
functionsfactory_FunctionFactory.Instance.register("year", year);
function month(params) {
    var date = dateFromFirstParameterOrToday(params);
    return date.getMonth() + 1;
}
functionsfactory_FunctionFactory.Instance.register("month", month);
function day(params) {
    var date = dateFromFirstParameterOrToday(params);
    return date.getDate();
}
functionsfactory_FunctionFactory.Instance.register("day", day);
function weekday(params) {
    var date = dateFromFirstParameterOrToday(params);
    return date.getDay();
}
functionsfactory_FunctionFactory.Instance.register("weekday", weekday);
function getQuestionValueByContext(context, name) {
    if (!context || !name)
        return undefined;
    var keys = ["row", "panel", "survey"];
    for (var i = 0; i < keys.length; i++) {
        var ctx = context[keys[i]];
        if (ctx && ctx.getQuestionByName) {
            var res = ctx.getQuestionByName(name);
            if (res)
                return res;
        }
    }
    return null;
}
function displayValue(params) {
    var q = getQuestionValueByContext(this, params[0]);
    if (!q)
        return "";
    if (params.length > 1 && !helpers_Helpers.isValueEmpty(params[1]))
        return q.getDisplayValue(true, params[1]);
    return q.displayValue;
}
functionsfactory_FunctionFactory.Instance.register("displayValue", displayValue);
function propertyValue(params) {
    if (params.length !== 2 || !params[0] || !params[1])
        return undefined;
    var q = getQuestionValueByContext(this, params[0]);
    return q ? q[params[1]] : undefined;
}
functionsfactory_FunctionFactory.Instance.register("propertyValue", propertyValue);
function substring_(params) {
    if (params.length < 2)
        return "";
    var s = params[0];
    if (!s || typeof s !== "string")
        return "";
    var start = params[1];
    if (!helpers_Helpers.isNumber(start))
        return "";
    var end = params.length > 2 ? params[2] : undefined;
    if (!helpers_Helpers.isNumber(end))
        return s.substring(start);
    return s.substring(start, end);
}
functionsfactory_FunctionFactory.Instance.register("substring", substring_);

// CONCATENATED MODULE: ./packages/survey-core/src/expressions/expressions.ts
var expressions_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();




var Operand = /** @class */ (function () {
    function Operand() {
    }
    Operand.prototype.toString = function (func) {
        if (func === void 0) { func = undefined; }
        return "";
    };
    Operand.prototype.hasFunction = function () {
        return false;
    };
    Operand.prototype.hasAsyncFunction = function () { return false; };
    Operand.prototype.addToAsyncList = function (list) { };
    Operand.prototype.isEqual = function (op) {
        return !!op && op.getType() === this.getType() && this.isContentEqual(op);
    };
    Operand.prototype.areOperatorsEquals = function (op1, op2) {
        return !op1 && !op2 || !!op1 && op1.isEqual(op2);
    };
    return Operand;
}());

var BinaryOperand = /** @class */ (function (_super) {
    expressions_extends(BinaryOperand, _super);
    function BinaryOperand(operatorName, left, right, isArithmeticOp) {
        if (left === void 0) { left = null; }
        if (right === void 0) { right = null; }
        if (isArithmeticOp === void 0) { isArithmeticOp = false; }
        var _this = _super.call(this) || this;
        _this.operatorName = operatorName;
        _this.left = left;
        _this.right = right;
        _this.isArithmeticValue = isArithmeticOp;
        if (isArithmeticOp) {
            _this.consumer = expressions_OperandMaker.binaryFunctions["arithmeticOp"](operatorName);
        }
        else {
            _this.consumer = expressions_OperandMaker.binaryFunctions[operatorName];
        }
        if (_this.consumer == null) {
            expressions_OperandMaker.throwInvalidOperatorError(operatorName);
        }
        return _this;
    }
    Object.defineProperty(BinaryOperand.prototype, "requireStrictCompare", {
        get: function () {
            return this.getIsOperandRequireStrict(this.left) ||
                this.getIsOperandRequireStrict(this.right);
        },
        enumerable: false,
        configurable: true
    });
    BinaryOperand.prototype.getIsOperandRequireStrict = function (op) {
        return !!op && op.requireStrictCompare;
    };
    BinaryOperand.prototype.getType = function () {
        return "binary";
    };
    Object.defineProperty(BinaryOperand.prototype, "isArithmetic", {
        get: function () {
            return this.isArithmeticValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BinaryOperand.prototype, "isConjunction", {
        get: function () {
            return this.operatorName == "or" || this.operatorName == "and";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BinaryOperand.prototype, "conjunction", {
        get: function () {
            return this.isConjunction ? this.operatorName : "";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BinaryOperand.prototype, "operator", {
        get: function () {
            return this.operatorName;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BinaryOperand.prototype, "leftOperand", {
        get: function () {
            return this.left;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BinaryOperand.prototype, "rightOperand", {
        get: function () {
            return this.right;
        },
        enumerable: false,
        configurable: true
    });
    BinaryOperand.prototype.isContentEqual = function (op) {
        var bOp = op;
        return bOp.operator === this.operator &&
            this.areOperatorsEquals(this.left, bOp.left) &&
            this.areOperatorsEquals(this.right, bOp.right);
    };
    BinaryOperand.prototype.evaluateParam = function (x, processValue) {
        return x == null ? null : x.evaluate(processValue);
    };
    BinaryOperand.prototype.evaluate = function (processValue) {
        return this.consumer.call(this, this.evaluateParam(this.left, processValue), this.evaluateParam(this.right, processValue), this.requireStrictCompare);
    };
    BinaryOperand.prototype.toString = function (func) {
        if (func === void 0) { func = undefined; }
        if (!!func) {
            var res = func(this);
            if (!!res)
                return res;
        }
        return ("(" +
            expressions_OperandMaker.safeToString(this.left, func) +
            " " +
            expressions_OperandMaker.operatorToString(this.operatorName) +
            " " +
            expressions_OperandMaker.safeToString(this.right, func) +
            ")");
    };
    BinaryOperand.prototype.setVariables = function (variables) {
        if (this.left != null)
            this.left.setVariables(variables);
        if (this.right != null)
            this.right.setVariables(variables);
    };
    BinaryOperand.prototype.hasFunction = function () {
        return ((!!this.left && this.left.hasFunction()) ||
            (!!this.right && this.right.hasFunction()));
    };
    BinaryOperand.prototype.hasAsyncFunction = function () {
        return ((!!this.left && this.left.hasAsyncFunction()) ||
            (!!this.right && this.right.hasAsyncFunction()));
    };
    BinaryOperand.prototype.addToAsyncList = function (list) {
        if (!!this.left)
            this.left.addToAsyncList(list);
        if (!!this.right)
            this.right.addToAsyncList(list);
    };
    return BinaryOperand;
}(Operand));

var UnaryOperand = /** @class */ (function (_super) {
    expressions_extends(UnaryOperand, _super);
    function UnaryOperand(expressionValue, operatorName) {
        var _this = _super.call(this) || this;
        _this.expressionValue = expressionValue;
        _this.operatorName = operatorName;
        _this.consumer = expressions_OperandMaker.unaryFunctions[operatorName];
        if (_this.consumer == null) {
            expressions_OperandMaker.throwInvalidOperatorError(operatorName);
        }
        return _this;
    }
    Object.defineProperty(UnaryOperand.prototype, "operator", {
        get: function () {
            return this.operatorName;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(UnaryOperand.prototype, "expression", {
        get: function () {
            return this.expressionValue;
        },
        enumerable: false,
        configurable: true
    });
    UnaryOperand.prototype.getType = function () {
        return "unary";
    };
    UnaryOperand.prototype.toString = function (func) {
        if (func === void 0) { func = undefined; }
        if (!!func) {
            var res = func(this);
            if (!!res)
                return res;
        }
        return (expressions_OperandMaker.operatorToString(this.operatorName) +
            " " +
            this.expression.toString(func));
    };
    UnaryOperand.prototype.isContentEqual = function (op) {
        var uOp = op;
        return uOp.operator == this.operator && this.areOperatorsEquals(this.expression, uOp.expression);
    };
    UnaryOperand.prototype.hasFunction = function () {
        return this.expression.hasFunction();
    };
    UnaryOperand.prototype.hasAsyncFunction = function () {
        return this.expression.hasAsyncFunction();
    };
    UnaryOperand.prototype.addToAsyncList = function (list) {
        this.expression.addToAsyncList(list);
    };
    UnaryOperand.prototype.evaluate = function (processValue) {
        var value = this.expression.evaluate(processValue);
        return this.consumer.call(this, value);
    };
    UnaryOperand.prototype.setVariables = function (variables) {
        this.expression.setVariables(variables);
    };
    return UnaryOperand;
}(Operand));

var ArrayOperand = /** @class */ (function (_super) {
    expressions_extends(ArrayOperand, _super);
    function ArrayOperand(values) {
        var _this = _super.call(this) || this;
        _this.values = values;
        return _this;
    }
    ArrayOperand.prototype.getType = function () {
        return "array";
    };
    ArrayOperand.prototype.toString = function (func) {
        if (func === void 0) { func = undefined; }
        if (!!func) {
            var res = func(this);
            if (!!res)
                return res;
        }
        return ("[" +
            this.values
                .map(function (el) {
                return el.toString(func);
            })
                .join(", ") +
            "]");
    };
    ArrayOperand.prototype.evaluate = function (processValue) {
        return this.values.map(function (el) {
            return el.evaluate(processValue);
        });
    };
    ArrayOperand.prototype.setVariables = function (variables) {
        this.values.forEach(function (el) {
            el.setVariables(variables);
        });
    };
    ArrayOperand.prototype.hasFunction = function () {
        return this.values.some(function (operand) { return operand.hasFunction(); });
    };
    ArrayOperand.prototype.hasAsyncFunction = function () {
        return this.values.some(function (operand) { return operand.hasAsyncFunction(); });
    };
    ArrayOperand.prototype.addToAsyncList = function (list) {
        this.values.forEach(function (operand) { return operand.addToAsyncList(list); });
    };
    ArrayOperand.prototype.isContentEqual = function (op) {
        var aOp = op;
        if (aOp.values.length !== this.values.length)
            return false;
        for (var i = 0; i < this.values.length; i++) {
            if (!aOp.values[i].isEqual(this.values[i]))
                return false;
        }
        return true;
    };
    return ArrayOperand;
}(Operand));

var expressions_Const = /** @class */ (function (_super) {
    expressions_extends(Const, _super);
    function Const(value) {
        var _this = _super.call(this) || this;
        _this.value = value;
        return _this;
    }
    Const.prototype.getType = function () {
        return "const";
    };
    Const.prototype.toString = function (func) {
        if (func === void 0) { func = undefined; }
        if (!!func) {
            var res = func(this);
            if (!!res)
                return res;
        }
        return this.value.toString();
    };
    Object.defineProperty(Const.prototype, "correctValue", {
        get: function () {
            return this.getCorrectValue(this.value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Const.prototype, "requireStrictCompare", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Const.prototype.evaluate = function () {
        return this.getCorrectValue(this.value);
    };
    Const.prototype.setVariables = function (variables) { };
    Const.prototype.getCorrectValue = function (value) {
        if (!value || typeof value != "string")
            return value;
        if (expressions_OperandMaker.isBooleanValue(value))
            return value.toLowerCase() === "true";
        if (value.length > 1 &&
            this.isQuote(value[0]) &&
            this.isQuote(value[value.length - 1]))
            return value.substring(1, value.length - 1);
        if (helpers_Helpers.isNumber(value)) {
            if (value[0] === "0" && value.indexOf("0x") != 0) {
                var len = value.length;
                var hasPoint = len > 1 && (value[1] === "." || value[1] === ",");
                if (!hasPoint && len > 1 || hasPoint && len < 2)
                    return value;
            }
            return helpers_Helpers.getNumber(value);
        }
        return value;
    };
    Const.prototype.isContentEqual = function (op) {
        var cOp = op;
        return cOp.value == this.value;
    };
    Const.prototype.isQuote = function (ch) {
        return ch == "'" || ch == '"';
    };
    return Const;
}(Operand));

var expressions_Variable = /** @class */ (function (_super) {
    expressions_extends(Variable, _super);
    function Variable(variableName) {
        var _this = _super.call(this, variableName) || this;
        _this.variableName = variableName;
        _this.valueInfo = {};
        _this.useValueAsItIs = false;
        if (!!_this.variableName &&
            _this.variableName.length > 1 &&
            _this.variableName[0] === Variable.DisableConversionChar) {
            _this.variableName = _this.variableName.substring(1);
            _this.useValueAsItIs = true;
        }
        return _this;
    }
    Object.defineProperty(Variable, "DisableConversionChar", {
        get: function () { return settings.expressionDisableConversionChar; },
        set: function (val) { settings.expressionDisableConversionChar = val; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Variable.prototype, "requireStrictCompare", {
        get: function () {
            return this.valueInfo.sctrictCompare === true;
        },
        enumerable: false,
        configurable: true
    });
    Variable.prototype.getType = function () {
        return "variable";
    };
    Variable.prototype.toString = function (func) {
        if (func === void 0) { func = undefined; }
        if (!!func) {
            var res = func(this);
            if (!!res)
                return res;
        }
        var prefix = this.useValueAsItIs ? Variable.DisableConversionChar : "";
        return "{" + prefix + this.variableName + "}";
    };
    Object.defineProperty(Variable.prototype, "variable", {
        get: function () {
            return this.variableName;
        },
        enumerable: false,
        configurable: true
    });
    Variable.prototype.evaluate = function (processValue) {
        this.valueInfo.name = this.variableName;
        processValue.getValueInfo(this.valueInfo);
        return this.valueInfo.hasValue
            ? this.getCorrectValue(this.valueInfo.value)
            : null;
    };
    Variable.prototype.setVariables = function (variables) {
        variables.push(this.variableName);
    };
    Variable.prototype.getCorrectValue = function (value) {
        if (this.useValueAsItIs)
            return value;
        return _super.prototype.getCorrectValue.call(this, value);
    };
    Variable.prototype.isContentEqual = function (op) {
        var vOp = op;
        return vOp.variable == this.variable;
    };
    return Variable;
}(expressions_Const));

var expressions_FunctionOperand = /** @class */ (function (_super) {
    expressions_extends(FunctionOperand, _super);
    function FunctionOperand(originalValue, parameters) {
        var _this = _super.call(this) || this;
        _this.originalValue = originalValue;
        _this.parameters = parameters;
        _this.isReadyValue = false;
        if (Array.isArray(parameters) && parameters.length === 0) {
            _this.parameters = new ArrayOperand([]);
        }
        return _this;
    }
    FunctionOperand.prototype.getType = function () {
        return "function";
    };
    FunctionOperand.prototype.evaluateAsync = function (processValue) {
        var _this = this;
        this.isReadyValue = false;
        var asyncProcessValue = new conditionProcessValue_ProcessValue();
        asyncProcessValue.values = helpers_Helpers.createCopy(processValue.values);
        asyncProcessValue.properties = helpers_Helpers.createCopy(processValue.properties);
        asyncProcessValue.properties.returnResult = function (result) {
            _this.asynResult = result;
            _this.isReadyValue = true;
            _this.onAsyncReady();
        };
        this.evaluateCore(asyncProcessValue);
    };
    FunctionOperand.prototype.evaluate = function (processValue) {
        if (this.isReady)
            return this.asynResult;
        return this.evaluateCore(processValue);
    };
    FunctionOperand.prototype.evaluateCore = function (processValue) {
        return functionsfactory_FunctionFactory.Instance.run(this.originalValue, this.parameters.evaluate(processValue), processValue.properties, this.parameters.values);
    };
    FunctionOperand.prototype.toString = function (func) {
        if (func === void 0) { func = undefined; }
        if (!!func) {
            var res = func(this);
            if (!!res)
                return res;
        }
        return this.originalValue + "(" + this.parameters.toString(func) + ")";
    };
    FunctionOperand.prototype.setVariables = function (variables) {
        this.parameters.setVariables(variables);
    };
    Object.defineProperty(FunctionOperand.prototype, "isReady", {
        get: function () {
            return this.isReadyValue;
        },
        enumerable: false,
        configurable: true
    });
    FunctionOperand.prototype.hasFunction = function () {
        return true;
    };
    FunctionOperand.prototype.hasAsyncFunction = function () {
        return this.isAsyncFunction() || this.parameters.hasAsyncFunction();
    };
    FunctionOperand.prototype.isAsyncFunction = function () {
        return functionsfactory_FunctionFactory.Instance.isAsyncFunction(this.originalValue);
    };
    FunctionOperand.prototype.addToAsyncList = function (list) {
        var item = undefined;
        if (this.isAsyncFunction()) {
            item = { operand: this };
        }
        if (this.parameters.hasAsyncFunction()) {
            var children = new Array();
            this.parameters.addToAsyncList(children);
            children.forEach(function (child) { return child.parent = item; });
            if (!item) {
                item = {};
            }
            item.children = children;
        }
        if (item) {
            list.push(item);
        }
    };
    FunctionOperand.prototype.isContentEqual = function (op) {
        var fOp = op;
        return fOp.originalValue == this.originalValue && this.areOperatorsEquals(fOp.parameters, this.parameters);
    };
    return FunctionOperand;
}(Operand));

var expressions_OperandMaker = /** @class */ (function () {
    function OperandMaker() {
    }
    OperandMaker.throwInvalidOperatorError = function (op) {
        throw new Error("Invalid operator: '" + op + "'");
    };
    OperandMaker.safeToString = function (operand, func) {
        return operand == null ? "" : operand.toString(func);
    };
    OperandMaker.toOperandString = function (value) {
        if (!!value &&
            !helpers_Helpers.isNumber(value) &&
            !OperandMaker.isBooleanValue(value))
            value = "'" + value + "'";
        return value;
    };
    OperandMaker.isBooleanValue = function (value) {
        return (!!value &&
            (value.toLowerCase() === "true" || value.toLowerCase() === "false"));
    };
    OperandMaker.countDecimals = function (value) {
        if (helpers_Helpers.isNumber(value) && Math.floor(value) !== value) {
            var strs = value.toString().split(".");
            return strs.length > 1 && strs[1].length || 0;
        }
        return 0;
    };
    OperandMaker.plusMinus = function (a, b, res) {
        var digitsA = OperandMaker.countDecimals(a);
        var digitsB = OperandMaker.countDecimals(b);
        if (digitsA > 0 || digitsB > 0) {
            var digits = Math.max(digitsA, digitsB);
            res = parseFloat(res.toFixed(digits));
        }
        return res;
    };
    OperandMaker.isTwoValueEquals = function (x, y, ignoreOrder) {
        if (ignoreOrder === void 0) { ignoreOrder = true; }
        if (x === "undefined")
            x = undefined;
        if (y === "undefined")
            y = undefined;
        return helpers_Helpers.isTwoValueEquals(x, y, ignoreOrder);
    };
    OperandMaker.operatorToString = function (operatorName) {
        var opStr = OperandMaker.signs[operatorName];
        return opStr == null ? operatorName : opStr;
    };
    OperandMaker.convertValForDateCompare = function (val, second) {
        if (second instanceof Date && typeof val === "string") {
            var res = new Date(val);
            res.setHours(0, 0, 0);
            return res;
        }
        return val;
    };
    OperandMaker.unaryFunctions = {
        empty: function (value) {
            return helpers_Helpers.isValueEmpty(value);
        },
        notempty: function (value) {
            return !OperandMaker.unaryFunctions.empty(value);
        },
        negate: function (value) {
            return !value;
        },
    };
    OperandMaker.binaryFunctions = {
        arithmeticOp: function (operatorName) {
            var convertForArithmeticOp = function (val, second) {
                if (!helpers_Helpers.isValueEmpty(val))
                    return val;
                if (typeof second === "number")
                    return 0;
                if (typeof val === "string")
                    return val;
                if (typeof second === "string")
                    return "";
                if (Array.isArray(second))
                    return [];
                return 0;
            };
            return function (a, b) {
                a = convertForArithmeticOp(a, b);
                b = convertForArithmeticOp(b, a);
                var consumer = OperandMaker.binaryFunctions[operatorName];
                return consumer == null ? null : consumer.call(this, a, b);
            };
        },
        and: function (a, b) {
            return a && b;
        },
        or: function (a, b) {
            return a || b;
        },
        plus: function (a, b) {
            return helpers_Helpers.sumAnyValues(a, b);
        },
        minus: function (a, b) {
            return helpers_Helpers.correctAfterPlusMinis(a, b, a - b);
        },
        mul: function (a, b) {
            return helpers_Helpers.correctAfterMultiple(a, b, a * b);
        },
        div: function (a, b) {
            if (!b)
                return null;
            return a / b;
        },
        mod: function (a, b) {
            if (!b)
                return null;
            return a % b;
        },
        power: function (a, b) {
            return Math.pow(a, b);
        },
        greater: function (left, right) {
            if (left == null || right == null)
                return false;
            left = OperandMaker.convertValForDateCompare(left, right);
            right = OperandMaker.convertValForDateCompare(right, left);
            return left > right;
        },
        less: function (left, right) {
            if (left == null || right == null)
                return false;
            left = OperandMaker.convertValForDateCompare(left, right);
            right = OperandMaker.convertValForDateCompare(right, left);
            return left < right;
        },
        greaterorequal: function (left, right) {
            if (OperandMaker.binaryFunctions.equal(left, right))
                return true;
            return OperandMaker.binaryFunctions.greater(left, right);
        },
        lessorequal: function (left, right) {
            if (OperandMaker.binaryFunctions.equal(left, right))
                return true;
            return OperandMaker.binaryFunctions.less(left, right);
        },
        equal: function (left, right, strictCompare) {
            left = OperandMaker.convertValForDateCompare(left, right);
            right = OperandMaker.convertValForDateCompare(right, left);
            return OperandMaker.isTwoValueEquals(left, right, strictCompare !== true);
        },
        notequal: function (left, right, strictCompare) {
            return !OperandMaker.binaryFunctions.equal(left, right, strictCompare);
        },
        contains: function (left, right) {
            return OperandMaker.binaryFunctions.containsCore(left, right, true);
        },
        notcontains: function (left, right) {
            if (!left && !helpers_Helpers.isValueEmpty(right))
                return true;
            return OperandMaker.binaryFunctions.containsCore(left, right, false);
        },
        anyof: function (left, right) {
            if (helpers_Helpers.isValueEmpty(left) && helpers_Helpers.isValueEmpty(right))
                return true;
            if (helpers_Helpers.isValueEmpty(left) ||
                (!Array.isArray(left) && left.length === 0))
                return false;
            if (helpers_Helpers.isValueEmpty(right))
                return true;
            if (!Array.isArray(left))
                return OperandMaker.binaryFunctions.contains(right, left);
            if (!Array.isArray(right))
                return OperandMaker.binaryFunctions.contains(left, right);
            for (var i = 0; i < right.length; i++) {
                if (OperandMaker.binaryFunctions.contains(left, right[i]))
                    return true;
            }
            return false;
        },
        allof: function (left, right) {
            if (!left && !helpers_Helpers.isValueEmpty(right))
                return false;
            if (!Array.isArray(right))
                return OperandMaker.binaryFunctions.contains(left, right);
            for (var i = 0; i < right.length; i++) {
                if (!OperandMaker.binaryFunctions.contains(left, right[i]))
                    return false;
            }
            return true;
        },
        containsCore: function (left, right, isContains) {
            if (!left && left !== 0 && left !== false)
                return false;
            if (!left.length) {
                left = left.toString();
                if (typeof right === "string" || right instanceof String) {
                    left = left.toUpperCase();
                    right = right.toUpperCase();
                }
            }
            if (typeof left === "string" || left instanceof String) {
                if (!right)
                    return false;
                right = right.toString();
                var found = left.indexOf(right) > -1;
                return isContains ? found : !found;
            }
            var rightArray = Array.isArray(right) ? right : [right];
            for (var rIndex = 0; rIndex < rightArray.length; rIndex++) {
                var i = 0;
                right = rightArray[rIndex];
                for (; i < left.length; i++) {
                    if (OperandMaker.isTwoValueEquals(left[i], right))
                        break;
                }
                if (i == left.length)
                    return !isContains;
            }
            return isContains;
        },
    };
    OperandMaker.signs = {
        less: "<",
        lessorequal: "<=",
        greater: ">",
        greaterorequal: ">=",
        equal: "==",
        notequal: "!=",
        plus: "+",
        minus: "-",
        mul: "*",
        div: "/",
        and: "and",
        or: "or",
        power: "^",
        mod: "%",
        negate: "!",
    };
    return OperandMaker;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/expressions/expressionParser.ts
var expressionParser_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/* eslint-disable */

// Generated by PEG.js v. 0.10.0 (ts-pegjs plugin v. 0.3.1 )
//
// https://pegjs.org/   https://github.com/metadevpro/ts-pegjs
"use strict";
var SyntaxError = /** @class */ (function (_super) {
    expressionParser_extends(SyntaxError, _super);
    function SyntaxError(message, expected, found, location) {
        var _this = _super.call(this) || this;
        _this.message = message;
        _this.expected = expected;
        _this.found = found;
        _this.location = location;
        _this.name = "SyntaxError";
        if (typeof Error.captureStackTrace === "function") {
            Error.captureStackTrace(_this, SyntaxError);
        }
        return _this;
    }
    SyntaxError.buildMessage = function (expected, found) {
        function hex(ch) {
            return ch.charCodeAt(0).toString(16).toUpperCase();
        }
        function literalEscape(s) {
            return s
                .replace(/\\/g, "\\\\")
                .replace(/"/g, "\\\"")
                .replace(/\0/g, "\\0")
                .replace(/\t/g, "\\t")
                .replace(/\n/g, "\\n")
                .replace(/\r/g, "\\r")
                .replace(/[\x00-\x0F]/g, function (ch) { return "\\x0" + hex(ch); })
                .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return "\\x" + hex(ch); });
        }
        function classEscape(s) {
            return s
                .replace(/\\/g, "\\\\")
                .replace(/\]/g, "\\]")
                .replace(/\^/g, "\\^")
                .replace(/-/g, "\\-")
                .replace(/\0/g, "\\0")
                .replace(/\t/g, "\\t")
                .replace(/\n/g, "\\n")
                .replace(/\r/g, "\\r")
                .replace(/[\x00-\x0F]/g, function (ch) { return "\\x0" + hex(ch); })
                .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return "\\x" + hex(ch); });
        }
        function describeExpectation(expectation) {
            switch (expectation.type) {
                case "literal":
                    return "\"" + literalEscape(expectation.text) + "\"";
                case "class":
                    var escapedParts = expectation.parts.map(function (part) {
                        return Array.isArray(part)
                            ? classEscape(part[0]) + "-" + classEscape(part[1])
                            : classEscape(part);
                    });
                    return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
                case "any":
                    return "any character";
                case "end":
                    return "end of input";
                case "other":
                    return expectation.description;
            }
        }
        function describeExpected(expected1) {
            var descriptions = expected1.map(describeExpectation);
            var i;
            var j;
            descriptions.sort();
            if (descriptions.length > 0) {
                for (i = 1, j = 1; i < descriptions.length; i++) {
                    if (descriptions[i - 1] !== descriptions[i]) {
                        descriptions[j] = descriptions[i];
                        j++;
                    }
                }
                descriptions.length = j;
            }
            switch (descriptions.length) {
                case 1:
                    return descriptions[0];
                case 2:
                    return descriptions[0] + " or " + descriptions[1];
                default:
                    return descriptions.slice(0, -1).join(", ")
                        + ", or "
                        + descriptions[descriptions.length - 1];
            }
        }
        function describeFound(found1) {
            return found1 ? "\"" + literalEscape(found1) + "\"" : "end of input";
        }
        return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
    };
    return SyntaxError;
}(Error));

function peg$parse(input, options) {
    options = options !== undefined ? options : {};
    var peg$FAILED = {};
    var peg$startRuleFunctions = { Expression: peg$parseExpression };
    var peg$startRuleFunction = peg$parseExpression;
    var peg$c0 = function (head, tail) {
        return buildBinaryOperand(head, tail, true);
    };
    var peg$c1 = "||";
    var peg$c2 = peg$literalExpectation("||", false);
    var peg$c3 = "or";
    var peg$c4 = peg$literalExpectation("or", true);
    var peg$c5 = function () { return "or"; };
    var peg$c6 = "&&";
    var peg$c7 = peg$literalExpectation("&&", false);
    var peg$c8 = "and";
    var peg$c9 = peg$literalExpectation("and", true);
    var peg$c10 = function () { return "and"; };
    var peg$c11 = function (head, tail) {
        return buildBinaryOperand(head, tail);
    };
    var peg$c12 = "<=";
    var peg$c13 = peg$literalExpectation("<=", false);
    var peg$c14 = "lessorequal";
    var peg$c15 = peg$literalExpectation("lessorequal", true);
    var peg$c16 = function () { return "lessorequal"; };
    var peg$c17 = ">=";
    var peg$c18 = peg$literalExpectation(">=", false);
    var peg$c19 = "greaterorequal";
    var peg$c20 = peg$literalExpectation("greaterorequal", true);
    var peg$c21 = function () { return "greaterorequal"; };
    var peg$c22 = "==";
    var peg$c23 = peg$literalExpectation("==", false);
    var peg$c24 = "equal";
    var peg$c25 = peg$literalExpectation("equal", true);
    var peg$c26 = function () { return "equal"; };
    var peg$c27 = "=";
    var peg$c28 = peg$literalExpectation("=", false);
    var peg$c29 = "!=";
    var peg$c30 = peg$literalExpectation("!=", false);
    var peg$c31 = "notequal";
    var peg$c32 = peg$literalExpectation("notequal", true);
    var peg$c33 = function () { return "notequal"; };
    var peg$c34 = "<";
    var peg$c35 = peg$literalExpectation("<", false);
    var peg$c36 = "less";
    var peg$c37 = peg$literalExpectation("less", true);
    var peg$c38 = function () { return "less"; };
    var peg$c39 = ">";
    var peg$c40 = peg$literalExpectation(">", false);
    var peg$c41 = "greater";
    var peg$c42 = peg$literalExpectation("greater", true);
    var peg$c43 = function () { return "greater"; };
    var peg$c44 = "+";
    var peg$c45 = peg$literalExpectation("+", false);
    var peg$c46 = function () { return "plus"; };
    var peg$c47 = "-";
    var peg$c48 = peg$literalExpectation("-", false);
    var peg$c49 = function () { return "minus"; };
    var peg$c50 = "*";
    var peg$c51 = peg$literalExpectation("*", false);
    var peg$c52 = function () { return "mul"; };
    var peg$c53 = "/";
    var peg$c54 = peg$literalExpectation("/", false);
    var peg$c55 = function () { return "div"; };
    var peg$c56 = "%";
    var peg$c57 = peg$literalExpectation("%", false);
    var peg$c58 = function () { return "mod"; };
    var peg$c59 = "^";
    var peg$c60 = peg$literalExpectation("^", false);
    var peg$c61 = "power";
    var peg$c62 = peg$literalExpectation("power", true);
    var peg$c63 = function () { return "power"; };
    var peg$c64 = "*=";
    var peg$c65 = peg$literalExpectation("*=", false);
    var peg$c66 = "contains";
    var peg$c67 = peg$literalExpectation("contains", true);
    var peg$c68 = "contain";
    var peg$c69 = peg$literalExpectation("contain", true);
    var peg$c70 = function () { return "contains"; };
    var peg$c71 = "notcontains";
    var peg$c72 = peg$literalExpectation("notcontains", true);
    var peg$c73 = "notcontain";
    var peg$c74 = peg$literalExpectation("notcontain", true);
    var peg$c75 = function () { return "notcontains"; };
    var peg$c76 = "anyof";
    var peg$c77 = peg$literalExpectation("anyof", true);
    var peg$c78 = function () { return "anyof"; };
    var peg$c79 = "allof";
    var peg$c80 = peg$literalExpectation("allof", true);
    var peg$c81 = function () { return "allof"; };
    var peg$c82 = "(";
    var peg$c83 = peg$literalExpectation("(", false);
    var peg$c84 = ")";
    var peg$c85 = peg$literalExpectation(")", false);
    var peg$c86 = function (expr) { return expr; };
    var peg$c87 = function (name, params) { return new expressions_FunctionOperand(name, params); };
    var peg$c88 = "!";
    var peg$c89 = peg$literalExpectation("!", false);
    var peg$c90 = "negate";
    var peg$c91 = peg$literalExpectation("negate", true);
    var peg$c92 = function (expr) { return new UnaryOperand(expr, "negate"); };
    var peg$c93 = function (expr, op) { return new UnaryOperand(expr, op); };
    var peg$c94 = "empty";
    var peg$c95 = peg$literalExpectation("empty", true);
    var peg$c96 = function () { return "empty"; };
    var peg$c97 = "notempty";
    var peg$c98 = peg$literalExpectation("notempty", true);
    var peg$c99 = function () { return "notempty"; };
    var peg$c100 = "undefined";
    var peg$c101 = peg$literalExpectation("undefined", false);
    var peg$c102 = "null";
    var peg$c103 = peg$literalExpectation("null", false);
    var peg$c104 = function () { return null; };
    var peg$c105 = function (value) { return new expressions_Const(value); };
    var peg$c106 = "{";
    var peg$c107 = peg$literalExpectation("{", false);
    var peg$c108 = "}";
    var peg$c109 = peg$literalExpectation("}", false);
    var peg$c110 = function (value) { return new expressions_Variable(value); };
    var peg$c111 = function (value) { return value; };
    var peg$c112 = "''";
    var peg$c113 = peg$literalExpectation("''", false);
    var peg$c114 = function () { return ""; };
    var peg$c115 = "\"\"";
    var peg$c116 = peg$literalExpectation("\"\"", false);
    var peg$c117 = "'";
    var peg$c118 = peg$literalExpectation("'", false);
    var peg$c119 = function (value) { return "'" + value + "'"; };
    var peg$c120 = "\"";
    var peg$c121 = peg$literalExpectation("\"", false);
    var peg$c122 = "[";
    var peg$c123 = peg$literalExpectation("[", false);
    var peg$c124 = "]";
    var peg$c125 = peg$literalExpectation("]", false);
    var peg$c126 = function (sequence) { return sequence; };
    var peg$c127 = ",";
    var peg$c128 = peg$literalExpectation(",", false);
    var peg$c129 = function (expr, tail) {
        if (expr == null)
            return new ArrayOperand([]);
        var array = [expr];
        if (Array.isArray(tail)) {
            var flatten = flattenArray(tail);
            for (var i = 3; i < flatten.length; i += 4) {
                array.push(flatten[i]);
            }
        }
        return new ArrayOperand(array);
    };
    var peg$c130 = "true";
    var peg$c131 = peg$literalExpectation("true", true);
    var peg$c132 = function () { return true; };
    var peg$c133 = "false";
    var peg$c134 = peg$literalExpectation("false", true);
    var peg$c135 = function () { return false; };
    var peg$c136 = "0x";
    var peg$c137 = peg$literalExpectation("0x", false);
    var peg$c138 = function () { return parseInt(text(), 16); };
    var peg$c139 = /^[\-]/;
    var peg$c140 = peg$classExpectation(["-"], false, false);
    var peg$c141 = function (sign, num) { return sign == null ? num : -num; };
    var peg$c142 = ".";
    var peg$c143 = peg$literalExpectation(".", false);
    var peg$c144 = function () { return parseFloat(text()); };
    var peg$c145 = function () { return parseInt(text(), 10); };
    var peg$c146 = "0";
    var peg$c147 = peg$literalExpectation("0", false);
    var peg$c148 = function () { return 0; };
    var peg$c149 = function (chars) { return chars.join(""); };
    var peg$c150 = "\\'";
    var peg$c151 = peg$literalExpectation("\\'", false);
    var peg$c152 = function () { return "'"; };
    var peg$c153 = "\\\"";
    var peg$c154 = peg$literalExpectation("\\\"", false);
    var peg$c155 = function () { return "\""; };
    var peg$c156 = /^[^"']/;
    var peg$c157 = peg$classExpectation(["\"", "'"], true, false);
    var peg$c158 = function () { return text(); };
    var peg$c159 = /^[^{}]/;
    var peg$c160 = peg$classExpectation(["{", "}"], true, false);
    var peg$c161 = /^[0-9]/;
    var peg$c162 = peg$classExpectation([["0", "9"]], false, false);
    var peg$c163 = /^[1-9]/;
    var peg$c164 = peg$classExpectation([["1", "9"]], false, false);
    var peg$c165 = /^[a-zA-Z_]/;
    var peg$c166 = peg$classExpectation([["a", "z"], ["A", "Z"], "_"], false, false);
    var peg$c167 = peg$otherExpectation("whitespace");
    var peg$c168 = /^[ \t\n\r]/;
    var peg$c169 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false);
    var peg$currPos = 0;
    var peg$savedPos = 0;
    var peg$posDetailsCache = [{ line: 1, column: 1 }];
    var peg$maxFailPos = 0;
    var peg$maxFailExpected = [];
    var peg$silentFails = 0;
    var peg$resultsCache = {};
    var peg$result;
    if (options.startRule !== undefined) {
        if (!(options.startRule in peg$startRuleFunctions)) {
            throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
        }
        peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
    }
    function text() {
        return input.substring(peg$savedPos, peg$currPos);
    }
    function location() {
        return peg$computeLocation(peg$savedPos, peg$currPos);
    }
    function expected(description, location1) {
        location1 = location1 !== undefined
            ? location1
            : peg$computeLocation(peg$savedPos, peg$currPos);
        throw peg$buildStructuredError([peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location1);
    }
    function error(message, location1) {
        location1 = location1 !== undefined
            ? location1
            : peg$computeLocation(peg$savedPos, peg$currPos);
        throw peg$buildSimpleError(message, location1);
    }
    function peg$literalExpectation(text1, ignoreCase) {
        return { type: "literal", text: text1, ignoreCase: ignoreCase };
    }
    function peg$classExpectation(parts, inverted, ignoreCase) {
        return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
    }
    function peg$anyExpectation() {
        return { type: "any" };
    }
    function peg$endExpectation() {
        return { type: "end" };
    }
    function peg$otherExpectation(description) {
        return { type: "other", description: description };
    }
    function peg$computePosDetails(pos) {
        var details = peg$posDetailsCache[pos];
        var p;
        if (details) {
            return details;
        }
        else {
            p = pos - 1;
            while (!peg$posDetailsCache[p]) {
                p--;
            }
            details = peg$posDetailsCache[p];
            details = {
                line: details.line,
                column: details.column
            };
            while (p < pos) {
                if (input.charCodeAt(p) === 10) {
                    details.line++;
                    details.column = 1;
                }
                else {
                    details.column++;
                }
                p++;
            }
            peg$posDetailsCache[pos] = details;
            return details;
        }
    }
    function peg$computeLocation(startPos, endPos) {
        var startPosDetails = peg$computePosDetails(startPos);
        var endPosDetails = peg$computePosDetails(endPos);
        return {
            start: {
                offset: startPos,
                line: startPosDetails.line,
                column: startPosDetails.column
            },
            end: {
                offset: endPos,
                line: endPosDetails.line,
                column: endPosDetails.column
            }
        };
    }
    function peg$fail(expected1) {
        if (peg$currPos < peg$maxFailPos) {
            return;
        }
        if (peg$currPos > peg$maxFailPos) {
            peg$maxFailPos = peg$currPos;
            peg$maxFailExpected = [];
        }
        peg$maxFailExpected.push(expected1);
    }
    function peg$buildSimpleError(message, location1) {
        return new SyntaxError(message, [], "", location1);
    }
    function peg$buildStructuredError(expected1, found, location1) {
        return new SyntaxError(SyntaxError.buildMessage(expected1, found), expected1, found, location1);
    }
    function peg$parseExpression() {
        var s0, s1, s2, s3, s4, s5, s6, s7, s8;
        var key = peg$currPos * 34 + 0;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        s1 = peg$parse_();
        if (s1 !== peg$FAILED) {
            s2 = peg$parseLogicOr();
            if (s2 !== peg$FAILED) {
                s3 = [];
                s4 = peg$currPos;
                s5 = peg$parse_();
                if (s5 !== peg$FAILED) {
                    s6 = peg$parseOrSign();
                    if (s6 !== peg$FAILED) {
                        s7 = peg$parse_();
                        if (s7 !== peg$FAILED) {
                            s8 = peg$parseLogicOr();
                            if (s8 !== peg$FAILED) {
                                s5 = [s5, s6, s7, s8];
                                s4 = s5;
                            }
                            else {
                                peg$currPos = s4;
                                s4 = peg$FAILED;
                            }
                        }
                        else {
                            peg$currPos = s4;
                            s4 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s4;
                        s4 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s4;
                    s4 = peg$FAILED;
                }
                while (s4 !== peg$FAILED) {
                    s3.push(s4);
                    s4 = peg$currPos;
                    s5 = peg$parse_();
                    if (s5 !== peg$FAILED) {
                        s6 = peg$parseOrSign();
                        if (s6 !== peg$FAILED) {
                            s7 = peg$parse_();
                            if (s7 !== peg$FAILED) {
                                s8 = peg$parseLogicOr();
                                if (s8 !== peg$FAILED) {
                                    s5 = [s5, s6, s7, s8];
                                    s4 = s5;
                                }
                                else {
                                    peg$currPos = s4;
                                    s4 = peg$FAILED;
                                }
                            }
                            else {
                                peg$currPos = s4;
                                s4 = peg$FAILED;
                            }
                        }
                        else {
                            peg$currPos = s4;
                            s4 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s4;
                        s4 = peg$FAILED;
                    }
                }
                if (s3 !== peg$FAILED) {
                    s4 = peg$parse_();
                    if (s4 !== peg$FAILED) {
                        peg$savedPos = s0;
                        s1 = peg$c0(s2, s3);
                        s0 = s1;
                    }
                    else {
                        peg$currPos = s0;
                        s0 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s0;
                    s0 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        else {
            peg$currPos = s0;
            s0 = peg$FAILED;
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseOrSign() {
        var s0, s1;
        var key = peg$currPos * 34 + 1;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        if (input.substr(peg$currPos, 2) === peg$c1) {
            s1 = peg$c1;
            peg$currPos += 2;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c2);
            }
        }
        if (s1 === peg$FAILED) {
            if (input.substr(peg$currPos, 2).toLowerCase() === peg$c3) {
                s1 = input.substr(peg$currPos, 2);
                peg$currPos += 2;
            }
            else {
                s1 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c4);
                }
            }
        }
        if (s1 !== peg$FAILED) {
            peg$savedPos = s0;
            s1 = peg$c5();
        }
        s0 = s1;
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseLogicOr() {
        var s0, s1, s2, s3, s4, s5, s6, s7;
        var key = peg$currPos * 34 + 2;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        s1 = peg$parseLogicAnd();
        if (s1 !== peg$FAILED) {
            s2 = [];
            s3 = peg$currPos;
            s4 = peg$parse_();
            if (s4 !== peg$FAILED) {
                s5 = peg$parseAndSign();
                if (s5 !== peg$FAILED) {
                    s6 = peg$parse_();
                    if (s6 !== peg$FAILED) {
                        s7 = peg$parseLogicAnd();
                        if (s7 !== peg$FAILED) {
                            s4 = [s4, s5, s6, s7];
                            s3 = s4;
                        }
                        else {
                            peg$currPos = s3;
                            s3 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s3;
                        s3 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s3;
                    s3 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s3;
                s3 = peg$FAILED;
            }
            while (s3 !== peg$FAILED) {
                s2.push(s3);
                s3 = peg$currPos;
                s4 = peg$parse_();
                if (s4 !== peg$FAILED) {
                    s5 = peg$parseAndSign();
                    if (s5 !== peg$FAILED) {
                        s6 = peg$parse_();
                        if (s6 !== peg$FAILED) {
                            s7 = peg$parseLogicAnd();
                            if (s7 !== peg$FAILED) {
                                s4 = [s4, s5, s6, s7];
                                s3 = s4;
                            }
                            else {
                                peg$currPos = s3;
                                s3 = peg$FAILED;
                            }
                        }
                        else {
                            peg$currPos = s3;
                            s3 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s3;
                        s3 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s3;
                    s3 = peg$FAILED;
                }
            }
            if (s2 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c0(s1, s2);
                s0 = s1;
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        else {
            peg$currPos = s0;
            s0 = peg$FAILED;
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseAndSign() {
        var s0, s1;
        var key = peg$currPos * 34 + 3;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        if (input.substr(peg$currPos, 2) === peg$c6) {
            s1 = peg$c6;
            peg$currPos += 2;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c7);
            }
        }
        if (s1 === peg$FAILED) {
            if (input.substr(peg$currPos, 3).toLowerCase() === peg$c8) {
                s1 = input.substr(peg$currPos, 3);
                peg$currPos += 3;
            }
            else {
                s1 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c9);
                }
            }
        }
        if (s1 !== peg$FAILED) {
            peg$savedPos = s0;
            s1 = peg$c10();
        }
        s0 = s1;
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseLogicAnd() {
        var s0, s1, s2, s3, s4, s5, s6, s7;
        var key = peg$currPos * 34 + 4;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        s1 = peg$parseCompOps();
        if (s1 !== peg$FAILED) {
            s2 = [];
            s3 = peg$currPos;
            s4 = peg$parse_();
            if (s4 !== peg$FAILED) {
                s5 = peg$parseComparableOperators();
                if (s5 !== peg$FAILED) {
                    s6 = peg$parse_();
                    if (s6 !== peg$FAILED) {
                        s7 = peg$parseCompOps();
                        if (s7 !== peg$FAILED) {
                            s4 = [s4, s5, s6, s7];
                            s3 = s4;
                        }
                        else {
                            peg$currPos = s3;
                            s3 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s3;
                        s3 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s3;
                    s3 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s3;
                s3 = peg$FAILED;
            }
            while (s3 !== peg$FAILED) {
                s2.push(s3);
                s3 = peg$currPos;
                s4 = peg$parse_();
                if (s4 !== peg$FAILED) {
                    s5 = peg$parseComparableOperators();
                    if (s5 !== peg$FAILED) {
                        s6 = peg$parse_();
                        if (s6 !== peg$FAILED) {
                            s7 = peg$parseCompOps();
                            if (s7 !== peg$FAILED) {
                                s4 = [s4, s5, s6, s7];
                                s3 = s4;
                            }
                            else {
                                peg$currPos = s3;
                                s3 = peg$FAILED;
                            }
                        }
                        else {
                            peg$currPos = s3;
                            s3 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s3;
                        s3 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s3;
                    s3 = peg$FAILED;
                }
            }
            if (s2 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c11(s1, s2);
                s0 = s1;
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        else {
            peg$currPos = s0;
            s0 = peg$FAILED;
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseComparableOperators() {
        var s0, s1;
        var key = peg$currPos * 34 + 5;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        if (input.substr(peg$currPos, 2) === peg$c12) {
            s1 = peg$c12;
            peg$currPos += 2;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c13);
            }
        }
        if (s1 === peg$FAILED) {
            if (input.substr(peg$currPos, 11).toLowerCase() === peg$c14) {
                s1 = input.substr(peg$currPos, 11);
                peg$currPos += 11;
            }
            else {
                s1 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c15);
                }
            }
        }
        if (s1 !== peg$FAILED) {
            peg$savedPos = s0;
            s1 = peg$c16();
        }
        s0 = s1;
        if (s0 === peg$FAILED) {
            s0 = peg$currPos;
            if (input.substr(peg$currPos, 2) === peg$c17) {
                s1 = peg$c17;
                peg$currPos += 2;
            }
            else {
                s1 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c18);
                }
            }
            if (s1 === peg$FAILED) {
                if (input.substr(peg$currPos, 14).toLowerCase() === peg$c19) {
                    s1 = input.substr(peg$currPos, 14);
                    peg$currPos += 14;
                }
                else {
                    s1 = peg$FAILED;
                    if (peg$silentFails === 0) {
                        peg$fail(peg$c20);
                    }
                }
            }
            if (s1 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c21();
            }
            s0 = s1;
            if (s0 === peg$FAILED) {
                s0 = peg$currPos;
                if (input.substr(peg$currPos, 2) === peg$c22) {
                    s1 = peg$c22;
                    peg$currPos += 2;
                }
                else {
                    s1 = peg$FAILED;
                    if (peg$silentFails === 0) {
                        peg$fail(peg$c23);
                    }
                }
                if (s1 === peg$FAILED) {
                    if (input.substr(peg$currPos, 5).toLowerCase() === peg$c24) {
                        s1 = input.substr(peg$currPos, 5);
                        peg$currPos += 5;
                    }
                    else {
                        s1 = peg$FAILED;
                        if (peg$silentFails === 0) {
                            peg$fail(peg$c25);
                        }
                    }
                }
                if (s1 !== peg$FAILED) {
                    peg$savedPos = s0;
                    s1 = peg$c26();
                }
                s0 = s1;
                if (s0 === peg$FAILED) {
                    s0 = peg$currPos;
                    if (input.charCodeAt(peg$currPos) === 61) {
                        s1 = peg$c27;
                        peg$currPos++;
                    }
                    else {
                        s1 = peg$FAILED;
                        if (peg$silentFails === 0) {
                            peg$fail(peg$c28);
                        }
                    }
                    if (s1 === peg$FAILED) {
                        if (input.substr(peg$currPos, 5).toLowerCase() === peg$c24) {
                            s1 = input.substr(peg$currPos, 5);
                            peg$currPos += 5;
                        }
                        else {
                            s1 = peg$FAILED;
                            if (peg$silentFails === 0) {
                                peg$fail(peg$c25);
                            }
                        }
                    }
                    if (s1 !== peg$FAILED) {
                        peg$savedPos = s0;
                        s1 = peg$c26();
                    }
                    s0 = s1;
                    if (s0 === peg$FAILED) {
                        s0 = peg$currPos;
                        if (input.substr(peg$currPos, 2) === peg$c29) {
                            s1 = peg$c29;
                            peg$currPos += 2;
                        }
                        else {
                            s1 = peg$FAILED;
                            if (peg$silentFails === 0) {
                                peg$fail(peg$c30);
                            }
                        }
                        if (s1 === peg$FAILED) {
                            if (input.substr(peg$currPos, 8).toLowerCase() === peg$c31) {
                                s1 = input.substr(peg$currPos, 8);
                                peg$currPos += 8;
                            }
                            else {
                                s1 = peg$FAILED;
                                if (peg$silentFails === 0) {
                                    peg$fail(peg$c32);
                                }
                            }
                        }
                        if (s1 !== peg$FAILED) {
                            peg$savedPos = s0;
                            s1 = peg$c33();
                        }
                        s0 = s1;
                        if (s0 === peg$FAILED) {
                            s0 = peg$currPos;
                            if (input.charCodeAt(peg$currPos) === 60) {
                                s1 = peg$c34;
                                peg$currPos++;
                            }
                            else {
                                s1 = peg$FAILED;
                                if (peg$silentFails === 0) {
                                    peg$fail(peg$c35);
                                }
                            }
                            if (s1 === peg$FAILED) {
                                if (input.substr(peg$currPos, 4).toLowerCase() === peg$c36) {
                                    s1 = input.substr(peg$currPos, 4);
                                    peg$currPos += 4;
                                }
                                else {
                                    s1 = peg$FAILED;
                                    if (peg$silentFails === 0) {
                                        peg$fail(peg$c37);
                                    }
                                }
                            }
                            if (s1 !== peg$FAILED) {
                                peg$savedPos = s0;
                                s1 = peg$c38();
                            }
                            s0 = s1;
                            if (s0 === peg$FAILED) {
                                s0 = peg$currPos;
                                if (input.charCodeAt(peg$currPos) === 62) {
                                    s1 = peg$c39;
                                    peg$currPos++;
                                }
                                else {
                                    s1 = peg$FAILED;
                                    if (peg$silentFails === 0) {
                                        peg$fail(peg$c40);
                                    }
                                }
                                if (s1 === peg$FAILED) {
                                    if (input.substr(peg$currPos, 7).toLowerCase() === peg$c41) {
                                        s1 = input.substr(peg$currPos, 7);
                                        peg$currPos += 7;
                                    }
                                    else {
                                        s1 = peg$FAILED;
                                        if (peg$silentFails === 0) {
                                            peg$fail(peg$c42);
                                        }
                                    }
                                }
                                if (s1 !== peg$FAILED) {
                                    peg$savedPos = s0;
                                    s1 = peg$c43();
                                }
                                s0 = s1;
                            }
                        }
                    }
                }
            }
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseCompOps() {
        var s0, s1, s2, s3, s4, s5, s6, s7;
        var key = peg$currPos * 34 + 6;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        s1 = peg$parsePlusMinusOps();
        if (s1 !== peg$FAILED) {
            s2 = [];
            s3 = peg$currPos;
            s4 = peg$parse_();
            if (s4 !== peg$FAILED) {
                s5 = peg$parsePlusMinusSigns();
                if (s5 !== peg$FAILED) {
                    s6 = peg$parse_();
                    if (s6 !== peg$FAILED) {
                        s7 = peg$parsePlusMinusOps();
                        if (s7 !== peg$FAILED) {
                            s4 = [s4, s5, s6, s7];
                            s3 = s4;
                        }
                        else {
                            peg$currPos = s3;
                            s3 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s3;
                        s3 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s3;
                    s3 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s3;
                s3 = peg$FAILED;
            }
            while (s3 !== peg$FAILED) {
                s2.push(s3);
                s3 = peg$currPos;
                s4 = peg$parse_();
                if (s4 !== peg$FAILED) {
                    s5 = peg$parsePlusMinusSigns();
                    if (s5 !== peg$FAILED) {
                        s6 = peg$parse_();
                        if (s6 !== peg$FAILED) {
                            s7 = peg$parsePlusMinusOps();
                            if (s7 !== peg$FAILED) {
                                s4 = [s4, s5, s6, s7];
                                s3 = s4;
                            }
                            else {
                                peg$currPos = s3;
                                s3 = peg$FAILED;
                            }
                        }
                        else {
                            peg$currPos = s3;
                            s3 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s3;
                        s3 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s3;
                    s3 = peg$FAILED;
                }
            }
            if (s2 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c0(s1, s2);
                s0 = s1;
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        else {
            peg$currPos = s0;
            s0 = peg$FAILED;
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parsePlusMinusSigns() {
        var s0, s1;
        var key = peg$currPos * 34 + 7;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        if (input.charCodeAt(peg$currPos) === 43) {
            s1 = peg$c44;
            peg$currPos++;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c45);
            }
        }
        if (s1 !== peg$FAILED) {
            peg$savedPos = s0;
            s1 = peg$c46();
        }
        s0 = s1;
        if (s0 === peg$FAILED) {
            s0 = peg$currPos;
            if (input.charCodeAt(peg$currPos) === 45) {
                s1 = peg$c47;
                peg$currPos++;
            }
            else {
                s1 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c48);
                }
            }
            if (s1 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c49();
            }
            s0 = s1;
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parsePlusMinusOps() {
        var s0, s1, s2, s3, s4, s5, s6, s7;
        var key = peg$currPos * 34 + 8;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        s1 = peg$parseMulDivOps();
        if (s1 !== peg$FAILED) {
            s2 = [];
            s3 = peg$currPos;
            s4 = peg$parse_();
            if (s4 !== peg$FAILED) {
                s5 = peg$parseMulDivSigns();
                if (s5 !== peg$FAILED) {
                    s6 = peg$parse_();
                    if (s6 !== peg$FAILED) {
                        s7 = peg$parseMulDivOps();
                        if (s7 !== peg$FAILED) {
                            s4 = [s4, s5, s6, s7];
                            s3 = s4;
                        }
                        else {
                            peg$currPos = s3;
                            s3 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s3;
                        s3 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s3;
                    s3 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s3;
                s3 = peg$FAILED;
            }
            while (s3 !== peg$FAILED) {
                s2.push(s3);
                s3 = peg$currPos;
                s4 = peg$parse_();
                if (s4 !== peg$FAILED) {
                    s5 = peg$parseMulDivSigns();
                    if (s5 !== peg$FAILED) {
                        s6 = peg$parse_();
                        if (s6 !== peg$FAILED) {
                            s7 = peg$parseMulDivOps();
                            if (s7 !== peg$FAILED) {
                                s4 = [s4, s5, s6, s7];
                                s3 = s4;
                            }
                            else {
                                peg$currPos = s3;
                                s3 = peg$FAILED;
                            }
                        }
                        else {
                            peg$currPos = s3;
                            s3 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s3;
                        s3 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s3;
                    s3 = peg$FAILED;
                }
            }
            if (s2 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c0(s1, s2);
                s0 = s1;
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        else {
            peg$currPos = s0;
            s0 = peg$FAILED;
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseMulDivSigns() {
        var s0, s1;
        var key = peg$currPos * 34 + 9;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        if (input.charCodeAt(peg$currPos) === 42) {
            s1 = peg$c50;
            peg$currPos++;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c51);
            }
        }
        if (s1 !== peg$FAILED) {
            peg$savedPos = s0;
            s1 = peg$c52();
        }
        s0 = s1;
        if (s0 === peg$FAILED) {
            s0 = peg$currPos;
            if (input.charCodeAt(peg$currPos) === 47) {
                s1 = peg$c53;
                peg$currPos++;
            }
            else {
                s1 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c54);
                }
            }
            if (s1 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c55();
            }
            s0 = s1;
            if (s0 === peg$FAILED) {
                s0 = peg$currPos;
                if (input.charCodeAt(peg$currPos) === 37) {
                    s1 = peg$c56;
                    peg$currPos++;
                }
                else {
                    s1 = peg$FAILED;
                    if (peg$silentFails === 0) {
                        peg$fail(peg$c57);
                    }
                }
                if (s1 !== peg$FAILED) {
                    peg$savedPos = s0;
                    s1 = peg$c58();
                }
                s0 = s1;
            }
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseMulDivOps() {
        var s0, s1, s2, s3, s4, s5, s6, s7;
        var key = peg$currPos * 34 + 10;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        s1 = peg$parseBinaryFuncOp();
        if (s1 !== peg$FAILED) {
            s2 = [];
            s3 = peg$currPos;
            s4 = peg$parse_();
            if (s4 !== peg$FAILED) {
                s5 = peg$parsePowerSigns();
                if (s5 !== peg$FAILED) {
                    s6 = peg$parse_();
                    if (s6 !== peg$FAILED) {
                        s7 = peg$parseBinaryFuncOp();
                        if (s7 !== peg$FAILED) {
                            s4 = [s4, s5, s6, s7];
                            s3 = s4;
                        }
                        else {
                            peg$currPos = s3;
                            s3 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s3;
                        s3 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s3;
                    s3 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s3;
                s3 = peg$FAILED;
            }
            while (s3 !== peg$FAILED) {
                s2.push(s3);
                s3 = peg$currPos;
                s4 = peg$parse_();
                if (s4 !== peg$FAILED) {
                    s5 = peg$parsePowerSigns();
                    if (s5 !== peg$FAILED) {
                        s6 = peg$parse_();
                        if (s6 !== peg$FAILED) {
                            s7 = peg$parseBinaryFuncOp();
                            if (s7 !== peg$FAILED) {
                                s4 = [s4, s5, s6, s7];
                                s3 = s4;
                            }
                            else {
                                peg$currPos = s3;
                                s3 = peg$FAILED;
                            }
                        }
                        else {
                            peg$currPos = s3;
                            s3 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s3;
                        s3 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s3;
                    s3 = peg$FAILED;
                }
            }
            if (s2 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c0(s1, s2);
                s0 = s1;
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        else {
            peg$currPos = s0;
            s0 = peg$FAILED;
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parsePowerSigns() {
        var s0, s1;
        var key = peg$currPos * 34 + 11;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        if (input.charCodeAt(peg$currPos) === 94) {
            s1 = peg$c59;
            peg$currPos++;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c60);
            }
        }
        if (s1 === peg$FAILED) {
            if (input.substr(peg$currPos, 5).toLowerCase() === peg$c61) {
                s1 = input.substr(peg$currPos, 5);
                peg$currPos += 5;
            }
            else {
                s1 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c62);
                }
            }
        }
        if (s1 !== peg$FAILED) {
            peg$savedPos = s0;
            s1 = peg$c63();
        }
        s0 = s1;
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseBinaryFuncOp() {
        var s0, s1, s2, s3, s4, s5, s6, s7;
        var key = peg$currPos * 34 + 12;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        s1 = peg$parseFactor();
        if (s1 !== peg$FAILED) {
            s2 = [];
            s3 = peg$currPos;
            s4 = peg$parse_();
            if (s4 !== peg$FAILED) {
                s5 = peg$parseBinFunctions();
                if (s5 !== peg$FAILED) {
                    s6 = peg$parse_();
                    if (s6 !== peg$FAILED) {
                        s7 = peg$parseFactor();
                        if (s7 === peg$FAILED) {
                            s7 = null;
                        }
                        if (s7 !== peg$FAILED) {
                            s4 = [s4, s5, s6, s7];
                            s3 = s4;
                        }
                        else {
                            peg$currPos = s3;
                            s3 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s3;
                        s3 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s3;
                    s3 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s3;
                s3 = peg$FAILED;
            }
            while (s3 !== peg$FAILED) {
                s2.push(s3);
                s3 = peg$currPos;
                s4 = peg$parse_();
                if (s4 !== peg$FAILED) {
                    s5 = peg$parseBinFunctions();
                    if (s5 !== peg$FAILED) {
                        s6 = peg$parse_();
                        if (s6 !== peg$FAILED) {
                            s7 = peg$parseFactor();
                            if (s7 === peg$FAILED) {
                                s7 = null;
                            }
                            if (s7 !== peg$FAILED) {
                                s4 = [s4, s5, s6, s7];
                                s3 = s4;
                            }
                            else {
                                peg$currPos = s3;
                                s3 = peg$FAILED;
                            }
                        }
                        else {
                            peg$currPos = s3;
                            s3 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s3;
                        s3 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s3;
                    s3 = peg$FAILED;
                }
            }
            if (s2 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c11(s1, s2);
                s0 = s1;
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        else {
            peg$currPos = s0;
            s0 = peg$FAILED;
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseBinFunctions() {
        var s0, s1;
        var key = peg$currPos * 34 + 13;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        if (input.substr(peg$currPos, 2) === peg$c64) {
            s1 = peg$c64;
            peg$currPos += 2;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c65);
            }
        }
        if (s1 === peg$FAILED) {
            if (input.substr(peg$currPos, 8).toLowerCase() === peg$c66) {
                s1 = input.substr(peg$currPos, 8);
                peg$currPos += 8;
            }
            else {
                s1 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c67);
                }
            }
            if (s1 === peg$FAILED) {
                if (input.substr(peg$currPos, 7).toLowerCase() === peg$c68) {
                    s1 = input.substr(peg$currPos, 7);
                    peg$currPos += 7;
                }
                else {
                    s1 = peg$FAILED;
                    if (peg$silentFails === 0) {
                        peg$fail(peg$c69);
                    }
                }
            }
        }
        if (s1 !== peg$FAILED) {
            peg$savedPos = s0;
            s1 = peg$c70();
        }
        s0 = s1;
        if (s0 === peg$FAILED) {
            s0 = peg$currPos;
            if (input.substr(peg$currPos, 11).toLowerCase() === peg$c71) {
                s1 = input.substr(peg$currPos, 11);
                peg$currPos += 11;
            }
            else {
                s1 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c72);
                }
            }
            if (s1 === peg$FAILED) {
                if (input.substr(peg$currPos, 10).toLowerCase() === peg$c73) {
                    s1 = input.substr(peg$currPos, 10);
                    peg$currPos += 10;
                }
                else {
                    s1 = peg$FAILED;
                    if (peg$silentFails === 0) {
                        peg$fail(peg$c74);
                    }
                }
            }
            if (s1 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c75();
            }
            s0 = s1;
            if (s0 === peg$FAILED) {
                s0 = peg$currPos;
                if (input.substr(peg$currPos, 5).toLowerCase() === peg$c76) {
                    s1 = input.substr(peg$currPos, 5);
                    peg$currPos += 5;
                }
                else {
                    s1 = peg$FAILED;
                    if (peg$silentFails === 0) {
                        peg$fail(peg$c77);
                    }
                }
                if (s1 !== peg$FAILED) {
                    peg$savedPos = s0;
                    s1 = peg$c78();
                }
                s0 = s1;
                if (s0 === peg$FAILED) {
                    s0 = peg$currPos;
                    if (input.substr(peg$currPos, 5).toLowerCase() === peg$c79) {
                        s1 = input.substr(peg$currPos, 5);
                        peg$currPos += 5;
                    }
                    else {
                        s1 = peg$FAILED;
                        if (peg$silentFails === 0) {
                            peg$fail(peg$c80);
                        }
                    }
                    if (s1 !== peg$FAILED) {
                        peg$savedPos = s0;
                        s1 = peg$c81();
                    }
                    s0 = s1;
                }
            }
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseFactor() {
        var s0, s1, s2, s3, s4, s5;
        var key = peg$currPos * 34 + 14;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        if (input.charCodeAt(peg$currPos) === 40) {
            s1 = peg$c82;
            peg$currPos++;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c83);
            }
        }
        if (s1 !== peg$FAILED) {
            s2 = peg$parse_();
            if (s2 !== peg$FAILED) {
                s3 = peg$parseExpression();
                if (s3 !== peg$FAILED) {
                    s4 = peg$parse_();
                    if (s4 !== peg$FAILED) {
                        if (input.charCodeAt(peg$currPos) === 41) {
                            s5 = peg$c84;
                            peg$currPos++;
                        }
                        else {
                            s5 = peg$FAILED;
                            if (peg$silentFails === 0) {
                                peg$fail(peg$c85);
                            }
                        }
                        if (s5 === peg$FAILED) {
                            s5 = null;
                        }
                        if (s5 !== peg$FAILED) {
                            peg$savedPos = s0;
                            s1 = peg$c86(s3);
                            s0 = s1;
                        }
                        else {
                            peg$currPos = s0;
                            s0 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s0;
                        s0 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s0;
                    s0 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        else {
            peg$currPos = s0;
            s0 = peg$FAILED;
        }
        if (s0 === peg$FAILED) {
            s0 = peg$parseFunctionOp();
            if (s0 === peg$FAILED) {
                s0 = peg$parseUnaryFunctionOp();
                if (s0 === peg$FAILED) {
                    s0 = peg$parseAtom();
                    if (s0 === peg$FAILED) {
                        s0 = peg$parseArrayOp();
                    }
                }
            }
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseFunctionOp() {
        var s0, s1, s2, s3, s4;
        var key = peg$currPos * 34 + 15;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        s1 = peg$parseLettersAndDigits();
        if (s1 !== peg$FAILED) {
            if (input.charCodeAt(peg$currPos) === 40) {
                s2 = peg$c82;
                peg$currPos++;
            }
            else {
                s2 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c83);
                }
            }
            if (s2 !== peg$FAILED) {
                s3 = peg$parseSequence();
                if (s3 !== peg$FAILED) {
                    if (input.charCodeAt(peg$currPos) === 41) {
                        s4 = peg$c84;
                        peg$currPos++;
                    }
                    else {
                        s4 = peg$FAILED;
                        if (peg$silentFails === 0) {
                            peg$fail(peg$c85);
                        }
                    }
                    if (s4 === peg$FAILED) {
                        s4 = null;
                    }
                    if (s4 !== peg$FAILED) {
                        peg$savedPos = s0;
                        s1 = peg$c87(s1, s3);
                        s0 = s1;
                    }
                    else {
                        peg$currPos = s0;
                        s0 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s0;
                    s0 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        else {
            peg$currPos = s0;
            s0 = peg$FAILED;
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseUnaryFunctionOp() {
        var s0, s1, s2, s3;
        var key = peg$currPos * 34 + 16;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        if (input.charCodeAt(peg$currPos) === 33) {
            s1 = peg$c88;
            peg$currPos++;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c89);
            }
        }
        if (s1 === peg$FAILED) {
            if (input.substr(peg$currPos, 6).toLowerCase() === peg$c90) {
                s1 = input.substr(peg$currPos, 6);
                peg$currPos += 6;
            }
            else {
                s1 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c91);
                }
            }
        }
        if (s1 !== peg$FAILED) {
            s2 = peg$parse_();
            if (s2 !== peg$FAILED) {
                s3 = peg$parseExpression();
                if (s3 !== peg$FAILED) {
                    peg$savedPos = s0;
                    s1 = peg$c92(s3);
                    s0 = s1;
                }
                else {
                    peg$currPos = s0;
                    s0 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        else {
            peg$currPos = s0;
            s0 = peg$FAILED;
        }
        if (s0 === peg$FAILED) {
            s0 = peg$currPos;
            s1 = peg$parseAtom();
            if (s1 !== peg$FAILED) {
                s2 = peg$parse_();
                if (s2 !== peg$FAILED) {
                    s3 = peg$parseUnFunctions();
                    if (s3 !== peg$FAILED) {
                        peg$savedPos = s0;
                        s1 = peg$c93(s1, s3);
                        s0 = s1;
                    }
                    else {
                        peg$currPos = s0;
                        s0 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s0;
                    s0 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseUnFunctions() {
        var s0, s1;
        var key = peg$currPos * 34 + 17;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        if (input.substr(peg$currPos, 5).toLowerCase() === peg$c94) {
            s1 = input.substr(peg$currPos, 5);
            peg$currPos += 5;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c95);
            }
        }
        if (s1 !== peg$FAILED) {
            peg$savedPos = s0;
            s1 = peg$c96();
        }
        s0 = s1;
        if (s0 === peg$FAILED) {
            s0 = peg$currPos;
            if (input.substr(peg$currPos, 8).toLowerCase() === peg$c97) {
                s1 = input.substr(peg$currPos, 8);
                peg$currPos += 8;
            }
            else {
                s1 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c98);
                }
            }
            if (s1 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c99();
            }
            s0 = s1;
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseAtom() {
        var s0, s1, s2, s3, s4;
        var key = peg$currPos * 34 + 18;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        s1 = peg$parse_();
        if (s1 !== peg$FAILED) {
            if (input.substr(peg$currPos, 9) === peg$c100) {
                s2 = peg$c100;
                peg$currPos += 9;
            }
            else {
                s2 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c101);
                }
            }
            if (s2 === peg$FAILED) {
                if (input.substr(peg$currPos, 4) === peg$c102) {
                    s2 = peg$c102;
                    peg$currPos += 4;
                }
                else {
                    s2 = peg$FAILED;
                    if (peg$silentFails === 0) {
                        peg$fail(peg$c103);
                    }
                }
            }
            if (s2 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c104();
                s0 = s1;
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        else {
            peg$currPos = s0;
            s0 = peg$FAILED;
        }
        if (s0 === peg$FAILED) {
            s0 = peg$currPos;
            s1 = peg$parse_();
            if (s1 !== peg$FAILED) {
                s2 = peg$parseConstValue();
                if (s2 !== peg$FAILED) {
                    peg$savedPos = s0;
                    s1 = peg$c105(s2);
                    s0 = s1;
                }
                else {
                    peg$currPos = s0;
                    s0 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
            if (s0 === peg$FAILED) {
                s0 = peg$currPos;
                s1 = peg$parse_();
                if (s1 !== peg$FAILED) {
                    if (input.charCodeAt(peg$currPos) === 123) {
                        s2 = peg$c106;
                        peg$currPos++;
                    }
                    else {
                        s2 = peg$FAILED;
                        if (peg$silentFails === 0) {
                            peg$fail(peg$c107);
                        }
                    }
                    if (s2 !== peg$FAILED) {
                        s3 = peg$parseValueInput();
                        if (s3 !== peg$FAILED) {
                            if (input.charCodeAt(peg$currPos) === 125) {
                                s4 = peg$c108;
                                peg$currPos++;
                            }
                            else {
                                s4 = peg$FAILED;
                                if (peg$silentFails === 0) {
                                    peg$fail(peg$c109);
                                }
                            }
                            if (s4 !== peg$FAILED) {
                                peg$savedPos = s0;
                                s1 = peg$c110(s3);
                                s0 = s1;
                            }
                            else {
                                peg$currPos = s0;
                                s0 = peg$FAILED;
                            }
                        }
                        else {
                            peg$currPos = s0;
                            s0 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s0;
                        s0 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s0;
                    s0 = peg$FAILED;
                }
            }
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseConstValue() {
        var s0, s1, s2, s3;
        var key = peg$currPos * 34 + 19;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        s1 = peg$parseLogicValue();
        if (s1 !== peg$FAILED) {
            peg$savedPos = s0;
            s1 = peg$c111(s1);
        }
        s0 = s1;
        if (s0 === peg$FAILED) {
            s0 = peg$currPos;
            s1 = peg$parseArithmeticValue();
            if (s1 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c111(s1);
            }
            s0 = s1;
            if (s0 === peg$FAILED) {
                s0 = peg$currPos;
                s1 = peg$parseLettersAndDigits();
                if (s1 !== peg$FAILED) {
                    peg$savedPos = s0;
                    s1 = peg$c111(s1);
                }
                s0 = s1;
                if (s0 === peg$FAILED) {
                    s0 = peg$currPos;
                    if (input.substr(peg$currPos, 2) === peg$c112) {
                        s1 = peg$c112;
                        peg$currPos += 2;
                    }
                    else {
                        s1 = peg$FAILED;
                        if (peg$silentFails === 0) {
                            peg$fail(peg$c113);
                        }
                    }
                    if (s1 !== peg$FAILED) {
                        peg$savedPos = s0;
                        s1 = peg$c114();
                    }
                    s0 = s1;
                    if (s0 === peg$FAILED) {
                        s0 = peg$currPos;
                        if (input.substr(peg$currPos, 2) === peg$c115) {
                            s1 = peg$c115;
                            peg$currPos += 2;
                        }
                        else {
                            s1 = peg$FAILED;
                            if (peg$silentFails === 0) {
                                peg$fail(peg$c116);
                            }
                        }
                        if (s1 !== peg$FAILED) {
                            peg$savedPos = s0;
                            s1 = peg$c114();
                        }
                        s0 = s1;
                        if (s0 === peg$FAILED) {
                            s0 = peg$currPos;
                            if (input.charCodeAt(peg$currPos) === 39) {
                                s1 = peg$c117;
                                peg$currPos++;
                            }
                            else {
                                s1 = peg$FAILED;
                                if (peg$silentFails === 0) {
                                    peg$fail(peg$c118);
                                }
                            }
                            if (s1 !== peg$FAILED) {
                                s2 = peg$parseAnyInput();
                                if (s2 !== peg$FAILED) {
                                    if (input.charCodeAt(peg$currPos) === 39) {
                                        s3 = peg$c117;
                                        peg$currPos++;
                                    }
                                    else {
                                        s3 = peg$FAILED;
                                        if (peg$silentFails === 0) {
                                            peg$fail(peg$c118);
                                        }
                                    }
                                    if (s3 !== peg$FAILED) {
                                        peg$savedPos = s0;
                                        s1 = peg$c119(s2);
                                        s0 = s1;
                                    }
                                    else {
                                        peg$currPos = s0;
                                        s0 = peg$FAILED;
                                    }
                                }
                                else {
                                    peg$currPos = s0;
                                    s0 = peg$FAILED;
                                }
                            }
                            else {
                                peg$currPos = s0;
                                s0 = peg$FAILED;
                            }
                            if (s0 === peg$FAILED) {
                                s0 = peg$currPos;
                                if (input.charCodeAt(peg$currPos) === 34) {
                                    s1 = peg$c120;
                                    peg$currPos++;
                                }
                                else {
                                    s1 = peg$FAILED;
                                    if (peg$silentFails === 0) {
                                        peg$fail(peg$c121);
                                    }
                                }
                                if (s1 !== peg$FAILED) {
                                    s2 = peg$parseAnyInput();
                                    if (s2 !== peg$FAILED) {
                                        if (input.charCodeAt(peg$currPos) === 34) {
                                            s3 = peg$c120;
                                            peg$currPos++;
                                        }
                                        else {
                                            s3 = peg$FAILED;
                                            if (peg$silentFails === 0) {
                                                peg$fail(peg$c121);
                                            }
                                        }
                                        if (s3 !== peg$FAILED) {
                                            peg$savedPos = s0;
                                            s1 = peg$c119(s2);
                                            s0 = s1;
                                        }
                                        else {
                                            peg$currPos = s0;
                                            s0 = peg$FAILED;
                                        }
                                    }
                                    else {
                                        peg$currPos = s0;
                                        s0 = peg$FAILED;
                                    }
                                }
                                else {
                                    peg$currPos = s0;
                                    s0 = peg$FAILED;
                                }
                            }
                        }
                    }
                }
            }
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseArrayOp() {
        var s0, s1, s2, s3;
        var key = peg$currPos * 34 + 20;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        if (input.charCodeAt(peg$currPos) === 91) {
            s1 = peg$c122;
            peg$currPos++;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c123);
            }
        }
        if (s1 !== peg$FAILED) {
            s2 = peg$parseSequence();
            if (s2 !== peg$FAILED) {
                if (input.charCodeAt(peg$currPos) === 93) {
                    s3 = peg$c124;
                    peg$currPos++;
                }
                else {
                    s3 = peg$FAILED;
                    if (peg$silentFails === 0) {
                        peg$fail(peg$c125);
                    }
                }
                if (s3 !== peg$FAILED) {
                    peg$savedPos = s0;
                    s1 = peg$c126(s2);
                    s0 = s1;
                }
                else {
                    peg$currPos = s0;
                    s0 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        else {
            peg$currPos = s0;
            s0 = peg$FAILED;
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseSequence() {
        var s0, s1, s2, s3, s4, s5, s6, s7;
        var key = peg$currPos * 34 + 21;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        s1 = peg$parseExpression();
        if (s1 === peg$FAILED) {
            s1 = null;
        }
        if (s1 !== peg$FAILED) {
            s2 = [];
            s3 = peg$currPos;
            s4 = peg$parse_();
            if (s4 !== peg$FAILED) {
                if (input.charCodeAt(peg$currPos) === 44) {
                    s5 = peg$c127;
                    peg$currPos++;
                }
                else {
                    s5 = peg$FAILED;
                    if (peg$silentFails === 0) {
                        peg$fail(peg$c128);
                    }
                }
                if (s5 !== peg$FAILED) {
                    s6 = peg$parse_();
                    if (s6 !== peg$FAILED) {
                        s7 = peg$parseExpression();
                        if (s7 !== peg$FAILED) {
                            s4 = [s4, s5, s6, s7];
                            s3 = s4;
                        }
                        else {
                            peg$currPos = s3;
                            s3 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s3;
                        s3 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s3;
                    s3 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s3;
                s3 = peg$FAILED;
            }
            while (s3 !== peg$FAILED) {
                s2.push(s3);
                s3 = peg$currPos;
                s4 = peg$parse_();
                if (s4 !== peg$FAILED) {
                    if (input.charCodeAt(peg$currPos) === 44) {
                        s5 = peg$c127;
                        peg$currPos++;
                    }
                    else {
                        s5 = peg$FAILED;
                        if (peg$silentFails === 0) {
                            peg$fail(peg$c128);
                        }
                    }
                    if (s5 !== peg$FAILED) {
                        s6 = peg$parse_();
                        if (s6 !== peg$FAILED) {
                            s7 = peg$parseExpression();
                            if (s7 !== peg$FAILED) {
                                s4 = [s4, s5, s6, s7];
                                s3 = s4;
                            }
                            else {
                                peg$currPos = s3;
                                s3 = peg$FAILED;
                            }
                        }
                        else {
                            peg$currPos = s3;
                            s3 = peg$FAILED;
                        }
                    }
                    else {
                        peg$currPos = s3;
                        s3 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s3;
                    s3 = peg$FAILED;
                }
            }
            if (s2 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c129(s1, s2);
                s0 = s1;
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        else {
            peg$currPos = s0;
            s0 = peg$FAILED;
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseLogicValue() {
        var s0, s1;
        var key = peg$currPos * 34 + 22;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        if (input.substr(peg$currPos, 4).toLowerCase() === peg$c130) {
            s1 = input.substr(peg$currPos, 4);
            peg$currPos += 4;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c131);
            }
        }
        if (s1 !== peg$FAILED) {
            peg$savedPos = s0;
            s1 = peg$c132();
        }
        s0 = s1;
        if (s0 === peg$FAILED) {
            s0 = peg$currPos;
            if (input.substr(peg$currPos, 5).toLowerCase() === peg$c133) {
                s1 = input.substr(peg$currPos, 5);
                peg$currPos += 5;
            }
            else {
                s1 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c134);
                }
            }
            if (s1 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c135();
            }
            s0 = s1;
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseArithmeticValue() {
        var s0, s1, s2;
        var key = peg$currPos * 34 + 23;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        if (input.substr(peg$currPos, 2) === peg$c136) {
            s1 = peg$c136;
            peg$currPos += 2;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c137);
            }
        }
        if (s1 !== peg$FAILED) {
            s2 = peg$parseDigits();
            if (s2 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c138();
                s0 = s1;
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        else {
            peg$currPos = s0;
            s0 = peg$FAILED;
        }
        if (s0 === peg$FAILED) {
            s0 = peg$currPos;
            if (peg$c139.test(input.charAt(peg$currPos))) {
                s1 = input.charAt(peg$currPos);
                peg$currPos++;
            }
            else {
                s1 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c140);
                }
            }
            if (s1 === peg$FAILED) {
                s1 = null;
            }
            if (s1 !== peg$FAILED) {
                s2 = peg$parseNumber();
                if (s2 !== peg$FAILED) {
                    peg$savedPos = s0;
                    s1 = peg$c141(s1, s2);
                    s0 = s1;
                }
                else {
                    peg$currPos = s0;
                    s0 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseNumber() {
        var s0, s1, s2, s3;
        var key = peg$currPos * 34 + 24;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        s1 = peg$parseDigits();
        if (s1 !== peg$FAILED) {
            if (input.charCodeAt(peg$currPos) === 46) {
                s2 = peg$c142;
                peg$currPos++;
            }
            else {
                s2 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c143);
                }
            }
            if (s2 !== peg$FAILED) {
                s3 = peg$parseDigits();
                if (s3 !== peg$FAILED) {
                    peg$savedPos = s0;
                    s1 = peg$c144();
                    s0 = s1;
                }
                else {
                    peg$currPos = s0;
                    s0 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        else {
            peg$currPos = s0;
            s0 = peg$FAILED;
        }
        if (s0 === peg$FAILED) {
            s0 = peg$currPos;
            s1 = peg$parseNonZeroDigits();
            if (s1 !== peg$FAILED) {
                s2 = peg$parseDigits();
                if (s2 === peg$FAILED) {
                    s2 = null;
                }
                if (s2 !== peg$FAILED) {
                    peg$savedPos = s0;
                    s1 = peg$c145();
                    s0 = s1;
                }
                else {
                    peg$currPos = s0;
                    s0 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
            if (s0 === peg$FAILED) {
                s0 = peg$currPos;
                if (input.charCodeAt(peg$currPos) === 48) {
                    s1 = peg$c146;
                    peg$currPos++;
                }
                else {
                    s1 = peg$FAILED;
                    if (peg$silentFails === 0) {
                        peg$fail(peg$c147);
                    }
                }
                if (s1 !== peg$FAILED) {
                    peg$savedPos = s0;
                    s1 = peg$c148();
                }
                s0 = s1;
            }
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseValueInput() {
        var s0, s1, s2;
        var key = peg$currPos * 34 + 25;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        s1 = [];
        s2 = peg$parseValueCharacters();
        if (s2 !== peg$FAILED) {
            while (s2 !== peg$FAILED) {
                s1.push(s2);
                s2 = peg$parseValueCharacters();
            }
        }
        else {
            s1 = peg$FAILED;
        }
        if (s1 !== peg$FAILED) {
            peg$savedPos = s0;
            s1 = peg$c149(s1);
        }
        s0 = s1;
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseAnyInput() {
        var s0, s1, s2;
        var key = peg$currPos * 34 + 26;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        s1 = [];
        s2 = peg$parseAnyCharacters();
        if (s2 !== peg$FAILED) {
            while (s2 !== peg$FAILED) {
                s1.push(s2);
                s2 = peg$parseAnyCharacters();
            }
        }
        else {
            s1 = peg$FAILED;
        }
        if (s1 !== peg$FAILED) {
            peg$savedPos = s0;
            s1 = peg$c149(s1);
        }
        s0 = s1;
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseAnyCharacters() {
        var s0, s1;
        var key = peg$currPos * 34 + 27;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        if (input.substr(peg$currPos, 2) === peg$c150) {
            s1 = peg$c150;
            peg$currPos += 2;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c151);
            }
        }
        if (s1 !== peg$FAILED) {
            peg$savedPos = s0;
            s1 = peg$c152();
        }
        s0 = s1;
        if (s0 === peg$FAILED) {
            s0 = peg$currPos;
            if (input.substr(peg$currPos, 2) === peg$c153) {
                s1 = peg$c153;
                peg$currPos += 2;
            }
            else {
                s1 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c154);
                }
            }
            if (s1 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c155();
            }
            s0 = s1;
            if (s0 === peg$FAILED) {
                s0 = peg$currPos;
                if (peg$c156.test(input.charAt(peg$currPos))) {
                    s1 = input.charAt(peg$currPos);
                    peg$currPos++;
                }
                else {
                    s1 = peg$FAILED;
                    if (peg$silentFails === 0) {
                        peg$fail(peg$c157);
                    }
                }
                if (s1 !== peg$FAILED) {
                    peg$savedPos = s0;
                    s1 = peg$c158();
                }
                s0 = s1;
            }
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseValueCharacters() {
        var s0, s1;
        var key = peg$currPos * 34 + 28;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        if (peg$c159.test(input.charAt(peg$currPos))) {
            s1 = input.charAt(peg$currPos);
            peg$currPos++;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c160);
            }
        }
        if (s1 !== peg$FAILED) {
            peg$savedPos = s0;
            s1 = peg$c158();
        }
        s0 = s1;
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseLettersAndDigits() {
        var s0, s1, s2, s3, s4, s5, s6;
        var key = peg$currPos * 34 + 29;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = peg$currPos;
        s1 = peg$parseLetters();
        if (s1 !== peg$FAILED) {
            s2 = [];
            s3 = peg$currPos;
            s4 = peg$parseDigits();
            if (s4 !== peg$FAILED) {
                s5 = [];
                s6 = peg$parseLetters();
                while (s6 !== peg$FAILED) {
                    s5.push(s6);
                    s6 = peg$parseLetters();
                }
                if (s5 !== peg$FAILED) {
                    s4 = [s4, s5];
                    s3 = s4;
                }
                else {
                    peg$currPos = s3;
                    s3 = peg$FAILED;
                }
            }
            else {
                peg$currPos = s3;
                s3 = peg$FAILED;
            }
            while (s3 !== peg$FAILED) {
                s2.push(s3);
                s3 = peg$currPos;
                s4 = peg$parseDigits();
                if (s4 !== peg$FAILED) {
                    s5 = [];
                    s6 = peg$parseLetters();
                    while (s6 !== peg$FAILED) {
                        s5.push(s6);
                        s6 = peg$parseLetters();
                    }
                    if (s5 !== peg$FAILED) {
                        s4 = [s4, s5];
                        s3 = s4;
                    }
                    else {
                        peg$currPos = s3;
                        s3 = peg$FAILED;
                    }
                }
                else {
                    peg$currPos = s3;
                    s3 = peg$FAILED;
                }
            }
            if (s2 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c158();
                s0 = s1;
            }
            else {
                peg$currPos = s0;
                s0 = peg$FAILED;
            }
        }
        else {
            peg$currPos = s0;
            s0 = peg$FAILED;
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseDigits() {
        var s0, s1;
        var key = peg$currPos * 34 + 30;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = [];
        if (peg$c161.test(input.charAt(peg$currPos))) {
            s1 = input.charAt(peg$currPos);
            peg$currPos++;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c162);
            }
        }
        if (s1 !== peg$FAILED) {
            while (s1 !== peg$FAILED) {
                s0.push(s1);
                if (peg$c161.test(input.charAt(peg$currPos))) {
                    s1 = input.charAt(peg$currPos);
                    peg$currPos++;
                }
                else {
                    s1 = peg$FAILED;
                    if (peg$silentFails === 0) {
                        peg$fail(peg$c162);
                    }
                }
            }
        }
        else {
            s0 = peg$FAILED;
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseNonZeroDigits() {
        var s0, s1;
        var key = peg$currPos * 34 + 31;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = [];
        if (peg$c163.test(input.charAt(peg$currPos))) {
            s1 = input.charAt(peg$currPos);
            peg$currPos++;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c164);
            }
        }
        if (s1 !== peg$FAILED) {
            while (s1 !== peg$FAILED) {
                s0.push(s1);
                if (peg$c163.test(input.charAt(peg$currPos))) {
                    s1 = input.charAt(peg$currPos);
                    peg$currPos++;
                }
                else {
                    s1 = peg$FAILED;
                    if (peg$silentFails === 0) {
                        peg$fail(peg$c164);
                    }
                }
            }
        }
        else {
            s0 = peg$FAILED;
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parseLetters() {
        var s0, s1;
        var key = peg$currPos * 34 + 32;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        s0 = [];
        if (peg$c165.test(input.charAt(peg$currPos))) {
            s1 = input.charAt(peg$currPos);
            peg$currPos++;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c166);
            }
        }
        if (s1 !== peg$FAILED) {
            while (s1 !== peg$FAILED) {
                s0.push(s1);
                if (peg$c165.test(input.charAt(peg$currPos))) {
                    s1 = input.charAt(peg$currPos);
                    peg$currPos++;
                }
                else {
                    s1 = peg$FAILED;
                    if (peg$silentFails === 0) {
                        peg$fail(peg$c166);
                    }
                }
            }
        }
        else {
            s0 = peg$FAILED;
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function peg$parse_() {
        var s0, s1;
        var key = peg$currPos * 34 + 33;
        var cached = peg$resultsCache[key];
        if (cached) {
            peg$currPos = cached.nextPos;
            return cached.result;
        }
        peg$silentFails++;
        s0 = [];
        if (peg$c168.test(input.charAt(peg$currPos))) {
            s1 = input.charAt(peg$currPos);
            peg$currPos++;
        }
        else {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c169);
            }
        }
        while (s1 !== peg$FAILED) {
            s0.push(s1);
            if (peg$c168.test(input.charAt(peg$currPos))) {
                s1 = input.charAt(peg$currPos);
                peg$currPos++;
            }
            else {
                s1 = peg$FAILED;
                if (peg$silentFails === 0) {
                    peg$fail(peg$c169);
                }
            }
        }
        peg$silentFails--;
        if (s0 === peg$FAILED) {
            s1 = peg$FAILED;
            if (peg$silentFails === 0) {
                peg$fail(peg$c167);
            }
        }
        peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
        return s0;
    }
    function buildBinaryOperand(head, tail, isArithmeticOp) {
        if (isArithmeticOp === void 0) { isArithmeticOp = false; }
        return tail.reduce(function (result, elements) {
            return new BinaryOperand(elements[1], result, elements[3], isArithmeticOp);
        }, head);
    }
    function flattenArray(array) {
        return [].concat.apply([], array);
    }
    peg$result = peg$startRuleFunction();
    if (peg$result !== peg$FAILED && peg$currPos === input.length) {
        return peg$result;
    }
    else {
        if (peg$result !== peg$FAILED && peg$currPos < input.length) {
            peg$fail(peg$endExpectation());
        }
        throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length
            ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
            : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
    }
}
var parse = peg$parse;

// CONCATENATED MODULE: ./packages/survey-core/src/conditionsParser.ts

var ConditionsParserError = /** @class */ (function () {
    function ConditionsParserError(at, code) {
        this.at = at;
        this.code = code;
    }
    return ConditionsParserError;
}());

var conditionsParser_ConditionsParser = /** @class */ (function () {
    function ConditionsParser() {
    }
    ConditionsParser.prototype.patchExpression = function (text) {
        return text
            .replace(/=>/g, ">=")
            .replace(/=</g, "<=")
            .replace(/<>/g, "!=")
            .replace(/equals/g, "equal ")
            .replace(/notequals/g, "notequal ");
    };
    ConditionsParser.prototype.createCondition = function (text) {
        return this.parseExpression(text);
    };
    ConditionsParser.prototype.parseExpression = function (text) {
        try {
            var result = ConditionsParser.parserCache[text];
            if (result === undefined) {
                result = parse(this.patchExpression(text));
                if (!result.hasAsyncFunction()) {
                    ConditionsParser.parserCache[text] = result;
                }
            }
            return result;
        }
        catch (e) {
            if (e instanceof SyntaxError) {
                this.conditionError = new ConditionsParserError(e.location.start.offset, e.message);
            }
        }
    };
    Object.defineProperty(ConditionsParser.prototype, "error", {
        get: function () {
            return this.conditionError;
        },
        enumerable: false,
        configurable: true
    });
    ConditionsParser.parserCache = {};
    return ConditionsParser;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/conditions.ts
var conditions_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();



var conditions_ExpressionExecutor = /** @class */ (function () {
    function ExpressionExecutor(expression) {
        this.processValue = new conditionProcessValue_ProcessValue();
        this.parser = new conditionsParser_ConditionsParser();
        this.isAsyncValue = false;
        this.hasFunctionValue = false;
        this.setExpression(expression);
    }
    Object.defineProperty(ExpressionExecutor.prototype, "expression", {
        get: function () {
            return this.expressionValue;
        },
        enumerable: false,
        configurable: true
    });
    ExpressionExecutor.prototype.setExpression = function (value) {
        if (this.expression === value)
            return;
        this.expressionValue = value;
        this.operand = this.parser.parseExpression(value);
        this.hasFunctionValue = this.canRun() ? this.operand.hasFunction() : false;
        this.isAsyncValue = this.hasFunction()
            ? this.operand.hasAsyncFunction()
            : false;
    };
    ExpressionExecutor.prototype.getVariables = function () {
        if (!this.operand)
            return [];
        var variables = [];
        this.operand.setVariables(variables);
        return variables;
    };
    ExpressionExecutor.prototype.hasFunction = function () {
        return this.hasFunctionValue;
    };
    Object.defineProperty(ExpressionExecutor.prototype, "isAsync", {
        get: function () {
            return this.isAsyncValue;
        },
        enumerable: false,
        configurable: true
    });
    ExpressionExecutor.prototype.canRun = function () {
        return !!this.operand;
    };
    ExpressionExecutor.prototype.run = function (values, properties) {
        if (properties === void 0) { properties = null; }
        if (!this.operand) {
            if (!!this.expression) {
                ConsoleWarnings.warn("Invalid expression: " + this.expression);
            }
            return null;
        }
        this.processValue.values = values;
        this.processValue.properties = properties;
        if (!this.isAsync)
            return this.runValues();
        this.asyncFuncList = new Array();
        this.operand.addToAsyncList(this.asyncFuncList);
        for (var i = 0; i < this.asyncFuncList.length; i++) {
            this.runAsyncItem(this.asyncFuncList[i]);
        }
        return false;
    };
    ExpressionExecutor.prototype.runAsyncItem = function (item) {
        var _this = this;
        if (item.children) {
            item.children.forEach(function (child) { return _this.runAsyncItem(child); });
        }
        else {
            this.runAsyncItemCore(item);
        }
    };
    ExpressionExecutor.prototype.runAsyncItemCore = function (item) {
        var _this = this;
        if (item.operand) {
            item.operand.onAsyncReady = function () { return _this.doAsyncFunctionReady(item); };
            item.operand.evaluateAsync(this.processValue);
        }
        else {
            this.doAsyncFunctionReady(item);
        }
    };
    ExpressionExecutor.prototype.doAsyncFunctionReady = function (item) {
        if (item.parent && this.isAsyncChildrenReady(item)) {
            this.runAsyncItemCore(item.parent);
            return;
        }
        for (var i = 0; i < this.asyncFuncList.length; i++) {
            if (!this.isAsyncFuncReady(this.asyncFuncList[i]))
                return;
        }
        this.runValues();
    };
    ExpressionExecutor.prototype.isAsyncFuncReady = function (item) {
        if (item.operand && !item.operand.isReady)
            return false;
        return this.isAsyncChildrenReady(item);
    };
    ExpressionExecutor.prototype.isAsyncChildrenReady = function (item) {
        if (item.children) {
            for (var i = 0; i < item.children.length; i++) {
                if (!this.isAsyncFuncReady(item.children[i]))
                    return false;
            }
        }
        return true;
    };
    ExpressionExecutor.prototype.runValues = function () {
        var res = this.operand.evaluate(this.processValue);
        if (!!this.onComplete) {
            this.onComplete(res);
        }
        return res;
    };
    ExpressionExecutor.createExpressionExecutor = function (expression) { return new ExpressionExecutor(expression); };
    return ExpressionExecutor;
}());

var ExpressionRunnerBase = /** @class */ (function () {
    function ExpressionRunnerBase(expression) {
        this._id = ExpressionRunnerBase.IdCounter++;
        this.expression = expression;
    }
    Object.defineProperty(ExpressionRunnerBase.prototype, "id", {
        get: function () { return this._id; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ExpressionRunnerBase.prototype, "expression", {
        get: function () {
            return !!this.expressionExecutor ? this.expressionExecutor.expression : "";
        },
        set: function (value) {
            var _this = this;
            if (!!this.expressionExecutor && value === this.expression)
                return;
            this.expressionExecutor = conditions_ExpressionExecutor.createExpressionExecutor(value);
            this.expressionExecutor.onComplete = function (res) { _this.doOnComplete(res); };
            this.variables = undefined;
            this.containsFunc = undefined;
        },
        enumerable: false,
        configurable: true
    });
    ExpressionRunnerBase.prototype.getVariables = function () {
        if (this.variables === undefined) {
            this.variables = this.expressionExecutor.getVariables();
        }
        return this.variables;
    };
    ExpressionRunnerBase.prototype.hasFunction = function () {
        if (this.containsFunc === undefined) {
            this.containsFunc = this.expressionExecutor.hasFunction();
        }
        return this.containsFunc;
    };
    Object.defineProperty(ExpressionRunnerBase.prototype, "isAsync", {
        get: function () {
            return this.expressionExecutor.isAsync;
        },
        enumerable: false,
        configurable: true
    });
    ExpressionRunnerBase.prototype.canRun = function () {
        return this.expressionExecutor.canRun();
    };
    ExpressionRunnerBase.prototype.runCore = function (values, properties) {
        if (properties === void 0) { properties = null; }
        if (this.onBeforeAsyncRun && this.isAsync) {
            this.onBeforeAsyncRun(this.id);
        }
        return this.expressionExecutor.run(values, properties);
    };
    ExpressionRunnerBase.prototype.doOnComplete = function (res) {
        if (this.onAfterAsyncRun && this.isAsync) {
            this.onAfterAsyncRun(this.id);
        }
    };
    ExpressionRunnerBase.IdCounter = 1;
    return ExpressionRunnerBase;
}());

var ConditionRunner = /** @class */ (function (_super) {
    conditions_extends(ConditionRunner, _super);
    function ConditionRunner() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ConditionRunner.prototype.run = function (values, properties) {
        if (properties === void 0) { properties = null; }
        return this.runCore(values, properties) == true;
    };
    ConditionRunner.prototype.doOnComplete = function (res) {
        if (!!this.onRunComplete)
            this.onRunComplete(res == true);
        _super.prototype.doOnComplete.call(this, res);
    };
    return ConditionRunner;
}(ExpressionRunnerBase));

var ExpressionRunner = /** @class */ (function (_super) {
    conditions_extends(ExpressionRunner, _super);
    function ExpressionRunner() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ExpressionRunner.prototype.run = function (values, properties) {
        if (properties === void 0) { properties = null; }
        return this.runCore(values, properties);
    };
    ExpressionRunner.prototype.doOnComplete = function (res) {
        if (!!this.onRunComplete)
            this.onRunComplete(res);
        _super.prototype.doOnComplete.call(this, res);
    };
    return ExpressionRunner;
}(ExpressionRunnerBase));


// CONCATENATED MODULE: ./packages/survey-core/src/base.ts
var base_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var base_spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
    for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
        to[j] = from[i];
    return to;
};







var base_Bindings = /** @class */ (function () {
    function Bindings(obj) {
        this.obj = obj;
        this.properties = null;
        this.values = null;
    }
    Bindings.prototype.getType = function () {
        return "bindings";
    };
    Bindings.prototype.getNames = function () {
        var res = [];
        this.fillProperties();
        for (var i = 0; i < this.properties.length; i++) {
            if (this.properties[i].isVisible("", this.obj)) {
                res.push(this.properties[i].name);
            }
        }
        return res;
    };
    Bindings.prototype.getProperties = function () {
        var res = [];
        this.fillProperties();
        for (var i = 0; i < this.properties.length; i++) {
            res.push(this.properties[i]);
        }
        return res;
    };
    Bindings.prototype.setBinding = function (propertyName, valueName) {
        if (!this.values)
            this.values = {};
        var oldValue = this.getJson();
        if (oldValue === valueName)
            return;
        if (!!valueName) {
            this.values[propertyName] = valueName;
        }
        else {
            delete this.values[propertyName];
            if (Object.keys(this.values).length == 0) {
                this.values = null;
            }
        }
        this.onChangedJSON(oldValue);
    };
    Bindings.prototype.clearBinding = function (propertyName) {
        this.setBinding(propertyName, "");
    };
    Bindings.prototype.isEmpty = function () {
        if (!this.values)
            return true;
        for (var key in this.values)
            return false;
        return true;
    };
    Bindings.prototype.getValueNameByPropertyName = function (propertyName) {
        if (!this.values)
            return undefined;
        return this.values[propertyName];
    };
    Bindings.prototype.getPropertiesByValueName = function (valueName) {
        if (!this.values)
            return [];
        var res = [];
        for (var key in this.values) {
            if (this.values[key] == valueName) {
                res.push(key);
            }
        }
        return res;
    };
    Bindings.prototype.getJson = function () {
        if (this.isEmpty())
            return undefined;
        var res = {};
        for (var key in this.values) {
            res[key] = this.values[key];
        }
        return res;
    };
    Bindings.prototype.setJson = function (value) {
        var oldValue = this.getJson();
        this.values = null;
        if (!!value) {
            this.values = {};
            for (var key in value) {
                this.values[key] = value[key];
            }
        }
        this.onChangedJSON(oldValue);
    };
    Bindings.prototype.fillProperties = function () {
        if (this.properties !== null)
            return;
        this.properties = [];
        var objProperties = Serializer.getPropertiesByObj(this.obj);
        for (var i = 0; i < objProperties.length; i++) {
            if (objProperties[i].isBindable) {
                this.properties.push(objProperties[i]);
            }
        }
    };
    Bindings.prototype.onChangedJSON = function (oldValue) {
        if (this.obj) {
            this.obj.onBindingChanged(oldValue, this.getJson());
        }
    };
    return Bindings;
}());

var Dependencies = /** @class */ (function () {
    function Dependencies(currentDependency, target, property) {
        this.currentDependency = currentDependency;
        this.target = target;
        this.property = property;
        this.dependencies = [];
        this.id = "" + (++Dependencies.DependenciesCount);
    }
    Dependencies.prototype.addDependency = function (target, property) {
        if (this.target === target && this.property === property)
            return;
        if (this.dependencies.some(function (dependency) { return dependency.obj === target && dependency.prop === property; }))
            return;
        this.dependencies.push({
            obj: target,
            prop: property,
            id: this.id
        });
        target.registerPropertyChangedHandlers([property], this.currentDependency, this.id);
    };
    Dependencies.prototype.dispose = function () {
        this.dependencies.forEach(function (dependency) {
            dependency.obj.unregisterPropertyChangedHandlers([dependency.prop], dependency.id);
        });
        // this.currentDependency = undefined;
    };
    Dependencies.DependenciesCount = 0;
    return Dependencies;
}());

var ComputedUpdater = /** @class */ (function () {
    function ComputedUpdater(_updater) {
        this._updater = _updater;
        this.dependencies = undefined;
        this.type = ComputedUpdater.ComputedUpdaterType;
    }
    Object.defineProperty(ComputedUpdater.prototype, "updater", {
        get: function () {
            return this._updater;
        },
        enumerable: false,
        configurable: true
    });
    ComputedUpdater.prototype.setDependencies = function (dependencies) {
        this.clearDependencies();
        this.dependencies = dependencies;
    };
    ComputedUpdater.prototype.getDependencies = function () {
        return this.dependencies;
    };
    ComputedUpdater.prototype.clearDependencies = function () {
        if (this.dependencies) {
            this.dependencies.dispose();
            this.dependencies = undefined;
        }
    };
    ComputedUpdater.prototype.dispose = function () {
        this.clearDependencies();
    };
    ComputedUpdater.ComputedUpdaterType = "__dependency_computed";
    return ComputedUpdater;
}());

/**
 * A base class for all SurveyJS objects.
 */
var base_Base = /** @class */ (function () {
    function Base() {
        this.dependencies = {};
        this.propertyHash = Base.createPropertiesHash();
        this.eventList = [];
        this.isLoadingFromJsonValue = false;
        this.loadingOwner = null;
        /**
         * An event that is raised when a property of this SurveyJS object has changed.
         *
         * Parameters:
         *
         * - `sender`: `this`\
         * A SurveyJS object whose property has changed.
         * - `options.name`: `string`\
         * The name of the changed property.
         * - `options.newValue`: `any`\
         * A new value for the property.
         * - `options.oldValue`: `any`\
         * An old value of the property. If the property is an array, `oldValue` contains the same array as `newValue` does.
         *
         * If you need to add and remove property change event handlers dynamically, use the [`registerPropertyChangedHandlers`](#registerPropertyChangedHandlers) and [`unregisterPropertyChangedHandlers`](#unregisterPropertyChangedHandlers) methods instead.
         */
        this.onPropertyChanged = this.addEvent();
        /**
         * An event that is raised when an [`ItemValue`](https://surveyjs.io/form-library/documentation/itemvalue) property is changed.
         *
         * Parameters:
         *
         * - `sender`: `this`\
         * A SurveyJS object whose property contains an array of `ItemValue` objects.
         * - `options.obj`: [`ItemValue`](https://surveyjs.io/form-library/documentation/itemvalue)\
         * An `ItemValue` object.
         * - `options.propertyName`: `string`\
         * The name of the property to which an array of `ItemValue` objects is assigned (for example, `"choices"` or `"rows"`).
         * - `options.name`: `"text"` | `"value"`\
         * The name of the changed property.
         * - `options.newValue`: `any`\
         * A new value for the property.
         */
        this.onItemValuePropertyChanged = this.addEvent();
        this.isCreating = true;
        this.animationAllowedLock = 0;
        //remove when knockout obsolete
        this.supportOnElementRenderedEvent = true;
        this.onElementRenderedEventEnabled = false;
        this._onElementRerendered = new EventBase();
        this.bindingsValue = new base_Bindings(this);
        CustomPropertiesCollection.createProperties(this);
        this.onBaseCreating();
        this.isCreating = false;
    }
    Base.finishCollectDependencies = function () {
        var deps = Base.currentDependencis;
        Base.currentDependencis = undefined;
        return deps;
    };
    Base.startCollectDependencies = function (updater, target, property) {
        if (Base.currentDependencis !== undefined) {
            throw new Error("Attempt to collect nested dependencies. Nested dependencies are not supported.");
        }
        Base.currentDependencis = new Dependencies(updater, target, property);
    };
    Base.collectDependency = function (target, property) {
        if (Base.currentDependencis === undefined)
            return;
        Base.currentDependencis.addDependency(target, property);
    };
    Object.defineProperty(Base, "commentSuffix", {
        get: function () {
            return settings.commentSuffix;
        },
        set: function (val) {
            settings.commentSuffix = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Base, "commentPrefix", {
        get: function () {
            return Base.commentSuffix;
        },
        set: function (val) {
            Base.commentSuffix = val;
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Returns `true` if a passed `value` is an empty string, array, or object or if it equals to `undefined` or `null`.
     *
     * @param value A value to be checked.
     * @param trimString *(Optional)* When this parameter is `true`, the method ignores whitespace characters at the beginning and end of a string value. Pass `false` to disable this functionality.
     */
    Base.prototype.isValueEmpty = function (value, trimString) {
        if (trimString === void 0) { trimString = true; }
        if (trimString) {
            value = this.trimValue(value);
        }
        return helpers_Helpers.isValueEmpty(value);
    };
    Base.prototype.equals = function (obj) {
        if (!obj)
            return false;
        if (this.isDisposed || obj.isDisposed)
            return false;
        if (this.getType() != obj.getType())
            return false;
        return this.equalsCore(obj);
    };
    Base.prototype.equalsCore = function (obj) {
        if (this.name !== obj.name)
            return false;
        return helpers_Helpers.isTwoValueEquals(this.toJSON(), obj.toJSON(), false, true, false);
    };
    Base.prototype.trimValue = function (value) {
        if (!!value && (typeof value === "string" || value instanceof String))
            return value.trim();
        return value;
    };
    Base.prototype.isPropertyEmpty = function (value) {
        return value !== "" && this.isValueEmpty(value);
    };
    Base.createPropertiesHash = function () {
        return {};
    };
    Base.prototype.dispose = function () {
        var _this = this;
        for (var i = 0; i < this.eventList.length; i++) {
            this.eventList[i].clear();
        }
        this.onPropertyValueChangedCallback = undefined;
        this.isDisposedValue = true;
        Object.keys(this.dependencies).forEach(function (key) { return _this.dependencies[key].dispose(); });
    };
    Object.defineProperty(Base.prototype, "isDisposed", {
        get: function () {
            return this.isDisposedValue === true;
        },
        enumerable: false,
        configurable: true
    });
    Base.prototype.addEvent = function () {
        var res = new EventBase();
        this.eventList.push(res);
        return res;
    };
    Base.prototype.onBaseCreating = function () { };
    /**
     * Returns the object type as it is used in the JSON schema.
     */
    Base.prototype.getType = function () {
        return "base";
    };
    /**
     * Use this method to find out if the current object is of a given `typeName` or inherited from it.
     *
     * @param typeName One of the values listed in the [getType()](https://surveyjs.io/form-library/documentation/question#getType) description.
     * @returns `true` if the current object is of a given `typeName` or inherited from it.
     * @see getType
     */
    Base.prototype.isDescendantOf = function (typeName) {
        return Serializer.isDescendantOf(this.getType(), typeName);
    };
    Base.prototype.getSurvey = function (isLive) {
        if (isLive === void 0) { isLive = false; }
        return null;
    };
    Object.defineProperty(Base.prototype, "isDesignMode", {
        /**
         * Returns `true` if the survey is being designed in Survey Creator.
         */
        get: function () {
            var survey = this.getSurvey();
            return !!survey && survey.isDesignMode;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Base.prototype, "isDesignModeV2", {
        get: function () {
            return settings.supportCreatorV2 && this.isDesignMode;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Base.prototype, "inSurvey", {
        /**
         * Returns `true` if the object is included in a survey.
         *
         * This property may return `false`, for example, when you [create a survey model dynamically](https://surveyjs.io/form-library/documentation/design-survey-create-a-simple-survey#create-or-change-a-survey-model-dynamically).
         */
        get: function () {
            return !!this.getSurvey(true);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Base.prototype, "bindings", {
        get: function () {
            return this.bindingsValue;
        },
        enumerable: false,
        configurable: true
    });
    Base.prototype.checkBindings = function (valueName, value) { };
    Base.prototype.updateBindings = function (propertyName, value) {
        var valueName = this.bindings.getValueNameByPropertyName(propertyName);
        if (!!valueName) {
            this.updateBindingValue(valueName, value);
        }
    };
    Base.prototype.updateBindingValue = function (valueName, value) { };
    Base.prototype.getTemplate = function () {
        return this.getType();
    };
    Object.defineProperty(Base.prototype, "isLoadingFromJson", {
        /**
         * Returns `true` if the object configuration is being loaded from JSON.
         */
        get: function () {
            return this.isLoadingFromJsonValue || this.getIsLoadingFromJson();
        },
        enumerable: false,
        configurable: true
    });
    Base.prototype.getIsLoadingFromJson = function () {
        if (!!this.loadingOwner && this.loadingOwner.isLoadingFromJson)
            return true;
        return this.isLoadingFromJsonValue;
    };
    Base.prototype.startLoadingFromJson = function (json) {
        this.isLoadingFromJsonValue = true;
        this.jsonObj = json;
    };
    Base.prototype.endLoadingFromJson = function () {
        this.isLoadingFromJsonValue = false;
    };
    /**
     * Returns a JSON object that corresponds to the current SurveyJS object.
     * @see fromJSON
     */
    Base.prototype.toJSON = function (options) {
        return new jsonobject_JsonObject().toJsonObject(this, options);
    };
    /**
     * Assigns a new configuration to the current SurveyJS object. This configuration is taken from a passed JSON object.
     *
     * The JSON object should contain only serializable properties of this SurveyJS object. Event handlers and properties that do not belong to the SurveyJS object are ignored.
     *
     * @param json A JSON object with properties that you want to apply to the current SurveyJS object.
     * @param options An object with configuration options.
     * @param {boolean} options.validatePropertyValues Pass `true` if you want to validate property values. Use the [`jsonErrors`](#jsonErrors) array to access validation errors.
     * @see toJSON
     */
    Base.prototype.fromJSON = function (json, options) {
        new jsonobject_JsonObject().toObject(json, this, options);
        this.onSurveyLoad();
    };
    Base.prototype.onSurveyLoad = function () { };
    /**
     * Creates a new object that has the same type and properties as the current SurveyJS object.
     */
    Base.prototype.clone = function () {
        var clonedObj = Serializer.createClass(this.getType());
        clonedObj.fromJSON(this.toJSON());
        return clonedObj;
    };
    /**
     * Returns a `JsonObjectProperty` object with metadata about a serializable property that belongs to the current SurveyJS object.
     *
     * If the property is not found, this method returns `null`.
     * @param propName A property name.
     */
    Base.prototype.getPropertyByName = function (propName) {
        var type = this.getType();
        if (!this.classMetaData || this.classMetaData.name !== type) {
            this.classMetaData = Serializer.findClass(type);
        }
        return !!this.classMetaData ? this.classMetaData.findProperty(propName) : null;
    };
    Base.prototype.isPropertyVisible = function (propName) {
        var prop = this.getPropertyByName(propName);
        return !!prop ? prop.isVisible("", this) : false;
    };
    Base.createProgressInfo = function () {
        return {
            questionCount: 0,
            answeredQuestionCount: 0,
            requiredQuestionCount: 0,
            requiredAnsweredQuestionCount: 0,
        };
    };
    Base.prototype.getProgressInfo = function () {
        return Base.createProgressInfo();
    };
    Base.prototype.localeChanged = function () { };
    Base.prototype.locStrsChanged = function () {
        if (!!this.arraysInfo) {
            for (var key in this.arraysInfo) {
                var item = this.arraysInfo[key];
                if (item && item.isItemValues) {
                    var arr = this.getPropertyValue(key);
                    if (arr && !!Base.itemValueLocStrChanged)
                        Base.itemValueLocStrChanged(arr);
                }
            }
        }
        if (!!this.localizableStrings) {
            for (var key in this.localizableStrings) {
                var item = this.getLocalizableString(key);
                if (item)
                    item.strChanged();
            }
        }
    };
    /**
     * Returns the value of a property with a specified name.
     *
     * If the property is not found or does not have a value, this method returns either `undefined`, `defaultValue` specified in the property configuration, or a value passed as the `defaultValue` parameter.
     *
     * @param name A property name.
     * @param defaultValue *(Optional)* A value to return if the property is not found or does not have a value.
     */
    Base.prototype.getPropertyValue = function (name, defaultValue) {
        if (defaultValue === void 0) { defaultValue = null; }
        var res = this.getPropertyValueWithoutDefault(name);
        if (this.isPropertyEmpty(res)) {
            var locStr = this.localizableStrings ? this.localizableStrings[name] : undefined;
            if (locStr)
                return locStr.text;
            if (defaultValue !== null && defaultValue !== undefined)
                return defaultValue;
            var propDefaultValue = this.getDefaultPropertyValue(name);
            if (propDefaultValue !== undefined)
                return propDefaultValue;
        }
        return res;
    };
    Base.prototype.getDefaultPropertyValue = function (name) {
        var prop = this.getPropertyByName(name);
        if (!prop || prop.isCustom && this.isCreating)
            return undefined;
        var dValue = prop.defaultValue;
        if (!!prop.defaultValueFunc)
            return dValue;
        if (!this.isPropertyEmpty(dValue) && !Array.isArray(dValue))
            return dValue;
        var locStr = this.localizableStrings ? this.localizableStrings[name] : undefined;
        if (locStr && locStr.localizationName)
            return this.getLocalizationString(locStr.localizationName);
        if (prop.type == "boolean" || prop.type == "switch")
            return false;
        if (prop.isCustom && !!prop.onGetValue)
            return prop.onGetValue(this);
        return undefined;
    };
    Base.prototype.hasDefaultPropertyValue = function (name) {
        return this.getDefaultPropertyValue(name) !== undefined;
    };
    Base.prototype.resetPropertyValue = function (name) {
        var locStr = this.localizableStrings ? this.localizableStrings[name] : undefined;
        if (locStr) {
            this.setLocalizableStringText(name, undefined);
            locStr.clear();
        }
        else {
            this.setPropertyValue(name, undefined);
        }
    };
    Base.prototype.getPropertyValueWithoutDefault = function (name) {
        return this.getPropertyValueCore(this.propertyHash, name);
    };
    Base.prototype.getPropertyValueCore = function (propertiesHash, name) {
        if (!this.isLoadingFromJson) {
            Base.collectDependency(this, name);
        }
        if (this.getPropertyValueCoreHandler)
            return this.getPropertyValueCoreHandler(propertiesHash, name);
        else
            return propertiesHash[name];
    };
    Base.prototype.geValueFromHash = function () {
        return this.propertyHash["value"];
    };
    Base.prototype.setPropertyValueCore = function (propertiesHash, name, val) {
        if (this.setPropertyValueCoreHandler) {
            if (!this.isDisposedValue) {
                this.setPropertyValueCoreHandler(propertiesHash, name, val);
            }
            else {
                ConsoleWarnings.disposedObjectChangedProperty(name, this.getType());
            }
        }
        else
            propertiesHash[name] = val;
    };
    Object.defineProperty(Base.prototype, "isEditingSurveyElement", {
        get: function () {
            var survey = this.getSurvey();
            return !!survey && survey.isEditingSurveyElement;
        },
        enumerable: false,
        configurable: true
    });
    Base.prototype.iteratePropertiesHash = function (func) {
        var _this = this;
        var keys = [];
        for (var key in this.propertyHash) {
            if (key === "value" &&
                this.isEditingSurveyElement &&
                Array.isArray(this.value))
                continue;
            keys.push(key);
        }
        keys.forEach(function (key) { return func(_this.propertyHash, key); });
    };
    /**
     * Assigns a new value to a specified property.
     * @param name A property name.
     * @param val A new value for the property.
     */
    Base.prototype.setPropertyValue = function (name, val) {
        if (!this.isLoadingFromJson) {
            var prop = this.getPropertyByName(name);
            if (!!prop) {
                val = prop.settingValue(this, val);
            }
        }
        var oldValue = this.getPropertyValue(name);
        if (oldValue &&
            Array.isArray(oldValue) &&
            !!this.arraysInfo &&
            (!val || Array.isArray(val))) {
            if (!this.isTwoValueEquals(oldValue, val)) {
                this.setArrayPropertyDirectly(name, val);
            }
        }
        else {
            this.setPropertyValueDirectly(name, val);
            if (!this.isDisposedValue && !this.isTwoValueEquals(oldValue, val)) {
                this.propertyValueChanged(name, oldValue, val);
            }
        }
    };
    Base.prototype.setArrayPropertyDirectly = function (name, val, sendNotification) {
        if (sendNotification === void 0) { sendNotification = true; }
        var arrayInfo = this.arraysInfo[name];
        this.setArray(name, this.getPropertyValue(name), val, arrayInfo ? arrayInfo.isItemValues : false, arrayInfo ? sendNotification && arrayInfo.onPush : null);
    };
    Base.prototype.setPropertyValueDirectly = function (name, val) {
        this.setPropertyValueCore(this.propertyHash, name, val);
    };
    Base.prototype.clearPropertyValue = function (name) {
        this.setPropertyValueCore(this.propertyHash, name, null);
        delete this.propertyHash[name];
    };
    Base.prototype.onPropertyValueChangedCallback = function (name, oldValue, newValue, sender, arrayChanges) { };
    Base.prototype.itemValuePropertyChanged = function (item, name, oldValue, newValue) {
        this.onItemValuePropertyChanged.fire(this, {
            obj: item,
            name: name,
            oldValue: oldValue,
            newValue: newValue,
            propertyName: item.ownerPropertyName,
        });
    };
    Base.prototype.onPropertyValueChanged = function (name, oldValue, newValue) { };
    Base.prototype.propertyValueChanged = function (name, oldValue, newValue, arrayChanges, target) {
        if (this.isLoadingFromJson)
            return;
        this.updateBindings(name, newValue);
        this.onPropertyValueChanged(name, oldValue, newValue);
        this.onPropertyChanged.fire(this, {
            name: name,
            oldValue: oldValue,
            newValue: newValue,
        });
        this.doPropertyValueChangedCallback(name, oldValue, newValue, arrayChanges, this);
        this.checkConditionPropertyChanged(name);
        if (!this.onPropChangeFunctions)
            return;
        for (var i = 0; i < this.onPropChangeFunctions.length; i++) {
            if (this.onPropChangeFunctions[i].name == name)
                this.onPropChangeFunctions[i].func(newValue, arrayChanges);
        }
    };
    Base.prototype.onBindingChanged = function (oldValue, newValue) {
        if (this.isLoadingFromJson)
            return;
        this.doPropertyValueChangedCallback("bindings", oldValue, newValue);
    };
    Object.defineProperty(Base.prototype, "isInternal", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Base.prototype.doPropertyValueChangedCallback = function (name, oldValue, newValue, arrayChanges, target) {
        var fireCallback = function (obj) {
            if (!!obj && !!obj.onPropertyValueChangedCallback) {
                obj.onPropertyValueChangedCallback(name, oldValue, newValue, target, arrayChanges);
            }
        };
        if (this.isInternal) {
            fireCallback(this);
            return;
        }
        if (!target)
            target = this;
        var notifier = this.getSurvey();
        if (!notifier)
            notifier = this;
        fireCallback(notifier);
        if (notifier !== this) {
            fireCallback(this);
        }
    };
    Base.prototype.addExpressionProperty = function (name, onExecute, canRun) {
        if (!this.expressionInfo) {
            this.expressionInfo = {};
        }
        this.expressionInfo[name] = { onExecute: onExecute, canRun: canRun };
    };
    Base.prototype.getDataFilteredValues = function () {
        return {};
    };
    Base.prototype.getDataFilteredProperties = function () {
        return {};
    };
    Base.prototype.runConditionCore = function (values, properties) {
        if (!this.expressionInfo)
            return;
        for (var key in this.expressionInfo) {
            this.runConditionItemCore(key, values, properties);
        }
    };
    Base.prototype.canRunConditions = function () {
        return !this.isDesignMode;
    };
    Base.prototype.checkConditionPropertyChanged = function (propName) {
        if (!this.expressionInfo || !this.expressionInfo[propName])
            return;
        if (!this.canRunConditions())
            return;
        this.runConditionItemCore(propName, this.getDataFilteredValues(), this.getDataFilteredProperties());
    };
    Base.prototype.runConditionItemCore = function (propName, values, properties) {
        var _this = this;
        var info = this.expressionInfo[propName];
        var expression = this.getPropertyValue(propName);
        if (!expression)
            return;
        if (!!info.canRun && !info.canRun(this))
            return;
        if (!info.runner) {
            info.runner = this.createExpressionRunner(expression);
            info.runner.onRunComplete = function (res) {
                info.onExecute(_this, res);
            };
        }
        info.runner.expression = expression;
        info.runner.run(values, properties);
    };
    Base.prototype.doBeforeAsynRun = function (id) {
        if (!this.asynExpressionHash)
            this.asynExpressionHash = [];
        var isChanged = !this.isAsyncExpressionRunning;
        this.asynExpressionHash[id] = true;
        if (isChanged) {
            this.onAsyncRunningChanged();
        }
    };
    Base.prototype.doAfterAsynRun = function (id) {
        if (!!this.asynExpressionHash) {
            delete this.asynExpressionHash[id];
            if (!this.isAsyncExpressionRunning) {
                this.onAsyncRunningChanged();
            }
        }
    };
    Base.prototype.onAsyncRunningChanged = function () { };
    Object.defineProperty(Base.prototype, "isAsyncExpressionRunning", {
        get: function () {
            return !!this.asynExpressionHash && Object.keys(this.asynExpressionHash).length > 0;
        },
        enumerable: false,
        configurable: true
    });
    Base.prototype.createExpressionRunner = function (expression) {
        var _this = this;
        var res = new ExpressionRunner(expression);
        res.onBeforeAsyncRun = function (id) { _this.doBeforeAsynRun(id); };
        res.onAfterAsyncRun = function (id) { _this.doAfterAsynRun(id); };
        return res;
    };
    /**
     * Registers a single value change handler for one or multiple properties.
     *
     * The `registerPropertyChangedHandlers` and [`unregisterPropertyChangedHandlers`](#unregisterPropertyChangedHandlers) methods allow you to manage property change event handlers dynamically. If you only need to attach an event handler without removing it afterwards, you can use the [`onPropertyChanged`](#onPropertyChanged) event instead.
     * @param propertyNames An array of one or multiple property names.
     * @param handler A function to call when one of the listed properties change. Accepts a new property value as an argument.
     * @param key *(Optional)* A key that identifies the current registration. If a function for one of the properties is already registered with the same key, the function will be overwritten. You can also use the key to subsequently unregister handlers.
     * @see unregisterPropertyChangedHandlers
     */
    Base.prototype.registerPropertyChangedHandlers = function (propertyNames, handler, key) {
        if (key === void 0) { key = null; }
        for (var i = 0; i < propertyNames.length; i++) {
            this.registerFunctionOnPropertyValueChanged(propertyNames[i], handler, key);
        }
    };
    /**
     * Unregisters value change event handlers for the specified properties.
     * @param propertyNames An array of one or multiple property names.
     * @param key *(Optional)* A key of the registration that you want to cancel.
     * @see registerPropertyChangedHandlers
     */
    Base.prototype.unregisterPropertyChangedHandlers = function (propertyNames, key) {
        if (key === void 0) { key = null; }
        for (var i = 0; i < propertyNames.length; i++) {
            this.unRegisterFunctionOnPropertyValueChanged(propertyNames[i], key);
        }
    };
    Base.prototype.registerFunctionOnPropertyValueChanged = function (name, func, key) {
        if (key === void 0) { key = null; }
        if (!this.onPropChangeFunctions) {
            this.onPropChangeFunctions = [];
        }
        if (key) {
            for (var i = 0; i < this.onPropChangeFunctions.length; i++) {
                var item = this.onPropChangeFunctions[i];
                if (item.name == name && item.key == key) {
                    item.func = func;
                    return;
                }
            }
        }
        this.onPropChangeFunctions.push({ name: name, func: func, key: key });
    };
    Base.prototype.registerFunctionOnPropertiesValueChanged = function (names, func, key) {
        if (key === void 0) { key = null; }
        this.registerPropertyChangedHandlers(names, func, key);
    };
    Base.prototype.unRegisterFunctionOnPropertyValueChanged = function (name, key) {
        if (key === void 0) { key = null; }
        if (!this.onPropChangeFunctions)
            return;
        for (var i = 0; i < this.onPropChangeFunctions.length; i++) {
            var item = this.onPropChangeFunctions[i];
            if (item.name == name && item.key == key) {
                this.onPropChangeFunctions.splice(i, 1);
                return;
            }
        }
    };
    Base.prototype.unRegisterFunctionOnPropertiesValueChanged = function (names, key) {
        if (key === void 0) { key = null; }
        this.unregisterPropertyChangedHandlers(names, key);
    };
    Base.prototype.createCustomLocalizableObj = function (name) {
        var locStr = this.getLocalizableString(name);
        if (locStr)
            return locStr;
        return this.createLocalizableString(name, this, false, true);
    };
    Base.prototype.getLocale = function () {
        var locOwner = this.getSurvey();
        return !!locOwner ? locOwner.getLocale() : "";
    };
    Base.prototype.getLocalizationString = function (strName) {
        return surveyLocalization.getString(strName, this.getLocale());
    };
    Base.prototype.getLocalizationFormatString = function (strName) {
        var args = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            args[_i - 1] = arguments[_i];
        }
        var str = this.getLocalizationString(strName);
        if (!str || !str.format)
            return "";
        return str.format.apply(str, args);
    };
    Base.prototype.createLocalizableString = function (name, owner, useMarkDown, defaultStr) {
        var _this = this;
        if (useMarkDown === void 0) { useMarkDown = false; }
        if (defaultStr === void 0) { defaultStr = false; }
        var locStr = new localizablestring_LocalizableString(owner, useMarkDown, name);
        if (defaultStr) {
            locStr.localizationName = defaultStr === true ? name : defaultStr;
        }
        locStr.onStrChanged = function (oldValue, newValue) {
            _this.propertyValueChanged(name, oldValue, newValue);
        };
        if (!this.localizableStrings) {
            this.localizableStrings = {};
        }
        this.localizableStrings[name] = locStr;
        var prop = this.getPropertyByName(name);
        locStr.disableLocalization = prop && prop.isLocalizable === false;
        return locStr;
    };
    Base.prototype.getLocalizableString = function (name) {
        return !!this.localizableStrings ? this.localizableStrings[name] : null;
    };
    Base.prototype.getLocalizableStringText = function (name, defaultStr) {
        if (defaultStr === void 0) { defaultStr = ""; }
        Base.collectDependency(this, name);
        var locStr = this.getLocalizableString(name);
        if (!locStr)
            return "";
        var res = locStr.text;
        return res ? res : defaultStr;
    };
    Base.prototype.setLocalizableStringText = function (name, value) {
        var locStr = this.getLocalizableString(name);
        if (!locStr)
            return;
        var oldValue = locStr.text;
        if (oldValue != value) {
            locStr.text = value;
            // this.propertyValueChanged(name, oldValue, value);
        }
    };
    Base.prototype.addUsedLocales = function (locales) {
        if (!!this.localizableStrings) {
            for (var key in this.localizableStrings) {
                var item = this.getLocalizableString(key);
                if (item)
                    this.AddLocStringToUsedLocales(item, locales);
            }
        }
        if (!!this.arraysInfo) {
            for (var key in this.arraysInfo) {
                var prop = this.getPropertyByName(key);
                if (!prop || !prop.isSerializable)
                    continue;
                var items = this.getPropertyValue(key);
                if (!items || !items.length)
                    continue;
                for (var i = 0; i < items.length; i++) {
                    var item = items[i];
                    if (item && item.addUsedLocales) {
                        item.addUsedLocales(locales);
                    }
                }
            }
        }
    };
    Base.prototype.searchText = function (text, founded) {
        var strs = [];
        this.getSearchableLocalizedStrings(strs);
        for (var i = 0; i < strs.length; i++) {
            if (strs[i].setFindText(text)) {
                founded.push({ element: this, str: strs[i] });
            }
        }
    };
    Base.prototype.getSearchableLocalizedStrings = function (arr) {
        if (!!this.localizableStrings) {
            var keys_1 = [];
            this.getSearchableLocKeys(keys_1);
            for (var i = 0; i < keys_1.length; i++) {
                var item = this.getLocalizableString(keys_1[i]);
                if (item)
                    arr.push(item);
            }
        }
        if (!this.arraysInfo)
            return;
        var keys = [];
        this.getSearchableItemValueKeys(keys);
        for (var i = 0; i < keys.length; i++) {
            var items = this.getPropertyValue(keys[i]);
            if (!items)
                continue;
            for (var j = 0; j < items.length; j++) {
                arr.push(items[j].locText);
            }
        }
    };
    Base.prototype.getSearchableLocKeys = function (keys) { };
    Base.prototype.getSearchableItemValueKeys = function (keys) { };
    Base.prototype.AddLocStringToUsedLocales = function (locStr, locales) {
        var locs = locStr.getLocales();
        for (var i = 0; i < locs.length; i++) {
            if (locales.indexOf(locs[i]) < 0) {
                locales.push(locs[i]);
            }
        }
    };
    Base.prototype.createItemValues = function (name) {
        var self = this;
        var result = this.createNewArray(name, function (item) {
            item.locOwner = self;
            item.ownerPropertyName = name;
            if (typeof item.getSurvey == "function") {
                var survey = item.getSurvey();
                if (!!survey && typeof survey.makeReactive == "function") {
                    survey.makeReactive(item);
                }
            }
        });
        this.arraysInfo[name].isItemValues = true;
        return result;
    };
    Base.prototype.notifyArrayChanged = function (ar, arrayChanges) {
        !!ar.onArrayChanged && ar.onArrayChanged(arrayChanges);
    };
    Base.prototype.createNewArrayCore = function (name) {
        var res = null;
        if (!!this.createArrayCoreHandler) {
            res = this.createArrayCoreHandler(this.propertyHash, name);
        }
        if (!res) {
            res = new Array();
            this.setPropertyValueCore(this.propertyHash, name, res);
        }
        return res;
    };
    Base.prototype.ensureArray = function (name, onPush, onRemove) {
        if (onPush === void 0) { onPush = null; }
        if (onRemove === void 0) { onRemove = null; }
        if (this.arraysInfo && this.arraysInfo[name]) {
            return;
        }
        return this.createNewArray(name, onPush, onRemove);
    };
    Base.prototype.createNewArray = function (name, onPush, onRemove) {
        if (onPush === void 0) { onPush = null; }
        if (onRemove === void 0) { onRemove = null; }
        var newArray = this.createNewArrayCore(name);
        if (!this.arraysInfo) {
            this.arraysInfo = {};
        }
        this.arraysInfo[name] = { onPush: onPush, isItemValues: false };
        var self = this;
        newArray.push = function (value) {
            var result = Object.getPrototypeOf(newArray).push.call(newArray, value);
            if (!self.isDisposedValue) {
                if (onPush)
                    onPush(value, newArray.length - 1);
                var arrayChanges = new ArrayChanges(newArray.length - 1, 0, [value], []);
                self.propertyValueChanged(name, newArray, newArray, arrayChanges);
                self.notifyArrayChanged(newArray, arrayChanges);
            }
            return result;
        };
        newArray.shift = function () {
            var result = Object.getPrototypeOf(newArray).shift.call(newArray);
            if (!self.isDisposedValue && result) {
                if (onRemove)
                    onRemove(result);
                var arrayChanges = new ArrayChanges(newArray.length - 1, 1, [], []);
                self.propertyValueChanged(name, newArray, newArray, arrayChanges);
                self.notifyArrayChanged(newArray, arrayChanges);
            }
            return result;
        };
        newArray.unshift = function (value) {
            var result = Object.getPrototypeOf(newArray).unshift.call(newArray, value);
            if (!self.isDisposedValue) {
                if (onPush)
                    onPush(value, newArray.length - 1);
                var arrayChanges = new ArrayChanges(0, 0, [value], []);
                self.propertyValueChanged(name, newArray, newArray, arrayChanges);
                self.notifyArrayChanged(newArray, arrayChanges);
            }
            return result;
        };
        newArray.pop = function () {
            var result = Object.getPrototypeOf(newArray).pop.call(newArray);
            if (!self.isDisposedValue) {
                if (onRemove)
                    onRemove(result);
                var arrayChanges = new ArrayChanges(newArray.length - 1, 1, [], []);
                self.propertyValueChanged(name, newArray, newArray, arrayChanges);
                self.notifyArrayChanged(newArray, arrayChanges);
            }
            return result;
        };
        newArray.splice = function (start, deleteCount) {
            var _a;
            var items = [];
            for (var _i = 2; _i < arguments.length; _i++) {
                items[_i - 2] = arguments[_i];
            }
            if (!start)
                start = 0;
            if (!deleteCount)
                deleteCount = 0;
            var result = (_a = Object.getPrototypeOf(newArray).splice).call.apply(_a, base_spreadArray([newArray,
                start,
                deleteCount], items));
            if (!items)
                items = [];
            if (!self.isDisposedValue) {
                if (onRemove && result) {
                    for (var i = 0; i < result.length; i++) {
                        onRemove(result[i]);
                    }
                }
                if (onPush) {
                    for (var i = 0; i < items.length; i++) {
                        onPush(items[i], start + i);
                    }
                }
                var arrayChanges = new ArrayChanges(start, deleteCount, items, result);
                self.propertyValueChanged(name, newArray, newArray, arrayChanges);
                self.notifyArrayChanged(newArray, arrayChanges);
            }
            return result;
        };
        return newArray;
    };
    Base.prototype.getItemValueType = function () {
        return undefined;
    };
    Base.prototype.setArray = function (name, src, dest, isItemValues, onPush) {
        var deletedItems = [].concat(src);
        Object.getPrototypeOf(src).splice.call(src, 0, src.length);
        if (!!dest) {
            for (var i = 0; i < dest.length; i++) {
                var item = dest[i];
                if (isItemValues) {
                    if (!!Base.createItemValue) {
                        item = Base.createItemValue(item, this.getItemValueType());
                    }
                }
                Object.getPrototypeOf(src).push.call(src, item);
                if (onPush)
                    onPush(src[i]);
            }
        }
        var arrayChanges = new ArrayChanges(0, deletedItems.length, src, deletedItems);
        this.propertyValueChanged(name, deletedItems, src, arrayChanges);
        this.notifyArrayChanged(src, arrayChanges);
    };
    Base.prototype.isTwoValueEquals = function (x, y, caseInSensitive, trimString) {
        if (caseInSensitive === void 0) { caseInSensitive = false; }
        if (trimString === void 0) { trimString = false; }
        return helpers_Helpers.isTwoValueEquals(x, y, false, !caseInSensitive, trimString);
    };
    Base.copyObject = function (dst, src) {
        for (var key in src) {
            var source = src[key];
            if (typeof source === "object") {
                source = {};
                this.copyObject(source, src[key]);
            }
            dst[key] = source;
        }
    };
    Base.prototype.copyCssClasses = function (dest, source) {
        if (!source)
            return;
        if (typeof source === "string" || source instanceof String) {
            dest["root"] = source;
        }
        else {
            Base.copyObject(dest, source);
        }
    };
    Base.prototype.getValueInLowCase = function (val) {
        if (!!val && typeof val == "string")
            return val.toLowerCase();
        return val;
    };
    Base.prototype.getElementsInDesign = function (includeHidden) {
        if (includeHidden === void 0) { includeHidden = false; }
        return [];
    };
    Object.defineProperty(Base.prototype, "animationAllowed", {
        get: function () {
            return this.getIsAnimationAllowed();
        },
        enumerable: false,
        configurable: true
    });
    Base.prototype.getIsAnimationAllowed = function () {
        return settings.animationEnabled && this.animationAllowedLock >= 0 && !this.isLoadingFromJson && !this.isDisposed && (!!this.onElementRerendered || !this.supportOnElementRenderedEvent);
    };
    Base.prototype.blockAnimations = function () {
        this.animationAllowedLock--;
    };
    Base.prototype.releaseAnimations = function () {
        this.animationAllowedLock++;
    };
    Base.prototype.enableOnElementRenderedEvent = function () {
        this.onElementRenderedEventEnabled = true;
    };
    Base.prototype.disableOnElementRenderedEvent = function () {
        this.onElementRenderedEventEnabled = false;
    };
    Object.defineProperty(Base.prototype, "onElementRerendered", {
        get: function () {
            return this.supportOnElementRenderedEvent && this.onElementRenderedEventEnabled ? this._onElementRerendered : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Base.prototype.afterRerender = function () {
        var _a;
        (_a = this.onElementRerendered) === null || _a === void 0 ? void 0 : _a.fire(this, undefined);
    };
    Base.currentDependencis = undefined;
    return Base;
}());

var ArrayChanges = /** @class */ (function () {
    function ArrayChanges(index, deleteCount, itemsToAdd, deletedItems) {
        this.index = index;
        this.deleteCount = deleteCount;
        this.itemsToAdd = itemsToAdd;
        this.deletedItems = deletedItems;
    }
    return ArrayChanges;
}());

var Event = /** @class */ (function () {
    function Event() {
    }
    Object.defineProperty(Event.prototype, "isEmpty", {
        get: function () {
            return this.length === 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Event.prototype, "length", {
        get: function () {
            return !!this.callbacks ? this.callbacks.length : 0;
        },
        enumerable: false,
        configurable: true
    });
    Event.prototype.fireByCreatingOptions = function (sender, createOptions) {
        if (!this.callbacks)
            return;
        for (var i = 0; i < this.callbacks.length; i++) {
            this.callbacks[i](sender, createOptions());
            if (!this.callbacks)
                return;
        }
    };
    Event.prototype.fire = function (sender, options) {
        if (!this.callbacks)
            return;
        var callbacks = [].concat(this.callbacks);
        for (var i = 0; i < callbacks.length; i++) {
            callbacks[i](sender, options);
            if (!this.callbacks)
                return;
        }
    };
    Event.prototype.clear = function () {
        this.callbacks = undefined;
    };
    Event.prototype.add = function (func) {
        if (this.hasFunc(func))
            return;
        if (!this.callbacks) {
            this.callbacks = new Array();
        }
        this.callbacks.push(func);
        this.fireCallbackChanged();
    };
    Event.prototype.remove = function (func) {
        if (this.hasFunc(func)) {
            var index = this.callbacks.indexOf(func, 0);
            this.callbacks.splice(index, 1);
            this.fireCallbackChanged();
        }
    };
    Event.prototype.hasFunc = function (func) {
        if (this.callbacks == null)
            return false;
        return this.callbacks.indexOf(func, 0) > -1;
    };
    Event.prototype.fireCallbackChanged = function () {
        if (!!this.onCallbacksChanged) {
            this.onCallbacksChanged();
        }
    };
    return Event;
}());

var EventBase = /** @class */ (function (_super) {
    base_extends(EventBase, _super);
    function EventBase() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return EventBase;
}(Event));


// CONCATENATED MODULE: ./packages/survey-core/src/utils/responsivity-manager.ts
var responsivity_manager_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();


var responsivity_manager_ResponsivityManager = /** @class */ (function () {
    function ResponsivityManager(container, model, itemsSelector, dotsItemSize, delayedUpdateFunction) {
        var _this = this;
        if (dotsItemSize === void 0) { dotsItemSize = null; }
        this.container = container;
        this.model = model;
        this.itemsSelector = itemsSelector;
        this.dotsItemSize = dotsItemSize;
        this.delayedUpdateFunction = delayedUpdateFunction;
        this.resizeObserver = undefined;
        this.isInitialized = false;
        this.minDimensionConst = 56;
        this.separatorSize = 17;
        this.separatorAddConst = 1;
        this.paddingSizeConst = 8;
        this.dotsSizeConst = 48;
        this.recalcMinDimensionConst = true;
        this.getComputedStyle = function (elt) {
            return DomDocumentHelper.getComputedStyle(elt);
        };
        this.model.updateCallback = function (isResetInitialized) {
            if (isResetInitialized)
                _this.isInitialized = false;
            setTimeout(function () { _this.process(); }, 1);
        };
        if (typeof ResizeObserver !== "undefined") {
            this.resizeObserver = new ResizeObserver(function (entries) {
                DomWindowHelper.requestAnimationFrame(function () {
                    _this.process();
                });
            });
            this.resizeObserver.observe(this.container.parentElement);
        }
    }
    ResponsivityManager.prototype.getDimensions = function (element) {
        return {
            scroll: element.scrollWidth,
            offset: element.offsetWidth,
        };
    };
    ResponsivityManager.prototype.getAvailableSpace = function () {
        var style = this.getComputedStyle(this.container);
        var space = this.container.offsetWidth;
        if (style.boxSizing === "border-box") {
            space -= parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
        }
        return space;
    };
    ResponsivityManager.prototype.calcItemSize = function (item) {
        return item.offsetWidth;
    };
    ResponsivityManager.prototype.calcMinDimension = function (currentAction) {
        var minDimensionConst = this.minDimensionConst;
        if (currentAction.iconSize && this.recalcMinDimensionConst) {
            minDimensionConst = 2 * currentAction.iconSize + this.paddingSizeConst;
        }
        return currentAction.canShrink
            ? minDimensionConst +
                (currentAction.needSeparator ? this.separatorSize : 0)
            : currentAction.maxDimension;
    };
    ResponsivityManager.prototype.getRenderedVisibleActionsCount = function () {
        var _this = this;
        var count = 0;
        this.container.querySelectorAll(this.itemsSelector).forEach(function (item) {
            if (_this.calcItemSize(item) > 0) {
                count++;
            }
        });
        return count;
    };
    ResponsivityManager.prototype.calcItemsSizes = function () {
        var _this = this;
        if (this.isInitialized)
            return;
        var actions = this.model.actions;
        var _items = this.container.querySelectorAll(this.itemsSelector);
        (_items || []).forEach(function (item, index) {
            var currentAction = actions[index];
            _this.calcActionDimensions(currentAction, item);
        });
    };
    ResponsivityManager.prototype.calcActionDimensions = function (currentAction, item) {
        currentAction.maxDimension = this.calcItemSize(item);
        currentAction.minDimension = this.calcMinDimension(currentAction);
    };
    Object.defineProperty(ResponsivityManager.prototype, "isContainerVisible", {
        get: function () {
            return isContainerVisible(this.container);
        },
        enumerable: false,
        configurable: true
    });
    ResponsivityManager.prototype.process = function () {
        var _this = this;
        if (this.isContainerVisible && !this.model.isResponsivenessDisabled) {
            if (!this.isInitialized) {
                this.model.setActionsMode("large");
            }
            var processResponsiveness_1 = function () {
                var _a;
                var dotsItemSize = _this.dotsItemSize;
                if (!_this.dotsItemSize) {
                    var dotsItemElement = (_a = _this.container) === null || _a === void 0 ? void 0 : _a.querySelector(".sv-dots");
                    dotsItemSize = dotsItemElement && _this.calcItemSize(dotsItemElement) || _this.dotsSizeConst;
                }
                _this.model.fit(_this.getAvailableSpace(), dotsItemSize);
            };
            if (!this.isInitialized) {
                var callback = function () {
                    _this.calcItemsSizes();
                    _this.isInitialized = true;
                    processResponsiveness_1();
                };
                if (this.getRenderedVisibleActionsCount() < this.model.visibleActions.length) {
                    if (this.delayedUpdateFunction) {
                        this.delayedUpdateFunction(callback);
                    }
                    else if (queueMicrotask) {
                        queueMicrotask(callback);
                    }
                    else {
                        callback();
                    }
                }
                else {
                    callback();
                }
            }
            else {
                processResponsiveness_1();
            }
        }
    };
    ResponsivityManager.prototype.dispose = function () {
        this.model.updateCallback = undefined;
        if (!!this.resizeObserver) {
            this.resizeObserver.disconnect();
        }
    };
    return ResponsivityManager;
}());

var VerticalResponsivityManager = /** @class */ (function (_super) {
    responsivity_manager_extends(VerticalResponsivityManager, _super);
    function VerticalResponsivityManager(container, model, itemsSelector, dotsItemSize, minDimension, delayedUpdateFunction) {
        if (minDimension === void 0) { minDimension = 40; }
        var _this = _super.call(this, container, model, itemsSelector, dotsItemSize, delayedUpdateFunction) || this;
        _this.minDimensionConst = minDimension;
        _this.recalcMinDimensionConst = false;
        return _this;
    }
    VerticalResponsivityManager.prototype.getDimensions = function () {
        return {
            scroll: this.container.scrollHeight,
            offset: this.container.offsetHeight,
        };
    };
    VerticalResponsivityManager.prototype.getAvailableSpace = function () {
        var style = this.getComputedStyle(this.container);
        var space = this.container.offsetHeight;
        if (style.boxSizing === "border-box") {
            space -= parseFloat(style.paddingTop) + parseFloat(style.paddingBottom);
        }
        return space;
    };
    VerticalResponsivityManager.prototype.calcItemSize = function (item) {
        return item.offsetHeight;
    };
    VerticalResponsivityManager.prototype.calcActionDimensions = function (currentAction, item) {
        currentAction.maxDimension = this.calcItemSize(item);
        currentAction.minDimension = this.calcItemSize(item);
    };
    return VerticalResponsivityManager;
}(responsivity_manager_ResponsivityManager));


// CONCATENATED MODULE: ./packages/survey-core/src/utils/cssClassBuilder.ts
var CssClassBuilder = /** @class */ (function () {
    function CssClassBuilder() {
        this.classes = [];
    }
    CssClassBuilder.prototype.isEmpty = function () {
        return this.toString() === "";
    };
    CssClassBuilder.prototype.append = function (value, condition) {
        if (condition === void 0) { condition = true; }
        if (!!value && condition) {
            if (typeof value === "string") {
                value = value.trim();
            }
            this.classes.push(value);
        }
        return this;
    };
    CssClassBuilder.prototype.toString = function () {
        return this.classes.join(" ");
    };
    return CssClassBuilder;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/actions/container.ts
var container_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};





var defaultActionBarCss = {
    root: "sv-action-bar",
    defaultSizeMode: "sv-action-bar--default-size-mode",
    smallSizeMode: "sv-action-bar--small-size-mode",
    item: "sv-action-bar-item",
    itemWithTitle: "",
    itemAsIcon: "sv-action-bar-item--icon",
    itemActive: "sv-action-bar-item--active",
    itemPressed: "sv-action-bar-item--pressed",
    itemIcon: "sv-action-bar-item__icon",
    itemTitle: "sv-action-bar-item__title",
    itemTitleWithIcon: "sv-action-bar-item__title--with-icon",
};
var container_ActionContainer = /** @class */ (function (_super) {
    container_extends(ActionContainer, _super);
    function ActionContainer() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.sizeMode = "default";
        return _this;
    }
    ActionContainer.prototype.getMarkdownHtml = function (text, name) {
        return !!this.locOwner ? this.locOwner.getMarkdownHtml(text, name) : undefined;
    };
    ActionContainer.prototype.getRenderer = function (name) {
        return !!this.locOwner ? this.locOwner.getRenderer(name) : null;
    };
    ActionContainer.prototype.getRendererContext = function (locStr) {
        return !!this.locOwner ? this.locOwner.getRendererContext(locStr) : locStr;
    };
    ActionContainer.prototype.getProcessedText = function (text) {
        return this.locOwner ? this.locOwner.getProcessedText(text) : text;
    };
    ActionContainer.prototype.getLocale = function () {
        return !!this.locOwner ? this.locOwner.getLocale() : "";
    };
    ActionContainer.prototype.getRenderedActions = function () {
        return this.actions;
    };
    ActionContainer.prototype.locStrsChanged = function () {
        _super.prototype.locStrsChanged.call(this);
        this.actions.forEach(function (item) {
            if (item.locTitle)
                item.locTitle.strChanged();
            item.locStrsChanged();
        });
    };
    ActionContainer.prototype.raiseUpdate = function (isResetInitialized) {
        this.isEmpty = !this.actions.some(function (action) { return action.visible; });
        this.updateCallback && this.updateCallback(isResetInitialized);
    };
    ActionContainer.prototype.onSet = function () {
        var _this = this;
        this.actions.forEach(function (item) { _this.setActionCssClasses(item); });
        this.raiseUpdate(true);
    };
    ActionContainer.prototype.onPush = function (item) {
        this.setActionCssClasses(item);
        item.owner = this;
        this.raiseUpdate(true);
    };
    ActionContainer.prototype.onRemove = function (item) {
        item.owner = null;
        this.raiseUpdate(true);
    };
    ActionContainer.prototype.setActionCssClasses = function (item) {
        item.cssClasses = this.cssClasses;
    };
    Object.defineProperty(ActionContainer.prototype, "hasActions", {
        get: function () {
            return (this.actions || []).length > 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ActionContainer.prototype, "renderedActions", {
        get: function () {
            return this.getRenderedActions();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ActionContainer.prototype, "visibleActions", {
        get: function () {
            return this.actions.filter(function (action) { return action.visible !== false; });
        },
        enumerable: false,
        configurable: true
    });
    ActionContainer.prototype.getRootCss = function () {
        var sizeModeClass = this.sizeMode === "small" ? this.cssClasses.smallSizeMode : this.cssClasses.defaultSizeMode;
        return new CssClassBuilder().append(this.cssClasses.root + (!!sizeModeClass ? " " + sizeModeClass : "") + (!!this.containerCss ? " " + this.containerCss : ""))
            .append(this.cssClasses.root + "--empty", this.isEmpty)
            .toString();
    };
    ActionContainer.prototype.getDefaultCssClasses = function () {
        return defaultActionBarCss;
    };
    Object.defineProperty(ActionContainer.prototype, "cssClasses", {
        get: function () {
            if (!this.cssClassesValue) {
                this.cssClassesValue = this.getDefaultCssClasses();
            }
            return this.cssClassesValue;
        },
        set: function (val) {
            var _this = this;
            this.cssClassesValue = {};
            this.copyCssClasses(this.cssClassesValue, this.getDefaultCssClasses());
            mergeValues(val, this.cssClasses);
            this.actions.forEach(function (action) {
                _this.setActionCssClasses(action);
            });
        },
        enumerable: false,
        configurable: true
    });
    ActionContainer.prototype.createAction = function (item) {
        return (item instanceof action_BaseAction ? item : new action_Action(item));
    };
    ActionContainer.prototype.addAction = function (val, sortByVisibleIndex) {
        if (sortByVisibleIndex === void 0) { sortByVisibleIndex = true; }
        var res = this.createAction(val);
        this.actions.push(res);
        this.sortItems();
        return res;
    };
    ActionContainer.prototype.sortItems = function () {
        this.actions = []
            .concat(this.actions.filter(function (item) { return item.visibleIndex === undefined || item.visibleIndex >= 0; }))
            .sort(function (firstItem, secondItem) {
            return firstItem.visibleIndex - secondItem.visibleIndex;
        });
    };
    ActionContainer.prototype.setItems = function (items, sortByVisibleIndex) {
        var _this = this;
        if (sortByVisibleIndex === void 0) { sortByVisibleIndex = true; }
        this.actions = items.map(function (item) { return _this.createAction(item); });
        if (sortByVisibleIndex) {
            this.sortItems();
        }
    };
    ActionContainer.prototype.popupAfterShowCallback = function (itemValue) {
    };
    ActionContainer.prototype.mouseOverHandler = function (itemValue) {
        var _this = this;
        itemValue.isHovered = true;
        this.actions.forEach(function (action) {
            if (action === itemValue && !!itemValue.popupModel) {
                itemValue.showPopupDelayed(_this.subItemsShowDelay);
                _this.popupAfterShowCallback(itemValue);
            }
        });
    };
    ActionContainer.prototype.initResponsivityManager = function (container, delayedUpdateFunction) {
        return;
    };
    ActionContainer.prototype.resetResponsivityManager = function () { };
    ActionContainer.prototype.getActionById = function (id) {
        for (var i = 0; i < this.actions.length; i++) {
            if (this.actions[i].id === id)
                return this.actions[i];
        }
        return null;
    };
    ActionContainer.prototype.dispose = function () {
        _super.prototype.dispose.call(this);
        this.actions.forEach(function (action) { return action.dispose(); });
        this.actions.length = 0;
    };
    __decorate([
        propertyArray({
            onSet: function (_, target) {
                target.onSet();
            },
            onPush: function (item, i, target) {
                target.onPush(item);
            },
            onRemove: function (item, i, target) {
                target.onRemove(item);
            }
        })
    ], ActionContainer.prototype, "actions", void 0);
    __decorate([
        jsonobject_property({})
    ], ActionContainer.prototype, "containerCss", void 0);
    __decorate([
        jsonobject_property({ defaultValue: false })
    ], ActionContainer.prototype, "isEmpty", void 0);
    __decorate([
        jsonobject_property({ defaultValue: 300 })
    ], ActionContainer.prototype, "subItemsShowDelay", void 0);
    __decorate([
        jsonobject_property({ defaultValue: 300 })
    ], ActionContainer.prototype, "subItemsHideDelay", void 0);
    return ActionContainer;
}(base_Base));


// CONCATENATED MODULE: ./packages/survey-core/src/element-helper.ts

var element_helper_ElementHelper = /** @class */ (function () {
    function ElementHelper() {
    }
    ElementHelper.focusElement = function (element) {
        element && element.focus();
    };
    ElementHelper.visibility = function (node) {
        var style = DomDocumentHelper.getComputedStyle(node);
        if (style.display === "none" || style.visibility === "hidden")
            return false;
        return node.parentElement ? this.visibility(node.parentElement) : true;
    };
    ElementHelper.getNextElementPreorder = function (element) {
        var result = !!element.nextElementSibling ? element.nextElementSibling : element.parentElement.firstElementChild;
        if (this.visibility(result)) {
            return result;
        }
        else {
            return this.getNextElementPreorder(result);
        }
    };
    ElementHelper.getNextElementPostorder = function (element) {
        var result = !!element.previousElementSibling ? element.previousElementSibling : element.parentElement.lastElementChild;
        if (this.visibility(result)) {
            return result;
        }
        else {
            return this.getNextElementPostorder(result);
        }
    };
    ElementHelper.hasHorizontalScroller = function (element) {
        if (!!element) {
            return element.scrollWidth > element.offsetWidth;
        }
        return false;
    };
    ElementHelper.hasVerticalScroller = function (element) {
        if (!!element) {
            return element.scrollHeight > element.offsetHeight;
        }
        return false;
    };
    return ElementHelper;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/list.ts
var list_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var list_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};







var defaultListCss = {
    root: "sv-list__container",
    item: "sv-list__item",
    searchClearButtonIcon: "sv-list__filter-clear-button",
    loadingIndicator: "sv-list__loading-indicator",
    itemSelected: "sv-list__item--selected",
    itemGroup: "sv-list__item--group",
    itemWithIcon: "sv-list__item--with-icon",
    itemDisabled: "sv-list__item--disabled",
    itemFocused: "sv-list__item--focused",
    itemHovered: "sv-list__item--hovered",
    itemTextWrap: "sv-list__item-text--wrap",
    itemIcon: "sv-list__item-icon",
    itemMarkerIcon: "sv-list-item__marker-icon",
    itemSeparator: "sv-list__item-separator",
    itemBody: "sv-list__item-body",
    itemsContainer: "sv-list",
    itemsContainerFiltering: "sv-list--filtering",
    filter: "sv-list__filter",
    filterIcon: "sv-list__filter-icon",
    filterInput: "sv-list__input",
    emptyContainer: "sv-list__empty-container",
    emptyText: "sv-list__empty-text"
};
var list_ListModel = /** @class */ (function (_super) {
    list_extends(ListModel, _super);
    function ListModel(items, onSelectionChanged, allowSelection, selectedItem, elementId) {
        var _this = _super.call(this) || this;
        _this.onSelectionChanged = onSelectionChanged;
        _this.allowSelection = allowSelection;
        _this.elementId = elementId;
        _this.onItemClick = function (itemValue) {
            if (_this.isItemDisabled(itemValue)) {
                return;
            }
            _this.isExpanded = false;
            if (_this.allowSelection) {
                _this.selectedItem = itemValue;
            }
            if (!!_this.onSelectionChanged) {
                _this.onSelectionChanged(itemValue);
            }
            var action = itemValue.action;
            if (!!action) {
                action(itemValue);
            }
        };
        _this.onItemHover = function (itemValue) {
            _this.mouseOverHandler(itemValue);
        };
        _this.isItemDisabled = function (itemValue) {
            return itemValue.enabled !== undefined && !itemValue.enabled;
        };
        _this.isItemSelected = function (itemValue) {
            return _this.areSameItems(_this.selectedItem, itemValue);
        };
        _this.isItemFocused = function (itemValue) {
            return _this.areSameItems(_this.focusedItem, itemValue);
        };
        _this.getListClass = function () {
            return new CssClassBuilder()
                .append(_this.cssClasses.itemsContainer)
                .append(_this.cssClasses.itemsContainerFiltering, !!_this.filterString && _this.visibleActions.length !== _this.visibleItems.length)
                .toString();
        };
        _this.getItemClass = function (itemValue) {
            return new CssClassBuilder()
                .append(_this.cssClasses.item)
                .append(_this.cssClasses.itemWithIcon, !!itemValue.iconName)
                .append(_this.cssClasses.itemDisabled, _this.isItemDisabled(itemValue))
                .append(_this.cssClasses.itemFocused, _this.isItemFocused(itemValue))
                .append(_this.cssClasses.itemSelected, _this.isItemSelected(itemValue))
                .append(_this.cssClasses.itemGroup, itemValue.hasSubItems)
                .append(_this.cssClasses.itemHovered, itemValue.isHovered)
                .append(_this.cssClasses.itemTextWrap, _this.textWrapEnabled)
                .append(itemValue.css)
                .toString();
        };
        _this.getItemIndent = function (itemValue) {
            var level = itemValue.level || 0;
            return (level + 1) * ListModel.INDENT + "px";
        };
        if (Object.keys(items).indexOf("items") !== -1) {
            var options_1 = items;
            Object.keys(options_1).forEach(function (key) {
                switch (key) {
                    case "items":
                        _this.setItems(options_1.items);
                        break;
                    case "onFilterStringChangedCallback":
                        _this.setOnFilterStringChangedCallback(options_1.onFilterStringChangedCallback);
                        break;
                    case "onTextSearchCallback":
                        _this.setOnTextSearchCallback(options_1.onTextSearchCallback);
                        break;
                    default:
                        _this[key] = options_1[key];
                }
            });
        }
        else {
            _this.setItems(items);
            _this.selectedItem = selectedItem;
        }
        return _this;
    }
    ListModel.prototype.hasText = function (item, filterStringInLow) {
        if (!filterStringInLow)
            return true;
        var text = item.title || "";
        if (this.onTextSearchCallback)
            return this.onTextSearchCallback(item, filterStringInLow);
        var textInLow = text.toLocaleLowerCase();
        textInLow = settings.comparator.normalizeTextCallback(textInLow, "filter");
        return textInLow.indexOf(filterStringInLow.toLocaleLowerCase()) > -1;
    };
    ListModel.prototype.isItemVisible = function (item) {
        return item.visible && (!this.shouldProcessFilter || this.hasText(item, this.filterString));
    };
    ListModel.prototype.getRenderedActions = function () {
        var actions = _super.prototype.getRenderedActions.call(this);
        if (this.filterString) {
            var newActions_1 = [];
            actions.forEach(function (action) {
                newActions_1.push(action);
                if (action.items) {
                    action.items.forEach(function (item) {
                        var a = new action_Action(item);
                        if (!a.iconName) {
                            a.iconName = action.iconName;
                        }
                        newActions_1.push(a);
                    });
                }
            });
            return newActions_1;
        }
        return actions;
    };
    Object.defineProperty(ListModel.prototype, "visibleItems", {
        get: function () {
            var _this = this;
            return this.visibleActions.filter(function (item) { return _this.isItemVisible(item); });
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ListModel.prototype, "shouldProcessFilter", {
        get: function () {
            return !this.onFilterStringChangedCallback;
        },
        enumerable: false,
        configurable: true
    });
    ListModel.prototype.onFilterStringChanged = function (text) {
        var _this = this;
        if (!!this.onFilterStringChangedCallback) {
            this.onFilterStringChangedCallback(text);
        }
        this.isEmpty = this.renderedActions.filter(function (action) { return _this.isItemVisible(action); }).length === 0;
    };
    ListModel.prototype.scrollToItem = function (selector, ms) {
        var _this = this;
        if (ms === void 0) { ms = 0; }
        setTimeout(function () {
            if (!_this.listContainerHtmlElement)
                return;
            var item = _this.listContainerHtmlElement.querySelector("." + selector);
            if (item) {
                setTimeout(function () {
                    item.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "start" });
                }, ms);
            }
        }, ms);
    };
    ListModel.prototype.setOnFilterStringChangedCallback = function (callback) {
        this.onFilterStringChangedCallback = callback;
    };
    ListModel.prototype.setOnTextSearchCallback = function (callback) {
        this.onTextSearchCallback = callback;
    };
    ListModel.prototype.setItems = function (items, sortByVisibleIndex) {
        var _this = this;
        if (sortByVisibleIndex === void 0) { sortByVisibleIndex = true; }
        _super.prototype.setItems.call(this, items, sortByVisibleIndex);
        if (this.elementId) {
            this.renderedActions.forEach(function (action) { action.elementId = _this.elementId + action.id; });
        }
        if (!this.isAllDataLoaded && !!this.actions.length) {
            this.actions.push(this.loadingIndicator);
        }
    };
    ListModel.prototype.onSet = function () {
        this.showFilter = this.searchEnabled && (this.forceShowFilter || (this.actions || []).length > ListModel.MINELEMENTCOUNT);
        _super.prototype.onSet.call(this);
    };
    ListModel.prototype.getDefaultCssClasses = function () {
        return defaultListCss;
    };
    ListModel.prototype.popupAfterShowCallback = function (itemValue) {
        this.addScrollEventListener(function () {
            itemValue.hidePopup();
        });
    };
    ListModel.prototype.onItemLeave = function (itemValue) {
        itemValue.hidePopupDelayed(this.subItemsHideDelay);
    };
    ListModel.prototype.areSameItems = function (item1, item2) {
        if (!!this.areSameItemsCallback)
            return this.areSameItemsCallback(item1, item2);
        return !!item1 && !!item2 && item1.id == item2.id;
    };
    Object.defineProperty(ListModel.prototype, "filterStringPlaceholder", {
        get: function () {
            return this.getLocalizationString("filterStringPlaceholder");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ListModel.prototype, "emptyMessage", {
        get: function () {
            return this.isAllDataLoaded ? this.getLocalizationString("emptyMessage") : this.loadingText;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ListModel.prototype, "scrollableContainer", {
        get: function () {
            return this.listContainerHtmlElement.querySelector("." + this.getDefaultCssClasses().itemsContainer);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ListModel.prototype, "loadingText", {
        get: function () {
            return this.getLocalizationString("loadingFile");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ListModel.prototype, "loadingIndicator", {
        get: function () {
            if (!this.loadingIndicatorValue) {
                this.loadingIndicatorValue = (new action_Action({
                    id: "loadingIndicator",
                    title: this.loadingText,
                    action: function () { },
                    css: this.cssClasses.loadingIndicator
                }));
            }
            return this.loadingIndicatorValue;
        },
        enumerable: false,
        configurable: true
    });
    ListModel.prototype.goToItems = function (event) {
        if (event.key === "ArrowDown" || event.keyCode === 40) {
            var currentElement = event.target.parentElement;
            var listElement = currentElement.parentElement.querySelector("ul");
            var firstChild = getFirstVisibleChild(listElement);
            if (!!listElement && !!firstChild) {
                element_helper_ElementHelper.focusElement(firstChild);
                event.preventDefault();
            }
        }
    };
    ListModel.prototype.onMouseMove = function (event) {
        this.resetFocusedItem();
    };
    ListModel.prototype.onKeyDown = function (event) {
        var currentElement = event.target;
        if (event.key === "ArrowDown" || event.keyCode === 40) {
            element_helper_ElementHelper.focusElement(element_helper_ElementHelper.getNextElementPreorder(currentElement));
            event.preventDefault();
        }
        else if (event.key === "ArrowUp" || event.keyCode === 38) {
            element_helper_ElementHelper.focusElement(element_helper_ElementHelper.getNextElementPostorder(currentElement));
            event.preventDefault();
        }
    };
    ListModel.prototype.onPointerDown = function (event, item) { };
    ListModel.prototype.refresh = function () {
        this.filterString = "";
        this.resetFocusedItem();
    };
    ListModel.prototype.onClickSearchClearButton = function (event) {
        event.currentTarget.parentElement.querySelector("input").focus();
        this.refresh();
    };
    ListModel.prototype.resetFocusedItem = function () {
        this.focusedItem = undefined;
    };
    ListModel.prototype.focusFirstVisibleItem = function () {
        this.focusedItem = this.visibleItems[0];
    };
    ListModel.prototype.focusLastVisibleItem = function () {
        this.focusedItem = this.visibleItems[this.visibleItems.length - 1];
    };
    ListModel.prototype.initFocusedItem = function () {
        var _this = this;
        this.focusedItem = this.visibleItems.filter(function (item) { return item.visible && _this.isItemSelected(item); })[0];
        if (!this.focusedItem) {
            this.focusFirstVisibleItem();
        }
    };
    ListModel.prototype.focusNextVisibleItem = function () {
        if (!this.focusedItem) {
            this.initFocusedItem();
        }
        else {
            var items = this.visibleItems;
            var currentFocusedItemIndex = items.indexOf(this.focusedItem);
            var nextItem = items[currentFocusedItemIndex + 1];
            if (nextItem) {
                this.focusedItem = nextItem;
            }
            else {
                this.focusFirstVisibleItem();
            }
        }
    };
    ListModel.prototype.focusPrevVisibleItem = function () {
        if (!this.focusedItem) {
            this.initFocusedItem();
        }
        else {
            var items = this.visibleItems;
            var currentFocusedItemIndex = items.indexOf(this.focusedItem);
            var prevItem = items[currentFocusedItemIndex - 1];
            if (prevItem) {
                this.focusedItem = prevItem;
            }
            else {
                this.focusLastVisibleItem();
            }
        }
    };
    ListModel.prototype.selectFocusedItem = function () {
        !!this.focusedItem && this.onItemClick(this.focusedItem);
    };
    ListModel.prototype.initListContainerHtmlElement = function (htmlElement) {
        this.listContainerHtmlElement = htmlElement;
    };
    ListModel.prototype.onLastItemRended = function (item) {
        if (this.isAllDataLoaded)
            return;
        if (item === this.actions[this.actions.length - 1] && !!this.listContainerHtmlElement) {
            this.hasVerticalScroller = element_helper_ElementHelper.hasVerticalScroller(this.scrollableContainer);
        }
    };
    ListModel.prototype.scrollToFocusedItem = function () {
        this.scrollToItem(this.getDefaultCssClasses().itemFocused);
    };
    ListModel.prototype.scrollToSelectedItem = function () {
        this.scrollToItem(this.getDefaultCssClasses().itemSelected, 110);
    };
    ListModel.prototype.addScrollEventListener = function (handler) {
        if (!!handler) {
            this.removeScrollEventListener();
            this.scrollHandler = handler;
        }
        if (!!this.scrollHandler) {
            this.scrollableContainer.addEventListener("scroll", this.scrollHandler);
        }
    };
    ListModel.prototype.removeScrollEventListener = function () {
        if (!!this.scrollHandler) {
            this.scrollableContainer.removeEventListener("scroll", this.scrollHandler);
        }
    };
    ListModel.prototype.dispose = function () {
        _super.prototype.dispose.call(this);
        if (!!this.loadingIndicatorValue) {
            this.loadingIndicatorValue.dispose();
        }
        this.listContainerHtmlElement = undefined;
    };
    ListModel.INDENT = 16;
    ListModel.MINELEMENTCOUNT = 10;
    list_decorate([
        jsonobject_property({
            defaultValue: true,
            onSet: function (newValue, target) {
                target.onSet();
            }
        })
    ], ListModel.prototype, "searchEnabled", void 0);
    list_decorate([
        jsonobject_property({ defaultValue: false })
    ], ListModel.prototype, "showFilter", void 0);
    list_decorate([
        jsonobject_property({ defaultValue: false })
    ], ListModel.prototype, "forceShowFilter", void 0);
    list_decorate([
        jsonobject_property({ defaultValue: false })
    ], ListModel.prototype, "isExpanded", void 0);
    list_decorate([
        jsonobject_property({})
    ], ListModel.prototype, "selectedItem", void 0);
    list_decorate([
        jsonobject_property()
    ], ListModel.prototype, "focusedItem", void 0);
    list_decorate([
        jsonobject_property({
            onSet: function (_, target) {
                target.onFilterStringChanged(target.filterString);
            }
        })
    ], ListModel.prototype, "filterString", void 0);
    list_decorate([
        jsonobject_property({ defaultValue: false })
    ], ListModel.prototype, "hasVerticalScroller", void 0);
    list_decorate([
        jsonobject_property({ defaultValue: true })
    ], ListModel.prototype, "isAllDataLoaded", void 0);
    list_decorate([
        jsonobject_property({ defaultValue: false })
    ], ListModel.prototype, "showSearchClearButton", void 0);
    list_decorate([
        jsonobject_property({ defaultValue: true })
    ], ListModel.prototype, "renderElements", void 0);
    list_decorate([
        jsonobject_property({ defaultValue: false })
    ], ListModel.prototype, "textWrapEnabled", void 0);
    return ListModel;
}(container_ActionContainer));


// CONCATENATED MODULE: ./packages/survey-core/src/popup.ts
var popup_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var popup_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};



var popup_PopupModel = /** @class */ (function (_super) {
    popup_extends(PopupModel, _super);
    function PopupModel(contentComponentName, contentComponentData, option1, option2) {
        var _this = _super.call(this) || this;
        _this.focusFirstInputSelector = "";
        _this.onCancel = function () { };
        _this.onApply = function () { return true; };
        _this.onHide = function () { };
        _this.onShow = function () { };
        _this.onDispose = function () { };
        _this.onVisibilityChanged = _this.addEvent();
        _this.onFooterActionsCreated = _this.addEvent();
        _this.onRecalculatePosition = _this.addEvent();
        _this.contentComponentName = contentComponentName;
        _this.contentComponentData = contentComponentData;
        if (!!option1 && typeof option1 === "string") {
            _this.verticalPosition = option1;
            _this.horizontalPosition = option2;
        }
        else if (!!option1) {
            var popupOptions = option1;
            for (var key in popupOptions) {
                _this[key] = popupOptions[key];
            }
        }
        return _this;
    }
    PopupModel.prototype.refreshInnerModel = function () {
        var innerModel = this.contentComponentData["model"];
        innerModel && innerModel.refresh && innerModel.refresh();
    };
    Object.defineProperty(PopupModel.prototype, "isVisible", {
        get: function () {
            return this.getPropertyValue("isVisible", false);
        },
        set: function (value) {
            if (this.isVisible === value) {
                return;
            }
            this.setPropertyValue("isVisible", value);
            this.onVisibilityChanged.fire(this, { model: this, isVisible: value });
        },
        enumerable: false,
        configurable: true
    });
    PopupModel.prototype.toggleVisibility = function () {
        this.isVisible = !this.isVisible;
    };
    PopupModel.prototype.show = function () {
        if (!this.isVisible)
            this.isVisible = true;
    };
    PopupModel.prototype.hide = function () {
        if (this.isVisible)
            this.isVisible = false;
    };
    PopupModel.prototype.recalculatePosition = function (isResetHeight) {
        this.onRecalculatePosition.fire(this, { isResetHeight: isResetHeight });
    };
    PopupModel.prototype.updateFooterActions = function (footerActions) {
        var options = { actions: footerActions };
        this.onFooterActionsCreated.fire(this, options);
        return options.actions;
    };
    PopupModel.prototype.updateDisplayMode = function (menuType) {
        switch (menuType) {
            case "dropdown": {
                this.displayMode = "popup";
                break;
            }
            case "popup": {
                this.displayMode = "overlay";
                this.overlayDisplayMode = "tablet-dropdown-overlay";
                break;
            }
            case "overlay": {
                this.displayMode = "overlay";
                this.overlayDisplayMode = "dropdown-overlay";
                break;
            }
        }
    };
    PopupModel.prototype.onHiding = function () {
        this.refreshInnerModel();
        this.onHide();
    };
    PopupModel.prototype.dispose = function () {
        _super.prototype.dispose.call(this);
        this.onDispose();
    };
    popup_decorate([
        jsonobject_property()
    ], PopupModel.prototype, "contentComponentName", void 0);
    popup_decorate([
        jsonobject_property()
    ], PopupModel.prototype, "contentComponentData", void 0);
    popup_decorate([
        jsonobject_property({ defaultValue: "bottom" })
    ], PopupModel.prototype, "verticalPosition", void 0);
    popup_decorate([
        jsonobject_property({ defaultValue: "left" })
    ], PopupModel.prototype, "horizontalPosition", void 0);
    popup_decorate([
        jsonobject_property({ defaultValue: true })
    ], PopupModel.prototype, "showPointer", void 0);
    popup_decorate([
        jsonobject_property({ defaultValue: false })
    ], PopupModel.prototype, "isModal", void 0);
    popup_decorate([
        jsonobject_property({ defaultValue: true })
    ], PopupModel.prototype, "canShrink", void 0);
    popup_decorate([
        jsonobject_property({ defaultValue: true })
    ], PopupModel.prototype, "isFocusedContent", void 0);
    popup_decorate([
        jsonobject_property({ defaultValue: true })
    ], PopupModel.prototype, "isFocusedContainer", void 0);
    popup_decorate([
        jsonobject_property({ defaultValue: "" })
    ], PopupModel.prototype, "cssClass", void 0);
    popup_decorate([
        jsonobject_property({ defaultValue: "" })
    ], PopupModel.prototype, "title", void 0);
    popup_decorate([
        jsonobject_property({ defaultValue: "auto" })
    ], PopupModel.prototype, "overlayDisplayMode", void 0);
    popup_decorate([
        jsonobject_property({ defaultValue: "popup" })
    ], PopupModel.prototype, "displayMode", void 0);
    popup_decorate([
        jsonobject_property({ defaultValue: "flex" })
    ], PopupModel.prototype, "positionMode", void 0);
    return PopupModel;
}(base_Base));

function createDialogOptions(componentName, data, onApply, onCancel, onHide, onShow, cssClass, title, displayMode) {
    if (onHide === void 0) { onHide = function () { }; }
    if (onShow === void 0) { onShow = function () { }; }
    if (displayMode === void 0) { displayMode = "popup"; }
    ConsoleWarnings.warn("The `showModal()` and `createDialogOptions()` methods are obsolete. Use the `showDialog()` method instead.");
    return {
        componentName: componentName,
        data: data,
        onApply: onApply,
        onCancel: onCancel,
        onHide: onHide,
        onShow: onShow,
        cssClass: cssClass,
        title: title,
        displayMode: displayMode
    };
}

// CONCATENATED MODULE: ./packages/survey-core/src/actions/action.ts
var action_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var action_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var action_spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
    for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
        to[j] = from[i];
    return to;
};







function createDropdownActionModel(actionOptions, dropdownOptions, locOwner) {
    dropdownOptions.locOwner = locOwner;
    return createDropdownActionModelAdvanced(actionOptions, dropdownOptions, dropdownOptions);
}
function createDropdownActionModelAdvanced(actionOptions, listOptions, popupOptions) {
    var _a;
    var originalSelectionChanged = listOptions.onSelectionChanged;
    listOptions.onSelectionChanged = function (item) {
        var params = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            params[_i - 1] = arguments[_i];
        }
        if (newAction.hasTitle) {
            newAction.title = item.title;
        }
        if (originalSelectionChanged) {
            originalSelectionChanged(item, params);
        }
    };
    var popupModel = createPopupModelWithListModel(listOptions, popupOptions);
    var newActionOptions = Object.assign({}, actionOptions, {
        component: "sv-action-bar-item-dropdown",
        popupModel: popupModel,
        action: function (action, isUserAction) {
            !!(actionOptions.action) && actionOptions.action();
            popupModel.isFocusedContent = popupModel.isFocusedContent || !isUserAction;
            popupModel.show();
        },
    });
    var newAction = new action_Action(newActionOptions);
    newAction.data = (_a = popupModel.contentComponentData) === null || _a === void 0 ? void 0 : _a.model;
    return newAction;
}
function createPopupModelWithListModel(listOptions, popupOptions) {
    var listModel = new list_ListModel(listOptions);
    listModel.onSelectionChanged = function (item) {
        if (listOptions.onSelectionChanged) {
            listOptions.onSelectionChanged(item);
        }
        popupModel.hide();
    };
    var _popupOptions = popupOptions || {};
    _popupOptions.onDispose = function () { listModel.dispose(); };
    var popupModel = new popup_PopupModel("sv-list", { model: listModel }, _popupOptions);
    popupModel.isFocusedContent = listModel.showFilter;
    popupModel.onShow = function () {
        if (!!_popupOptions.onShow)
            _popupOptions.onShow();
        listModel.scrollToSelectedItem();
    };
    return popupModel;
}
function getActionDropdownButtonTarget(container) {
    return container === null || container === void 0 ? void 0 : container.previousElementSibling;
}
var action_BaseAction = /** @class */ (function (_super) {
    action_extends(BaseAction, _super);
    function BaseAction() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.rendredIdValue = BaseAction.getNextRendredId();
        _this.markerIconSize = 16;
        return _this;
    }
    BaseAction.getNextRendredId = function () { return BaseAction.renderedId++; };
    Object.defineProperty(BaseAction.prototype, "renderedId", {
        get: function () { return this.rendredIdValue; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BaseAction.prototype, "owner", {
        get: function () { return this.ownerValue; },
        set: function (val) {
            if (val !== this.owner) {
                this.ownerValue = val;
                this.locStrsChanged();
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BaseAction.prototype, "visible", {
        get: function () {
            return this.getVisible();
        },
        set: function (val) {
            this.setVisible(val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BaseAction.prototype, "enabled", {
        get: function () {
            return this.getEnabled();
        },
        set: function (val) {
            this.setEnabled(val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BaseAction.prototype, "component", {
        get: function () {
            return this.getComponent();
        },
        set: function (val) {
            this.setComponent(val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BaseAction.prototype, "locTitle", {
        get: function () {
            return this.getLocTitle();
        },
        set: function (val) {
            this.setLocTitle(val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BaseAction.prototype, "title", {
        get: function () {
            return this.getTitle();
        },
        set: function (val) {
            this.setTitle(val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BaseAction.prototype, "cssClasses", {
        get: function () {
            return this.cssClassesValue || defaultActionBarCss;
        },
        set: function (val) {
            this.cssClassesValue = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BaseAction.prototype, "isVisible", {
        get: function () {
            return this.visible && this.mode !== "popup" && this.mode !== "removed";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BaseAction.prototype, "disabled", {
        get: function () {
            return this.enabled !== undefined && !this.enabled;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BaseAction.prototype, "canShrink", {
        get: function () {
            return !this.disableShrink && !!this.iconName;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BaseAction.prototype, "hasTitle", {
        get: function () {
            return (((this.mode != "small" &&
                (this.showTitle || this.showTitle === undefined)) ||
                !this.iconName) &&
                !!this.title);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BaseAction.prototype, "hasSubItems", {
        get: function () {
            return !!this.items && this.items.length > 0;
        },
        enumerable: false,
        configurable: true
    });
    BaseAction.prototype.getActionBarItemTitleCss = function () {
        return new CssClassBuilder()
            .append(this.cssClasses.itemTitle)
            .append(this.cssClasses.itemTitleWithIcon, !!this.iconName)
            .toString();
    };
    BaseAction.prototype.getActionBarItemCss = function () {
        return new CssClassBuilder()
            .append(this.cssClasses.item)
            .append(this.cssClasses.itemWithTitle, this.hasTitle)
            .append(this.cssClasses.itemAsIcon, !this.hasTitle)
            .append(this.cssClasses.itemActive, !!this.active)
            .append(this.cssClasses.itemPressed, !!this.pressed)
            .append(this.innerCss)
            .toString();
    };
    BaseAction.prototype.getActionRootCss = function () {
        return new CssClassBuilder()
            .append("sv-action")
            .append(this.css)
            .append("sv-action--space", this.needSpace)
            .append("sv-action--hidden", !this.isVisible)
            .toString();
    };
    BaseAction.prototype.getTooltip = function () {
        return this.tooltip || this.title;
    };
    BaseAction.prototype.getIsTrusted = function (args) {
        if (!!args.originalEvent) {
            return args.originalEvent.isTrusted;
        }
        return args.isTrusted;
    };
    BaseAction.prototype.showPopup = function () {
        if (!!this.popupModel) {
            this.popupModel.show();
        }
    };
    BaseAction.prototype.hidePopup = function () {
        if (!!this.popupModel) {
            this.popupModel.hide();
        }
    };
    BaseAction.prototype.clearPopupTimeouts = function () {
        if (this.showPopupTimeout)
            clearTimeout(this.showPopupTimeout);
        if (this.hidePopupTimeout)
            clearTimeout(this.hidePopupTimeout);
    };
    BaseAction.prototype.showPopupDelayed = function (delay) {
        var _this = this;
        this.clearPopupTimeouts();
        this.showPopupTimeout = setTimeout(function () {
            _this.clearPopupTimeouts();
            _this.showPopup();
        }, delay);
    };
    BaseAction.prototype.hidePopupDelayed = function (delay) {
        var _this = this;
        var _a;
        if ((_a = this.popupModel) === null || _a === void 0 ? void 0 : _a.isVisible) {
            this.clearPopupTimeouts();
            this.hidePopupTimeout = setTimeout(function () {
                _this.clearPopupTimeouts();
                _this.hidePopup();
                _this.isHovered = false;
            }, delay);
        }
        else {
            this.clearPopupTimeouts();
            this.isHovered = false;
        }
    };
    BaseAction.renderedId = 1;
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "tooltip", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "showTitle", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "innerCss", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "active", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "pressed", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "data", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "popupModel", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "needSeparator", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "template", void 0);
    action_decorate([
        jsonobject_property({ defaultValue: "large" })
    ], BaseAction.prototype, "mode", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "visibleIndex", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "disableTabStop", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "disableShrink", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "disableHide", void 0);
    action_decorate([
        jsonobject_property({ defaultValue: false })
    ], BaseAction.prototype, "needSpace", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "ariaChecked", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "ariaExpanded", void 0);
    action_decorate([
        jsonobject_property({ defaultValue: "button" })
    ], BaseAction.prototype, "ariaRole", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "iconName", void 0);
    action_decorate([
        jsonobject_property({ defaultValue: 24 })
    ], BaseAction.prototype, "iconSize", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "markerIconName", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "markerIconSize", void 0);
    action_decorate([
        jsonobject_property()
    ], BaseAction.prototype, "css", void 0);
    action_decorate([
        jsonobject_property({ defaultValue: false })
    ], BaseAction.prototype, "isPressed", void 0);
    action_decorate([
        jsonobject_property({ defaultValue: false })
    ], BaseAction.prototype, "isHovered", void 0);
    return BaseAction;
}(base_Base));

var action_Action = /** @class */ (function (_super) {
    action_extends(Action, _super);
    function Action(innerItem) {
        var _this = _super.call(this) || this;
        _this.innerItem = innerItem;
        _this.locTitleChanged = function () {
            var val = _this.locTitle.renderedHtml;
            _this.setPropertyValue("_title", !!val ? val : undefined);
        };
        _this.locTitle = !!innerItem ? innerItem["locTitle"] : null;
        //Object.assign(this, item) to support IE11
        if (!!innerItem) {
            for (var key in innerItem) {
                if (key === "locTitle" || key === "title" && !!_this.locTitle && !!_this.title)
                    continue;
                _this[key] = innerItem[key];
            }
        }
        if (!!_this.locTitleName) {
            _this.locTitleChanged();
        }
        _this.registerFunctionOnPropertyValueChanged("_title", function () {
            _this.raiseUpdate(true);
        });
        _this.locStrChangedInPopupModel();
        return _this;
    }
    Action.prototype.raiseUpdate = function (isResetInitialized) {
        if (isResetInitialized === void 0) { isResetInitialized = false; }
        this.updateCallback && this.updateCallback(isResetInitialized);
    };
    Action.prototype.createLocTitle = function () {
        return this.createLocalizableString("title", this, true);
    };
    Action.prototype.setSubItems = function (options) {
        this.markerIconName = "icon-next_16x16";
        this.component = "sv-list-item-group";
        this.items = action_spreadArray([], options.items);
        var listOptions = Object.assign({}, options);
        listOptions.searchEnabled = false;
        var popupModel = createPopupModelWithListModel(listOptions, { horizontalPosition: "right", showPointer: false, canShrink: false });
        popupModel.cssClass = "sv-popup-inner";
        this.popupModel = popupModel;
    };
    Action.prototype.getLocTitle = function () {
        return this.locTitleValue;
    };
    Action.prototype.setLocTitle = function (val) {
        if (!val && !this.locTitleValue) {
            val = this.createLocTitle();
        }
        if (!!this.locTitleValue) {
            this.locTitleValue.onStringChanged.remove(this.locTitleChanged);
        }
        this.locTitleValue = val;
        this.locTitleValue.onStringChanged.add(this.locTitleChanged);
        this.locTitleChanged();
    };
    Action.prototype.getTitle = function () {
        return this._title;
    };
    Action.prototype.setTitle = function (val) {
        this._title = val;
    };
    Object.defineProperty(Action.prototype, "locTitleName", {
        get: function () {
            return this.locTitle.localizationName;
        },
        set: function (val) {
            this.locTitle.localizationName = val;
        },
        enumerable: false,
        configurable: true
    });
    Action.prototype.locStrsChanged = function () {
        _super.prototype.locStrsChanged.call(this);
        this.locTooltipChanged();
        this.locStrChangedInPopupModel();
    };
    Action.prototype.doAction = function (args) {
        var evt = !!args.originalEvent ? args.originalEvent : args;
        this.action(this, evt.isTrusted);
        evt.preventDefault();
        evt.stopPropagation();
        return true;
    };
    Action.prototype.doMouseDown = function () {
        this.isMouseDown = true;
    };
    Action.prototype.doFocus = function (args) {
        if (!!this.onFocus) {
            var evt = !!args.originalEvent ? args.originalEvent : args;
            this.onFocus(this.isMouseDown, evt);
        }
        this.isMouseDown = false;
    };
    Action.prototype.locStrChangedInPopupModel = function () {
        if (!this.popupModel || !this.popupModel.contentComponentData || !this.popupModel.contentComponentData.model)
            return;
        var model = this.popupModel.contentComponentData.model;
        if (Array.isArray(model.actions)) {
            var actions = model.actions;
            actions.forEach(function (item) {
                if (!!item.locStrsChanged) {
                    item.locStrsChanged();
                }
            });
        }
    };
    Action.prototype.locTooltipChanged = function () {
        if (!this.locTooltipName)
            return;
        this.tooltip = surveyLocalization.getString(this.locTooltipName, this.locTitle.locale);
    };
    //ILocalizableOwner
    Action.prototype.getLocale = function () { return this.owner ? this.owner.getLocale() : ""; };
    Action.prototype.getMarkdownHtml = function (text, name) { return this.owner ? this.owner.getMarkdownHtml(text, name) : undefined; };
    Action.prototype.getProcessedText = function (text) { return this.owner ? this.owner.getProcessedText(text) : text; };
    Action.prototype.getRenderer = function (name) { return this.owner ? this.owner.getRenderer(name) : null; };
    Action.prototype.getRendererContext = function (locStr) { return this.owner ? this.owner.getRendererContext(locStr) : locStr; };
    Action.prototype.setVisible = function (val) {
        this._visible = val;
    };
    Action.prototype.getVisible = function () {
        return this._visible;
    };
    Action.prototype.setEnabled = function (val) {
        this._enabled = val;
    };
    Action.prototype.getEnabled = function () {
        if (this.enabledIf)
            return this.enabledIf();
        return this._enabled;
    };
    Action.prototype.setComponent = function (val) {
        this._component = val;
    };
    Action.prototype.getComponent = function () {
        return this._component;
    };
    Action.prototype.dispose = function () {
        this.updateCallback = undefined;
        this.action = undefined;
        _super.prototype.dispose.call(this);
        if (this.popupModel) {
            this.popupModel.dispose();
        }
        if (!!this.locTitleValue) {
            this.locTitleValue.onStringChanged.remove(this.locTitleChanged);
            this.locTitleChanged = undefined;
        }
    };
    action_decorate([
        jsonobject_property()
    ], Action.prototype, "id", void 0);
    action_decorate([
        jsonobject_property({
            defaultValue: true,
            onSet: function (_, target) {
                target.raiseUpdate();
            }
        })
    ], Action.prototype, "_visible", void 0);
    action_decorate([
        jsonobject_property({
            onSet: function (_, target) {
                target.locTooltipChanged();
            }
        })
    ], Action.prototype, "locTooltipName", void 0);
    action_decorate([
        jsonobject_property()
    ], Action.prototype, "_enabled", void 0);
    action_decorate([
        jsonobject_property()
    ], Action.prototype, "action", void 0);
    action_decorate([
        jsonobject_property()
    ], Action.prototype, "onFocus", void 0);
    action_decorate([
        jsonobject_property()
    ], Action.prototype, "_component", void 0);
    action_decorate([
        jsonobject_property()
    ], Action.prototype, "items", void 0);
    action_decorate([
        jsonobject_property({
            onSet: function (val, target) {
                if (target.locTitleValue.text === val)
                    return;
                target.locTitleValue.text = val;
            }
        })
    ], Action.prototype, "_title", void 0);
    return Action;
}(action_BaseAction));

var ActionDropdownViewModel = /** @class */ (function () {
    function ActionDropdownViewModel(item) {
        this.item = item;
        this.funcKey = "sv-dropdown-action";
        this.setupPopupCallbacks();
    }
    ActionDropdownViewModel.prototype.setupPopupCallbacks = function () {
        var _this = this;
        var popupModel = this.popupModel = this.item.popupModel;
        if (!popupModel)
            return;
        popupModel.registerPropertyChangedHandlers(["isVisible"], function () {
            if (!popupModel.isVisible) {
                _this.item.pressed = false;
            }
            else {
                _this.item.pressed = true;
            }
        }, this.funcKey);
    };
    ActionDropdownViewModel.prototype.removePopupCallbacks = function () {
        if (!!this.popupModel) {
            this.popupModel.unregisterPropertyChangedHandlers(["isVisible"], this.funcKey);
        }
    };
    ActionDropdownViewModel.prototype.dispose = function () {
        this.removePopupCallbacks();
    };
    return ActionDropdownViewModel;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/actions/adaptive-container.ts
var adaptive_container_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();




var adaptive_container_AdaptiveActionContainer = /** @class */ (function (_super) {
    adaptive_container_extends(AdaptiveActionContainer, _super);
    function AdaptiveActionContainer() {
        var _this = _super.call(this) || this;
        _this.minVisibleItemsCount = 0;
        _this.isResponsivenessDisabled = false;
        _this.dotsItem = createDropdownActionModelAdvanced({
            id: "dotsItem-id" + AdaptiveActionContainer.ContainerID++,
            css: "sv-dots",
            innerCss: "sv-dots__item",
            iconName: "icon-more",
            visible: false,
            tooltip: surveyLocalization.getString("more"),
        }, {
            items: [],
            allowSelection: false
        });
        return _this;
    }
    AdaptiveActionContainer.prototype.hideItemsGreaterN = function (visibleItemsCount) {
        var actionsToHide = this.getActionsToHide();
        visibleItemsCount = Math.max(visibleItemsCount, this.minVisibleItemsCount - (this.visibleActions.length - actionsToHide.length));
        var hiddenItems = [];
        actionsToHide.forEach(function (item) {
            if (visibleItemsCount <= 0) {
                if (item.removePriority) {
                    item.mode = "removed";
                }
                else {
                    item.mode = "popup";
                    hiddenItems.push(item.innerItem);
                }
            }
            visibleItemsCount--;
        });
        this.hiddenItemsListModel.setItems(hiddenItems);
    };
    AdaptiveActionContainer.prototype.getActionsToHide = function () {
        return this.visibleActions.filter(function (action) { return !action.disableHide; }).sort(function (a, b) { return a.removePriority || 0 - b.removePriority || 0; });
    };
    AdaptiveActionContainer.prototype.getVisibleItemsCount = function (availableSize) {
        this.visibleActions.filter(function (action) { return action.disableHide; }).forEach(function (action) { return availableSize -= action.minDimension; });
        var itemsSizes = this.getActionsToHide().map(function (item) { return item.minDimension; });
        var currSize = 0;
        for (var i = 0; i < itemsSizes.length; i++) {
            currSize += itemsSizes[i];
            if (currSize > availableSize)
                return i;
        }
        return i;
    };
    AdaptiveActionContainer.prototype.updateItemMode = function (availableSize, itemsSize) {
        var items = this.visibleActions;
        for (var index = items.length - 1; index >= 0; index--) {
            if (itemsSize > availableSize && !items[index].disableShrink) {
                itemsSize -= items[index].maxDimension - items[index].minDimension;
                items[index].mode = "small";
            }
            else {
                items[index].mode = "large";
            }
        }
        if (itemsSize > availableSize) {
            var hidableItems = this.visibleActions.filter(function (a) { return a.removePriority; });
            hidableItems.sort(function (a, b) { return a.removePriority - b.removePriority; });
            for (var index = 0; index < hidableItems.length; index++) {
                if (itemsSize > availableSize) {
                    itemsSize -= items[index].disableShrink ? hidableItems[index].maxDimension : hidableItems[index].minDimension;
                    hidableItems[index].mode = "removed";
                }
            }
        }
    };
    Object.defineProperty(AdaptiveActionContainer.prototype, "hiddenItemsListModel", {
        get: function () {
            return this.dotsItem.data;
        },
        enumerable: false,
        configurable: true
    });
    AdaptiveActionContainer.prototype.onSet = function () {
        var _this = this;
        this.actions.forEach(function (action) { return action.updateCallback = function (isResetInitialized) { return _this.raiseUpdate(isResetInitialized); }; });
        _super.prototype.onSet.call(this);
    };
    AdaptiveActionContainer.prototype.onPush = function (item) {
        var _this = this;
        item.updateCallback = function (isResetInitialized) { return _this.raiseUpdate(isResetInitialized); };
        _super.prototype.onPush.call(this, item);
    };
    AdaptiveActionContainer.prototype.getRenderedActions = function () {
        if (this.actions.length === 1 && !!this.actions[0].iconName)
            return this.actions;
        return this.actions.concat([this.dotsItem]);
    };
    AdaptiveActionContainer.prototype.raiseUpdate = function (isResetInitialized) {
        if (!this.isResponsivenessDisabled) {
            _super.prototype.raiseUpdate.call(this, isResetInitialized);
        }
    };
    AdaptiveActionContainer.prototype.fit = function (dimension, dotsItemSize) {
        if (dimension <= 0)
            return;
        this.dotsItem.visible = false;
        var minSize = 0;
        var maxSize = 0;
        var items = this.visibleActions;
        items.forEach(function (item) {
            minSize += item.minDimension;
            maxSize += item.maxDimension;
        });
        if (dimension >= maxSize) {
            this.setActionsMode("large");
        }
        else if (dimension < minSize) {
            this.setActionsMode("small");
            this.hideItemsGreaterN(this.getVisibleItemsCount(dimension - dotsItemSize));
            this.dotsItem.visible = !!this.hiddenItemsListModel.actions.length;
        }
        else {
            this.updateItemMode(dimension, maxSize);
        }
    };
    AdaptiveActionContainer.prototype.initResponsivityManager = function (container, delayedUpdateFunction) {
        this.responsivityManager = new responsivity_manager_ResponsivityManager(container, this, ":scope > .sv-action:not(.sv-dots) > .sv-action__content", null, delayedUpdateFunction);
    };
    AdaptiveActionContainer.prototype.resetResponsivityManager = function () {
        if (!!this.responsivityManager) {
            this.responsivityManager.dispose();
            this.responsivityManager = undefined;
        }
    };
    AdaptiveActionContainer.prototype.setActionsMode = function (mode) {
        this.actions.forEach(function (action) {
            if (mode == "small" && action.disableShrink)
                return;
            action.mode = mode;
        });
    };
    AdaptiveActionContainer.prototype.dispose = function () {
        _super.prototype.dispose.call(this);
        this.dotsItem.data.dispose();
        this.dotsItem.dispose();
        this.resetResponsivityManager();
    };
    AdaptiveActionContainer.ContainerID = 1;
    return AdaptiveActionContainer;
}(container_ActionContainer));


// CONCATENATED MODULE: ./packages/survey-core/src/utils/taskmanager.ts
var Task = /** @class */ (function () {
    function Task(func, isMultiple) {
        var _this = this;
        if (isMultiple === void 0) { isMultiple = false; }
        this.func = func;
        this.isMultiple = isMultiple;
        this._isCompleted = false;
        this.execute = function () {
            if (!_this._isCompleted) {
                _this.func();
                _this._isCompleted = !_this.isMultiple;
            }
        };
    }
    Task.prototype.discard = function () {
        this._isCompleted = true;
    };
    Object.defineProperty(Task.prototype, "isCompleted", {
        get: function () {
            return this._isCompleted;
        },
        enumerable: false,
        configurable: true
    });
    return Task;
}());

var TaskManger = /** @class */ (function () {
    function TaskManger(interval) {
        if (interval === void 0) { interval = 100; }
        this.interval = interval;
        setTimeout(TaskManger.Instance().tick, interval);
    }
    // dispose
    TaskManger.Instance = function () {
        if (!TaskManger.instance) {
            TaskManger.instance = new TaskManger();
        }
        return TaskManger.instance;
    };
    TaskManger.prototype.tick = function () {
        try {
            var newTasks = [];
            for (var i = 0; i < TaskManger.tasks.length; i++) {
                var task = TaskManger.tasks[i];
                task.execute();
                if (!task.isCompleted) {
                    newTasks.push(task);
                }
                else {
                    if (typeof task.dispose === "function") {
                        task.dispose();
                    }
                }
            }
            TaskManger.tasks = newTasks;
        }
        finally {
            setTimeout(TaskManger.Instance().tick, this.interval);
        }
    };
    TaskManger.schedule = function (task) {
        TaskManger.tasks.push(task);
    };
    TaskManger.instance = undefined;
    TaskManger.tasks = [];
    return TaskManger;
}());

function debounce(func) {
    var _this = this;
    var isSheduled = false;
    var isCanceled = false;
    var funcArgs;
    return { run: (function () {
            var args = [];
            for (var _i = 0; _i < arguments.length; _i++) {
                args[_i] = arguments[_i];
            }
            isCanceled = false;
            funcArgs = args;
            if (!isSheduled) {
                isSheduled = true;
                queueMicrotask(function () {
                    if (!isCanceled) {
                        func.apply(_this, funcArgs);
                    }
                    isCanceled = false;
                    isSheduled = false;
                });
            }
        }), cancel: function () {
            isCanceled = true;
        } };
}

// CONCATENATED MODULE: ./packages/survey-core/src/utils/animation.ts
var animation_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();



var animation_AnimationUtils = /** @class */ (function () {
    function AnimationUtils() {
        this.cancelQueue = [];
    }
    AnimationUtils.prototype.getMsFromRule = function (value) {
        if (value === "auto")
            return 0;
        return Number(value.slice(0, -1).replace(",", ".")) * 1000;
    };
    AnimationUtils.prototype.reflow = function (element) {
        return element.offsetHeight;
    };
    AnimationUtils.prototype.getAnimationsCount = function (element) {
        var animationName = "";
        if (getComputedStyle) {
            animationName = getComputedStyle(element).animationName;
        }
        return (animationName && animationName != "none" ? animationName.split(", ").length : 0);
    };
    AnimationUtils.prototype.getAnimationDuration = function (element) {
        var style = getComputedStyle(element);
        var delays = style["animationDelay"].split(", ");
        var durations = style["animationDuration"].split(", ");
        var duration = 0;
        for (var i = 0; i < Math.max(durations.length, delays.length); i++) {
            duration = Math.max(duration, this.getMsFromRule(durations[i % durations.length]) + this.getMsFromRule(delays[i % delays.length]));
        }
        return duration;
    };
    AnimationUtils.prototype.addCancelCallback = function (callback) {
        this.cancelQueue.push(callback);
    };
    AnimationUtils.prototype.removeCancelCallback = function (callback) {
        if (this.cancelQueue.indexOf(callback) >= 0) {
            this.cancelQueue.splice(this.cancelQueue.indexOf(callback), 1);
        }
    };
    AnimationUtils.prototype.onAnimationEnd = function (element, callback, options) {
        var _this = this;
        var cancelTimeout;
        var animationsCount = this.getAnimationsCount(element);
        var onEndCallback = function (isCancel) {
            if (isCancel === void 0) { isCancel = true; }
            _this.afterAnimationRun(element, options);
            callback(isCancel);
            clearTimeout(cancelTimeout);
            _this.removeCancelCallback(onEndCallback);
            element.removeEventListener("animationend", onAnimationEndCallback);
        };
        var onAnimationEndCallback = function (event) {
            if (event.target == event.currentTarget && --animationsCount <= 0) {
                onEndCallback(false);
            }
        };
        if (animationsCount > 0) {
            element.addEventListener("animationend", onAnimationEndCallback);
            this.addCancelCallback(onEndCallback);
            cancelTimeout = setTimeout(function () {
                onEndCallback(false);
            }, this.getAnimationDuration(element) + 10);
        }
        else {
            this.afterAnimationRun(element, options);
            callback(true);
        }
    };
    AnimationUtils.prototype.afterAnimationRun = function (element, options) {
        if (element && options) {
            options.onAfterRunAnimation && options.onAfterRunAnimation(element);
        }
    };
    AnimationUtils.prototype.beforeAnimationRun = function (element, options) {
        if (element && options) {
            options.onBeforeRunAnimation && options.onBeforeRunAnimation(element);
        }
    };
    AnimationUtils.prototype.getCssClasses = function (options) {
        return options.cssClass.replace(/\s+$/, "").split(/\s+/);
    };
    AnimationUtils.prototype.runAnimation = function (element, options, callback) {
        if (element && (options === null || options === void 0 ? void 0 : options.cssClass)) {
            this.reflow(element);
            this.getCssClasses(options).forEach(function (cssClass) {
                element.classList.add(cssClass);
            });
            this.onAnimationEnd(element, callback, options);
        }
        else {
            callback(true);
        }
    };
    AnimationUtils.prototype.clearHtmlElement = function (element, options) {
        if (element && options.cssClass) {
            this.getCssClasses(options).forEach(function (cssClass) {
                element.classList.remove(cssClass);
            });
        }
    };
    AnimationUtils.prototype.onNextRender = function (callback, isCancel) {
        var _this = this;
        if (isCancel === void 0) { isCancel = false; }
        if (!isCancel && DomWindowHelper.isAvailable()) {
            var cancelCallback_1 = function () {
                callback(true);
                cancelAnimationFrame(latestRAF_1);
            };
            var latestRAF_1 = DomWindowHelper.requestAnimationFrame(function () {
                latestRAF_1 = DomWindowHelper.requestAnimationFrame(function () {
                    callback(false);
                    _this.removeCancelCallback(cancelCallback_1);
                });
            });
            this.addCancelCallback(cancelCallback_1);
        }
        else {
            callback(true);
        }
    };
    AnimationUtils.prototype.cancel = function () {
        var cancelQueue = [].concat(this.cancelQueue);
        cancelQueue.forEach(function (callback) { return callback(); });
        this.cancelQueue = [];
    };
    return AnimationUtils;
}());

var AnimationPropertyUtils = /** @class */ (function (_super) {
    animation_extends(AnimationPropertyUtils, _super);
    function AnimationPropertyUtils() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    AnimationPropertyUtils.prototype.onEnter = function (options) {
        var _this = this;
        var htmlElement = options.getAnimatedElement();
        var enterOptions = options.getEnterOptions ? options.getEnterOptions() : {};
        this.beforeAnimationRun(htmlElement, enterOptions);
        this.runAnimation(htmlElement, enterOptions, function () {
            _this.clearHtmlElement(htmlElement, enterOptions);
        });
    };
    AnimationPropertyUtils.prototype.onLeave = function (options, callback) {
        var _this = this;
        var htmlElement = options.getAnimatedElement();
        var leaveOptions = options.getLeaveOptions ? options.getLeaveOptions() : {};
        this.beforeAnimationRun(htmlElement, leaveOptions);
        this.runAnimation(htmlElement, leaveOptions, function (isCancel) {
            callback();
            _this.onNextRender(function () {
                _this.clearHtmlElement(htmlElement, leaveOptions);
            }, isCancel);
        });
    };
    return AnimationPropertyUtils;
}(animation_AnimationUtils));

var AnimationGroupUtils = /** @class */ (function (_super) {
    animation_extends(AnimationGroupUtils, _super);
    function AnimationGroupUtils() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    AnimationGroupUtils.prototype.runGroupAnimation = function (options, addedItems, removedItems, reorderedItems, callback) {
        var _this = this;
        var info = {
            isAddingRunning: addedItems.length > 0,
            isDeletingRunning: removedItems.length > 0,
            isReorderingRunning: reorderedItems.length > 0
        };
        var addedHtmlElements = addedItems.map(function (el) { return options.getAnimatedElement(el); });
        var enterOptions = addedItems.map(function (el) { return options.getEnterOptions ? options.getEnterOptions(el, info) : {}; });
        var removedHtmlElements = removedItems.map(function (el) { return options.getAnimatedElement(el); });
        var leaveOptions = removedItems.map(function (el) { return options.getLeaveOptions ? options.getLeaveOptions(el, info) : {}; });
        var reorderedHtmlElements = reorderedItems.map(function (el) { return options.getAnimatedElement(el.item); });
        var reorderedOptions = reorderedItems.map(function (el) { return options.getReorderOptions ? options.getReorderOptions(el.item, el.movedForward, info) : {}; });
        addedItems.forEach(function (_, i) {
            _this.beforeAnimationRun(addedHtmlElements[i], enterOptions[i]);
        });
        removedItems.forEach(function (_, i) {
            _this.beforeAnimationRun(removedHtmlElements[i], leaveOptions[i]);
        });
        reorderedItems.forEach(function (_, i) {
            _this.beforeAnimationRun(reorderedHtmlElements[i], reorderedOptions[i]);
        });
        var counter = addedItems.length + removedItems.length + reorderedHtmlElements.length;
        var onAnimationEndCallback = function (isCancel) {
            if (--counter <= 0) {
                callback && callback();
                _this.onNextRender(function () {
                    addedItems.forEach(function (_, i) {
                        _this.clearHtmlElement(addedHtmlElements[i], enterOptions[i]);
                    });
                    removedItems.forEach(function (_, i) {
                        _this.clearHtmlElement(removedHtmlElements[i], leaveOptions[i]);
                    });
                    reorderedItems.forEach(function (_, i) {
                        _this.clearHtmlElement(reorderedHtmlElements[i], reorderedOptions[i]);
                    });
                }, isCancel);
            }
        };
        addedItems.forEach(function (_, i) {
            _this.runAnimation(addedHtmlElements[i], enterOptions[i], onAnimationEndCallback);
        });
        removedItems.forEach(function (_, i) {
            _this.runAnimation(removedHtmlElements[i], leaveOptions[i], onAnimationEndCallback);
        });
        reorderedItems.forEach(function (_, i) {
            _this.runAnimation(reorderedHtmlElements[i], reorderedOptions[i], onAnimationEndCallback);
        });
    };
    return AnimationGroupUtils;
}(animation_AnimationUtils));

var animation_AnimationProperty = /** @class */ (function () {
    function AnimationProperty(animationOptions, update, getCurrentValue) {
        var _this = this;
        this.animationOptions = animationOptions;
        this.update = update;
        this.getCurrentValue = getCurrentValue;
        this._debouncedSync = debounce(function (newValue) {
            _this.animation.cancel();
            try {
                _this._sync(newValue);
            }
            catch (_a) {
                _this.update(newValue);
            }
        });
    }
    AnimationProperty.prototype.onNextRender = function (callback, onCancel) {
        var _this = this;
        var rerenderEvent = this.animationOptions.getRerenderEvent();
        if (!rerenderEvent) {
            if (DomWindowHelper.isAvailable()) {
                var raf_1 = DomWindowHelper.requestAnimationFrame(function () {
                    callback();
                    _this.cancelCallback = undefined;
                });
                this.cancelCallback = function () {
                    onCancel && onCancel();
                    cancelAnimationFrame(raf_1);
                    _this.cancelCallback = undefined;
                };
            }
            else {
                throw new Error("Can't get next render");
            }
        }
        else {
            var clear_1 = function () {
                rerenderEvent.remove(nextRenderCallback_1);
                _this.cancelCallback = undefined;
            };
            var nextRenderCallback_1 = function () {
                callback();
                clear_1();
            };
            this.cancelCallback = function () {
                onCancel && onCancel();
                clear_1();
            };
            rerenderEvent.add(nextRenderCallback_1);
        }
    };
    AnimationProperty.prototype.sync = function (newValue) {
        if (this.animationOptions.isAnimationEnabled()) {
            this._debouncedSync.run(newValue);
        }
        else {
            this.cancel();
            this.update(newValue);
        }
    };
    AnimationProperty.prototype.cancel = function () {
        this._debouncedSync.cancel();
        this.cancelCallback && this.cancelCallback();
        this.animation.cancel();
    };
    return AnimationProperty;
}());

var AnimationBoolean = /** @class */ (function (_super) {
    animation_extends(AnimationBoolean, _super);
    function AnimationBoolean() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.animation = new AnimationPropertyUtils();
        return _this;
    }
    AnimationBoolean.prototype._sync = function (newValue) {
        var _this = this;
        if (newValue !== this.getCurrentValue()) {
            if (newValue) {
                this.onNextRender(function () {
                    _this.animation.onEnter(_this.animationOptions);
                });
                this.update(newValue);
            }
            else {
                this.animation.onLeave(this.animationOptions, function () {
                    _this.update(newValue);
                });
            }
        }
        else {
            this.update(newValue);
        }
    };
    return AnimationBoolean;
}(animation_AnimationProperty));

var animation_AnimationGroup = /** @class */ (function (_super) {
    animation_extends(AnimationGroup, _super);
    function AnimationGroup() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.animation = new AnimationGroupUtils();
        return _this;
    }
    AnimationGroup.prototype._sync = function (newValue) {
        var _this = this;
        var _a, _b;
        var oldValue = this.getCurrentValue();
        var allowSyncRemovalAddition = (_a = this.animationOptions.allowSyncRemovalAddition) !== null && _a !== void 0 ? _a : true;
        var _c = compareArrays(oldValue, newValue, (_b = this.animationOptions.getKey) !== null && _b !== void 0 ? _b : (function (item) { return item; })), addedItems = _c.addedItems, deletedItems = _c.deletedItems, reorderedItems = _c.reorderedItems, mergedItems = _c.mergedItems;
        if (!allowSyncRemovalAddition && (reorderedItems.length > 0 || addedItems.length > 0)) {
            deletedItems = [];
            mergedItems = newValue;
        }
        var runAnimationCallback = function () {
            _this.animation.runGroupAnimation(_this.animationOptions, addedItems, deletedItems, reorderedItems, function () {
                if (deletedItems.length > 0) {
                    _this.update(newValue);
                }
            });
        };
        if ([addedItems, deletedItems, reorderedItems].some(function (arr) { return arr.length > 0; })) {
            if (deletedItems.length <= 0 || reorderedItems.length > 0 || addedItems.length > 0) {
                this.onNextRender(runAnimationCallback, function () {
                    _this.update(newValue);
                });
                this.update(mergedItems);
            }
            else {
                runAnimationCallback();
            }
        }
        else {
            this.update(newValue);
        }
    };
    return AnimationGroup;
}(animation_AnimationProperty));

var AnimationTab = /** @class */ (function (_super) {
    animation_extends(AnimationTab, _super);
    function AnimationTab(animationOptions, update, getCurrentValue, mergeValues) {
        var _this = _super.call(this, animationOptions, update, getCurrentValue) || this;
        _this.mergeValues = mergeValues;
        _this.animation = new AnimationGroupUtils();
        return _this;
    }
    AnimationTab.prototype._sync = function (newValue) {
        var _this = this;
        var oldValue = [].concat(this.getCurrentValue());
        if (oldValue[0] !== newValue[0]) {
            var tempValue = !!this.mergeValues ? this.mergeValues(newValue, oldValue) : [].concat(oldValue, newValue);
            this.onNextRender(function () {
                _this.animation.runGroupAnimation(_this.animationOptions, newValue, oldValue, [], function () {
                    _this.update(newValue);
                });
            }, function () { return _this.update(newValue); });
            this.update(tempValue, true);
        }
        else {
            this.update(newValue);
        }
    };
    return AnimationTab;
}(animation_AnimationProperty));


// CONCATENATED MODULE: ./packages/survey-core/src/survey-element.ts
var survey_element_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var survey_element_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};










/**
 * A base class for the [`SurveyElement`](https://surveyjs.io/form-library/documentation/surveyelement) and [`SurveyModel`](https://surveyjs.io/form-library/documentation/surveymodel) classes.
 */
var survey_element_SurveyElementCore = /** @class */ (function (_super) {
    survey_element_extends(SurveyElementCore, _super);
    function SurveyElementCore() {
        var _this = _super.call(this) || this;
        _this.createLocTitleProperty();
        return _this;
    }
    SurveyElementCore.prototype.createLocTitleProperty = function () {
        return this.createLocalizableString("title", this, true);
    };
    Object.defineProperty(SurveyElementCore.prototype, "isPage", {
        /**
         * Returns `true` if the survey element is a page.
         * @see Base.getType
         */
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElementCore.prototype, "isPanel", {
        /**
         * Returns `true` if the survey element is a panel.
         * @see Base.getType
         */
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElementCore.prototype, "isQuestion", {
        /**
         * Returns `true` if the survey element is a question.
         * @see Base.getType
         */
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElementCore.prototype, "isSurvey", {
        /**
         * Returns `true` if the element is a survey.
         * @see Base.getType
         */
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElementCore.prototype, "title", {
        /**
         * A title for the survey element. If `title` is undefined, the `name` property value is displayed instead.
         *
         * Empty pages and panels do not display their titles or names.
         *
         * @see [Configure Question Titles](https://surveyjs.io/form-library/documentation/design-survey-question-titles)
        */
        get: function () {
            return this.getLocalizableStringText("title", this.getDefaultTitleValue());
        },
        set: function (val) {
            this.setLocalizableStringText("title", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElementCore.prototype, "locTitle", {
        get: function () {
            return this.getLocalizableString("title");
        },
        enumerable: false,
        configurable: true
    });
    SurveyElementCore.prototype.getDefaultTitleValue = function () { return undefined; };
    SurveyElementCore.prototype.updateDescriptionVisibility = function (newDescription) {
        var showPlaceholder = false;
        if (this.isDesignMode) {
            var property_1 = Serializer.findProperty(this.getType(), "description");
            showPlaceholder = !!(property_1 === null || property_1 === void 0 ? void 0 : property_1.placeholder);
        }
        this.hasDescription = !!newDescription || (showPlaceholder && this.isDesignMode);
    };
    Object.defineProperty(SurveyElementCore.prototype, "locDescription", {
        get: function () {
            return this.getLocalizableString("description");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElementCore.prototype, "titleTagName", {
        get: function () {
            var titleTagName = this.getDefaultTitleTagName();
            var survey = this.getSurvey();
            return !!survey ? survey.getElementTitleTagName(this, titleTagName) : titleTagName;
        },
        enumerable: false,
        configurable: true
    });
    SurveyElementCore.prototype.getDefaultTitleTagName = function () {
        return settings.titleTags[this.getType()];
    };
    Object.defineProperty(SurveyElementCore.prototype, "hasTitle", {
        get: function () { return this.title.length > 0; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElementCore.prototype, "hasTitleActions", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElementCore.prototype, "hasTitleEvents", {
        get: function () {
            return this.hasTitleActions;
        },
        enumerable: false,
        configurable: true
    });
    SurveyElementCore.prototype.getTitleToolbar = function () { return null; };
    SurveyElementCore.prototype.getTitleOwner = function () { return undefined; };
    Object.defineProperty(SurveyElementCore.prototype, "isTitleOwner", {
        get: function () { return !!this.getTitleOwner(); },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElementCore.prototype, "isTitleRenderedAsString", {
        get: function () { return this.getIsTitleRenderedAsString(); },
        enumerable: false,
        configurable: true
    });
    SurveyElementCore.prototype.toggleState = function () { return undefined; };
    Object.defineProperty(SurveyElementCore.prototype, "cssClasses", {
        get: function () { return {}; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElementCore.prototype, "cssTitle", {
        get: function () { return ""; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElementCore.prototype, "ariaTitleId", {
        get: function () { return undefined; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElementCore.prototype, "ariaDescriptionId", {
        get: function () { return undefined; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElementCore.prototype, "titleTabIndex", {
        get: function () { return undefined; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElementCore.prototype, "titleAriaExpanded", {
        get: function () { return undefined; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElementCore.prototype, "titleAriaRole", {
        get: function () { return undefined; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElementCore.prototype, "ariaLabel", {
        get: function () {
            return this.locTitle.renderedHtml;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElementCore.prototype, "titleAriaLabel", {
        get: function () {
            return this.ariaLabel;
        },
        enumerable: false,
        configurable: true
    });
    SurveyElementCore.prototype.getIsTitleRenderedAsString = function () { return !this.isTitleOwner; };
    survey_element_decorate([
        jsonobject_property()
    ], SurveyElementCore.prototype, "hasDescription", void 0);
    survey_element_decorate([
        jsonobject_property({
            localizable: true,
            onSet: function (newDescription, self) {
                self.updateDescriptionVisibility(newDescription);
            }
        })
    ], SurveyElementCore.prototype, "description", void 0);
    return SurveyElementCore;
}(base_Base));

// TODO: rename
var DragTypeOverMeEnum;
(function (DragTypeOverMeEnum) {
    DragTypeOverMeEnum[DragTypeOverMeEnum["InsideEmptyPanel"] = 1] = "InsideEmptyPanel";
    DragTypeOverMeEnum[DragTypeOverMeEnum["MultilineRight"] = 2] = "MultilineRight";
    DragTypeOverMeEnum[DragTypeOverMeEnum["MultilineLeft"] = 3] = "MultilineLeft";
    DragTypeOverMeEnum[DragTypeOverMeEnum["Top"] = 4] = "Top";
    DragTypeOverMeEnum[DragTypeOverMeEnum["Right"] = 5] = "Right";
    DragTypeOverMeEnum[DragTypeOverMeEnum["Bottom"] = 6] = "Bottom";
    DragTypeOverMeEnum[DragTypeOverMeEnum["Left"] = 7] = "Left";
})(DragTypeOverMeEnum || (DragTypeOverMeEnum = {}));
/**
 * A base class for all survey elements.
 */
var survey_element_SurveyElement = /** @class */ (function (_super) {
    survey_element_extends(SurveyElement, _super);
    function SurveyElement(name) {
        var _this = _super.call(this) || this;
        _this.selectedElementInDesignValue = _this;
        _this.disableDesignActions = SurveyElement.CreateDisabledDesignElements;
        _this.parentQuestionValue = null;
        _this.isContentElement = false;
        _this.isEditableTemplateElement = false;
        _this.isInteractiveDesignElement = true;
        _this.isSingleInRow = true;
        _this._renderedIsExpanded = true;
        _this._isAnimatingCollapseExpand = false;
        _this.animationCollapsed = new AnimationBoolean(_this.getExpandCollapseAnimationOptions(), function (val) {
            _this._renderedIsExpanded = val;
            if (_this.animationAllowed) {
                if (val) {
                    _this.isAnimatingCollapseExpand = true;
                }
                else {
                    _this.updateElementCss(false);
                }
            }
        }, function () { return _this.renderedIsExpanded; });
        _this.name = name;
        _this.createNewArray("errors");
        _this.createNewArray("titleActions");
        _this.registerPropertyChangedHandlers(["isReadOnly"], function () { _this.onReadOnlyChanged(); });
        _this.registerPropertyChangedHandlers(["errors"], function () { _this.updateVisibleErrors(); });
        _this.registerPropertyChangedHandlers(["isSingleInRow"], function () { _this.updateElementCss(false); });
        _this.registerPropertyChangedHandlers(["minWidth", "maxWidth", "renderWidth", "allowRootStyle", "parent"], function () { _this.updateRootStyle(); });
        return _this;
    }
    SurveyElement.getProgressInfoByElements = function (children, isRequired) {
        var info = base_Base.createProgressInfo();
        for (var i = 0; i < children.length; i++) {
            if (!children[i].isVisible)
                continue;
            var childInfo = children[i].getProgressInfo();
            info.questionCount += childInfo.questionCount;
            info.answeredQuestionCount += childInfo.answeredQuestionCount;
            info.requiredQuestionCount += childInfo.requiredQuestionCount;
            info.requiredAnsweredQuestionCount +=
                childInfo.requiredAnsweredQuestionCount;
        }
        if (isRequired && info.questionCount > 0) {
            if (info.requiredQuestionCount == 0)
                info.requiredQuestionCount = 1;
            if (info.answeredQuestionCount > 0)
                info.requiredAnsweredQuestionCount = 1;
        }
        return info;
    };
    SurveyElement.ScrollElementToTop = function (elementId, scrollIfVisible, scrollIntoViewOptions) {
        var root = settings.environment.root;
        if (!elementId || typeof root === "undefined")
            return false;
        var el = root.getElementById(elementId);
        return SurveyElement.ScrollElementToViewCore(el, false, scrollIfVisible, scrollIntoViewOptions);
    };
    SurveyElement.ScrollElementToViewCore = function (el, checkLeft, scrollIfVisible, scrollIntoViewOptions) {
        if (!el || !el.scrollIntoView)
            return false;
        var elTop = scrollIfVisible ? -1 : el.getBoundingClientRect().top;
        var needScroll = elTop < 0;
        var elLeft = -1;
        if (!needScroll && checkLeft) {
            elLeft = el.getBoundingClientRect().left;
            needScroll = elLeft < 0;
        }
        if (!needScroll && DomWindowHelper.isAvailable()) {
            var height = DomWindowHelper.getInnerHeight();
            needScroll = height > 0 && height < elTop;
            if (!needScroll && checkLeft) {
                var width = DomWindowHelper.getInnerWidth();
                needScroll = width > 0 && width < elLeft;
            }
        }
        if (needScroll) {
            el.scrollIntoView(scrollIntoViewOptions);
        }
        return needScroll;
    };
    SurveyElement.GetFirstNonTextElement = function (elements, removeSpaces) {
        if (removeSpaces === void 0) { removeSpaces = false; }
        if (!elements || !elements.length || elements.length == 0)
            return null;
        if (removeSpaces) {
            var tEl = elements[0];
            if (tEl.nodeName === "#text")
                tEl.data = "";
            tEl = elements[elements.length - 1];
            if (tEl.nodeName === "#text")
                tEl.data = "";
        }
        for (var i = 0; i < elements.length; i++) {
            if (elements[i].nodeName != "#text" && elements[i].nodeName != "#comment")
                return elements[i];
        }
        return null;
    };
    SurveyElement.FocusElement = function (elementId) {
        if (!elementId || !DomDocumentHelper.isAvailable())
            return false;
        var res = SurveyElement.focusElementCore(elementId);
        if (!res) {
            setTimeout(function () {
                SurveyElement.focusElementCore(elementId);
            }, 10);
        }
        return res;
    };
    SurveyElement.focusElementCore = function (elementId) {
        var root = settings.environment.root;
        if (!root)
            return false;
        var el = root.getElementById(elementId);
        // https://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom
        if (el && !el["disabled"] && el.style.display !== "none" && el.offsetParent !== null) {
            SurveyElement.ScrollElementToViewCore(el, true, false);
            el.focus();
            return true;
        }
        return false;
    };
    Object.defineProperty(SurveyElement.prototype, "colSpan", {
        get: function () {
            return this.getPropertyValue("colSpan", 1);
        },
        set: function (val) {
            this.setPropertyValue("colSpan", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.onPropertyValueChanged = function (name, oldValue, newValue) {
        _super.prototype.onPropertyValueChanged.call(this, name, oldValue, newValue);
        if (name === "state") {
            this.updateElementCss(false);
            this.notifyStateChanged(oldValue);
            if (this.stateChangedCallback)
                this.stateChangedCallback();
        }
    };
    SurveyElement.prototype.getSkeletonComponentNameCore = function () {
        if (this.survey) {
            return this.survey.getSkeletonComponentName(this);
        }
        return "";
    };
    Object.defineProperty(SurveyElement.prototype, "parentQuestion", {
        /**
         * A Dynamic Panel, Dynamic Matrix, or Dropdown Matrix that includes the current question.
         *
         * This property is `null` for standalone questions.
         */
        get: function () {
            return this.parentQuestionValue;
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.setParentQuestion = function (val) {
        this.parentQuestionValue = val;
        this.onParentQuestionChanged();
    };
    SurveyElement.prototype.onParentQuestionChanged = function () { };
    Object.defineProperty(SurveyElement.prototype, "skeletonComponentName", {
        get: function () {
            return this.getSkeletonComponentNameCore();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "state", {
        /**
         * Gets and sets the survey element's expand state.
         *
         * Possible values:
         *
         * - `"default"` (default) - The survey element is displayed in full and cannot be collapsed in the UI.
         * - `"expanded"` - The survey element is displayed in full and can be collapsed in the UI.
         * - `"collapsed"` - The survey element displays only `title` and `description` and can be expanded in the UI.
         *
         * @see toggleState
         * @see collapse
         * @see expand
         * @see isCollapsed
         * @see isExpanded
         */
        get: function () {
            return this.getPropertyValue("state");
        },
        set: function (val) {
            this.setPropertyValue("state", val);
            this.renderedIsExpanded = !(this.state === "collapsed" && !this.isDesignMode);
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.notifyStateChanged = function (prevState) {
        if (this.survey) {
            this.survey.elementContentVisibilityChanged(this);
        }
    };
    Object.defineProperty(SurveyElement.prototype, "isCollapsed", {
        /**
         * Returns `true` if the survey element is collapsed.
         * @see state
         * @see toggleState
         * @see collapse
         * @see expand
         * @see isExpanded
         */
        get: function () {
            return this.state === "collapsed" && !this.isDesignMode;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "isExpanded", {
        /**
         * Returns `true` if the survey element is expanded.
         * @see state
         * @see toggleState
         * @see collapse
         * @see expand
         * @see isCollapsed
         */
        get: function () {
            return this.state === "expanded";
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Collapses the survey element.
     *
     * In collapsed state, the element displays only `title` and `description`.
     * @see title
     * @see description
     * @see state
     * @see toggleState
     * @see expand
     * @see isCollapsed
     * @see isExpanded
     */
    SurveyElement.prototype.collapse = function () {
        if (this.isDesignMode)
            return;
        this.state = "collapsed";
    };
    /**
     * Expands the survey element.
     * @see state
     * @see toggleState
     * @see collapse
     * @see isCollapsed
     * @see isExpanded
     */
    SurveyElement.prototype.expand = function () {
        this.state = "expanded";
    };
    /**
     * Toggles the survey element's `state` between collapsed and expanded.
     * @see state
     * @see collapse
     * @see expand
     * @see isCollapsed
     * @see isExpanded
     */
    SurveyElement.prototype.toggleState = function () {
        if (this.isCollapsed) {
            this.expand();
            return true;
        }
        if (this.isExpanded) {
            this.collapse();
            return false;
        }
        return true;
    };
    Object.defineProperty(SurveyElement.prototype, "hasStateButton", {
        get: function () {
            return this.isExpanded || this.isCollapsed;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "shortcutText", {
        get: function () {
            return this.title || this.name;
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.getTitleToolbar = function () {
        if (!this.titleToolbarValue) {
            this.titleToolbarValue = this.createActionContainer(true);
            this.titleToolbarValue.containerCss = (this.isPanel ? this.cssClasses.panel.titleBar : this.cssClasses.titleBar) || "sv-action-title-bar";
            this.titleToolbarValue.setItems(this.getTitleActions());
        }
        return this.titleToolbarValue;
    };
    SurveyElement.prototype.createActionContainer = function (allowAdaptiveActions) {
        var actionContainer = allowAdaptiveActions ? new adaptive_container_AdaptiveActionContainer() : new container_ActionContainer();
        if (this.survey && !!this.survey.getCss().actionBar) {
            actionContainer.cssClasses = this.survey.getCss().actionBar;
        }
        return actionContainer;
    };
    Object.defineProperty(SurveyElement.prototype, "titleActions", {
        get: function () {
            return this.getPropertyValue("titleActions");
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.getTitleActions = function () {
        if (!this.isTitleActionRequested) {
            this.updateTitleActions();
            this.isTitleActionRequested = true;
        }
        return this.titleActions;
    };
    SurveyElement.prototype.getDefaultTitleActions = function () {
        return [];
    };
    SurveyElement.prototype.updateTitleActions = function () {
        var actions = this.getDefaultTitleActions();
        if (!!this.survey) {
            actions = this.survey.getUpdatedElementTitleActions(this, actions);
        }
        this.setPropertyValue("titleActions", actions);
    };
    Object.defineProperty(SurveyElement.prototype, "hasTitleActions", {
        get: function () {
            return this.getTitleActions().length > 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "hasTitleEvents", {
        get: function () {
            return this.state !== undefined && this.state !== "default";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "titleTabIndex", {
        get: function () {
            return !this.isPage && this.state !== "default" ? 0 : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "titleAriaExpanded", {
        get: function () {
            if (this.isPage || this.state === "default")
                return undefined;
            return this.state === "expanded" ? "true" : "false";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "titleAriaRole", {
        get: function () {
            if (this.isPage || this.state === "default")
                return undefined;
            return "button";
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.setSurveyImpl = function (value, isLight) {
        this.surveyImplValue = value;
        if (!this.surveyImplValue) {
            this.setSurveyCore(null);
            this.surveyDataValue = null;
        }
        else {
            this.surveyDataValue = this.surveyImplValue.getSurveyData();
            this.setSurveyCore(this.surveyImplValue.getSurvey());
            this.textProcessorValue = this.surveyImplValue.getTextProcessor();
            this.onSetData();
        }
        if (!!this.survey) {
            this.updateDescriptionVisibility(this.description);
            this.clearCssClasses();
        }
    };
    SurveyElement.prototype.canRunConditions = function () {
        return _super.prototype.canRunConditions.call(this) && !!this.data;
    };
    SurveyElement.prototype.getDataFilteredValues = function () {
        return !!this.data ? this.data.getFilteredValues() : {};
    };
    SurveyElement.prototype.getDataFilteredProperties = function () {
        var props = !!this.data ? this.data.getFilteredProperties() : {};
        props.question = this;
        return props;
    };
    Object.defineProperty(SurveyElement.prototype, "surveyImpl", {
        get: function () {
            return this.surveyImplValue;
        },
        enumerable: false,
        configurable: true
    });
    /* You shouldn't use this method ever */
    SurveyElement.prototype.__setData = function (data) {
        if (settings.supportCreatorV2) {
            this.surveyDataValue = data;
        }
    };
    Object.defineProperty(SurveyElement.prototype, "data", {
        get: function () {
            return this.surveyDataValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "survey", {
        /**
         * Returns the survey object.
         */
        get: function () {
            return this.getSurvey();
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.getSurvey = function (live) {
        if (live === void 0) { live = false; }
        if (!!this.surveyValue)
            return this.surveyValue;
        if (!!this.surveyImplValue) {
            this.setSurveyCore(this.surveyImplValue.getSurvey());
        }
        return this.surveyValue;
    };
    SurveyElement.prototype.setSurveyCore = function (value) {
        this.surveyValue = value;
        if (!!this.surveyChangedCallback) {
            this.surveyChangedCallback();
        }
    };
    Object.defineProperty(SurveyElement.prototype, "isInternal", {
        get: function () {
            return this.isContentElement;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "areInvisibleElementsShowing", {
        get: function () {
            return (!!this.survey &&
                this.survey.areInvisibleElementsShowing &&
                !this.isContentElement);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "isVisible", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "isReadOnly", {
        /**
         * Returns `true` if the survey element or its parent element is read-only.
         *
         * If you want to switch a survey element to the read-only state based on a condition, specify the [`enableIf`](https://surveyjs.io/form-library/documentation/question#enableIf) property. Refer to the following help topic for information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see readOnly
         */
        get: function () {
            return this.readOnly;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "readOnly", {
        /**
         * Makes the survey element read-only.
         *
         * If you want to switch a survey element to the read-only state based on a condition, specify the [`enableIf`](https://surveyjs.io/form-library/documentation/question#enableIf) property. Refer to the following help topic for information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see isReadOnly
         */
        get: function () {
            return this.getPropertyValue("readOnly");
        },
        set: function (val) {
            if (this.readOnly == val)
                return;
            this.setPropertyValue("readOnly", val);
            if (!this.isLoadingFromJson) {
                this.setPropertyValue("isReadOnly", this.isReadOnly);
            }
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.onReadOnlyChanged = function () {
        if (!!this.readOnlyChangedCallback) {
            this.readOnlyChangedCallback();
        }
    };
    Object.defineProperty(SurveyElement.prototype, "css", {
        get: function () {
            return !!this.survey ? this.survey.getCss() : {};
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "cssClassesValue", {
        get: function () {
            return this.getPropertyValueWithoutDefault("cssClassesValue");
        },
        set: function (val) {
            this.setPropertyValue("cssClassesValue", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.ensureCssClassesValue = function () {
        if (!this.cssClassesValue) {
            this.cssClassesValue = this.calcCssClasses(this.css);
            this.updateElementCssCore(this.cssClassesValue);
        }
    };
    Object.defineProperty(SurveyElement.prototype, "cssClasses", {
        /**
         * Returns an object in which keys are UI elements and values are CSS classes applied to them.
         *
         * Use the following events of the [`SurveyModel`](https://surveyjs.io/form-library/documentation/surveymodel) object to override CSS classes:
         *
         * - [`onUpdateQuestionCssClasses`](https://surveyjs.io/form-library/documentation/surveymodel#onUpdateQuestionCssClasses)
         * - [`onUpdatePanelCssClasses`](https://surveyjs.io/form-library/documentation/surveymodel#onUpdatePanelCssClasses)
         * - [`onUpdatePageCssClasses`](https://surveyjs.io/form-library/documentation/surveymodel#onUpdatePageCssClasses)
         * - [`onUpdateChoiceItemCss`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onUpdateChoiceItemCss)
         */
        get: function () {
            var _dummy = this.cssClassesValue;
            if (!this.survey)
                return this.calcCssClasses(this.css);
            this.ensureCssClassesValue();
            return this.cssClassesValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "cssTitleNumber", {
        get: function () {
            var css = this.cssClasses;
            if (css.number)
                return css.number;
            return css.panel ? css.panel.number : undefined;
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.calcCssClasses = function (css) { return undefined; };
    SurveyElement.prototype.updateElementCssCore = function (cssClasses) { };
    Object.defineProperty(SurveyElement.prototype, "cssError", {
        get: function () { return ""; },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.updateElementCss = function (reNew) {
        this.clearCssClasses();
    };
    SurveyElement.prototype.clearCssClasses = function () {
        this.cssClassesValue = undefined;
    };
    SurveyElement.prototype.getIsLoadingFromJson = function () {
        if (_super.prototype.getIsLoadingFromJson.call(this))
            return true;
        return this.surveyValue ? this.surveyValue.isLoadingFromJson : false;
    };
    Object.defineProperty(SurveyElement.prototype, "name", {
        /**
         * A survey element identifier.
         *
         * > Question names must be unique.
         */
        get: function () {
            return this.getPropertyValue("name", "");
        },
        set: function (val) {
            var oldValue = this.name;
            this.setPropertyValue("name", this.getValidName(val));
            if (!this.isLoadingFromJson && !!oldValue) {
                this.onNameChanged(oldValue);
            }
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.getValidName = function (name) {
        return name;
    };
    SurveyElement.prototype.onNameChanged = function (oldValue) { };
    SurveyElement.prototype.updateBindingValue = function (valueName, value) {
        if (!!this.data &&
            !this.isTwoValueEquals(value, this.data.getValue(valueName))) {
            this.data.setValue(valueName, value, false);
        }
    };
    Object.defineProperty(SurveyElement.prototype, "errors", {
        /**
         * Validation errors. Call the `validate()` method to validate survey element data.
         * @see validate
         */
        get: function () {
            return this.getPropertyValue("errors");
        },
        set: function (val) {
            this.setPropertyValue("errors", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.updateVisibleErrors = function () {
        var counter = 0;
        for (var i = 0; i < this.errors.length; i++) {
            if (this.errors[i].visible)
                counter++;
        }
        this.hasVisibleErrors = counter > 0;
    };
    Object.defineProperty(SurveyElement.prototype, "containsErrors", {
        /**
         * Returns `true` if the survey element or its child elements have validation errors.
         *
         * This property contains the result of the most recent validation. This result may be outdated. Call the `validate` method to get an up-to-date value.
         * @see errors
         */
        get: function () {
            return this.getPropertyValue("containsErrors", false);
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.updateContainsErrors = function () {
        this.setPropertyValue("containsErrors", this.getContainsErrors());
    };
    SurveyElement.prototype.getContainsErrors = function () {
        return this.errors.length > 0;
    };
    Object.defineProperty(SurveyElement.prototype, "selectedElementInDesign", {
        get: function () {
            return this.selectedElementInDesignValue;
        },
        set: function (val) {
            this.selectedElementInDesignValue = val;
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.updateCustomWidgets = function () { };
    SurveyElement.prototype.onSurveyLoad = function () { };
    Object.defineProperty(SurveyElement.prototype, "wasRendered", {
        get: function () { return !!this.wasRenderedValue; },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.onFirstRendering = function () {
        this.wasRenderedValue = true;
        this.ensureCssClassesValue();
    };
    SurveyElement.prototype.endLoadingFromJson = function () {
        _super.prototype.endLoadingFromJson.call(this);
        if (!this.survey) {
            this.onSurveyLoad();
        }
        this.updateDescriptionVisibility(this.description);
    };
    SurveyElement.prototype.setVisibleIndex = function (index) {
        return 0;
    };
    SurveyElement.prototype.delete = function (doDispose) { };
    /**
     * Returns the survey's [locale](https://surveyjs.io/form-library/documentation/surveymodel#locale).
     *
     * If a default locale is used, this method returns an empty string. To get the applied locale in this case, use the following code:
     *
     * ```js
     * import { surveyLocalization } from 'survey-core';
     * const defaultLocale = surveyLocalization.defaultLocale;
     * ```
     *
     * @see [Localization & Globalization](https://surveyjs.io/form-library/documentation/localization)
     */
    SurveyElement.prototype.getLocale = function () {
        return this.survey
            ? this.survey.getLocale()
            : this.locOwner
                ? this.locOwner.getLocale()
                : "";
    };
    SurveyElement.prototype.getMarkdownHtml = function (text, name) {
        return this.survey
            ? this.survey.getSurveyMarkdownHtml(this, text, name)
            : this.locOwner
                ? this.locOwner.getMarkdownHtml(text, name)
                : undefined;
    };
    SurveyElement.prototype.getRenderer = function (name) {
        return this.survey && typeof this.survey.getRendererForString === "function"
            ? this.survey.getRendererForString(this, name)
            : this.locOwner && typeof this.locOwner.getRenderer === "function"
                ? this.locOwner.getRenderer(name)
                : null;
    };
    SurveyElement.prototype.getRendererContext = function (locStr) {
        return this.survey && typeof this.survey.getRendererContextForString === "function"
            ? this.survey.getRendererContextForString(this, locStr)
            : this.locOwner && typeof this.locOwner.getRendererContext === "function"
                ? this.locOwner.getRendererContext(locStr)
                : locStr;
    };
    SurveyElement.prototype.getProcessedText = function (text) {
        if (this.isLoadingFromJson)
            return text;
        if (this.textProcessor)
            return this.textProcessor.processText(text, this.getUseDisplayValuesInDynamicTexts());
        if (this.locOwner)
            return this.locOwner.getProcessedText(text);
        return text;
    };
    SurveyElement.prototype.getUseDisplayValuesInDynamicTexts = function () { return true; };
    SurveyElement.prototype.removeSelfFromList = function (list) {
        if (!list || !Array.isArray(list))
            return;
        var index = list.indexOf(this);
        if (index > -1) {
            list.splice(index, 1);
        }
    };
    Object.defineProperty(SurveyElement.prototype, "textProcessor", {
        get: function () {
            return this.textProcessorValue;
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.getProcessedHtml = function (html) {
        if (!html || !this.textProcessor)
            return html;
        return this.textProcessor.processText(html, true);
    };
    SurveyElement.prototype.onSetData = function () { };
    Object.defineProperty(SurveyElement.prototype, "parent", {
        get: function () {
            return this.getPropertyValue("parent", null);
        },
        set: function (val) {
            this.setPropertyValue("parent", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.getPage = function (parent) {
        while (parent && parent.parent)
            parent = parent.parent;
        if (parent && parent.getType() == "page")
            return parent;
        return null;
    };
    SurveyElement.prototype.moveToBase = function (parent, container, insertBefore) {
        if (insertBefore === void 0) { insertBefore = null; }
        if (!container)
            return false;
        parent.removeElement(this);
        var index = -1;
        if (helpers_Helpers.isNumber(insertBefore)) {
            index = parseInt(insertBefore);
        }
        if (index == -1 && !!insertBefore && !!insertBefore.getType) {
            index = container.indexOf(insertBefore);
        }
        container.addElement(this, index);
        return true;
    };
    SurveyElement.prototype.setPage = function (parent, newPage) {
        var oldPage = this.getPage(parent);
        //fix for the creator v1: https://github.com/surveyjs/survey-creator/issues/1744
        if (typeof newPage === "string") {
            var survey = this.getSurvey();
            survey.pages.forEach(function (page) {
                if (newPage === page.name)
                    newPage = page;
            });
        }
        if (oldPage === newPage)
            return;
        if (parent)
            parent.removeElement(this);
        if (newPage) {
            newPage.addElement(this, -1);
        }
    };
    SurveyElement.prototype.getSearchableLocKeys = function (keys) {
        keys.push("title");
        keys.push("description");
    };
    Object.defineProperty(SurveyElement.prototype, "isDefaultV2Theme", {
        get: function () {
            return this.survey && this.survey.getCss().root == "sd-root-modern";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "hasParent", {
        get: function () {
            return (this.parent && !this.parent.isPage && (!this.parent.originalPage)) || (this.parent === undefined);
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.shouldAddRunnerStyles = function () {
        return !this.isDesignMode && this.isDefaultV2Theme;
    };
    Object.defineProperty(SurveyElement.prototype, "isCompact", {
        get: function () {
            return this.survey && this.survey["isCompact"];
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.canHaveFrameStyles = function () {
        return (this.parent !== undefined && (!this.hasParent || this.parent && this.parent.showPanelAsPage));
    };
    SurveyElement.prototype.getHasFrameV2 = function () {
        return this.shouldAddRunnerStyles() && this.canHaveFrameStyles();
    };
    SurveyElement.prototype.getIsNested = function () {
        return this.shouldAddRunnerStyles() && !this.canHaveFrameStyles();
    };
    SurveyElement.prototype.getCssRoot = function (cssClasses) {
        var isExpanadable = !!this.isCollapsed || !!this.isExpanded;
        return new CssClassBuilder()
            .append(cssClasses.withFrame, this.getHasFrameV2() && !this.isCompact)
            .append(cssClasses.compact, this.isCompact && this.getHasFrameV2())
            .append(cssClasses.collapsed, !!this.isCollapsed)
            .append(cssClasses.expandableAnimating, isExpanadable && this.isAnimatingCollapseExpand)
            .append(cssClasses.expanded, !!this.isExpanded && this.renderedIsExpanded)
            .append(cssClasses.expandable, isExpanadable)
            .append(cssClasses.nested, this.getIsNested())
            .toString();
    };
    Object.defineProperty(SurveyElement.prototype, "width", {
        /**
         * Sets survey element width in CSS values.
         *
         * Default value: ""
         * @see minWidth
         * @see maxWidth
        */
        get: function () {
            return this.getPropertyValue("width", "");
        },
        set: function (val) {
            this.setPropertyValue("width", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "minWidth", {
        /**
         * Gets or sets minimum survey element width in CSS values.
         *
         * Default value: "300px" (taken from [`settings.minWidth`](https://surveyjs.io/form-library/documentation/settings#minWidth))
         * @see maxWidth
         * @see renderWidth
         * @see width
         */
        get: function () {
            return this.getPropertyValue("minWidth");
        },
        set: function (val) {
            this.setPropertyValue("minWidth", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "maxWidth", {
        /**
         * Gets or sets maximum survey element width in CSS values.
         *
         * Default value: "100%" (taken from [`settings.maxWidth`](https://surveyjs.io/form-library/documentation/settings#maxWidth))
         * @see minWidth
         * @see renderWidth
         * @see width
         */
        get: function () {
            return this.getPropertyValue("maxWidth");
        },
        set: function (val) {
            this.setPropertyValue("maxWidth", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "renderWidth", {
        /**
         * Returns a calculated width of the rendered survey element in CSS values.
         * @see width
         * @see minWidth
         * @see maxWidth
         */
        get: function () {
            return this.getPropertyValue("renderWidth", "");
        },
        set: function (val) {
            this.setPropertyValue("renderWidth", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "indent", {
        /**
         * Increases or decreases an indent of survey element content from the left edge. Accepts positive integer values and 0. Does not apply in the Default V2 theme.
         * @see rightIndent
         */
        get: function () {
            return this.getPropertyValue("indent");
        },
        set: function (val) {
            this.setPropertyValue("indent", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "rightIndent", {
        /**
         * Increases or decreases an indent of survey element content from the right edge. Accepts positive integer values and 0. Does not apply in the Default V2 theme.
         * @see indent
         */
        get: function () {
            return this.getPropertyValue("rightIndent", 0);
        },
        set: function (val) {
            this.setPropertyValue("rightIndent", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.getRootStyle = function () {
        var style = {};
        if (!!this.paddingLeft) {
            style["--sv-element-add-padding-left"] = this.paddingLeft;
        }
        if (!!this.paddingRight) {
            style["--sv-element-add-padding-right"] = this.paddingRight;
        }
        return style;
    };
    Object.defineProperty(SurveyElement.prototype, "paddingLeft", {
        get: function () {
            return this.getPropertyValue("paddingLeft", "");
        },
        set: function (val) {
            this.setPropertyValue("paddingLeft", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "paddingRight", {
        get: function () {
            return this.getPropertyValue("paddingRight", "");
        },
        set: function (val) {
            this.setPropertyValue("paddingRight", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.updateRootStyle = function () {
        var style = {};
        var _width;
        if (!!this.parent) {
            var columns = this.parent.getColumsForElement(this);
            _width = columns.reduce(function (sum, col) { return col.effectiveWidth + sum; }, 0);
            if (!!_width && _width !== 100) {
                style["flexGrow"] = 0;
                style["flexShrink"] = 0;
                style["flexBasis"] = _width + "%";
                style["minWidth"] = undefined;
                style["maxWidth"] = undefined;
            }
        }
        if (Object.keys(style).length == 0) {
            var minWidth = this.minWidth;
            if (minWidth != "auto")
                minWidth = "min(100%, " + minWidth + ")";
            if (this.allowRootStyle && this.renderWidth) {
                // style["width"] = this.renderWidth;
                style["flexGrow"] = 1;
                style["flexShrink"] = 1;
                style["flexBasis"] = this.renderWidth;
                style["minWidth"] = minWidth;
                style["maxWidth"] = this.maxWidth;
            }
        }
        this.rootStyle = style;
    };
    SurveyElement.prototype.isContainsSelection = function (el) {
        var elementWithSelection = undefined;
        var _document = DomDocumentHelper.getDocument();
        if (DomDocumentHelper.isAvailable() && !!_document && _document["selection"]) {
            elementWithSelection = _document["selection"].createRange().parentElement();
        }
        else {
            var selection = DomWindowHelper.getSelection();
            if (!!selection && selection.rangeCount > 0) {
                var range = selection.getRangeAt(0);
                if (range.startOffset !== range.endOffset) {
                    elementWithSelection = range.startContainer.parentNode;
                }
            }
        }
        return elementWithSelection == el;
    };
    Object.defineProperty(SurveyElement.prototype, "clickTitleFunction", {
        get: function () {
            var _this = this;
            if (this.needClickTitleFunction()) {
                return function (event) {
                    if (!!event && _this.isContainsSelection(event.target)) {
                        return;
                    }
                    return _this.processTitleClick();
                };
            }
            return undefined;
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.needClickTitleFunction = function () {
        return this.state !== "default";
    };
    SurveyElement.prototype.processTitleClick = function () {
        if (this.state !== "default") {
            this.toggleState();
        }
    };
    Object.defineProperty(SurveyElement.prototype, "hasAdditionalTitleToolbar", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "additionalTitleToolbar", {
        get: function () {
            return this.getAdditionalTitleToolbar();
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.getAdditionalTitleToolbar = function () {
        return null;
    };
    SurveyElement.prototype.getCssTitle = function (cssClasses) {
        var isExpandable = this.state !== "default";
        var numInlineLimit = 4;
        return new CssClassBuilder()
            .append(cssClasses.title)
            .append(cssClasses.titleNumInline, (this.no || "").length > numInlineLimit || isExpandable)
            .append(cssClasses.titleExpandable, isExpandable)
            .append(cssClasses.titleExpanded, this.isExpanded)
            .append(cssClasses.titleCollapsed, this.isCollapsed)
            .append(cssClasses.titleDisabled, this.isDisabledStyle)
            .append(cssClasses.titleReadOnly, this.isReadOnly)
            .append(cssClasses.titleOnError, this.containsErrors).toString();
    };
    Object.defineProperty(SurveyElement.prototype, "isDisabledStyle", {
        get: function () {
            return this.getIsDisableAndReadOnlyStyles(false)[1];
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "isReadOnlyStyle", {
        get: function () {
            return this.getIsDisableAndReadOnlyStyles(false)[0];
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.getIsDisableAndReadOnlyStyles = function (itemReadOnly) {
        var isPreview = this.isPreviewStyle;
        var isReadOnly = itemReadOnly || this.isReadOnly;
        var isReadOnlyStyle = isReadOnly && !isPreview;
        var isDisableStyle = !this.isDefaultV2Theme && (isReadOnly || isPreview);
        return [isReadOnlyStyle, isDisableStyle];
    };
    Object.defineProperty(SurveyElement.prototype, "isPreviewStyle", {
        get: function () {
            return !!this.survey && this.survey.state === "preview";
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.localeChanged = function () {
        _super.prototype.localeChanged.call(this);
        this.updateDescriptionVisibility(this.description);
        if (this.errors.length > 0) {
            this.errors.forEach(function (err) {
                err.updateText();
            });
        }
    };
    SurveyElement.prototype.setWrapperElement = function (element) {
        this.wrapperElement = element;
    };
    SurveyElement.prototype.getWrapperElement = function () {
        return this.wrapperElement;
    };
    Object.defineProperty(SurveyElement.prototype, "isAnimatingCollapseExpand", {
        get: function () {
            return this._isAnimatingCollapseExpand || this._renderedIsExpanded != this.isExpanded;
        },
        set: function (val) {
            if (val !== this._isAnimatingCollapseExpand) {
                this._isAnimatingCollapseExpand = val;
                this.updateElementCss(false);
            }
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.onElementExpanded = function (elementIsRendered) {
    };
    SurveyElement.prototype.getExpandCollapseAnimationOptions = function () {
        var _this = this;
        var beforeRunAnimation = function (el) {
            _this.isAnimatingCollapseExpand = true;
            el.style.setProperty("--animation-height", el.offsetHeight + "px");
        };
        var afterRunAnimation = function (el) {
            _this.isAnimatingCollapseExpand = false;
        };
        return {
            getRerenderEvent: function () { return _this.onElementRerendered; },
            getEnterOptions: function () {
                var cssClasses = _this.isPanel ? _this.cssClasses.panel : _this.cssClasses;
                return {
                    cssClass: cssClasses.contentFadeIn,
                    onBeforeRunAnimation: beforeRunAnimation,
                    onAfterRunAnimation: function (el) {
                        afterRunAnimation(el);
                        _this.onElementExpanded(true);
                    },
                };
            },
            getLeaveOptions: function () {
                var cssClasses = _this.isPanel ? _this.cssClasses.panel : _this.cssClasses;
                return {
                    cssClass: cssClasses.contentFadeOut,
                    onBeforeRunAnimation: beforeRunAnimation,
                    onAfterRunAnimation: afterRunAnimation
                };
            },
            getAnimatedElement: function () {
                var _a;
                var cssClasses = _this.isPanel ? _this.cssClasses.panel : _this.cssClasses;
                if (cssClasses.content) {
                    var selector = classesToSelector(cssClasses.content);
                    if (selector) {
                        return (_a = _this.getWrapperElement()) === null || _a === void 0 ? void 0 : _a.querySelector(":scope " + selector);
                    }
                }
                return undefined;
            },
            isAnimationEnabled: function () { return _this.isExpandCollapseAnimationEnabled; }
        };
    };
    Object.defineProperty(SurveyElement.prototype, "isExpandCollapseAnimationEnabled", {
        get: function () {
            return this.animationAllowed && !this.isDesignMode;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyElement.prototype, "renderedIsExpanded", {
        get: function () {
            return !!this._renderedIsExpanded;
        },
        set: function (val) {
            var oldValue = this._renderedIsExpanded;
            this.animationCollapsed.sync(val);
            if (!this.isExpandCollapseAnimationEnabled && !oldValue && this.renderedIsExpanded) {
                this.onElementExpanded(false);
            }
        },
        enumerable: false,
        configurable: true
    });
    SurveyElement.prototype.getIsAnimationAllowed = function () {
        return _super.prototype.getIsAnimationAllowed.call(this) && !!this.survey && !this.survey["isEndLoadingFromJson"];
    };
    SurveyElement.prototype.dispose = function () {
        _super.prototype.dispose.call(this);
        if (this.titleToolbarValue) {
            this.titleToolbarValue.dispose();
        }
    };
    SurveyElement.CreateDisabledDesignElements = false;
    survey_element_decorate([
        jsonobject_property({ defaultValue: null })
    ], SurveyElement.prototype, "dragTypeOverMe", void 0);
    survey_element_decorate([
        jsonobject_property({ defaultValue: false })
    ], SurveyElement.prototype, "isDragMe", void 0);
    survey_element_decorate([
        jsonobject_property({
            onSet: function (newValue, target) {
                target.colSpan = newValue;
            }
        })
    ], SurveyElement.prototype, "effectiveColSpan", void 0);
    survey_element_decorate([
        jsonobject_property({ defaultValue: false })
    ], SurveyElement.prototype, "hasVisibleErrors", void 0);
    survey_element_decorate([
        jsonobject_property({ defaultValue: true })
    ], SurveyElement.prototype, "isSingleInRow", void 0);
    survey_element_decorate([
        jsonobject_property({ defaultValue: true })
    ], SurveyElement.prototype, "allowRootStyle", void 0);
    survey_element_decorate([
        jsonobject_property()
    ], SurveyElement.prototype, "rootStyle", void 0);
    survey_element_decorate([
        jsonobject_property()
    ], SurveyElement.prototype, "_renderedIsExpanded", void 0);
    return SurveyElement;
}(survey_element_SurveyElementCore));


// CONCATENATED MODULE: ./packages/survey-core/src/localizablestring.ts






/**
 * The class represents the string that supports multi-languages and markdown.
 * It uses in all objects where support for multi-languages and markdown is required.
 */
var localizablestring_LocalizableString = /** @class */ (function () {
    function LocalizableString(owner, useMarkdown, name) {
        if (useMarkdown === void 0) { useMarkdown = false; }
        var _a;
        this.owner = owner;
        this.useMarkdown = useMarkdown;
        this.name = name;
        this.values = {};
        this.htmlValues = {};
        this._allowLineBreaks = false;
        this.onStringChanged = new EventBase();
        if (owner instanceof survey_element_SurveyElementCore) {
            this._allowLineBreaks = ((_a = Serializer.findProperty(owner.getType(), name)) === null || _a === void 0 ? void 0 : _a.type) == "text";
        }
        this.onCreating();
    }
    Object.defineProperty(LocalizableString, "defaultLocale", {
        get: function () {
            return settings.localization.defaultLocaleName;
        },
        set: function (val) {
            settings.localization.defaultLocaleName = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(LocalizableString.prototype, "localizationName", {
        get: function () {
            return this._localizationName;
        },
        set: function (val) {
            if (this._localizationName != val) {
                this._localizationName = val;
                this.strChanged();
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(LocalizableString.prototype, "allowLineBreaks", {
        get: function () {
            return this._allowLineBreaks;
        },
        enumerable: false,
        configurable: true
    });
    LocalizableString.prototype.getIsMultiple = function () { return false; };
    Object.defineProperty(LocalizableString.prototype, "locale", {
        get: function () {
            if (this.owner && this.owner.getLocale) {
                var res = this.owner.getLocale();
                if (!!res || !this.sharedData)
                    return res;
            }
            if (!!this.sharedData)
                return this.sharedData.locale;
            return "";
        },
        enumerable: false,
        configurable: true
    });
    LocalizableString.prototype.strChanged = function () {
        this.searchableText = undefined;
        if (this.renderedText === undefined && this.isEmpty && !this.onGetTextCallback && !this.localizationName)
            return;
        this.calculatedTextValue = this.calcText();
        if (this.renderedText !== this.calculatedTextValue) {
            this.renderedText = undefined;
            this.calculatedTextValue = undefined;
        }
        this.htmlValues = {};
        this.onChanged();
        this.onStringChanged.fire(this, {});
    };
    Object.defineProperty(LocalizableString.prototype, "text", {
        get: function () {
            return this.pureText;
        },
        set: function (value) {
            this.setLocaleText(this.locale, value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(LocalizableString.prototype, "calculatedText", {
        get: function () {
            this.renderedText =
                this.calculatedTextValue !== undefined
                    ? this.calculatedTextValue
                    : this.calcText();
            this.calculatedTextValue = undefined;
            return this.renderedText;
        },
        enumerable: false,
        configurable: true
    });
    LocalizableString.prototype.calcText = function () {
        var res = this.pureText;
        if (res &&
            this.owner &&
            this.owner.getProcessedText &&
            res.indexOf("{") > -1) {
            res = this.owner.getProcessedText(res);
        }
        if (this.onGetTextCallback)
            res = this.onGetTextCallback(res);
        return res;
    };
    Object.defineProperty(LocalizableString.prototype, "pureText", {
        get: function () {
            var loc = this.locale;
            if (!loc)
                loc = this.defaultLoc;
            var res = this.getValue(loc);
            if (this.isValueEmpty(res) && loc === this.defaultLoc) {
                res = this.getValue(surveyLocalization.defaultLocale);
            }
            if (this.isValueEmpty(res)) {
                var dialect = this.getRootDialect(loc);
                if (!!dialect) {
                    res = this.getValue(dialect);
                }
            }
            if (this.isValueEmpty(res) && loc !== this.defaultLoc) {
                res = this.getValue(this.defaultLoc);
            }
            if (this.isValueEmpty(res) && !!this.getLocalizationName()) {
                res = this.getLocalizationStr();
                if (!!this.onGetLocalizationTextCallback) {
                    res = this.onGetLocalizationTextCallback(res);
                }
            }
            if (!res)
                res = this.defaultValue || "";
            return res;
        },
        enumerable: false,
        configurable: true
    });
    LocalizableString.prototype.getRootDialect = function (loc) {
        if (!loc)
            return loc;
        var index = loc.indexOf("-");
        return index > -1 ? loc.substring(0, index) : "";
    };
    LocalizableString.prototype.getLocalizationName = function () {
        return !!this.sharedData ? this.sharedData.localizationName : this.localizationName;
    };
    LocalizableString.prototype.getLocalizationStr = function () {
        var name = this.getLocalizationName();
        return !!name ? surveyLocalization.getString(name, this.locale) : "";
    };
    Object.defineProperty(LocalizableString.prototype, "hasHtml", {
        get: function () {
            return this.hasHtmlValue();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(LocalizableString.prototype, "html", {
        get: function () {
            if (!this.hasHtml)
                return "";
            return this.getHtmlValue();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(LocalizableString.prototype, "isEmpty", {
        get: function () {
            return this.getValuesKeys().length == 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(LocalizableString.prototype, "textOrHtml", {
        get: function () {
            return this.hasHtml ? this.getHtmlValue() : this.calculatedText;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(LocalizableString.prototype, "renderedHtml", {
        get: function () {
            return this.textOrHtml;
        },
        enumerable: false,
        configurable: true
    });
    LocalizableString.prototype.getLocaleText = function (loc) {
        var res = this.getLocaleTextCore(loc);
        return res ? res : "";
    };
    LocalizableString.prototype.getLocaleTextCore = function (loc) {
        if (!loc)
            loc = this.defaultLoc;
        return this.getValue(loc);
    };
    LocalizableString.prototype.isLocaleTextEqualsWithDefault = function (loc, val) {
        var res = this.getLocaleTextCore(loc);
        if (res === val)
            return true;
        return this.isValueEmpty(res) && this.isValueEmpty(val);
    };
    LocalizableString.prototype.clear = function () {
        this.setJson(undefined);
    };
    LocalizableString.prototype.clearLocale = function (loc) {
        this.setLocaleText(loc, undefined);
    };
    LocalizableString.prototype.setLocaleText = function (loc, value) {
        loc = this.getValueLoc(loc);
        if (!this.storeDefaultText && this.isLocaleTextEqualsWithDefault(loc, value)) {
            if (!this.isValueEmpty(value) || !!loc && loc !== this.defaultLoc)
                return;
            var dl = surveyLocalization.defaultLocale;
            var oldValue_1 = this.getValue(dl);
            if (!!dl && !this.isValueEmpty(oldValue_1)) {
                this.setValue(dl, value);
                this.fireStrChanged(dl, oldValue_1);
            }
            return;
        }
        if (!settings.localization.storeDuplicatedTranslations &&
            !this.isValueEmpty(value) && loc && loc != this.defaultLoc &&
            !this.getValue(loc) &&
            value == this.getLocaleText(this.defaultLoc))
            return;
        var curLoc = this.curLocale;
        if (!loc)
            loc = this.defaultLoc;
        var oldValue = this.onStrChanged && loc === curLoc ? this.pureText : undefined;
        delete this.htmlValues[loc];
        if (this.isValueEmpty(value)) {
            this.deleteValue(loc);
        }
        else {
            if (typeof value === "string") {
                if (this.canRemoveLocValue(loc, value)) {
                    this.setLocaleText(loc, null);
                }
                else {
                    this.setValue(loc, value);
                    if (loc == this.defaultLoc) {
                        this.deleteValuesEqualsToDefault(value);
                    }
                }
            }
        }
        this.fireStrChanged(loc, oldValue);
    };
    LocalizableString.prototype.isValueEmpty = function (val) {
        if (val === undefined || val === null)
            return true;
        if (this.localizationName)
            return false;
        return val === "";
    };
    Object.defineProperty(LocalizableString.prototype, "curLocale", {
        get: function () {
            return !!this.locale ? this.locale : this.defaultLoc;
        },
        enumerable: false,
        configurable: true
    });
    LocalizableString.prototype.canRemoveLocValue = function (loc, val) {
        if (settings.localization.storeDuplicatedTranslations)
            return false;
        if (loc === this.defaultLoc)
            return false;
        var dialect = this.getRootDialect(loc);
        if (!!dialect) {
            var dialectVal = this.getLocaleText(dialect);
            if (!!dialectVal)
                return dialectVal == val;
            return this.canRemoveLocValue(dialect, val);
        }
        else {
            return val == this.getLocaleText(this.defaultLoc);
        }
    };
    LocalizableString.prototype.fireStrChanged = function (loc, oldValue) {
        this.strChanged();
        if (!this.onStrChanged)
            return;
        var value = this.pureText;
        if (loc !== this.curLocale || oldValue !== value) {
            this.onStrChanged(oldValue, value);
        }
    };
    LocalizableString.prototype.hasNonDefaultText = function () {
        var keys = this.getValuesKeys();
        if (keys.length == 0)
            return false;
        return keys.length > 1 || keys[0] != this.defaultLoc;
    };
    LocalizableString.prototype.getLocales = function () {
        var keys = this.getValuesKeys();
        if (keys.length == 0)
            return [];
        return keys;
    };
    LocalizableString.prototype.getJson = function () {
        if (!!this.sharedData)
            return this.sharedData.getJson();
        var keys = this.getValuesKeys();
        if (keys.length == 0)
            return null;
        if (keys.length == 1 &&
            keys[0] == settings.localization.defaultLocaleName &&
            !settings.serialization.localizableStringSerializeAsObject)
            return this.values[keys[0]];
        var res = {};
        for (var key in this.values) {
            res[key] = this.values[key];
        }
        return res;
    };
    LocalizableString.prototype.setJson = function (value) {
        if (!!this.sharedData) {
            this.sharedData.setJson(value);
            return;
        }
        this.values = {};
        this.htmlValues = {};
        if (value === null || value === undefined)
            return;
        if (typeof value === "string") {
            this.setLocaleText(null, value);
        }
        else {
            for (var key in value) {
                this.setLocaleText(key, value[key]);
            }
        }
        this.strChanged();
    };
    Object.defineProperty(LocalizableString.prototype, "renderAs", {
        get: function () {
            if (!this.owner || typeof this.owner.getRenderer !== "function") {
                return LocalizableString.defaultRenderer;
            }
            return this.owner.getRenderer(this.name) || LocalizableString.defaultRenderer;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(LocalizableString.prototype, "renderAsData", {
        get: function () {
            if (!this.owner || typeof this.owner.getRendererContext !== "function") {
                return this;
            }
            return this.owner.getRendererContext(this) || this;
        },
        enumerable: false,
        configurable: true
    });
    LocalizableString.prototype.equals = function (obj) {
        if (!!this.sharedData)
            return this.sharedData.equals(obj);
        if (!obj || !obj.values)
            return false;
        return helpers_Helpers.isTwoValueEquals(this.values, obj.values, false, true, false);
    };
    LocalizableString.prototype.setFindText = function (text) {
        if (this.searchText == text)
            return;
        this.searchText = text;
        if (!this.searchableText) {
            var textOrHtml = this.textOrHtml;
            this.searchableText = !!textOrHtml ? textOrHtml.toLowerCase() : "";
        }
        var str = this.searchableText;
        var index = !!str && !!text ? str.indexOf(text) : undefined;
        if (index < 0)
            index = undefined;
        if (index != undefined || this.searchIndex != index) {
            this.searchIndex = index;
            if (!!this.onSearchChanged) {
                this.onSearchChanged();
            }
        }
        return this.searchIndex != undefined;
    };
    LocalizableString.prototype.onChanged = function () { };
    LocalizableString.prototype.onCreating = function () { };
    LocalizableString.prototype.hasHtmlValue = function () {
        if (!this.owner || !this.useMarkdown)
            return false;
        var loc = this.locale;
        if (!loc)
            loc = this.defaultLoc;
        if (this.htmlValues[loc] !== undefined)
            return !!this.htmlValues[loc];
        var renderedText = this.calculatedText;
        if (!renderedText) {
            this.setHtmlValue(loc, "");
            return false;
        }
        if (!!this.getLocalizationName() && renderedText === this.getLocalizationStr()) {
            this.setHtmlValue(loc, "");
            return false;
        }
        var res = this.owner.getMarkdownHtml(renderedText, this.name);
        this.setHtmlValue(loc, res);
        return !!res;
    };
    LocalizableString.prototype.setHtmlValue = function (loc, val) {
        this.htmlValues[loc] = val;
    };
    LocalizableString.prototype.getHtmlValue = function () {
        var loc = this.locale;
        if (!loc)
            loc = this.defaultLoc;
        return this.htmlValues[loc];
    };
    LocalizableString.prototype.deleteValuesEqualsToDefault = function (defaultValue) {
        if (settings.localization.storeDuplicatedTranslations)
            return;
        var keys = this.getValuesKeys();
        for (var i = 0; i < keys.length; i++) {
            if (keys[i] == this.defaultLoc)
                continue;
            if (this.getValue(keys[i]) == defaultValue) {
                this.deleteValue(keys[i]);
            }
        }
    };
    LocalizableString.prototype.getValue = function (loc) {
        if (!!this.sharedData)
            return this.sharedData.getValue(loc);
        return this.values[this.getValueLoc(loc)];
    };
    LocalizableString.prototype.setValue = function (loc, value) {
        if (!!this.sharedData)
            this.sharedData.setValue(loc, value);
        else
            this.values[this.getValueLoc(loc)] = value;
    };
    LocalizableString.prototype.deleteValue = function (loc) {
        if (!!this.sharedData)
            this.sharedData.deleteValue(loc);
        else
            delete this.values[this.getValueLoc(loc)];
    };
    LocalizableString.prototype.getValueLoc = function (loc) {
        if (this.disableLocalization)
            return settings.localization.defaultLocaleName;
        return loc;
    };
    LocalizableString.prototype.getValuesKeys = function () {
        if (!!this.sharedData)
            return this.sharedData.getValuesKeys();
        return Object.keys(this.values);
    };
    Object.defineProperty(LocalizableString.prototype, "defaultLoc", {
        get: function () {
            return settings.localization.defaultLocaleName;
        },
        enumerable: false,
        configurable: true
    });
    LocalizableString.SerializeAsObject = false;
    LocalizableString.defaultRenderer = "sv-string-viewer";
    LocalizableString.editableRenderer = "sv-string-editor";
    return LocalizableString;
}());

/**
 * The class represents the list of strings that supports multi-languages.
 */
var localizablestring_LocalizableStrings = /** @class */ (function () {
    function LocalizableStrings(owner) {
        this.owner = owner;
        this.values = {};
    }
    LocalizableStrings.prototype.getIsMultiple = function () { return true; };
    Object.defineProperty(LocalizableStrings.prototype, "locale", {
        get: function () {
            return this.owner && this.owner.getLocale ? this.owner.getLocale() : "";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(LocalizableStrings.prototype, "value", {
        get: function () {
            return this.getValue("");
        },
        set: function (val) {
            this.setValue("", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(LocalizableStrings.prototype, "text", {
        get: function () {
            return Array.isArray(this.value) ? this.value.join("\n") : "";
        },
        set: function (val) {
            this.value = !!val ? val.split("\n") : [];
        },
        enumerable: false,
        configurable: true
    });
    LocalizableStrings.prototype.getLocaleText = function (loc) {
        var res = this.getValueCore(loc, !loc || loc === this.locale);
        if (!res || !Array.isArray(res) || res.length == 0)
            return "";
        return res.join("\n");
    };
    LocalizableStrings.prototype.setLocaleText = function (loc, newValue) {
        var val = !!newValue ? newValue.split("\n") : null;
        this.setValue(loc, val);
    };
    LocalizableStrings.prototype.getValue = function (loc) {
        return this.getValueCore(loc);
    };
    LocalizableStrings.prototype.getValueCore = function (loc, useDefault) {
        if (useDefault === void 0) { useDefault = true; }
        loc = this.getLocale(loc);
        if (this.values[loc])
            return this.values[loc];
        if (useDefault) {
            var defLoc = settings.localization.defaultLocaleName;
            if (loc !== defLoc && this.values[defLoc])
                return this.values[defLoc];
        }
        return [];
    };
    LocalizableStrings.prototype.setValue = function (loc, val) {
        loc = this.getLocale(loc);
        var oldValue = helpers_Helpers.createCopy(this.values);
        if (!val || val.length == 0) {
            delete this.values[loc];
        }
        else {
            this.values[loc] = val;
        }
        if (!!this.onValueChanged) {
            this.onValueChanged(oldValue, this.values);
        }
    };
    LocalizableStrings.prototype.hasValue = function (loc) {
        if (loc === void 0) { loc = ""; }
        return !this.isEmpty && this.getValue(loc).length > 0;
    };
    Object.defineProperty(LocalizableStrings.prototype, "isEmpty", {
        get: function () {
            return this.getValuesKeys().length == 0;
        },
        enumerable: false,
        configurable: true
    });
    LocalizableStrings.prototype.getLocale = function (loc) {
        if (!!loc)
            return loc;
        loc = this.locale;
        return !!loc ? loc : settings.localization.defaultLocaleName;
    };
    LocalizableStrings.prototype.getLocales = function () {
        var keys = this.getValuesKeys();
        if (keys.length == 0)
            return [];
        return keys;
    };
    LocalizableStrings.prototype.getJson = function () {
        var keys = this.getValuesKeys();
        if (keys.length == 0)
            return null;
        if (keys.length == 1 &&
            keys[0] == settings.localization.defaultLocaleName &&
            !settings.serialization.localizableStringSerializeAsObject)
            return this.values[keys[0]];
        return helpers_Helpers.createCopy(this.values);
    };
    LocalizableStrings.prototype.setJson = function (value) {
        this.values = {};
        if (!value)
            return;
        if (Array.isArray(value)) {
            this.setValue(null, value);
        }
        else {
            for (var key in value) {
                this.setValue(key, value[key]);
            }
        }
    };
    LocalizableStrings.prototype.getValuesKeys = function () {
        return Object.keys(this.values);
    };
    return LocalizableStrings;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/utils/utils.ts




function compareVersions(a, b) {
    var regExStrip0 = /(\.0+)+$/;
    var segmentsA = a.replace(regExStrip0, "").split(".");
    var segmentsB = b.replace(regExStrip0, "").split(".");
    var len = Math.min(segmentsA.length, segmentsB.length);
    for (var i = 0; i < len; i++) {
        var diff = parseInt(segmentsA[i], 10) - parseInt(segmentsB[i], 10);
        if (diff) {
            return diff;
        }
    }
    return segmentsA.length - segmentsB.length;
}
function confirmAction(message) {
    if (!!settings && !!settings.confirmActionFunc)
        return settings.confirmActionFunc(message);
    return confirm(message);
}
function confirmActionAsync(message, funcOnYes, funcOnNo, locale, rootElement) {
    var callbackFunc = function (res) {
        if (res)
            funcOnYes();
        else if (!!funcOnNo)
            funcOnNo();
    };
    if (!!settings && !!settings.confirmActionAsync) {
        if (settings.confirmActionAsync(message, callbackFunc, undefined, locale, rootElement))
            return;
    }
    callbackFunc(confirmAction(message));
}
function detectIEBrowser() {
    var ua = navigator.userAgent;
    var oldIe = ua.indexOf("MSIE ");
    var elevenIe = ua.indexOf("Trident/");
    return oldIe > -1 || elevenIe > -1;
}
function detectIEOrEdge() {
    if (typeof detectIEOrEdge.isIEOrEdge === "undefined") {
        var ua = navigator.userAgent;
        var msie = ua.indexOf("MSIE ");
        var trident = ua.indexOf("Trident/");
        var edge = ua.indexOf("Edge/");
        detectIEOrEdge.isIEOrEdge = edge > 0 || trident > 0 || msie > 0;
    }
    return detectIEOrEdge.isIEOrEdge;
}
function loadFileFromBase64(b64Data, fileName) {
    try {
        var byteString = atob(b64Data.split(",")[1]);
        // separate out the mime component
        var mimeString = b64Data
            .split(",")[0]
            .split(":")[1]
            .split(";")[0];
        // write the bytes of the string to an ArrayBuffer
        var ab = new ArrayBuffer(byteString.length);
        var ia = new Uint8Array(ab);
        for (var i = 0; i < byteString.length; i++) {
            ia[i] = byteString.charCodeAt(i);
        }
        // write the ArrayBuffer to a blob, and you're done
        var bb = new Blob([ab], { type: mimeString });
        if (!!navigator && navigator["msSaveBlob"]) {
            navigator["msSaveOrOpenBlob"](bb, fileName);
        }
    }
    catch (err) { }
}
function isMobile() {
    return (DomWindowHelper.isAvailable() && DomWindowHelper.hasOwn("orientation"));
}
var isShadowDOM = function (rootElement) {
    return !!rootElement && !!("host" in rootElement && rootElement.host);
};
var getElement = function (element) {
    var root = settings.environment.root;
    return typeof element === "string" ? root.getElementById(element) : element;
};
function isElementVisible(element, threshold) {
    if (threshold === void 0) { threshold = 0; }
    if (typeof settings.environment === "undefined") {
        return false;
    }
    var root = settings.environment.root;
    var clientHeight = isShadowDOM(root)
        ? root.host.clientHeight
        : root.documentElement.clientHeight;
    var elementRect = element.getBoundingClientRect();
    var viewHeight = Math.max(clientHeight, DomWindowHelper.getInnerHeight());
    var topWin = -threshold;
    var bottomWin = viewHeight + threshold;
    var topEl = elementRect.top;
    var bottomEl = elementRect.bottom;
    var maxTop = Math.max(topWin, topEl);
    var minBottom = Math.min(bottomWin, bottomEl);
    return maxTop <= minBottom;
}
function findScrollableParent(element) {
    var root = settings.environment.root;
    if (!element) {
        return isShadowDOM(root)
            ? root.host
            : root.documentElement;
    }
    if (element.scrollHeight > element.clientHeight &&
        (getComputedStyle(element).overflowY === "scroll" ||
            getComputedStyle(element).overflowY === "auto")) {
        return element;
    }
    if (element.scrollWidth > element.clientWidth &&
        (getComputedStyle(element).overflowX === "scroll" ||
            getComputedStyle(element).overflowX === "auto")) {
        return element;
    }
    return findScrollableParent(element.parentElement);
}
function scrollElementByChildId(id) {
    var environment = settings.environment;
    if (!environment)
        return;
    var root = environment.root;
    var el = root.getElementById(id);
    if (!el)
        return;
    var scrollableEl = findScrollableParent(el);
    if (!!scrollableEl) {
        setTimeout(function () { return scrollableEl.dispatchEvent(new CustomEvent("scroll")); }, 10);
    }
}
function navigateToUrl(url) {
    var location = DomWindowHelper.getLocation();
    if (!url || !location)
        return;
    location.href = getSafeUrl(url);
}
function wrapUrlForBackgroundImage(url) {
    return !!url ? ["url(", url, ")"].join("") : "";
}
function getIconNameFromProxy(iconName) {
    if (!iconName)
        return iconName;
    var proxyName = settings.customIcons[iconName];
    return !!proxyName ? proxyName : iconName;
}
function createSvg(size, width, height, iconName, svgElem, title) {
    if (!svgElem)
        return;
    if (size !== "auto") {
        svgElem.style.width = (size || width || 16) + "px";
        svgElem.style.height = (size || height || 16) + "px";
    }
    var node = svgElem.childNodes[0];
    var realIconName = getIconNameFromProxy(iconName);
    node.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#" + realIconName);
    var titleElement = svgElem.getElementsByTagName("title")[0];
    if (!title) {
        if (!!titleElement) {
            svgElem.removeChild(titleElement);
        }
        return;
    }
    else {
        if (!titleElement) {
            titleElement = DomDocumentHelper.getDocument().createElementNS("http://www.w3.org/2000/svg", "title");
            svgElem.appendChild(titleElement);
        }
    }
    titleElement.textContent = title;
}
function getSafeUrl(url) {
    if (!url)
        return url;
    if (url.toLocaleLowerCase().indexOf("javascript:") > -1)
        return encodeURIComponent(url);
    return url;
}
function unwrap(value) {
    if (typeof value !== "function") {
        return value;
    }
    else {
        return value();
    }
}
// export function getSize(value: any): number {
//   if (typeof value === "number") {
//     return value;
//   }
//   if (typeof value === "string" && value.includes("px")) {
//     return parseInt(value);
//   }
//   if (!!value && typeof value === "string" && value.length > 0) {
//     const lastSymbol: string = value[value.length - 1];
//     if ((lastSymbol >= "0" && lastSymbol <= "9") || lastSymbol == ".") {
//       try {
//         const num: number = parseInt(value);
//         return num;
//       } catch { }
//     }
//   }
//   return value;
// }
function getRenderedSize(val) {
    if (typeof val == "string") {
        if (!isNaN(Number(val))) {
            return Number(val);
        }
        else if (val.includes("px")) {
            return parseFloat(val);
        }
    }
    if (typeof val == "number") {
        return val;
    }
    return undefined;
}
function getRenderedStyleSize(val) {
    if (getRenderedSize(val) !== undefined) {
        return undefined;
    }
    return val;
}
var keyFocusedClassName = "sv-focused--by-key";
function doKey2ClickBlur(evt) {
    var element = evt.target;
    if (!element || !element.classList)
        return;
    element.classList.remove(keyFocusedClassName);
}
function doKey2ClickUp(evt, options) {
    if (!!evt.target && evt.target["contentEditable"] === "true") {
        return;
    }
    var element = evt.target;
    if (!element)
        return;
    var char = evt.which || evt.keyCode;
    if (char === 9) {
        if (!!element.classList && !element.classList.contains(keyFocusedClassName)) {
            element.classList.add(keyFocusedClassName);
        }
        return;
    }
    if (options) {
        if (!options.__keyDownReceived)
            return;
        options.__keyDownReceived = false;
    }
    if (char === 13 || char === 32) {
        if (element.click)
            element.click();
    }
    else if ((!options || options.processEsc) && char === 27) {
        if (element.blur)
            element.blur();
    }
}
function doKey2ClickDown(evt, options) {
    if (options === void 0) { options = { processEsc: true }; }
    if (options)
        options.__keyDownReceived = true;
    if (!!evt.target && evt.target["contentEditable"] === "true") {
        return;
    }
    var char = evt.which || evt.keyCode;
    var supportedCodes = [13, 32];
    if (options.processEsc) {
        supportedCodes.push(27);
    }
    if (supportedCodes.indexOf(char) !== -1) {
        evt.preventDefault();
    }
}
function increaseHeightByContent(element, getComputedStyle) {
    if (!element)
        return;
    if (!getComputedStyle)
        getComputedStyle = function (elt) { return DomDocumentHelper.getComputedStyle(elt); };
    var style = getComputedStyle(element);
    element.style.height = "auto";
    if (!!element.scrollHeight) {
        element.style.height = (element.scrollHeight + parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth)) + "px";
    }
}
function getOriginalEvent(event) {
    return event.originalEvent || event;
}
function preventDefaults(event) {
    event.preventDefault();
    event.stopPropagation();
}
function classesToSelector(str) {
    if (!str)
        return str;
    var re = /\s*?([\w-]+)\s*?/g;
    return str.replace(re, ".$1");
}
function getElementWidth(el) {
    return !!getComputedStyle ? Number.parseFloat(getComputedStyle(el).width) : el.offsetWidth;
}
function isContainerVisible(el) {
    return !!(el.offsetWidth ||
        el.offsetHeight ||
        el.getClientRects().length);
}
function getFirstVisibleChild(el) {
    var result;
    for (var index = 0; index < el.children.length; index++) {
        if (!result && getComputedStyle(el.children[index]).display !== "none") {
            result = el.children[index];
        }
    }
    return result;
}
function findParentByClassNames(element, classNames) {
    if (!!element) {
        if (classNames.every(function (className) { return !className || element.classList.contains(className); })) {
            return element;
        }
        else {
            return findParentByClassNames(element.parentElement, classNames);
        }
    }
}
function sanitizeEditableContent(element, cleanLineBreaks) {
    if (cleanLineBreaks === void 0) { cleanLineBreaks = true; }
    if (DomWindowHelper.isAvailable() && DomDocumentHelper.isAvailable() && element.childNodes.length > 0) {
        var selection = DomWindowHelper.getSelection();
        if (selection.rangeCount == 0) {
            return;
        }
        var range = selection.getRangeAt(0);
        range.setStart(range.endContainer, range.endOffset);
        range.setEndAfter(element.lastChild);
        selection.removeAllRanges();
        selection.addRange(range);
        var tail = selection.toString();
        var innerText = element.innerText;
        tail = tail.replace(/\r/g, "");
        if (cleanLineBreaks) {
            tail = tail.replace(/\n/g, "");
            innerText = innerText.replace(/\n/g, "");
        }
        var tail_len = tail.length;
        element.innerText = innerText;
        range = DomDocumentHelper.getDocument().createRange();
        range.setStart(element.firstChild, 0);
        range.setEnd(element.firstChild, 0);
        selection.removeAllRanges();
        selection.addRange(range);
        while (selection.toString().length < innerText.length - tail_len) {
            var selLen = selection.toString().length;
            selection.modify("extend", "forward", "character");
            if (selection.toString().length == selLen)
                break;
        }
        range = selection.getRangeAt(0);
        range.setStart(range.endContainer, range.endOffset);
    }
}
function mergeValues(src, dest) {
    if (!dest || !src)
        return;
    if (typeof dest !== "object")
        return;
    for (var key in src) {
        var value = src[key];
        if (!Array.isArray(value) && value && typeof value === "object") {
            if (!dest[key] || typeof dest[key] !== "object")
                dest[key] = {};
            mergeValues(value, dest[key]);
        }
        else {
            dest[key] = value;
        }
    }
}
var Logger = /** @class */ (function () {
    function Logger() {
        this._result = "";
    }
    Logger.prototype.log = function (action) {
        this._result += "->" + action;
    };
    Object.defineProperty(Logger.prototype, "result", {
        get: function () {
            return this._result;
        },
        enumerable: false,
        configurable: true
    });
    return Logger;
}());

function showConfirmDialog(message, callback, applyTitle, locale, rootElement) {
    var locStr = new localizablestring_LocalizableString(undefined);
    var popupViewModel = settings.showDialog({
        componentName: "sv-string-viewer",
        data: { locStr: locStr, locString: locStr, model: locStr },
        onApply: function () {
            callback(true);
            return true;
        },
        onCancel: function () {
            callback(false);
            return false;
        },
        title: message,
        displayMode: "popup",
        isFocusedContent: false,
        cssClass: "sv-popup--confirm-delete"
    }, rootElement);
    var toolbar = popupViewModel.footerToolbar;
    var applyBtn = toolbar.getActionById("apply");
    var cancelBtn = toolbar.getActionById("cancel");
    cancelBtn.title = surveyLocalization.getString("cancel", locale);
    cancelBtn.innerCss = "sv-popup__body-footer-item sv-popup__button sd-btn sd-btn--small";
    applyBtn.title = applyTitle || surveyLocalization.getString("ok", locale);
    applyBtn.innerCss = "sv-popup__body-footer-item sv-popup__button sv-popup__button--danger sd-btn sd-btn--small sd-btn--danger";
    configConfirmDialog(popupViewModel);
    return true;
}
function configConfirmDialog(popupViewModel) {
    popupViewModel.width = "min-content";
}
function chooseFiles(input, callback) {
    if (!DomWindowHelper.isFileReaderAvailable())
        return;
    input.value = "";
    input.onchange = function (event) {
        if (!DomWindowHelper.isFileReaderAvailable())
            return;
        if (!input || !input.files || input.files.length < 1)
            return;
        var files = [];
        for (var i = 0; i < input.files.length; i++) {
            files.push(input.files[i]);
        }
        callback(files);
    };
    input.click();
}
function compareArrays(oldValue, newValue, getKey) {
    var oldItemsMap = new Map();
    var newItemsMap = new Map();
    var commonItemsInNewMap = new Map();
    var commonItemsInOldMap = new Map();
    oldValue.forEach(function (item) {
        var itemKey = getKey(item);
        if (!oldItemsMap.has(itemKey)) {
            oldItemsMap.set(getKey(item), item);
        }
        else {
            //if keys are set incorrectly do not process comparing
            throw new Error("keys must be unique");
        }
    });
    newValue.forEach(function (item) {
        var itemKey = getKey(item);
        if (!newItemsMap.has(itemKey)) {
            newItemsMap.set(itemKey, item);
        }
        else {
            //if keys are set incorrectly do not process comparing
            throw new Error("keys must be unique");
        }
    });
    var addedItems = [];
    var deletedItems = [];
    //calculating addedItems and items that exist in both arrays
    newItemsMap.forEach(function (item, key) {
        if (!oldItemsMap.has(key)) {
            addedItems.push(item);
        }
        else {
            commonItemsInNewMap.set(key, commonItemsInNewMap.size);
        }
    });
    //calculating deletedItems and items that exist in both arrays
    oldItemsMap.forEach(function (item, key) {
        if (!newItemsMap.has(key)) {
            deletedItems.push(item);
        }
        else {
            commonItemsInOldMap.set(key, commonItemsInOldMap.size);
        }
    });
    //calculating reordered items
    var reorderedItems = [];
    commonItemsInNewMap.forEach(function (index, key) {
        var oldIndex = commonItemsInOldMap.get(key);
        var item = newItemsMap.get(key);
        if (oldIndex !== index)
            reorderedItems.push({ item: item, movedForward: oldIndex < index });
    });
    //calculating merged array if multiple operations are applied at once
    var oldItemsWithCorrectOrder = new Array(oldValue.length);
    var commonItemsIndex = 0;
    var commonItemsKeysOrder = Array.from(commonItemsInNewMap.keys());
    oldValue.forEach(function (item, index) {
        if (commonItemsInNewMap.has(getKey(item))) {
            oldItemsWithCorrectOrder[index] = newItemsMap.get(commonItemsKeysOrder[commonItemsIndex]);
            commonItemsIndex++;
        }
        else {
            oldItemsWithCorrectOrder[index] = item;
        }
    });
    var valuesToInsertBeforeKey = new Map();
    var tempValuesArray = [];
    oldItemsWithCorrectOrder.forEach(function (item) {
        var itemKey = getKey(item);
        if (newItemsMap.has(itemKey)) {
            if (tempValuesArray.length > 0) {
                valuesToInsertBeforeKey.set(itemKey, tempValuesArray);
                tempValuesArray = [];
            }
        }
        else {
            tempValuesArray.push(item);
        }
    });
    var mergedItems = new Array();
    newItemsMap.forEach(function (item, key) {
        if (valuesToInsertBeforeKey.has(key)) {
            valuesToInsertBeforeKey.get(key).forEach(function (item) {
                mergedItems.push(item);
            });
        }
        mergedItems.push(item);
    });
    tempValuesArray.forEach(function (item) {
        mergedItems.push(item);
    });
    return { reorderedItems: reorderedItems, deletedItems: deletedItems, addedItems: addedItems, mergedItems: mergedItems };
}
function roundTo2Decimals(number) {
    return Math.round(number * 100) / 100;
}


// CONCATENATED MODULE: ./packages/survey-core/src/settings.ts


var settings_document = typeof globalThis !== "undefined" ? globalThis.document : undefined.document;
var defaultEnvironment = (!!settings_document ? {
    root: settings_document,
    _rootElement: DomDocumentHelper.getBody(),
    get rootElement() {
        var _a;
        return (_a = this._rootElement) !== null && _a !== void 0 ? _a : DomDocumentHelper.getBody();
    },
    set rootElement(rootElement) {
        this._rootElement = rootElement;
    },
    _popupMountContainer: DomDocumentHelper.getBody(),
    get popupMountContainer() {
        var _a;
        return (_a = this._popupMountContainer) !== null && _a !== void 0 ? _a : DomDocumentHelper.getBody();
    },
    set popupMountContainer(popupMountContainer) {
        this._popupMountContainer = popupMountContainer;
    },
    svgMountContainer: settings_document.head,
    stylesSheetsMountContainer: settings_document.head,
} : undefined);
var columnWidthsByType = {
    "file": { minWidth: "240px" },
    "comment": { minWidth: "200px" }
};
/**
 * Global settings that apply to all surveys on the page. To specify one of the settings, use the code below:
 *
 * ```js
 * import { settings } from "survey-core";
 *
 * settings.settingName = "value";
 * ```
 */
var settings = {
    /**
     * An object that configures survey appearance when the survey is being designed in Survey Creator.
     *
     * Nested properties:
     *
     * - `showEmptyDescriptions`: `boolean`\
     * Specifies whether to display an empty description for pages and panels. Default value: `true`.
     *
     * - `showEmptyTitles`: `boolean`\
     * Specifies whether to display an empty title for pages and panels. Default value: `true`.
     */
    designMode: {
        showEmptyDescriptions: true,
        showEmptyTitles: true
    },
    //#region designMode section, Obsolete properties
    get allowShowEmptyDescriptionInDesignMode() { return this.designMode.showEmptyDescriptions; },
    set allowShowEmptyDescriptionInDesignMode(val) { this.designMode.showEmptyDescriptions = val; },
    get allowShowEmptyTitleInDesignMode() { return this.designMode.showEmptyTitles; },
    set allowShowEmptyTitleInDesignMode(val) { this.designMode.showEmptyTitles = val; },
    //#endregion
    /**
     * An object that contains properties related to localization.
     *
     * Nested properties:
     *
     * - `useLocalTimeZone`: `boolean`\
     * Disable this property if you want internal SurveyJS functions to use methods that work with UTC date and time (`setUTCDate()` `setUTCHours()`, etc.) instead of methods that work with local date and time (`setYear()`, `setHours()`, etc.). Default value: `true`.
     *
     * - `defaultLocaleName`: `string`\
     * A property key that stores a translation for the default locale. Default value: `"default"`.
     *
     * - `storeDuplicatedTranslations`: `boolean`\
     * Specifies whether surveys should store translation strings that equal the translation strings in the default locale. Default value: `false`.
     */
    localization: {
        useLocalTimeZone: true,
        storeDuplicatedTranslations: false,
        defaultLocaleName: "default"
    },
    //#region localization section, obsolete properties
    get useLocalTimeZone() { return this.localization.useLocalTimeZone; },
    set useLocalTimeZone(val) { this.localization.useLocalTimeZone = val; },
    get storeDuplicatedTranslations() { return this.localization.storeDuplicatedTranslations; },
    set storeDuplicatedTranslations(val) { this.localization.storeDuplicatedTranslations = val; },
    get defaultLocaleName() { return this.localization.defaultLocaleName; },
    set defaultLocaleName(val) { this.localization.defaultLocaleName = val; },
    //#endregion
    /**
     * An object with properties that configure surveys when they work with a web service.
     *
     * Nested properties:
     *
     * - `encodeUrlParams`: `boolean`\
     * Specifies whether to encode URL parameters when you access a web service. Default value: `true`.
     *
     * - `cacheLoadedChoices`: `boolean`\
     * Specifies whether to cache [choices loaded from a web service](https://surveyjs.io/form-library/documentation/api-reference/questionselectbase#choicesByUrl). Default value: `true`.
     *
     * - `disableQuestionWhileLoadingChoices`: `boolean`\
     * Disables a question while its choices are being loaded from a web service. Default value: `false`.
     *
     * - `surveyServiceUrl`: `string`\
     * The URL of the SurveyJS Service API endpoint.
     *
     * - `onBeforeRequestChoices`: `(sender: ChoicesRestful, options: { request: XMLHttpRequest })`\
     * An event that is raised before a request for choices is send. Applies to questions with a specified [`choiceByUrl`](https://surveyjs.io/form-library/documentation/api-reference/questionselectbase#choicesByUrl) property. Use the `options.request` parameter to access and modify the `XMLHttpRequest` object. For instance, you can add authentication headers to it:
     *
     *     ```js
     *     import { settings } from "survey-core";
     *
     *     settings.web.onBeforeSendRequest = (sender, options) => {
     *       options.request.setRequestHeader('RequestVerificationToken', requestVerificationToken);
     *     };
     *     ```
     */
    web: {
        onBeforeRequestChoices: function (sender, options) { },
        encodeUrlParams: true,
        cacheLoadedChoices: true,
        disableQuestionWhileLoadingChoices: false,
        surveyServiceUrl: "https://api.surveyjs.io/public/v1/Survey"
    },
    //#region web section, obsolete properties
    get webserviceEncodeParameters() { return this.web.encodeUrlParams; },
    set webserviceEncodeParameters(val) { this.web.encodeUrlParams = val; },
    get useCachingForChoicesRestful() { return this.web.cacheLoadedChoices; },
    set useCachingForChoicesRestful(val) { this.web.cacheLoadedChoices = val; },
    get useCachingForChoicesRestfull() { return this.web.cacheLoadedChoices; },
    set useCachingForChoicesRestfull(val) { this.web.cacheLoadedChoices = val; },
    get disableOnGettingChoicesFromWeb() { return this.web.disableQuestionWhileLoadingChoices; },
    set disableOnGettingChoicesFromWeb(val) { this.web.disableQuestionWhileLoadingChoices = val; },
    get surveyServiceUrl() { return this.web.surveyServiceUrl; },
    set surveyServiceUrl(val) { this.web.surveyServiceUrl = val; },
    //#endregion
    /**
     * An object that contains properties related to [triggers](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#conditional-survey-logic-triggers).
     *
     * Nested properties:
     *
     * - `changeNavigationButtonsOnComplete`: `boolean`\
     * Specifies whether to re-evaluate an expression associated with the [Complete trigger](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#complete) immediately when a question value changes. If the expression evaluates to `true`, the trigger is executed. Default value: `false`.\
     * Keep this property set to `false` if you want to re-evaluate the Complete trigger's expression only when the respondents navigate to another page.
     *
     * - `executeCompleteOnValueChanged`: `boolean`\
     * Specifies whether to replace the Next button with the Complete button when the [Complete trigger](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#complete) is going to be executed. Default value: `true`.
     *
     * - `executeSkipOnValueChanged`: `boolean`\
     * Specifies whether to re-evaluate an expression associated with the [Skip trigger](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#skip) immediately when a question value changes. If the expression evaluates to `true`, the trigger is executed. Default value: `true`.\
     * Disable this property if you want to re-evaluate the Skip trigger's expression only when respondents navigate to another page.
     */
    triggers: {
        changeNavigationButtonsOnComplete: true,
        executeCompleteOnValueChanged: false,
        executeSkipOnValueChanged: true
    },
    //#region triggers section, Obsolete properties
    get executeCompleteTriggerOnValueChanged() { return this.triggers.executeCompleteOnValueChanged; },
    set executeCompleteTriggerOnValueChanged(val) { this.triggers.executeCompleteOnValueChanged = val; },
    get changeNavigationButtonsOnCompleteTrigger() { return this.triggers.changeNavigationButtonsOnComplete; },
    set changeNavigationButtonsOnCompleteTrigger(val) { this.triggers.changeNavigationButtonsOnComplete = val; },
    get executeSkipTriggerOnValueChanged() { return this.triggers.executeSkipOnValueChanged; },
    set executeSkipTriggerOnValueChanged(val) { this.triggers.executeSkipOnValueChanged = val; },
    //#endregion
    /**
     * An object that contains properties related to JSON serialization.
     *
     * Nested properties:
     *
     * - `itemValueSerializeAsObject`: `boolean`\
     * Enable this property if you want to serialize [`ItemValue`](https://surveyjs.io/form-library/documentation/api-reference/itemvalue) instances as objects even when they include only the `value` property. Default value: `false`. View an example below.
     *
     * - `itemValueSerializeDisplayText`: `boolean`\
     * Enable this property if you want to serialize the `text` property of [`ItemValue`](https://surveyjs.io/form-library/documentation/api-reference/itemvalue) objects even when it is empty or equal to the `value` property. Default value: `false`. View an example below.
     *
     * - `localizableStringSerializeAsObject`: `boolean`\
     * Enable this property if you want to serialize [`LocalizableString`](https://surveyjs.io/form-library/documentation/api-reference/localizablestring) instances as objects even when they include only a translation string for the default locale. For example, `"Custom String"` will be serialized as `{ default: "Custom String" }`. Default value: `false`.
     *
     * ```js
     * import { ItemValue, settings } from "survey-core";
     *
     * // `itemValueSerializeAsObject` example
     * settings.serialization.itemValueSerializeAsObject = true;
     * const item = new ItemValue(5);
     * const itemString = item.toJSON(); // Produces { value: 5 } instead of 5
     *
     * // `itemValueSerializeDisplayText` example
     * settings.serialization.itemValueSerializeDisplayText = true;
     * const item = new ItemValue("item1");
     * const itemString = item.toJSON(); // Produces { value: "item1", text: "item1" } instead of "item1"
     * ```
     * @see [settings.parseNumber](https://surveyjs.io/form-library/documentation/api-reference/settings#parseNumber)
     */
    serialization: {
        itemValueSerializeAsObject: false,
        itemValueSerializeDisplayText: false,
        localizableStringSerializeAsObject: false
    },
    //#region serialization section, Obsolete properties
    get itemValueAlwaysSerializeAsObject() { return this.serialization.itemValueSerializeAsObject; },
    set itemValueAlwaysSerializeAsObject(val) { this.serialization.itemValueSerializeAsObject = val; },
    get itemValueAlwaysSerializeText() { return this.serialization.itemValueSerializeDisplayText; },
    set itemValueAlwaysSerializeText(val) { this.serialization.itemValueSerializeDisplayText = val; },
    get serializeLocalizableStringAsObject() { return this.serialization.localizableStringSerializeAsObject; },
    set serializeLocalizableStringAsObject(val) { this.serialization.localizableStringSerializeAsObject = val; },
    //#endregion
    /**
     * An object that configures lazy rendering.
     *
     * Nested properties:
     *
     * - `enabled`: `boolean`\
     * Specifies whether to add questions to the DOM only when they get into the viewport. Default value: `false`.
     *
     * [View Demo](https://surveyjs.io/form-library/examples/survey-lazy/ (linkStyle))
     * @see [SurveyModel.lazyRendering](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#lazyRendering)
     */
    lazyRender: {
        enabled: false,
        firstBatchSize: 3
    },
    //#region lazyRender section, Obsolete properties
    get lazyRowsRendering() { return this.lazyRender.enabled; },
    set lazyRowsRendering(val) { this.lazyRender.enabled = val; },
    get lazyRowsRenderingStartRow() { return this.lazyRender.firstBatchSize; },
    set lazyRowsRenderingStartRow(val) { this.lazyRender.firstBatchSize = val; },
    //#endregion
    /**
     * An object with properties that apply to [Single-Choice](https://surveyjs.io/form-library/documentation/api-reference/matrix-table-question-model), [Multiple-Choice](https://surveyjs.io/form-library/documentation/api-reference/matrix-table-with-dropdown-list), and [Dynamic Matrix](https://surveyjs.io/form-library/documentation/api-reference/dynamic-matrix-table-question-model) questions.
     *
     * Nested properties:
     *
     * - `defaultRowName`: `string`\
     * A property key that stores an object with default cell values. Default value: "default".
     *
     * - `defaultCellType`: `string`\
     * The default type of matrix cells. Default value: `"dropdown"`.\
     * You can specify this setting for individual questions or matrix columns: [`cellType`](https://surveyjs.io/form-library/documentation/api-reference/dynamic-matrix-table-question-model#cellType). Refer to the `cellType` property description for information on possible values.
     *
     * - `totalsSuffix`: `string`\
     * A suffix added to the name of the property that stores total values. The resulting property name consists of the matrix name and the suffix. Default value: `"-total"`.
     *
     * - `maxRowCount`: `number`\
     * A maximum number of rows in a Dynamic Matrix. Default value: 1000.\
     * You can specify this setting for an individual Dynamic Matrix: [`maxRowCount`](https://surveyjs.io/form-library/documentation/api-reference/dynamic-matrix-table-question-model#maxRowCount).
     *
     * - `maxRowCountInCondition`: `number`\
     * A maximum number of matrix rows included in the Condition drop-down menu in Survey Creator. This menu is used to configure conditional survey logic. Default value: 1.\
     * If you set this property to 0, the Condition menu does not include any matrix rows. Users still can specify conditions that use matrix rows but only with Manual Entry.
     *
     * - `renderRemoveAsIcon`: `boolean`\
     * Disable this property if you want to render the Remove action in Dynamic Matrix as a button. Otherwise, the action is rendered as an icon. Default value: `true`.
     *
     * - `columnWidthsByType`: `object`\
     * An object that specifies fixed and minimum column width based on the column type.\
     * Example: `settings.matrix.columnWidthsByType = { "tagbox": { minWidth: "240px", width: "300px" } }`
     *
     * - `rateSize`: `"small"` (default) | `"normal"`\
     * Specifies the size of rate values. Applies to [Rating Scale](https://surveyjs.io/form-library/examples/rating-scale/) questions within matrixes.
     */
    matrix: {
        defaultCellType: "dropdown",
        defaultRowName: "default",
        totalsSuffix: "-total",
        maxRowCount: 1000,
        maxRowCountInCondition: 1,
        renderRemoveAsIcon: true,
        columnWidthsByType: columnWidthsByType,
        rateSize: "small",
    },
    //#region matrix section, Obsolete properties
    get matrixDefaultRowName() { return this.matrix.defaultRowName; },
    set matrixDefaultRowName(val) { this.matrix.defaultRowName = val; },
    get matrixDefaultCellType() { return this.matrix.defaultCellType; },
    set matrixDefaultCellType(val) { this.matrix.defaultCellType = val; },
    get matrixTotalValuePostFix() { return this.matrix.totalsSuffix; },
    set matrixTotalValuePostFix(val) { this.matrix.totalsSuffix = val; },
    get matrixMaximumRowCount() { return this.matrix.maxRowCount; },
    set matrixMaximumRowCount(val) { this.matrix.maxRowCount = val; },
    get matrixMaxRowCountInCondition() { return this.matrix.maxRowCountInCondition; },
    set matrixMaxRowCountInCondition(val) { this.matrix.maxRowCountInCondition = val; },
    get matrixRenderRemoveAsIcon() { return this.matrix.renderRemoveAsIcon; },
    set matrixRenderRemoveAsIcon(val) { this.matrix.renderRemoveAsIcon = val; },
    //#endregion
    /**
     * An object with properties that apply to [Dynamic Panel](https://surveyjs.io/form-library/documentation/api-reference/dynamic-panel-model) questions.
     *
     * Nested properties:
     *
     * - `maxPanelCount`: `number`\
     * A maximum number of panels in Dynamic Panel. Default value: 100.\
     * You can specify this setting for an individual Dynamic Panel: [`maxPanelCount`](https://surveyjs.io/form-library/documentation/api-reference/dynamic-panel-model#maxPanelCount).
     *
     * - `maxPanelCountInCondition`: `number`\
     * A maximum number of Dynamic Panel panels included in the Condition drop-down menu in Survey Creator. This menu is used to configure conditional survey logic. Default value: 1.\
     * If you set this property to 0, the Condition menu does not include any panel questions. Users still can specify conditions that use panel questions but only with Manual Entry.
     */
    panel: {
        maxPanelCount: 100,
        maxPanelCountInCondition: 1
    },
    //#region panel section, Obsolete properties
    get panelDynamicMaxPanelCountInCondition() { return this.panel.maxPanelCountInCondition; },
    set panelDynamicMaxPanelCountInCondition(val) { this.panel.maxPanelCountInCondition = val; },
    get panelMaximumPanelCount() { return this.panel.maxPanelCount; },
    set panelMaximumPanelCount(val) { this.panel.maxPanelCount = val; },
    //#endregion
    /**
     * An object with properties that configure questions in read-only mode.
     *
     * Nested properties:
     *
     * - `commentRenderMode`: `"textarea"` (default) | `"div"`\
     * Specifies how to render the input field of [Comment](https://surveyjs.io/form-library/documentation/api-reference/comment-field-model) questions in [read-only](https://surveyjs.io/form-library/documentation/api-reference/comment-field-model#readOnly) mode: as a disabled `<textarea>` element or as a `<div>` element with a non-editable question value within it.
     *
     * - `textRenderMode`: `"input"` (default) | `"div"`\
     * Specifies how to render the input field of [Text](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model) questions in [read-only](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model#readOnly) mode: as a disabled `<input>` element or as a `<div>` element with a non-editable question value within it.
     */
    readOnly: {
        enableValidation: false,
        commentRenderMode: "textarea",
        textRenderMode: "input"
    },
    //#region readOnly section, Obsolete properties
    get readOnlyCommentRenderMode() { return this.readOnly.commentRenderMode; },
    set readOnlyCommentRenderMode(val) { this.readOnly.commentRenderMode = val; },
    get readOnlyTextRenderMode() { return this.readOnly.textRenderMode; },
    set readOnlyTextRenderMode(val) { this.readOnly.textRenderMode = val; },
    //#endregion
    /**
     * An object with properties that configure question numbering.
     *
     * Nested properties:
     *
     * - `includeQuestionsWithHiddenNumber`: `boolean`\
     * Specifies whether to number questions whose [`hideNumber`](https://surveyjs.io/form-library/documentation/api-reference/question#hideNumber) property is enabled. Default value: `false`.
     *
     * - `includeQuestionsWithHiddenTitle`: `boolean`\
     * Specifies whether to number questions whose [`titleLocation`](https://surveyjs.io/form-library/documentation/api-reference/question#titleLocation) property is set to `"hidden"`. Default value: `false`.
     */
    numbering: {
        includeQuestionsWithHiddenNumber: false,
        includeQuestionsWithHiddenTitle: false
    },
    //#region numbering section, Obsolete properties
    get setQuestionVisibleIndexForHiddenTitle() { return this.numbering.includeQuestionsWithHiddenTitle; },
    set setQuestionVisibleIndexForHiddenTitle(val) { this.numbering.includeQuestionsWithHiddenTitle = val; },
    get setQuestionVisibleIndexForHiddenNumber() { return this.numbering.includeQuestionsWithHiddenNumber; },
    set setQuestionVisibleIndexForHiddenNumber(val) { this.numbering.includeQuestionsWithHiddenNumber = val; },
    //#endregion
    /**
     * Specifies an action to perform when users press the Enter key within a survey.
     *
     * Possible values:
     *
     * - `"moveToNextEditor"` - Moves focus to the next editor.
     * - `"loseFocus"` - Removes focus from the current editor.
     * - `"default"` - Behaves as a standard `<input>` element.
     */
    enterKeyAction: "default",
    /**
     * An object that configures string comparison.
     *
     * Nested properties:
     *
     * - `trimStrings`: `boolean`\
     * Specifies whether to remove whitespace from both ends of a string before the comparison. Default value: `true`.
     *
     * - `caseSensitive`: `boolean`\
     * Specifies whether to differentiate between capital and lower-case letters. Default value: `false`.
     */
    comparator: {
        trimStrings: true,
        caseSensitive: false,
        normalizeTextCallback: function (str, reason) { return str; }
    },
    expressionDisableConversionChar: "#",
    get commentPrefix() { return settings.commentSuffix; },
    set commentPrefix(val) { settings.commentSuffix = val; },
    /**
     * A suffix added to the name of the property that stores comments.
     *
     * Default value: "-Comment"
     *
     * You can specify this setting for an individual survey: [`commentSuffix`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#commentSuffix).
     */
    commentSuffix: "-Comment",
    /**
     * A separator used in a shorthand notation that specifies a value and display text for an [`ItemValue`](https://surveyjs.io/form-library/documentation/api-reference/itemvalue) object: `"value|text"`.
     *
     * Default value: `"|"`
     * @see [settings.choicesSeparator](https://surveyjs.io/form-library/documentation/api-reference/settings#choicesSeparator)
     */
    itemValueSeparator: "|",
    /**
     * A maximum number of rate values in a [Rating](https://surveyjs.io/form-library/documentation/api-reference/rating-scale-question-model) question.
     *
     * Default value: 20
     */
    ratingMaximumRateValueCount: 20,
    /**
     * Specifies whether to close the drop-down menu of a [Multi-Select Dropdown (Tag Box)](https://surveyjs.io/form-library/examples/how-to-create-multiselect-tag-box/) question after a user selects a value.
     *
     * This setting applies to all Multi-Select Dropdown questions on a web page. You can use the [`closeOnSelect`](https://surveyjs.io/form-library/documentation/api-reference/dropdown-tag-box-model#closeOnSelect) property to specify the same setting for an individual Multi-Select Dropdown question.
     */
    tagboxCloseOnSelect: false,
    /**
     * A time interval in milliseconds between the last entered character and the beginning of search in [Single-](https://surveyjs.io/form-library/examples/create-dropdown-menu-in-javascript/) and [Multi-Select Dropdown](https://surveyjs.io/form-library/examples/how-to-create-multiselect-tag-box/) questions. Applies only to questions with the [`choicesLazyLoadEnabled`](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model#choicesLazyLoadEnabled) property set to `true`.
     *
     * Default value: 500
     *
     * [View Demo](https://surveyjs.io/form-library/examples/lazy-loading-dropdown/ (linkStyle))
     */
    dropdownSearchDelay: 500,
    /**
     * A function that activates a browser confirm dialog.
     *
     * Use the following code to execute this function:
     *
     * ```js
     * import { settings } from "survey-core";
     *
     * // `result` contains `true` if the action was confirmed or `false` otherwise
     * const result = settings.confirmActionFunc("Are you sure?");
     * ```
     *
     * You can redefine the `confirmActionFunc` function if you want to display a custom dialog window. Your function should return `true` if a user confirms an action or `false` otherwise.
     * @param message A message to be displayed in the confirm dialog window.
     */
    confirmActionFunc: function (message) {
        return confirm(message);
    },
    /**
     * A function that activates a proprietary SurveyJS confirm dialog.
     *
     * Use the following code to execute this function:
     *
     * ```js
     * import { settings } from "survey-core";
     *
     * settings.confirmActionAsync("Are you sure?", (confirmed) => {
     *   if (confirmed) {
     *     // ...
     *     // Proceed with the action
     *     // ...
     *   } else {
     *     // ...
     *     // Cancel the action
     *     // ...
     *   }
     * });
     * ```
     *
     * You can redefine the `confirmActionAsync` function if you want to display a custom dialog window. Your function should return `true` to be enabled; otherwise, a survey executes the [`confirmActionFunc`](#confirmActionFunc) function. Pass the dialog result as the `callback` parameter: `true` if a user confirms an action, `false` otherwise.
     * @param message A message to be displayed in the confirm dialog window.
     * @param callback A callback function that should be called with `true` if a user confirms an action or `false` otherwise.
     */
    confirmActionAsync: function (message, callback, applyTitle, locale, rootElement) {
        return showConfirmDialog(message, callback, applyTitle, locale, rootElement);
    },
    /**
     * A minimum width value for all survey elements.
     *
     * Default value: `"300px"`
     *
     * You can override this setting for individual elements: [`minWidth`](https://surveyjs.io/form-library/documentation/api-reference/surveyelement#minWidth).
     */
    minWidth: "300px",
    /**
     * A maximum width value for all survey elements.
     *
     * Default value: `"100%"`
     *
     * You can override this setting for individual elements: [`maxWidth`](https://surveyjs.io/form-library/documentation/api-reference/surveyelement#maxWidth).
     */
    maxWidth: "100%",
    /**
     * Specifies how many times surveys can re-evaluate expressions when a question value changes. This limit helps avoid recursions in expressions.
     *
     * Default value: 10
     */
    maxConditionRunCountOnValueChanged: 10,
    /**
     * An object that configures notifications.
     *
     * Nested properties:
     *
     * - `lifetime`: `number`\
     * Specifies a time period during which a notification is displayed; measured in milliseconds.
     */
    notifications: {
        lifetime: 2000
    },
    /**
     * Specifies how many milliseconds a survey should wait before it automatically switches to the next page. Applies only when [auto-advance](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#goNextPageAutomatic) is enabled.
     *
     * Default value: 300
     */
    autoAdvanceDelay: 300,
    /**
     * Specifies the direction in which to lay out Checkbox and Radiogroup items. This setting affects the resulting UI when items are arranged in [more than one column](https://surveyjs.io/form-library/documentation/api-reference/checkbox-question-model#colCount).
     *
     * Possible values:
     *
     * - `"row"` (default) - Items fill the current row, then move on to the next row.
     * - `"column"` - Items fill the current column, then move on to the next column.
     */
    showItemsInOrder: "default",
    /**
     * A value to save in survey results when respondents select the "None" choice item.
     *
     * Default value: `"none"`
     */
    noneItemValue: "none",
    /**
     * A value to save in survey results when respondents select the "Refuse to answer" choice item.
     *
     * Default value: `"refused"`
     */
    refuseItemValue: "refused",
    /**
     * A value to save in survey results when respondents select the "Don't know" choice item.
     *
     * Default value: `"dontknow"`
     */
    dontKnowItemValue: "dontknow",
    /**
     * An object whose properties specify the order of the special choice items ("None", "Other", "Select All", "Refuse to answer", "Don't know") in select-based questions.
     *
     * Default value: `{ selectAllItem: [-1], noneItem: [1], otherItem: [2], dontKnowItem: [3], otherItem: [4] }`
     *
     * Use this object to reorder special choices. Each property accepts an array of integer numbers. Negative numbers place a special choice item above regular choice items, positive numbers place it below them. For instance, the code below specifies the following order of choices: None, Select All, regular choices, Other.
     *
     * ```js
     * import { settings } from "survey-core";
     *
     * settings.specialChoicesOrder.noneItem = [-2];
     * settings.specialChoicesOrder.selectAllItem = [-1];
     * settings.specialChoicesOrder.otherItem = [1];
     * ```
     *
     * If you want to duplicate a special choice item above and below other choices, add two numbers to the corresponding array:
     *
     * ```js
     * settings.specialChoicesOrder.selectAllItem = [-1, 3] // Displays Select All above and below other choices
     * ```
     */
    specialChoicesOrder: {
        selectAllItem: [-1],
        noneItem: [1],
        refuseItem: [2],
        dontKnowItem: [3],
        otherItem: [4]
    },
    /**
     * One or several characters used to separate choice options in a list.
     *
     * Default value: `", "`
     * @see [settings.itemValueSeparator](https://surveyjs.io/form-library/documentation/api-reference/settings#itemValueSeparator)
     */
    choicesSeparator: ", ",
    /**
     * A list of supported validators by question type.
     */
    supportedValidators: {
        question: ["expression"],
        comment: ["text", "regex"],
        text: ["numeric", "text", "regex", "email"],
        checkbox: ["answercount"],
        imagepicker: ["answercount"],
    },
    /**
     * Specifies a minimum date that users can enter into a [Text](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model) question with [`inputType`](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model#inputType) set to `"date"` or `"datetime-local"`. Set this property to a string with the folllowing format: `"yyyy-mm-dd"`.
     */
    minDate: "",
    /**
     * Specifies a maximum date that users can enter into a [Text](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model) question with [`inputType`](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model#inputType) set to `"date"` or `"datetime-local"`. Set this property to a string with the folllowing format: `"yyyy-mm-dd"`.
     */
    maxDate: "",
    showModal: undefined,
    showDialog: undefined,
    supportCreatorV2: false,
    showDefaultItemsInCreatorV2: true,
    /**
     * An object that specifies icon replacements. Object keys are built-in icon names. To use a custom icon, assign its name to the key of the icon you want to replace:
     *
     * ```js
     * import { settings } from "survey-core";
     *
     * settings.customIcons["icon-redo"] = "custom-redo-icon";
     * ```
     *
     * For more information about icons in SurveyJS, refer to the following help topic: [UI Icons](https://surveyjs.io/form-library/documentation/icons).
     */
    customIcons: {},
    /**
     * Specifies which part of a choice item responds to a drag gesture in Ranking questions.
     *
     * Possible values:
     *
     * - `"entireItem"` (default) - Users can use the entire choice item as a drag handle.
     * - `"icon"` - Users can only use the choice item icon as a drag handle.
     */
    rankingDragHandleArea: "entireItem",
    environment: defaultEnvironment,
    /**
     * Allows you to hide the maximum length indicator in text input questions.
     *
     * If you specify a question's [`maxLength`](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model#maxLength) property or a survey's [`maxTextLength`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#maxTextLength) property, text input questions indicate the number of entered characters and the character limit. Assign `false` to the `settings.showMaxLengthIndicator` property if you want to hide this indicator.
     *
     * Default value: `true`
     */
    showMaxLengthIndicator: true,
    /**
     * Specifies whether to animate survey elements.
     *
     * Default value: `true`
    */
    animationEnabled: true,
    /**
     * An object that specifies heading levels (`<h1>`, `<h2>`, etc.) to use when rendering survey, page, panel, and question titles.
     *
     * Default value: `{ survey: "h3", page: "h4", panel: "h4", question: "h5" }`
     *
     * If you want to modify heading levels for individual titles, handle `SurveyModel`'s [`onGetTitleTagName`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onGetTitleTagName) event.
     */
    titleTags: {
        survey: "h3",
        page: "h4",
        panel: "h4",
        question: "h5",
    },
    questions: {
        inputTypes: [
            "color",
            "date",
            "datetime-local",
            "email",
            "month",
            "number",
            "password",
            "range",
            "tel",
            "text",
            "time",
            "url",
            "week",
        ],
        dataList: [
            "",
            "name",
            "honorific-prefix",
            "given-name",
            "additional-name",
            "family-name",
            "honorific-suffix",
            "nickname",
            "organization-title",
            "username",
            "new-password",
            "current-password",
            "organization",
            "street-address",
            "address-line1",
            "address-line2",
            "address-line3",
            "address-level4",
            "address-level3",
            "address-level2",
            "address-level1",
            "country",
            "country-name",
            "postal-code",
            "cc-name",
            "cc-given-name",
            "cc-additional-name",
            "cc-family-name",
            "cc-number",
            "cc-exp",
            "cc-exp-month",
            "cc-exp-year",
            "cc-csc",
            "cc-type",
            "transaction-currency",
            "transaction-amount",
            "language",
            "bday",
            "bday-day",
            "bday-month",
            "bday-year",
            "sex",
            "url",
            "photo",
            "tel",
            "tel-country-code",
            "tel-national",
            "tel-area-code",
            "tel-local",
            "tel-local-prefix",
            "tel-local-suffix",
            "tel-extension",
            "email",
            "impp",
        ]
    },
    legacyProgressBarView: false,
    /**
     * An object with properties that configure input masks.
     *
     * Nested properties:
     *
     * - `patternPlaceholderChar`: `string`\
     * A symbol used as a placeholder for characters to be entered in [pattern masks](https://surveyjs.io/form-library/documentation/api-reference/inputmaskpattern). Default value: `"_"`.
     *
     * - `patternEscapeChar`: `string`\
     * A symbol used to insert literal representations of special characters in [pattern masks](https://surveyjs.io/form-library/documentation/api-reference/inputmaskpattern). Default value: `"\\"`.
     *
     * - `patternDefinitions`: `<{ [key: string]: RegExp }>`\
     * An object that maps placeholder symbols to regular expressions in [pattern masks](https://surveyjs.io/form-library/documentation/api-reference/inputmaskpattern). Default value: `{ "9": /[0-9]/, "a": /[a-zA-Z]/, "#": /[a-zA-Z0-9]/ }`.
     */
    maskSettings: {
        patternPlaceholderChar: "_",
        patternEscapeChar: "\\",
        patternDefinitions: {
            "9": /[0-9]/,
            "a": /[a-zA-Z]/,
            "#": /[a-zA-Z0-9]/
        }
    },
    /**
     * Specifies whether to store date-time values in the following format: `"YYYY-MM-DDThh:mm:ss.sssZ"`. Applies only to form fields with [`inputType`](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model#inputType) set to `"datetime-local"`.
     *
     * Default value: `false`
     *
     * If you enable this setting, date-time values are converted from local time to UTC when they are saved to the survey's [`data`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#data) object, while the question values remain in local time. Therefore, when you specify default values using a question's [`defaultValue`](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model#defaultValue) property, you need to use local time, but if you specify them using the `data` object, use a UTC date-time value in the following format: `"YYYY-MM-DDThh:mm:ss.sssZ"`.
     *
     * ```js
     * const surveyJson = {
     *   "elements": [{
     *     "name": "datetime",
     *     "type": "text",
     *     "title": "Select a date and time",
     *     "inputType": "datetime-local",
     *     "defaultValue": "2024-07-16T12:15:00" // Local date-time value
     *   }]
     * }
     * ```
     *
     * ```js
     * import { Model } from "survey-core";
     * const surveyJson = { ... }
     * const survey = new Model(surveyJson);
     *
     * survey.data = {
     *   datetime: "2024-07-16T12:15:00.000Z" // UTC date-time value
     * }
     * ```
     */
    storeUtcDates: false,
    /**
     * A function that allows you to define custom parsing rules for numbers represented as string values.
     *
     * The following code shows a template that you can use to implement the `parseNumber` function:
     *
     * ```js
     * import { settings } from "survey-core";
     *
     * settings.parseNumber = (stringValue, numericValue) => {
     *   if (typeof stringValue !== "string" || !stringValue)
     *     return numericValue;
     *   let parsedNumber = numericValue;
     *   // ...
     *   // Parsing the number according to custom parsing rules
     *   // ...
     *   return parsedNumber;
     * };
     * ```
     * @param stringValue A number represented as a string value.
     * @param numericValue A number parsed using a default parsing function. `NaN` if the original string is not a number.
     * @returns A number that results from parsing the string value.
     * @see [settings.serialization](https://surveyjs.io/form-library/documentation/api-reference/settings#serialization)
     */
    parseNumber: function (stringValue, numericValue) { return numericValue; }
};

// CONCATENATED MODULE: ./packages/survey-core/src/survey-error.ts


var survey_error_SurveyError = /** @class */ (function () {
    function SurveyError(text, errorOwner) {
        if (text === void 0) { text = null; }
        if (errorOwner === void 0) { errorOwner = null; }
        this.text = text;
        this.errorOwner = errorOwner;
        this.visible = true;
        this.onUpdateErrorTextCallback = undefined;
    }
    SurveyError.prototype.equals = function (error) {
        if (!error || !error.getErrorType)
            return false;
        if (this.getErrorType() !== error.getErrorType())
            return false;
        return this.text === error.text && this.visible === error.visible;
    };
    Object.defineProperty(SurveyError.prototype, "locText", {
        get: function () {
            if (!this.locTextValue) {
                this.locTextValue = new localizablestring_LocalizableString(this.errorOwner, true);
                this.locTextValue.storeDefaultText = true;
                this.locTextValue.text = this.getText();
            }
            return this.locTextValue;
        },
        enumerable: false,
        configurable: true
    });
    SurveyError.prototype.getText = function () {
        var res = this.text;
        if (!res)
            res = this.getDefaultText();
        if (!!this.errorOwner) {
            res = this.errorOwner.getErrorCustomText(res, this);
        }
        return res;
    };
    SurveyError.prototype.getErrorType = function () {
        return "base";
    };
    SurveyError.prototype.getDefaultText = function () {
        return "";
    };
    SurveyError.prototype.getLocale = function () {
        return !!this.errorOwner ? this.errorOwner.getLocale() : "";
    };
    SurveyError.prototype.getLocalizationString = function (locStrName) {
        return surveyLocalization.getString(locStrName, this.getLocale());
    };
    SurveyError.prototype.updateText = function () {
        if (this.onUpdateErrorTextCallback) {
            this.onUpdateErrorTextCallback(this);
        }
        this.locText.text = this.getText();
    };
    return SurveyError;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/error.ts
var error_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();


var AnswerRequiredError = /** @class */ (function (_super) {
    error_extends(AnswerRequiredError, _super);
    function AnswerRequiredError(text, errorOwner) {
        if (text === void 0) { text = null; }
        if (errorOwner === void 0) { errorOwner = null; }
        var _this = _super.call(this, text, errorOwner) || this;
        _this.text = text;
        return _this;
    }
    AnswerRequiredError.prototype.getErrorType = function () {
        return "required";
    };
    AnswerRequiredError.prototype.getDefaultText = function () {
        return this.getLocalizationString("requiredError");
    };
    return AnswerRequiredError;
}(survey_error_SurveyError));

var OneAnswerRequiredError = /** @class */ (function (_super) {
    error_extends(OneAnswerRequiredError, _super);
    function OneAnswerRequiredError(text, errorOwner) {
        if (text === void 0) { text = null; }
        if (errorOwner === void 0) { errorOwner = null; }
        var _this = _super.call(this, text, errorOwner) || this;
        _this.text = text;
        return _this;
    }
    OneAnswerRequiredError.prototype.getErrorType = function () {
        return "requireoneanswer";
    };
    OneAnswerRequiredError.prototype.getDefaultText = function () {
        return this.getLocalizationString("requiredErrorInPanel");
    };
    return OneAnswerRequiredError;
}(survey_error_SurveyError));

var RequreNumericError = /** @class */ (function (_super) {
    error_extends(RequreNumericError, _super);
    function RequreNumericError(text, errorOwner) {
        if (text === void 0) { text = null; }
        if (errorOwner === void 0) { errorOwner = null; }
        var _this = _super.call(this, text, errorOwner) || this;
        _this.text = text;
        return _this;
    }
    RequreNumericError.prototype.getErrorType = function () {
        return "requirenumeric";
    };
    RequreNumericError.prototype.getDefaultText = function () {
        return this.getLocalizationString("numericError");
    };
    return RequreNumericError;
}(survey_error_SurveyError));

var error_ExceedSizeError = /** @class */ (function (_super) {
    error_extends(ExceedSizeError, _super);
    function ExceedSizeError(maxSize, errorOwner) {
        if (errorOwner === void 0) { errorOwner = null; }
        var _this = _super.call(this, null, errorOwner) || this;
        _this.maxSize = maxSize;
        _this.locText.text = _this.getText();
        return _this;
    }
    ExceedSizeError.prototype.getErrorType = function () {
        return "exceedsize";
    };
    ExceedSizeError.prototype.getDefaultText = function () {
        return surveyLocalization
            .getString("exceedMaxSize")["format"](this.getTextSize());
    };
    ExceedSizeError.prototype.getTextSize = function () {
        var sizes = ["Bytes", "KB", "MB", "GB", "TB"];
        var fixed = [0, 0, 2, 3, 3];
        if (this.maxSize === 0) {
            return "0 Byte";
        }
        var i = Math.floor(Math.log(this.maxSize) / Math.log(1024));
        var value = this.maxSize / Math.pow(1024, i);
        return value.toFixed(fixed[i]) + " " + sizes[i];
    };
    return ExceedSizeError;
}(survey_error_SurveyError));

var WebRequestError = /** @class */ (function (_super) {
    error_extends(WebRequestError, _super);
    function WebRequestError(status, response, errorOwner) {
        if (errorOwner === void 0) { errorOwner = null; }
        var _this = _super.call(this, null, errorOwner) || this;
        _this.status = status;
        _this.response = response;
        return _this;
    }
    WebRequestError.prototype.getErrorType = function () {
        return "webrequest";
    };
    WebRequestError.prototype.getDefaultText = function () {
        var str = this.getLocalizationString("urlRequestError");
        return !!str ? str["format"](this.status, this.response) : "";
    };
    return WebRequestError;
}(survey_error_SurveyError));

var WebRequestEmptyError = /** @class */ (function (_super) {
    error_extends(WebRequestEmptyError, _super);
    function WebRequestEmptyError(text, errorOwner) {
        if (errorOwner === void 0) { errorOwner = null; }
        var _this = _super.call(this, text, errorOwner) || this;
        _this.text = text;
        return _this;
    }
    WebRequestEmptyError.prototype.getErrorType = function () {
        return "webrequestempty";
    };
    WebRequestEmptyError.prototype.getDefaultText = function () {
        return this.getLocalizationString("urlGetChoicesError");
    };
    return WebRequestEmptyError;
}(survey_error_SurveyError));

var OtherEmptyError = /** @class */ (function (_super) {
    error_extends(OtherEmptyError, _super);
    function OtherEmptyError(text, errorOwner) {
        if (errorOwner === void 0) { errorOwner = null; }
        var _this = _super.call(this, text, errorOwner) || this;
        _this.text = text;
        return _this;
    }
    OtherEmptyError.prototype.getErrorType = function () {
        return "otherempty";
    };
    OtherEmptyError.prototype.getDefaultText = function () {
        return this.getLocalizationString("otherRequiredError");
    };
    return OtherEmptyError;
}(survey_error_SurveyError));

var UploadingFileError = /** @class */ (function (_super) {
    error_extends(UploadingFileError, _super);
    function UploadingFileError(text, errorOwner) {
        if (errorOwner === void 0) { errorOwner = null; }
        var _this = _super.call(this, text, errorOwner) || this;
        _this.text = text;
        return _this;
    }
    UploadingFileError.prototype.getErrorType = function () {
        return "uploadingfile";
    };
    UploadingFileError.prototype.getDefaultText = function () {
        return this.getLocalizationString("uploadingFile");
    };
    return UploadingFileError;
}(survey_error_SurveyError));

var RequiredInAllRowsError = /** @class */ (function (_super) {
    error_extends(RequiredInAllRowsError, _super);
    function RequiredInAllRowsError(text, errorOwner) {
        if (errorOwner === void 0) { errorOwner = null; }
        var _this = _super.call(this, text, errorOwner) || this;
        _this.text = text;
        return _this;
    }
    RequiredInAllRowsError.prototype.getErrorType = function () {
        return "requiredinallrowserror";
    };
    RequiredInAllRowsError.prototype.getDefaultText = function () {
        return this.getLocalizationString("requiredInAllRowsError");
    };
    return RequiredInAllRowsError;
}(survey_error_SurveyError));

var EachRowUniqueError = /** @class */ (function (_super) {
    error_extends(EachRowUniqueError, _super);
    function EachRowUniqueError(text, errorOwner) {
        if (errorOwner === void 0) { errorOwner = null; }
        var _this = _super.call(this, text, errorOwner) || this;
        _this.text = text;
        return _this;
    }
    EachRowUniqueError.prototype.getErrorType = function () {
        return "eachrowuniqueeerror";
    };
    EachRowUniqueError.prototype.getDefaultText = function () {
        return this.getLocalizationString("eachRowUniqueError");
    };
    return EachRowUniqueError;
}(survey_error_SurveyError));

var error_MinRowCountError = /** @class */ (function (_super) {
    error_extends(MinRowCountError, _super);
    function MinRowCountError(minRowCount, errorOwner) {
        if (errorOwner === void 0) { errorOwner = null; }
        var _this = _super.call(this, null, errorOwner) || this;
        _this.minRowCount = minRowCount;
        return _this;
    }
    MinRowCountError.prototype.getErrorType = function () {
        return "minrowcounterror";
    };
    MinRowCountError.prototype.getDefaultText = function () {
        return surveyLocalization
            .getString("minRowCountError")["format"](this.minRowCount);
    };
    return MinRowCountError;
}(survey_error_SurveyError));

var KeyDuplicationError = /** @class */ (function (_super) {
    error_extends(KeyDuplicationError, _super);
    function KeyDuplicationError(text, errorOwner) {
        if (errorOwner === void 0) { errorOwner = null; }
        var _this = _super.call(this, text, errorOwner) || this;
        _this.text = text;
        return _this;
    }
    KeyDuplicationError.prototype.getErrorType = function () {
        return "keyduplicationerror";
    };
    KeyDuplicationError.prototype.getDefaultText = function () {
        return this.getLocalizationString("keyDuplicationError");
    };
    return KeyDuplicationError;
}(survey_error_SurveyError));

var CustomError = /** @class */ (function (_super) {
    error_extends(CustomError, _super);
    function CustomError(text, errorOwner) {
        if (errorOwner === void 0) { errorOwner = null; }
        var _this = _super.call(this, text, errorOwner) || this;
        _this.text = text;
        return _this;
    }
    CustomError.prototype.getErrorType = function () {
        return "custom";
    };
    return CustomError;
}(survey_error_SurveyError));


// CONCATENATED MODULE: ./packages/survey-core/src/validator.ts
var validator_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();





var ValidatorResult = /** @class */ (function () {
    function ValidatorResult(value, error) {
        if (error === void 0) { error = null; }
        this.value = value;
        this.error = error;
    }
    return ValidatorResult;
}());

/**
 * Base SurveyJS validator class.
 */
var validator_SurveyValidator = /** @class */ (function (_super) {
    validator_extends(SurveyValidator, _super);
    function SurveyValidator() {
        var _this = _super.call(this) || this;
        _this.createLocalizableString("text", _this, true);
        return _this;
    }
    SurveyValidator.prototype.getSurvey = function (live) {
        if (live === void 0) { live = false; }
        return !!this.errorOwner && !!this.errorOwner["getSurvey"]
            ? this.errorOwner.getSurvey()
            : null;
    };
    Object.defineProperty(SurveyValidator.prototype, "text", {
        get: function () {
            return this.getLocalizableStringText("text");
        },
        set: function (value) {
            this.setLocalizableStringText("text", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyValidator.prototype, "isValidateAllValues", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyValidator.prototype, "locText", {
        get: function () {
            return this.getLocalizableString("text");
        },
        enumerable: false,
        configurable: true
    });
    SurveyValidator.prototype.getErrorText = function (name) {
        if (this.text)
            return this.text;
        return this.getDefaultErrorText(name);
    };
    SurveyValidator.prototype.getDefaultErrorText = function (name) {
        return "";
    };
    SurveyValidator.prototype.validate = function (value, name, values, properties) {
        if (name === void 0) { name = null; }
        if (values === void 0) { values = null; }
        if (properties === void 0) { properties = null; }
        return null;
    };
    Object.defineProperty(SurveyValidator.prototype, "isRunning", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyValidator.prototype, "isAsync", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    SurveyValidator.prototype.getLocale = function () {
        return !!this.errorOwner ? this.errorOwner.getLocale() : "";
    };
    SurveyValidator.prototype.getMarkdownHtml = function (text, name) {
        return !!this.errorOwner
            ? this.errorOwner.getMarkdownHtml(text, name)
            : undefined;
    };
    SurveyValidator.prototype.getRenderer = function (name) {
        return !!this.errorOwner ? this.errorOwner.getRenderer(name) : null;
    };
    SurveyValidator.prototype.getRendererContext = function (locStr) {
        return !!this.errorOwner ? this.errorOwner.getRendererContext(locStr) : locStr;
    };
    SurveyValidator.prototype.getProcessedText = function (text) {
        return !!this.errorOwner ? this.errorOwner.getProcessedText(text) : text;
    };
    SurveyValidator.prototype.createCustomError = function (name) {
        var _this = this;
        var err = new CustomError(this.getErrorText(name), this.errorOwner);
        err.onUpdateErrorTextCallback = (function (err) { return err.text = _this.getErrorText(name); });
        return err;
    };
    SurveyValidator.prototype.toString = function () {
        var res = this.getType().replace("validator", "");
        if (!!this.text) {
            res += ", " + this.text;
        }
        return res;
    };
    return SurveyValidator;
}(base_Base));

var ValidatorRunner = /** @class */ (function () {
    function ValidatorRunner() {
    }
    ValidatorRunner.prototype.run = function (owner) {
        var _this = this;
        var res = [];
        var values = null;
        var properties = null;
        this.prepareAsyncValidators();
        var asyncResults = [];
        var validators = owner.getValidators();
        for (var i = 0; i < validators.length; i++) {
            var validator = validators[i];
            if (!values && validator.isValidateAllValues) {
                values = owner.getDataFilteredValues();
                properties = owner.getDataFilteredProperties();
            }
            if (validator.isAsync) {
                this.asyncValidators.push(validator);
                validator.onAsyncCompleted = function (result) {
                    if (!!result && !!result.error)
                        asyncResults.push(result.error);
                    if (!_this.onAsyncCompleted)
                        return;
                    for (var i = 0; i < _this.asyncValidators.length; i++) {
                        if (_this.asyncValidators[i].isRunning)
                            return;
                    }
                    _this.onAsyncCompleted(asyncResults);
                };
            }
        }
        validators = owner.getValidators();
        for (var i = 0; i < validators.length; i++) {
            var validator = validators[i];
            var validatorResult = validator.validate(owner.validatedValue, owner.getValidatorTitle(), values, properties);
            if (!!validatorResult && !!validatorResult.error) {
                res.push(validatorResult.error);
            }
        }
        if (this.asyncValidators.length == 0 && !!this.onAsyncCompleted)
            this.onAsyncCompleted([]);
        return res;
    };
    ValidatorRunner.prototype.prepareAsyncValidators = function () {
        if (!!this.asyncValidators) {
            for (var i = 0; i < this.asyncValidators.length; i++) {
                this.asyncValidators[i].onAsyncCompleted = null;
            }
        }
        this.asyncValidators = [];
    };
    return ValidatorRunner;
}());

/**
 * Validate numeric values.
 */
var validator_NumericValidator = /** @class */ (function (_super) {
    validator_extends(NumericValidator, _super);
    function NumericValidator(minValue, maxValue) {
        if (minValue === void 0) { minValue = null; }
        if (maxValue === void 0) { maxValue = null; }
        var _this = _super.call(this) || this;
        _this.minValue = minValue;
        _this.maxValue = maxValue;
        return _this;
    }
    NumericValidator.prototype.getType = function () {
        return "numericvalidator";
    };
    NumericValidator.prototype.validate = function (value, name, values, properties) {
        if (name === void 0) { name = null; }
        if (values === void 0) { values = null; }
        if (properties === void 0) { properties = null; }
        if (this.isValueEmpty(value))
            return null;
        if (!helpers_Helpers.isNumber(value)) {
            return new ValidatorResult(null, new RequreNumericError(this.text, this.errorOwner));
        }
        var result = new ValidatorResult(helpers_Helpers.getNumber(value));
        if (this.minValue !== null && this.minValue > result.value) {
            result.error = this.createCustomError(name);
            return result;
        }
        if (this.maxValue !== null && this.maxValue < result.value) {
            result.error = this.createCustomError(name);
            return result;
        }
        return typeof value === "number" ? null : result;
    };
    NumericValidator.prototype.getDefaultErrorText = function (name) {
        var vName = name ? name : this.getLocalizationString("value");
        if (this.minValue !== null && this.maxValue !== null) {
            return this.getLocalizationFormatString("numericMinMax", vName, this.minValue, this.maxValue);
        }
        else {
            if (this.minValue !== null) {
                return this.getLocalizationFormatString("numericMin", vName, this.minValue);
            }
            return this.getLocalizationFormatString("numericMax", vName, this.maxValue);
        }
    };
    Object.defineProperty(NumericValidator.prototype, "minValue", {
        /**
         * The minValue property.
         */
        get: function () {
            return this.getPropertyValue("minValue");
        },
        set: function (val) {
            this.setPropertyValue("minValue", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(NumericValidator.prototype, "maxValue", {
        /**
         * The maxValue property.
         */
        get: function () {
            return this.getPropertyValue("maxValue");
        },
        set: function (val) {
            this.setPropertyValue("maxValue", val);
        },
        enumerable: false,
        configurable: true
    });
    return NumericValidator;
}(validator_SurveyValidator));

/**
 * Validate text values.
 */
var TextValidator = /** @class */ (function (_super) {
    validator_extends(TextValidator, _super);
    function TextValidator() {
        return _super.call(this) || this;
    }
    TextValidator.prototype.getType = function () {
        return "textvalidator";
    };
    TextValidator.prototype.validate = function (value, name, values, properties) {
        if (name === void 0) { name = null; }
        if (values === void 0) { values = null; }
        if (properties === void 0) { properties = null; }
        if (this.isValueEmpty(value))
            return null;
        if (!this.allowDigits) {
            var reg = /^[A-Za-z\s\.]*$/;
            if (!reg.test(value)) {
                return new ValidatorResult(null, this.createCustomError(name));
            }
        }
        if (this.minLength > 0 && value.length < this.minLength) {
            return new ValidatorResult(null, this.createCustomError(name));
        }
        if (this.maxLength > 0 && value.length > this.maxLength) {
            return new ValidatorResult(null, this.createCustomError(name));
        }
        return null;
    };
    TextValidator.prototype.getDefaultErrorText = function (name) {
        if (this.minLength > 0 && this.maxLength > 0)
            return this.getLocalizationFormatString("textMinMaxLength", this.minLength, this.maxLength);
        if (this.minLength > 0)
            return this.getLocalizationFormatString("textMinLength", this.minLength);
        return this.getLocalizationFormatString("textMaxLength", this.maxLength);
    };
    Object.defineProperty(TextValidator.prototype, "minLength", {
        /**
         * The minLength property.
         */
        get: function () {
            return this.getPropertyValue("minLength");
        },
        set: function (val) {
            this.setPropertyValue("minLength", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(TextValidator.prototype, "maxLength", {
        /**
         * The maxLength property.
         */
        get: function () {
            return this.getPropertyValue("maxLength");
        },
        set: function (val) {
            this.setPropertyValue("maxLength", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(TextValidator.prototype, "allowDigits", {
        /**
         * The allowDigits property.
         */
        get: function () {
            return this.getPropertyValue("allowDigits");
        },
        set: function (val) {
            this.setPropertyValue("allowDigits", val);
        },
        enumerable: false,
        configurable: true
    });
    return TextValidator;
}(validator_SurveyValidator));

/**
 * Validates the number of answers.
 */
var AnswerCountValidator = /** @class */ (function (_super) {
    validator_extends(AnswerCountValidator, _super);
    function AnswerCountValidator(minCount, maxCount) {
        if (minCount === void 0) { minCount = null; }
        if (maxCount === void 0) { maxCount = null; }
        var _this = _super.call(this) || this;
        _this.minCount = minCount;
        _this.maxCount = maxCount;
        return _this;
    }
    AnswerCountValidator.prototype.getType = function () {
        return "answercountvalidator";
    };
    AnswerCountValidator.prototype.validate = function (value, name, values, properties) {
        if (name === void 0) { name = null; }
        if (values === void 0) { values = null; }
        if (properties === void 0) { properties = null; }
        if (value == null || value.constructor != Array)
            return null;
        var count = value.length;
        if (count == 0)
            return null;
        if (this.minCount && count < this.minCount) {
            return new ValidatorResult(null, this.createCustomError(this.getLocalizationFormatString("minSelectError", this.minCount)));
        }
        if (this.maxCount && count > this.maxCount) {
            return new ValidatorResult(null, this.createCustomError(this.getLocalizationFormatString("maxSelectError", this.maxCount)));
        }
        return null;
    };
    AnswerCountValidator.prototype.getDefaultErrorText = function (name) {
        return name;
    };
    Object.defineProperty(AnswerCountValidator.prototype, "minCount", {
        /**
         * The minCount property.
         */
        get: function () {
            return this.getPropertyValue("minCount");
        },
        set: function (val) {
            this.setPropertyValue("minCount", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnswerCountValidator.prototype, "maxCount", {
        /**
         * The maxCount property.
         */
        get: function () {
            return this.getPropertyValue("maxCount");
        },
        set: function (val) {
            this.setPropertyValue("maxCount", val);
        },
        enumerable: false,
        configurable: true
    });
    return AnswerCountValidator;
}(validator_SurveyValidator));

/**
 * Use it to validate the text by regular expressions.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/javascript-form-validation/ (linkStyle))
 */
var RegexValidator = /** @class */ (function (_super) {
    validator_extends(RegexValidator, _super);
    function RegexValidator(regex) {
        if (regex === void 0) { regex = null; }
        var _this = _super.call(this) || this;
        _this.regex = regex;
        return _this;
    }
    RegexValidator.prototype.getType = function () {
        return "regexvalidator";
    };
    RegexValidator.prototype.validate = function (value, name, values, properties) {
        if (name === void 0) { name = null; }
        if (values === void 0) { values = null; }
        if (properties === void 0) { properties = null; }
        if (!this.regex || this.isValueEmpty(value))
            return null;
        var re = this.createRegExp();
        if (Array.isArray(value)) {
            for (var i = 0; i < value.length; i++) {
                var res = this.hasError(re, value[i], name);
                if (res)
                    return res;
            }
        }
        return this.hasError(re, value, name);
    };
    RegexValidator.prototype.hasError = function (re, value, name) {
        if (re.test(value))
            return null;
        return new ValidatorResult(value, this.createCustomError(name));
    };
    Object.defineProperty(RegexValidator.prototype, "regex", {
        /**
         * The regex property.
         */
        get: function () {
            return this.getPropertyValue("regex");
        },
        set: function (val) {
            this.setPropertyValue("regex", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(RegexValidator.prototype, "insensitive", {
        get: function () {
            return this.getPropertyValue("insensitive");
        },
        set: function (val) {
            this.setPropertyValue("insensitive", val);
        },
        enumerable: false,
        configurable: true
    });
    RegexValidator.prototype.createRegExp = function () {
        return new RegExp(this.regex, this.insensitive ? "i" : "");
    };
    return RegexValidator;
}(validator_SurveyValidator));

/**
 * Validate e-mail address in the text input
 */
var EmailValidator = /** @class */ (function (_super) {
    validator_extends(EmailValidator, _super);
    function EmailValidator() {
        var _this = _super.call(this) || this;
        _this.re = /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()=[\]\.,;:\s@\"]+\.)+[^<>()=[\]\.,;:\s@\"]{2,})$/i;
        return _this;
    }
    EmailValidator.prototype.getType = function () {
        return "emailvalidator";
    };
    EmailValidator.prototype.validate = function (value, name, values, properties) {
        if (name === void 0) { name = null; }
        if (values === void 0) { values = null; }
        if (properties === void 0) { properties = null; }
        if (!value)
            return null;
        if (this.re.test(value))
            return null;
        return new ValidatorResult(value, this.createCustomError(name));
    };
    EmailValidator.prototype.getDefaultErrorText = function (name) {
        return this.getLocalizationString("invalidEmail");
    };
    return EmailValidator;
}(validator_SurveyValidator));

/**
 * Show error if expression returns false
 */
var validator_ExpressionValidator = /** @class */ (function (_super) {
    validator_extends(ExpressionValidator, _super);
    function ExpressionValidator(expression) {
        if (expression === void 0) { expression = null; }
        var _this = _super.call(this) || this;
        _this.conditionRunner = null;
        _this.isRunningValue = false;
        _this.expression = expression;
        return _this;
    }
    ExpressionValidator.prototype.getType = function () {
        return "expressionvalidator";
    };
    Object.defineProperty(ExpressionValidator.prototype, "isValidateAllValues", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ExpressionValidator.prototype, "isAsync", {
        get: function () {
            if (!this.ensureConditionRunner())
                return false;
            return this.conditionRunner.isAsync;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ExpressionValidator.prototype, "isRunning", {
        get: function () {
            return this.isRunningValue;
        },
        enumerable: false,
        configurable: true
    });
    ExpressionValidator.prototype.validate = function (value, name, values, properties) {
        var _this = this;
        if (name === void 0) { name = null; }
        if (values === void 0) { values = null; }
        if (properties === void 0) { properties = null; }
        if (!this.ensureConditionRunner())
            return null;
        this.conditionRunner.onRunComplete = function (res) {
            _this.isRunningValue = false;
            if (!!_this.onAsyncCompleted) {
                _this.onAsyncCompleted(_this.generateError(res, value, name));
            }
        };
        this.isRunningValue = true;
        var res = this.conditionRunner.run(values, properties);
        if (this.conditionRunner.isAsync)
            return null;
        this.isRunningValue = false;
        return this.generateError(res, value, name);
    };
    ExpressionValidator.prototype.generateError = function (res, value, name) {
        if (!res) {
            return new ValidatorResult(value, this.createCustomError(name));
        }
        return null;
    };
    ExpressionValidator.prototype.getDefaultErrorText = function (name) {
        return this.getLocalizationFormatString("invalidExpression", this.expression);
    };
    ExpressionValidator.prototype.ensureConditionRunner = function () {
        if (!!this.conditionRunner) {
            this.conditionRunner.expression = this.expression;
            return true;
        }
        if (!this.expression)
            return false;
        this.conditionRunner = new ConditionRunner(this.expression);
        return true;
    };
    Object.defineProperty(ExpressionValidator.prototype, "expression", {
        /**
         * The expression property.
         */
        get: function () {
            return this.getPropertyValue("expression");
        },
        set: function (val) {
            this.setPropertyValue("expression", val);
        },
        enumerable: false,
        configurable: true
    });
    return ExpressionValidator;
}(validator_SurveyValidator));

Serializer.addClass("surveyvalidator", [
    { name: "text", serializationProperty: "locText" },
]);
Serializer.addClass("numericvalidator", ["minValue:number", "maxValue:number"], function () {
    return new validator_NumericValidator();
}, "surveyvalidator");
Serializer.addClass("textvalidator", [{ name: "minLength:number", default: 0 },
    { name: "maxLength:number", default: 0 },
    { name: "allowDigits:boolean", default: true }], function () {
    return new TextValidator();
}, "surveyvalidator");
Serializer.addClass("answercountvalidator", ["minCount:number", "maxCount:number"], function () {
    return new AnswerCountValidator();
}, "surveyvalidator");
Serializer.addClass("regexvalidator", ["regex", { name: "insensitive:boolean", visible: false }], function () {
    return new RegexValidator();
}, "surveyvalidator");
Serializer.addClass("emailvalidator", [], function () {
    return new EmailValidator();
}, "surveyvalidator");
Serializer.addClass("expressionvalidator", ["expression:condition"], function () {
    return new validator_ExpressionValidator();
}, "surveyvalidator");

// CONCATENATED MODULE: ./packages/survey-core/src/questionCustomWidgets.ts

var QuestionCustomWidget = /** @class */ (function () {
    function QuestionCustomWidget(name, widgetJson) {
        this.name = name;
        this.widgetJson = widgetJson;
        this.htmlTemplate = widgetJson.htmlTemplate ? widgetJson.htmlTemplate : "";
    }
    QuestionCustomWidget.prototype.afterRender = function (question, el) {
        var _this = this;
        if (!this.widgetJson.afterRender)
            return;
        question.localeChangedCallback = function () {
            if (_this.widgetJson.willUnmount) {
                _this.widgetJson.willUnmount(question, el);
            }
            _this.widgetJson.afterRender(question, el);
        };
        this.widgetJson.afterRender(question, el);
    };
    QuestionCustomWidget.prototype.willUnmount = function (question, el) {
        if (this.widgetJson.willUnmount)
            this.widgetJson.willUnmount(question, el);
    };
    QuestionCustomWidget.prototype.getDisplayValue = function (question, value) {
        if (value === void 0) { value = undefined; }
        if (this.widgetJson.getDisplayValue)
            return this.widgetJson.getDisplayValue(question, value);
        return null;
    };
    QuestionCustomWidget.prototype.validate = function (question) {
        if (this.widgetJson.validate)
            return this.widgetJson.validate(question);
        return undefined;
    };
    QuestionCustomWidget.prototype.isFit = function (question) {
        if (this.isLibraryLoaded() && this.widgetJson.isFit)
            return this.widgetJson.isFit(question);
        return false;
    };
    Object.defineProperty(QuestionCustomWidget.prototype, "canShowInToolbox", {
        get: function () {
            if (this.widgetJson.showInToolbox === false)
                return false;
            if (questionCustomWidgets_CustomWidgetCollection.Instance.getActivatedBy(this.name) != "customtype")
                return false;
            return !this.widgetJson.widgetIsLoaded || this.widgetJson.widgetIsLoaded();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCustomWidget.prototype, "showInToolbox", {
        get: function () {
            return this.widgetJson.showInToolbox !== false;
        },
        set: function (val) {
            this.widgetJson.showInToolbox = val;
        },
        enumerable: false,
        configurable: true
    });
    QuestionCustomWidget.prototype.init = function () {
        if (this.widgetJson.init) {
            this.widgetJson.init();
        }
    };
    QuestionCustomWidget.prototype.activatedByChanged = function (activatedBy) {
        if (this.isLibraryLoaded() && this.widgetJson.activatedByChanged) {
            this.widgetJson.activatedByChanged(activatedBy);
        }
    };
    QuestionCustomWidget.prototype.isLibraryLoaded = function () {
        if (this.widgetJson.widgetIsLoaded)
            return this.widgetJson.widgetIsLoaded() == true;
        return true;
    };
    Object.defineProperty(QuestionCustomWidget.prototype, "isDefaultRender", {
        get: function () {
            return this.widgetJson.isDefaultRender;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCustomWidget.prototype, "pdfQuestionType", {
        get: function () {
            return this.widgetJson.pdfQuestionType;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCustomWidget.prototype, "pdfRender", {
        get: function () {
            return this.widgetJson.pdfRender;
        },
        enumerable: false,
        configurable: true
    });
    return QuestionCustomWidget;
}());

var questionCustomWidgets_CustomWidgetCollection = /** @class */ (function () {
    function CustomWidgetCollection() {
        this.widgetsValues = [];
        this.widgetsActivatedBy = {};
        this.onCustomWidgetAdded = new Event();
    }
    Object.defineProperty(CustomWidgetCollection.prototype, "widgets", {
        get: function () {
            return this.widgetsValues;
        },
        enumerable: false,
        configurable: true
    });
    CustomWidgetCollection.prototype.add = function (widgetJson, activatedBy) {
        if (activatedBy === void 0) { activatedBy = "property"; }
        this.addCustomWidget(widgetJson, activatedBy);
    };
    CustomWidgetCollection.prototype.addCustomWidget = function (widgetJson, activatedBy) {
        if (activatedBy === void 0) { activatedBy = "property"; }
        var name = widgetJson.name;
        if (!name) {
            name = "widget_" + this.widgets.length + 1;
        }
        var customWidget = new QuestionCustomWidget(name, widgetJson);
        this.widgetsValues.push(customWidget);
        customWidget.init();
        this.widgetsActivatedBy[name] = activatedBy;
        customWidget.activatedByChanged(activatedBy);
        this.onCustomWidgetAdded.fire(customWidget, null);
        return customWidget;
    };
    /**
     * Returns the way the custom wiget is activated. It can be activated by a property ("property"), question type ("type") or by new/custom question type ("customtype").
     * @param widgetName the custom widget name
     * @see setActivatedBy
     */
    CustomWidgetCollection.prototype.getActivatedBy = function (widgetName) {
        var res = this.widgetsActivatedBy[widgetName];
        return res ? res : "property";
    };
    /**
     * Sets the way the custom wiget is activated. The activation types are: property ("property"), question type ("type") or new/custom question type ("customtype"). A custom wiget may support all or only some of this activation types.
     * @param widgetName
     * @param activatedBy there are three possible variants: "property", "type" and "customtype"
     */
    CustomWidgetCollection.prototype.setActivatedBy = function (widgetName, activatedBy) {
        if (!widgetName || !activatedBy)
            return;
        var widget = this.getCustomWidgetByName(widgetName);
        if (!widget)
            return;
        this.widgetsActivatedBy[widgetName] = activatedBy;
        widget.activatedByChanged(activatedBy);
    };
    CustomWidgetCollection.prototype.clear = function () {
        this.widgetsValues = [];
    };
    CustomWidgetCollection.prototype.getCustomWidgetByName = function (name) {
        for (var i = 0; i < this.widgets.length; i++) {
            if (this.widgets[i].name == name)
                return this.widgets[i];
        }
        return null;
    };
    CustomWidgetCollection.prototype.getCustomWidget = function (question) {
        for (var i = 0; i < this.widgetsValues.length; i++) {
            if (this.widgetsValues[i].isFit(question))
                return this.widgetsValues[i];
        }
        return null;
    };
    CustomWidgetCollection.Instance = new CustomWidgetCollection();
    return CustomWidgetCollection;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/rendererFactory.ts
var RendererFactory = /** @class */ (function () {
    function RendererFactory() {
        this.renderersHash = {};
        this.defaultHash = {};
    }
    RendererFactory.prototype.unregisterRenderer = function (questionType, rendererAs) {
        delete this.renderersHash[questionType][rendererAs];
        if (this.defaultHash[questionType] === rendererAs) {
            delete this.defaultHash[questionType];
        }
    };
    RendererFactory.prototype.registerRenderer = function (questionType, renderAs, renderer, useAsDefault) {
        if (useAsDefault === void 0) { useAsDefault = false; }
        if (!this.renderersHash[questionType]) {
            this.renderersHash[questionType] = {};
        }
        this.renderersHash[questionType][renderAs] = renderer;
        if (useAsDefault) {
            this.defaultHash[questionType] = renderAs;
        }
    };
    RendererFactory.prototype.getRenderer = function (questionType, renderAs) {
        var qHash = this.renderersHash[questionType];
        if (!!qHash) {
            if (!!renderAs && qHash[renderAs])
                return qHash[renderAs];
            var dVal = this.defaultHash[questionType];
            if (!!dVal && qHash[dVal])
                return qHash[dVal];
        }
        return "default";
    };
    RendererFactory.prototype.getRendererByQuestion = function (question) {
        return this.getRenderer(question.getType(), question.renderAs);
    };
    RendererFactory.prototype.clear = function () {
        this.renderersHash = {};
    };
    RendererFactory.Instance = new RendererFactory();
    return RendererFactory;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/question.ts
var question_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var question_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};















var TriggerExpressionInfo = /** @class */ (function () {
    function TriggerExpressionInfo(name, canRun, doComplete) {
        this.name = name;
        this.canRun = canRun;
        this.doComplete = doComplete;
        this.runSecondCheck = function (keys) { return false; };
    }
    return TriggerExpressionInfo;
}());
/**
 * A base class for all questions.
 */
var question_Question = /** @class */ (function (_super) {
    question_extends(Question, _super);
    function Question(name) {
        var _this = _super.call(this, name) || this;
        _this.customWidgetData = { isNeedRender: true };
        _this.hasCssErrorCallback = function () { return false; };
        _this.isReadyValue = true;
        _this.dependedQuestions = [];
        /**
         * An event that is raised when the question's ready state has changed (expressions are evaluated, choices are loaded from a web resource specified by the `choicesByUrl` property, etc.).
         *
         * Parameters:
         *
         * - `sender`: `SurveyModel`\
         * A survey instance that contains the question whose ready state has changed.
         * - `options.isReady`: `boolean`\
         * Indicates whether the question is ready.
         * - `options.oldIsReady`: `boolean`\
         * Indicates the previous ready state.
         */
        _this.onReadyChanged = _this.addEvent();
        _this.triggersInfo = [];
        _this.isRunningValidatorsValue = false;
        _this.isValueChangedInSurvey = false;
        _this.allowNotifyValueChanged = true;
        _this.id = Question.getQuestionId();
        _this.onCreating();
        _this.createNewArray("validators", function (validator) {
            validator.errorOwner = _this;
        });
        _this.addExpressionProperty("visibleIf", function (obj, res) { _this.visible = res === true; }, function (obj) { return !_this.areInvisibleElementsShowing; });
        _this.addExpressionProperty("enableIf", function (obj, res) { _this.readOnly = res === false; });
        _this.addExpressionProperty("requiredIf", function (obj, res) { _this.isRequired = res === true; });
        _this.createLocalizableString("commentText", _this, true, "otherItemText");
        _this.createLocalizableString("requiredErrorText", _this);
        _this.addTriggerInfo("resetValueIf", function () { return !_this.isEmpty(); }, function () {
            _this.clearValue();
            _this.updateValueWithDefaults();
        });
        var setValueIfInfo = _this.addTriggerInfo("setValueIf", function () { return true; }, function () { return _this.runSetValueExpression(); });
        setValueIfInfo.runSecondCheck = function (keys) { return _this.checkExpressionIf(keys); };
        _this.registerPropertyChangedHandlers(["width"], function () {
            _this.updateQuestionCss();
            if (!!_this.parent) {
                _this.parent.elementWidthChanged(_this);
            }
        });
        _this.registerPropertyChangedHandlers(["isRequired"], function () {
            if (!_this.isRequired && _this.errors.length > 0) {
                _this.validate();
            }
            _this.locTitle.strChanged();
            _this.clearCssClasses();
        });
        _this.registerPropertyChangedHandlers(["indent", "rightIndent"], function () {
            _this.onIndentChanged();
        });
        _this.registerPropertyChangedHandlers(["showCommentArea", "showOtherItem"], function () {
            _this.initCommentFromSurvey();
        });
        _this.registerFunctionOnPropertiesValueChanged(["no", "readOnly", "hasVisibleErrors", "containsErrors"], function () {
            _this.updateQuestionCss();
        });
        _this.registerPropertyChangedHandlers(["isMobile"], function () { _this.onMobileChanged(); });
        _this.registerPropertyChangedHandlers(["colSpan"], function () { var _a; (_a = _this.parent) === null || _a === void 0 ? void 0 : _a.updateColumns(); });
        return _this;
    }
    Question.getQuestionId = function () {
        return "sq_" + Question.questionCounter++;
    };
    Question.prototype.isReadOnlyRenderDiv = function () {
        return this.isReadOnly && settings.readOnly.commentRenderMode === "div";
    };
    Question.prototype.allowMobileInDesignMode = function () {
        return false;
    };
    Question.prototype.updateIsMobileFromSurvey = function () {
        this.setIsMobile(this.survey._isMobile);
    };
    Question.prototype.setIsMobile = function (val) {
        this.isMobile = val && (this.allowMobileInDesignMode() || !this.isDesignMode);
    };
    Question.prototype.themeChanged = function (theme) { };
    Question.prototype.getDefaultTitle = function () { return this.name; };
    Question.prototype.createLocTitleProperty = function () {
        var _this = this;
        var locTitleValue = _super.prototype.createLocTitleProperty.call(this);
        locTitleValue.storeDefaultText = true;
        locTitleValue.onGetTextCallback = function (text) {
            if (!text) {
                text = _this.getDefaultTitle();
            }
            if (!_this.survey)
                return text;
            return _this.survey.getUpdatedQuestionTitle(_this, text);
        };
        this.locProcessedTitle = new localizablestring_LocalizableString(this, true);
        this.locProcessedTitle.sharedData = locTitleValue;
        return locTitleValue;
    };
    Question.prototype.getSurvey = function (live) {
        if (live === void 0) { live = false; }
        if (live) {
            return !!this.parent ? this.parent.getSurvey(live) : null;
        }
        if (!!this.onGetSurvey)
            return this.onGetSurvey();
        return _super.prototype.getSurvey.call(this);
    };
    Question.prototype.getValueName = function () {
        if (!!this.valueName)
            return this.valueName.toString();
        return this.name;
    };
    Object.defineProperty(Question.prototype, "valueName", {
        /**
         * Specifies an object property that should store the question value.
         *
         * Refer to the [Merge Question Values](https://surveyjs.io/form-library/documentation/design-survey-merge-question-values) help topic for more information.
         */
        get: function () {
            return this.getPropertyValue("valueName", "");
        },
        set: function (val) {
            var oldValueName = this.getValueName();
            this.setPropertyValue("valueName", val);
            this.onValueNameChanged(oldValueName);
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.onValueNameChanged = function (oldValue) {
        if (!this.survey)
            return;
        this.survey.questionRenamed(this, this.name, !!oldValue ? oldValue : this.name);
        this.initDataFromSurvey();
    };
    Question.prototype.onNameChanged = function (oldValue) {
        this.locTitle.strChanged();
        if (!this.survey)
            return;
        this.survey.questionRenamed(this, oldValue, this.valueName ? this.valueName : oldValue);
    };
    Object.defineProperty(Question.prototype, "isReady", {
        get: function () {
            return this.isReadyValue;
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.onAsyncRunningChanged = function () {
        this.updateIsReady();
    };
    Question.prototype.updateIsReady = function () {
        var res = this.getIsQuestionReady();
        if (res) {
            var questions = this.getIsReadyDependsOn();
            for (var i = 0; i < questions.length; i++) {
                if (!questions[i].getIsQuestionReady()) {
                    res = false;
                    break;
                }
            }
        }
        this.setIsReady(res);
    };
    Question.prototype.getIsQuestionReady = function () {
        return !this.isAsyncExpressionRunning && this.getAreNestedQuestionsReady();
    };
    Question.prototype.getAreNestedQuestionsReady = function () {
        var questions = this.getIsReadyNestedQuestions();
        if (!Array.isArray(questions))
            return true;
        for (var i = 0; i < questions.length; i++) {
            if (!questions[i].isReady)
                return false;
        }
        return true;
    };
    Question.prototype.getIsReadyNestedQuestions = function () {
        return this.getNestedQuestions();
    };
    Question.prototype.setIsReady = function (val) {
        var oldIsReady = this.isReadyValue;
        this.isReadyValue = val;
        if (oldIsReady != val) {
            this.getIsReadyDependends().forEach(function (q) { return q.updateIsReady(); });
            this.onReadyChanged.fire(this, {
                question: this,
                isReady: val,
                oldIsReady: oldIsReady,
            });
        }
    };
    Question.prototype.getIsReadyDependsOn = function () {
        return this.getIsReadyDependendCore(true);
    };
    Question.prototype.getIsReadyDependends = function () {
        return this.getIsReadyDependendCore(false);
    };
    Question.prototype.getIsReadyDependendCore = function (isDependOn) {
        var _this = this;
        if (!this.survey)
            return [];
        var questions = this.survey.questionsByValueName(this.getValueName());
        var res = new Array();
        questions.forEach(function (q) { if (q !== _this)
            res.push(q); });
        if (!isDependOn) {
            if (this.parentQuestion) {
                res.push(this.parentQuestion);
            }
            if (this.dependedQuestions.length > 0) {
                this.dependedQuestions.forEach(function (q) { return res.push(q); });
            }
        }
        return res;
    };
    Question.prototype.choicesLoaded = function () { };
    Object.defineProperty(Question.prototype, "page", {
        /**
         * Returns a page to which the question belongs and allows you to move this question to a different page.
         */
        get: function () {
            if (!!this.parentQuestion)
                return this.parentQuestion.page;
            return this.getPage(this.parent);
        },
        set: function (val) {
            this.setPage(this.parent, val);
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.getPanel = function () {
        return null;
    };
    Question.prototype.delete = function (doDispose) {
        if (doDispose === void 0) { doDispose = true; }
        this.removeFromParent();
        if (doDispose) {
            this.dispose();
        }
        else {
            this.resetDependedQuestions();
        }
    };
    Question.prototype.removeFromParent = function () {
        if (!!this.parent) {
            this.removeSelfFromList(this.parent.elements);
        }
    };
    Question.prototype.addDependedQuestion = function (question) {
        if (!question || this.dependedQuestions.indexOf(question) > -1)
            return;
        this.dependedQuestions.push(question);
    };
    Question.prototype.removeDependedQuestion = function (question) {
        if (!question)
            return;
        var index = this.dependedQuestions.indexOf(question);
        if (index > -1) {
            this.dependedQuestions.splice(index, 1);
        }
    };
    Question.prototype.updateDependedQuestions = function () {
        for (var i = 0; i < this.dependedQuestions.length; i++) {
            this.dependedQuestions[i].updateDependedQuestion();
        }
    };
    Question.prototype.updateDependedQuestion = function () { };
    Question.prototype.resetDependedQuestion = function () { };
    Object.defineProperty(Question.prototype, "isFlowLayout", {
        get: function () {
            return this.getLayoutType() === "flow";
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.getLayoutType = function () {
        if (!!this.parent)
            return this.parent.getChildrenLayoutType();
        return "row";
    };
    Question.prototype.isLayoutTypeSupported = function (layoutType) {
        return layoutType !== "flow";
    };
    Object.defineProperty(Question.prototype, "visible", {
        /**
         * Gets or sets question visibility.
         *
         * If you want to display or hide a question based on a condition, specify the [`visibleIf`](https://surveyjs.io/form-library/documentation/question#visibleIf) property. Refer to the following help topic for information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see isVisible
         * @see visibleIf
         */
        get: function () {
            return this.getPropertyValue("visible", true);
        },
        set: function (val) {
            if (val == this.visible)
                return;
            this.setPropertyValue("visible", val);
            this.onVisibleChanged();
            this.notifySurveyVisibilityChanged();
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.onVisibleChanged = function () {
        this.updateIsVisibleProp();
        if (!this.isVisible && this.errors && this.errors.length > 0) {
            this.errors = [];
        }
    };
    Question.prototype.notifyStateChanged = function (prevState) {
        _super.prototype.notifyStateChanged.call(this, prevState);
        if (this.isCollapsed) {
            this.onHidingContent();
        }
    };
    Question.prototype.updateIsVisibleProp = function () {
        var prev = this.getPropertyValue("isVisible");
        var val = this.isVisible;
        if (prev !== val) {
            this.setPropertyValue("isVisible", val);
            if (!val) {
                this.onHidingContent();
            }
        }
    };
    Object.defineProperty(Question.prototype, "useDisplayValuesInDynamicTexts", {
        /**
         * Specifies whether to use display names for question values in placeholders.
         *
         * Default value: `true`
         *
         * This property applies to questions whose values are defined as objects with the `value` and `text` properties (for example, [choice items](https://surveyjs.io/form-library/documentation/questionradiogroupmodel#choices) in Radiogroup, Checkbox, and Dropdown questions).
         *
         * You can use question values as placeholders in the following places:
         *
         * - Survey element titles and descriptions
         * - The [`html`](https://surveyjs.io/form-library/documentation/questionhtmlmodel#html) property of the [HTML](https://surveyjs.io/form-library/documentation/questionhtmlmodel) question
         *
         * To use a question value as a placeholder, specify the question `name` in curly brackets: `{questionName}`. Refer to the following help topic for more information: [Dynamic Texts - Question Values](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#question-values).
         */
        get: function () {
            return this.getPropertyValue("useDisplayValuesInDynamicTexts");
        },
        set: function (val) {
            this.setPropertyValue("useDisplayValuesInDynamicTexts", val);
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.getUseDisplayValuesInDynamicTexts = function () { return this.useDisplayValuesInDynamicTexts; };
    Object.defineProperty(Question.prototype, "visibleIf", {
        /**
         * A Boolean expression. If it evaluates to `false`, this question becomes hidden.
         *
         * A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
         *
         * Refer to the following help topic for more information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see visible
         * @see isVisible
         */
        get: function () {
            return this.getPropertyValue("visibleIf", "");
        },
        set: function (val) {
            this.setPropertyValue("visibleIf", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "isVisible", {
        /**
         * Returns `true` if the question is visible or the survey is currently in design mode.
         *
         * If you want to display or hide a question based on a condition, specify the [`visibleIf`](https://surveyjs.io/form-library/documentation/question#visibleIf) property. Refer to the following help topic for information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see visibleIf
         * @see visible
         * @see isParentVisible
         */
        get: function () {
            if (this.survey && this.survey.areEmptyElementsHidden && this.isEmpty())
                return false;
            if (this.areInvisibleElementsShowing)
                return true;
            return this.isVisibleCore();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "isVisibleInSurvey", {
        get: function () {
            return this.isVisible && this.isParentVisible;
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.isVisibleCore = function () {
        return this.visible;
    };
    Object.defineProperty(Question.prototype, "visibleIndex", {
        /**
         * Returns the visible index of the question in the survey. It can be from 0 to all visible questions count - 1
         * The visibleIndex is -1 if the title is 'hidden' or hideNumber is true
         * @see titleLocation
         * @see hideNumber
         */
        get: function () {
            return this.getPropertyValue("visibleIndex", -1);
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.onHidingContent = function () { };
    Object.defineProperty(Question.prototype, "hideNumber", {
        /**
         * Hides the question number from the title and excludes the question from numbering.
         *
         * If you want to disable question numbering in the entire survey, set `SurveyModel`'s `showQuestionNumbers` property to `false`.
         * @see SurveyModel.showQuestionNumbers
         */
        get: function () {
            return this.getPropertyValue("hideNumber");
        },
        set: function (val) {
            this.setPropertyValue("hideNumber", val);
            this.notifySurveyVisibilityChanged();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "isAllowTitleLeft", {
        /**
         * Returns `true` if the question can display its title to the left of the input field.
         * @see titleLocation
         * @see getTitleLocation
         * @see hasTitle
         */
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Returns the question type.
     * Possible values:
     * - [*"boolean"*](https://surveyjs.io/Documentation/Library?id=questionbooleanmodel)
     * - [*"checkbox"*](https://surveyjs.io/Documentation/Library?id=questioncheckboxmodel)
     * - [*"comment"*](https://surveyjs.io/Documentation/Library?id=questioncommentmodel)
     * - [*"dropdown"*](https://surveyjs.io/Documentation/Library?id=questiondropdownmodel)
     * - [*"tagbox"*](https://surveyjs.io/form-library/documentation/questiontagboxmodel)
     * - [*"expression"*](https://surveyjs.io/Documentation/Library?id=questionexpressionmodel)
     * - [*"file"*](https://surveyjs.io/Documentation/Library?id=questionfilemodel)
     * - [*"html"*](https://surveyjs.io/Documentation/Library?id=questionhtmlmodel)
     * - [*"image"*](https://surveyjs.io/Documentation/Library?id=questionimagemodel)
     * - [*"imagepicker"*](https://surveyjs.io/Documentation/Library?id=questionimagepickermodel)
     * - [*"matrix"*](https://surveyjs.io/Documentation/Library?id=questionmatrixmodel)
     * - [*"matrixdropdown"*](https://surveyjs.io/Documentation/Library?id=questionmatrixdropdownmodel)
     * - [*"matrixdynamic"*](https://surveyjs.io/Documentation/Library?id=questionmatrixdynamicmodel)
     * - [*"multipletext"*](https://surveyjs.io/Documentation/Library?id=questionmultipletextmodel)
     * - [*"panel"*](https://surveyjs.io/Documentation/Library?id=panelmodel)
     * - [*"paneldynamic"*](https://surveyjs.io/Documentation/Library?id=questionpaneldynamicmodel)
     * - [*"radiogroup"*](https://surveyjs.io/Documentation/Library?id=questionradiogroupmodel)
     * - [*"rating"*](https://surveyjs.io/Documentation/Library?id=questionratingmodel)
     * - [*"ranking"*](https://surveyjs.io/Documentation/Library?id=questionrankingmodel)
     * - [*"signaturepad"*](https://surveyjs.io/Documentation/Library?id=questionsignaturepadmodel)
     * - [*"text"*](https://surveyjs.io/Documentation/Library?id=questiontextmodel)
     */
    Question.prototype.getType = function () {
        return "question";
    };
    Object.defineProperty(Question.prototype, "isQuestion", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.moveTo = function (container, insertBefore) {
        if (insertBefore === void 0) { insertBefore = null; }
        return this.moveToBase(this.parent, container, insertBefore);
    };
    Question.prototype.getProgressInfo = function () {
        if (!this.hasInput)
            return _super.prototype.getProgressInfo.call(this);
        return {
            questionCount: 1,
            answeredQuestionCount: !this.isEmpty() ? 1 : 0,
            requiredQuestionCount: this.isRequired ? 1 : 0,
            requiredAnsweredQuestionCount: !this.isEmpty() && this.isRequired ? 1 : 0,
        };
    };
    Question.prototype.ensureSetValueExpressionRunner = function () {
        var _this = this;
        if (!this.setValueExpressionRunner) {
            this.setValueExpressionRunner = new ExpressionRunner(this.setValueExpression);
            this.setValueExpressionRunner.onRunComplete = function (res) {
                _this.runExpressionSetValue(res);
            };
        }
        else {
            this.setValueExpressionRunner.expression = this.setValueExpression;
        }
    };
    Question.prototype.runSetValueExpression = function () {
        if (!this.setValueExpression) {
            this.clearValue();
        }
        else {
            this.ensureSetValueExpressionRunner();
            this.setValueExpressionRunner.run(this.getDataFilteredValues(), this.getDataFilteredProperties());
        }
    };
    Question.prototype.checkExpressionIf = function (keys) {
        this.ensureSetValueExpressionRunner();
        if (!this.setValueExpressionRunner)
            return false;
        return new conditionProcessValue_ProcessValue().isAnyKeyChanged(keys, this.setValueExpressionRunner.getVariables());
    };
    Question.prototype.addTriggerInfo = function (name, canRun, doComplete) {
        var info = new TriggerExpressionInfo(name, canRun, doComplete);
        this.triggersInfo.push(info);
        return info;
    };
    Question.prototype.runTriggerInfo = function (info, name, value) {
        var expression = this[info.name];
        var keys = {};
        keys[name] = value;
        if (!expression || info.isRunning || !info.canRun()) {
            if (info.runSecondCheck(keys)) {
                info.doComplete();
            }
            return;
        }
        if (!info.runner) {
            info.runner = new ExpressionRunner(expression);
            info.runner.onRunComplete = function (res) {
                if (res === true) {
                    info.doComplete();
                }
                info.isRunning = false;
            };
        }
        else {
            info.runner.expression = expression;
        }
        if (!new conditionProcessValue_ProcessValue().isAnyKeyChanged(keys, info.runner.getVariables()) && !info.runSecondCheck(keys))
            return;
        info.isRunning = true;
        info.runner.run(this.getDataFilteredValues(), this.getDataFilteredProperties());
    };
    Question.prototype.runTriggers = function (name, value) {
        var _this = this;
        if (this.isSettingQuestionValue || (this.parentQuestion && this.parentQuestion.getValueName() === name))
            return;
        this.triggersInfo.forEach(function (info) {
            _this.runTriggerInfo(info, name, value);
        });
    };
    Question.prototype.runConditions = function () {
        if (this.data && !this.isLoadingFromJson) {
            if (!this.isDesignMode) {
                this.runCondition(this.getDataFilteredValues(), this.getDataFilteredProperties());
            }
            this.locStrsChanged();
        }
    };
    Question.prototype.setSurveyImpl = function (value, isLight) {
        _super.prototype.setSurveyImpl.call(this, value);
        if (!this.survey)
            return;
        this.survey.questionCreated(this);
        if (isLight !== true) {
            this.runConditions();
        }
        this.calcRenderedCommentPlaceholder();
        if (!this.visible) {
            this.updateIsVisibleProp();
        }
        this.updateIsMobileFromSurvey();
    };
    Object.defineProperty(Question.prototype, "parent", {
        /**
         * Returns a survey element (panel or page) that contains the question and allows you to move this question to a different survey element.
         */
        get: function () {
            return this.getPropertyValue("parent", null);
        },
        set: function (val) {
            if (this.parent === val)
                return;
            this.removeFromParent();
            this.setPropertyValue("parent", val);
            this.updateQuestionCss();
            this.onParentChanged();
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.onParentChanged = function () { };
    Object.defineProperty(Question.prototype, "hasTitle", {
        /**
         * Returns `false` if the `titleLocation` property is set to `"hidden"` or if the question cannot have a title (for example, an [HTML](https://surveyjs.io/form-library/documentation/questionhtmlmodel) question).
         *
         * If the `title` property is `undefined` or set to an empty string, the `hasTitle` property returns `true`, because the question uses its `name` as a title in this case.
         * @see title
         * @see titleLocation
         */
        get: function () {
            return this.getTitleLocation() !== "hidden";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "titleLocation", {
        /**
         * Sets question title location relative to the input field. Overrides the `questionTitleLocation` property specified for the question's container (survey, page, or panel).
         *
         * Possible values:
         *
         * - `"default"` (default) - Inherits the setting from the `questionTitleLocation` property specified for the question's container.
         * - `"top"` - Displays the title above the input field.
         * - `"bottom"` - Displays the title below the input field.
         * - `"left"` - Displays the title to the left of the input field.
         * - `"hidden"` - Hides the question title.
         *
         * > Certain question types (Matrix, Multiple Text) do not support the `"left"` value. For them, the `"top"` value is used.
         * @see SurveyModel.questionTitleLocation
         * @see getTitleLocation
         * @see isAllowTitleLeft
         */
        get: function () {
            return this.getPropertyValue("titleLocation");
        },
        set: function (value) {
            var isVisibilityChanged = this.titleLocation == "hidden" || value == "hidden";
            this.setPropertyValue("titleLocation", value.toLowerCase());
            this.updateQuestionCss();
            if (isVisibilityChanged) {
                this.notifySurveyVisibilityChanged();
            }
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.getTitleOwner = function () { return this; };
    Question.prototype.getIsTitleRenderedAsString = function () { return this.titleLocation === "hidden"; };
    Question.prototype.notifySurveyOnChildrenVisibilityChanged = function () { return false; };
    Question.prototype.notifySurveyVisibilityChanged = function () {
        if (!this.survey || this.isLoadingFromJson)
            return;
        this.survey.questionVisibilityChanged(this, this.isVisible, !this.parentQuestion || this.parentQuestion.notifySurveyOnChildrenVisibilityChanged());
        var isClearOnHidden = this.isClearValueOnHidden;
        if (!this.visible) {
            this.clearValueOnHidding(isClearOnHidden);
        }
        if (isClearOnHidden && this.isVisibleInSurvey) {
            this.updateValueWithDefaults();
        }
    };
    Question.prototype.clearValueOnHidding = function (isClearOnHidden) {
        if (isClearOnHidden) {
            this.clearValueIfInvisible();
        }
    };
    Object.defineProperty(Question.prototype, "titleWidth", {
        get: function () {
            if (this.parent && this.getTitleLocation() === "left") {
                var columns = this.parent.getColumsForElement(this);
                var columnCount = columns.length;
                if (columnCount !== 0 && !!columns[0].questionTitleWidth)
                    return columns[0].questionTitleWidth;
                var percentWidth = this.getPercentQuestionTitleWidth();
                if (!percentWidth && !!this.parent) {
                    var width = this.parent.getQuestionTitleWidth();
                    if (width && !isNaN(width))
                        width = width + "px";
                    return width;
                }
                return (percentWidth / (columnCount || 1)) + "%";
            }
            return undefined;
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.getPercentQuestionTitleWidth = function () {
        var width = !!this.parent && this.parent.getQuestionTitleWidth();
        if (!!width && width[width.length - 1] === "%") {
            return parseInt(width);
        }
        return undefined;
    };
    /**
     * Returns title location calculated based on the question's `titleLocation` property and the `questionTitleLocation` property of the question's containers (survey, page, or panel).
     * @see titleLocation
     * @see SurveyModel.questionTitleLocation
     */
    Question.prototype.getTitleLocation = function () {
        if (this.isFlowLayout)
            return "hidden";
        var location = this.getTitleLocationCore();
        if (location === "left" && !this.isAllowTitleLeft)
            location = "top";
        return location;
    };
    Question.prototype.getTitleLocationCore = function () {
        if (this.titleLocation !== "default")
            return this.titleLocation;
        if (!!this.parent)
            return this.parent.getQuestionTitleLocation();
        if (!!this.survey)
            return this.survey.questionTitleLocation;
        return "top";
    };
    Object.defineProperty(Question.prototype, "hasTitleOnLeft", {
        get: function () {
            return this.hasTitle && this.getTitleLocation() === "left";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "hasTitleOnTop", {
        get: function () {
            return this.hasTitle && this.getTitleLocation() === "top";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "hasTitleOnBottom", {
        get: function () {
            return this.hasTitle && this.getTitleLocation() === "bottom";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "hasTitleOnLeftTop", {
        get: function () {
            if (!this.hasTitle)
                return false;
            var location = this.getTitleLocation();
            return location === "left" || location === "top";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "errorLocation", {
        /**
         * Specifies the error message position. Overrides the `questionErrorLocation` property specified for the question's container ([survey](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#questionErrorLocation), [page](https://surveyjs.io/form-library/documentation/api-reference/page-model#questionErrorLocation), or [panel](https://surveyjs.io/form-library/documentation/api-reference/panel-model#questionErrorLocation)).
         *
         * Possible values:
         *
         * - `"default"` (default) - Inherits the setting from the `questionErrorLocation` property specified for the question's container.
         * - `"top"` - Displays error messages above questions.
         * - `"bottom"` - Displays error messages below questions.
         */
        get: function () {
            return this.getPropertyValue("errorLocation");
        },
        set: function (val) {
            this.setPropertyValue("errorLocation", val);
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.getErrorLocation = function () {
        if (this.errorLocation !== "default")
            return this.errorLocation;
        if (this.parentQuestion)
            return this.parentQuestion.getChildErrorLocation(this);
        if (this.parent)
            return this.parent.getQuestionErrorLocation();
        return this.survey ? this.survey.questionErrorLocation : "top";
    };
    Question.prototype.getChildErrorLocation = function (child) {
        return this.getErrorLocation();
    };
    Object.defineProperty(Question.prototype, "hasInput", {
        /**
         * Returns `false` if the question has no input fields ([HTML](https://surveyjs.io/form-library/documentation/questionhtmlmodel), [Image](https://surveyjs.io/form-library/documentation/questionimagemodel), and similar question types).
         * @see hasSingleInput
         */
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "hasSingleInput", {
        /**
         * Returns `false` if the question has no input fields ([HTML](https://surveyjs.io/form-library/documentation/questionhtmlmodel), [Image](https://surveyjs.io/form-library/documentation/questionimagemodel)) or has multiple input fields ([Matrix](https://surveyjs.io/form-library/documentation/questionmatrixmodel), [Multiple Text](https://surveyjs.io/form-library/documentation/questionmultipletextmodel)).
         * @see hasInput
         */
        get: function () {
            return this.hasInput;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "inputId", {
        get: function () {
            return this.id + "i";
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.getDefaultTitleValue = function () { return this.name; };
    Question.prototype.getDefaultTitleTagName = function () {
        return settings.titleTags.question;
    };
    Object.defineProperty(Question.prototype, "descriptionLocation", {
        /**
         * Specifies where to display a question description.
         *
         * Possible values:
         *
         * - `"default"` (default) - Inherits the setting from the Survey's [`questionDescriptionLocation`](https://surveyjs.io/form-library/documentation/surveymodel#questionDescriptionLocation) property.
         * - `"underTitle"` - Displays the description under the question title.
         * - `"underInput"` - Displays the description under the interactive area.
         * @see description
         * @see hasDescription
         */
        get: function () {
            return this.getPropertyValue("descriptionLocation");
        },
        set: function (val) {
            this.setPropertyValue("descriptionLocation", val);
            this.updateQuestionCss();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "hasDescriptionUnderTitle", {
        get: function () {
            return this.getDescriptionLocation() == "underTitle" && this.hasDescription;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "hasDescriptionUnderInput", {
        get: function () {
            return this.getDescriptionLocation() == "underInput" && this.hasDescription;
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.getDescriptionLocation = function () {
        if (this.descriptionLocation !== "default")
            return this.descriptionLocation;
        return !!this.survey
            ? this.survey.questionDescriptionLocation
            : "underTitle";
    };
    Question.prototype.needClickTitleFunction = function () {
        return _super.prototype.needClickTitleFunction.call(this) || this.hasInput;
    };
    Question.prototype.processTitleClick = function () {
        var _this = this;
        _super.prototype.processTitleClick.call(this);
        if (this.isCollapsed)
            return;
        setTimeout(function () {
            _this.focus();
        }, 1);
        return true;
    };
    Object.defineProperty(Question.prototype, "requiredErrorText", {
        /**
         * Specifies a custom error message for a required form field.
         * @see isRequired
         */
        get: function () {
            return this.getLocalizableStringText("requiredErrorText");
        },
        set: function (val) {
            this.setLocalizableStringText("requiredErrorText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "locRequiredErrorText", {
        get: function () {
            return this.getLocalizableString("requiredErrorText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "commentText", {
        /**
         * Specifies a caption displayed above the comment area. Applies when the `showCommentArea` property is `true`.
         * @see showCommentArea
         * @see comment
         */
        get: function () {
            return this.getLocalizableStringText("commentText");
        },
        set: function (val) {
            this.setLocalizableStringText("commentText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "locCommentText", {
        get: function () {
            return this.getLocalizableString("commentText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "commentPlaceHolder", {
        get: function () {
            return this.commentPlaceholder;
        },
        set: function (newValue) {
            this.commentPlaceholder = newValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "renderedCommentPlaceholder", {
        get: function () {
            return this.getPropertyValue("renderedCommentPlaceholder");
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.calcRenderedCommentPlaceholder = function () {
        var res = !this.isReadOnly ? this.commentPlaceHolder : undefined;
        this.setPropertyValue("renderedCommentPlaceholder", res);
    };
    Question.prototype.getAllErrors = function () {
        return this.errors.slice();
    };
    Question.prototype.getErrorByType = function (errorType) {
        for (var i = 0; i < this.errors.length; i++) {
            if (this.errors[i].getErrorType() === errorType)
                return this.errors[i];
        }
        return null;
    };
    Object.defineProperty(Question.prototype, "customWidget", {
        get: function () {
            if (!this.isCustomWidgetRequested && !this.customWidgetValue) {
                this.isCustomWidgetRequested = true;
                this.updateCustomWidget();
            }
            return this.customWidgetValue;
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.updateCustomWidget = function () {
        this.customWidgetValue = questionCustomWidgets_CustomWidgetCollection.Instance.getCustomWidget(this);
    };
    Question.prototype.localeChanged = function () {
        _super.prototype.localeChanged.call(this);
        this.calcRenderedCommentPlaceholder();
        if (!!this.localeChangedCallback) {
            this.localeChangedCallback();
        }
    };
    Object.defineProperty(Question.prototype, "isCompositeQuestion", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "isContainer", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Question.prototype.updateCommentElements = function () {
        if (!this.autoGrowComment || !Array.isArray(this.commentElements))
            return;
        for (var i = 0; i < this.commentElements.length; i++) {
            var el = this.commentElements[i];
            if (el)
                increaseHeightByContent(el);
        }
    };
    Question.prototype.onCommentInput = function (event) {
        if (this.isInputTextUpdate) {
            if (event.target) {
                this.comment = event.target.value;
            }
        }
        else {
            this.updateCommentElements();
        }
    };
    Question.prototype.onCommentChange = function (event) {
        this.comment = event.target.value;
        if (this.comment !== event.target.value) {
            event.target.value = this.comment;
        }
    };
    Question.prototype.afterRenderQuestionElement = function (el) {
        if (!this.survey || !this.hasSingleInput)
            return;
        this.survey.afterRenderQuestionInput(this, el);
    };
    Question.prototype.afterRender = function (el) {
        var _this = this;
        this.afterRenderCore(el);
        if (!this.survey)
            return;
        this.survey.afterRenderQuestion(this, el);
        if (!!this.afterRenderQuestionCallback) {
            this.afterRenderQuestionCallback(this, el);
        }
        if (this.supportComment() || this.supportOther()) {
            this.commentElements = [];
            this.getCommentElementsId().forEach(function (id) {
                var root = settings.environment.root;
                var el = root.getElementById(id);
                if (el)
                    _this.commentElements.push(el);
            });
            this.updateCommentElements();
        }
        this.checkForResponsiveness(el);
    };
    Question.prototype.afterRenderCore = function (el) {
    };
    Question.prototype.getCommentElementsId = function () {
        return [this.commentId];
    };
    Question.prototype.beforeDestroyQuestionElement = function (el) {
        this.commentElements = undefined;
    };
    Object.defineProperty(Question.prototype, "processedTitle", {
        get: function () {
            var res = this.locProcessedTitle.textOrHtml;
            return res ? res : this.name;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "fullTitle", {
        get: function () {
            return this.locTitle.renderedHtml;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "titlePattern", {
        get: function () {
            return !!this.survey ? this.survey.questionTitlePattern : "numTitleRequire";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "isRequireTextOnStart", {
        get: function () {
            return this.isRequired && this.titlePattern == "requireNumTitle";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "isRequireTextBeforeTitle", {
        get: function () {
            return this.isRequired && this.titlePattern == "numRequireTitle" && this.requiredText !== "";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "isRequireTextAfterTitle", {
        get: function () {
            return this.isRequired && this.titlePattern == "numTitleRequire" && this.requiredText !== "";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "startWithNewLine", {
        /**
         * Disable this property if you want to render the current question on the same line or row with the previous question or panel.
         */
        get: function () {
            return this.getPropertyValue("startWithNewLine");
        },
        set: function (val) {
            if (this.startWithNewLine == val)
                return;
            this.setPropertyValue("startWithNewLine", val);
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.calcCssClasses = function (css) {
        var classes = { error: {} };
        this.copyCssClasses(classes, css.question);
        this.copyCssClasses(classes.error, css.error);
        this.updateCssClasses(classes, css);
        if (this.survey) {
            this.survey.updateQuestionCssClasses(this, classes);
        }
        if (this.onUpdateCssClassesCallback) {
            this.onUpdateCssClassesCallback(classes);
        }
        return classes;
    };
    Object.defineProperty(Question.prototype, "cssRoot", {
        get: function () {
            this.ensureElementCss();
            return this.getPropertyValue("cssRoot", "");
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.setCssRoot = function (val) {
        this.setPropertyValue("cssRoot", val);
    };
    Question.prototype.getCssRoot = function (cssClasses) {
        var hasError = this.hasCssError();
        return new CssClassBuilder()
            .append(_super.prototype.getCssRoot.call(this, cssClasses))
            .append(this.isFlowLayout && !this.isDesignMode
            ? cssClasses.flowRoot
            : cssClasses.mainRoot)
            .append(cssClasses.titleLeftRoot, !this.isFlowLayout && this.hasTitleOnLeft)
            .append(cssClasses.titleTopRoot, !this.isFlowLayout && this.hasTitleOnTop)
            .append(cssClasses.titleBottomRoot, !this.isFlowLayout && this.hasTitleOnBottom)
            .append(cssClasses.descriptionUnderInputRoot, !this.isFlowLayout && this.hasDescriptionUnderInput)
            .append(cssClasses.hasError, hasError)
            .append(cssClasses.hasErrorTop, hasError && this.getErrorLocation() == "top")
            .append(cssClasses.hasErrorBottom, hasError && this.getErrorLocation() == "bottom")
            .append(cssClasses.small, !this.width)
            .append(cssClasses.answered, this.isAnswered)
            .append(cssClasses.noPointerEventsMode, this.isReadOnlyAttr)
            .toString();
    };
    Object.defineProperty(Question.prototype, "cssHeader", {
        get: function () {
            this.ensureElementCss();
            return this.getPropertyValue("cssHeader", "");
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.setCssHeader = function (val) {
        this.setPropertyValue("cssHeader", val);
    };
    Question.prototype.getCssHeader = function (cssClasses) {
        return new CssClassBuilder()
            .append(cssClasses.header)
            .append(cssClasses.headerTop, this.hasTitleOnTop)
            .append(cssClasses.headerLeft, this.hasTitleOnLeft)
            .append(cssClasses.headerBottom, this.hasTitleOnBottom)
            .toString();
    };
    Question.prototype.supportContainerQueries = function () {
        return false;
    };
    Object.defineProperty(Question.prototype, "cssContent", {
        get: function () {
            this.ensureElementCss();
            return this.getPropertyValue("cssContent", "");
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.setCssContent = function (val) {
        this.setPropertyValue("cssContent", val);
    };
    Question.prototype.getCssContent = function (cssClasses) {
        return new CssClassBuilder()
            .append(cssClasses.content)
            .append(cssClasses.contentSupportContainerQueries, this.supportContainerQueries())
            .append(cssClasses.contentLeft, this.hasTitleOnLeft)
            .toString();
    };
    Object.defineProperty(Question.prototype, "cssTitle", {
        get: function () {
            this.ensureElementCss();
            return this.getPropertyValue("cssTitle", "");
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.setCssTitle = function (val) {
        this.setPropertyValue("cssTitle", val);
    };
    Question.prototype.getCssTitle = function (cssClasses) {
        return new CssClassBuilder()
            .append(_super.prototype.getCssTitle.call(this, cssClasses))
            .append(cssClasses.titleOnAnswer, !this.containsErrors && this.isAnswered)
            .append(cssClasses.titleEmpty, !this.title.trim())
            .toString();
    };
    Object.defineProperty(Question.prototype, "cssDescription", {
        get: function () {
            this.ensureElementCss();
            return this.getPropertyValue("cssDescription", "");
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.setCssDescription = function (val) {
        this.setPropertyValue("cssDescription", val);
    };
    Question.prototype.getCssDescription = function (cssClasses) {
        return new CssClassBuilder()
            .append(cssClasses.description, this.hasDescriptionUnderTitle)
            .append(cssClasses.descriptionUnderInput, this.hasDescriptionUnderInput)
            .toString();
    };
    Question.prototype.showErrorOnCore = function (location) {
        return !this.showErrorsAboveQuestion && !this.showErrorsBelowQuestion && this.getErrorLocation() === location;
    };
    Object.defineProperty(Question.prototype, "showErrorOnTop", {
        get: function () {
            return this.showErrorOnCore("top");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "showErrorOnBottom", {
        get: function () {
            return this.showErrorOnCore("bottom");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "showErrorsOutsideQuestion", {
        get: function () {
            return this.isDefaultV2Theme;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "showErrorsAboveQuestion", {
        get: function () {
            return this.showErrorsOutsideQuestion && this.getErrorLocation() === "top";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "showErrorsBelowQuestion", {
        get: function () {
            return this.showErrorsOutsideQuestion && this.getErrorLocation() === "bottom";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "cssError", {
        get: function () {
            this.ensureElementCss();
            return this.getPropertyValue("cssError", "");
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.setCssError = function (val) {
        this.setPropertyValue("cssError", val);
    };
    Question.prototype.getCssError = function (cssClasses) {
        return new CssClassBuilder()
            .append(cssClasses.error.root)
            .append(cssClasses.errorsContainer, this.showErrorsBelowQuestion || this.showErrorsAboveQuestion)
            .append(cssClasses.errorsContainerTop, this.showErrorsAboveQuestion)
            .append(cssClasses.errorsContainerBottom, this.showErrorsBelowQuestion)
            .append(cssClasses.error.locationTop, this.showErrorOnTop)
            .append(cssClasses.error.locationBottom, this.showErrorOnBottom)
            .toString();
    };
    Question.prototype.hasCssError = function () {
        return this.errors.length > 0 || this.hasCssErrorCallback();
    };
    Question.prototype.getRootCss = function () {
        return new CssClassBuilder()
            .append(this.cssRoot)
            .append(this.cssClasses.readOnly, this.isReadOnlyStyle)
            .append(this.cssClasses.disabled, this.isDisabledStyle)
            .append(this.cssClasses.preview, this.isPreviewStyle)
            .append(this.cssClasses.invisible, !this.isDesignMode && this.areInvisibleElementsShowing && !this.visible)
            .toString();
    };
    Question.prototype.getQuestionRootCss = function () {
        return new CssClassBuilder()
            .append(this.cssClasses.root)
            .append(this.cssClasses.rootMobile, this.isMobile)
            .toString();
    };
    Question.prototype.updateElementCss = function (reNew) {
        _super.prototype.updateElementCss.call(this, reNew);
        if (reNew) {
            this.updateQuestionCss(true);
        }
        this.onIndentChanged();
    };
    Question.prototype.updateQuestionCss = function (reNew) {
        if (this.isLoadingFromJson ||
            !this.survey ||
            (reNew !== true && !this.cssClassesValue))
            return;
        this.updateElementCssCore(this.cssClasses);
    };
    Question.prototype.ensureElementCss = function () {
        if (!this.cssClassesValue) {
            this.updateQuestionCss(true);
        }
    };
    Question.prototype.updateElementCssCore = function (cssClasses) {
        this.setCssRoot(this.getCssRoot(cssClasses));
        this.setCssHeader(this.getCssHeader(cssClasses));
        this.setCssContent(this.getCssContent(cssClasses));
        this.setCssTitle(this.getCssTitle(cssClasses));
        this.setCssDescription(this.getCssDescription(cssClasses));
        this.setCssError(this.getCssError(cssClasses));
    };
    Question.prototype.updateCssClasses = function (res, css) {
        if (!css.question)
            return;
        var objCss = css[this.getCssType()];
        var titleBuilder = new CssClassBuilder().append(res.title)
            .append(css.question.titleRequired, this.isRequired);
        res.title = titleBuilder.toString();
        var rootBuilder = new CssClassBuilder().append(res.root)
            .append(objCss, this.isRequired && !!css.question.required);
        if (objCss === undefined || objCss === null) {
            res.root = rootBuilder.toString();
        }
        else if (typeof objCss === "string" || objCss instanceof String) {
            res.root = rootBuilder.append(objCss.toString()).toString();
        }
        else {
            res.root = rootBuilder.toString();
            for (var key in objCss) {
                res[key] = objCss[key];
            }
        }
    };
    Question.prototype.getCssType = function () {
        return this.getType();
    };
    Object.defineProperty(Question.prototype, "renderCssRoot", {
        get: function () {
            return this.cssClasses.root || undefined;
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.onIndentChanged = function () {
        this.paddingLeft = this.getIndentSize(this.indent);
        this.paddingRight = this.getIndentSize(this.rightIndent);
    };
    Question.prototype.getIndentSize = function (indent) {
        if (indent < 1 || !this.getSurvey() || !this.cssClasses || !this.cssClasses.indent)
            return "";
        return indent * this.cssClasses.indent + "px";
    };
    /**
     * Moves focus to the input field of this question.
     * @param onError Pass `true` if you want to focus an input field with the first validation error. Default value: `false` (focuses the first input field). Applies to question types with multiple input fields.
     */
    Question.prototype.focus = function (onError, scrollIfVisible) {
        if (onError === void 0) { onError = false; }
        if (this.isDesignMode || !this.isVisible || !this.survey)
            return;
        var page = this.page;
        var shouldChangePage = !!page && this.survey.activePage !== page;
        if (shouldChangePage) {
            this.survey.focusQuestionByInstance(this, onError);
        }
        else {
            this.focuscore(onError, scrollIfVisible);
        }
    };
    Question.prototype.focuscore = function (onError, scrollIfVisible) {
        if (onError === void 0) { onError = false; }
        if (!!this.survey) {
            this.expandAllParents();
            this.survey.scrollElementToTop(this, this, null, this.id, scrollIfVisible);
        }
        this.focusInputElement(onError);
    };
    Question.prototype.focusInputElement = function (onError) {
        var id = !onError ? this.getFirstInputElementId() : this.getFirstErrorInputElementId();
        if (survey_element_SurveyElement.FocusElement(id)) {
            this.fireCallback(this.focusCallback);
        }
    };
    Object.defineProperty(Question.prototype, "isValidateVisitedEmptyFields", {
        get: function () {
            return this.supportEmptyValidation() && !!this.survey && this.survey.getValidateVisitedEmptyFields() && this.isEmpty();
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.supportEmptyValidation = function () { return false; };
    Question.prototype.onBlur = function (event) {
        this.onBlurCore(event);
    };
    Question.prototype.onFocus = function (event) {
        this.onFocusCore(event);
    };
    Question.prototype.onBlurCore = function (event) {
        if (this.isFocusEmpty && this.isEmpty()) {
            this.validate(true);
        }
    };
    Question.prototype.onFocusCore = function (event) {
        this.isFocusEmpty = this.isValidateVisitedEmptyFields;
    };
    Question.prototype.expandAllParents = function () {
        this.expandAllParentsCore(this);
    };
    Question.prototype.expandAllParentsCore = function (element) {
        if (!element)
            return;
        if (element.isCollapsed) {
            element.expand();
        }
        this.expandAllParentsCore(element.parent);
        this.expandAllParentsCore(element.parentQuestion);
    };
    Question.prototype.focusIn = function () {
        if (!this.survey || this.isDisposed || this.isContainer)
            return;
        this.survey.whenQuestionFocusIn(this);
    };
    Question.prototype.fireCallback = function (callback) {
        if (callback)
            callback();
    };
    Question.prototype.getOthersMaxLength = function () {
        if (!this.survey)
            return null;
        return this.survey.maxOthersLength > 0 ? this.survey.maxOthersLength : null;
    };
    Question.prototype.onCreating = function () { };
    Question.prototype.getFirstQuestionToFocus = function (withError) {
        return this.hasInput && (!withError || this.currentErrorCount > 0) ? this : null;
    };
    Question.prototype.getFirstInputElementId = function () {
        return this.inputId;
    };
    Question.prototype.getFirstErrorInputElementId = function () {
        return this.getFirstInputElementId();
    };
    Question.prototype.getProcessedTextValue = function (textValue) {
        var name = textValue.name.toLocaleLowerCase();
        textValue.isExists =
            Object.keys(Question.TextPreprocessorValuesMap).indexOf(name) !== -1 ||
                this[textValue.name] !== undefined;
        textValue.value = this[Question.TextPreprocessorValuesMap[name] || textValue.name];
    };
    Question.prototype.supportComment = function () {
        var prop = this.getPropertyByName("showCommentArea");
        return !prop || prop.visible;
    };
    Question.prototype.supportOther = function () {
        return false;
    };
    Object.defineProperty(Question.prototype, "isRequired", {
        /**
         * Makes the question required. If a respondent skips a required question, the survey displays a validation error.
         * @see requiredIf
         * @see [Data Validation](https://surveyjs.io/form-library/documentation/data-validation)
         */
        get: function () {
            return this.getPropertyValue("isRequired");
        },
        set: function (val) {
            this.setPropertyValue("isRequired", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "requiredIf", {
        /**
         * A Boolean expression. If it evaluates to `true`, this question becomes required.
         *
         * A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
         *
         * Refer to the following help topic for more information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see isRequired
         */
        get: function () {
            return this.getPropertyValue("requiredIf", "");
        },
        set: function (val) {
            this.setPropertyValue("requiredIf", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "showCommentArea", {
        /**
         * Specifies whether to display a comment area. Incompatible with the `showOtherItem` property.
         * @see comment
         * @see commentText
         * @see showOtherItem
         */
        get: function () {
            return this.getPropertyValue("showCommentArea", false);
        },
        set: function (val) {
            if (!this.supportComment())
                return;
            this.setPropertyValue("showCommentArea", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "hasComment", {
        get: function () {
            return this.showCommentArea;
        },
        set: function (val) {
            this.showCommentArea = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "id", {
        /**
         * A value to assign to the `id` attribute of the rendered HTML element. A default `id` is generated automatically.
         */
        get: function () {
            return this.getPropertyValue("id");
        },
        set: function (val) {
            this.setPropertyValue("id", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "ariaTitleId", {
        get: function () {
            return this.id + "_ariaTitle";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "ariaDescriptionId", {
        get: function () {
            return this.id + "_ariaDescription";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "commentId", {
        get: function () {
            return this.id + "_comment";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "showOtherItem", {
        /**
         * Specifies whether to display the "Other" choice item. Incompatible with the `showCommentArea` property.
         *
         * @see otherText
         * @see otherItem
         * @see otherErrorText
         * @see showCommentArea
         * @see [settings.specialChoicesOrder](https://surveyjs.io/form-library/documentation/api-reference/settings#specialChoicesOrder)
         */
        get: function () {
            return this.getPropertyValue("showOtherItem", false);
        },
        set: function (val) {
            if (!this.supportOther() || this.showOtherItem == val)
                return;
            this.setPropertyValue("showOtherItem", val);
            this.hasOtherChanged();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "hasOther", {
        get: function () {
            return this.showOtherItem;
        },
        set: function (val) {
            this.showOtherItem = val;
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.hasOtherChanged = function () { };
    Object.defineProperty(Question.prototype, "requireUpdateCommentValue", {
        get: function () {
            return this.hasComment || this.hasOther;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "isReadOnly", {
        get: function () {
            var isParentReadOnly = !!this.parent && this.parent.isReadOnly;
            var isPareQuestionReadOnly = !!this.parentQuestion && this.parentQuestion.isReadOnly;
            var isSurveyReadOnly = !!this.survey && this.survey.isDisplayMode;
            var callbackVal = !!this.readOnlyCallback && this.readOnlyCallback();
            return this.readOnly || isParentReadOnly || isSurveyReadOnly || isPareQuestionReadOnly || callbackVal;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "isInputReadOnly", {
        get: function () {
            if (this.forceIsInputReadOnly !== undefined) {
                return this.forceIsInputReadOnly;
            }
            return this.isReadOnly || this.isDesignModeV2;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "renderedInputReadOnly", {
        get: function () {
            return this.isInputReadOnly ? "" : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "renderedInputDisabled", {
        get: function () {
            return this.isInputReadOnly ? "" : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "isReadOnlyAttr", {
        get: function () {
            return this.isReadOnly;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "isDisabledAttr", {
        get: function () {
            return this.isDesignModeV2;
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.onReadOnlyChanged = function () {
        this.setPropertyValue("isInputReadOnly", this.isInputReadOnly);
        _super.prototype.onReadOnlyChanged.call(this);
        if (this.isReadOnly) {
            this.clearErrors();
        }
        this.updateQuestionCss();
        this.calcRenderedCommentPlaceholder();
    };
    Object.defineProperty(Question.prototype, "enableIf", {
        /**
         * A Boolean expression. If it evaluates to `false`, this question becomes read-only.
         *
         * A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
         *
         * Refer to the following help topic for more information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see readOnly
         * @see isReadOnly
         */
        get: function () {
            return this.getPropertyValue("enableIf", "");
        },
        set: function (val) {
            this.setPropertyValue("enableIf", val);
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.surveyChoiceItemVisibilityChange = function () { };
    Question.prototype.runCondition = function (values, properties) {
        if (this.isDesignMode)
            return;
        if (!properties)
            properties = {};
        properties["question"] = this;
        this.runConditionCore(values, properties);
        if (!this.isValueChangedDirectly && (!this.isClearValueOnHidden || this.isVisibleInSurvey)) {
            this.defaultValueRunner = this.getDefaultRunner(this.defaultValueRunner, this.defaultValueExpression);
            this.runDefaultValueExpression(this.defaultValueRunner, values, properties);
        }
    };
    Object.defineProperty(Question.prototype, "no", {
        /**
         * A question number or letter (depends on the `questionStartIndex` property of the question container (panel, page, or survey)).
         *
         * When the question number, title, or the entire question is invisible, this property returns an empty string.
         * @see SurveyModel.questionStartIndex
         * @see hideNumber
         * @see titleLocation
         * @see visibleIf
         */
        get: function () {
            return this.getPropertyValue("no");
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.calcNo = function () {
        if (!this.hasTitle || this.hideNumber)
            return "";
        var no = helpers_Helpers.getNumberByIndex(this.visibleIndex, this.getStartIndex());
        if (!!this.survey) {
            no = this.survey.getUpdatedQuestionNo(this, no);
        }
        return no;
    };
    Question.prototype.getStartIndex = function () {
        if (!!this.parent)
            return this.parent.getQuestionStartIndex();
        if (!!this.survey)
            return this.survey.questionStartIndex;
        return "";
    };
    Question.prototype.onSurveyLoad = function () {
        this.isCustomWidgetRequested = false;
        this.fireCallback(this.surveyLoadCallback);
        this.updateValueWithDefaults();
        if (this.isEmpty()) {
            this.initDataFromSurvey();
        }
        this.calcRenderedCommentPlaceholder();
        this.onIndentChanged();
    };
    Question.prototype.onSetData = function () {
        _super.prototype.onSetData.call(this);
        if (!this.survey)
            return;
        this.initDataFromSurvey();
        this.onSurveyValueChanged(this.value);
        this.updateValueWithDefaults();
        this.onIndentChanged();
        this.updateQuestionCss();
        this.updateIsAnswered();
    };
    Question.prototype.initDataFromSurvey = function () {
        if (!!this.data) {
            var val = this.data.getValue(this.getValueName());
            if (!helpers_Helpers.isValueEmpty(val) || !this.isLoadingFromJson) {
                this.updateValueFromSurvey(val);
            }
            this.initCommentFromSurvey();
        }
    };
    Question.prototype.initCommentFromSurvey = function () {
        if (!!this.data && this.requireUpdateCommentValue) {
            this.updateCommentFromSurvey(this.data.getComment(this.getValueName()));
        }
        else {
            this.updateCommentFromSurvey("");
        }
    };
    Question.prototype.runExpression = function (expression) {
        if (!this.survey || !expression)
            return undefined;
        return this.survey.runExpression(expression);
    };
    Object.defineProperty(Question.prototype, "commentAreaRows", {
        get: function () {
            return this.survey && this.survey.commentAreaRows;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "autoGrowComment", {
        get: function () {
            return this.survey && this.survey.autoGrowComment;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "allowResizeComment", {
        get: function () {
            return this.survey && this.survey.allowResizeComment;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "questionValue", {
        get: function () {
            return this.getPropertyValueWithoutDefault("value");
        },
        set: function (val) {
            this.setPropertyValue("value", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "questionComment", {
        get: function () {
            return this.getPropertyValueWithoutDefault("comment");
        },
        set: function (val) {
            this.setPropertyValue("comment", val);
            this.fireCallback(this.commentChangedCallback);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "isValueArray", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "value", {
        /**
         * Gets or sets the question value.
         *
         * The following table illustrates how the value type depends on the question type:
         *
         * | Question type | Value type(s) |
         * | ------------- | ------------- |
         * | Checkboxes | `Array<string \| number>` |
         * | Dropdown | `string` \| `number` |
         * | Dynamic Matrix | `Array<object>` |
         * | Dynamic Panel | `Array<object>` |
         * | Expression | `string` \| `number` \| `boolean` |
         * | File Upload | `File` \| `Array<File>` |
         * | HTML | (no value) |
         * | Image | (no value) |
         * | Image Picker | `Array<string \| number>` |
         * | Long Text | `string` |
         * | Multi-Select Dropdown | `object` |
         * | Multi-Select Matrix | `object` |
         * | Multiple Textboxes | `Array<string>` |
         * | Panel | (no value) |
         * | Radio Button Group | `string` \| `number` |
         * | Ranking | `Array<string \| number>` |
         * | Rating Scale | `number` \| `string` |
         * | Signature | `string` (base64-encoded image) |
         * | Single-Line Input | `string` \| `number` \| `Date` |
         * | Single-Select Matrix | `object` |
         * | Yes/No (Boolean) | `boolean` \| `string` |
         */
        get: function () {
            return this.getValueCore();
        },
        set: function (newValue) {
            this.setNewValue(newValue);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "hasFilteredValue", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Question.prototype.getFilteredValue = function () { return this.value; };
    Question.prototype.getFilteredName = function () { return this.getValueName(); };
    Object.defineProperty(Question.prototype, "valueForSurvey", {
        get: function () {
            return this.valueForSurveyCore(this.value);
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.valueForSurveyCore = function (val) {
        if (!!this.valueToDataCallback) {
            return this.valueToDataCallback(val);
        }
        return val;
    };
    Question.prototype.valueFromDataCore = function (val) {
        if (!!this.valueFromDataCallback) {
            return this.valueFromDataCallback(val);
        }
        return val;
    };
    /**
     * Sets the question's `value` and `comment` properties to `undefined`.
     * @see value
     * @see comment
     */
    Question.prototype.clearValue = function (keepComment) {
        if (this.value !== undefined) {
            this.value = undefined;
        }
        if (!!this.comment && keepComment !== true) {
            this.comment = undefined;
        }
        this.setValueChangedDirectly(false);
    };
    Question.prototype.clearValueOnly = function () {
        this.clearValue(true);
    };
    Question.prototype.unbindValue = function () {
        this.clearValue();
    };
    Question.prototype.createValueCopy = function () {
        return this.getUnbindValue(this.value);
    };
    Question.prototype.initDataUI = function () { };
    Question.prototype.getUnbindValue = function (value) {
        if (this.isValueSurveyElement(value))
            return value;
        return helpers_Helpers.getUnbindValue(value);
    };
    Question.prototype.isValueSurveyElement = function (val) {
        if (!val)
            return false;
        if (Array.isArray(val))
            return val.length > 0 ? this.isValueSurveyElement(val[0]) : false;
        return !!val.getType && !!val.onPropertyChanged;
    };
    Question.prototype.canClearValueAsInvisible = function (reason) {
        if (reason === "onHiddenContainer" && !this.isParentVisible)
            return true;
        if (this.isVisibleInSurvey)
            return false;
        if (!!this.page && this.page.isStartPage)
            return false;
        if (!this.survey)
            return true;
        return !this.survey.hasVisibleQuestionByValueName(this.getValueName());
    };
    Object.defineProperty(Question.prototype, "isParentVisible", {
        /**
         * Returns `true` if a parent element (page or panel) is visible.
         */
        get: function () {
            if (this.parentQuestion && !this.parentQuestion.isVisible)
                return false;
            var parent = this.parent;
            while (parent) {
                if (!parent.isVisible)
                    return false;
                parent = parent.parent;
            }
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.clearValueIfInvisible = function (reason) {
        if (reason === void 0) { reason = "onHidden"; }
        var clearIf = this.getClearIfInvisible();
        if (clearIf === "none")
            return;
        if (reason === "onHidden" && clearIf === "onComplete")
            return;
        if (reason === "onHiddenContainer" && clearIf !== reason)
            return;
        this.clearValueIfInvisibleCore(reason);
    };
    Question.prototype.clearValueIfInvisibleCore = function (reason) {
        if (this.canClearValueAsInvisible(reason)) {
            this.clearValue();
            this.setValueChangedDirectly(undefined);
        }
    };
    Object.defineProperty(Question.prototype, "clearIfInvisible", {
        /**
         * Specifies when to clear the question value if the question becomes invisible.
         *
         * Possible values:
         *
         * - `"default"` (default) - Inherits the setting from the Survey's [`clearInvisibleValues`](https://surveyjs.io/form-library/documentation/surveymodel#clearInvisibleValues) property.
         * - `"onHidden"` - Clears the value when the question becomes invisible. If a question is invisible on startup and has an initial value, this value will be cleared when the survey is complete.
         * - `"onHiddenContainer"` - Clears the value when the question or its container (page or panel) becomes invisible. If a question is invisible on startup and has an initial value, this value will be cleared when the survey is complete.
         * - `"onComplete"` - Clears the value when the survey is complete.
         * - `"none"` - Never clears the value of an invisible question.
         * @see SurveyModel.clearInvisibleValues
         * @see visible
         * @see SurveyModel.onComplete
         */
        get: function () {
            return this.getPropertyValue("clearIfInvisible");
        },
        set: function (val) {
            this.setPropertyValue("clearIfInvisible", val);
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.getClearIfInvisible = function () {
        var res = this.clearIfInvisible;
        if (!!this.survey)
            return this.survey.getQuestionClearIfInvisible(res);
        return res !== "default" ? res : "onComplete";
    };
    Object.defineProperty(Question.prototype, "displayValue", {
        get: function () {
            if (this.isLoadingFromJson)
                return "";
            return this.getDisplayValue(true);
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Returns a display text that corresponds to the question value. For example, if you call this method for a Dropdown question, it returns an item text instead of an item value.
     * @param keysAsText Applies when the question value is an object (in Matrix, Multiple Text, and similar questions). Pass `true` if not only values in the object should be display texts, but also keys. Default value: `false`.
     * @param value Specify this parameter to get a display text for a specific value, not for the current question value. If the question value is an object, this parameter should be a similar object.
     */
    Question.prototype.getDisplayValue = function (keysAsText, value) {
        if (value === void 0) { value = undefined; }
        var res = this.calcDisplayValue(keysAsText, value);
        if (this.survey) {
            res = this.survey.getQuestionDisplayValue(this, res);
        }
        return !!this.displayValueCallback ? this.displayValueCallback(res) : res;
    };
    Question.prototype.calcDisplayValue = function (keysAsText, value) {
        if (value === void 0) { value = undefined; }
        if (this.customWidget) {
            var res = this.customWidget.getDisplayValue(this, value);
            if (res)
                return res;
        }
        value = value == undefined ? this.createValueCopy() : value;
        if (this.isValueEmpty(value, !this.allowSpaceAsAnswer))
            return this.getDisplayValueEmpty();
        return this.getDisplayValueCore(keysAsText, value);
    };
    Question.prototype.getDisplayValueCore = function (keyAsText, value) {
        return value;
    };
    Question.prototype.getDisplayValueEmpty = function () {
        return "";
    };
    Object.defineProperty(Question.prototype, "defaultValue", {
        /**
         * A default value for the question. Ignored for question types that cannot have a [value](https://surveyjs.io/form-library/documentation/question#value) (for example, HTML).
         *
         * The default value is used as a question value in the following cases:
         *
         * - While the survey is being loaded from JSON.
         * - The question is just added to the survey and does not yet have an answer.
         * - The respondent left the answer empty.
         * @see defaultValueExpression
         */
        get: function () {
            return this.getPropertyValue("defaultValue");
        },
        set: function (val) {
            if (this.isValueExpression(val)) {
                this.defaultValueExpression = val.substring(1);
                return;
            }
            this.setPropertyValue("defaultValue", this.convertDefaultValue(val));
            this.updateValueWithDefaults();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "defaultValueExpression", {
        /**
         * An expression used to calculate the [defaultValue](https://surveyjs.io/form-library/documentation/question#defaultValue).
         *
         * This expression applies until the question [value](https://surveyjs.io/form-library/documentation/question#value) is specified by an end user or programmatically.
         *
         * An expression can reference other questions as follows:
         *
         * - `{other_question_name}`
         * - `{panel.other_question_name}` (to access questions inside the same dynamic panel)
         * - `{row.other_question_name}` (to access questions inside the same dynamic matrix or multi-column dropdown)
         *
         * An expression can also include built-in and custom functions for advanced calculations. For example, if the `defaultValue` should be today's date, set the `defaultValueExpression` to `"today()"`, and the corresponding built-in function will be executed each time the survey is loaded. Refer to the following help topic for more information: [Built-In Functions](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#built-in-functions).
         *
         * [View Demo](https://surveyjs.io/form-library/examples/specify-default-question-value-dynamically (linkStyle))
         * @see defaultValue
         * @see setValueExpression
         */
        get: function () {
            return this.getPropertyValue("defaultValueExpression");
        },
        set: function (val) {
            this.setPropertyValue("defaultValueExpression", val);
            this.defaultValueRunner = undefined;
            this.updateValueWithDefaults();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "resetValueIf", {
        /**
         * A Boolean expression. If it evaluates to `true`, the question value is reset to [default](#defaultValue).
         *
         * A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
         *
         * [Expressions](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#expressions (linkStyle))
         * @see setValueIf
         */
        get: function () {
            return this.getPropertyValue("resetValueIf");
        },
        set: function (val) {
            this.setPropertyValue("resetValueIf", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "setValueIf", {
        /**
         * A Boolean expression. If it evaluates to `true`, the question value is set to a value calculated using the [`setValueExpression`](#setValueExpression).
         *
         * A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
         *
         * [Expressions](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#expressions (linkStyle))
         * @see resetValueIf
         */
        get: function () {
            return this.getPropertyValue("setValueIf");
        },
        set: function (val) {
            this.setPropertyValue("setValueIf", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "setValueExpression", {
        /**
         * An expression used to calculate the question value.
         *
         * You can use `setValueExpression` as a standalone property or in conjunction with the [`setValueIf`](#setValueIf) expression, in which case the calculated question value applies only when `setValueIf` evaluates to `true`.
         *
         * [Expressions](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#expressions (linkStyle))
         * @see defaultValueExpression
         * @see resetValueIf
         */
        get: function () {
            return this.getPropertyValue("setValueExpression");
        },
        set: function (val) {
            this.setPropertyValue("setValueExpression", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "resizeStyle", {
        get: function () {
            return this.allowResizeComment ? "both" : "none";
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Returns the question value as an object in which the question name, title, value, and other parameters are stored as individual properties.
     *
     * If the question can have more than one value (Matrix, Multiple Text), the object enables the `isNode` flag and stores information about these values in the `data` property. Refer to the following help topic for more information: [Access Full Survey Results](https://surveyjs.io/form-library/documentation/handle-survey-results-access#access-full-survey-results).
     *
     * Pass an object with the `includeEmpty` property set to `false` if you want to skip empty answers.
     */
    Question.prototype.getPlainData = function (options) {
        var _this = this;
        if (!options) {
            options = { includeEmpty: true, includeQuestionTypes: false };
        }
        if (options.includeEmpty || !this.isEmpty()) {
            var questionPlainData = {
                name: this.name,
                title: this.locTitle.renderedHtml,
                value: this.value,
                displayValue: this.displayValue,
                isNode: false,
                getString: function (val) {
                    return typeof val === "object" ? JSON.stringify(val) : val;
                },
            };
            if (options.includeQuestionTypes === true) {
                questionPlainData.questionType = this.getType();
            }
            (options.calculations || []).forEach(function (calculation) {
                questionPlainData[calculation.propertyName] = _this.getPlainDataCalculatedValue(calculation.propertyName);
            });
            if (this.hasComment) {
                questionPlainData.isNode = true;
                questionPlainData.data = [
                    {
                        name: 0,
                        isComment: true,
                        title: "Comment",
                        value: settings.commentSuffix,
                        displayValue: this.comment,
                        getString: function (val) {
                            return typeof val === "object" ? JSON.stringify(val) : val;
                        },
                        isNode: false,
                    },
                ];
            }
            return questionPlainData;
        }
        return undefined;
    };
    Question.prototype.getPlainDataCalculatedValue = function (propName) {
        return this[propName];
    };
    Object.defineProperty(Question.prototype, "correctAnswer", {
        /**
         * A correct answer to this question. Specify this property if you want to [create a quiz](https://surveyjs.io/form-library/documentation/design-survey-create-a-quiz).
         * @see SurveyModel.getCorrectAnswerCount
         * @see SurveyModel.getInCorrectAnswerCount
         */
        get: function () {
            return this.getPropertyValue("correctAnswer");
        },
        set: function (val) {
            this.setPropertyValue("correctAnswer", this.convertDefaultValue(val));
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.convertDefaultValue = function (val) {
        return val;
    };
    Object.defineProperty(Question.prototype, "quizQuestionCount", {
        /**
         * The number of quiz questions. A question counts if it is visible, has an input field, and specifies `correctAnswer`.
         * @see [Create a Quiz](https://surveyjs.io/form-library/documentation/design-survey-create-a-quiz)
         * @see correctAnswer
         * @see SurveyModel.getQuizQuestions
         */
        get: function () {
            if (this.isVisible &&
                this.hasInput &&
                !this.isValueEmpty(this.correctAnswer))
                return this.getQuizQuestionCount();
            return 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "correctAnswerCount", {
        get: function () {
            if (!this.isEmpty() && !this.isValueEmpty(this.correctAnswer))
                return this.getCorrectAnswerCount();
            return 0;
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.getQuizQuestionCount = function () {
        return 1;
    };
    Question.prototype.getCorrectAnswerCount = function () {
        return this.checkIfAnswerCorrect() ? 1 : 0;
    };
    Question.prototype.checkIfAnswerCorrect = function () {
        var isEqual = helpers_Helpers.isTwoValueEquals(this.value, this.correctAnswer, this.getAnswerCorrectIgnoreOrder(), settings.comparator.caseSensitive, true);
        var correct = isEqual ? 1 : 0;
        var options = { result: isEqual, correctAnswer: correct, correctAnswers: correct, incorrectAnswers: this.quizQuestionCount - correct };
        if (!!this.survey) {
            this.survey.onCorrectQuestionAnswer(this, options);
        }
        return options.result;
    };
    Question.prototype.getAnswerCorrectIgnoreOrder = function () { return false; };
    /**
    * Returns `true` if a question answer matches the `correctAnswer` property value.
    *
    * [View Demo](https://surveyjs.io/form-library/examples/create-a-scored-quiz (linkStyle))
    * @see correctAnswer
    * @see SurveyModel.getQuizQuestions
    */
    Question.prototype.isAnswerCorrect = function () {
        return this.correctAnswerCount == this.quizQuestionCount;
    };
    Question.prototype.updateValueWithDefaults = function () {
        if (this.isLoadingFromJson || (!this.isDesignMode && this.isDefaultValueEmpty()))
            return;
        if (!this.isDesignMode && !this.isEmpty())
            return;
        if (this.isEmpty() && this.isDefaultValueEmpty())
            return;
        if (this.isClearValueOnHidden && !this.isVisible)
            return;
        if (this.isDesignMode && this.isContentElement && this.isDefaultValueEmpty())
            return;
        this.setDefaultValue();
    };
    Object.defineProperty(Question.prototype, "isValueDefault", {
        get: function () {
            return !this.isEmpty() && (this.isTwoValueEquals(this.defaultValue, this.value) || !this.isValueChangedDirectly && !!this.defaultValueExpression);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "isClearValueOnHidden", {
        get: function () {
            var clearIf = this.getClearIfInvisible();
            if (clearIf === "none" || clearIf === "onComplete")
                return false;
            return clearIf === "onHidden" || clearIf === "onHiddenContainer";
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.getQuestionFromArray = function (name, index) {
        return null;
    };
    Question.prototype.getDefaultValue = function () {
        return this.defaultValue;
    };
    Question.prototype.isDefaultValueEmpty = function () {
        return !this.defaultValueExpression && this.isValueEmpty(this.defaultValue, !this.allowSpaceAsAnswer);
    };
    Question.prototype.getDefaultRunner = function (runner, expression) {
        if (!runner && !!expression) {
            runner = this.createExpressionRunner(expression);
        }
        if (!!runner) {
            runner.expression = expression;
        }
        return runner;
    };
    Question.prototype.setDefaultValue = function () {
        var _this = this;
        this.setDefaultValueCore(function (val) {
            if (!_this.isTwoValueEquals(_this.value, val)) {
                _this.value = val;
            }
        });
    };
    Question.prototype.setDefaultValueCore = function (func) {
        this.defaultValueRunner = this.getDefaultRunner(this.defaultValueRunner, this.defaultValueExpression);
        this.setValueAndRunExpression(this.defaultValueRunner, this.getUnbindValue(this.defaultValue), function (val) { return func(val); });
    };
    Question.prototype.isValueExpression = function (val) {
        return !!val && typeof val == "string" && val.length > 0 && val[0] == "=";
    };
    Question.prototype.setValueAndRunExpression = function (runner, defaultValue, setFunc, values, properties) {
        var _this = this;
        if (values === void 0) { values = null; }
        if (properties === void 0) { properties = null; }
        var func = function (val) {
            _this.runExpressionSetValueCore(val, setFunc);
        };
        if (!this.runDefaultValueExpression(runner, values, properties, func)) {
            func(defaultValue);
        }
    };
    Question.prototype.convertFuncValuetoQuestionValue = function (val) {
        return helpers_Helpers.convertValToQuestionVal(val);
    };
    Question.prototype.runExpressionSetValueCore = function (val, setFunc) {
        setFunc(this.convertFuncValuetoQuestionValue(val));
    };
    Question.prototype.runExpressionSetValue = function (val) {
        var _this = this;
        this.runExpressionSetValueCore(val, function (val) {
            if (!_this.isTwoValueEquals(_this.value, val)) {
                _this.value = val;
            }
        });
    };
    Question.prototype.runDefaultValueExpression = function (runner, values, properties, setFunc) {
        var _this = this;
        if (values === void 0) { values = null; }
        if (properties === void 0) { properties = null; }
        if (!runner || !this.data)
            return false;
        if (!setFunc) {
            setFunc = function (val) {
                _this.runExpressionSetValue(val);
            };
        }
        if (!values)
            values = this.defaultValueExpression ? this.data.getFilteredValues() : {};
        if (!properties)
            properties = this.defaultValueExpression ? this.data.getFilteredProperties() : {};
        if (!!runner && runner.canRun) {
            runner.onRunComplete = function (res) {
                if (res == undefined)
                    res = _this.defaultValue;
                _this.isChangingViaDefaultValue = true;
                setFunc(res);
                _this.isChangingViaDefaultValue = false;
            };
            runner.run(values, properties);
        }
        return true;
    };
    Object.defineProperty(Question.prototype, "comment", {
        /**
         * A comment to the selected question value. Enable the `showCommentArea` property to allow users to leave comments.
         * @see showCommentArea
         * @see commentText
         */
        get: function () {
            return this.getQuestionComment();
        },
        set: function (newValue) {
            if (!!newValue) {
                var trimmedValue = newValue.toString().trim();
                if (trimmedValue !== newValue) {
                    newValue = trimmedValue;
                    if (newValue === this.comment) {
                        this.setPropertyValueDirectly("comment", newValue);
                    }
                }
            }
            if (this.comment == newValue)
                return;
            this.setQuestionComment(newValue);
            this.updateCommentElements();
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.getCommentAreaCss = function (isOther) {
        if (isOther === void 0) { isOther = false; }
        return new CssClassBuilder()
            .append("form-group", isOther)
            .append(this.cssClasses.formGroup, !isOther)
            .append(this.cssClasses.commentArea)
            .toString();
    };
    Question.prototype.getQuestionComment = function () {
        return this.questionComment;
    };
    Question.prototype.setQuestionComment = function (newValue) {
        this.setNewComment(newValue);
    };
    /**
     * Returns `true` if the question value is an empty string, array, or object or if it equals `undefined` or `null`.
     */
    Question.prototype.isEmpty = function () {
        return this.isValueEmpty(this.value, !this.allowSpaceAsAnswer);
    };
    Object.defineProperty(Question.prototype, "isAnswered", {
        get: function () {
            return this.getPropertyValue("isAnswered");
        },
        set: function (val) {
            this.setPropertyValue("isAnswered", val);
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.updateIsAnswered = function () {
        var oldVal = this.isAnswered;
        this.setPropertyValue("isAnswered", this.getIsAnswered());
        if (oldVal !== this.isAnswered) {
            this.updateQuestionCss();
        }
    };
    Question.prototype.getIsAnswered = function () {
        return !this.isEmpty();
    };
    Object.defineProperty(Question.prototype, "validators", {
        /**
         * Question validators.
         * @see [Data Validation](https://surveyjs.io/form-library/documentation/data-validation)
         */
        get: function () {
            return this.getPropertyValue("validators");
        },
        set: function (val) {
            this.setPropertyValue("validators", val);
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.getValidators = function () {
        return this.validators;
    };
    Question.prototype.getSupportedValidators = function () {
        var res = [];
        var className = this.getType();
        while (!!className) {
            var classValidators = settings.supportedValidators[className];
            if (!!classValidators) {
                for (var i = classValidators.length - 1; i >= 0; i--) {
                    res.splice(0, 0, classValidators[i]);
                }
            }
            var classInfo = Serializer.findClass(className);
            className = classInfo.parentName;
        }
        return res;
    };
    Question.prototype.addConditionObjectsByContext = function (objects, context) {
        objects.push({
            name: this.getFilteredName(),
            text: this.processedTitle,
            question: this,
        });
    };
    /**
     * Returns an array of questions nested within the current question. Use this method to obtain questions within [Multiple Text](https://surveyjs.io/form-library/documentation/api-reference/multiple-text-entry-question-model), [Dynamic Panel](https://surveyjs.io/form-library/documentation/api-reference/dynamic-panel-model), and [Matrix](https://surveyjs.io/form-library/documentation/api-reference/matrix-table-question-model)-like questions.
     * @param visibleOnly A Boolean value that specifies whether to include only visible nested questions.
     * @returns An array of nested questions.
     */
    Question.prototype.getNestedQuestions = function (visibleOnly) {
        if (visibleOnly === void 0) { visibleOnly = false; }
        var res = [];
        this.collectNestedQuestions(res, visibleOnly);
        if (res.length === 1 && res[0] === this)
            return [];
        return res;
    };
    Question.prototype.collectNestedQuestions = function (questions, visibleOnly) {
        if (visibleOnly === void 0) { visibleOnly = false; }
        if (visibleOnly && !this.isVisible)
            return;
        this.collectNestedQuestionsCore(questions, visibleOnly);
    };
    Question.prototype.collectNestedQuestionsCore = function (questions, visibleOnly) {
        questions.push(this);
    };
    Question.prototype.getConditionJson = function (operator, path) {
        if (operator === void 0) { operator = null; }
        if (path === void 0) { path = null; }
        var json = new jsonobject_JsonObject().toJsonObject(this);
        json["type"] = this.getType();
        return json;
    };
    Question.prototype.hasErrors = function (fireCallback, rec) {
        if (fireCallback === void 0) { fireCallback = true; }
        if (rec === void 0) { rec = null; }
        var errors = this.checkForErrors(!!rec && rec.isOnValueChanged === true);
        if (fireCallback) {
            if (!!this.survey) {
                this.survey.beforeSettingQuestionErrors(this, errors);
            }
            this.errors = errors;
            if (this.errors !== errors) {
                this.errors.forEach(function (er) { return er.locText.strChanged(); });
            }
        }
        this.updateContainsErrors();
        if (this.isCollapsed && rec && fireCallback && errors.length > 0) {
            this.expand();
        }
        return errors.length > 0;
    };
    /**
     * Validates this question and returns `false` if the validation fails.
     * @param fireCallback *(Optional)* Pass `false` if you do not want to show validation errors in the UI.
     * @see [Data Validation](https://surveyjs.io/form-library/documentation/data-validation)
     */
    Question.prototype.validate = function (fireCallback, rec) {
        if (fireCallback === void 0) { fireCallback = true; }
        if (rec === void 0) { rec = null; }
        if (!!rec && rec.isOnValueChanged) {
            if (!!this.parent) {
                this.parent.validateContainerOnly();
            }
        }
        return !this.hasErrors(fireCallback, rec);
    };
    Object.defineProperty(Question.prototype, "currentErrorCount", {
        get: function () {
            return this.errors.length;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "requiredText", {
        /**
         * Returns a character or text string that indicates a required question.
         * @see SurveyModel.requiredText
         * @see isRequired
         */
        get: function () {
            return this.survey != null && this.isRequired
                ? this.survey.requiredText
                : "";
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.addError = function (error) {
        if (!error)
            return;
        var newError = null;
        if (typeof error === "string" || error instanceof String) {
            newError = this.addCustomError(error);
        }
        else {
            newError = error;
        }
        this.errors.push(newError);
    };
    Question.prototype.addCustomError = function (error) {
        return new CustomError(error, this.survey);
    };
    Question.prototype.removeError = function (error) {
        if (!error)
            return;
        var errors = this.errors;
        var index = errors.indexOf(error);
        if (index !== -1)
            errors.splice(index, 1);
    };
    Question.prototype.checkForErrors = function (isOnValueChanged) {
        var qErrors = new Array();
        if (this.isVisible && this.canCollectErrors()) {
            this.collectErrors(qErrors, isOnValueChanged);
        }
        return qErrors;
    };
    Question.prototype.canCollectErrors = function () {
        return !this.isReadOnly || settings.readOnly.enableValidation;
    };
    Question.prototype.collectErrors = function (qErrors, isOnValueChanged) {
        this.onCheckForErrors(qErrors, isOnValueChanged);
        if (qErrors.length > 0 || !this.canRunValidators(isOnValueChanged))
            return;
        var errors = this.runValidators();
        if (errors.length > 0) {
            //validators may change the question value.
            qErrors.length = 0;
            for (var i = 0; i < errors.length; i++) {
                qErrors.push(errors[i]);
            }
        }
        if (this.survey && qErrors.length == 0) {
            var error = this.fireSurveyValidation();
            if (error) {
                qErrors.push(error);
            }
        }
    };
    Question.prototype.canRunValidators = function (isOnValueChanged) {
        return true;
    };
    Question.prototype.fireSurveyValidation = function () {
        if (this.validateValueCallback)
            return this.validateValueCallback();
        return this.survey ? this.survey.validateQuestion(this) : null;
    };
    Question.prototype.onCheckForErrors = function (errors, isOnValueChanged) {
        var _this = this;
        if ((!isOnValueChanged || this.isOldAnswered) && this.hasRequiredError()) {
            var err = new AnswerRequiredError(this.requiredErrorText, this);
            err.onUpdateErrorTextCallback = function (err) { err.text = _this.requiredErrorText; };
            errors.push(err);
        }
        if (!this.isEmpty() && this.customWidget) {
            var text = this.customWidget.validate(this);
            if (!!text) {
                errors.push(this.addCustomError(text));
            }
        }
    };
    Question.prototype.hasRequiredError = function () {
        return this.isRequired && this.isEmpty();
    };
    Object.defineProperty(Question.prototype, "isRunningValidators", {
        get: function () {
            return this.getIsRunningValidators();
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.getIsRunningValidators = function () {
        return this.isRunningValidatorsValue;
    };
    Question.prototype.runValidators = function () {
        var _this = this;
        if (!!this.validatorRunner) {
            this.validatorRunner.onAsyncCompleted = null;
        }
        this.validatorRunner = new ValidatorRunner();
        this.isRunningValidatorsValue = true;
        this.validatorRunner.onAsyncCompleted = function (errors) {
            _this.doOnAsyncCompleted(errors);
        };
        return this.validatorRunner.run(this);
    };
    Question.prototype.doOnAsyncCompleted = function (errors) {
        for (var i = 0; i < errors.length; i++) {
            this.errors.push(errors[i]);
        }
        this.isRunningValidatorsValue = false;
        this.raiseOnCompletedAsyncValidators();
    };
    Question.prototype.raiseOnCompletedAsyncValidators = function () {
        if (!!this.onCompletedAsyncValidators && !this.isRunningValidators) {
            this.onCompletedAsyncValidators(this.getAllErrors().length > 0);
            this.onCompletedAsyncValidators = null;
        }
    };
    Question.prototype.setNewValue = function (newValue) {
        if (this.isNewValueEqualsToValue(newValue))
            return;
        if (!this.checkIsValueCorrect(newValue))
            return;
        this.isOldAnswered = this.isAnswered;
        this.isSettingQuestionValue = true;
        this.setNewValueInData(newValue);
        this.allowNotifyValueChanged && this.onValueChanged();
        this.isSettingQuestionValue = false;
        if (this.isAnswered !== this.isOldAnswered) {
            this.updateQuestionCss();
        }
        this.isOldAnswered = undefined;
        if (this.parent) {
            this.parent.onQuestionValueChanged(this);
        }
    };
    Question.prototype.checkIsValueCorrect = function (val) {
        var res = this.isValueEmpty(val, !this.allowSpaceAsAnswer) || this.isNewValueCorrect(val);
        if (!res) {
            ConsoleWarnings.inCorrectQuestionValue(this.name, val);
        }
        return res;
    };
    Question.prototype.isNewValueCorrect = function (val) {
        return true;
    };
    Question.prototype.isNewValueEqualsToValue = function (newValue) {
        var val = this.value;
        if (!this.isTwoValueEquals(newValue, val, false, false))
            return false;
        var isObj = newValue === val && !!val && (Array.isArray(val) || typeof val === "object");
        return !isObj;
    };
    Question.prototype.isTextValue = function () {
        return false;
    };
    Question.prototype.getIsInputTextUpdate = function () {
        return !!this.survey ? this.survey.isUpdateValueTextOnTyping : false;
    };
    Object.defineProperty(Question.prototype, "requireStrictCompare", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Question.prototype.getDataLocNotification = function () {
        return this.isInputTextUpdate ? "text" : false;
    };
    Object.defineProperty(Question.prototype, "isInputTextUpdate", {
        get: function () {
            return this.getIsInputTextUpdate() && this.isTextValue();
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.setNewValueInData = function (newValue) {
        newValue = this.valueToData(newValue);
        if (!this.isValueChangedInSurvey) {
            this.setValueCore(newValue);
        }
    };
    Question.prototype.getValueCore = function () {
        return this.questionValue;
    };
    Question.prototype.setValueCore = function (newValue) {
        this.setQuestionValue(newValue);
        if (this.data != null && this.canSetValueToSurvey()) {
            newValue = this.valueForSurvey;
            this.data.setValue(this.getValueName(), newValue, this.getDataLocNotification(), this.allowNotifyValueChanged, this.name);
        }
        this.isMouseDown = false;
    };
    Question.prototype.canSetValueToSurvey = function () {
        return true;
    };
    Question.prototype.valueFromData = function (val) { return val; };
    Question.prototype.valueToData = function (val) { return val; };
    Question.prototype.convertToCorrectValue = function (val) { return val; };
    Question.prototype.onValueChanged = function () { };
    Question.prototype.onMouseDown = function () {
        this.isMouseDown = true;
    };
    Question.prototype.setNewComment = function (newValue) {
        if (this.questionComment === newValue)
            return;
        this.questionComment = newValue;
        this.setCommentIntoData(newValue);
    };
    Question.prototype.setCommentIntoData = function (newValue) {
        if (this.data != null) {
            this.data.setComment(this.getValueName(), newValue, this.getIsInputTextUpdate() ? "text" : false);
        }
    };
    Question.prototype.getValidName = function (name) {
        return makeNameValid(name);
    };
    //IQuestion
    Question.prototype.updateValueFromSurvey = function (newValue, clearData) {
        var _this = this;
        if (clearData === void 0) { clearData = false; }
        newValue = this.getUnbindValue(newValue);
        newValue = this.valueFromDataCore(newValue);
        if (!this.checkIsValueCorrect(newValue))
            return;
        var isEmpty = this.isValueEmpty(newValue);
        if (!isEmpty && this.defaultValueExpression) {
            this.setDefaultValueCore(function (val) {
                _this.updateValueFromSurveyCore(newValue, _this.isTwoValueEquals(newValue, val));
            });
        }
        else {
            this.updateValueFromSurveyCore(newValue, this.data !== this.getSurvey());
            if (clearData && isEmpty) {
                this.isValueChangedDirectly = false;
            }
        }
        this.updateDependedQuestions();
        this.updateIsAnswered();
    };
    Question.prototype.updateValueFromSurveyCore = function (newValue, viaDefaultVal) {
        this.isChangingViaDefaultValue = viaDefaultVal;
        this.setQuestionValue(this.valueFromData(newValue));
        this.isChangingViaDefaultValue = false;
    };
    Question.prototype.updateCommentFromSurvey = function (newValue) {
        this.questionComment = newValue;
    };
    Question.prototype.onChangeQuestionValue = function (newValue) { };
    Question.prototype.setValueChangedDirectly = function (val) {
        this.isValueChangedDirectly = val;
        if (!!this.setValueChangedDirectlyCallback) {
            this.setValueChangedDirectlyCallback(val);
        }
    };
    Question.prototype.setQuestionValue = function (newValue, updateIsAnswered) {
        if (updateIsAnswered === void 0) { updateIsAnswered = true; }
        newValue = this.convertToCorrectValue(newValue);
        var isEqual = this.isTwoValueEquals(this.questionValue, newValue);
        if (!isEqual && !this.isChangingViaDefaultValue && !this.isParentChangingViaDefaultValue) {
            this.setValueChangedDirectly(true);
        }
        this.questionValue = newValue;
        if (!isEqual) {
            this.onChangeQuestionValue(newValue);
        }
        !isEqual && this.allowNotifyValueChanged &&
            this.fireCallback(this.valueChangedCallback);
        if (updateIsAnswered)
            this.updateIsAnswered();
    };
    Object.defineProperty(Question.prototype, "isParentChangingViaDefaultValue", {
        get: function () {
            var _a;
            return ((_a = this.data) === null || _a === void 0 ? void 0 : _a.isChangingViaDefaultValue) === true;
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.onSurveyValueChanged = function (newValue) { };
    Question.prototype.setVisibleIndex = function (val) {
        if (!this.isVisible ||
            (!this.hasTitle && !settings.numbering.includeQuestionsWithHiddenTitle) ||
            (this.hideNumber && !settings.numbering.includeQuestionsWithHiddenNumber)) {
            val = -1;
        }
        this.setPropertyValue("visibleIndex", val);
        this.setPropertyValue("no", this.calcNo());
        return val < 0 ? 0 : 1;
    };
    Question.prototype.removeElement = function (element) {
        return false;
    };
    Question.prototype.supportGoNextPageAutomatic = function () {
        return false;
    };
    Question.prototype.supportGoNextPageError = function () {
        return true;
    };
    /**
     * Removes values that cannot be assigned to this question, for example, choices unlisted in the `choices` array.
     *
     * Call this method after you assign new question values in code to ensure that they are acceptable.
     *
     * > This method does not remove values that fail validation. Call the `validate()` method to validate newly assigned values.
     *
     * @see validate
     */
    Question.prototype.clearIncorrectValues = function () { };
    Question.prototype.clearOnDeletingContainer = function () { };
    /**
     * Empties the `errors` array.
     * @see errors
     */
    Question.prototype.clearErrors = function () {
        this.errors = [];
    };
    Question.prototype.clearUnusedValues = function () { };
    Question.prototype.onAnyValueChanged = function (name, questionName) { };
    Question.prototype.checkBindings = function (valueName, value) {
        if (this.bindings.isEmpty() || !this.data)
            return;
        var props = this.bindings.getPropertiesByValueName(valueName);
        for (var i = 0; i < props.length; i++) {
            var propName = props[i];
            if (this.isValueEmpty(value) && helpers_Helpers.isNumber(this[propName])) {
                value = 0;
            }
            this[propName] = value;
        }
    };
    Question.prototype.getComponentName = function () {
        return RendererFactory.Instance.getRendererByQuestion(this);
    };
    Question.prototype.isDefaultRendering = function () {
        return (!!this.customWidget ||
            this.getComponentName() === "default");
    };
    //ISurveyErrorOwner
    Question.prototype.getErrorCustomText = function (text, error) {
        if (!!this.survey)
            return this.survey.getSurveyErrorCustomText(this, text, error);
        return text;
    };
    //IValidatorOwner
    Question.prototype.getValidatorTitle = function () {
        return null;
    };
    Object.defineProperty(Question.prototype, "validatedValue", {
        get: function () {
            return this.value;
        },
        set: function (val) {
            this.value = val;
        },
        enumerable: false,
        configurable: true
    });
    Question.prototype.getAllValues = function () {
        return !!this.data ? this.data.getAllValues() : null;
    };
    Question.prototype.processPopupVisiblilityChanged = function (popupModel, visible) {
        this.survey.processPopupVisiblityChanged(this, popupModel, visible);
    };
    Question.prototype.processOpenDropdownMenu = function (options) {
        this.survey.processOpenDropdownMenu(this, options);
    };
    Question.prototype.onTextKeyDownHandler = function (event) {
        if (event.keyCode === 13) {
            this.survey.questionEditFinishCallback(this, event);
        }
    };
    Question.prototype.transformToMobileView = function () { };
    Question.prototype.transformToDesktopView = function () { };
    Question.prototype.needResponsiveWidth = function () {
        return false;
    };
    //responsiveness methods
    Question.prototype.supportResponsiveness = function () {
        return false;
    };
    Question.prototype.needResponsiveness = function () {
        return this.supportResponsiveness() && this.isDefaultV2Theme && !this.isDesignMode;
    };
    Question.prototype.checkForResponsiveness = function (el) {
        var _this = this;
        if (this.needResponsiveness()) {
            if (this.isCollapsed) {
                var onStateChanged = function () {
                    if (_this.isExpanded) {
                        _this.initResponsiveness(el);
                        _this.unregisterPropertyChangedHandlers(["state"], "for-responsiveness");
                    }
                };
                this.registerPropertyChangedHandlers(["state"], onStateChanged, "for-responsiveness");
            }
            else {
                this.initResponsiveness(el);
            }
        }
    };
    Question.prototype.getObservedElementSelector = function () {
        return ".sd-scrollable-container";
    };
    Question.prototype.onMobileChanged = function () {
        this.onMobileChangedCallback && this.onMobileChangedCallback();
    };
    Question.prototype.triggerResponsiveness = function (hard) {
        if (hard === void 0) { hard = true; }
        if (this.triggerResponsivenessCallback) {
            this.triggerResponsivenessCallback(hard);
        }
    };
    Question.prototype.initResponsiveness = function (el) {
        var _this = this;
        this.destroyResizeObserver();
        if (!!el && this.isDefaultRendering()) {
            var scrollableSelector_1 = this.getObservedElementSelector();
            if (!scrollableSelector_1)
                return;
            var defaultRootEl = el.querySelector(scrollableSelector_1);
            if (!defaultRootEl)
                return;
            var isProcessed_1 = false;
            var requiredWidth_1 = undefined;
            this.triggerResponsivenessCallback = function (hard) {
                if (hard) {
                    requiredWidth_1 = undefined;
                    _this.renderAs = "default";
                    isProcessed_1 = false;
                }
                var callback = function () {
                    var rootEl = el.querySelector(scrollableSelector_1);
                    if (!requiredWidth_1 && _this.isDefaultRendering()) {
                        requiredWidth_1 = rootEl.scrollWidth;
                    }
                    if (isProcessed_1 || !isContainerVisible(rootEl)) {
                        isProcessed_1 = false;
                    }
                    else {
                        isProcessed_1 = _this.processResponsiveness(requiredWidth_1, getElementWidth(rootEl));
                    }
                };
                if (hard) {
                    setTimeout(callback, 1);
                }
                else {
                    callback();
                }
            };
            this.resizeObserver = new ResizeObserver(function (entries) {
                DomWindowHelper.requestAnimationFrame(function () {
                    _this.triggerResponsiveness(false);
                });
            });
            this.onMobileChangedCallback = function () {
                setTimeout(function () {
                    var rootEl = el.querySelector(scrollableSelector_1);
                    _this.processResponsiveness(requiredWidth_1, getElementWidth(rootEl));
                }, 0);
            };
            this.resizeObserver.observe(el);
        }
    };
    Question.prototype.getCompactRenderAs = function () {
        return "default";
    };
    Question.prototype.getDesktopRenderAs = function () {
        return "default";
    };
    Question.prototype.onBeforeSetCompactRenderer = function () { };
    Question.prototype.onBeforeSetDesktopRenderer = function () { };
    Question.prototype.processResponsiveness = function (requiredWidth, availableWidth) {
        availableWidth = Math.round(availableWidth);
        if (Math.abs(requiredWidth - availableWidth) > 2) {
            var oldRenderAs = this.renderAs;
            if (requiredWidth > availableWidth) {
                this.onBeforeSetCompactRenderer();
                this.renderAs = this.getCompactRenderAs();
            }
            else {
                this.onBeforeSetDesktopRenderer();
                this.renderAs = this.getDesktopRenderAs();
            }
            return oldRenderAs !== this.renderAs;
        }
        return false;
    };
    Question.prototype.destroyResizeObserver = function () {
        if (!!this.resizeObserver) {
            this.resizeObserver.disconnect();
            this.resizeObserver = undefined;
            this.onMobileChangedCallback = undefined;
            this.triggerResponsivenessCallback = undefined;
            this.renderAs = this.getDesktopRenderAs();
        }
    };
    Question.prototype.dispose = function () {
        _super.prototype.dispose.call(this);
        this.resetDependedQuestions();
        this.destroyResizeObserver();
    };
    Question.prototype.resetDependedQuestions = function () {
        for (var i = 0; i < this.dependedQuestions.length; i++) {
            this.dependedQuestions[i].resetDependedQuestion();
        }
    };
    Object.defineProperty(Question.prototype, "isNewA11yStructure", {
        //a11y
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "ariaLabel", {
        get: function () {
            if (this.isNewA11yStructure)
                return null;
            return this.locTitle.renderedHtml;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "ariaRole", {
        get: function () {
            if (this.isNewA11yStructure)
                return null;
            return "textbox";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "ariaRequired", {
        get: function () {
            if (this.isNewA11yStructure)
                return null;
            return this.isRequired ? "true" : "false";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "ariaInvalid", {
        get: function () {
            if (this.isNewA11yStructure)
                return null;
            return this.hasCssError() ? "true" : "false";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "ariaLabelledBy", {
        get: function () {
            if (this.isNewA11yStructure)
                return null;
            if (this.hasTitle) {
                return this.ariaTitleId;
            }
            else {
                return null;
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "ariaDescribedBy", {
        get: function () {
            if (this.isNewA11yStructure)
                return null;
            if (this.hasTitle) {
                return this.ariaDescriptionId;
            }
            else {
                return null;
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "ariaErrormessage", {
        get: function () {
            if (this.isNewA11yStructure)
                return null;
            return this.hasCssError() ? this.id + "_errors" : null;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "a11y_input_ariaRole", {
        //EO a11y
        //new a11y
        get: function () {
            return null;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "a11y_input_ariaRequired", {
        get: function () {
            return this.isRequired ? "true" : "false";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "a11y_input_ariaInvalid", {
        get: function () {
            return this.hasCssError() ? "true" : "false";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "a11y_input_ariaLabel", {
        get: function () {
            if (this.hasTitle && !this.parentQuestion) {
                return null;
            }
            else {
                return this.locTitle.renderedHtml;
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "a11y_input_ariaLabelledBy", {
        get: function () {
            if (this.hasTitle && !this.parentQuestion) {
                return this.ariaTitleId;
            }
            else {
                return null;
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "a11y_input_ariaDescribedBy", {
        get: function () {
            if (this.hasTitle && !this.parentQuestion) {
                return this.ariaDescriptionId;
            }
            else {
                return null;
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Question.prototype, "a11y_input_ariaErrormessage", {
        get: function () {
            return this.hasCssError() ? this.id + "_errors" : null;
        },
        enumerable: false,
        configurable: true
    });
    Question.TextPreprocessorValuesMap = {
        title: "processedTitle",
        require: "requiredText",
    };
    Question.questionCounter = 100;
    question_decorate([
        jsonobject_property({ defaultValue: false })
    ], Question.prototype, "isMobile", void 0);
    question_decorate([
        jsonobject_property()
    ], Question.prototype, "forceIsInputReadOnly", void 0);
    question_decorate([
        jsonobject_property()
    ], Question.prototype, "ariaExpanded", void 0);
    question_decorate([
        jsonobject_property({ localizable: true, onSet: function (val, target) { return target.calcRenderedCommentPlaceholder(); } })
    ], Question.prototype, "commentPlaceholder", void 0);
    question_decorate([
        jsonobject_property()
    ], Question.prototype, "renderAs", void 0);
    question_decorate([
        jsonobject_property({ defaultValue: false })
    ], Question.prototype, "inMatrixMode", void 0);
    return Question;
}(survey_element_SurveyElement));

function makeNameValid(str) {
    if (!str)
        return str;
    str = str.trim().replace(/[\{\}]+/g, "");
    while (!!str && str[0] === settings.expressionDisableConversionChar) {
        str = str.substring(1);
    }
    return str;
}
Serializer.addClass("question", [
    { name: "!name", onSettingValue: function (obj, val) { return makeNameValid(val); } },
    {
        name: "state",
        default: "default",
        choices: ["default", "collapsed", "expanded"],
    },
    { name: "visible:switch", default: true, overridingProperty: "visibleIf" },
    { name: "useDisplayValuesInDynamicTexts:boolean", alternativeName: "useDisplayValuesInTitle", default: true, layout: "row" },
    "visibleIf:condition",
    { name: "width" },
    { name: "minWidth", defaultFunc: function () { return settings.minWidth; } },
    { name: "maxWidth", defaultFunc: function () { return settings.maxWidth; } },
    {
        name: "colSpan:number", visible: false,
        onSerializeValue: function (obj) { return obj.getPropertyValue("colSpan"); },
    },
    {
        name: "effectiveColSpan:number", minValue: 1, isSerializable: false,
        visibleIf: function (obj) { return !!obj && !!obj.survey && obj.survey.gridLayoutEnabled; }
    },
    { name: "startWithNewLine:boolean", default: true, layout: "row" },
    { name: "indent:number", default: 0, choices: [0, 1, 2, 3], layout: "row" },
    {
        name: "page",
        isSerializable: false,
        visibleIf: function (obj) {
            var survey = obj ? obj.survey : null;
            return !survey || !survey.pages || survey.pages.length > 1;
        },
        choices: function (obj) {
            var survey = obj ? obj.survey : null;
            return survey
                ? survey.pages.map(function (p) {
                    return { value: p.name, text: p.title };
                })
                : [];
        },
    },
    {
        name: "title:text", serializationProperty: "locTitle", layout: "row", dependsOn: "name",
        onPropertyEditorUpdate: function (obj, editor) {
            if (!!obj && !!editor) {
                editor.placeholder = obj.name;
            }
        }
    },
    {
        name: "titleLocation",
        default: "default",
        choices: ["default", "top", "bottom", "left", "hidden"],
        layout: "row",
    },
    {
        name: "description:text",
        serializationProperty: "locDescription",
        layout: "row",
    },
    {
        name: "descriptionLocation",
        default: "default",
        choices: ["default", "underInput", "underTitle"],
    },
    {
        name: "hideNumber:boolean",
        dependsOn: "titleLocation",
        visibleIf: function (obj) {
            if (!obj) {
                return true;
            }
            if (obj.titleLocation === "hidden") {
                return false;
            }
            var parent = obj ? obj.parent : null;
            var numberingAllowedByParent = !parent || parent.showQuestionNumbers !== "off";
            if (!numberingAllowedByParent) {
                return false;
            }
            var survey = obj ? obj.survey : null;
            return (!survey ||
                survey.showQuestionNumbers !== "off" ||
                (!!parent && parent.showQuestionNumbers === "onpanel"));
        },
    },
    { name: "valueName", onSettingValue: function (obj, val) { return makeNameValid(val); } },
    "enableIf:condition",
    "resetValueIf:condition",
    "setValueIf:condition",
    "setValueExpression:expression",
    "defaultValue:value",
    {
        name: "defaultValueExpression:expression",
        category: "logic",
    },
    "correctAnswer:value",
    {
        name: "clearIfInvisible",
        default: "default",
        choices: ["default", "none", "onComplete", "onHidden", "onHiddenContainer"],
    },
    { name: "isRequired:switch", overridingProperty: "requiredIf" },
    "requiredIf:condition",
    {
        name: "requiredErrorText:text",
        serializationProperty: "locRequiredErrorText",
    },
    { name: "errorLocation", default: "default", choices: ["default", "top", "bottom"] },
    { name: "readOnly:switch", overridingProperty: "enableIf" },
    {
        name: "validators:validators",
        baseClassName: "surveyvalidator",
        classNamePart: "validator",
    },
    {
        name: "bindings:bindings",
        serializationProperty: "bindings",
        visibleIf: function (obj) {
            return obj.bindings.getNames().length > 0;
        },
    },
    { name: "renderAs", default: "default", visible: false },
    { name: "showCommentArea", visible: false, default: false, alternativeName: "hasComment", category: "general" },
    {
        name: "commentText",
        dependsOn: "showCommentArea",
        visibleIf: function (obj) {
            return obj.showCommentArea;
        },
        serializationProperty: "locCommentText"
    },
    {
        name: "commentPlaceholder",
        alternativeName: "commentPlaceHolder",
        serializationProperty: "locCommentPlaceholder",
        dependsOn: "showCommentArea",
        visibleIf: function (obj) {
            return obj.hasComment;
        }
    }
]);
Serializer.addAlterNativeClassName("question", "questionbase");

// CONCATENATED MODULE: ./packages/survey-core/src/itemvalue.ts
var itemvalue_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var itemvalue_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};








/**
 * Array of ItemValue is used in checkbox, dropdown and radiogroup choices, matrix columns and rows.
 * It has two main properties: value and text. If text is empty, value is used for displaying.
 * The text property is localizable and support markdown.
 */
var itemvalue_ItemValue = /** @class */ (function (_super) {
    itemvalue_extends(ItemValue, _super);
    function ItemValue(value, text, typeName) {
        if (text === void 0) { text = null; }
        if (typeName === void 0) { typeName = "itemvalue"; }
        var _this = _super.call(this) || this;
        _this.typeName = typeName;
        _this.ownerPropertyName = "";
        _this.locTextValue = new localizablestring_LocalizableString(_this, true, "text");
        _this.locTextValue.onStrChanged = function (oldValue, newValue) {
            if (newValue == _this.value) {
                newValue = undefined;
            }
            _this.propertyValueChanged("text", oldValue, newValue);
        };
        _this.locTextValue.onGetTextCallback = function (txt) {
            return txt
                ? txt
                : !helpers_Helpers.isValueEmpty(_this.value)
                    ? _this.value.toString()
                    : null;
        };
        if (text)
            _this.locText.text = text;
        if (!!value && typeof value === "object") {
            _this.setData(value);
        }
        else {
            _this.value = value;
        }
        if (_this.getType() != "itemvalue") {
            CustomPropertiesCollection.createProperties(_this);
        }
        _this.data = _this;
        _this.onCreating();
        return _this;
    }
    ItemValue.prototype.getMarkdownHtml = function (text, name) {
        return !!this.locOwner ? this.locOwner.getMarkdownHtml(text, name) : undefined;
    };
    ItemValue.prototype.getRenderer = function (name) {
        return !!this.locOwner ? this.locOwner.getRenderer(name) : null;
    };
    ItemValue.prototype.getRendererContext = function (locStr) {
        return !!this.locOwner ? this.locOwner.getRendererContext(locStr) : locStr;
    };
    ItemValue.prototype.getProcessedText = function (text) {
        return this.locOwner ? this.locOwner.getProcessedText(text) : text;
    };
    Object.defineProperty(ItemValue, "Separator", {
        get: function () {
            return settings.itemValueSeparator;
        },
        set: function (val) {
            settings.itemValueSeparator = val;
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Resets the input array and fills it with values from the values array
     */
    ItemValue.setData = function (items, values, type) {
        items.length = 0;
        for (var i = 0; i < values.length; i++) {
            var value = values[i];
            var itemType = !!value && typeof value.getType === "function" ? value.getType() : (type !== null && type !== void 0 ? type : "itemvalue");
            var item = Serializer.createClass(itemType);
            item.setData(value);
            if (!!value.originalItem) {
                item.originalItem = value.originalItem;
            }
            items.push(item);
        }
    };
    ItemValue.getData = function (items) {
        var result = [];
        for (var i = 0; i < items.length; i++) {
            result.push(items[i].getData());
        }
        return result;
    };
    ItemValue.getItemByValue = function (items, val) {
        if (!Array.isArray(items))
            return null;
        var valIsEmpty = helpers_Helpers.isValueEmpty(val);
        for (var i = 0; i < items.length; i++) {
            if (valIsEmpty && helpers_Helpers.isValueEmpty(items[i].value))
                return items[i];
            if (helpers_Helpers.isTwoValueEquals(items[i].value, val, false, true, false))
                return items[i];
        }
        return null;
    };
    ItemValue.getTextOrHtmlByValue = function (items, val) {
        var item = ItemValue.getItemByValue(items, val);
        return item !== null ? item.locText.textOrHtml : "";
    };
    ItemValue.locStrsChanged = function (items) {
        for (var i = 0; i < items.length; i++) {
            items[i].locStrsChanged();
        }
    };
    ItemValue.runConditionsForItems = function (items, filteredItems, runner, values, properties, useItemExpression, onItemCallBack) {
        if (useItemExpression === void 0) { useItemExpression = true; }
        return ItemValue.runConditionsForItemsCore(items, filteredItems, runner, values, properties, true, useItemExpression, onItemCallBack);
    };
    ItemValue.runEnabledConditionsForItems = function (items, runner, values, properties, onItemCallBack) {
        return ItemValue.runConditionsForItemsCore(items, null, runner, values, properties, false, true, onItemCallBack);
    };
    ItemValue.runConditionsForItemsCore = function (items, filteredItems, runner, values, properties, isVisible, useItemExpression, onItemCallBack) {
        if (useItemExpression === void 0) { useItemExpression = true; }
        if (!values) {
            values = {};
        }
        var itemValue = values["item"];
        var choiceValue = values["choice"];
        var hasChanded = false;
        for (var i = 0; i < items.length; i++) {
            var item = items[i];
            values["item"] = item.value;
            values["choice"] = item.value;
            var itemRunner = useItemExpression && !!item.getConditionRunner
                ? item.getConditionRunner(isVisible)
                : false;
            if (!itemRunner) {
                itemRunner = runner;
            }
            var newValue = true;
            if (itemRunner) {
                newValue = itemRunner.run(values, properties);
            }
            if (!!onItemCallBack) {
                newValue = onItemCallBack(item, newValue);
            }
            if (!!filteredItems && newValue) {
                filteredItems.push(item);
            }
            var oldValue = isVisible ? item.isVisible : item.isEnabled;
            if (newValue != oldValue) {
                hasChanded = true;
                if (isVisible) {
                    if (!!item.setIsVisible)
                        item.setIsVisible(newValue);
                }
                else {
                    if (!!item.setIsEnabled)
                        item.setIsEnabled(newValue);
                }
            }
        }
        if (itemValue) {
            values["item"] = itemValue;
        }
        else {
            delete values["item"];
        }
        if (choiceValue) {
            values["choice"] = choiceValue;
        }
        else {
            delete values["choice"];
        }
        return hasChanded;
    };
    ItemValue.prototype.onCreating = function () { };
    ItemValue.prototype.getType = function () {
        return !!this.typeName ? this.typeName : "itemvalue";
    };
    ItemValue.prototype.getSurvey = function (live) {
        if (live === void 0) { live = false; }
        return !!this.locOwner && !!this.locOwner["getSurvey"]
            ? this.locOwner.getSurvey()
            : null;
    };
    ItemValue.prototype.getLocale = function () {
        return !!this.locOwner && this.locOwner.getLocale ? this.locOwner.getLocale() : "";
    };
    Object.defineProperty(ItemValue.prototype, "isInternal", {
        get: function () {
            return this.isGhost === true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ItemValue.prototype, "locText", {
        get: function () {
            return this.locTextValue;
        },
        enumerable: false,
        configurable: true
    });
    ItemValue.prototype.setLocText = function (locText) {
        this.locTextValue = locText;
    };
    Object.defineProperty(ItemValue.prototype, "locOwner", {
        get: function () {
            return this._locOwner;
        },
        set: function (value) {
            this._locOwner = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ItemValue.prototype, "value", {
        get: function () {
            return this.getPropertyValue("value");
        },
        set: function (newValue) {
            var text = undefined;
            if (!helpers_Helpers.isValueEmpty(newValue)) {
                var str = newValue.toString();
                var index = str.indexOf(settings.itemValueSeparator);
                if (index > -1) {
                    newValue = str.slice(0, index);
                    text = str.slice(index + 1);
                }
            }
            this.setPropertyValue("value", newValue);
            if (!!text) {
                this.text = text;
            }
            this.id = this.value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ItemValue.prototype, "hasText", {
        get: function () {
            return this.locText.pureText ? true : false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ItemValue.prototype, "pureText", {
        get: function () {
            return this.locText.pureText;
        },
        set: function (val) {
            this.text = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ItemValue.prototype, "text", {
        get: function () {
            return this.locText.calculatedText; //TODO: it will be correct to use this.locText.text, however it would require a lot of rewriting in Creator
        },
        set: function (newText) {
            this.locText.text = newText;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ItemValue.prototype, "calculatedText", {
        get: function () {
            return this.locText.calculatedText;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ItemValue.prototype, "shortcutText", {
        get: function () {
            return this.text;
        },
        enumerable: false,
        configurable: true
    });
    ItemValue.prototype.canSerializeValue = function () {
        var val = this.value;
        if (val === undefined || val === null)
            return false;
        return !Array.isArray(val) && typeof val !== "object";
    };
    ItemValue.prototype.getData = function () {
        var json = this.toJSON();
        if (!!json["value"] && !!json["value"]["pos"]) {
            delete json["value"]["pos"];
        }
        if (helpers_Helpers.isValueEmpty(json.value))
            return json;
        var canSerializeVal = this.canSerializeValue();
        var canSerializeAsContant = !canSerializeVal || !settings.serialization.itemValueSerializeAsObject && !settings.serialization.itemValueSerializeDisplayText;
        if (canSerializeAsContant && Object.keys(json).length == 1)
            return this.value;
        if (settings.serialization.itemValueSerializeDisplayText && json.text === undefined && canSerializeVal) {
            json.text = this.value.toString();
        }
        return json;
    };
    ItemValue.prototype.toJSON = function () {
        var res = {};
        var properties = Serializer.getProperties(this.getType());
        if (!properties || properties.length == 0) {
            properties = Serializer.getProperties("itemvalue");
        }
        var jsoObj = new jsonobject_JsonObject();
        for (var i = 0; i < properties.length; i++) {
            var prop = properties[i];
            if (prop.name === "text" && !this.locText.hasNonDefaultText() &&
                helpers_Helpers.isTwoValueEquals(this.value, this.text, false, true, false))
                continue;
            jsoObj.valueToJson(this, res, prop);
        }
        return res;
    };
    ItemValue.prototype.setData = function (value) {
        if (helpers_Helpers.isValueEmpty(value))
            return;
        if (typeof value.value === "undefined" && typeof value.text !== "undefined" && Object.keys(value).length === 1) {
            value.value = value.text;
        }
        if (typeof value.value !== "undefined") {
            var json = void 0;
            if (typeof value.toJSON === "function") {
                json = value.toJSON();
            }
            else {
                json = value;
            }
            new jsonobject_JsonObject().toObject(json, this);
        }
        else {
            this.value = value;
        }
        this.locText.strChanged();
    };
    Object.defineProperty(ItemValue.prototype, "visibleIf", {
        get: function () {
            return this.getPropertyValueWithoutDefault("visibleIf") || "";
        },
        set: function (val) {
            this.setPropertyValue("visibleIf", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ItemValue.prototype, "enableIf", {
        get: function () {
            return this.getPropertyValueWithoutDefault("enableIf") || "";
        },
        set: function (val) {
            this.setPropertyValue("enableIf", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ItemValue.prototype, "isVisible", {
        get: function () {
            var res = this.getPropertyValueWithoutDefault("isVisible");
            return res !== undefined ? res : true;
        },
        enumerable: false,
        configurable: true
    });
    ItemValue.prototype.setIsVisible = function (val) {
        this.setPropertyValue("isVisible", val);
    };
    Object.defineProperty(ItemValue.prototype, "isEnabled", {
        get: function () {
            var res = this.getPropertyValueWithoutDefault("isEnabled");
            return res !== undefined ? res : true;
        },
        enumerable: false,
        configurable: true
    });
    ItemValue.prototype.setIsEnabled = function (val) {
        this.setPropertyValue("isEnabled", val);
    };
    ItemValue.prototype.addUsedLocales = function (locales) {
        this.AddLocStringToUsedLocales(this.locTextValue, locales);
    };
    ItemValue.prototype.locStrsChanged = function () {
        _super.prototype.locStrsChanged.call(this);
        this.locText.strChanged();
    };
    ItemValue.prototype.onPropertyValueChanged = function (name, oldValue, newValue) {
        if (name === "value" && !this.hasText) {
            this.locText.strChanged();
        }
        var funcName = "itemValuePropertyChanged";
        if (!this.locOwner || !this.locOwner[funcName])
            return;
        this.locOwner[funcName](this, name, oldValue, newValue);
    };
    ItemValue.prototype.getConditionRunner = function (isVisible) {
        if (isVisible)
            return this.getVisibleConditionRunner();
        return this.getEnableConditionRunner();
    };
    ItemValue.prototype.getVisibleConditionRunner = function () {
        if (!this.visibleIf)
            return null;
        if (!this.visibleConditionRunner)
            this.visibleConditionRunner = new ConditionRunner(this.visibleIf);
        this.visibleConditionRunner.expression = this.visibleIf;
        return this.visibleConditionRunner;
    };
    ItemValue.prototype.getEnableConditionRunner = function () {
        if (!this.enableIf)
            return null;
        if (!this.enableConditionRunner)
            this.enableConditionRunner = new ConditionRunner(this.enableIf);
        this.enableConditionRunner.expression = this.enableIf;
        return this.enableConditionRunner;
    };
    Object.defineProperty(ItemValue.prototype, "selected", {
        get: function () {
            var _this = this;
            var locOwner = this._locOwner;
            if (locOwner instanceof question_Question && locOwner.isItemSelected && this.selectedValue === undefined) {
                this.selectedValue = (new ComputedUpdater(function () { return locOwner.isItemSelected(_this); }));
            }
            return this.selectedValue;
        },
        enumerable: false,
        configurable: true
    });
    ItemValue.prototype.getComponent = function () {
        if (this._locOwner instanceof question_Question) {
            return this.componentValue || this._locOwner.itemComponent;
        }
        return this.componentValue;
    };
    ItemValue.prototype.setComponent = function (val) {
        this.componentValue = val;
    };
    ItemValue.prototype.getEnabled = function () {
        return this.isEnabled;
    };
    ItemValue.prototype.setEnabled = function (val) {
        this.setIsEnabled(val);
    };
    ItemValue.prototype.getVisible = function () {
        var isVisible = this.isVisible === undefined ? true : this.isVisible;
        var visible = this._visible === undefined ? true : this._visible;
        return isVisible && visible;
    };
    ItemValue.prototype.setVisible = function (val) {
        this._visible = val;
    };
    ItemValue.prototype.getLocTitle = function () {
        return this.locText;
    };
    ItemValue.prototype.getTitle = function () {
        return this.text;
    };
    ItemValue.prototype.setLocTitle = function (val) { };
    ItemValue.prototype.setTitle = function (val) { };
    itemvalue_decorate([
        jsonobject_property({ defaultValue: true })
    ], ItemValue.prototype, "_visible", void 0);
    itemvalue_decorate([
        jsonobject_property()
    ], ItemValue.prototype, "selectedValue", void 0);
    itemvalue_decorate([
        jsonobject_property()
    ], ItemValue.prototype, "icon", void 0);
    return ItemValue;
}(action_BaseAction));

base_Base.createItemValue = function (source, type) {
    var item = null;
    if (!!type) {
        item = jsonobject_JsonObject.metaData.createClass(type, {});
    }
    else if (typeof source.getType === "function") {
        item = new itemvalue_ItemValue(null, undefined, source.getType());
    }
    else {
        item = new itemvalue_ItemValue(null);
    }
    item.setData(source);
    return item;
};
base_Base.itemValueLocStrChanged = function (arr) {
    itemvalue_ItemValue.locStrsChanged(arr);
};
jsonobject_JsonObjectProperty.getItemValuesDefaultValue = function (val, type) {
    var res = new Array();
    itemvalue_ItemValue.setData(res, Array.isArray(val) ? val : [], type);
    return res;
};
Serializer.addClass("itemvalue", [
    { name: "!value", isUnique: true },
    {
        name: "text",
        serializationProperty: "locText",
    },
    { name: "visibleIf:condition", showMode: "form" },
    {
        name: "enableIf:condition",
        showMode: "form",
        visibleIf: function (obj) {
            return !obj || obj.ownerPropertyName !== "rateValues";
        },
    }
], function (value) { return new itemvalue_ItemValue(value); });

// CONCATENATED MODULE: ./packages/survey-core/src/calculatedValue.ts
var calculatedValue_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();




/**
 * The calculated value is a way to define the variable in Survey Creator.
 * It has two main properties: name and expression. Based on expression the value read-only property is automatically calculated.
 * The name property should be unique though all calculated values.
 * It uses survey.getVariable/seruvey.setVariable functions to get/set its value. The class do not store its value internally.
 * You may set includeIntoResult property to true to store this calculated value into survey result.
 */
var calculatedValue_CalculatedValue = /** @class */ (function (_super) {
    calculatedValue_extends(CalculatedValue, _super);
    function CalculatedValue(name, expression) {
        if (name === void 0) { name = null; }
        if (expression === void 0) { expression = null; }
        var _this = _super.call(this) || this;
        _this.expressionIsRunning = false;
        _this.isCalculated = false;
        if (!!name) {
            _this.name = name;
        }
        if (!!expression) {
            _this.expression = expression;
        }
        return _this;
    }
    CalculatedValue.prototype.setOwner = function (data) {
        this.data = data;
        this.rerunExpression();
    };
    CalculatedValue.prototype.getType = function () {
        return "calculatedvalue";
    };
    CalculatedValue.prototype.getSurvey = function (live) {
        if (live === void 0) { live = false; }
        return !!this.data && !!this.data["getSurvey"]
            ? this.data.getSurvey()
            : null;
    };
    Object.defineProperty(CalculatedValue.prototype, "owner", {
        get: function () {
            return this.data;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalculatedValue.prototype, "name", {
        /**
         * The calculated value name. It should be non empty and unique.
         */
        get: function () {
            return this.getPropertyValue("name") || "";
        },
        set: function (val) {
            this.setPropertyValue("name", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalculatedValue.prototype, "includeIntoResult", {
        /**
         * Set this property to true to include the non-empty calculated value into survey result, survey.data property.
         */
        get: function () {
            return this.getPropertyValue("includeIntoResult");
        },
        set: function (val) {
            this.setPropertyValue("includeIntoResult", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalculatedValue.prototype, "expression", {
        /**
         * The Expression that used to calculate the value. You may use standard operators like +, -, * and /, squares (). Here is the example of accessing the question value {questionname}.
         * Example: "({quantity} * {price}) * (100 - {discount}) / 100"
         */
        get: function () {
            return this.getPropertyValue("expression") || "";
        },
        set: function (val) {
            this.setPropertyValue("expression", val);
            this.rerunExpression();
        },
        enumerable: false,
        configurable: true
    });
    CalculatedValue.prototype.locCalculation = function () {
        this.expressionIsRunning = true;
    };
    CalculatedValue.prototype.unlocCalculation = function () {
        this.expressionIsRunning = false;
    };
    CalculatedValue.prototype.resetCalculation = function () {
        this.isCalculated = false;
    };
    CalculatedValue.prototype.doCalculation = function (calculatedValues, values, properties) {
        if (this.isCalculated)
            return;
        this.runExpressionCore(calculatedValues, values, properties);
        this.isCalculated = true;
    };
    CalculatedValue.prototype.runExpression = function (values, properties) {
        this.runExpressionCore(null, values, properties);
    };
    Object.defineProperty(CalculatedValue.prototype, "value", {
        get: function () {
            if (!this.data)
                return undefined;
            return this.data.getVariable(this.name);
        },
        enumerable: false,
        configurable: true
    });
    CalculatedValue.prototype.setValue = function (val) {
        if (!this.data)
            return;
        this.data.setVariable(this.name, val);
    };
    Object.defineProperty(CalculatedValue.prototype, "canRunExpression", {
        get: function () {
            return (!!this.data &&
                !this.isLoadingFromJson &&
                !!this.expression &&
                !this.expressionIsRunning &&
                !!this.name);
        },
        enumerable: false,
        configurable: true
    });
    CalculatedValue.prototype.rerunExpression = function () {
        if (!this.canRunExpression)
            return;
        this.runExpression(this.data.getFilteredValues(), this.data.getFilteredProperties());
    };
    CalculatedValue.prototype.runExpressionCore = function (calculatedValues, values, properties) {
        if (!this.canRunExpression)
            return;
        this.ensureExpression(values);
        this.locCalculation();
        if (!!calculatedValues) {
            this.runDependentExpressions(calculatedValues, values, properties);
        }
        this.expressionRunner.run(values, properties);
    };
    CalculatedValue.prototype.runDependentExpressions = function (calculatedValues, values, properties) {
        var variables = this.expressionRunner.getVariables();
        if (!variables)
            return;
        for (var i = 0; i < calculatedValues.length; i++) {
            var calcItem = calculatedValues[i];
            if (calcItem === this || variables.indexOf(calcItem.name) < 0)
                continue;
            calcItem.doCalculation(calculatedValues, values, properties);
            values[calcItem.name] = calcItem.value;
        }
    };
    CalculatedValue.prototype.ensureExpression = function (values) {
        var _this = this;
        if (!!this.expressionRunner)
            return;
        this.expressionRunner = new ExpressionRunner(this.expression);
        this.expressionRunner.onRunComplete = function (newValue) {
            if (!helpers_Helpers.isTwoValueEquals(newValue, _this.value, false, true, false)) {
                _this.setValue(newValue);
            }
            _this.unlocCalculation();
        };
    };
    return CalculatedValue;
}(base_Base));

Serializer.addClass("calculatedvalue", [
    { name: "!name", isUnique: true },
    "expression:expression",
    "includeIntoResult:boolean",
], function () {
    return new calculatedValue_CalculatedValue();
}, "base");

// CONCATENATED MODULE: ./packages/survey-core/src/expressionItems.ts
var expressionItems_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();



/**
 * Base class for HtmlConditionItem and UrlConditionItem classes.
 */
var expressionItems_ExpressionItem = /** @class */ (function (_super) {
    expressionItems_extends(ExpressionItem, _super);
    function ExpressionItem(expression) {
        if (expression === void 0) { expression = null; }
        var _this = _super.call(this) || this;
        _this.expression = expression;
        return _this;
    }
    ExpressionItem.prototype.getType = function () {
        return "expressionitem";
    };
    ExpressionItem.prototype.runCondition = function (values, properties) {
        if (!this.expression)
            return false;
        return new ConditionRunner(this.expression).run(values, properties);
    };
    Object.defineProperty(ExpressionItem.prototype, "expression", {
        /**
         * The expression property. If this expression returns true, then survey will use html property to show on complete page.
         */
        get: function () {
            return this.getPropertyValue("expression", "");
        },
        set: function (val) {
            this.setPropertyValue("expression", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ExpressionItem.prototype, "locHtml", {
        get: function () {
            return this.getLocalizableString("html");
        },
        enumerable: false,
        configurable: true
    });
    ExpressionItem.prototype.getLocale = function () {
        return !!this.locOwner ? this.locOwner.getLocale() : "";
    };
    ExpressionItem.prototype.getMarkdownHtml = function (text, name) {
        return !!this.locOwner ? this.locOwner.getMarkdownHtml(text, name) : undefined;
    };
    ExpressionItem.prototype.getRenderer = function (name) {
        return !!this.locOwner ? this.locOwner.getRenderer(name) : null;
    };
    ExpressionItem.prototype.getRendererContext = function (locStr) {
        return !!this.locOwner ? this.locOwner.getRendererContext(locStr) : locStr;
    };
    ExpressionItem.prototype.getProcessedText = function (text) {
        return this.locOwner ? this.locOwner.getProcessedText(text) : text;
    };
    ExpressionItem.prototype.getSurvey = function (isLive) {
        if (isLive === void 0) { isLive = false; }
        return this.locOwner;
    };
    return ExpressionItem;
}(base_Base));

/**
 * A class that contains expression and html propeties. It uses in survey.completedHtmlOnCondition array.
 * If the expression returns true then html of this item uses instead of survey.completedHtml property
 * @see SurveyModel.completedHtmlOnCondition
 * @see SurveyModel.completedHtml
 */
var HtmlConditionItem = /** @class */ (function (_super) {
    expressionItems_extends(HtmlConditionItem, _super);
    function HtmlConditionItem(expression, html) {
        if (expression === void 0) { expression = null; }
        if (html === void 0) { html = null; }
        var _this = _super.call(this, expression) || this;
        _this.createLocalizableString("html", _this);
        _this.html = html;
        return _this;
    }
    HtmlConditionItem.prototype.getType = function () {
        return "htmlconditionitem";
    };
    Object.defineProperty(HtmlConditionItem.prototype, "html", {
        /**
         * The html that shows on completed ('Thank you') page. The expression should return true
         * @see expression
         */
        get: function () {
            return this.getLocalizableStringText("html");
        },
        set: function (value) {
            this.setLocalizableStringText("html", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(HtmlConditionItem.prototype, "locHtml", {
        get: function () {
            return this.getLocalizableString("html");
        },
        enumerable: false,
        configurable: true
    });
    return HtmlConditionItem;
}(expressionItems_ExpressionItem));

/**
 * A class that contains expression and url propeties. It uses in survey.navigateToUrlOnCondition array.
 * If the expression returns true then url of this item uses instead of survey.navigateToUrl property
 * @see SurveyModel.navigateToUrl
 */
var UrlConditionItem = /** @class */ (function (_super) {
    expressionItems_extends(UrlConditionItem, _super);
    function UrlConditionItem(expression, url) {
        if (expression === void 0) { expression = null; }
        if (url === void 0) { url = null; }
        var _this = _super.call(this, expression) || this;
        _this.createLocalizableString("url", _this);
        _this.url = url;
        return _this;
    }
    UrlConditionItem.prototype.getType = function () {
        return "urlconditionitem";
    };
    Object.defineProperty(UrlConditionItem.prototype, "url", {
        /**
         * The url that survey navigates to on completing the survey. The expression should return true
         * @see expression
         */
        get: function () {
            return this.getLocalizableStringText("url");
        },
        set: function (value) {
            this.setLocalizableStringText("url", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(UrlConditionItem.prototype, "locUrl", {
        get: function () {
            return this.getLocalizableString("url");
        },
        enumerable: false,
        configurable: true
    });
    return UrlConditionItem;
}(expressionItems_ExpressionItem));

Serializer.addClass("expressionitem", ["expression:condition"], function () {
    return new expressionItems_ExpressionItem();
}, "base");
Serializer.addClass("htmlconditionitem", [{ name: "html:html", serializationProperty: "locHtml" }], function () {
    return new HtmlConditionItem();
}, "expressionitem");
Serializer.addClass("urlconditionitem", [{ name: "url:string", serializationProperty: "locUrl" }], function () {
    return new UrlConditionItem();
}, "expressionitem");

// CONCATENATED MODULE: ./packages/survey-core/src/choicesRestful.ts
var choicesRestful_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();





var XmlParser = /** @class */ (function () {
    function XmlParser() {
        this.parser = new DOMParser();
    }
    XmlParser.prototype.assignValue = function (target, name, value) {
        if (Array.isArray(target[name])) {
            target[name].push(value);
        }
        else if (target[name] !== undefined) {
            target[name] = [target[name]].concat(value);
        }
        else if (typeof value === "object" &&
            Object.keys(value).length === 1 &&
            Object.keys(value)[0] === name) {
            target[name] = value[name];
        }
        else {
            target[name] = value;
        }
    };
    XmlParser.prototype.xml2Json = function (xmlNode, result) {
        if (xmlNode.children && xmlNode.children.length > 0) {
            for (var i = 0; i < xmlNode.children.length; i++) {
                var childNode = xmlNode.children[i];
                var childObject = {};
                this.xml2Json(childNode, childObject);
                this.assignValue(result, childNode.nodeName, childObject);
            }
        }
        else {
            this.assignValue(result, xmlNode.nodeName, xmlNode.textContent);
        }
    };
    XmlParser.prototype.parseXmlString = function (xmlString) {
        var xmlRoot = this.parser.parseFromString(xmlString, "text/xml");
        var json = {};
        this.xml2Json(xmlRoot, json);
        return json;
    };
    return XmlParser;
}());
/**
 * Configures access to a RESTful service that returns choices for [Checkbox](https://surveyjs.io/Examples/Library?id=questiontype-checkbox), [Dropdown](https://surveyjs.io/Examples/Library?id=questiontype-dropdown), [Radiogroup](https://surveyjs.io/Examples/Library?id=questiontype-radiogroup), and other multiple-choice question types.
 *
 * Use the following properties to configure this object:
 *
 * ```js
 * {
 *   url: "http://...", // A RESTful service's URL.
 *   valueName: "value", // Specifies which field contains choice values.
 *   titleName: "title", // Specifies which field contains display texts for choice values.
 *   imageLinkName: "imageUrl", // Specifies which field contains image URLs. Used in Image Picker questions.
 *   // Path to the array of choices. Specify `path` only if the array of choices is nested within the object returned by the service.
 *   // The following path separators are allowed: semicolon `;`, comma `,`.
 *   path: "myNestedArray"
 * }
 * ```
 *
 * Typically, you should assign this object to a question's [`choicesByUrl`](https://surveyjs.io/Documentation/Library?id=QuestionSelectBase#choicesByUrl) property. You can also specify additional application-wide settings using the [`settings.web`](https://surveyjs.io/form-library/documentation/api-reference/settings#web) object.
 */
var choicesRestful_ChoicesRestful = /** @class */ (function (_super) {
    choicesRestful_extends(ChoicesRestful, _super);
    function ChoicesRestful() {
        var _this = _super.call(this) || this;
        _this.lastObjHash = "";
        _this.isRunningValue = false;
        _this.processedUrl = "";
        _this.processedPath = "";
        _this.isUsingCacheFromUrl = undefined;
        _this.error = null;
        _this.createItemValue = function (value) {
            return new itemvalue_ItemValue(value);
        };
        _this.registerPropertyChangedHandlers(["url"], function () {
            if (_this.owner)
                _this.owner.setPropertyValue("isUsingRestful", !!_this.url);
        });
        return _this;
    }
    Object.defineProperty(ChoicesRestful, "EncodeParameters", {
        get: function () {
            return settings.web.encodeUrlParams;
        },
        set: function (val) {
            settings.web.encodeUrlParams = val;
        },
        enumerable: false,
        configurable: true
    });
    ChoicesRestful.clearCache = function () {
        ChoicesRestful.itemsResult = {};
        ChoicesRestful.sendingSameRequests = {};
    };
    ChoicesRestful.addSameRequest = function (obj) {
        if (!obj.isUsingCache)
            return false;
        var hash = obj.objHash;
        var res = ChoicesRestful.sendingSameRequests[hash];
        if (!res) {
            ChoicesRestful.sendingSameRequests[obj.objHash] = [];
            return false;
        }
        res.push(obj);
        obj.isRunningValue = true;
        return true;
    };
    ChoicesRestful.unregisterSameRequests = function (obj, items) {
        if (!obj.isUsingCache)
            return;
        var res = ChoicesRestful.sendingSameRequests[obj.objHash];
        delete ChoicesRestful.sendingSameRequests[obj.objHash];
        if (!res)
            return;
        for (var i = 0; i < res.length; i++) {
            res[i].isRunningValue = false;
            if (!!res[i].getResultCallback) {
                res[i].getResultCallback(items);
            }
        }
    };
    Object.defineProperty(ChoicesRestful, "onBeforeSendRequest", {
        get: function () {
            return settings.web.onBeforeRequestChoices;
        },
        set: function (val) {
            settings.web.onBeforeRequestChoices = val;
        },
        enumerable: false,
        configurable: true
    });
    ChoicesRestful.getCachedItemsResult = function (obj) {
        var hash = obj.objHash;
        var res = ChoicesRestful.itemsResult[hash];
        if (!res)
            return false;
        if (obj.getResultCallback) {
            obj.getResultCallback(res);
        }
        return true;
    };
    ChoicesRestful.prototype.getSurvey = function (live) {
        if (live === void 0) { live = false; }
        return !!this.owner ? this.owner.survey : null;
    };
    ChoicesRestful.prototype.run = function (textProcessor) {
        if (textProcessor === void 0) { textProcessor = null; }
        if (!this.url || !this.getResultCallback)
            return;
        this.processedText(textProcessor);
        if (!this.processedUrl) {
            this.doEmptyResultCallback({});
            this.lastObjHash = this.objHash;
            return;
        }
        if (this.lastObjHash === this.objHash)
            return;
        this.lastObjHash = this.objHash;
        this.error = null;
        if (this.useChangedItemsResults())
            return;
        if (ChoicesRestful.addSameRequest(this))
            return;
        this.sendRequest();
    };
    Object.defineProperty(ChoicesRestful.prototype, "isUsingCache", {
        get: function () {
            if (this.isUsingCacheFromUrl === true)
                return true;
            if (this.isUsingCacheFromUrl === false)
                return false;
            return settings.web.cacheLoadedChoices;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ChoicesRestful.prototype, "isRunning", {
        get: function () {
            return this.getIsRunning();
        },
        enumerable: false,
        configurable: true
    });
    ChoicesRestful.prototype.getIsRunning = function () {
        return this.isRunningValue;
    };
    Object.defineProperty(ChoicesRestful.prototype, "isWaitingForParameters", {
        get: function () {
            return this.url && !this.processedUrl;
        },
        enumerable: false,
        configurable: true
    });
    ChoicesRestful.prototype.useChangedItemsResults = function () {
        return ChoicesRestful.getCachedItemsResult(this);
    };
    ChoicesRestful.prototype.doEmptyResultCallback = function (serverResult) {
        var items = [];
        if (this.updateResultCallback) {
            items = this.updateResultCallback(items, serverResult);
        }
        this.getResultCallback(items);
    };
    ChoicesRestful.prototype.processedText = function (textProcessor) {
        var urlText = this.url;
        if (!!urlText) {
            urlText = urlText
                .replace(ChoicesRestful.cacheText, "")
                .replace(ChoicesRestful.noCacheText, "");
        }
        if (textProcessor) {
            var pUrl = textProcessor.processTextEx(urlText, false, settings.web.encodeUrlParams);
            var pPath = textProcessor.processTextEx(this.path, false, settings.web.encodeUrlParams);
            if (!pUrl.hasAllValuesOnLastRun || !pPath.hasAllValuesOnLastRun) {
                this.processedUrl = "";
                this.processedPath = "";
            }
            else {
                this.processedUrl = pUrl.text;
                this.processedPath = pPath.text;
            }
        }
        else {
            this.processedUrl = urlText;
            this.processedPath = this.path;
        }
        if (this.onProcessedUrlCallback) {
            this.onProcessedUrlCallback(this.processedUrl, this.processedPath);
        }
    };
    ChoicesRestful.prototype.parseResponse = function (response) {
        var parsedResponse;
        if (!!response &&
            typeof response.indexOf === "function" &&
            response.indexOf("<") === 0) {
            var parser = new XmlParser();
            parsedResponse = parser.parseXmlString(response);
        }
        else {
            try {
                parsedResponse = JSON.parse(response);
            }
            catch (_a) {
                parsedResponse = (response || "")
                    .split("\n")
                    .map(function (s) { return s.trim(" "); })
                    .filter(function (s) { return !!s; });
            }
        }
        return parsedResponse;
    };
    ChoicesRestful.prototype.sendRequest = function () {
        var xhr = new XMLHttpRequest();
        xhr.open("GET", this.processedUrl);
        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        var self = this;
        var loadingObjHash = this.objHash;
        xhr.onload = function () {
            self.beforeLoadRequest();
            if (xhr.status === 200) {
                self.onLoad(self.parseResponse(xhr.response), loadingObjHash);
            }
            else {
                self.onError(xhr.statusText, xhr.responseText);
            }
        };
        var options = { request: xhr };
        if (!!settings.web.onBeforeRequestChoices) {
            settings.web.onBeforeRequestChoices(this, options);
        }
        this.beforeSendRequest();
        options.request.send();
    };
    ChoicesRestful.prototype.getType = function () {
        return "choicesByUrl";
    };
    Object.defineProperty(ChoicesRestful.prototype, "isEmpty", {
        get: function () {
            return !this.url && !this.path;
        },
        enumerable: false,
        configurable: true
    });
    ChoicesRestful.prototype.getCustomPropertiesNames = function () {
        var properties = this.getCustomProperties();
        var res = new Array();
        for (var i = 0; i < properties.length; i++) {
            res.push(this.getCustomPropertyName(properties[i].name));
        }
        return res;
    };
    ChoicesRestful.prototype.getCustomPropertyName = function (propertyName) {
        return propertyName + "Name";
    };
    ChoicesRestful.prototype.getCustomProperties = function () {
        var properties = Serializer.getProperties(this.itemValueType);
        var res = [];
        for (var i = 0; i < properties.length; i++) {
            if (properties[i].name === "value" ||
                properties[i].name === "text" ||
                properties[i].name === "visibleIf" ||
                properties[i].name === "enableIf")
                continue;
            res.push(properties[i]);
        }
        return res;
    };
    ChoicesRestful.prototype.setData = function (json) {
        this.clear();
        if (json.url)
            this.url = json.url;
        if (json.path)
            this.path = json.path;
        if (json.valueName)
            this.valueName = json.valueName;
        if (json.titleName)
            this.titleName = json.titleName;
        if (json.imageLinkName)
            this.imageLinkName = json.imageLinkName;
        if (json.allowEmptyResponse !== undefined)
            this.allowEmptyResponse = json.allowEmptyResponse;
        if (json.attachOriginalItems !== undefined)
            this.attachOriginalItems = json.attachOriginalItems;
        var properties = this.getCustomPropertiesNames();
        for (var i = 0; i < properties.length; i++) {
            if (json[properties[i]])
                this[properties[i]] = json[properties[i]];
        }
    };
    ChoicesRestful.prototype.getData = function () {
        if (this.isEmpty)
            return null;
        var res = {};
        if (this.url)
            res["url"] = this.url;
        if (this.path)
            res["path"] = this.path;
        if (this.valueName)
            res["valueName"] = this.valueName;
        if (this.titleName)
            res["titleName"] = this.titleName;
        if (this.imageLinkName)
            res["imageLinkName"] = this.imageLinkName;
        if (this.allowEmptyResponse)
            res["allowEmptyResponse"] = this.allowEmptyResponse;
        if (this.attachOriginalItems)
            res["attachOriginalItems"] = this.attachOriginalItems;
        var properties = this.getCustomPropertiesNames();
        for (var i = 0; i < properties.length; i++) {
            if (this[properties[i]])
                res[properties[i]] = this[properties[i]];
        }
        return res;
    };
    Object.defineProperty(ChoicesRestful.prototype, "url", {
        /**
         * A RESTful service's URL.
         *
         * This property supports [dynamic URLs](https://surveyjs.io/Documentation/Library?id=design-survey-conditional-logic#dynamic-texts). For example, the URL below depends on the `region` question's value. When the value changes, the survey automatically loads a new dataset that corresponds to the selected region.
         *
         * ```js
         * url: "https://surveyjs.io/api/CountriesExample?region={region}"
         * ```
         *
         * [View Demo](https://surveyjs.io/Examples/Library/?id=questiontype-dropdownrestfull (linkStyle))
         * @see path
         * @see valueName
         * @see titleName
         */
        get: function () {
            return this.getPropertyValue("url") || "";
        },
        set: function (val) {
            this.setPropertyValue("url", val);
            this.isUsingCacheFromUrl = undefined;
            if (!val)
                return;
            if (val.indexOf(ChoicesRestful.cacheText) > -1) {
                this.isUsingCacheFromUrl = true;
            }
            else {
                if (val.indexOf(ChoicesRestful.noCacheText) > -1) {
                    this.isUsingCacheFromUrl = false;
                }
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ChoicesRestful.prototype, "path", {
        /**
         * Path to the array of choices. The following path separators are allowed: semicolon `;`, comma `,`.
         *
         * Specify this property only if the array of choices is nested within the object returned by the service. For example, the service returns the following object:
         *
         * ```js
         * {
         *   countries: [ ... ],
         *   capitals: [ ... ]
         * }
         * ```
         *
         * To populate choices with values from the `countries` array, set the `path` property to `"countries"`. To use the `capitals` array, set this property to `"capitals"`.
         * @see url
         * @see valueName
         * @see titleName
         */
        get: function () {
            return this.getPropertyValue("path") || "";
        },
        set: function (val) {
            this.setPropertyValue("path", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ChoicesRestful.prototype, "valueName", {
        /**
         * Specifies which property in the obtained data object contains choice values.
         *
         * [View Demo](https://surveyjs.io/Examples/Library/?id=questiontype-dropdownrestfull (linkStyle))
         *
         * @see url
         * @see path
         * @see titleName
         */
        get: function () {
            return this.getPropertyValue("valueName", "");
        },
        set: function (val) {
            this.setPropertyValue("valueName", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ChoicesRestful.prototype, "titleName", {
        /**
         * Specifies which property in the obtained data object contains display texts for choices.
         *
         * @see url
         * @see path
         * @see valueName
         */
        get: function () {
            return this.getPropertyValue("titleName", "");
        },
        set: function (val) {
            this.setPropertyValue("titleName", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ChoicesRestful.prototype, "imageLinkName", {
        /**
         * Specifies which property in the obtained data object contains image URLs. Used only in [Image Picker](https://surveyjs.io/Examples/Library?id=questiontype-imagepicker) questions.
         *
         * @see url
         * @see path
         * @see valueName
         */
        get: function () {
            return this.getPropertyValue("imageLinkName", "");
        },
        set: function (val) {
            this.setPropertyValue("imageLinkName", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ChoicesRestful.prototype, "allowEmptyResponse", {
        /**
         * Specifies whether the service is allowed to return an empty response or an empty array in a response.
         *
         * Default value: `false`
         */
        get: function () {
            return this.getPropertyValue("allowEmptyResponse");
        },
        set: function (val) {
            this.setPropertyValue("allowEmptyResponse", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ChoicesRestful.prototype, "attachOriginalItems", {
        get: function () {
            return this.getPropertyValue("attachOriginalItems");
        },
        set: function (val) {
            this.setPropertyValue("attachOriginalItems", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ChoicesRestful.prototype, "itemValueType", {
        get: function () {
            if (!this.owner)
                return "itemvalue";
            var prop = Serializer.findProperty(this.owner.getType(), "choices");
            if (!prop)
                return "itemvalue";
            if (prop.type == "itemvalue[]")
                return "itemvalue";
            return prop.type;
        },
        enumerable: false,
        configurable: true
    });
    ChoicesRestful.prototype.clear = function () {
        this.url = undefined;
        this.path = undefined;
        this.valueName = undefined;
        this.titleName = undefined;
        this.imageLinkName = undefined;
        var properties = this.getCustomPropertiesNames();
        for (var i = 0; i < properties.length; i++) {
            if (this[properties[i]])
                this[properties[i]] = "";
        }
    };
    ChoicesRestful.prototype.beforeSendRequest = function () {
        this.isRunningValue = true;
        if (!!this.beforeSendRequestCallback) {
            this.beforeSendRequestCallback();
        }
    };
    ChoicesRestful.prototype.beforeLoadRequest = function () {
        this.isRunningValue = false;
    };
    ChoicesRestful.prototype.onLoad = function (result, loadingObjHash) {
        if (loadingObjHash === void 0) { loadingObjHash = null; }
        if (!loadingObjHash) {
            loadingObjHash = this.objHash;
        }
        var items = new Array();
        var updatedResult = this.getResultAfterPath(result);
        if (updatedResult && updatedResult["length"]) {
            for (var i = 0; i < updatedResult.length; i++) {
                var itemValue = updatedResult[i];
                if (!itemValue)
                    continue;
                var value = !!this.getItemValueCallback
                    ? this.getItemValueCallback(itemValue)
                    : this.getValue(itemValue);
                var item = this.createItemValue(value);
                this.setTitle(item, itemValue);
                this.setCustomProperties(item, itemValue);
                if (this.attachOriginalItems) {
                    item.originalItem = itemValue;
                }
                var imageLink = this.getImageLink(itemValue);
                if (!!imageLink) {
                    item.imageLink = imageLink;
                }
                items.push(item);
            }
        }
        else {
            if (!this.allowEmptyResponse) {
                this.error = new WebRequestEmptyError(null, this.owner);
            }
        }
        if (this.updateResultCallback) {
            items = this.updateResultCallback(items, result);
        }
        if (this.isUsingCache) {
            ChoicesRestful.itemsResult[loadingObjHash] = items;
        }
        this.callResultCallback(items, loadingObjHash);
        ChoicesRestful.unregisterSameRequests(this, items);
    };
    ChoicesRestful.prototype.callResultCallback = function (items, loadingObjHash) {
        if (loadingObjHash != this.objHash)
            return;
        this.getResultCallback(items);
    };
    ChoicesRestful.prototype.setCustomProperties = function (item, itemValue) {
        var properties = this.getCustomProperties();
        for (var i = 0; i < properties.length; i++) {
            var prop = properties[i];
            var val = this.getValueCore(itemValue, this.getPropertyBinding(prop.name));
            if (!this.isValueEmpty(val)) {
                item[prop.name] = val;
            }
        }
    };
    ChoicesRestful.prototype.getPropertyBinding = function (propertyName) {
        if (this[this.getCustomPropertyName(propertyName)])
            return this[this.getCustomPropertyName(propertyName)];
        if (this[propertyName])
            return this[propertyName];
        return propertyName;
    };
    ChoicesRestful.prototype.onError = function (status, response) {
        this.error = new WebRequestError(status, response, this.owner);
        this.doEmptyResultCallback(response);
        ChoicesRestful.unregisterSameRequests(this, []);
    };
    ChoicesRestful.prototype.getResultAfterPath = function (result) {
        if (!result)
            return result;
        if (!this.processedPath)
            return result;
        var pathes = this.getPathes();
        for (var i = 0; i < pathes.length; i++) {
            result = result[pathes[i]];
            if (!result)
                return null;
        }
        return result;
    };
    ChoicesRestful.prototype.getPathes = function () {
        var pathes = [];
        if (this.processedPath.indexOf(";") > -1) {
            pathes = this.path.split(";");
        }
        else {
            pathes = this.processedPath.split(",");
        }
        if (pathes.length == 0)
            pathes.push(this.processedPath);
        return pathes;
    };
    ChoicesRestful.prototype.getValue = function (item) {
        if (!item)
            return null;
        if (this.valueName)
            return this.getValueCore(item, this.valueName);
        if (!(item instanceof Object))
            return item;
        var len = Object.keys(item).length;
        if (len < 1)
            return null;
        return item[Object.keys(item)[0]];
    };
    ChoicesRestful.prototype.setTitle = function (item, itemValue) {
        var title = this.titleName ? this.titleName : "title";
        var val = this.getValueCore(itemValue, title);
        if (!val)
            return;
        if (typeof val === "string") {
            item.text = val;
        }
        else {
            item.locText.setJson(val);
        }
    };
    ChoicesRestful.prototype.getImageLink = function (item) {
        var imageLink = this.imageLinkName ? this.imageLinkName : "imageLink";
        return this.getValueCore(item, imageLink);
    };
    ChoicesRestful.prototype.getValueCore = function (item, property) {
        if (!item)
            return null;
        if (property.indexOf(".") < 0)
            return item[property];
        var properties = property.split(".");
        for (var i = 0; i < properties.length; i++) {
            item = item[properties[i]];
            if (!item)
                return null;
        }
        return item;
    };
    Object.defineProperty(ChoicesRestful.prototype, "objHash", {
        get: function () {
            return (this.processedUrl +
                ";" +
                this.processedPath +
                ";" +
                this.valueName +
                ";" +
                this.titleName +
                ";" +
                this.imageLinkName);
        },
        enumerable: false,
        configurable: true
    });
    ChoicesRestful.cacheText = "{CACHE}";
    ChoicesRestful.noCacheText = "{NOCACHE}";
    ChoicesRestful.itemsResult = {};
    ChoicesRestful.sendingSameRequests = {};
    return ChoicesRestful;
}(base_Base));

/**
 * Obsolete, please use ChoicesRestful
 */
var choicesRestful_ChoicesRestfull = /** @class */ (function (_super) {
    choicesRestful_extends(ChoicesRestfull, _super);
    function ChoicesRestfull() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(ChoicesRestfull, "EncodeParameters", {
        get: function () {
            return choicesRestful_ChoicesRestful.EncodeParameters;
        },
        set: function (val) {
            choicesRestful_ChoicesRestful.EncodeParameters = val;
        },
        enumerable: false,
        configurable: true
    });
    ChoicesRestfull.clearCache = function () {
        choicesRestful_ChoicesRestful.clearCache();
    };
    Object.defineProperty(ChoicesRestfull, "onBeforeSendRequest", {
        get: function () {
            return settings.web.onBeforeRequestChoices;
        },
        set: function (val) {
            settings.web.onBeforeRequestChoices = val;
        },
        enumerable: false,
        configurable: true
    });
    return ChoicesRestfull;
}(choicesRestful_ChoicesRestful));

Serializer.addClass("choicesByUrl", [
    "url",
    "path",
    "valueName",
    "titleName",
    {
        name: "imageLinkName",
        visibleIf: function (obj) {
            return !!obj && !!obj.owner && obj.owner.getType() == "imagepicker";
        },
    },
    { name: "allowEmptyResponse:boolean" },
    { name: "attachOriginalItems:boolean", visible: false },
], function () {
    return new choicesRestful_ChoicesRestful();
});

// CONCATENATED MODULE: ./packages/survey-core/src/martixBase.ts
var martixBase_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var martixBase_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};






/**
 * A base class for all matrix question types.
 */
var martixBase_QuestionMatrixBaseModel = /** @class */ (function (_super) {
    martixBase_extends(QuestionMatrixBaseModel, _super);
    function QuestionMatrixBaseModel(name) {
        var _this = _super.call(this, name) || this;
        _this.generatedVisibleRows = null;
        _this.generatedTotalRow = null;
        _this.filteredRows = null;
        _this.filteredColumns = null;
        _this.columns = _this.createColumnValues();
        _this.rows = _this.createItemValues("rows");
        return _this;
    }
    QuestionMatrixBaseModel.prototype.createColumnValues = function () {
        return this.createItemValues("columns");
    };
    QuestionMatrixBaseModel.prototype.getType = function () {
        return "matrixbase";
    };
    QuestionMatrixBaseModel.prototype.endLoadingFromJson = function () {
        _super.prototype.endLoadingFromJson.call(this);
        this.updateVisibilityBasedOnRows();
    };
    Object.defineProperty(QuestionMatrixBaseModel.prototype, "isCompositeQuestion", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixBaseModel.prototype, "showHeader", {
        /**
         * Specifies whether to display the table header that contains column captions.
         *
         * Default value: `true`
         */
        get: function () {
            return this.getPropertyValue("showHeader");
        },
        set: function (val) {
            this.setPropertyValue("showHeader", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixBaseModel.prototype, "columns", {
        /**
         * An array of matrix columns.
         *
         * For a Single-Select Matrix, the `columns` array can contain configuration objects with the `text` (display value) and `value` (value to be saved in survey results) properties. Alternatively, the array can contain primitive values that will be used as both the display values and values to be saved in survey results.
         *
         * [View "Single-Select Matrix" Demo](https://surveyjs.io/form-library/examples/single-selection-matrix-table-question/ (linkStyle))
         *
         * For a Multi-Select Matrix or Dynamic Matrix, the `columns` array should contain configuration objects with properties described in the [`MatrixDropdownColumn`](https://surveyjs.io/form-library/documentation/api-reference/multi-select-matrix-column-values) API Reference section.
         *
         * [View "Multi-Select Matrix" Demo](https://surveyjs.io/form-library/examples/questiontype-matrixdropdown/ (linkStyle))
         */
        get: function () {
            return this.getPropertyValue("columns");
        },
        set: function (newValue) {
            this.setPropertyValue("columns", newValue);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixBaseModel.prototype, "visibleColumns", {
        get: function () {
            return !!this.filteredColumns ? this.filteredColumns : this.columns;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixBaseModel.prototype, "rows", {
        /**
         * An array of matrix rows.
         *
         * This array can contain primitive values or objects with the `text` (display value) and `value` (value to be saved in survey results) properties.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/single-selection-matrix-table-question/ (linkStyle))
         */
        get: function () {
            return this.getPropertyValue("rows");
        },
        set: function (newValue) {
            var newRows = this.processRowsOnSet(newValue);
            this.setPropertyValue("rows", newRows);
            this.filterItems();
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixBaseModel.prototype.processRowsOnSet = function (newRows) {
        return newRows;
    };
    QuestionMatrixBaseModel.prototype.getVisibleRows = function () {
        return [];
    };
    Object.defineProperty(QuestionMatrixBaseModel.prototype, "visibleRows", {
        /**
         * Returns an array of visible matrix rows.
         * @see rowsVisibleIf
         */
        get: function () {
            return this.getVisibleRows();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixBaseModel.prototype, "rowsVisibleIf", {
        /**
         * A Boolean expression that is evaluated against each matrix row. If the expression evaluates to `false`, the row becomes hidden.
         *
         * A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
         *
         * Use the `{item}` placeholder to reference the current row in the expression.
         *
         * Refer to the following help topic for more information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see visibleRows
         * @see columnsVisibleIf
         */
        get: function () {
            return this.getPropertyValue("rowsVisibleIf", "");
        },
        set: function (val) {
            this.setPropertyValue("rowsVisibleIf", val);
            this.filterItems();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixBaseModel.prototype, "columnsVisibleIf", {
        /**
         * A Boolean expression that is evaluated against each matrix column. If the expression evaluates to `false`, the column becomes hidden.
         *
         * A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
         *
         * Use the `{item}` placeholder to reference the current column in the expression.
         *
         * Refer to the following help topic for more information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see rowsVisibleIf
         */
        get: function () {
            return this.getPropertyValue("columnsVisibleIf", "");
        },
        set: function (val) {
            this.setPropertyValue("columnsVisibleIf", val);
            this.filterItems();
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixBaseModel.prototype.runCondition = function (values, properties) {
        _super.prototype.runCondition.call(this, values, properties);
        this.runItemsCondition(values, properties);
    };
    QuestionMatrixBaseModel.prototype.filterItems = function () {
        if (this.areInvisibleElementsShowing) {
            this.onRowsChanged();
            return false;
        }
        if (this.isLoadingFromJson || !this.data)
            return false;
        return this.runItemsCondition(this.getDataFilteredValues(), this.getDataFilteredProperties());
    };
    QuestionMatrixBaseModel.prototype.onColumnsChanged = function () { };
    QuestionMatrixBaseModel.prototype.onRowsChanged = function () {
        this.updateVisibilityBasedOnRows();
        this.fireCallback(this.visibleRowsChangedCallback);
    };
    QuestionMatrixBaseModel.prototype.updateVisibilityBasedOnRows = function () {
        if (this.hideIfRowsEmpty) {
            this.onVisibleChanged();
        }
    };
    QuestionMatrixBaseModel.prototype.isVisibleCore = function () {
        var res = _super.prototype.isVisibleCore.call(this);
        if (!res || !this.hideIfRowsEmpty)
            return res;
        return this.rows.length > 0 && (!this.filteredRows || this.filteredRows.length > 0);
    };
    QuestionMatrixBaseModel.prototype.shouldRunColumnExpression = function () {
        return !this.survey || !this.survey.areInvisibleElementsShowing;
    };
    QuestionMatrixBaseModel.prototype.hasRowsAsItems = function () {
        return true;
    };
    QuestionMatrixBaseModel.prototype.runItemsCondition = function (values, properties) {
        var oldVisibleRows = null;
        if (!!this.filteredRows && !helpers_Helpers.isValueEmpty(this.defaultValue)) {
            oldVisibleRows = [];
            for (var i = 0; i < this.filteredRows.length; i++) {
                oldVisibleRows.push(this.filteredRows[i]);
            }
        }
        var hasChanges = this.hasRowsAsItems() && this.runConditionsForRows(values, properties);
        var hasColumnsChanged = this.runConditionsForColumns(values, properties);
        hasChanges = hasColumnsChanged || hasChanges;
        if (hasChanges) {
            if (this.isClearValueOnHidden && (!!this.filteredColumns || !!this.filteredRows)) {
                this.clearIncorrectValues();
            }
            if (!!oldVisibleRows) {
                this.restoreNewVisibleRowsValues(oldVisibleRows);
            }
            this.clearGeneratedRows();
            if (hasColumnsChanged) {
                this.onColumnsChanged();
            }
            this.onRowsChanged();
        }
        return hasChanges;
    };
    QuestionMatrixBaseModel.prototype.clearGeneratedRows = function () {
        this.generatedVisibleRows = null;
    };
    QuestionMatrixBaseModel.prototype.runConditionsForRows = function (values, properties) {
        var showInvisibile = !!this.survey && this.survey.areInvisibleElementsShowing;
        var runner = !showInvisibile && !!this.rowsVisibleIf
            ? new ConditionRunner(this.rowsVisibleIf)
            : null;
        this.filteredRows = [];
        var hasChanged = itemvalue_ItemValue.runConditionsForItems(this.rows, this.filteredRows, runner, values, properties, !showInvisibile);
        itemvalue_ItemValue.runEnabledConditionsForItems(this.rows, undefined, values, properties);
        if (this.filteredRows.length === this.rows.length) {
            this.filteredRows = null;
        }
        return hasChanged;
    };
    QuestionMatrixBaseModel.prototype.runConditionsForColumns = function (values, properties) {
        var useColumnsExpression = !!this.survey && !this.survey.areInvisibleElementsShowing;
        var runner = useColumnsExpression && !!this.columnsVisibleIf
            ? new ConditionRunner(this.columnsVisibleIf)
            : null;
        this.filteredColumns = [];
        var hasChanged = itemvalue_ItemValue.runConditionsForItems(this.columns, this.filteredColumns, runner, values, properties, this.shouldRunColumnExpression());
        if (this.filteredColumns.length === this.columns.length) {
            this.filteredColumns = null;
        }
        return hasChanged;
    };
    QuestionMatrixBaseModel.prototype.clearIncorrectValues = function () {
        var val = this.value;
        if (!val)
            return;
        var newVal = null;
        var isChanged = false;
        var rows = !!this.filteredRows ? this.filteredRows : this.rows;
        var columns = !!this.filteredColumns ? this.filteredColumns : this.columns;
        for (var key in val) {
            if (itemvalue_ItemValue.getItemByValue(rows, key) &&
                itemvalue_ItemValue.getItemByValue(columns, val[key])) {
                if (newVal == null)
                    newVal = {};
                newVal[key] = val[key];
            }
            else {
                isChanged = true;
            }
        }
        if (isChanged) {
            this.value = newVal;
        }
        _super.prototype.clearIncorrectValues.call(this);
    };
    QuestionMatrixBaseModel.prototype.clearInvisibleValuesInRows = function () {
        if (this.isEmpty())
            return;
        var newData = this.getUnbindValue(this.value);
        var rows = this.rows;
        for (var i = 0; i < rows.length; i++) {
            var key = rows[i].value;
            if (!!newData[key] && !rows[i].isVisible) {
                delete newData[key];
            }
        }
        if (this.isTwoValueEquals(newData, this.value))
            return;
        this.value = newData;
    };
    QuestionMatrixBaseModel.prototype.restoreNewVisibleRowsValues = function (oldVisibleRows) {
        var rows = !!this.filteredRows ? this.filteredRows : this.rows;
        var val = this.defaultValue;
        var newValue = this.getUnbindValue(this.value);
        var isChanged = false;
        for (var key in val) {
            if (itemvalue_ItemValue.getItemByValue(rows, key) &&
                !itemvalue_ItemValue.getItemByValue(oldVisibleRows, key)) {
                if (newValue == null)
                    newValue = {};
                newValue[key] = val[key];
                isChanged = true;
            }
        }
        if (isChanged) {
            this.value = newValue;
        }
    };
    QuestionMatrixBaseModel.prototype.needResponsiveWidth = function () {
        //TODO: make it mor intelligent
        return true;
    };
    Object.defineProperty(QuestionMatrixBaseModel.prototype, "columnsAutoWidth", {
        get: function () {
            return !this.isMobile && !this.columns.some(function (col) { return !!col.width; });
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixBaseModel.prototype.getTableCss = function () {
        var _a;
        return new CssClassBuilder()
            .append(this.cssClasses.root)
            .append(this.cssClasses.columnsAutoWidth, this.columnsAutoWidth)
            .append(this.cssClasses.noHeader, !this.showHeader)
            .append(this.cssClasses.hasFooter, !!((_a = this.renderedTable) === null || _a === void 0 ? void 0 : _a.showAddRowOnBottom))
            .append(this.cssClasses.rootAlternateRows, this.alternateRows)
            .append(this.cssClasses.rootVerticalAlignTop, (this.verticalAlign === "top"))
            .append(this.cssClasses.rootVerticalAlignMiddle, (this.verticalAlign === "middle")).toString();
    };
    Object.defineProperty(QuestionMatrixBaseModel.prototype, "columnMinWidth", {
        /**
         * Minimum column width in CSS values.
         *
         * @see width
         */
        get: function () {
            return this.getPropertyValue("columnMinWidth") || "";
        },
        set: function (val) {
            this.setPropertyValue("columnMinWidth", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixBaseModel.prototype, "rowTitleWidth", {
        /**
         * A width for the column that displays row titles (first column). Accepts CSS values.
         */
        get: function () {
            return this.getPropertyValue("rowTitleWidth") || "";
        },
        set: function (val) {
            this.setPropertyValue("rowTitleWidth", val);
        },
        enumerable: false,
        configurable: true
    });
    //a11y
    QuestionMatrixBaseModel.prototype.getCellAriaLabel = function (rowTitle, columnTitle) {
        var row = (this.getLocalizationString("matrix_row") || "row").toLocaleLowerCase();
        var column = (this.getLocalizationString("matrix_column") || "column").toLocaleLowerCase();
        return row + " " + rowTitle + ", " + column + " " + columnTitle;
    };
    Object.defineProperty(QuestionMatrixBaseModel.prototype, "isNewA11yStructure", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    martixBase_decorate([
        jsonobject_property()
    ], QuestionMatrixBaseModel.prototype, "verticalAlign", void 0);
    martixBase_decorate([
        jsonobject_property()
    ], QuestionMatrixBaseModel.prototype, "alternateRows", void 0);
    return QuestionMatrixBaseModel;
}(question_Question));

Serializer.addClass("matrixbase", [
    { name: "showCommentArea:switch", layout: "row", visible: true, category: "general" },
    "columnsVisibleIf:condition",
    "rowsVisibleIf:condition",
    "columnMinWidth",
    { name: "showHeader:boolean", default: true },
    {
        name: "verticalAlign",
        choices: ["top", "middle"],
        default: "middle",
    },
    { name: "alternateRows:boolean", default: false }
], undefined, "question");

// CONCATENATED MODULE: ./packages/survey-core/src/textPreProcessor.ts


var TextPreProcessorItem = /** @class */ (function () {
    function TextPreProcessorItem() {
    }
    return TextPreProcessorItem;
}());

var TextPreProcessorValue = /** @class */ (function () {
    function TextPreProcessorValue(name, returnDisplayValue) {
        this.name = name;
        this.returnDisplayValue = returnDisplayValue;
        this.isExists = false;
        this.canProcess = true;
    }
    return TextPreProcessorValue;
}());

var textPreProcessor_TextPreProcessor = /** @class */ (function () {
    function TextPreProcessor() {
        this._unObservableValues = [undefined];
    }
    Object.defineProperty(TextPreProcessor.prototype, "hasAllValuesOnLastRunValue", {
        get: function () {
            return this._unObservableValues[0];
        },
        set: function (val) {
            this._unObservableValues[0] = val;
        },
        enumerable: false,
        configurable: true
    });
    TextPreProcessor.prototype.process = function (text, returnDisplayValue, doEncoding) {
        if (returnDisplayValue === void 0) { returnDisplayValue = false; }
        if (doEncoding === void 0) { doEncoding = false; }
        this.hasAllValuesOnLastRunValue = true;
        if (!text)
            return text;
        if (!this.onProcess)
            return text;
        var items = this.getItems(text);
        for (var i = items.length - 1; i >= 0; i--) {
            var item = items[i];
            var name = this.getName(text.substring(item.start + 1, item.end));
            if (!name)
                continue;
            var textValue = new TextPreProcessorValue(name, returnDisplayValue);
            this.onProcess(textValue);
            if (!textValue.isExists) {
                if (textValue.canProcess) {
                    this.hasAllValuesOnLastRunValue = false;
                }
                continue;
            }
            if (helpers_Helpers.isValueEmpty(textValue.value)) {
                this.hasAllValuesOnLastRunValue = false;
            }
            var replacedValue = !helpers_Helpers.isValueEmpty(textValue.value)
                ? textValue.value
                : "";
            if (doEncoding) {
                replacedValue = encodeURIComponent(replacedValue);
            }
            text =
                text.substring(0, item.start) + replacedValue + text.substring(item.end + 1);
        }
        return text;
    };
    TextPreProcessor.prototype.processValue = function (name, returnDisplayValue) {
        var textValue = new TextPreProcessorValue(name, returnDisplayValue);
        if (!!this.onProcess) {
            this.onProcess(textValue);
        }
        return textValue;
    };
    Object.defineProperty(TextPreProcessor.prototype, "hasAllValuesOnLastRun", {
        get: function () {
            return !!this.hasAllValuesOnLastRunValue;
        },
        enumerable: false,
        configurable: true
    });
    TextPreProcessor.prototype.getItems = function (text) {
        var items = [];
        var length = text.length;
        var start = -1;
        var ch = "";
        for (var i = 0; i < length; i++) {
            ch = text[i];
            if (ch == "{")
                start = i;
            if (ch == "}") {
                if (start > -1) {
                    var item = new TextPreProcessorItem();
                    item.start = start;
                    item.end = i;
                    items.push(item);
                }
                start = -1;
            }
        }
        return items;
    };
    TextPreProcessor.prototype.getName = function (name) {
        if (!name)
            return;
        return name.trim();
    };
    return TextPreProcessor;
}());

var textPreProcessor_QuestionTextProcessor = /** @class */ (function () {
    function QuestionTextProcessor(variableName) {
        var _this = this;
        this.variableName = variableName;
        this.textPreProcessor = new textPreProcessor_TextPreProcessor();
        this.textPreProcessor.onProcess = function (textValue) {
            _this.getProcessedTextValue(textValue);
        };
    }
    QuestionTextProcessor.prototype.processValue = function (name, returnDisplayValue) {
        return this.textPreProcessor.processValue(name, returnDisplayValue);
    };
    Object.defineProperty(QuestionTextProcessor.prototype, "survey", {
        get: function () {
            return null;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextProcessor.prototype, "panel", {
        get: function () {
            return null;
        },
        enumerable: false,
        configurable: true
    });
    QuestionTextProcessor.prototype.getValues = function () {
        return !!this.panel ? this.panel.getValue() : null;
    };
    QuestionTextProcessor.prototype.getQuestionByName = function (name) {
        return !!this.panel
            ? this.panel.getQuestionByValueName(name)
            : null;
    };
    QuestionTextProcessor.prototype.getParentTextProcessor = function () { return null; };
    QuestionTextProcessor.prototype.onCustomProcessText = function (textValue) {
        return false;
    };
    QuestionTextProcessor.prototype.getQuestionDisplayText = function (question) {
        return question.displayValue;
    };
    //ITextProcessor
    QuestionTextProcessor.prototype.getProcessedTextValue = function (textValue) {
        if (!textValue)
            return;
        if (this.onCustomProcessText(textValue))
            return;
        var firstName = new conditionProcessValue_ProcessValue().getFirstName(textValue.name);
        textValue.isExists = firstName == this.variableName;
        textValue.canProcess = textValue.isExists;
        if (!textValue.canProcess)
            return;
        //name should start with the variable name
        textValue.name = textValue.name.replace(this.variableName + ".", "");
        var firstName = new conditionProcessValue_ProcessValue().getFirstName(textValue.name);
        var question = this.getQuestionByName(firstName);
        var values = {};
        if (question) {
            values[firstName] = textValue.returnDisplayValue
                ? this.getQuestionDisplayText(question)
                : question.value;
        }
        else {
            var allValues = !!this.panel ? this.getValues() : null;
            if (allValues) {
                values[firstName] = allValues[firstName];
            }
        }
        textValue.value = new conditionProcessValue_ProcessValue().getValue(textValue.name, values);
    };
    QuestionTextProcessor.prototype.processText = function (text, returnDisplayValue) {
        if (this.survey && this.survey.isDesignMode)
            return text;
        text = this.textPreProcessor.process(text, returnDisplayValue);
        text = this.processTextCore(this.getParentTextProcessor(), text, returnDisplayValue);
        return this.processTextCore(this.survey, text, returnDisplayValue);
    };
    QuestionTextProcessor.prototype.processTextEx = function (text, returnDisplayValue) {
        text = this.processText(text, returnDisplayValue);
        var hasAllValuesOnLastRun = this.textPreProcessor.hasAllValuesOnLastRun;
        var res = { hasAllValuesOnLastRun: true, text: text };
        if (this.survey) {
            res = this.survey.processTextEx(text, returnDisplayValue, false);
        }
        res.hasAllValuesOnLastRun =
            res.hasAllValuesOnLastRun && hasAllValuesOnLastRun;
        return res;
    };
    QuestionTextProcessor.prototype.processTextCore = function (textProcessor, text, returnDisplayValue) {
        if (!textProcessor)
            return text;
        return textProcessor.processText(text, returnDisplayValue);
    };
    return QuestionTextProcessor;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/question_custom.ts
var question_custom_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();








var question_custom_ComponentQuestionJSON = /** @class */ (function () {
    function ComponentQuestionJSON(name, json) {
        this.name = name;
        this.json = json;
        var self = this;
        Serializer.addClass(name, [], function (json) {
            return question_custom_ComponentCollection.Instance.createQuestion(!!json ? json.name : "", self);
        }, "question");
        this.onInit();
    }
    ComponentQuestionJSON.prototype.onInit = function () {
        if (!this.json.onInit)
            return;
        this.json.onInit();
    };
    ComponentQuestionJSON.prototype.onCreated = function (question) {
        if (!this.json.onCreated)
            return;
        this.json.onCreated(question);
    };
    ComponentQuestionJSON.prototype.onLoaded = function (question) {
        if (!this.json.onLoaded)
            return;
        this.json.onLoaded(question);
    };
    ComponentQuestionJSON.prototype.onAfterRender = function (question, htmlElement) {
        if (!this.json.onAfterRender)
            return;
        this.json.onAfterRender(question, htmlElement);
    };
    ComponentQuestionJSON.prototype.onAfterRenderContentElement = function (question, element, htmlElement) {
        if (!this.json.onAfterRenderContentElement)
            return;
        this.json.onAfterRenderContentElement(question, element, htmlElement);
    };
    ComponentQuestionJSON.prototype.onUpdateQuestionCssClasses = function (question, element, css) {
        if (!this.json.onUpdateQuestionCssClasses)
            return;
        this.json.onUpdateQuestionCssClasses(question, element, css);
    };
    ComponentQuestionJSON.prototype.onSetQuestionValue = function (question, newValue) {
        if (this.json.onSetQuestionValue) {
            this.json.onSetQuestionValue(question, newValue);
        }
        if (this.json.onValueSet) {
            this.json.onValueSet(question, newValue);
        }
    };
    ComponentQuestionJSON.prototype.onPropertyChanged = function (question, propertyName, newValue) {
        if (!this.json.onPropertyChanged)
            return;
        this.json.onPropertyChanged(question, propertyName, newValue);
    };
    ComponentQuestionJSON.prototype.onValueChanged = function (question, name, newValue) {
        if (!this.json.onValueChanged)
            return;
        this.json.onValueChanged(question, name, newValue);
    };
    ComponentQuestionJSON.prototype.onValueChanging = function (question, name, newValue) {
        if (!this.json.onValueChanging)
            return newValue;
        return this.json.onValueChanging(question, name, newValue);
    };
    ComponentQuestionJSON.prototype.onGetErrorText = function (question) {
        if (!this.json.getErrorText)
            return undefined;
        return this.json.getErrorText(question);
    };
    ComponentQuestionJSON.prototype.onItemValuePropertyChanged = function (question, item, propertyName, name, newValue) {
        if (!this.json.onItemValuePropertyChanged)
            return;
        this.json.onItemValuePropertyChanged(question, {
            obj: item,
            propertyName: propertyName,
            name: name,
            newValue: newValue,
        });
    };
    ComponentQuestionJSON.prototype.getDisplayValue = function (keyAsText, value, question) {
        if (!this.json.getDisplayValue)
            return question.getDisplayValue(keyAsText, value);
        return this.json.getDisplayValue(question);
    };
    Object.defineProperty(ComponentQuestionJSON.prototype, "defaultQuestionTitle", {
        get: function () {
            return this.json.defaultQuestionTitle;
        },
        enumerable: false,
        configurable: true
    });
    ComponentQuestionJSON.prototype.setValueToQuestion = function (val) {
        var converter = this.json.valueToQuestion || this.json.setValue;
        return !!converter ? converter(val) : val;
    };
    ComponentQuestionJSON.prototype.getValueFromQuestion = function (val) {
        var converter = this.json.valueFromQuestion || this.json.getValue;
        return !!converter ? converter(val) : val;
    };
    Object.defineProperty(ComponentQuestionJSON.prototype, "isComposite", {
        get: function () {
            return !!this.json.elementsJSON || !!this.json.createElements;
        },
        enumerable: false,
        configurable: true
    });
    ComponentQuestionJSON.prototype.getDynamicProperties = function () {
        if (!Array.isArray(this.dynamicProperties)) {
            this.dynamicProperties = this.calcDynamicProperties();
        }
        return this.dynamicProperties;
    };
    ComponentQuestionJSON.prototype.calcDynamicProperties = function () {
        var baseProps = this.json.inheritBaseProps;
        if (!baseProps || !this.json.questionJSON)
            return [];
        var type = this.json.questionJSON.type;
        if (!type)
            return [];
        if (Array.isArray(baseProps)) {
            var props_1 = [];
            baseProps.forEach(function (name) {
                var prop = Serializer.findProperty(type, name);
                if (prop) {
                    props_1.push(prop);
                }
            });
            return props_1;
        }
        var invalidNames = [];
        for (var key in this.json.questionJSON) {
            invalidNames.push(key);
        }
        return Serializer.getDynamicPropertiesByTypes(this.name, type, invalidNames);
    };
    return ComponentQuestionJSON;
}());

var question_custom_ComponentCollection = /** @class */ (function () {
    function ComponentCollection() {
        this.customQuestionValues = [];
    }
    ComponentCollection.prototype.add = function (json) {
        if (!json)
            return;
        var name = json.name;
        if (!name) {
            throw "Attribute name is missed";
        }
        name = name.toLowerCase();
        if (!!this.getCustomQuestionByName(name)) {
            throw "There is already registered custom question with name '" +
                name +
                "'";
        }
        if (!!Serializer.findClass(name)) {
            throw "There is already class with name '" + name + "'";
        }
        var customQuestion = new question_custom_ComponentQuestionJSON(name, json);
        if (!!this.onAddingJson)
            this.onAddingJson(name, customQuestion.isComposite);
        this.customQuestionValues.push(customQuestion);
    };
    ComponentCollection.prototype.remove = function (componentName) {
        if (!componentName)
            return false;
        var index = this.getCustomQuestionIndex(componentName.toLowerCase());
        if (index < 0)
            return false;
        this.removeByIndex(index);
        return true;
    };
    Object.defineProperty(ComponentCollection.prototype, "items", {
        get: function () {
            return this.customQuestionValues;
        },
        enumerable: false,
        configurable: true
    });
    ComponentCollection.prototype.getCustomQuestionByName = function (name) {
        var index = this.getCustomQuestionIndex(name);
        return index >= 0 ? this.customQuestionValues[index] : undefined;
    };
    ComponentCollection.prototype.getCustomQuestionIndex = function (name) {
        for (var i = 0; i < this.customQuestionValues.length; i++) {
            if (this.customQuestionValues[i].name === name)
                return i;
        }
        return -1;
    };
    ComponentCollection.prototype.removeByIndex = function (index) {
        Serializer.removeClass(this.customQuestionValues[index].name);
        this.customQuestionValues.splice(index, 1);
    };
    ComponentCollection.prototype.clear = function (includeInternal) {
        for (var i = this.customQuestionValues.length - 1; i >= 0; i--) {
            if (includeInternal || !this.customQuestionValues[i].json.internal) {
                this.removeByIndex(i);
            }
        }
    };
    ComponentCollection.prototype.createQuestion = function (name, questionJSON) {
        if (!!questionJSON.isComposite)
            return this.createCompositeModel(name, questionJSON);
        return this.createCustomModel(name, questionJSON);
    };
    ComponentCollection.prototype.createCompositeModel = function (name, questionJSON) {
        if (!!this.onCreateComposite)
            return this.onCreateComposite(name, questionJSON);
        return new question_custom_QuestionCompositeModel(name, questionJSON);
    };
    ComponentCollection.prototype.createCustomModel = function (name, questionJSON) {
        if (!!this.onCreateCustom)
            return this.onCreateCustom(name, questionJSON);
        return new question_custom_QuestionCustomModel(name, questionJSON);
    };
    ComponentCollection.Instance = new ComponentCollection();
    return ComponentCollection;
}());

var question_custom_QuestionCustomModelBase = /** @class */ (function (_super) {
    question_custom_extends(QuestionCustomModelBase, _super);
    function QuestionCustomModelBase(name, customQuestion) {
        var _this = _super.call(this, name) || this;
        _this.customQuestion = customQuestion;
        CustomPropertiesCollection.createProperties(_this);
        survey_element_SurveyElement.CreateDisabledDesignElements = true;
        _this.locQuestionTitle = _this.createLocalizableString("questionTitle", _this);
        _this.locQuestionTitle.setJson(_this.customQuestion.defaultQuestionTitle);
        _this.createWrapper();
        survey_element_SurveyElement.CreateDisabledDesignElements = false;
        if (!!_this.customQuestion) {
            _this.customQuestion.onCreated(_this);
        }
        return _this;
    }
    QuestionCustomModelBase.prototype.getType = function () {
        return !!this.customQuestion ? this.customQuestion.name : "custom";
    };
    QuestionCustomModelBase.prototype.locStrsChanged = function () {
        _super.prototype.locStrsChanged.call(this);
        if (!!this.getElement()) {
            this.getElement().locStrsChanged();
        }
    };
    QuestionCustomModelBase.prototype.localeChanged = function () {
        _super.prototype.locStrsChanged.call(this);
        if (!!this.getElement()) {
            this.getElement().localeChanged();
        }
    };
    QuestionCustomModelBase.prototype.getDefaultTitle = function () {
        if (!this.locQuestionTitle.isEmpty) {
            return this.getProcessedText(this.locQuestionTitle.textOrHtml);
        }
        return _super.prototype.getDefaultTitle.call(this);
    };
    QuestionCustomModelBase.prototype.addUsedLocales = function (locales) {
        _super.prototype.addUsedLocales.call(this, locales);
        if (!!this.getElement()) {
            this.getElement().addUsedLocales(locales);
        }
    };
    QuestionCustomModelBase.prototype.needResponsiveWidth = function () {
        var el = this.getElement();
        return !!el ? el.needResponsiveWidth() : false;
    };
    QuestionCustomModelBase.prototype.createWrapper = function () { };
    QuestionCustomModelBase.prototype.onPropertyValueChanged = function (name, oldValue, newValue) {
        _super.prototype.onPropertyValueChanged.call(this, name, oldValue, newValue);
        if (!!this.customQuestion && !this.isLoadingFromJson) {
            this.customQuestion.onPropertyChanged(this, name, newValue);
        }
    };
    QuestionCustomModelBase.prototype.itemValuePropertyChanged = function (item, name, oldValue, newValue) {
        _super.prototype.itemValuePropertyChanged.call(this, item, name, oldValue, newValue);
        if (!!this.customQuestion && !this.isLoadingFromJson) {
            this.customQuestion.onItemValuePropertyChanged(this, item, item.ownerPropertyName, name, newValue);
        }
    };
    QuestionCustomModelBase.prototype.onFirstRendering = function () {
        var el = this.getElement();
        if (!!el) {
            el.onFirstRendering();
        }
        _super.prototype.onFirstRendering.call(this);
    };
    QuestionCustomModelBase.prototype.onHidingContent = function () {
        _super.prototype.onHidingContent.call(this);
        var el = this.getElement();
        if (!!el) {
            el.onHidingContent();
        }
    };
    QuestionCustomModelBase.prototype.getProgressInfo = function () {
        var res = _super.prototype.getProgressInfo.call(this);
        if (!!this.getElement()) {
            res = this.getElement().getProgressInfo();
        }
        if (this.isRequired && res.requiredQuestionCount == 0) {
            res.requiredQuestionCount = 1;
            if (!this.isEmpty()) {
                res.answeredQuestionCount = 1;
            }
        }
        return res;
    };
    QuestionCustomModelBase.prototype.initElement = function (el) {
        if (!el)
            return;
        el.setSurveyImpl(this);
        el.disableDesignActions = true;
    };
    QuestionCustomModelBase.prototype.setSurveyImpl = function (value, isLight) {
        this.isSettingValOnLoading = true;
        _super.prototype.setSurveyImpl.call(this, value, isLight);
        this.initElement(this.getElement());
        this.isSettingValOnLoading = false;
    };
    QuestionCustomModelBase.prototype.onSurveyLoad = function () {
        _super.prototype.onSurveyLoad.call(this);
        if (!!this.getElement()) {
            this.getElement().onSurveyLoad();
            this.customQuestion.onLoaded(this);
        }
    };
    QuestionCustomModelBase.prototype.afterRenderQuestionElement = function (el) {
        //Do nothing
    };
    QuestionCustomModelBase.prototype.afterRenderCore = function (el) {
        _super.prototype.afterRenderCore.call(this, el);
        if (!!this.customQuestion) {
            this.customQuestion.onAfterRender(this, el);
        }
    };
    QuestionCustomModelBase.prototype.onUpdateQuestionCssClasses = function (element, css) {
        if (!!this.customQuestion) {
            this.customQuestion.onUpdateQuestionCssClasses(this, element, css);
        }
    };
    QuestionCustomModelBase.prototype.setQuestionValue = function (newValue, updateIsAnswered) {
        if (updateIsAnswered === void 0) { updateIsAnswered = true; }
        _super.prototype.setQuestionValue.call(this, newValue, updateIsAnswered);
        this.updateElementCss();
        if (!!this.customQuestion) {
            this.customQuestion.onSetQuestionValue(this, newValue);
        }
    };
    QuestionCustomModelBase.prototype.setNewValue = function (newValue) {
        _super.prototype.setNewValue.call(this, newValue);
        this.updateElementCss();
    };
    QuestionCustomModelBase.prototype.onCheckForErrors = function (errors, isOnValueChanged) {
        _super.prototype.onCheckForErrors.call(this, errors, isOnValueChanged);
        if (!!this.customQuestion) {
            var text = this.customQuestion.onGetErrorText(this);
            if (!!text) {
                errors.push(new CustomError(text, this));
            }
        }
    };
    //ISurveyImpl
    QuestionCustomModelBase.prototype.getSurveyData = function () {
        return this;
    };
    QuestionCustomModelBase.prototype.getTextProcessor = function () {
        return this.textProcessor;
    };
    //ISurveyData
    QuestionCustomModelBase.prototype.getValue = function (name) {
        return this.value;
    };
    QuestionCustomModelBase.prototype.setValue = function (name, newValue, locNotification, allowNotifyValueChanged) {
        if (!this.data)
            return;
        if (!!this.customQuestion) {
            this.customQuestion.onValueChanged(this, name, newValue);
        }
        var newName = this.convertDataName(name);
        var valueForSurvey = this.convertDataValue(name, newValue);
        if (this.valueToDataCallback) {
            valueForSurvey = this.valueToDataCallback(valueForSurvey);
        }
        this.data.setValue(newName, valueForSurvey, locNotification, allowNotifyValueChanged);
        this.updateIsAnswered();
        this.updateElementCss();
    };
    QuestionCustomModelBase.prototype.getQuestionByName = function (name) {
        return undefined;
    };
    QuestionCustomModelBase.prototype.isValueChanging = function (name, newValue) {
        if (!!this.customQuestion) {
            var qValue = newValue;
            newValue = this.customQuestion.onValueChanging(this, name, newValue);
            if (!helpers_Helpers.isTwoValueEquals(newValue, qValue)) {
                var q = this.getQuestionByName(name);
                if (!!q) {
                    q.value = newValue;
                    return true;
                }
            }
        }
        return false;
    };
    QuestionCustomModelBase.prototype.convertDataName = function (name) {
        return this.getValueName();
    };
    QuestionCustomModelBase.prototype.convertDataValue = function (name, newValue) {
        return newValue;
    };
    QuestionCustomModelBase.prototype.getVariable = function (name) {
        return !!this.data ? this.data.getVariable(name) : null;
    };
    QuestionCustomModelBase.prototype.setVariable = function (name, newValue) {
        if (!this.data)
            return;
        this.data.setVariable(name, newValue);
    };
    QuestionCustomModelBase.prototype.getComment = function (name) {
        return !!this.data ? this.data.getComment(this.getValueName()) : "";
    };
    QuestionCustomModelBase.prototype.setComment = function (name, newValue, locNotification) {
        if (!this.data)
            return;
        this.data.setComment(this.getValueName(), newValue, locNotification);
    };
    QuestionCustomModelBase.prototype.getAllValues = function () {
        return !!this.data ? this.data.getAllValues() : {};
    };
    QuestionCustomModelBase.prototype.getFilteredValues = function () {
        return !!this.data ? this.data.getFilteredValues() : {};
    };
    QuestionCustomModelBase.prototype.getFilteredProperties = function () {
        return !!this.data ? this.data.getFilteredProperties() : {};
    };
    QuestionCustomModelBase.prototype.findQuestionByName = function (name) {
        return !!this.data ? this.data.findQuestionByName(name) : null;
    };
    QuestionCustomModelBase.prototype.getEditingSurveyElement = function () {
        return undefined;
    };
    //IPanel
    QuestionCustomModelBase.prototype.addElement = function (element, index) { };
    QuestionCustomModelBase.prototype.removeElement = function (element) {
        return false;
    };
    QuestionCustomModelBase.prototype.getQuestionTitleLocation = function () {
        return "left";
    };
    QuestionCustomModelBase.prototype.getQuestionTitleWidth = function () {
        return undefined;
    };
    QuestionCustomModelBase.prototype.getColumsForElement = function (el) {
        return [];
    };
    QuestionCustomModelBase.prototype.updateColumns = function () { };
    QuestionCustomModelBase.prototype.getQuestionStartIndex = function () {
        return this.getStartIndex();
    };
    QuestionCustomModelBase.prototype.getChildrenLayoutType = function () {
        return "row";
    };
    QuestionCustomModelBase.prototype.elementWidthChanged = function (el) { };
    Object.defineProperty(QuestionCustomModelBase.prototype, "elements", {
        get: function () {
            return [];
        },
        enumerable: false,
        configurable: true
    });
    QuestionCustomModelBase.prototype.indexOf = function (el) {
        return -1;
    };
    QuestionCustomModelBase.prototype.ensureRowsVisibility = function () {
        // do nothing
    };
    QuestionCustomModelBase.prototype.validateContainerOnly = function () {
        // do nothing
    };
    QuestionCustomModelBase.prototype.onQuestionValueChanged = function (el) {
        // do nothing
    };
    QuestionCustomModelBase.prototype.getQuestionErrorLocation = function () {
        return this.getErrorLocation();
    };
    QuestionCustomModelBase.prototype.getContentDisplayValueCore = function (keyAsText, value, question) {
        if (!question)
            return _super.prototype.getDisplayValueCore.call(this, keyAsText, value);
        return this.customQuestion.getDisplayValue(keyAsText, value, question);
    };
    return QuestionCustomModelBase;
}(question_Question));

var question_custom_QuestionCustomModel = /** @class */ (function (_super) {
    question_custom_extends(QuestionCustomModel, _super);
    function QuestionCustomModel() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    QuestionCustomModel.prototype.getTemplate = function () {
        return "custom";
    };
    QuestionCustomModel.prototype.getDynamicProperties = function () {
        return this.customQuestion.getDynamicProperties() || [];
    };
    QuestionCustomModel.prototype.getDynamicType = function () {
        return this.questionWrapper ? this.questionWrapper.getType() : "question";
    };
    QuestionCustomModel.prototype.getOriginalObj = function () {
        return this.questionWrapper;
    };
    QuestionCustomModel.prototype.createWrapper = function () {
        var _this = this;
        this.questionWrapper = this.createQuestion();
        this.createDynamicProperties(this.questionWrapper);
        if (this.getDynamicProperties().length > 0) {
            this.questionWrapper.onPropertyValueChangedCallback = function (name, oldValue, newValue, sender, arrayChanges) {
                var prop = _this.getDynamicProperty(name);
                if (prop) {
                    _this.propertyValueChanged(name, oldValue, newValue, arrayChanges);
                }
            };
        }
    };
    QuestionCustomModel.prototype.getDynamicProperty = function (name) {
        var props = this.getDynamicProperties();
        for (var i = 0; i < props.length; i++) {
            if (props[i].name === name)
                return props[i];
        }
        return null;
    };
    QuestionCustomModel.prototype.getElement = function () {
        return this.contentQuestion;
    };
    QuestionCustomModel.prototype.onAnyValueChanged = function (name, questionName) {
        _super.prototype.onAnyValueChanged.call(this, name, questionName);
        if (!!this.contentQuestion) {
            this.contentQuestion.onAnyValueChanged(name, questionName);
        }
    };
    QuestionCustomModel.prototype.getQuestionByName = function (name) {
        return this.contentQuestion;
    };
    QuestionCustomModel.prototype.getDefaultTitle = function () {
        if (this.hasJSONTitle && this.contentQuestion) {
            return this.getProcessedText(this.contentQuestion.title);
        }
        return _super.prototype.getDefaultTitle.call(this);
    };
    QuestionCustomModel.prototype.setValue = function (name, newValue, locNotification, allowNotifyValueChanged) {
        if (this.isValueChanging(name, newValue))
            return;
        _super.prototype.setValue.call(this, name, newValue, locNotification, allowNotifyValueChanged);
    };
    QuestionCustomModel.prototype.onSetData = function () {
        _super.prototype.onSetData.call(this);
        if (!!this.survey && !this.isEmpty()) {
            this.setValue(this.name, this.value, false, this.allowNotifyValueChanged);
        }
    };
    QuestionCustomModel.prototype.hasErrors = function (fireCallback, rec) {
        if (fireCallback === void 0) { fireCallback = true; }
        if (rec === void 0) { rec = null; }
        if (!this.contentQuestion)
            return false;
        var res = this.contentQuestion.hasErrors(fireCallback, rec);
        this.errors = [];
        for (var i = 0; i < this.contentQuestion.errors.length; i++) {
            this.errors.push(this.contentQuestion.errors[i]);
        }
        if (!res) {
            res = _super.prototype.hasErrors.call(this, fireCallback, rec);
        }
        this.updateElementCss();
        return res;
    };
    QuestionCustomModel.prototype.focus = function (onError) {
        if (onError === void 0) { onError = false; }
        if (!!this.contentQuestion) {
            this.contentQuestion.focus(onError);
        }
        else {
            _super.prototype.focus.call(this, onError);
        }
    };
    QuestionCustomModel.prototype.afterRenderCore = function (el) {
        _super.prototype.afterRenderCore.call(this, el);
        if (!!this.contentQuestion) {
            this.contentQuestion.afterRender(el);
        }
    };
    Object.defineProperty(QuestionCustomModel.prototype, "contentQuestion", {
        get: function () {
            return this.questionWrapper;
        },
        enumerable: false,
        configurable: true
    });
    QuestionCustomModel.prototype.createQuestion = function () {
        var _this = this;
        var json = this.customQuestion.json;
        var res = null;
        if (!!json.questionJSON) {
            this.hasJSONTitle = !!json.questionJSON.title;
            var qType = json.questionJSON.type;
            if (!qType || !Serializer.findClass(qType))
                throw "type attribute in questionJSON is empty or incorrect";
            res = Serializer.createClass(qType);
            res.fromJSON(json.questionJSON);
            res = this.checkCreatedQuestion(res);
        }
        else {
            if (!!json.createQuestion) {
                res = this.checkCreatedQuestion(json.createQuestion());
            }
        }
        this.initElement(res);
        if (!!res) {
            res.isContentElement = true;
            if (!res.name) {
                res.name = "question";
            }
            res.onUpdateCssClassesCallback = function (css) {
                _this.onUpdateQuestionCssClasses(res, css);
            };
            res.hasCssErrorCallback = function () { return _this.errors.length > 0; };
            res.setValueChangedDirectlyCallback = function (val) { _this.setValueChangedDirectly(val); };
        }
        return res;
    };
    QuestionCustomModel.prototype.checkCreatedQuestion = function (res) {
        if (!res)
            return res;
        if (!res.isQuestion) {
            if (Array.isArray(res.questions) && res.questions.length > 0) {
                res = res.questions[0];
            }
            else {
                res = Serializer.createClass("text");
            }
            ConsoleWarnings.error("Could not create component: '" + this.getType() + "'. questionJSON should be a question.");
        }
        return res;
    };
    QuestionCustomModel.prototype.onSurveyLoad = function () {
        _super.prototype.onSurveyLoad.call(this);
        if (!this.contentQuestion)
            return;
        if (this.isEmpty() && !this.contentQuestion.isEmpty()) {
            this.value = this.getContentQuestionValue();
        }
    };
    QuestionCustomModel.prototype.runCondition = function (values, properties) {
        _super.prototype.runCondition.call(this, values, properties);
        if (!!this.contentQuestion) {
            this.contentQuestion.runCondition(values, properties);
        }
    };
    QuestionCustomModel.prototype.convertDataName = function (name) {
        var q = this.contentQuestion;
        if (!q || name === this.getValueName())
            return _super.prototype.convertDataName.call(this, name);
        var newName = name.replace(q.getValueName(), this.getValueName());
        return newName.indexOf(this.getValueName()) == 0
            ? newName
            : _super.prototype.convertDataName.call(this, name);
    };
    QuestionCustomModel.prototype.convertDataValue = function (name, newValue) {
        return this.convertDataName(name) == _super.prototype.convertDataName.call(this, name)
            ? this.getContentQuestionValue()
            : newValue;
    };
    QuestionCustomModel.prototype.getContentQuestionValue = function () {
        if (!this.contentQuestion)
            return undefined;
        var val = this.contentQuestion.value;
        if (!!this.customQuestion)
            val = this.customQuestion.getValueFromQuestion(val);
        return val;
    };
    QuestionCustomModel.prototype.setContentQuestionValue = function (val) {
        if (!this.contentQuestion)
            return;
        if (!!this.customQuestion)
            val = this.customQuestion.setValueToQuestion(val);
        this.contentQuestion.value = val;
    };
    QuestionCustomModel.prototype.canSetValueToSurvey = function () {
        return false;
    };
    QuestionCustomModel.prototype.setQuestionValue = function (newValue, updateIsAnswered) {
        if (updateIsAnswered === void 0) { updateIsAnswered = true; }
        _super.prototype.setQuestionValue.call(this, newValue, updateIsAnswered);
        if (!this.isLoadingFromJson && !!this.contentQuestion &&
            !this.isTwoValueEquals(this.getContentQuestionValue(), newValue)) {
            this.setContentQuestionValue(this.getUnbindValue(newValue));
        }
    };
    QuestionCustomModel.prototype.onSurveyValueChanged = function (newValue) {
        _super.prototype.onSurveyValueChanged.call(this, newValue);
        if (!!this.contentQuestion) {
            this.contentQuestion.onSurveyValueChanged(newValue);
        }
    };
    QuestionCustomModel.prototype.getValueCore = function () {
        if (!!this.contentQuestion)
            return this.getContentQuestionValue();
        return _super.prototype.getValueCore.call(this);
    };
    QuestionCustomModel.prototype.setValueChangedDirectly = function (val) {
        if (this.isSettingValueChanged)
            return;
        this.isSettingValueChanged = true;
        _super.prototype.setValueChangedDirectly.call(this, val);
        if (!!this.contentQuestion) {
            this.contentQuestion.setValueChangedDirectly(val);
        }
        this.isSettingValueChanged = false;
    };
    QuestionCustomModel.prototype.createDynamicProperties = function (el) {
        if (!el)
            return;
        var props = this.getDynamicProperties();
        if (Array.isArray(props)) {
            Serializer.addDynamicPropertiesIntoObj(this, el, props);
        }
    };
    QuestionCustomModel.prototype.initElement = function (el) {
        var _this = this;
        _super.prototype.initElement.call(this, el);
        if (!!el) {
            el.parent = this;
            el.afterRenderQuestionCallback = function (question, element) {
                if (!!_this.customQuestion) {
                    _this.customQuestion.onAfterRenderContentElement(_this, question, element);
                }
            };
        }
    };
    QuestionCustomModel.prototype.updateElementCss = function (reNew) {
        if (!!this.contentQuestion) {
            this.questionWrapper.updateElementCss(reNew);
        }
        _super.prototype.updateElementCss.call(this, reNew);
    };
    QuestionCustomModel.prototype.updateElementCssCore = function (cssClasses) {
        if (!!this.contentQuestion) {
            cssClasses = this.contentQuestion.cssClasses;
        }
        _super.prototype.updateElementCssCore.call(this, cssClasses);
    };
    QuestionCustomModel.prototype.getDisplayValueCore = function (keyAsText, value) {
        return _super.prototype.getContentDisplayValueCore.call(this, keyAsText, value, this.contentQuestion);
    };
    return QuestionCustomModel;
}(question_custom_QuestionCustomModelBase));

var QuestionCompositeTextProcessor = /** @class */ (function (_super) {
    question_custom_extends(QuestionCompositeTextProcessor, _super);
    function QuestionCompositeTextProcessor(composite, variableName) {
        var _this = _super.call(this, variableName) || this;
        _this.composite = composite;
        _this.variableName = variableName;
        return _this;
    }
    Object.defineProperty(QuestionCompositeTextProcessor.prototype, "survey", {
        get: function () {
            return this.composite.survey;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCompositeTextProcessor.prototype, "panel", {
        get: function () {
            return this.composite.contentPanel;
        },
        enumerable: false,
        configurable: true
    });
    return QuestionCompositeTextProcessor;
}(textPreProcessor_QuestionTextProcessor));
var question_custom_QuestionCompositeModel = /** @class */ (function (_super) {
    question_custom_extends(QuestionCompositeModel, _super);
    function QuestionCompositeModel(name, customQuestion) {
        var _this = _super.call(this, name, customQuestion) || this;
        _this.customQuestion = customQuestion;
        _this.settingNewValue = false;
        _this.textProcessing = new QuestionCompositeTextProcessor(_this, QuestionCompositeModel.ItemVariableName);
        return _this;
    }
    QuestionCompositeModel.prototype.createWrapper = function () {
        this.panelWrapper = this.createPanel();
    };
    QuestionCompositeModel.prototype.getTemplate = function () {
        return "composite";
    };
    QuestionCompositeModel.prototype.getElement = function () {
        return this.contentPanel;
    };
    QuestionCompositeModel.prototype.getCssRoot = function (cssClasses) {
        return new CssClassBuilder().append(_super.prototype.getCssRoot.call(this, cssClasses)).append(cssClasses.composite).toString();
    };
    Object.defineProperty(QuestionCompositeModel.prototype, "contentPanel", {
        get: function () {
            return this.panelWrapper;
        },
        enumerable: false,
        configurable: true
    });
    QuestionCompositeModel.prototype.hasErrors = function (fireCallback, rec) {
        if (fireCallback === void 0) { fireCallback = true; }
        if (rec === void 0) { rec = null; }
        var res = _super.prototype.hasErrors.call(this, fireCallback, rec);
        if (!this.contentPanel)
            return res;
        return this.contentPanel.hasErrors(fireCallback, false, rec) || res;
    };
    QuestionCompositeModel.prototype.updateElementCss = function (reNew) {
        _super.prototype.updateElementCss.call(this, reNew);
        if (this.contentPanel) {
            this.contentPanel.updateElementCss(reNew);
        }
    };
    QuestionCompositeModel.prototype.dispose = function () {
        this.unConnectEditingObj();
        _super.prototype.dispose.call(this);
    };
    QuestionCompositeModel.prototype.updateEditingObj = function () {
        var _this = this;
        var _a;
        var obj = (_a = this.data) === null || _a === void 0 ? void 0 : _a.getEditingSurveyElement();
        if (!obj)
            return undefined;
        var newObj = obj[this.getValueName()];
        if (!!newObj && !newObj.onPropertyChanged) {
            newObj = undefined;
        }
        if (newObj !== this.editingObjValue) {
            this.unConnectEditingObj();
            this.editingObjValue = newObj;
            if (!!newObj) {
                this.onEditingObjPropertyChanged = function (sender, options) {
                    _this.setNewValueIntoQuestion(options.name, _this.editingObjValue[options.name]);
                };
                newObj.onPropertyChanged.add(this.onEditingObjPropertyChanged);
            }
        }
        return this.editingObjValue;
    };
    QuestionCompositeModel.prototype.unConnectEditingObj = function () {
        if (!!this.editingObjValue && !this.editingObjValue.isDisposed) {
            this.editingObjValue.onPropertyChanged.remove(this.onEditingObjPropertyChanged);
        }
    };
    QuestionCompositeModel.prototype.getEditingSurveyElement = function () {
        return this.editingObjValue;
    };
    QuestionCompositeModel.prototype.getTextProcessor = function () {
        return this.textProcessing;
    };
    QuestionCompositeModel.prototype.findQuestionByName = function (name) {
        var res = this.getQuestionByName(name);
        if (!!res)
            return res;
        return _super.prototype.findQuestionByName.call(this, name);
    };
    QuestionCompositeModel.prototype.clearValueIfInvisibleCore = function (reason) {
        _super.prototype.clearValueIfInvisibleCore.call(this, reason);
        var questions = this.contentPanel.questions;
        for (var i = 0; i < questions.length; i++) {
            questions[i].clearValueIfInvisible(reason);
        }
    };
    QuestionCompositeModel.prototype.onAnyValueChanged = function (name, questionName) {
        _super.prototype.onAnyValueChanged.call(this, name, questionName);
        var questions = this.contentPanel.questions;
        for (var i = 0; i < questions.length; i++) {
            questions[i].onAnyValueChanged(name, questionName);
        }
    };
    Object.defineProperty(QuestionCompositeModel.prototype, "hasSingleInput", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCompositeModel.prototype, "isContainer", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    QuestionCompositeModel.prototype.createPanel = function () {
        var _this = this;
        var res = Serializer.createClass("panel");
        res.showQuestionNumbers = "off";
        res.renderWidth = "100%";
        var json = this.customQuestion.json;
        if (!!json.elementsJSON) {
            res.fromJSON({ elements: json.elementsJSON });
        }
        if (!!json.createElements) {
            json.createElements(res, this);
        }
        this.initElement(res);
        res.readOnly = this.isReadOnly;
        res.questions.forEach(function (q) { return q.onUpdateCssClassesCallback = function (css) {
            _this.onUpdateQuestionCssClasses(q, css);
        }; });
        this.setAfterRenderCallbacks(res);
        return res;
    };
    QuestionCompositeModel.prototype.onReadOnlyChanged = function () {
        if (!!this.contentPanel) {
            this.contentPanel.readOnly = this.isReadOnly;
        }
        _super.prototype.onReadOnlyChanged.call(this);
    };
    QuestionCompositeModel.prototype.updateValueFromSurvey = function (newValue, clearData) {
        if (clearData === void 0) { clearData = false; }
        this.updateEditingObj();
        _super.prototype.updateValueFromSurvey.call(this, newValue, clearData);
    };
    QuestionCompositeModel.prototype.onSurveyLoad = function () {
        this.isSettingValOnLoading = true;
        if (!!this.contentPanel) {
            this.contentPanel.readOnly = this.isReadOnly;
            this.setIsContentElement(this.contentPanel);
        }
        _super.prototype.onSurveyLoad.call(this);
        if (!!this.contentPanel) {
            var val = this.getContentPanelValue();
            if (!helpers_Helpers.isValueEmpty(val)) {
                this.value = val;
            }
        }
        this.isSettingValOnLoading = false;
    };
    QuestionCompositeModel.prototype.setIsContentElement = function (panel) {
        panel.isContentElement = true;
        var elements = panel.elements;
        for (var i = 0; i < elements.length; i++) {
            var el = elements[i];
            if (el.isPanel) {
                this.setIsContentElement(el);
            }
            else {
                el.isContentElement = true;
            }
        }
    };
    QuestionCompositeModel.prototype.setVisibleIndex = function (val) {
        var res = _super.prototype.setVisibleIndex.call(this, val);
        if (this.isVisible && !!this.contentPanel) {
            res += this.contentPanel.setVisibleIndex(val);
        }
        return res;
    };
    QuestionCompositeModel.prototype.runCondition = function (values, properties) {
        _super.prototype.runCondition.call(this, values, properties);
        if (!!this.contentPanel) {
            var oldComposite = values[QuestionCompositeModel.ItemVariableName];
            values[QuestionCompositeModel.ItemVariableName] = this.contentPanel.getValue();
            this.contentPanel.runCondition(values, properties);
            delete values[QuestionCompositeModel.ItemVariableName];
            if (!!oldComposite) {
                values[QuestionCompositeModel.ItemVariableName] = oldComposite;
            }
        }
    };
    QuestionCompositeModel.prototype.onSurveyValueChanged = function (newValue) {
        _super.prototype.onSurveyValueChanged.call(this, newValue);
        var val = !!newValue ? newValue : {};
        if (!!this.contentPanel) {
            this.contentPanel.questions.forEach(function (q) {
                q.onSurveyValueChanged(val[q.getValueName()]);
            });
        }
    };
    QuestionCompositeModel.prototype.getValue = function (name) {
        var val = this.value;
        return !!val ? val[name] : null;
    };
    QuestionCompositeModel.prototype.getQuestionByName = function (name) {
        return !!this.contentPanel ? this.contentPanel.getQuestionByName(name) : undefined;
    };
    QuestionCompositeModel.prototype.setValue = function (name, newValue, locNotification, allowNotifyValueChanged) {
        if (this.settingNewValue) {
            this.setNewValueIntoQuestion(name, newValue);
            return;
        }
        if (this.isValueChanging(name, newValue))
            return;
        this.settingNewValue = true;
        if (!this.isEditingSurveyElement && !!this.contentPanel) {
            var index = 0;
            var maxTimes = this.contentPanel.questions.length + 1;
            while (index < maxTimes && this.updateValueCoreWithPanelValue())
                index++;
        }
        this.setNewValueIntoQuestion(name, newValue);
        _super.prototype.setValue.call(this, name, newValue, locNotification, allowNotifyValueChanged);
        this.settingNewValue = false;
        this.runPanelTriggers(QuestionCompositeModel.ItemVariableName + "." + name, newValue);
    };
    QuestionCompositeModel.prototype.runPanelTriggers = function (name, value) {
        if (!!this.contentPanel) {
            this.contentPanel.questions.forEach(function (q) {
                q.runTriggers(name, value);
            });
        }
    };
    QuestionCompositeModel.prototype.getFilteredValues = function () {
        var values = !!this.data ? this.data.getFilteredValues() : {};
        if (!!this.contentPanel) {
            values[QuestionCompositeModel.ItemVariableName] = this.contentPanel.getValue();
        }
        return values;
    };
    QuestionCompositeModel.prototype.updateValueCoreWithPanelValue = function () {
        var panelValue = this.getContentPanelValue();
        if (this.isTwoValueEquals(this.getValueCore(), panelValue))
            return false;
        this.setValueCore(panelValue);
        return true;
    };
    QuestionCompositeModel.prototype.getContentPanelValue = function (val) {
        if (!val)
            val = this.contentPanel.getValue();
        return this.customQuestion.setValueToQuestion(val);
    };
    QuestionCompositeModel.prototype.getValueForContentPanel = function (val) {
        return this.customQuestion.getValueFromQuestion(val);
    };
    QuestionCompositeModel.prototype.setNewValueIntoQuestion = function (name, newValue) {
        var q = this.getQuestionByName(name);
        if (!!q && !this.isTwoValueEquals(newValue, q.value)) {
            q.value = newValue;
        }
    };
    QuestionCompositeModel.prototype.addConditionObjectsByContext = function (objects, context) {
        if (!this.contentPanel)
            return;
        var questions = this.contentPanel.questions;
        var prefixName = this.name;
        var prefixText = this.title;
        for (var i = 0; i < questions.length; i++) {
            objects.push({
                name: prefixName + "." + questions[i].name,
                text: prefixText + "." + questions[i].title,
                question: questions[i],
            });
        }
    };
    QuestionCompositeModel.prototype.collectNestedQuestionsCore = function (questions, visibleOnly) {
        if (!this.contentPanel)
            return;
        this.contentPanel.questions.forEach(function (q) { return q.collectNestedQuestions(questions, visibleOnly); });
    };
    QuestionCompositeModel.prototype.convertDataValue = function (name, newValue) {
        var val = !!this.contentPanel && !this.isEditingSurveyElement ?
            this.contentPanel.getValue() : this.getValueForContentPanel(this.value);
        if (!val)
            val = {};
        if (!val.getType) {
            val = helpers_Helpers.getUnbindValue(val);
        }
        if (this.isValueEmpty(newValue) && !this.isEditingSurveyElement) {
            delete val[name];
        }
        else {
            val[name] = newValue;
        }
        return this.getContentPanelValue(val);
    };
    QuestionCompositeModel.prototype.setQuestionValue = function (newValue, updateIsAnswered) {
        if (updateIsAnswered === void 0) { updateIsAnswered = true; }
        this.setValuesIntoQuestions(newValue);
        if (!this.isEditingSurveyElement && !!this.contentPanel) {
            newValue = this.getContentPanelValue();
        }
        _super.prototype.setQuestionValue.call(this, newValue, updateIsAnswered);
    };
    QuestionCompositeModel.prototype.setValuesIntoQuestions = function (newValue) {
        if (!this.contentPanel)
            return;
        newValue = this.getValueForContentPanel(newValue);
        var oldSettingNewValue = this.settingNewValue;
        this.settingNewValue = true;
        var questions = this.contentPanel.questions;
        for (var i = 0; i < questions.length; i++) {
            var key = questions[i].getValueName();
            var val = !!newValue ? newValue[key] : undefined;
            var q = questions[i];
            if (!this.isTwoValueEquals(q.value, val) && (val !== undefined || !q.isEmpty())) {
                q.value = val;
            }
        }
        this.settingNewValue = oldSettingNewValue;
    };
    QuestionCompositeModel.prototype.getDisplayValueCore = function (keyAsText, value) {
        return _super.prototype.getContentDisplayValueCore.call(this, keyAsText, value, this.contentPanel);
    };
    QuestionCompositeModel.prototype.setAfterRenderCallbacks = function (panel) {
        var _this = this;
        if (!panel || !this.customQuestion)
            return;
        var questions = panel.questions;
        for (var i = 0; i < questions.length; i++) {
            questions[i].afterRenderQuestionCallback = function (question, element) {
                _this.customQuestion.onAfterRenderContentElement(_this, question, element);
            };
        }
    };
    QuestionCompositeModel.ItemVariableName = "composite";
    return QuestionCompositeModel;
}(question_custom_QuestionCustomModelBase));


// CONCATENATED MODULE: ./packages/survey-core/src/questionfactory.ts



var questionfactory_QuestionFactory = /** @class */ (function () {
    function QuestionFactory() {
    }
    Object.defineProperty(QuestionFactory, "DefaultChoices", {
        get: function () {
            return [
                surveyLocalization.getString("choices_Item") + "1",
                surveyLocalization.getString("choices_Item") + "2",
                surveyLocalization.getString("choices_Item") + "3",
            ];
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFactory, "DefaultColums", {
        get: function () {
            var colName = surveyLocalization.getString("matrix_column") + " ";
            return [colName + "1", colName + "2", colName + "3"];
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFactory, "DefaultRows", {
        get: function () {
            var rowName = surveyLocalization.getString("matrix_row") + " ";
            return [rowName + "1", rowName + "2"];
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFactory, "DefaultMutlipleTextItems", {
        get: function () {
            var itemName = surveyLocalization.getString("multipletext_itemname");
            return [itemName + "1", itemName + "2"];
        },
        enumerable: false,
        configurable: true
    });
    QuestionFactory.prototype.registerQuestion = function (questionType, questionCreator, showInToolbox) {
        if (showInToolbox === void 0) { showInToolbox = true; }
        questionfactory_ElementFactory.Instance.registerElement(questionType, questionCreator, showInToolbox);
    };
    QuestionFactory.prototype.registerCustomQuestion = function (questionType) {
        questionfactory_ElementFactory.Instance.registerCustomQuestion(questionType);
    };
    QuestionFactory.prototype.unregisterElement = function (elementType, removeFromSerializer) {
        if (removeFromSerializer === void 0) { removeFromSerializer = false; }
        questionfactory_ElementFactory.Instance.unregisterElement(elementType, removeFromSerializer);
    };
    QuestionFactory.prototype.clear = function () {
        questionfactory_ElementFactory.Instance.clear();
    };
    QuestionFactory.prototype.getAllTypes = function () {
        return questionfactory_ElementFactory.Instance.getAllTypes();
    };
    QuestionFactory.prototype.createQuestion = function (questionType, name) {
        return questionfactory_ElementFactory.Instance.createElement(questionType, name);
    };
    QuestionFactory.Instance = new QuestionFactory();
    return QuestionFactory;
}());

var questionfactory_ElementFactory = /** @class */ (function () {
    function ElementFactory() {
        var _this = this;
        this.creatorHash = {};
        this.registerCustomQuestion = function (questionType, showInToolbox) {
            if (showInToolbox === void 0) { showInToolbox = true; }
            var creator = function (name) {
                var el = Serializer.createClass(questionType);
                if (!!el)
                    el.name = name;
                return el;
            };
            _this.registerElement(questionType, creator, showInToolbox);
        };
    }
    ElementFactory.prototype.registerElement = function (elementType, elementCreator, showInToolbox) {
        if (showInToolbox === void 0) { showInToolbox = true; }
        this.creatorHash[elementType] = { showInToolbox: showInToolbox, creator: elementCreator };
    };
    ElementFactory.prototype.clear = function () {
        this.creatorHash = {};
    };
    ElementFactory.prototype.unregisterElement = function (elementType, removeFromSerializer) {
        if (removeFromSerializer === void 0) { removeFromSerializer = false; }
        delete this.creatorHash[elementType];
        if (removeFromSerializer) {
            Serializer.removeClass(elementType);
        }
    };
    ElementFactory.prototype.getAllToolboxTypes = function () {
        return this.getAllTypesCore(true);
    };
    ElementFactory.prototype.getAllTypes = function () {
        return this.getAllTypesCore(false);
    };
    ElementFactory.prototype.createElement = function (elementType, name) {
        var item = this.creatorHash[elementType];
        if (!!item && !!item.creator)
            return item.creator(name);
        var compJSON = question_custom_ComponentCollection.Instance.getCustomQuestionByName(elementType);
        if (!!compJSON)
            return question_custom_ComponentCollection.Instance.createQuestion(name, compJSON);
        return null;
    };
    ElementFactory.prototype.getAllTypesCore = function (showInToolboxOnly) {
        var result = new Array();
        for (var key in this.creatorHash) {
            if (!showInToolboxOnly || this.creatorHash[key].showInToolbox) {
                result.push(key);
            }
        }
        return result.sort();
    };
    ElementFactory.Instance = new ElementFactory();
    return ElementFactory;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/question_expression.ts
var question_expression_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();




/**
 * A class that describes the Expression question type. It is a read-only question type that calculates a value based on a specified expression.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/questiontype-expression/ (linkStyle))
 */
var question_expression_QuestionExpressionModel = /** @class */ (function (_super) {
    question_expression_extends(QuestionExpressionModel, _super);
    function QuestionExpressionModel(name) {
        var _this = _super.call(this, name) || this;
        _this.createLocalizableString("format", _this);
        _this.registerPropertyChangedHandlers(["expression"], function () {
            if (_this.expressionRunner) {
                _this.expressionRunner = _this.createRunner();
            }
        });
        _this.registerPropertyChangedHandlers(["format", "currency", "displayStyle"], function () {
            _this.updateFormatedValue();
        });
        return _this;
    }
    QuestionExpressionModel.prototype.getType = function () {
        return "expression";
    };
    Object.defineProperty(QuestionExpressionModel.prototype, "hasInput", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionExpressionModel.prototype, "format", {
        /**
         * A string that formats a question value. Use `{0}` to reference the question value in the format string.
         * @see displayStyle
         */
        get: function () {
            return this.getLocalizableStringText("format", "");
        },
        set: function (val) {
            this.setLocalizableStringText("format", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionExpressionModel.prototype, "locFormat", {
        get: function () {
            return this.getLocalizableString("format");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionExpressionModel.prototype, "expression", {
        /**
         * An expression used to calculate the question value.
         *
         * Refer to the following help topic for more information: [Expressions](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#expressions).
         */
        get: function () {
            return this.getPropertyValue("expression", "");
        },
        set: function (val) {
            this.setPropertyValue("expression", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionExpressionModel.prototype.locCalculation = function () {
        this.expressionIsRunning = true;
    };
    QuestionExpressionModel.prototype.unlocCalculation = function () {
        this.expressionIsRunning = false;
    };
    QuestionExpressionModel.prototype.runCondition = function (values, properties) {
        _super.prototype.runCondition.call(this, values, properties);
        if (!this.expression ||
            this.expressionIsRunning ||
            (!this.runIfReadOnly && this.isReadOnly))
            return;
        this.locCalculation();
        if (!this.expressionRunner) {
            this.expressionRunner = this.createRunner();
        }
        this.expressionRunner.run(values, properties);
    };
    QuestionExpressionModel.prototype.canCollectErrors = function () {
        return true;
    };
    QuestionExpressionModel.prototype.hasRequiredError = function () {
        return false;
    };
    QuestionExpressionModel.prototype.createRunner = function () {
        var _this = this;
        var res = this.createExpressionRunner(this.expression);
        res.onRunComplete = function (newValue) {
            _this.value = _this.roundValue(newValue);
            _this.unlocCalculation();
        };
        return res;
    };
    Object.defineProperty(QuestionExpressionModel.prototype, "maximumFractionDigits", {
        /**
         * The maximum number of fraction digits. Applies only if the `displayStyle` property is not `"none"`. Accepts values in the range from -1 to 20, where -1 disables the property.
         *
         * Default value: -1
         * @see displayStyle
         * @see minimumFractionDigits
         * @see precision
         */
        get: function () {
            return this.getPropertyValue("maximumFractionDigits");
        },
        set: function (val) {
            if (val < -1 || val > 20)
                return;
            this.setPropertyValue("maximumFractionDigits", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionExpressionModel.prototype, "minimumFractionDigits", {
        /**
         * The minimum number of fraction digits. Applies only if the `displayStyle` property is not `"none"`. Accepts values in the range from -1 to 20, where -1 disables the property.
         *
         * Default value: -1
         * @see displayStyle
         * @see maximumFractionDigits
         */
        get: function () {
            return this.getPropertyValue("minimumFractionDigits");
        },
        set: function (val) {
            if (val < -1 || val > 20)
                return;
            this.setPropertyValue("minimumFractionDigits", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionExpressionModel.prototype, "runIfReadOnly", {
        get: function () {
            return this.runIfReadOnlyValue === true;
        },
        set: function (val) {
            this.runIfReadOnlyValue = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionExpressionModel.prototype, "formatedValue", {
        get: function () {
            return this.getPropertyValue("formatedValue", "");
        },
        enumerable: false,
        configurable: true
    });
    QuestionExpressionModel.prototype.updateFormatedValue = function () {
        this.setPropertyValue("formatedValue", this.getDisplayValueCore(false, this.value));
    };
    QuestionExpressionModel.prototype.onValueChanged = function () {
        this.updateFormatedValue();
    };
    QuestionExpressionModel.prototype.updateValueFromSurvey = function (newValue, clearData) {
        _super.prototype.updateValueFromSurvey.call(this, newValue, clearData);
        this.updateFormatedValue();
    };
    QuestionExpressionModel.prototype.getDisplayValueCore = function (keysAsText, value) {
        var val = value === undefined || value === null ? this.defaultValue : value;
        var res = "";
        if (!this.isValueEmpty(val)) {
            var str = this.getValueAsStr(val);
            res = !this.format ? str : this.format["format"](str);
        }
        if (!!this.survey) {
            res = this.survey.getExpressionDisplayValue(this, val, res);
        }
        return res;
    };
    Object.defineProperty(QuestionExpressionModel.prototype, "displayStyle", {
        /**
         * Specifies a display style for the question value.
         *
         * Possible values:
         *
         * - `"decimal"`
         * - `"currency"`
         * - `"percent"`
         * - `"date"`
         * - `"none"` (default)
         *
         * If you use the `"currency"` display style, you can also set the `currency` property to specify a currency other than USD.
         * @see currency
         * @see minimumFractionDigits
         * @see maximumFractionDigits
         * @see format
         */
        get: function () {
            return this.getPropertyValue("displayStyle");
        },
        set: function (val) {
            this.setPropertyValue("displayStyle", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionExpressionModel.prototype, "currency", {
        /**
         * A three-letter currency code. Applies only if the `displayStyle` property is set to `"currency"`.
         *
         * Default value: "USD".
         * @see displayStyle
         * @see minimumFractionDigits
         * @see maximumFractionDigits
         * @see format
         */
        get: function () {
            return this.getPropertyValue("currency");
        },
        set: function (val) {
            if (getCurrecyCodes().indexOf(val) < 0)
                return;
            this.setPropertyValue("currency", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionExpressionModel.prototype, "useGrouping", {
        /**
         * Specifies whether to use grouping separators in number representation. Separators depend on the selected [locale](https://surveyjs.io/form-library/documentation/surveymodel#locale).
         *
         * Default value: `true`
         */
        get: function () {
            return this.getPropertyValue("useGrouping");
        },
        set: function (val) {
            this.setPropertyValue("useGrouping", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionExpressionModel.prototype, "precision", {
        /**
         * Specifies how many decimal digits to keep in the expression value.
         *
         * Default value: -1 (unlimited)
         * @see maximumFractionDigits
         */
        get: function () {
            return this.getPropertyValue("precision");
        },
        set: function (val) {
            this.setPropertyValue("precision", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionExpressionModel.prototype.roundValue = function (val) {
        if (val === Infinity)
            return undefined;
        if (this.precision < 0)
            return val;
        if (!helpers_Helpers.isNumber(val))
            return val;
        return parseFloat(val.toFixed(this.precision));
    };
    QuestionExpressionModel.prototype.getValueAsStr = function (val) {
        if (this.displayStyle == "date") {
            var d = new Date(val);
            if (!!d && !!d.toLocaleDateString)
                return d.toLocaleDateString();
        }
        if (this.displayStyle != "none" && helpers_Helpers.isNumber(val)) {
            var locale = this.getLocale();
            if (!locale)
                locale = "en";
            var options = {
                style: this.displayStyle,
                currency: this.currency,
                useGrouping: this.useGrouping,
            };
            if (this.maximumFractionDigits > -1) {
                options["maximumFractionDigits"] = this.maximumFractionDigits;
            }
            if (this.minimumFractionDigits > -1) {
                options["minimumFractionDigits"] = this.minimumFractionDigits;
            }
            return val.toLocaleString(locale, options);
        }
        return val.toString();
    };
    return QuestionExpressionModel;
}(question_Question));

function getCurrecyCodes() {
    return [
        "AED",
        "AFN",
        "ALL",
        "AMD",
        "ANG",
        "AOA",
        "ARS",
        "AUD",
        "AWG",
        "AZN",
        "BAM",
        "BBD",
        "BDT",
        "BGN",
        "BHD",
        "BIF",
        "BMD",
        "BND",
        "BOB",
        "BOV",
        "BRL",
        "BSD",
        "BTN",
        "BWP",
        "BYN",
        "BZD",
        "CAD",
        "CDF",
        "CHE",
        "CHF",
        "CHW",
        "CLF",
        "CLP",
        "CNY",
        "COP",
        "COU",
        "CRC",
        "CUC",
        "CUP",
        "CVE",
        "CZK",
        "DJF",
        "DKK",
        "DOP",
        "DZD",
        "EGP",
        "ERN",
        "ETB",
        "EUR",
        "FJD",
        "FKP",
        "GBP",
        "GEL",
        "GHS",
        "GIP",
        "GMD",
        "GNF",
        "GTQ",
        "GYD",
        "HKD",
        "HNL",
        "HRK",
        "HTG",
        "HUF",
        "IDR",
        "ILS",
        "INR",
        "IQD",
        "IRR",
        "ISK",
        "JMD",
        "JOD",
        "JPY",
        "KES",
        "KGS",
        "KHR",
        "KMF",
        "KPW",
        "KRW",
        "KWD",
        "KYD",
        "KZT",
        "LAK",
        "LBP",
        "LKR",
        "LRD",
        "LSL",
        "LYD",
        "MAD",
        "MDL",
        "MGA",
        "MKD",
        "MMK",
        "MNT",
        "MOP",
        "MRO",
        "MUR",
        "MVR",
        "MWK",
        "MXN",
        "MXV",
        "MYR",
        "MZN",
        "NAD",
        "NGN",
        "NIO",
        "NOK",
        "NPR",
        "NZD",
        "OMR",
        "PAB",
        "PEN",
        "PGK",
        "PHP",
        "PKR",
        "PLN",
        "PYG",
        "QAR",
        "RON",
        "RSD",
        "RUB",
        "RWF",
        "SAR",
        "SBD",
        "SCR",
        "SDG",
        "SEK",
        "SGD",
        "SHP",
        "SLL",
        "SOS",
        "SRD",
        "SSP",
        "STD",
        "SVC",
        "SYP",
        "SZL",
        "THB",
        "TJS",
        "TMT",
        "TND",
        "TOP",
        "TRY",
        "TTD",
        "TWD",
        "TZS",
        "UAH",
        "UGX",
        "USD",
        "USN",
        "UYI",
        "UYU",
        "UZS",
        "VEF",
        "VND",
        "VUV",
        "WST",
        "XAF",
        "XAG",
        "XAU",
        "XBA",
        "XBB",
        "XBC",
        "XBD",
        "XCD",
        "XDR",
        "XOF",
        "XPD",
        "XPF",
        "XPT",
        "XSU",
        "XTS",
        "XUA",
        "XXX",
        "YER",
        "ZAR",
        "ZMW",
        "ZWL",
    ];
}
Serializer.addClass("expression", [
    "expression:expression",
    { name: "format", serializationProperty: "locFormat" },
    {
        name: "displayStyle",
        default: "none",
        choices: ["none", "decimal", "currency", "percent", "date"],
    },
    {
        name: "currency",
        choices: function () {
            return getCurrecyCodes();
        },
        default: "USD",
        visibleIf: function (obj) {
            return obj.displayStyle === "currency";
        }
    },
    { name: "maximumFractionDigits:number", default: -1 },
    { name: "minimumFractionDigits:number", default: -1 },
    { name: "useGrouping:boolean", default: true },
    { name: "precision:number", default: -1, category: "data" },
    { name: "enableIf", visible: false },
    { name: "isRequired", visible: false },
    { name: "readOnly", visible: false },
    { name: "requiredErrorText", visible: false },
    { name: "defaultValueExpression", visible: false },
    { name: "defaultValue", visible: false },
    { name: "correctAnswer", visible: false },
    { name: "requiredIf", visible: false }
], function () {
    return new question_expression_QuestionExpressionModel("");
}, "question");
questionfactory_QuestionFactory.Instance.registerQuestion("expression", function (name) {
    return new question_expression_QuestionExpressionModel(name);
});

// CONCATENATED MODULE: ./packages/survey-core/src/question_matrixdropdowncolumn.ts
var question_matrixdropdowncolumn_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();




function onUpdateSelectBaseCellQuestion(cellQuestion, column, question, data) {
    cellQuestion.storeOthersAsComment = !!question
        ? question.storeOthersAsComment
        : false;
    if ((!cellQuestion.choices || cellQuestion.choices.length == 0) &&
        cellQuestion.choicesByUrl.isEmpty) {
        cellQuestion.choices = question.choices;
    }
    if (!cellQuestion.choicesByUrl.isEmpty) {
        cellQuestion.choicesByUrl.run(data.getTextProcessor());
    }
}
function onUpdateSelectDropdownCellQuestion(cellQuestion, column, question, data) {
    onUpdateSelectBaseCellQuestion(cellQuestion, column, question, data);
    if (!!cellQuestion.locPlaceholder && cellQuestion.locPlaceholder.isEmpty && !question.locPlaceholder.isEmpty) {
        cellQuestion.optionsCaption = question.optionsCaption;
    }
}
var matrixDropdownColumnTypes = {
    dropdown: {
        onCellQuestionUpdate: function (cellQuestion, column, question, data) {
            onUpdateSelectDropdownCellQuestion(cellQuestion, column, question, data);
        }
    },
    checkbox: {
        onCellQuestionUpdate: function (cellQuestion, column, question, data) {
            onUpdateSelectBaseCellQuestion(cellQuestion, column, question, data);
            cellQuestion.colCount =
                column.colCount > -1 ? column.colCount : question.columnColCount;
        },
    },
    radiogroup: {
        onCellQuestionUpdate: function (cellQuestion, column, question, data) {
            onUpdateSelectBaseCellQuestion(cellQuestion, column, question, data);
            cellQuestion.colCount =
                column.colCount > -1 ? column.colCount : question.columnColCount;
        },
    },
    tagbox: {
        onCellQuestionUpdate: function (cellQuestion, column, question, data) {
            onUpdateSelectBaseCellQuestion(cellQuestion, column, question, data);
        }
    },
    text: {},
    comment: {},
    boolean: {
        onCellQuestionUpdate: function (cellQuestion, column, question, data) {
            cellQuestion.renderAs = column.renderAs;
        },
    },
    expression: {},
    rating: {},
};
/**
 * An auxiliary class that describes a column in a [Multi-Select Matrix](https://surveyjs.io/form-library/documentation/api-reference/matrix-table-with-dropdown-list) or [Dynamic Matrix](https://surveyjs.io/form-library/documentation/api-reference/dynamic-matrix-table-question-model).
 *
 * You can get an object of this class from the [`columns`](https://surveyjs.io/form-library/documentation/api-reference/matrix-table-with-dropdown-list#columns) array or by calling the [`getColumnByName()`](https://surveyjs.io/form-library/documentation/api-reference/matrix-table-with-dropdown-list#getColumnByName) method on a matrix instance.
 */
var question_matrixdropdowncolumn_MatrixDropdownColumn = /** @class */ (function (_super) {
    question_matrixdropdowncolumn_extends(MatrixDropdownColumn, _super);
    function MatrixDropdownColumn(name, title) {
        if (title === void 0) { title = null; }
        var _this = _super.call(this) || this;
        _this.colOwnerValue = null;
        _this.indexValue = -1;
        _this._hasVisibleCell = true;
        _this.previousChoicesId = undefined;
        _this.createLocalizableString("totalFormat", _this);
        _this.createLocalizableString("cellHint", _this);
        _this.registerPropertyChangedHandlers(["showInMultipleColumns"], function () { _this.doShowInMultipleColumnsChanged(); });
        _this.registerPropertyChangedHandlers(["visible"], function () { _this.doColumnVisibilityChanged(); });
        _this.updateTemplateQuestion();
        _this.name = name;
        if (title) {
            _this.title = title;
        }
        else {
            _this.templateQuestion.locTitle.strChanged();
        }
        return _this;
    }
    MatrixDropdownColumn.getColumnTypes = function () {
        var res = [];
        for (var key in matrixDropdownColumnTypes) {
            res.push(key);
        }
        return res;
    };
    MatrixDropdownColumn.prototype.getOriginalObj = function () {
        return this.templateQuestion;
    };
    MatrixDropdownColumn.prototype.getClassNameProperty = function () {
        return "cellType";
    };
    MatrixDropdownColumn.prototype.getSurvey = function (live) {
        if (live === void 0) { live = false; }
        return !!this.colOwner ? this.colOwner.survey : null;
    };
    MatrixDropdownColumn.prototype.endLoadingFromJson = function () {
        var _this = this;
        _super.prototype.endLoadingFromJson.call(this);
        this.templateQuestion.autoOtherMode = this.isShowInMultipleColumns;
        this.templateQuestion.endLoadingFromJson();
        this.templateQuestion.onGetSurvey = function () {
            return _this.getSurvey();
        };
    };
    MatrixDropdownColumn.prototype.getDynamicPropertyName = function () {
        return "cellType";
    };
    MatrixDropdownColumn.prototype.getDynamicType = function () {
        if (this.cellType === "default")
            return "question";
        return this.calcCellQuestionType(null);
    };
    Object.defineProperty(MatrixDropdownColumn.prototype, "colOwner", {
        get: function () {
            return this.colOwnerValue;
        },
        set: function (value) {
            this.colOwnerValue = value;
            if (!!value) {
                this.updateTemplateQuestion();
                this.setParentQuestionToTemplate(this.templateQuestion);
            }
        },
        enumerable: false,
        configurable: true
    });
    MatrixDropdownColumn.prototype.locStrsChanged = function () {
        _super.prototype.locStrsChanged.call(this);
        this.locTitle.strChanged();
    };
    MatrixDropdownColumn.prototype.addUsedLocales = function (locales) {
        _super.prototype.addUsedLocales.call(this, locales);
        this.templateQuestion.addUsedLocales(locales);
    };
    Object.defineProperty(MatrixDropdownColumn.prototype, "index", {
        get: function () {
            return this.indexValue;
        },
        enumerable: false,
        configurable: true
    });
    MatrixDropdownColumn.prototype.setIndex = function (val) {
        this.indexValue = val;
    };
    MatrixDropdownColumn.prototype.getType = function () {
        return "matrixdropdowncolumn";
    };
    Object.defineProperty(MatrixDropdownColumn.prototype, "cellType", {
        /**
         * Specifies the type of column cells.
         *
         * Possible values:
         *
         * - [`"dropdown"`](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model)
         * - [`"checkbox"`](https://surveyjs.io/form-library/documentation/api-reference/checkbox-question-model)
         * - [`"radiogroup"`](https://surveyjs.io/form-library/documentation/api-reference/radio-button-question-model)
         * - [`"tagbox"`](https://surveyjs.io/form-library/documentation/api-reference/dropdown-tag-box-model)
         * - [`"text"`](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model)
         * - [`"comment"`](https://surveyjs.io/form-library/documentation/api-reference/comment-field-model)
         * - [`"boolean"`](https://surveyjs.io/form-library/documentation/api-reference/boolean-question-model)
         * - [`"expression"`](https://surveyjs.io/form-library/documentation/api-reference/expression-model)
         * - [`"rating"`](https://surveyjs.io/form-library/documentation/api-reference/rating-scale-question-model)
         * - `"default"` (default) - Inherits the input type from the [`cellType`](https://surveyjs.io/form-library/documentation/api-reference/matrix-table-with-dropdown-list#cellType) property specified for the parent matrix.
         *
         * The input types are based upon standalone question types. Depending on the selected input type, the matrix column can have additional configuration properties inherited from the corresponding question type. For instance, Dropdown, Checkboxes, Radio Button Group, and Tag Box columns can specify the [`choices`](https://surveyjs.io/form-library/documentation/api-reference/radio-button-question-model#choices) array, similar to the question types upon which they are based. Refer to the API Reference of these question types for a full list of available properties.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/aggregate-data-within-form/ (linkStyle))
         */
        get: function () {
            return this.getPropertyValue("cellType");
        },
        set: function (val) {
            val = val.toLocaleLowerCase();
            this.updateTemplateQuestion(val);
            this.setPropertyValue("cellType", val);
            if (!!this.colOwner) {
                this.colOwner.onColumnCellTypeChanged(this);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "templateQuestion", {
        get: function () {
            return this.templateQuestionValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "value", {
        get: function () {
            return this.templateQuestion.name;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "isVisible", {
        //For filtering columns
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "isColumnVisible", {
        get: function () {
            if (this.isDesignMode)
                return true;
            return this.visible && this.hasVisibleCell;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "visible", {
        /**
         * Gets or sets column visibility.
         *
         * If you want to display or hide a column based on a condition, specify the [`visibleIf`](#visibleIf) property.
         * @see isRequired
         * @see readOnly
         */
        get: function () { return this.templateQuestion.visible; },
        set: function (val) {
            this.templateQuestion.visible = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "hasVisibleCell", {
        get: function () {
            return this._hasVisibleCell;
        },
        set: function (newVal) {
            this._hasVisibleCell = newVal;
        },
        enumerable: false,
        configurable: true
    });
    MatrixDropdownColumn.prototype.getVisibleMultipleChoices = function () {
        var choices = this.templateQuestion.visibleChoices;
        if (!Array.isArray(choices))
            return [];
        if (!Array.isArray(this._visiblechoices))
            return choices;
        var res = new Array();
        for (var i = 0; i < choices.length; i++) {
            var item = choices[i];
            if (this._visiblechoices.indexOf(item.value) > -1)
                res.push(item);
        }
        return res;
    };
    Object.defineProperty(MatrixDropdownColumn.prototype, "getVisibleChoicesInCell", {
        get: function () {
            if (Array.isArray(this._visiblechoices))
                return this._visiblechoices;
            var res = this.templateQuestion.visibleChoices;
            return Array.isArray(res) ? res : [];
        },
        enumerable: false,
        configurable: true
    });
    MatrixDropdownColumn.prototype.setVisibleChoicesInCell = function (val) {
        this._visiblechoices = val;
    };
    Object.defineProperty(MatrixDropdownColumn.prototype, "isFilteredMultipleColumns", {
        get: function () {
            if (!this.showInMultipleColumns)
                return false;
            var choices = this.templateQuestion.choices;
            if (!Array.isArray(choices))
                return false;
            for (var i = 0; i < choices.length; i++) {
                if (choices[i].visibleIf)
                    return true;
            }
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "name", {
        /**
         * A column ID that is not visible to respondents.
         *
         * > Column IDs must be unique.
         * @see title
         */
        get: function () {
            return this.templateQuestion.name;
        },
        set: function (val) {
            this.templateQuestion.name = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "title", {
        /**
         * A user-friendly column caption to display. If `title` is undefined, [`name`](#name) is displayed instead.
         */
        get: function () {
            return this.templateQuestion.title;
        },
        set: function (val) {
            this.templateQuestion.title = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "locTitle", {
        get: function () {
            return this.templateQuestion.locTitle;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "fullTitle", {
        get: function () {
            return this.locTitle.textOrHtml;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "isRequired", {
        /**
         * Marks the column as required. If a respondent skips any cell in a required column, the matrix displays a [validation error](#requiredErrorText).
         *
         * If you want to mark the column as required based on a condition, specify the [`requiredIf`](#requiredIf) property.
         * @see visible
         * @see readOnly
         */
        get: function () {
            return this.templateQuestion.isRequired;
        },
        set: function (val) {
            this.templateQuestion.isRequired = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "isRenderedRequired", {
        get: function () {
            return this.getPropertyValue("isRenderedRequired", this.isRequired);
        },
        set: function (val) {
            this.setPropertyValue("isRenderedRequired", val);
        },
        enumerable: false,
        configurable: true
    });
    MatrixDropdownColumn.prototype.updateIsRenderedRequired = function (val) {
        this.isRenderedRequired = val || this.isRequired;
    };
    Object.defineProperty(MatrixDropdownColumn.prototype, "requiredText", {
        get: function () {
            return this.isRenderedRequired && this.getSurvey() ? this.getSurvey().requiredText : this.templateQuestion.requiredText;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "requiredErrorText", {
        /**
         * Specifies a custom error message for a required column.
         * @see isRequired
         */
        get: function () {
            return this.templateQuestion.requiredErrorText;
        },
        set: function (val) {
            this.templateQuestion.requiredErrorText = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "locRequiredErrorText", {
        get: function () {
            return this.templateQuestion.locRequiredErrorText;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "readOnly", {
        /**
         * Makes the column read-only.
         *
         * If you want to switch the column to the read-only state based on a condition, specify the [`enableIf`](#enableIf) property.
         * @see visible
         * @see isRequired
         */
        get: function () {
            return this.templateQuestion.readOnly;
        },
        set: function (val) {
            this.templateQuestion.readOnly = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "hasOther", {
        get: function () {
            return this.templateQuestion.hasOther;
        },
        set: function (val) {
            this.templateQuestion.hasOther = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "visibleIf", {
        /**
         * A Boolean expression. If it evaluates to `false`, this column becomes hidden.
         *
         * Refer to the following help topic for more information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see visible
         */
        get: function () {
            return this.templateQuestion.visibleIf;
        },
        set: function (val) {
            this.templateQuestion.visibleIf = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "enableIf", {
        /**
         * A Boolean expression. If it evaluates to `false`, this column becomes read-only.
         *
         * Refer to the following help topic for more information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see readOnly
         */
        get: function () {
            return this.templateQuestion.enableIf;
        },
        set: function (val) {
            this.templateQuestion.enableIf = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "requiredIf", {
        /**
         * A Boolean expression. If it evaluates to `true`, this column becomes required.
         *
         * Refer to the following help topic for more information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see isRequired
         */
        get: function () {
            return this.templateQuestion.requiredIf;
        },
        set: function (val) {
            this.templateQuestion.requiredIf = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "resetValueIf", {
        /**
         * A Boolean expression. If it evaluates to `true`, all cells in this column are set to a value calculated using the [`defaultValueExpression`](#defaultValueExpression).
         *
         * [Expressions](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#expressions (linkStyle))
         * @see setValueIf
         */
        get: function () {
            return this.templateQuestion.resetValueIf;
        },
        set: function (val) {
            this.templateQuestion.resetValueIf = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "defaultValueExpression", {
        /**
         * An expression used to calculate the column's default value. This expression applies to all cells of this column until the cell value is specified by an end user or programmatically.
         *
         * [Expressions](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#expressions (linkStyle))
         * @see setValueExpression
         */
        get: function () {
            return this.templateQuestion.defaultValueExpression;
        },
        set: function (val) {
            this.templateQuestion.defaultValueExpression = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "setValueIf", {
        /**
         * A Boolean expression. If it evaluates to `true`, all cells in this column are set to a value calculated using the [`setValueExpression`](#setValueExpression).
         *
         * [Expressions](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#expressions (linkStyle))
         * @see resetValueIf
         */
        get: function () {
            return this.templateQuestion.setValueIf;
        },
        set: function (val) {
            this.templateQuestion.setValueIf = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "setValueExpression", {
        /**
         * An expression used to calculate a value for all column cells.
         *
         * You can use `setValueExpression` as a standalone property or in conjunction with the [`setValueIf`](#setValueIf) expression, in which case the calculated cell value applies only when `setValueIf` evaluates to `true`.
         *
         * [Expressions](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#expressions (linkStyle))
         * @see defaultValueExpression
         * @see resetValueIf
         */
        get: function () {
            return this.templateQuestion.setValueExpression;
        },
        set: function (val) {
            this.templateQuestion.setValueExpression = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "isUnique", {
        /**
         * Specifies whether a respondent is required to provide a unique response for each question within this column.
         *
         * Default value: `false`
         */
        get: function () {
            return this.getPropertyValue("isUnique");
        },
        set: function (val) {
            this.setPropertyValue("isUnique", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "showInMultipleColumns", {
        /**
         * Specifies whether to create an individual column for each choice option. Applies only to columns of `"checkbox"` or `"radiogroup"` [`cellType`](#cellType).
         */
        get: function () {
            return this.getPropertyValue("showInMultipleColumns");
        },
        set: function (val) {
            this.setPropertyValue("showInMultipleColumns", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "isSupportMultipleColumns", {
        get: function () {
            return ["checkbox", "radiogroup"].indexOf(this.cellType) > -1;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "isShowInMultipleColumns", {
        get: function () {
            return this.showInMultipleColumns && this.isSupportMultipleColumns;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "validators", {
        /**
         * Column validators.
         *
         * [Data Validation](https://surveyjs.io/form-library/documentation/data-validation (linkStyle))
         * @see isRequired
         */
        get: function () {
            return this.templateQuestion.validators;
        },
        set: function (val) {
            this.templateQuestion.validators = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "totalType", {
        /**
         * An aggregation method used to calculate the column total.
         *
         * Possible values:
         *
         * - `"none"` (default) - Disables total calculations.
         * - `"sum"`
         * - `"count"`
         * - `"min"`
         * - `"max"`
         * - `"avg"`
         *
         * [View Demo](https://surveyjs.io/form-library/examples/aggregate-data-within-form/ (linkStyle))
         * @see totalFormat
         * @see totalDisplayStyle
         */
        get: function () {
            return this.getPropertyValue("totalType");
        },
        set: function (val) {
            this.setPropertyValue("totalType", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "totalExpression", {
        /**
         * An expression used to calculate total values. Overrides the [`totalType`](#totalType) property.
         *
         * [Expressions](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#expressions (linkStyle))
         */
        get: function () {
            return this.getPropertyValue("totalExpression");
        },
        set: function (val) {
            this.setPropertyValue("totalExpression", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "hasTotal", {
        get: function () {
            return this.totalType != "none" || !!this.totalExpression;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "totalFormat", {
        /**
         * A string pattern used to display column totals. To reference a total value within this pattern, use the `{0}` placeholder.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/aggregate-data-within-form/ (linkStyle))
         * @see totalType
         * @see totalDisplayStyle
         */
        get: function () {
            return this.getLocalizableStringText("totalFormat", "");
        },
        set: function (val) {
            this.setLocalizableStringText("totalFormat", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "locTotalFormat", {
        get: function () {
            return this.getLocalizableString("totalFormat");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "cellHint", {
        get: function () {
            return this.getLocalizableStringText("cellHint", "");
        },
        set: function (val) {
            this.setLocalizableStringText("cellHint", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "locCellHint", {
        get: function () {
            return this.getLocalizableString("cellHint");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "renderAs", {
        get: function () {
            return this.getPropertyValue("renderAs");
        },
        set: function (val) {
            this.setPropertyValue("renderAs", val);
            if (!!this.templateQuestion) {
                this.templateQuestion.renderAs = val;
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "totalMaximumFractionDigits", {
        get: function () {
            return this.getPropertyValue("totalMaximumFractionDigits");
        },
        set: function (val) {
            if (val < -1 || val > 20)
                return;
            this.setPropertyValue("totalMaximumFractionDigits", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "totalMinimumFractionDigits", {
        get: function () {
            return this.getPropertyValue("totalMinimumFractionDigits");
        },
        set: function (val) {
            if (val < -1 || val > 20)
                return;
            this.setPropertyValue("totalMinimumFractionDigits", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "totalDisplayStyle", {
        /**
         * A format for calculated total values.
         *
         * Possible values:
         *
         * - `"none"` (default)
         * - `"decimal"`
         * - `"currency"`
         * - `"percent"`
         *
         * [View Demo](https://surveyjs.io/form-library/examples/aggregate-data-within-form/ (linkStyle))
         * @see totalType
         * @see totalFormat
         * @see totalCurrency
         */
        get: function () {
            return this.getPropertyValue("totalDisplayStyle");
        },
        set: function (val) {
            this.setPropertyValue("totalDisplayStyle", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "totalAlignment", {
        /**
         * An alignment for calculated total values.
         *
         * Possible values:
         *
         * - `"left"`
         * - `"center"`
         * - `"right"`
         * - `"auto"` (default) - Applies one of the values above based on the column's [cell type](#cellType).
         *
         * [View Demo](https://surveyjs.io/form-library/examples/aggregate-data-within-form/ (linkStyle))
         * @see totalType
         * @see totalFormat
         * @see totalCurrency
         * @see totalDisplayStyle
         */
        get: function () {
            return this.getPropertyValue("totalAlignment");
        },
        set: function (val) {
            this.setPropertyValue("totalAlignment", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "totalCurrency", {
        /**
         * Specifies a currency used to display calculated total values. Applies only if [`totalDisplayStyle`](#totalDisplayStyle) is set to `"currency"`.
         * @see totalType
         */
        get: function () {
            return this.getPropertyValue("totalCurrency");
        },
        set: function (val) {
            if (getCurrecyCodes().indexOf(val) < 0)
                return;
            this.setPropertyValue("totalCurrency", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "minWidth", {
        /**
         * Gets or sets minimum column width in CSS values. By default, the matrix calculates column widths to optimally fit the content of all columns.
         * @see width
         */
        get: function () {
            return this.getPropertyValue("minWidth", "");
        },
        set: function (val) {
            this.setPropertyValue("minWidth", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "width", {
        /**
         * Gets or sets column width in CSS values. By default, the matrix calculates column widths to optimally fit the content of all columns.
         * @see minWidth
        */
        get: function () {
            return this.templateQuestion.width;
        },
        set: function (val) {
            this.templateQuestion.width = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownColumn.prototype, "colCount", {
        /**
         * Gets or sets the number of columns used to arrange choice options. Applies only to columns of `"checkbox"` or `"radiogroup"` [`cellType`](#cellType).
         *
         * Default value: -1 (inherits the actual value from the parent matrix's [`columnColCount`](https://surveyjs.io/form-library/documentation/api-reference/matrix-table-with-dropdown-list#columnColCount) property)
         */
        get: function () {
            return this.getPropertyValue("colCount");
        },
        set: function (val) {
            if (val < -1 || val > 4)
                return;
            this.setPropertyValue("colCount", val);
        },
        enumerable: false,
        configurable: true
    });
    MatrixDropdownColumn.prototype.getLocale = function () {
        return this.colOwner ? this.colOwner.getLocale() : "";
    };
    MatrixDropdownColumn.prototype.getMarkdownHtml = function (text, name) {
        return this.colOwner ? this.colOwner.getMarkdownHtml(text, name) : undefined;
    };
    MatrixDropdownColumn.prototype.getRenderer = function (name) {
        return !!this.colOwner ? this.colOwner.getRenderer(name) : null;
    };
    MatrixDropdownColumn.prototype.getRendererContext = function (locStr) {
        return !!this.colOwner ? this.colOwner.getRendererContext(locStr) : locStr;
    };
    MatrixDropdownColumn.prototype.getProcessedText = function (text) {
        return this.colOwner ? this.colOwner.getProcessedText(text) : text;
    };
    MatrixDropdownColumn.prototype.createCellQuestion = function (row) {
        var qType = this.calcCellQuestionType(row);
        var cellQuestion = this.createNewQuestion(qType);
        this.callOnCellQuestionUpdate(cellQuestion, row);
        return cellQuestion;
    };
    MatrixDropdownColumn.prototype.startLoadingFromJson = function (json) {
        _super.prototype.startLoadingFromJson.call(this, json);
        if (!!json && !json.cellType && !!json.choices) {
            json.cellType = this.colOwner.getCellType();
        }
    };
    MatrixDropdownColumn.prototype.updateCellQuestion = function (cellQuestion, data, onUpdateJson) {
        if (onUpdateJson === void 0) { onUpdateJson = null; }
        this.setQuestionProperties(cellQuestion, onUpdateJson);
    };
    MatrixDropdownColumn.prototype.callOnCellQuestionUpdate = function (cellQuestion, data) {
        var qType = cellQuestion.getType();
        var qDefinition = matrixDropdownColumnTypes[qType];
        if (qDefinition && qDefinition["onCellQuestionUpdate"]) {
            qDefinition["onCellQuestionUpdate"](cellQuestion, this, this.colOwner, data);
        }
    };
    MatrixDropdownColumn.prototype.defaultCellTypeChanged = function () {
        this.updateTemplateQuestion();
    };
    MatrixDropdownColumn.prototype.calcCellQuestionType = function (row) {
        var cellType = this.getDefaultCellQuestionType();
        if (!!row && !!this.colOwner) {
            cellType = this.colOwner.getCustomCellType(this, row, cellType);
        }
        return cellType;
    };
    MatrixDropdownColumn.prototype.getDefaultCellQuestionType = function (cellType) {
        if (!cellType)
            cellType = this.cellType;
        if (cellType !== "default")
            return cellType;
        if (this.colOwner)
            return this.colOwner.getCellType();
        return settings.matrix.defaultCellType;
    };
    MatrixDropdownColumn.prototype.updateTemplateQuestion = function (newCellType) {
        var _this = this;
        var curCellType = this.getDefaultCellQuestionType(newCellType);
        var prevCellType = this.templateQuestion
            ? this.templateQuestion.getType()
            : "";
        if (curCellType === prevCellType)
            return;
        if (this.templateQuestion) {
            this.removeProperties(prevCellType);
        }
        this.templateQuestionValue = this.createNewQuestion(curCellType);
        this.templateQuestion.locOwner = this;
        this.addProperties(curCellType);
        this.templateQuestion.onPropertyChanged.add(function (sender, options) {
            _this.propertyValueChanged(options.name, options.oldValue, options.newValue);
        });
        this.templateQuestion.onItemValuePropertyChanged.add(function (sender, options) {
            _this.doItemValuePropertyChanged(options.propertyName, options.obj, options.name, options.newValue, options.oldValue);
        });
        this.templateQuestion.isContentElement = true;
        if (!this.isLoadingFromJson) {
            this.templateQuestion.onGetSurvey = function () {
                return _this.getSurvey();
            };
        }
        this.templateQuestion.locTitle.strChanged();
    };
    MatrixDropdownColumn.prototype.createNewQuestion = function (cellType) {
        var question = Serializer.createClass(cellType);
        if (!question) {
            question = Serializer.createClass("text");
        }
        question.loadingOwner = this;
        question.isEditableTemplateElement = true;
        question.autoOtherMode = this.isShowInMultipleColumns;
        this.setQuestionProperties(question);
        this.setParentQuestionToTemplate(question);
        return question;
    };
    MatrixDropdownColumn.prototype.setParentQuestionToTemplate = function (question) {
        if (!!this.colOwner && this.colOwner.isQuestion) {
            question.setParentQuestion(this.colOwner);
        }
    };
    MatrixDropdownColumn.prototype.setQuestionProperties = function (question, onUpdateJson) {
        var _this = this;
        if (onUpdateJson === void 0) { onUpdateJson = null; }
        if (this.templateQuestion) {
            var json = new jsonobject_JsonObject().toJsonObject(this.templateQuestion, true);
            if (onUpdateJson) {
                onUpdateJson(json);
            }
            json.type = question.getType();
            if (this.cellType === "default" && !!this.colOwner && this.colOwner.hasChoices()) {
                delete json["choices"];
            }
            delete json["itemComponent"];
            if (this.jsonObj) {
                Object.keys(this.jsonObj).forEach(function (prop) {
                    json[prop] = _this.jsonObj[prop];
                });
            }
            if (json["choicesOrder"] === "random") {
                json["choicesOrder"] = "none";
                var visChoices = this.templateQuestion["visibleChoices"];
                if (Array.isArray(visChoices)) {
                    json["choices"] = visChoices;
                }
            }
            new jsonobject_JsonObject().toObject(json, question);
            question.isContentElement = this.templateQuestion.isContentElement;
            this.previousChoicesId = undefined;
            question.loadedChoicesFromServerCallback = function () {
                if (!_this.isShowInMultipleColumns)
                    return;
                if (!!_this.previousChoicesId && _this.previousChoicesId !== question.id)
                    return;
                _this.previousChoicesId = question.id;
                var choices = question.visibleChoices;
                _this.templateQuestion.choices = choices;
                _this.propertyValueChanged("choices", choices, choices);
            };
        }
    };
    MatrixDropdownColumn.prototype.propertyValueChanged = function (name, oldValue, newValue) {
        _super.prototype.propertyValueChanged.call(this, name, oldValue, newValue);
        if (name === "isRequired") {
            this.updateIsRenderedRequired(newValue);
        }
        if (!this.colOwner || this.isLoadingFromJson)
            return;
        if (this.isShowInMultipleColumns) {
            if (name === "choicesOrder")
                return;
            if (["visibleChoices", "choices"].indexOf(name) > -1) {
                this.colOwner.onShowInMultipleColumnsChanged(this);
            }
        }
        if (!Serializer.hasOriginalProperty(this, name))
            return;
        this.colOwner.onColumnPropertyChanged(this, name, newValue);
    };
    MatrixDropdownColumn.prototype.doItemValuePropertyChanged = function (propertyName, obj, name, newValue, oldValue) {
        if (!Serializer.hasOriginalProperty(obj, name))
            return;
        if (this.colOwner != null && !this.isLoadingFromJson) {
            this.colOwner.onColumnItemValuePropertyChanged(this, propertyName, obj, name, newValue, oldValue);
        }
    };
    MatrixDropdownColumn.prototype.doShowInMultipleColumnsChanged = function () {
        if (this.colOwner != null) {
            this.colOwner.onShowInMultipleColumnsChanged(this);
        }
        if (this.templateQuestion) {
            this.templateQuestion.autoOtherMode = this.isShowInMultipleColumns;
        }
    };
    MatrixDropdownColumn.prototype.doColumnVisibilityChanged = function () {
        if (this.colOwner != null && !this.isDesignMode) {
            this.colOwner.onColumnVisibilityChanged(this);
        }
    };
    MatrixDropdownColumn.prototype.getProperties = function (curCellType) {
        return Serializer.getDynamicPropertiesByObj(this, curCellType);
    };
    MatrixDropdownColumn.prototype.removeProperties = function (curCellType) {
        var properties = this.getProperties(curCellType);
        for (var i = 0; i < properties.length; i++) {
            var prop = properties[i];
            delete this[prop.name];
            if (prop.serializationProperty) {
                delete this[prop.serializationProperty];
            }
        }
    };
    MatrixDropdownColumn.prototype.addProperties = function (curCellType) {
        var props = this.getProperties(curCellType);
        Serializer.addDynamicPropertiesIntoObj(this, this.templateQuestion, props);
    };
    return MatrixDropdownColumn;
}(base_Base));

Serializer.addClass("matrixdropdowncolumn", [
    { name: "!name", isUnique: true },
    {
        name: "title", serializationProperty: "locTitle", dependsOn: "name",
        onPropertyEditorUpdate: function (obj, editor) {
            if (!!obj && !!editor) {
                editor.placeholder = obj.name;
            }
        }
    },
    { name: "cellHint", serializationProperty: "locCellHint", visible: false },
    {
        name: "cellType",
        default: "default",
        choices: function () {
            var res = question_matrixdropdowncolumn_MatrixDropdownColumn.getColumnTypes();
            res.splice(0, 0, "default");
            return res;
        },
    },
    { name: "colCount", default: -1, choices: [-1, 0, 1, 2, 3, 4] },
    "isRequired:boolean",
    "isUnique:boolean",
    {
        name: "requiredErrorText:text",
        serializationProperty: "locRequiredErrorText",
    },
    "readOnly:boolean",
    {
        name: "minWidth",
        onPropertyEditorUpdate: function (obj, editor) {
            if (!!obj && !!editor) {
                editor.value = obj.minWidth;
            }
        }
    },
    "width",
    { name: "visible:switch", default: true, overridingProperty: "visibleIf" },
    "visibleIf:condition",
    "enableIf:condition",
    "requiredIf:condition",
    "resetValueIf:condition",
    "setValueIf:condition",
    "setValueExpression:expression",
    {
        name: "showInMultipleColumns:boolean",
        dependsOn: "cellType",
        visibleIf: function (obj) {
            return obj.isSupportMultipleColumns;
        },
    },
    {
        name: "validators:validators",
        baseClassName: "surveyvalidator",
        classNamePart: "validator",
    },
    {
        name: "totalType",
        visibleIf: function (obj) { return !obj.isShowInMultipleColumns; },
        default: "none",
        choices: ["none", "sum", "count", "min", "max", "avg"],
    },
    { name: "totalExpression:expression", visibleIf: function (obj) { return !obj.isShowInMultipleColumns; } },
    { name: "totalFormat", serializationProperty: "locTotalFormat", visibleIf: function (obj) { return obj.hasTotal; } },
    {
        name: "totalDisplayStyle",
        visibleIf: function (obj) { return obj.hasTotal; },
        default: "none",
        choices: ["none", "decimal", "currency", "percent"],
    },
    {
        name: "totalAlignment",
        visibleIf: function (obj) { return obj.hasTotal; },
        default: "auto",
        choices: ["auto", "left", "center", "right"],
    },
    {
        name: "totalCurrency",
        visibleIf: function (obj) { return obj.hasTotal; },
        choices: function () {
            return getCurrecyCodes();
        },
        default: "USD",
    },
    { name: "totalMaximumFractionDigits:number", default: -1, visibleIf: function (obj) { return obj.hasTotal; } },
    { name: "totalMinimumFractionDigits:number", default: -1, visibleIf: function (obj) { return obj.hasTotal; } },
    { name: "renderAs", default: "default", visible: false },
], function () {
    return new question_matrixdropdowncolumn_MatrixDropdownColumn("");
});

// CONCATENATED MODULE: ./packages/survey-core/src/question_matrixdropdownrendered.ts
var question_matrixdropdownrendered_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var question_matrixdropdownrendered_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var question_matrixdropdownrendered_spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
    for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
        to[j] = from[i];
    return to;
};









var question_matrixdropdownrendered_QuestionMatrixDropdownRenderedCell = /** @class */ (function () {
    function QuestionMatrixDropdownRenderedCell() {
        this.minWidth = "";
        this.width = "";
        this.colSpans = 1;
        this.isActionsCell = false;
        this.isErrorsCell = false;
        this.isDragHandlerCell = false;
        this.isDetailRowCell = false;
        this.classNameValue = "";
        this.idValue = QuestionMatrixDropdownRenderedCell.counter++;
    }
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "requiredText", {
        get: function () {
            return this.column && this.column.isRenderedRequired ? this.column.requiredText : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "hasQuestion", {
        get: function () {
            return !!this.question && !this.isErrorsCell;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "hasTitle", {
        get: function () {
            return !!this.locTitle;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "hasPanel", {
        get: function () {
            return !!this.panel;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "id", {
        get: function () {
            return this.idValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "item", {
        get: function () {
            return this.itemValue;
        },
        set: function (val) {
            this.itemValue = val;
            if (!!val) {
                val.hideCaption = true;
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "isChoice", {
        get: function () {
            return !!this.item;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "isItemChoice", {
        get: function () {
            return this.isChoice && !this.isOtherChoice;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "choiceValue", {
        get: function () {
            return this.isChoice ? this.item.value : null;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "isCheckbox", {
        get: function () {
            return this.isItemChoice && this.question.isDescendantOf("checkbox");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "isRadio", {
        get: function () {
            return this.isItemChoice && this.question.isDescendantOf("radiogroup");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "isFirstChoice", {
        get: function () {
            return this.choiceIndex === 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "className", {
        get: function () {
            var builder = new CssClassBuilder().append(this.classNameValue);
            if (this.hasQuestion) {
                builder
                    .append(this.question.cssClasses.hasError, this.question.errors.length > 0)
                    .append(this.question.cssClasses.answered, this.question.isAnswered);
            }
            return builder.toString();
        },
        set: function (val) {
            this.classNameValue = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "cellQuestionWrapperClassName", {
        get: function () {
            return this.cell.getQuestionWrapperClassName(this.matrix.cssClasses.cellQuestionWrapper);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "isVisible", {
        get: function () {
            var _a;
            return (!this.hasQuestion && !this.isErrorsCell) || !((_a = this.matrix) === null || _a === void 0 ? void 0 : _a.isMobile) || this.question.isVisible;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "showResponsiveTitle", {
        get: function () {
            var _a;
            return this.hasQuestion && ((_a = this.matrix) === null || _a === void 0 ? void 0 : _a.isMobile);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "responsiveTitleCss", {
        get: function () {
            return new CssClassBuilder().append(this.matrix.cssClasses.cellResponsiveTitle).toString();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "responsiveLocTitle", {
        get: function () {
            return this.cell.column.locTitle;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedCell.prototype, "headers", {
        get: function () {
            if (this.cell && this.cell.column) {
                if (this.matrix.IsMultiplyColumn(this.cell.column)) {
                    if (!!this.item) {
                        return this.item.locText.renderedHtml;
                    }
                    else {
                        return "";
                    }
                }
                var cellHint = this.cell.column.cellHint;
                if (!!cellHint) {
                    if (cellHint.trim() === "")
                        return "";
                    return this.cell.column.locCellHint.renderedHtml;
                }
                if (this.hasQuestion && this.question.isVisible && this.question.title)
                    return this.question.title;
                return this.cell.column.title;
            }
            if (this.hasQuestion && this.question.isVisible) {
                return this.question.locTitle.renderedHtml;
            }
            if (this.hasTitle) {
                return this.locTitle.renderedHtml || "";
            }
            return "";
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownRenderedCell.prototype.getTitle = function () {
        return (this.matrix && this.matrix.showHeader) ? this.headers : "";
    };
    QuestionMatrixDropdownRenderedCell.prototype.calculateFinalClassName = function (matrixCssClasses) {
        var questionCss = this.cell.question.cssClasses;
        // 'text-align': $data.isChoice ? 'center':
        var builder = new CssClassBuilder()
            .append(questionCss.itemValue, !!questionCss)
            .append(questionCss.asCell, !!questionCss);
        return builder.append(matrixCssClasses.cell, builder.isEmpty() && !!matrixCssClasses)
            .append(matrixCssClasses.choiceCell, this.isChoice)
            .toString();
    };
    QuestionMatrixDropdownRenderedCell.prototype.focusIn = function () {
        if (this.question) {
            this.question.focusIn();
        }
    };
    QuestionMatrixDropdownRenderedCell.counter = 1;
    return QuestionMatrixDropdownRenderedCell;
}());

var question_matrixdropdownrendered_QuestionMatrixDropdownRenderedRow = /** @class */ (function (_super) {
    question_matrixdropdownrendered_extends(QuestionMatrixDropdownRenderedRow, _super);
    function QuestionMatrixDropdownRenderedRow(cssClasses, isDetailRow) {
        if (isDetailRow === void 0) { isDetailRow = false; }
        var _this = _super.call(this) || this;
        _this.cssClasses = cssClasses;
        _this.isDetailRow = isDetailRow;
        _this.hasEndActions = false;
        _this.isErrorsRow = false;
        _this.cells = [];
        _this.idValue = QuestionMatrixDropdownRenderedRow.counter++;
        return _this;
    }
    Object.defineProperty(QuestionMatrixDropdownRenderedRow.prototype, "id", {
        get: function () {
            return this.idValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedRow.prototype, "attributes", {
        get: function () {
            if (!this.row)
                return {};
            return { "data-sv-drop-target-matrix-row": this.row.id };
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedRow.prototype, "className", {
        get: function () {
            var _a, _b;
            return new CssClassBuilder()
                .append(this.cssClasses.row)
                .append(this.cssClasses.detailRow, this.isDetailRow)
                .append(this.cssClasses.rowHasPanel, (_a = this.row) === null || _a === void 0 ? void 0 : _a.hasPanel)
                .append(this.cssClasses.expandedRow, ((_b = this.row) === null || _b === void 0 ? void 0 : _b.isDetailPanelShowing) && !this.isDetailRow)
                .append(this.cssClasses.rowHasEndActions, this.hasEndActions)
                .append(this.cssClasses.ghostRow, this.isGhostRow)
                .append(this.cssClasses.rowAdditional, this.isAdditionalClasses)
                .toString();
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownRenderedRow.prototype.setRootElement = function (val) {
        this.rootElement = val;
    };
    QuestionMatrixDropdownRenderedRow.prototype.getRootElement = function () {
        return this.rootElement;
    };
    QuestionMatrixDropdownRenderedRow.counter = 1;
    question_matrixdropdownrendered_decorate([
        jsonobject_property({ defaultValue: false })
    ], QuestionMatrixDropdownRenderedRow.prototype, "isGhostRow", void 0);
    question_matrixdropdownrendered_decorate([
        jsonobject_property({ defaultValue: false })
    ], QuestionMatrixDropdownRenderedRow.prototype, "isAdditionalClasses", void 0);
    question_matrixdropdownrendered_decorate([
        jsonobject_property({ defaultValue: true })
    ], QuestionMatrixDropdownRenderedRow.prototype, "visible", void 0);
    return QuestionMatrixDropdownRenderedRow;
}(base_Base));

var question_matrixdropdownrendered_QuestionMatrixDropdownRenderedErrorRow = /** @class */ (function (_super) {
    question_matrixdropdownrendered_extends(QuestionMatrixDropdownRenderedErrorRow, _super);
    function QuestionMatrixDropdownRenderedErrorRow(cssClasses) {
        var _this = _super.call(this, cssClasses) || this;
        _this.isErrorsRow = true;
        return _this;
    }
    Object.defineProperty(QuestionMatrixDropdownRenderedErrorRow.prototype, "attributes", {
        get: function () {
            return {};
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedErrorRow.prototype, "className", {
        get: function () {
            return new CssClassBuilder()
                .append(this.cssClasses.row)
                .append(this.cssClasses.errorRow)
                .toString();
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownRenderedErrorRow.prototype.onAfterCreated = function () {
        var _this = this;
        var callback = function () {
            _this.visible = _this.cells.some(function (cell) { return cell.question && cell.question.hasVisibleErrors; });
        };
        this.cells.forEach(function (cell) {
            if (cell.question) {
                cell.question.registerFunctionOnPropertyValueChanged("hasVisibleErrors", callback);
            }
        });
        callback();
    };
    return QuestionMatrixDropdownRenderedErrorRow;
}(question_matrixdropdownrendered_QuestionMatrixDropdownRenderedRow));

var question_matrixdropdownrendered_QuestionMatrixDropdownRenderedTable = /** @class */ (function (_super) {
    question_matrixdropdownrendered_extends(QuestionMatrixDropdownRenderedTable, _super);
    function QuestionMatrixDropdownRenderedTable(matrix) {
        var _this = _super.call(this) || this;
        _this.matrix = matrix;
        _this._renderedRows = [];
        _this.renderedRowsAnimation = new animation_AnimationGroup(_this.getRenderedRowsAnimationOptions(), function (val) {
            _this._renderedRows = val;
        }, function () { return _this._renderedRows; });
        _this.hasActionCellInRowsValues = {};
        _this.build();
        return _this;
    }
    QuestionMatrixDropdownRenderedTable.prototype.getIsAnimationAllowed = function () {
        return _super.prototype.getIsAnimationAllowed.call(this) && this.matrix.animationAllowed;
    };
    QuestionMatrixDropdownRenderedTable.prototype.getRenderedRowsAnimationOptions = function () {
        var _this = this;
        var beforeAnimationRun = function (el) {
            el.querySelectorAll(":scope > td > *").forEach(function (el) {
                el.style.setProperty("--animation-height", el.offsetHeight + "px");
            });
        };
        return {
            isAnimationEnabled: function () {
                return _this.animationAllowed;
            },
            getRerenderEvent: function () { return _this.onElementRerendered; },
            getAnimatedElement: function (el) {
                return el.getRootElement();
            },
            getLeaveOptions: function () {
                return { cssClass: _this.cssClasses.rowFadeOut, onBeforeRunAnimation: beforeAnimationRun };
            },
            getEnterOptions: function () {
                return { cssClass: _this.cssClasses.rowFadeIn, onBeforeRunAnimation: beforeAnimationRun };
            }
        };
    };
    QuestionMatrixDropdownRenderedTable.prototype.updateRenderedRows = function () {
        this.renderedRows = this.rows;
    };
    Object.defineProperty(QuestionMatrixDropdownRenderedTable.prototype, "renderedRows", {
        get: function () {
            return this._renderedRows;
        },
        set: function (val) {
            this.renderedRowsAnimation.sync(val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedTable.prototype, "showTable", {
        get: function () {
            return this.getPropertyValue("showTable", true);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedTable.prototype, "showHeader", {
        get: function () {
            return this.getPropertyValue("showHeader");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedTable.prototype, "showAddRow", {
        get: function () {
            return this.getPropertyValue("showAddRow", false);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedTable.prototype, "showAddRowOnTop", {
        get: function () {
            return this.getPropertyValue("showAddRowOnTop", false);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedTable.prototype, "showAddRowOnBottom", {
        get: function () {
            return this.getPropertyValue("showAddRowOnBottom", false);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedTable.prototype, "showFooter", {
        get: function () {
            return this.matrix.hasFooter && this.matrix.isColumnLayoutHorizontal;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedTable.prototype, "hasFooter", {
        get: function () {
            return !!this.footerRow;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedTable.prototype, "hasRemoveRows", {
        get: function () {
            return this.hasRemoveRowsValue;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownRenderedTable.prototype.isRequireReset = function () {
        return (this.hasRemoveRows != this.matrix.canRemoveRows ||
            !this.matrix.isColumnLayoutHorizontal);
    };
    Object.defineProperty(QuestionMatrixDropdownRenderedTable.prototype, "headerRow", {
        get: function () {
            return this.headerRowValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedTable.prototype, "footerRow", {
        get: function () {
            return this.footerRowValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedTable.prototype, "isRowsDragAndDrop", {
        get: function () {
            return this.matrix.isRowsDragAndDrop && this.matrix.isColumnLayoutHorizontal;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedTable.prototype, "showCellErrorsTop", {
        get: function () {
            //todo
            return this.matrix.getErrorLocation() === "top";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownRenderedTable.prototype, "showCellErrorsBottom", {
        get: function () {
            //todo
            return this.matrix.getErrorLocation() === "bottom";
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownRenderedTable.prototype.build = function () {
        this.hasRemoveRowsValue = this.matrix.canRemoveRows;
        //build rows now
        var rows = this.matrix.visibleRows;
        this.cssClasses = this.matrix.cssClasses;
        this.buildRowsActions();
        this.buildHeader();
        this.buildRows();
        this.buildFooter();
        this.updateShowTableAndAddRow();
    };
    QuestionMatrixDropdownRenderedTable.prototype.updateShowTableAndAddRow = function () {
        var showTable = this.rows.length > 0 ||
            this.matrix.isDesignMode ||
            !this.matrix.getShowColumnsIfEmpty();
        this.setPropertyValue("showTable", showTable);
        var showAddRow = this.matrix.canAddRow && showTable;
        var showAddRowOnTop = showAddRow;
        var showAddRowOnBottom = showAddRow;
        if (showAddRowOnTop) {
            if (this.matrix.getAddRowLocation() === "default") {
                showAddRowOnTop = !this.matrix.isColumnLayoutHorizontal;
            }
            else {
                showAddRowOnTop = this.matrix.getAddRowLocation() !== "bottom";
            }
        }
        if (showAddRowOnBottom && this.matrix.getAddRowLocation() !== "topBottom") {
            showAddRowOnBottom = !showAddRowOnTop;
        }
        this.setPropertyValue("showAddRow", this.matrix.canAddRow);
        this.setPropertyValue("showAddRowOnTop", showAddRowOnTop);
        this.setPropertyValue("showAddRowOnBottom", showAddRowOnBottom);
    };
    QuestionMatrixDropdownRenderedTable.prototype.onAddedRow = function (row, index) {
        if (this.getRenderedDataRowCount() >= this.matrix.visibleRows.length)
            return;
        var rowIndex = this.getRenderedRowIndexByIndex(index);
        this.rowsActions.splice(index, 0, this.buildRowActions(row));
        this.addHorizontalRow(this.rows, row, this.matrix.visibleRows.length == 1 && !this.matrix.showHeader, rowIndex);
        this.updateShowTableAndAddRow();
    };
    QuestionMatrixDropdownRenderedTable.prototype.getRenderedRowIndexByIndex = function (index) {
        var res = 0;
        var dataRowIndex = 0;
        for (var i = 0; i < this.rows.length; i++) {
            if (dataRowIndex === index) {
                if (this.rows[i].isErrorsRow || this.rows[i].isDetailRow)
                    res++;
                break;
            }
            res++;
            if (!(this.rows[i].isErrorsRow) && !this.rows[i].isDetailRow)
                dataRowIndex++;
        }
        if (dataRowIndex < index)
            return this.rows.length;
        return res;
    };
    QuestionMatrixDropdownRenderedTable.prototype.getRenderedDataRowCount = function () {
        var res = 0;
        for (var i = 0; i < this.rows.length; i++) {
            if (!(this.rows[i].isErrorsRow) && !this.rows[i].isDetailRow)
                res++;
        }
        return res;
    };
    QuestionMatrixDropdownRenderedTable.prototype.onRemovedRow = function (row) {
        var rowIndex = this.getRenderedRowIndex(row);
        if (rowIndex < 0)
            return;
        this.rowsActions.splice(rowIndex, 1);
        var removeCount = 1;
        if (rowIndex < this.rows.length - 1 && this.showCellErrorsBottom &&
            this.rows[rowIndex + 1].isErrorsRow) {
            removeCount++;
        }
        if (rowIndex < this.rows.length - 1 &&
            (this.rows[rowIndex + 1].isDetailRow ||
                this.showCellErrorsBottom && rowIndex + 1 < this.rows.length - 1 && this.rows[rowIndex + 2].isDetailRow)) {
            removeCount++;
        }
        if (rowIndex > 0 && this.showCellErrorsTop && this.rows[rowIndex - 1].isErrorsRow) {
            rowIndex--;
            removeCount++;
        }
        this.rows.splice(rowIndex, removeCount);
        this.updateShowTableAndAddRow();
    };
    QuestionMatrixDropdownRenderedTable.prototype.onDetailPanelChangeVisibility = function (row, isShowing) {
        var rowIndex = this.getRenderedRowIndex(row);
        if (rowIndex < 0)
            return;
        var currentIndex = rowIndex;
        if (this.showCellErrorsBottom)
            currentIndex++;
        var panelRowIndex = currentIndex < this.rows.length - 1 && this.rows[currentIndex + 1].isDetailRow
            ? currentIndex + 1
            : -1;
        if ((isShowing && panelRowIndex > -1) || (!isShowing && panelRowIndex < 0))
            return;
        if (isShowing) {
            var detailRow = this.createDetailPanelRow(row, this.rows[rowIndex]);
            this.rows.splice(currentIndex + 1, 0, detailRow);
        }
        else {
            this.rows.splice(panelRowIndex, 1);
        }
    };
    QuestionMatrixDropdownRenderedTable.prototype.getRenderedRowIndex = function (row) {
        for (var i = 0; i < this.rows.length; i++) {
            if (this.rows[i].row == row)
                return i;
        }
        return -1;
    };
    QuestionMatrixDropdownRenderedTable.prototype.buildRowsActions = function () {
        this.rowsActions = [];
        var rows = this.matrix.visibleRows;
        for (var i = 0; i < rows.length; i++) {
            this.rowsActions.push(this.buildRowActions(rows[i]));
        }
    };
    QuestionMatrixDropdownRenderedTable.prototype.createRenderedRow = function (cssClasses, isDetailRow) {
        if (isDetailRow === void 0) { isDetailRow = false; }
        return new question_matrixdropdownrendered_QuestionMatrixDropdownRenderedRow(cssClasses, isDetailRow);
    };
    QuestionMatrixDropdownRenderedTable.prototype.createErrorRenderedRow = function (cssClasses) {
        return new question_matrixdropdownrendered_QuestionMatrixDropdownRenderedErrorRow(cssClasses);
    };
    QuestionMatrixDropdownRenderedTable.prototype.buildHeader = function () {
        var colHeaders = this.matrix.isColumnLayoutHorizontal && this.matrix.showHeader;
        var isShown = colHeaders ||
            (this.matrix.hasRowText && !this.matrix.isColumnLayoutHorizontal);
        this.setPropertyValue("showHeader", isShown);
        if (!isShown)
            return;
        this.headerRowValue = this.createRenderedRow(this.cssClasses);
        if (this.isRowsDragAndDrop) {
            this.headerRow.cells.push(this.createHeaderCell(null, "action"));
        }
        if (this.hasActionCellInRows("start")) {
            this.headerRow.cells.push(this.createHeaderCell(null, "action"));
        }
        if (this.matrix.hasRowText && this.matrix.showHeader) {
            this.headerRow.cells.push(this.createHeaderCell(null));
        }
        if (this.matrix.isColumnLayoutHorizontal) {
            for (var i = 0; i < this.matrix.visibleColumns.length; i++) {
                var column = this.matrix.visibleColumns[i];
                if (!column.isColumnVisible)
                    continue;
                if (this.matrix.IsMultiplyColumn(column)) {
                    this.createMutlipleColumnsHeader(column);
                }
                else {
                    this.headerRow.cells.push(this.createHeaderCell(column));
                }
            }
        }
        else {
            var rows = this.matrix.visibleRows;
            for (var i = 0; i < rows.length; i++) {
                var cell = this.createTextCell(rows[i].locText);
                this.setHeaderCellCssClasses(cell);
                cell.row = rows[i];
                this.headerRow.cells.push(cell);
            }
            if (this.matrix.hasFooter) {
                var cell = this.createTextCell(this.matrix.getFooterText());
                this.setHeaderCellCssClasses(cell);
                this.headerRow.cells.push(cell);
            }
        }
        if (this.hasActionCellInRows("end")) {
            this.headerRow.cells.push(this.createHeaderCell(null, "action"));
        }
    };
    QuestionMatrixDropdownRenderedTable.prototype.buildFooter = function () {
        if (!this.showFooter)
            return;
        this.footerRowValue = this.createRenderedRow(this.cssClasses);
        if (this.isRowsDragAndDrop) {
            this.footerRow.cells.push(this.createHeaderCell(null));
        }
        if (this.hasActionCellInRows("start")) {
            this.footerRow.cells.push(this.createHeaderCell(null, "action"));
        }
        if (this.matrix.hasRowText) {
            var cell_1 = this.createTextCell(this.matrix.getFooterText());
            cell_1.className = new CssClassBuilder().append(cell_1.className)
                .append(this.cssClasses.footerTotalCell).toString();
            this.footerRow.cells.push(cell_1);
        }
        var cells = this.matrix.visibleTotalRow.cells;
        for (var i = 0; i < cells.length; i++) {
            var cell = cells[i];
            if (!cell.column.isColumnVisible)
                continue;
            if (this.matrix.IsMultiplyColumn(cell.column)) {
                this.createMutlipleColumnsFooter(this.footerRow, cell);
            }
            else {
                var editCell = this.createEditCell(cell);
                if (cell.column) {
                    this.setHeaderCellWidth(cell.column, editCell);
                }
                editCell.className = new CssClassBuilder().append(editCell.className)
                    .append(this.cssClasses.footerCell).toString();
                this.footerRow.cells.push(editCell);
            }
        }
        if (this.hasActionCellInRows("end")) {
            this.footerRow.cells.push(this.createHeaderCell(null, "action"));
        }
    };
    QuestionMatrixDropdownRenderedTable.prototype.buildRows = function () {
        this.blockAnimations();
        var rows = this.matrix.isColumnLayoutHorizontal
            ? this.buildHorizontalRows()
            : this.buildVerticalRows();
        this.rows = rows;
        this.releaseAnimations();
    };
    QuestionMatrixDropdownRenderedTable.prototype.hasActionCellInRows = function (location) {
        if (this.hasActionCellInRowsValues[location] === undefined) {
            this.hasActionCellInRowsValues[location] = this.hasActionsCellInLocaltion(location);
        }
        return this.hasActionCellInRowsValues[location];
    };
    QuestionMatrixDropdownRenderedTable.prototype.hasActionsCellInLocaltion = function (location) {
        var _this = this;
        if (location == "end" && this.hasRemoveRows)
            return true;
        return this.matrix.visibleRows.some(function (row, index) { return !_this.isValueEmpty(_this.getRowActions(index, location)); });
    };
    QuestionMatrixDropdownRenderedTable.prototype.canRemoveRow = function (row) {
        return this.matrix.canRemoveRow(row);
    };
    QuestionMatrixDropdownRenderedTable.prototype.buildHorizontalRows = function () {
        var rows = this.matrix.visibleRows;
        var renderedRows = [];
        for (var i = 0; i < rows.length; i++) {
            this.addHorizontalRow(renderedRows, rows[i], i == 0 && !this.matrix.showHeader);
        }
        return renderedRows;
    };
    QuestionMatrixDropdownRenderedTable.prototype.addHorizontalRow = function (renderedRows, row, useAsHeader, index) {
        if (index === void 0) { index = -1; }
        var renderedRow = this.createHorizontalRow(row, useAsHeader);
        var errorRow = this.createErrorRow(renderedRow);
        renderedRow.row = row;
        if (index < 0) {
            index = renderedRows.length;
        }
        if (this.matrix.isMobile) {
            var cells = [];
            for (var i = 0; i < renderedRow.cells.length; i++) {
                if (this.showCellErrorsTop && !errorRow.cells[i].isEmpty) {
                    cells.push(errorRow.cells[i]);
                }
                cells.push(renderedRow.cells[i]);
                if (this.showCellErrorsBottom && !errorRow.cells[i].isEmpty) {
                    cells.push(errorRow.cells[i]);
                }
            }
            renderedRow.cells = cells;
            renderedRows.splice(index, 0, renderedRow);
        }
        else {
            renderedRows.splice.apply(renderedRows, question_matrixdropdownrendered_spreadArray([index, 0], (this.showCellErrorsTop ? [errorRow, renderedRow] : [renderedRow, errorRow])));
            index++;
        }
        if (row.isDetailPanelShowing) {
            renderedRows.splice(index + 1, 0, this.createDetailPanelRow(row, renderedRow));
        }
    };
    QuestionMatrixDropdownRenderedTable.prototype.getRowDragCell = function (rowIndex) {
        var cell = new question_matrixdropdownrendered_QuestionMatrixDropdownRenderedCell();
        var lockedRows = this.matrix.lockedRowCount;
        cell.isDragHandlerCell = lockedRows < 1 || rowIndex >= lockedRows;
        cell.isEmpty = !cell.isDragHandlerCell;
        cell.className = this.getActionsCellClassName(cell);
        cell.row = this.matrix.visibleRows[rowIndex];
        return cell;
    };
    QuestionMatrixDropdownRenderedTable.prototype.getActionsCellClassName = function (cell) {
        var _this = this;
        if (cell === void 0) { cell = null; }
        var classBuilder = new CssClassBuilder()
            .append(this.cssClasses.actionsCell)
            .append(this.cssClasses.actionsCellDrag, cell === null || cell === void 0 ? void 0 : cell.isDragHandlerCell)
            .append(this.cssClasses.detailRowCell, cell === null || cell === void 0 ? void 0 : cell.isDetailRowCell)
            .append(this.cssClasses.verticalCell, !this.matrix.isColumnLayoutHorizontal);
        if (cell.isActionsCell) {
            var actions = cell.item.value.actions;
            if (this.cssClasses.actionsCellPrefix) {
                actions.forEach(function (action) {
                    classBuilder.append(_this.cssClasses.actionsCellPrefix + "--" + action.id);
                });
            }
        }
        return classBuilder.toString();
    };
    QuestionMatrixDropdownRenderedTable.prototype.getRowActionsCell = function (rowIndex, location, isDetailRow) {
        if (isDetailRow === void 0) { isDetailRow = false; }
        var rowActions = this.getRowActions(rowIndex, location);
        if (!this.isValueEmpty(rowActions)) {
            var cell = new question_matrixdropdownrendered_QuestionMatrixDropdownRenderedCell();
            var actionContainer = this.matrix.allowAdaptiveActions ? new adaptive_container_AdaptiveActionContainer() : new container_ActionContainer();
            if (!!this.matrix.survey && this.matrix.survey.getCss().actionBar) {
                actionContainer.cssClasses = this.matrix.survey.getCss().actionBar;
            }
            actionContainer.setItems(rowActions);
            var itemValue = new itemvalue_ItemValue(actionContainer);
            cell.item = itemValue;
            cell.isActionsCell = true;
            cell.isDragHandlerCell = false;
            cell.isDetailRowCell = isDetailRow;
            cell.className = this.getActionsCellClassName(cell);
            cell.row = this.matrix.visibleRows[rowIndex];
            return cell;
        }
        return null;
    };
    QuestionMatrixDropdownRenderedTable.prototype.getRowActions = function (rowIndex, location) {
        var actions = this.rowsActions[rowIndex];
        if (!Array.isArray(actions))
            return [];
        return actions.filter(function (action) {
            if (!action.location) {
                action.location = "start";
            }
            return action.location === location;
        });
    };
    QuestionMatrixDropdownRenderedTable.prototype.buildRowActions = function (row) {
        var actions = [];
        this.setDefaultRowActions(row, actions);
        if (!!this.matrix.survey) {
            actions = this.matrix.survey.getUpdatedMatrixRowActions(this.matrix, row, actions);
        }
        return actions;
    };
    Object.defineProperty(QuestionMatrixDropdownRenderedTable.prototype, "showRemoveButtonAsIcon", {
        get: function () {
            return (settings.matrix.renderRemoveAsIcon && this.matrix.survey && this.matrix.survey.css.root === "sd-root-modern");
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownRenderedTable.prototype.setDefaultRowActions = function (row, actions) {
        var _this = this;
        var matrix = this.matrix;
        if (this.hasRemoveRows && this.canRemoveRow(row)) {
            if (!this.showRemoveButtonAsIcon) {
                actions.push(new action_Action({
                    id: "remove-row",
                    location: "end",
                    enabled: !this.matrix.isInputReadOnly,
                    component: "sv-matrix-remove-button",
                    data: { row: row, question: this.matrix },
                }));
            }
            else {
                actions.push(new action_Action({
                    id: "remove-row",
                    iconName: "icon-delete",
                    iconSize: "auto",
                    component: "sv-action-bar-item",
                    innerCss: new CssClassBuilder().append(this.matrix.cssClasses.button).append(this.matrix.cssClasses.buttonRemove).toString(),
                    location: "end",
                    showTitle: false,
                    title: matrix.removeRowText,
                    enabled: !matrix.isInputReadOnly,
                    data: { row: row, question: matrix },
                    action: function () {
                        matrix.removeRowUI(row);
                    },
                }));
            }
        }
        if (row.hasPanel) {
            if (this.matrix.isMobile) {
                actions.unshift(new action_Action({
                    id: "show-detail-mobile",
                    title: "Show Details",
                    showTitle: true,
                    location: "end",
                    action: function (context) {
                        context.title = row.isDetailPanelShowing ? _this.matrix.getLocalizationString("showDetails") : _this.matrix.getLocalizationString("hideDetails");
                        row.showHideDetailPanelClick();
                    },
                }));
            }
            else {
                actions.push(new action_Action({
                    id: "show-detail",
                    title: this.matrix.getLocalizationString("editText"),
                    showTitle: false,
                    location: "start",
                    component: "sv-matrix-detail-button",
                    data: { row: row, question: this.matrix },
                }));
            }
        }
    };
    QuestionMatrixDropdownRenderedTable.prototype.createErrorRow = function (row) {
        var res = this.createErrorRenderedRow(this.cssClasses);
        for (var i = 0; i < row.cells.length; i++) {
            var cell = row.cells[i];
            if (!cell.hasQuestion) {
                res.cells.push(this.createEmptyCell(true));
            }
            else if (this.matrix.IsMultiplyColumn(cell.cell.column)) {
                if (cell.isFirstChoice) {
                    res.cells.push(this.createErrorCell(cell.cell));
                }
                else {
                    res.cells.push(this.createEmptyCell(true));
                }
            }
            else {
                res.cells.push(this.createErrorCell(cell.cell));
            }
        }
        res.onAfterCreated();
        return res;
    };
    QuestionMatrixDropdownRenderedTable.prototype.createHorizontalRow = function (row, useAsHeader) {
        var res = this.createRenderedRow(this.cssClasses);
        if (this.isRowsDragAndDrop) {
            var rowIndex = this.matrix.visibleRows.indexOf(row);
            res.cells.push(this.getRowDragCell(rowIndex));
        }
        this.addRowActionsCell(row, res, "start");
        if (this.matrix.hasRowText) {
            var renderedCell = this.createTextCell(row.locText);
            renderedCell.row = row;
            res.cells.push(renderedCell);
            this.setHeaderCellWidth(null, renderedCell);
            renderedCell.className = new CssClassBuilder()
                .append(renderedCell.className)
                .append(this.cssClasses.rowTextCell)
                .append(this.cssClasses.columnTitleCell, !this.matrix.isColumnLayoutHorizontal)
                .append(this.cssClasses.detailRowText, row.hasPanel)
                .toString();
        }
        for (var i = 0; i < row.cells.length; i++) {
            var cell = row.cells[i];
            if (!cell.column.isColumnVisible)
                continue;
            if (this.matrix.IsMultiplyColumn(cell.column)) {
                this.createMutlipleEditCells(res, cell);
            }
            else {
                if (cell.column.isShowInMultipleColumns) {
                    cell.question.visibleChoices.map(function (c) { return c.hideCaption = false; });
                }
                var renderedCell = this.createEditCell(cell);
                res.cells.push(renderedCell);
                if (useAsHeader) {
                    this.setHeaderCellWidth(cell.column, renderedCell);
                }
            }
        }
        this.addRowActionsCell(row, res, "end");
        return res;
    };
    QuestionMatrixDropdownRenderedTable.prototype.addRowActionsCell = function (row, renderedRow, location) {
        var rowIndex = this.matrix.visibleRows.indexOf(row);
        if (this.hasActionCellInRows(location)) {
            var actions = this.getRowActionsCell(rowIndex, location, renderedRow.isDetailRow);
            if (!!actions) {
                renderedRow.cells.push(actions);
                renderedRow.hasEndActions = true;
            }
            else {
                var cell = new question_matrixdropdownrendered_QuestionMatrixDropdownRenderedCell();
                cell.isEmpty = true;
                cell.isDetailRowCell = renderedRow.isDetailRow;
                renderedRow.cells.push(cell);
            }
        }
    };
    QuestionMatrixDropdownRenderedTable.prototype.createDetailPanelRow = function (row, renderedRow) {
        var panelFullWidth = this.matrix.isDesignMode;
        var res = this.createRenderedRow(this.cssClasses, true);
        res.row = row;
        var buttonCell = new question_matrixdropdownrendered_QuestionMatrixDropdownRenderedCell();
        if (this.matrix.hasRowText) {
            buttonCell.colSpans = 2;
        }
        buttonCell.isEmpty = true;
        if (!panelFullWidth)
            res.cells.push(buttonCell);
        var actionsCell = null;
        if (this.hasActionCellInRows("end")) {
            actionsCell = new question_matrixdropdownrendered_QuestionMatrixDropdownRenderedCell();
            actionsCell.isEmpty = true;
        }
        var cell = new question_matrixdropdownrendered_QuestionMatrixDropdownRenderedCell();
        cell.panel = row.detailPanel;
        cell.colSpans =
            renderedRow.cells.length -
                (!panelFullWidth ? buttonCell.colSpans : 0) -
                (!!actionsCell ? actionsCell.colSpans : 0);
        cell.className = this.cssClasses.detailPanelCell;
        res.cells.push(cell);
        if (!!actionsCell) {
            if (this.matrix.isMobile) {
                this.addRowActionsCell(row, res, "end");
            }
            else {
                res.cells.push(actionsCell);
            }
        }
        if (typeof this.matrix.onCreateDetailPanelRenderedRowCallback === "function") {
            this.matrix.onCreateDetailPanelRenderedRowCallback(res);
        }
        return res;
    };
    QuestionMatrixDropdownRenderedTable.prototype.buildVerticalRows = function () {
        var columns = this.matrix.columns;
        var renderedRows = [];
        for (var i = 0; i < columns.length; i++) {
            var col = columns[i];
            if (col.isColumnVisible) {
                if (this.matrix.IsMultiplyColumn(col)) {
                    this.createMutlipleVerticalRows(renderedRows, col, i);
                }
                else {
                    var renderedRow = this.createVerticalRow(col, i);
                    var errorRow = this.createErrorRow(renderedRow);
                    if (this.showCellErrorsTop) {
                        renderedRows.push(errorRow);
                        renderedRows.push(renderedRow);
                    }
                    else {
                        renderedRows.push(renderedRow);
                        renderedRows.push(errorRow);
                    }
                }
            }
        }
        if (this.hasActionCellInRows("end")) {
            renderedRows.push(this.createEndVerticalActionRow());
        }
        return renderedRows;
    };
    QuestionMatrixDropdownRenderedTable.prototype.createMutlipleVerticalRows = function (renderedRows, column, index) {
        var choices = this.getMultipleColumnChoices(column);
        if (!choices)
            return;
        for (var i = 0; i < choices.length; i++) {
            var renderedRow = this.createVerticalRow(column, index, choices[i], i);
            var errorRow = this.createErrorRow(renderedRow);
            if (this.showCellErrorsTop) {
                renderedRows.push(errorRow);
                renderedRows.push(renderedRow);
            }
            else {
                renderedRows.push(renderedRow);
                renderedRows.push(errorRow);
            }
        }
    };
    QuestionMatrixDropdownRenderedTable.prototype.createVerticalRow = function (column, index, choice, choiceIndex) {
        if (choice === void 0) { choice = null; }
        if (choiceIndex === void 0) { choiceIndex = -1; }
        var res = this.createRenderedRow(this.cssClasses);
        if (this.matrix.showHeader) {
            var lTitle = !!choice ? choice.locText : column.locTitle;
            var hCell = this.createTextCell(lTitle);
            hCell.column = column;
            hCell.className = new CssClassBuilder()
                .append(hCell.className)
                .append(this.cssClasses.rowTextCell)
                .append(this.cssClasses.columnTitleCell).toString();
            res.cells.push(hCell);
        }
        var rows = this.matrix.visibleRows;
        for (var i = 0; i < rows.length; i++) {
            var rChoice = choice;
            var rChoiceIndex = choiceIndex >= 0 ? choiceIndex : i;
            var cell = rows[i].cells[index];
            var visChoices = !!choice ? cell.question.visibleChoices : undefined;
            if (!!visChoices && rChoiceIndex < visChoices.length) {
                rChoice = visChoices[rChoiceIndex];
            }
            var rCell = this.createEditCell(cell, rChoice);
            rCell.item = rChoice;
            rCell.choiceIndex = rChoiceIndex;
            res.cells.push(rCell);
        }
        if (this.matrix.hasTotal) {
            res.cells.push(this.createEditCell(this.matrix.visibleTotalRow.cells[index]));
        }
        return res;
    };
    QuestionMatrixDropdownRenderedTable.prototype.createEndVerticalActionRow = function () {
        var res = this.createRenderedRow(this.cssClasses);
        if (this.matrix.showHeader) {
            res.cells.push(this.createEmptyCell());
        }
        var rows = this.matrix.visibleRows;
        for (var i = 0; i < rows.length; i++) {
            res.cells.push(this.getRowActionsCell(i, "end"));
        }
        if (this.matrix.hasTotal) {
            res.cells.push(this.createEmptyCell());
        }
        return res;
    };
    QuestionMatrixDropdownRenderedTable.prototype.createMutlipleEditCells = function (rRow, cell, isFooter) {
        if (isFooter === void 0) { isFooter = false; }
        var choices = isFooter
            ? this.getMultipleColumnChoices(cell.column)
            : cell.question.visibleChoices;
        if (!choices)
            return;
        for (var i = 0; i < choices.length; i++) {
            var rCell = this.createEditCell(cell, !isFooter ? choices[i] : undefined);
            if (!isFooter) {
                //rCell.item = choices[i];
                this.setItemCellCssClasses(rCell);
                rCell.choiceIndex = i;
            }
            rRow.cells.push(rCell);
        }
    };
    QuestionMatrixDropdownRenderedTable.prototype.setItemCellCssClasses = function (cell) {
        cell.className = new CssClassBuilder()
            .append(this.cssClasses.cell)
            .append(this.cssClasses.itemCell)
            .append(this.cssClasses.radioCell, cell.isRadio)
            .append(this.cssClasses.checkboxCell, cell.isCheckbox)
            .toString();
    };
    QuestionMatrixDropdownRenderedTable.prototype.createEditCell = function (cell, choiceItem) {
        if (choiceItem === void 0) { choiceItem = undefined; }
        var res = new question_matrixdropdownrendered_QuestionMatrixDropdownRenderedCell();
        res.cell = cell;
        res.row = cell.row;
        res.question = cell.question;
        res.matrix = this.matrix;
        res.item = choiceItem;
        res.isOtherChoice = !!choiceItem && !!cell.question && cell.question.otherItem === choiceItem;
        res.className = res.calculateFinalClassName(this.cssClasses);
        return res;
    };
    QuestionMatrixDropdownRenderedTable.prototype.createErrorCell = function (cell, choiceItem) {
        if (choiceItem === void 0) { choiceItem = undefined; }
        var res = new question_matrixdropdownrendered_QuestionMatrixDropdownRenderedCell();
        res.question = cell.question;
        res.row = cell.row;
        res.matrix = this.matrix;
        res.isErrorsCell = true;
        res.className = new CssClassBuilder()
            .append(this.cssClasses.cell)
            .append(this.cssClasses.errorsCell)
            .append(this.cssClasses.errorsCellTop, this.showCellErrorsTop)
            .append(this.cssClasses.errorsCellBottom, this.showCellErrorsBottom)
            .toString();
        return res;
    };
    QuestionMatrixDropdownRenderedTable.prototype.createMutlipleColumnsFooter = function (rRow, cell) {
        this.createMutlipleEditCells(rRow, cell, true);
    };
    QuestionMatrixDropdownRenderedTable.prototype.createMutlipleColumnsHeader = function (column) {
        var choices = this.getMultipleColumnChoices(column);
        if (!choices)
            return;
        for (var i = 0; i < choices.length; i++) {
            var cell = this.createTextCell(choices[i].locText);
            this.setHeaderCell(column, cell);
            this.setHeaderCellCssClasses(cell);
            this.headerRow.cells.push(cell);
        }
    };
    QuestionMatrixDropdownRenderedTable.prototype.getMultipleColumnChoices = function (column) {
        var choices = column.templateQuestion.choices;
        if (!!choices && Array.isArray(choices) && choices.length == 0)
            return [].concat(this.matrix.choices, column.getVisibleMultipleChoices());
        choices = column.getVisibleMultipleChoices();
        if (!choices || !Array.isArray(choices))
            return null;
        return choices;
    };
    QuestionMatrixDropdownRenderedTable.prototype.setHeaderCellCssClasses = function (cell, cellType) {
        cell.className = new CssClassBuilder()
            .append(this.cssClasses.headerCell)
            .append(this.cssClasses.columnTitleCell, this.matrix.isColumnLayoutHorizontal)
            .append(this.cssClasses.emptyCell, !!cell.isEmpty)
            .append(this.cssClasses.cell + "--" + cellType, !!cellType)
            .toString();
    };
    QuestionMatrixDropdownRenderedTable.prototype.createHeaderCell = function (column, cellType) {
        if (cellType === void 0) { cellType = null; }
        var cell = !!column ? this.createTextCell(column.locTitle) : this.createEmptyCell();
        cell.column = column;
        this.setHeaderCell(column, cell);
        if (!cellType)
            cellType = (!!column && column.cellType !== "default") ? column.cellType : this.matrix.cellType;
        this.setHeaderCellCssClasses(cell, cellType);
        return cell;
    };
    QuestionMatrixDropdownRenderedTable.prototype.setHeaderCell = function (column, cell) {
        this.setHeaderCellWidth(column, cell);
    };
    QuestionMatrixDropdownRenderedTable.prototype.setHeaderCellWidth = function (column, cell) {
        cell.minWidth = column != null ? this.matrix.getColumnWidth(column) : this.matrix.getRowTitleWidth();
        cell.width = column != null ? column.width : this.matrix.getRowTitleWidth();
    };
    QuestionMatrixDropdownRenderedTable.prototype.createTextCell = function (locTitle) {
        var cell = new question_matrixdropdownrendered_QuestionMatrixDropdownRenderedCell();
        cell.locTitle = locTitle;
        if (!!this.cssClasses.cell) {
            cell.className = this.cssClasses.cell;
        }
        return cell;
    };
    QuestionMatrixDropdownRenderedTable.prototype.createEmptyCell = function (isError) {
        if (isError === void 0) { isError = false; }
        var res = this.createTextCell(null);
        res.isEmpty = true;
        res.className = new CssClassBuilder()
            .append(this.cssClasses.cell)
            .append(this.cssClasses.emptyCell)
            .append(this.cssClasses.errorsCell, isError)
            .toString();
        return res;
    };
    question_matrixdropdownrendered_decorate([
        propertyArray({
            onPush: function (_, i, target) {
                target.updateRenderedRows();
            },
            onRemove: function (_, i, target) {
                target.updateRenderedRows();
            }
        })
    ], QuestionMatrixDropdownRenderedTable.prototype, "rows", void 0);
    question_matrixdropdownrendered_decorate([
        propertyArray()
    ], QuestionMatrixDropdownRenderedTable.prototype, "_renderedRows", void 0);
    return QuestionMatrixDropdownRenderedTable;
}(base_Base));


// CONCATENATED MODULE: ./packages/survey-core/src/question_matrixdropdownbase.ts
var question_matrixdropdownbase_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();















var question_matrixdropdownbase_MatrixDropdownCell = /** @class */ (function () {
    function MatrixDropdownCell(column, row, data) {
        this.column = column;
        this.row = row;
        this.data = data;
        this.questionValue = this.createQuestion(column, row, data);
        this.questionValue.updateCustomWidget();
        this.updateCellQuestionTitleDueToAccessebility(row);
    }
    MatrixDropdownCell.prototype.updateCellQuestionTitleDueToAccessebility = function (row) {
        var _this = this;
        this.questionValue.locTitle.onGetTextCallback = function (str) {
            if (!row || !row.getSurvey())
                return _this.questionValue.title;
            var rowTitle = row.getAccessbilityText();
            if (!rowTitle)
                return _this.questionValue.title;
            return _this.column.colOwner.getCellAriaLabel(rowTitle, _this.questionValue.title);
        };
    };
    MatrixDropdownCell.prototype.locStrsChanged = function () {
        this.question.locStrsChanged();
    };
    MatrixDropdownCell.prototype.createQuestion = function (column, row, data) {
        var _this = this;
        var res = data.createQuestion(this.row, this.column);
        res.readOnlyCallback = function () { return !_this.row.isRowEnabled(); };
        res.validateValueCallback = function () {
            return data.validateCell(row, column.name, row.value);
        };
        CustomPropertiesCollection.getProperties(column.getType()).forEach(function (property) {
            var propertyName = property.name;
            if (column[propertyName] !== undefined) {
                res[propertyName] = column[propertyName];
            }
        });
        return res;
    };
    Object.defineProperty(MatrixDropdownCell.prototype, "question", {
        get: function () {
            return this.questionValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownCell.prototype, "value", {
        get: function () {
            return this.question.value;
        },
        set: function (value) {
            this.question.value = value;
        },
        enumerable: false,
        configurable: true
    });
    MatrixDropdownCell.prototype.getQuestionWrapperClassName = function (className) {
        return className;
    };
    MatrixDropdownCell.prototype.runCondition = function (values, properties) {
        this.question.runCondition(values, properties);
    };
    return MatrixDropdownCell;
}());

var question_matrixdropdownbase_MatrixDropdownTotalCell = /** @class */ (function (_super) {
    question_matrixdropdownbase_extends(MatrixDropdownTotalCell, _super);
    function MatrixDropdownTotalCell(column, row, data) {
        var _this = _super.call(this, column, row, data) || this;
        _this.column = column;
        _this.row = row;
        _this.data = data;
        _this.updateCellQuestion();
        return _this;
    }
    MatrixDropdownTotalCell.prototype.createQuestion = function (column, row, data) {
        var res = Serializer.createClass("expression");
        res.setSurveyImpl(row);
        return res;
    };
    MatrixDropdownTotalCell.prototype.locStrsChanged = function () {
        this.updateCellQuestion();
        _super.prototype.locStrsChanged.call(this);
    };
    MatrixDropdownTotalCell.prototype.updateCellQuestion = function () {
        this.question.locCalculation();
        this.column.updateCellQuestion(this.question, null, function (json) {
            delete json["defaultValue"];
        });
        this.question.expression = this.getTotalExpression();
        this.question.format = this.column.totalFormat;
        this.question.currency = this.column.totalCurrency;
        this.question.displayStyle = this.column.totalDisplayStyle;
        this.question.maximumFractionDigits = this.column.totalMaximumFractionDigits;
        this.question.minimumFractionDigits = this.column.totalMinimumFractionDigits;
        this.question.unlocCalculation();
        this.question.runIfReadOnly = true;
    };
    MatrixDropdownTotalCell.prototype.getQuestionWrapperClassName = function (className) {
        var result = _super.prototype.getQuestionWrapperClassName.call(this, className);
        if (!result) {
            return result;
        }
        if (this.question.expression && this.question.expression != "''") {
            result += " " + className + "--expression";
        }
        var alignment = this.column.totalAlignment;
        if (alignment === "auto") {
            if (this.column.cellType === "dropdown") {
                alignment = "left";
            }
        }
        return result + " " + className + "--" + alignment;
    };
    MatrixDropdownTotalCell.prototype.getTotalExpression = function () {
        if (!!this.column.totalExpression)
            return this.column.totalExpression;
        if (this.column.totalType == "none")
            return "''";
        var funName = this.column.totalType + "InArray";
        if (!functionsfactory_FunctionFactory.Instance.hasFunction(funName))
            return "";
        return funName + "({self}, '" + this.column.name + "')";
    };
    return MatrixDropdownTotalCell;
}(question_matrixdropdownbase_MatrixDropdownCell));

var MatrixDropdownRowTextProcessor = /** @class */ (function (_super) {
    question_matrixdropdownbase_extends(MatrixDropdownRowTextProcessor, _super);
    function MatrixDropdownRowTextProcessor(row, variableName, parentTextProcessor) {
        var _this = _super.call(this, variableName) || this;
        _this.row = row;
        _this.variableName = variableName;
        _this.parentTextProcessor = parentTextProcessor;
        return _this;
    }
    MatrixDropdownRowTextProcessor.prototype.getParentTextProcessor = function () { return this.parentTextProcessor; };
    Object.defineProperty(MatrixDropdownRowTextProcessor.prototype, "survey", {
        get: function () {
            return this.row.getSurvey();
        },
        enumerable: false,
        configurable: true
    });
    MatrixDropdownRowTextProcessor.prototype.getValues = function () {
        return this.row.value;
    };
    MatrixDropdownRowTextProcessor.prototype.getQuestionByName = function (name) {
        return this.row.getQuestionByName(name);
    };
    MatrixDropdownRowTextProcessor.prototype.onCustomProcessText = function (textValue) {
        if (textValue.name == question_matrixdropdownbase_MatrixDropdownRowModelBase.IndexVariableName) {
            textValue.isExists = true;
            textValue.value = this.row.rowIndex;
            return true;
        }
        if (textValue.name == question_matrixdropdownbase_MatrixDropdownRowModelBase.RowValueVariableName) {
            textValue.isExists = true;
            textValue.value = this.row.rowName;
            return true;
        }
        return false;
    };
    return MatrixDropdownRowTextProcessor;
}(textPreProcessor_QuestionTextProcessor));
var question_matrixdropdownbase_MatrixDropdownRowModelBase = /** @class */ (function () {
    function MatrixDropdownRowModelBase(data, value) {
        var _this = this;
        this.isSettingValue = false;
        this.detailPanelValue = null;
        this.cells = [];
        this.isCreatingDetailPanel = false;
        this.data = data;
        this.subscribeToChanges(value);
        this.textPreProcessor = new MatrixDropdownRowTextProcessor(this, MatrixDropdownRowModelBase.RowVariableName, !!data ? data.getParentTextProcessor() : null);
        this.showHideDetailPanelClick = function () {
            if (_this.getSurvey().isDesignMode)
                return true;
            _this.showHideDetailPanel();
        };
        this.idValue = MatrixDropdownRowModelBase.getId();
    }
    MatrixDropdownRowModelBase.getId = function () {
        return "srow_" + MatrixDropdownRowModelBase.idCounter++;
    };
    Object.defineProperty(MatrixDropdownRowModelBase.prototype, "id", {
        get: function () {
            return this.idValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownRowModelBase.prototype, "rowName", {
        get: function () {
            return null;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownRowModelBase.prototype, "dataName", {
        get: function () {
            return this.rowName;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownRowModelBase.prototype, "text", {
        get: function () {
            return this.rowName;
        },
        enumerable: false,
        configurable: true
    });
    MatrixDropdownRowModelBase.prototype.isRowEnabled = function () { return true; };
    MatrixDropdownRowModelBase.prototype.isRowHasEnabledCondition = function () { return false; };
    Object.defineProperty(MatrixDropdownRowModelBase.prototype, "value", {
        get: function () {
            var result = {};
            var questions = this.questions;
            for (var i = 0; i < questions.length; i++) {
                var question = questions[i];
                if (!question.isEmpty()) {
                    result[question.getValueName()] = question.value;
                }
                if (!!question.comment &&
                    !!this.getSurvey() &&
                    this.getSurvey().storeOthersAsComment) {
                    result[question.getValueName() + base_Base.commentSuffix] =
                        question.comment;
                }
            }
            return result;
        },
        set: function (value) {
            this.isSettingValue = true;
            this.subscribeToChanges(value);
            var questions = this.questions;
            for (var i = 0; i < questions.length; i++) {
                var question = questions[i];
                var val = this.getCellValue(value, question.getValueName());
                var oldComment = question.comment;
                var comment = !!value
                    ? value[question.getValueName() + base_Base.commentSuffix]
                    : "";
                if (comment == undefined)
                    comment = "";
                question.updateValueFromSurvey(val);
                if (!!comment || this.isTwoValueEquals(oldComment, question.comment)) {
                    question.updateCommentFromSurvey(comment);
                }
                question.onSurveyValueChanged(val);
            }
            this.isSettingValue = false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownRowModelBase.prototype, "locText", {
        get: function () {
            return null;
        },
        enumerable: false,
        configurable: true
    });
    MatrixDropdownRowModelBase.prototype.getAccessbilityText = function () {
        return this.locText && this.locText.renderedHtml;
    };
    Object.defineProperty(MatrixDropdownRowModelBase.prototype, "hasPanel", {
        get: function () {
            if (!this.data)
                return false;
            return this.data.hasDetailPanel(this);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownRowModelBase.prototype, "detailPanel", {
        get: function () {
            return this.detailPanelValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownRowModelBase.prototype, "detailPanelId", {
        get: function () {
            return !!this.detailPanel ? this.detailPanel.id : "";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownRowModelBase.prototype, "isDetailPanelShowing", {
        get: function () {
            return !!this.data ? this.data.getIsDetailPanelShowing(this) : false;
        },
        enumerable: false,
        configurable: true
    });
    MatrixDropdownRowModelBase.prototype.setIsDetailPanelShowing = function (val) {
        if (!val && this.detailPanel) {
            this.detailPanel.onHidingContent();
        }
        if (!!this.data) {
            this.data.setIsDetailPanelShowing(this, val);
        }
        if (!!this.onDetailPanelShowingChanged) {
            this.onDetailPanelShowingChanged();
        }
    };
    MatrixDropdownRowModelBase.prototype.showHideDetailPanel = function () {
        if (this.isDetailPanelShowing) {
            this.hideDetailPanel();
        }
        else {
            this.showDetailPanel();
        }
    };
    MatrixDropdownRowModelBase.prototype.showDetailPanel = function () {
        this.ensureDetailPanel();
        if (!this.detailPanelValue)
            return;
        this.setIsDetailPanelShowing(true);
    };
    MatrixDropdownRowModelBase.prototype.hideDetailPanel = function (destroyPanel) {
        if (destroyPanel === void 0) { destroyPanel = false; }
        this.setIsDetailPanelShowing(false);
        if (destroyPanel) {
            this.detailPanelValue = null;
        }
    };
    MatrixDropdownRowModelBase.prototype.ensureDetailPanel = function () {
        if (this.isCreatingDetailPanel)
            return;
        if (!!this.detailPanelValue || !this.hasPanel || !this.data)
            return;
        this.isCreatingDetailPanel = true;
        this.detailPanelValue = this.data.createRowDetailPanel(this);
        var questions = this.detailPanelValue.questions;
        var value = this.data.getRowValue(this.data.getRowIndex(this));
        if (!helpers_Helpers.isValueEmpty(value)) {
            for (var i = 0; i < questions.length; i++) {
                var key = questions[i].getValueName();
                var val = !!this.editingObj ? Serializer.getObjPropertyValue(this.editingObj, key) : value[key];
                if (!helpers_Helpers.isValueEmpty(val)) {
                    questions[i].value = val;
                }
            }
        }
        this.detailPanelValue.setSurveyImpl(this);
        this.isCreatingDetailPanel = false;
    };
    MatrixDropdownRowModelBase.prototype.getAllValues = function () {
        return this.value;
    };
    MatrixDropdownRowModelBase.prototype.getFilteredValues = function () {
        var res = this.data ? this.data.getDataFilteredValues() : {};
        var values = this.validationValues;
        if (values) {
            for (var key in values) {
                res[key] = values[key];
            }
        }
        res.row = this.getAllValues();
        this.applyRowVariablesToValues(res, this.rowIndex);
        return res;
    };
    MatrixDropdownRowModelBase.prototype.getFilteredProperties = function () {
        return { survey: this.getSurvey(), row: this };
    };
    MatrixDropdownRowModelBase.prototype.applyRowVariablesToValues = function (res, rowIndex) {
        res[MatrixDropdownRowModelBase.IndexVariableName] = rowIndex;
        res[MatrixDropdownRowModelBase.RowValueVariableName] = this.rowName;
    };
    MatrixDropdownRowModelBase.prototype.runCondition = function (values, properties) {
        if (!!this.data) {
            values[MatrixDropdownRowModelBase.OwnerVariableName] = this.data.value;
        }
        var rowIndex = this.rowIndex;
        this.applyRowVariablesToValues(values, rowIndex);
        var newProps = helpers_Helpers.createCopy(properties);
        newProps[MatrixDropdownRowModelBase.RowVariableName] = this;
        var rowValues = rowIndex > 0 ? this.data.getRowValue(this.rowIndex - 1) : this.value;
        for (var i = 0; i < this.cells.length; i++) {
            if (i > 0) {
                mergeValues(this.value, rowValues);
            }
            values[MatrixDropdownRowModelBase.RowVariableName] = rowValues;
            this.cells[i].runCondition(values, newProps);
        }
        if (!!this.detailPanel) {
            this.detailPanel.runCondition(values, newProps);
        }
        if (this.isRowHasEnabledCondition()) {
            this.onQuestionReadOnlyChanged();
        }
    };
    MatrixDropdownRowModelBase.prototype.getNamesWithDefaultValues = function () {
        var res = [];
        this.questions.forEach(function (q) {
            if (q.isValueDefault) {
                res.push(q.getValueName());
            }
        });
        return res;
    };
    MatrixDropdownRowModelBase.prototype.clearValue = function (keepComment) {
        var questions = this.questions;
        for (var i = 0; i < questions.length; i++) {
            questions[i].clearValue(keepComment);
        }
    };
    MatrixDropdownRowModelBase.prototype.onAnyValueChanged = function (name, questionName) {
        var questions = this.questions;
        for (var i = 0; i < questions.length; i++) {
            questions[i].onAnyValueChanged(name, questionName);
        }
    };
    MatrixDropdownRowModelBase.prototype.getDataValueCore = function (valuesHash, key) {
        var survey = this.getSurvey();
        if (!!survey) {
            return survey.getDataValueCore(valuesHash, key);
        }
        else {
            return valuesHash[key];
        }
    };
    MatrixDropdownRowModelBase.prototype.getValue = function (name) {
        var question = this.getQuestionByName(name);
        return !!question ? question.value : null;
    };
    MatrixDropdownRowModelBase.prototype.setValue = function (name, newColumnValue) {
        this.setValueCore(name, newColumnValue, false);
    };
    MatrixDropdownRowModelBase.prototype.getVariable = function (name) {
        return undefined;
    };
    MatrixDropdownRowModelBase.prototype.setVariable = function (name, newValue) { };
    MatrixDropdownRowModelBase.prototype.getComment = function (name) {
        var question = this.getQuestionByName(name);
        return !!question ? question.comment : "";
    };
    MatrixDropdownRowModelBase.prototype.setComment = function (name, newValue, locNotification) {
        this.setValueCore(name, newValue, true);
    };
    MatrixDropdownRowModelBase.prototype.findQuestionByName = function (name) {
        if (!name)
            return undefined;
        var prefix = MatrixDropdownRowModelBase.RowVariableName + ".";
        if (name.indexOf(prefix) === 0) {
            return this.getQuestionByName(name.substring(prefix.length));
        }
        var survey = this.getSurvey();
        return !!survey ? survey.getQuestionByName(name) : null;
    };
    MatrixDropdownRowModelBase.prototype.getEditingSurveyElement = function () { return undefined; };
    MatrixDropdownRowModelBase.prototype.setValueCore = function (name, newColumnValue, isComment) {
        if (this.isSettingValue)
            return;
        this.updateQuestionsValue(name, newColumnValue, isComment);
        if (!isComment) {
            this.updateSharedQuestionsValue(name, newColumnValue);
        }
        var newValue = this.value;
        var changedName = isComment ? name + base_Base.commentSuffix : name;
        var changedValue = newColumnValue;
        var changedQuestion = this.getQuestionByName(name);
        var changingValue = this.data.onRowChanging(this, changedName, newValue);
        if (!!changedQuestion &&
            !this.isTwoValueEquals(changingValue, changedValue)) {
            this.isSettingValue = true;
            if (isComment) {
                changedQuestion.comment = changingValue;
            }
            else {
                changedQuestion.value = changingValue;
            }
            this.isSettingValue = false;
            newValue = this.value;
        }
        if (this.data.isValidateOnValueChanging && this.hasQuestonError(changedQuestion))
            return;
        var isDeleting = newColumnValue == null && !changedQuestion ||
            isComment && !newColumnValue && !!changedQuestion;
        this.data.onRowChanged(this, changedName, newValue, isDeleting);
        if (changedName) {
            this.runTriggers(question_matrixdropdownbase_MatrixDropdownTotalRowModel.RowVariableName + "." + changedName, newValue);
        }
        this.onAnyValueChanged(MatrixDropdownRowModelBase.RowVariableName, "");
    };
    MatrixDropdownRowModelBase.prototype.updateQuestionsValue = function (name, newColumnValue, isComment) {
        if (!this.detailPanel)
            return;
        var colQuestion = this.getQuestionByColumnName(name);
        var detailQuestion = this.detailPanel.getQuestionByName(name);
        if (!colQuestion || !detailQuestion)
            return;
        var isColQuestion = this.isTwoValueEquals(newColumnValue, isComment ? colQuestion.comment : colQuestion.value);
        var question = isColQuestion ? detailQuestion : colQuestion;
        this.isSettingValue = true;
        if (!isComment) {
            question.value = newColumnValue;
        }
        else {
            question.comment = newColumnValue;
        }
        this.isSettingValue = false;
    };
    MatrixDropdownRowModelBase.prototype.updateSharedQuestionsValue = function (name, value) {
        var questions = this.getQuestionsByValueName(name);
        if (questions.length > 1) {
            for (var i = 0; i < questions.length; i++) {
                if (!helpers_Helpers.isTwoValueEquals(questions[i].value, value)) {
                    this.isSettingValue = true;
                    questions[i].updateValueFromSurvey(value);
                    this.isSettingValue = false;
                }
            }
        }
    };
    MatrixDropdownRowModelBase.prototype.runTriggers = function (name, value) {
        if (!name)
            return;
        this.questions.forEach(function (q) { return q.runTriggers(name, value); });
    };
    MatrixDropdownRowModelBase.prototype.hasQuestonError = function (question) {
        if (!question)
            return false;
        if (question.hasErrors(true, {
            isOnValueChanged: !this.data.isValidateOnValueChanging,
        }))
            return true;
        if (question.isEmpty())
            return false;
        var cell = this.getCellByColumnName(question.name);
        if (!cell || !cell.column || !cell.column.isUnique)
            return false;
        return this.data.checkIfValueInRowDuplicated(this, question);
    };
    Object.defineProperty(MatrixDropdownRowModelBase.prototype, "isEmpty", {
        get: function () {
            var val = this.value;
            if (helpers_Helpers.isValueEmpty(val))
                return true;
            for (var key in val) {
                if (val[key] !== undefined && val[key] !== null)
                    return false;
            }
            return true;
        },
        enumerable: false,
        configurable: true
    });
    MatrixDropdownRowModelBase.prototype.getQuestionByColumn = function (column) {
        var cell = this.getCellByColumn(column);
        return !!cell ? cell.question : null;
    };
    MatrixDropdownRowModelBase.prototype.getCellByColumn = function (column) {
        for (var i = 0; i < this.cells.length; i++) {
            if (this.cells[i].column == column)
                return this.cells[i];
        }
        return null;
    };
    MatrixDropdownRowModelBase.prototype.getCellByColumnName = function (columnName) {
        for (var i = 0; i < this.cells.length; i++) {
            if (this.cells[i].column.name == columnName)
                return this.cells[i];
        }
        return null;
    };
    MatrixDropdownRowModelBase.prototype.getQuestionByColumnName = function (columnName) {
        var cell = this.getCellByColumnName(columnName);
        return !!cell ? cell.question : null;
    };
    Object.defineProperty(MatrixDropdownRowModelBase.prototype, "questions", {
        get: function () {
            var res = [];
            for (var i = 0; i < this.cells.length; i++) {
                res.push(this.cells[i].question);
            }
            var detailQuestions = !!this.detailPanel ? this.detailPanel.questions : [];
            for (var i = 0; i < detailQuestions.length; i++) {
                res.push(detailQuestions[i]);
            }
            return res;
        },
        enumerable: false,
        configurable: true
    });
    MatrixDropdownRowModelBase.prototype.getQuestionByName = function (name) {
        var res = this.getQuestionByColumnName(name);
        if (!!res)
            return res;
        return !!this.detailPanel ? this.detailPanel.getQuestionByName(name) : null;
    };
    MatrixDropdownRowModelBase.prototype.getQuestionsByName = function (name) {
        var res = [];
        var q = this.getQuestionByColumnName(name);
        if (!!q)
            res.push(q);
        if (!!this.detailPanel) {
            q = this.detailPanel.getQuestionByName(name);
            if (!!q)
                res.push(q);
        }
        return res;
    };
    MatrixDropdownRowModelBase.prototype.getQuestionsByValueName = function (name) {
        var res = [];
        for (var i = 0; i < this.cells.length; i++) {
            var cell = this.cells[i];
            if (cell.question && cell.question.getValueName() === name) {
                res.push(cell.question);
            }
        }
        if (!!this.detailPanel) {
            res = res.concat(this.detailPanel.getQuestionsByValueName(name));
        }
        return res;
    };
    MatrixDropdownRowModelBase.prototype.getSharedQuestionByName = function (columnName) {
        return !!this.data
            ? this.data.getSharedQuestionByName(columnName, this)
            : null;
    };
    MatrixDropdownRowModelBase.prototype.clearIncorrectValues = function (val) {
        for (var key in val) {
            var question = this.getQuestionByName(key);
            if (question) {
                var qVal = question.value;
                question.clearIncorrectValues();
                if (!this.isTwoValueEquals(qVal, question.value)) {
                    this.setValue(key, question.value);
                }
            }
            else {
                if (!this.getSharedQuestionByName(key) &&
                    key.indexOf(settings.matrix.totalsSuffix) < 0) {
                    this.setValue(key, null);
                }
            }
        }
    };
    MatrixDropdownRowModelBase.prototype.getLocale = function () {
        return this.data ? this.data.getLocale() : "";
    };
    MatrixDropdownRowModelBase.prototype.getMarkdownHtml = function (text, name) {
        return this.data ? this.data.getMarkdownHtml(text, name) : undefined;
    };
    MatrixDropdownRowModelBase.prototype.getRenderer = function (name) {
        return this.data ? this.data.getRenderer(name) : null;
    };
    MatrixDropdownRowModelBase.prototype.getRendererContext = function (locStr) {
        return this.data ? this.data.getRendererContext(locStr) : locStr;
    };
    MatrixDropdownRowModelBase.prototype.getProcessedText = function (text) {
        return this.data ? this.data.getProcessedText(text) : text;
    };
    MatrixDropdownRowModelBase.prototype.locStrsChanged = function () {
        for (var i = 0; i < this.cells.length; i++) {
            this.cells[i].locStrsChanged();
        }
        if (!!this.detailPanel) {
            this.detailPanel.locStrsChanged();
        }
    };
    MatrixDropdownRowModelBase.prototype.updateCellQuestionOnColumnChanged = function (column, name, newValue) {
        var cell = this.getCellByColumn(column);
        if (!cell)
            return;
        this.updateCellOnColumnChanged(cell, name, newValue);
    };
    MatrixDropdownRowModelBase.prototype.updateCellQuestionOnColumnItemValueChanged = function (column, propertyName, obj, name, newValue, oldValue) {
        var cell = this.getCellByColumn(column);
        if (!cell)
            return;
        this.updateCellOnColumnItemValueChanged(cell, propertyName, obj, name, newValue, oldValue);
    };
    MatrixDropdownRowModelBase.prototype.onQuestionReadOnlyChanged = function () {
        var questions = this.questions;
        for (var i = 0; i < questions.length; i++) {
            var q = questions[i];
            q.setPropertyValue("isReadOnly", q.isReadOnly);
        }
        if (!!this.detailPanel) {
            var parentIsReadOnly = !!this.data && this.data.isMatrixReadOnly();
            this.detailPanel.readOnly = parentIsReadOnly || !this.isRowEnabled();
        }
    };
    MatrixDropdownRowModelBase.prototype.hasErrors = function (fireCallback, rec, raiseOnCompletedAsyncValidators) {
        var res = false;
        var cells = this.cells;
        if (!cells)
            return res;
        this.validationValues = rec.validationValues;
        for (var colIndex = 0; colIndex < cells.length; colIndex++) {
            if (!cells[colIndex])
                continue;
            var question = cells[colIndex].question;
            if (!question || !question.visible)
                continue;
            question.onCompletedAsyncValidators = function (hasErrors) {
                raiseOnCompletedAsyncValidators();
            };
            if (!!rec && rec.isOnValueChanged === true && question.isEmpty())
                continue;
            res = question.hasErrors(fireCallback, rec) || res;
        }
        if (this.hasPanel) {
            this.ensureDetailPanel();
            var panelHasError = this.detailPanel.hasErrors(fireCallback, false, rec);
            if (!rec.hideErroredPanel && panelHasError && fireCallback) {
                if (rec.isSingleDetailPanel) {
                    rec.hideErroredPanel = true;
                }
                this.showDetailPanel();
            }
            res = panelHasError || res;
        }
        this.validationValues = undefined;
        return res;
    };
    MatrixDropdownRowModelBase.prototype.updateCellOnColumnChanged = function (cell, name, newValue) {
        if (name === "choices" && Array.isArray(newValue) && newValue.length === 0 && this.data) {
            newValue = this.data.choices;
        }
        cell.question[name] = newValue;
    };
    MatrixDropdownRowModelBase.prototype.updateCellOnColumnItemValueChanged = function (cell, propertyName, obj, name, newValue, oldValue) {
        var items = cell.question[propertyName];
        if (!Array.isArray(items))
            return;
        var val = name === "value" ? oldValue : obj["value"];
        var item = itemvalue_ItemValue.getItemByValue(items, val);
        if (!item)
            return;
        item[name] = newValue;
    };
    MatrixDropdownRowModelBase.prototype.buildCells = function (value) {
        this.isSettingValue = true;
        var columns = this.data.columns;
        for (var i = 0; i < columns.length; i++) {
            var column = columns[i];
            var cell = this.createCell(column);
            this.cells.push(cell);
            var cellValue = this.getCellValue(value, column.name);
            if (!helpers_Helpers.isValueEmpty(cellValue)) {
                cell.question.value = cellValue;
                var commentKey = column.name + base_Base.commentSuffix;
                if (!!value && !helpers_Helpers.isValueEmpty(value[commentKey])) {
                    cell.question.comment = value[commentKey];
                }
            }
        }
        this.isSettingValue = false;
    };
    MatrixDropdownRowModelBase.prototype.isTwoValueEquals = function (val1, val2) {
        return helpers_Helpers.isTwoValueEquals(val1, val2, false, true, false);
    };
    MatrixDropdownRowModelBase.prototype.getCellValue = function (value, name) {
        if (!!this.editingObj)
            return Serializer.getObjPropertyValue(this.editingObj, name);
        return !!value ? value[name] : undefined;
    };
    MatrixDropdownRowModelBase.prototype.createCell = function (column) {
        return new question_matrixdropdownbase_MatrixDropdownCell(column, this, this.data);
    };
    MatrixDropdownRowModelBase.prototype.getSurveyData = function () {
        return this;
    };
    MatrixDropdownRowModelBase.prototype.getSurvey = function () {
        return this.data ? this.data.getSurvey() : null;
    };
    MatrixDropdownRowModelBase.prototype.getTextProcessor = function () {
        return this.textPreProcessor;
    };
    Object.defineProperty(MatrixDropdownRowModelBase.prototype, "rowIndex", {
        get: function () {
            return !!this.data ? this.data.getRowIndex(this) + 1 : -1;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownRowModelBase.prototype, "editingObj", {
        get: function () {
            return this.editingObjValue;
        },
        enumerable: false,
        configurable: true
    });
    MatrixDropdownRowModelBase.prototype.dispose = function () {
        if (!!this.editingObj) {
            this.editingObj.onPropertyChanged.remove(this.onEditingObjPropertyChanged);
            this.editingObjValue = null;
        }
    };
    MatrixDropdownRowModelBase.prototype.subscribeToChanges = function (value) {
        var _this = this;
        if (!value || !value.getType || !value.onPropertyChanged)
            return;
        if (value === this.editingObj)
            return;
        this.editingObjValue = value;
        this.onEditingObjPropertyChanged = function (sender, options) {
            _this.updateOnSetValue(options.name, options.newValue);
        };
        this.editingObj.onPropertyChanged.add(this.onEditingObjPropertyChanged);
    };
    MatrixDropdownRowModelBase.prototype.updateOnSetValue = function (name, newValue) {
        this.isSettingValue = true;
        var questions = this.getQuestionsByName(name);
        for (var i = 0; i < questions.length; i++) {
            questions[i].value = newValue;
        }
        this.isSettingValue = false;
    };
    MatrixDropdownRowModelBase.RowVariableName = "row";
    MatrixDropdownRowModelBase.OwnerVariableName = "self";
    MatrixDropdownRowModelBase.IndexVariableName = "rowIndex";
    MatrixDropdownRowModelBase.RowValueVariableName = "rowValue";
    MatrixDropdownRowModelBase.idCounter = 1;
    return MatrixDropdownRowModelBase;
}());

var question_matrixdropdownbase_MatrixDropdownTotalRowModel = /** @class */ (function (_super) {
    question_matrixdropdownbase_extends(MatrixDropdownTotalRowModel, _super);
    function MatrixDropdownTotalRowModel(data) {
        var _this = _super.call(this, data, null) || this;
        _this.buildCells(null);
        return _this;
    }
    MatrixDropdownTotalRowModel.prototype.createCell = function (column) {
        return new question_matrixdropdownbase_MatrixDropdownTotalCell(column, this, this.data);
    };
    MatrixDropdownTotalRowModel.prototype.setValue = function (name, newValue) {
        if (!!this.data && !this.isSettingValue) {
            this.data.onTotalValueChanged();
        }
    };
    MatrixDropdownTotalRowModel.prototype.runCondition = function (values, properties) {
        var counter = 0;
        var prevValue;
        do {
            prevValue = helpers_Helpers.getUnbindValue(this.value);
            _super.prototype.runCondition.call(this, values, properties);
            counter++;
        } while (!helpers_Helpers.isTwoValueEquals(prevValue, this.value) && counter < 3);
    };
    MatrixDropdownTotalRowModel.prototype.updateCellOnColumnChanged = function (cell, name, newValue) {
        cell.updateCellQuestion();
    };
    return MatrixDropdownTotalRowModel;
}(question_matrixdropdownbase_MatrixDropdownRowModelBase));

/**
 * A base class for the [QuestionMatrixDropdownModel](https://surveyjs.io/form-library/documentation/questionmatrixdropdownmodel) and [QuestionMatrixDynamicModel](https://surveyjs.io/form-library/documentation/questionmatrixdynamicmodel) classes.
 */
var question_matrixdropdownbase_QuestionMatrixDropdownModelBase = /** @class */ (function (_super) {
    question_matrixdropdownbase_extends(QuestionMatrixDropdownModelBase, _super);
    function QuestionMatrixDropdownModelBase(name) {
        var _this = _super.call(this, name) || this;
        _this.isRowChanging = false;
        _this.lockResetRenderedTable = false;
        _this.isDoingonAnyValueChanged = false;
        _this.createItemValues("choices");
        _this.createLocalizableString("placeholder", _this, false, true);
        _this.createLocalizableString("keyDuplicationError", _this, false, true);
        _this.detailPanelValue = _this.createNewDetailPanel();
        _this.detailPanel.selectedElementInDesign = _this;
        _this.detailPanel.renderWidth = "100%";
        _this.detailPanel.isInteractiveDesignElement = false;
        _this.detailPanel.showTitle = false;
        _this.registerPropertyChangedHandlers(["columns", "cellType"], function () { _this.updateColumnsAndRows(); });
        _this.registerPropertyChangedHandlers(["placeholder", "columnColCount", "rowTitleWidth", "choices"], function () {
            _this.clearRowsAndResetRenderedTable();
        });
        _this.registerPropertyChangedHandlers([
            "transposeData",
            "addRowLocation",
            "hideColumnsIfEmpty",
            "showHeader",
            "minRowCount",
            "isReadOnly",
            "rowCount",
            "hasFooter",
            "detailPanelMode",
        ], function () {
            _this.resetRenderedTable();
        });
        _this.registerPropertyChangedHandlers(["isMobile"], function () {
            _this.resetRenderedTable();
        });
        return _this;
    }
    Object.defineProperty(QuestionMatrixDropdownModelBase, "defaultCellType", {
        get: function () {
            return settings.matrix.defaultCellType;
        },
        set: function (val) {
            settings.matrix.defaultCellType = val;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.addDefaultColumns = function (matrix) {
        var colNames = questionfactory_QuestionFactory.DefaultColums;
        for (var i = 0; i < colNames.length; i++)
            matrix.addColumn(colNames[i]);
    };
    QuestionMatrixDropdownModelBase.prototype.createColumnValues = function () {
        var _this = this;
        return this.createNewArray("columns", function (item) {
            item.colOwner = _this;
            if (_this.onAddColumn)
                _this.onAddColumn(item);
            if (_this.survey) {
                _this.survey.matrixColumnAdded(_this, item);
            }
        }, function (item) {
            item.colOwner = null;
            if (_this.onRemoveColumn)
                _this.onRemoveColumn(item);
        });
    };
    QuestionMatrixDropdownModelBase.prototype.getType = function () {
        return "matrixdropdownbase";
    };
    QuestionMatrixDropdownModelBase.prototype.dispose = function () {
        _super.prototype.dispose.call(this);
        this.clearGeneratedRows();
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "hasSingleInput", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "isContainer", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "isRowsDynamic", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "isUpdateLocked", {
        get: function () {
            return this.isLoadingFromJson || this.isUpdating;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.beginUpdate = function () {
        this.isUpdating = true;
    };
    QuestionMatrixDropdownModelBase.prototype.endUpdate = function () {
        this.isUpdating = false;
        this.updateColumnsAndRows();
    };
    QuestionMatrixDropdownModelBase.prototype.updateColumnsAndRows = function () {
        this.updateColumnsIndexes(this.columns);
        this.updateColumnsCellType();
        this.generatedTotalRow = null;
        this.clearRowsAndResetRenderedTable();
    };
    QuestionMatrixDropdownModelBase.prototype.itemValuePropertyChanged = function (item, name, oldValue, newValue) {
        _super.prototype.itemValuePropertyChanged.call(this, item, name, oldValue, newValue);
        if (item.ownerPropertyName === "choices") {
            this.clearRowsAndResetRenderedTable();
        }
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "transposeData", {
        /**
         * Specifies whether to display [`columns`](#columns) as rows and [`rows`](#rows) as columns.
         *
         * Default value: `false`
         *
         * [View Demo](https://surveyjs.io/form-library/examples/transpose-dynamic-rows-to-columns-in-matrix/ (linkStyle))
         */
        get: function () {
            return this.getPropertyValue("transposeData");
        },
        set: function (val) {
            this.setPropertyValue("transposeData", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "columnLayout", {
        /**
         * This property is obsolete. Use the [`transposeData`](#transposeData) property instead.
         */
        get: function () {
            return this.transposeData ? "vertical" : "horizontal";
        },
        set: function (val) {
            this.transposeData = val === "vertical";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "columnsLocation", {
        get: function () {
            return this.columnLayout;
        },
        set: function (val) {
            this.columnLayout = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "detailErrorLocation", {
        /**
         * Specifies the error message position for questions within detail sections.
         *
         * Possible values:
         *
         * - `"default"` (default) - Inherits the setting from the [`errorLocation`](#errorLocation) property.
         * - `"top"` - Displays error messages above questions.
         * - `"bottom"` - Displays error messages below questions.
         * @see cellErrorLocation
         */
        get: function () {
            return this.getPropertyValue("detailErrorLocation");
        },
        set: function (value) {
            this.setPropertyValue("detailErrorLocation", value.toLowerCase());
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "cellErrorLocation", {
        /**
         * Specifies the error message position relative to matrix cells.
         *
         * Possible values:
         *
         * - `"default"` (default) - Inherits the setting from the [`errorLocation`](#errorLocation) property.
         * - `"top"` - Displays error messages above matrix cells.
         * - `"bottom"` - Displays error messages below matrix cells.
         * @see detailErrorLocation
         */
        get: function () {
            return this.getPropertyValue("cellErrorLocation");
        },
        set: function (value) {
            this.setPropertyValue("cellErrorLocation", value.toLowerCase());
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.getChildErrorLocation = function (child) {
        var errLocation = !!child.parent ? this.detailErrorLocation : this.cellErrorLocation;
        if (errLocation !== "default")
            return errLocation;
        return _super.prototype.getChildErrorLocation.call(this, child);
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "isColumnLayoutHorizontal", {
        /**
         * Returns `true` if [`columns`](#columns) are placed in the horizontal direction and [`rows`](#columns) in the vertical direction.
         *
         * To specify the layout, use the [`transposeData`](#transposeData) property. If you set it to `true`, the survey applies it only when the screen has enough space. Otherwise, the survey falls back to the original layout, but the `transposeData` property remains set to `true`. Unlike `transposeData`, the `isColumnLayoutHorizontal` property always indicates the current layout.
         * @see transposeData
         */
        get: function () {
            return this.isMobile ? true : !this.transposeData;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "isUniqueCaseSensitive", {
        /**
         * Enables case-sensitive comparison in columns with the `isUnique` property set to `true`.
         *
         * When this property is `true`, `"ABC"` and `"abc"` are considered different values.
         *
         * Default value: `false`
         * @see keyDuplicationError
         */
        get: function () {
            return this.isUniqueCaseSensitiveValue !== undefined ? this.isUniqueCaseSensitiveValue : settings.comparator.caseSensitive;
        },
        set: function (val) {
            this.isUniqueCaseSensitiveValue = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "detailPanelMode", {
        /**
         * Specifies the location of detail sections.
         *
         * Possible values:
         *
         * - `"underRow"` - Displays detail sections under their respective rows. Users can expand any number of detail sections.
         * - `"underRowSingle"` - Displays detail sections under their respective rows, but only one detail section can be expanded at a time.
         * - `"none"` (default) - Hides detail sections.
         *
         * Use the `detailElements` property to specify content of detail sections.
         * @see detailElements
         * @see detailPanel
         */
        get: function () {
            return this.getPropertyValue("detailPanelMode");
        },
        set: function (val) {
            this.setPropertyValue("detailPanelMode", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "detailPanel", {
        /**
         * Contains a [`PanelModel`](https://surveyjs.io/form-library/documentation/panelmodel) instance that represents a detail section template.
         * @see detailElements
         * @see detailPanelMode
         */
        get: function () {
            return this.detailPanelValue;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.getPanel = function () {
        return this.detailPanel;
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "detailElements", {
        /**
         * An array of survey elements (questions and panels) to be displayed in detail sections.
         *
         * Detail sections are expandable panels displayed under each matrix row. You can use them to display questions that do not fit into the row.
         *
         * Set the `detailPanelMode` property to `"underRow"` or `"underRowSingle"` to display detail sections.
         * @see detailPanelMode
         * @see detailPanel
         */
        get: function () {
            return this.detailPanel.elements;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.createNewDetailPanel = function () {
        return Serializer.createClass("panel");
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "hasRowText", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.getFooterText = function () {
        return null;
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "canAddRow", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "canRemoveRows", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.canRemoveRow = function (row) {
        return true;
    };
    QuestionMatrixDropdownModelBase.prototype.onPointerDown = function (pointerDownEvent, row) { };
    QuestionMatrixDropdownModelBase.prototype.onRowsChanged = function () {
        this.resetRenderedTable();
        _super.prototype.onRowsChanged.call(this);
    };
    QuestionMatrixDropdownModelBase.prototype.onStartRowAddingRemoving = function () {
        this.lockResetRenderedTable = true;
        this.setValueChangedDirectly(true);
    };
    QuestionMatrixDropdownModelBase.prototype.onEndRowAdding = function () {
        this.lockResetRenderedTable = false;
        if (!this.renderedTable)
            return;
        if (this.renderedTable.isRequireReset()) {
            this.resetRenderedTable();
        }
        else {
            var index = this.visibleRows.length - 1;
            this.renderedTable.onAddedRow(this.visibleRows[index], index);
        }
    };
    QuestionMatrixDropdownModelBase.prototype.onEndRowRemoving = function (row) {
        this.lockResetRenderedTable = false;
        if (this.renderedTable.isRequireReset()) {
            this.resetRenderedTable();
        }
        else {
            if (!!row) {
                this.renderedTable.onRemovedRow(row);
            }
        }
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "renderedTableValue", {
        get: function () {
            return this.getPropertyValue("renderedTable", null);
        },
        set: function (val) {
            this.setPropertyValue("renderedTable", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.clearRowsAndResetRenderedTable = function () {
        this.clearGeneratedRows();
        this.resetRenderedTable();
        this.fireCallback(this.columnsChangedCallback);
    };
    //For internal use
    QuestionMatrixDropdownModelBase.prototype.resetRenderedTable = function () {
        if (this.lockResetRenderedTable || this.isUpdateLocked)
            return;
        this.renderedTableValue = null;
        this.fireCallback(this.onRenderedTableResetCallback);
    };
    QuestionMatrixDropdownModelBase.prototype.clearGeneratedRows = function () {
        if (!this.generatedVisibleRows)
            return;
        for (var i = 0; i < this.generatedVisibleRows.length; i++) {
            this.generatedVisibleRows[i].dispose();
        }
        _super.prototype.clearGeneratedRows.call(this);
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "isRendredTableCreated", {
        get: function () {
            return !!this.renderedTableValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "renderedTable", {
        get: function () {
            if (!this.renderedTableValue) {
                this.renderedTableValue = this.createRenderedTable();
                if (!!this.onRenderedTableCreatedCallback) {
                    this.onRenderedTableCreatedCallback(this.renderedTableValue);
                }
            }
            return this.renderedTableValue;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.createRenderedTable = function () {
        return new question_matrixdropdownrendered_QuestionMatrixDropdownRenderedTable(this);
    };
    QuestionMatrixDropdownModelBase.prototype.onMatrixRowCreated = function (row) {
        if (!this.survey)
            return;
        var options = {
            rowValue: row.value,
            row: row,
            column: null,
            columnName: null,
            cell: null,
            cellQuestion: null,
            value: null,
        };
        for (var i = 0; i < this.visibleColumns.length; i++) {
            options.column = this.visibleColumns[i];
            options.columnName = options.column.name;
            var cell = row.cells[i];
            options.cell = cell;
            options.cellQuestion = cell.question;
            options.value = cell.value;
            if (!!this.onCellCreatedCallback) {
                this.onCellCreatedCallback(options);
            }
            this.survey.matrixCellCreated(this, options);
        }
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "cellType", {
        /**
         * Specifies the type of matrix cells. You can override this property for individual columns.
         *
         * Possible values:
         *
         * - [`"dropdown"`](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model)
         * - [`"checkbox"`](https://surveyjs.io/form-library/documentation/api-reference/checkbox-question-model)
         * - [`"radiogroup"`](https://surveyjs.io/form-library/documentation/api-reference/radio-button-question-model)
         * - [`"tagbox"`](https://surveyjs.io/form-library/documentation/api-reference/dropdown-tag-box-model)
         * - [`"text"`](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model)
         * - [`"comment"`](https://surveyjs.io/form-library/documentation/api-reference/comment-field-model)
         * - [`"boolean"`](https://surveyjs.io/form-library/documentation/api-reference/boolean-question-model)
         * - [`"expression"`](https://surveyjs.io/form-library/documentation/api-reference/expression-model)
         * - [`"rating"`](https://surveyjs.io/form-library/documentation/api-reference/rating-scale-question-model)
         *
         * Default value: `"dropdown"` (inherited from [`settings.matrix.defaultCellType`](https://surveyjs.io/form-library/documentation/settings#matrixDefaultCellType))
         */
        get: function () {
            return this.getPropertyValue("cellType", settings.matrix.defaultCellType);
        },
        set: function (val) {
            val = val.toLowerCase();
            this.setPropertyValue("cellType", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.isSelectCellType = function () {
        return Serializer.isDescendantOf(this.cellType, "selectbase");
    };
    QuestionMatrixDropdownModelBase.prototype.updateColumnsCellType = function () {
        for (var i = 0; i < this.columns.length; i++) {
            this.columns[i].defaultCellTypeChanged();
        }
    };
    QuestionMatrixDropdownModelBase.prototype.updateColumnsIndexes = function (cols) {
        for (var i = 0; i < cols.length; i++) {
            cols[i].setIndex(i);
        }
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "columnColCount", {
        /**
         * Specifies the number of columns in Radiogroup and Checkbox cells.
         *
         * Default value: 0 (the number of columns is selected automatically based on the available column width)
         * @see cellType
         */
        get: function () {
            return this.getPropertyValue("columnColCount");
        },
        set: function (value) {
            if (value < 0 || value > 4)
                return;
            this.setPropertyValue("columnColCount", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "horizontalScroll", {
        get: function () {
            return this.getPropertyValue("horizontalScroll");
        },
        set: function (val) {
            this.setPropertyValue("horizontalScroll", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "allowAdaptiveActions", {
        get: function () {
            return this.getPropertyValue("allowAdaptiveActions");
        },
        set: function (val) {
            this.setPropertyValue("allowAdaptiveActions", val);
            if (!!this.detailPanel) {
                this.detailPanel.allowAdaptiveActions = val;
            }
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.getRequiredText = function () {
        return this.survey ? this.survey.requiredText : "";
    };
    QuestionMatrixDropdownModelBase.prototype.hasChoices = function () {
        return this.choices.length > 0;
    };
    QuestionMatrixDropdownModelBase.prototype.onColumnPropertyChanged = function (column, name, newValue) {
        this.updateHasFooter();
        if (!this.generatedVisibleRows)
            return;
        for (var i = 0; i < this.generatedVisibleRows.length; i++) {
            this.generatedVisibleRows[i].updateCellQuestionOnColumnChanged(column, name, newValue);
        }
        if (!!this.generatedTotalRow) {
            this.generatedTotalRow.updateCellQuestionOnColumnChanged(column, name, newValue);
        }
        this.onColumnsChanged();
        if (name == "isRequired") {
            this.resetRenderedTable();
        }
    };
    QuestionMatrixDropdownModelBase.prototype.onColumnItemValuePropertyChanged = function (column, propertyName, obj, name, newValue, oldValue) {
        if (!this.generatedVisibleRows)
            return;
        for (var i = 0; i < this.generatedVisibleRows.length; i++) {
            this.generatedVisibleRows[i].updateCellQuestionOnColumnItemValueChanged(column, propertyName, obj, name, newValue, oldValue);
        }
    };
    QuestionMatrixDropdownModelBase.prototype.onShowInMultipleColumnsChanged = function (column) {
        this.resetTableAndRows();
    };
    QuestionMatrixDropdownModelBase.prototype.onColumnVisibilityChanged = function (column) {
        this.resetTableAndRows();
    };
    QuestionMatrixDropdownModelBase.prototype.onColumnCellTypeChanged = function (column) {
        this.resetTableAndRows();
    };
    QuestionMatrixDropdownModelBase.prototype.resetTableAndRows = function () {
        this.clearGeneratedRows();
        this.resetRenderedTable();
    };
    QuestionMatrixDropdownModelBase.prototype.getRowTitleWidth = function () {
        return "";
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "hasFooter", {
        get: function () {
            return this.getPropertyValue("hasFooter", false);
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.getAddRowLocation = function () {
        return "default";
    };
    QuestionMatrixDropdownModelBase.prototype.getShowColumnsIfEmpty = function () {
        return false;
    };
    QuestionMatrixDropdownModelBase.prototype.updateShowTableAndAddRow = function () {
        if (!!this.renderedTable) {
            this.renderedTable.updateShowTableAndAddRow();
        }
    };
    QuestionMatrixDropdownModelBase.prototype.updateHasFooter = function () {
        this.setPropertyValue("hasFooter", this.hasTotal);
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "hasTotal", {
        get: function () {
            for (var i = 0; i < this.columns.length; i++) {
                if (this.columns[i].hasTotal)
                    return true;
            }
            return false;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.getCellType = function () {
        return this.cellType;
    };
    QuestionMatrixDropdownModelBase.prototype.getCustomCellType = function (column, row, cellType) {
        if (!this.survey)
            return cellType;
        var options = {
            rowValue: row.value,
            row: row,
            column: column,
            columnName: column.name,
            cellType: cellType
        };
        this.survey.matrixCellCreating(this, options);
        return options.cellType;
    };
    QuestionMatrixDropdownModelBase.prototype.getConditionJson = function (operator, path) {
        if (operator === void 0) { operator = null; }
        if (path === void 0) { path = null; }
        if (!path)
            return _super.prototype.getConditionJson.call(this, operator);
        var columnName = "";
        for (var i = path.length - 1; i >= 0; i--) {
            if (path[i] == ".")
                break;
            columnName = path[i] + columnName;
        }
        var question = undefined;
        var column = this.getColumnByName(columnName);
        if (!!column) {
            question = column.createCellQuestion(null);
        }
        else {
            if (this.detailPanelMode !== "none") {
                question = this.detailPanel.getQuestionByName(columnName);
            }
        }
        return !!question ? question.getConditionJson(operator) : null;
    };
    QuestionMatrixDropdownModelBase.prototype.clearIncorrectValues = function () {
        var rows = this.visibleRows;
        if (!rows)
            return;
        for (var i = 0; i < rows.length; i++) {
            rows[i].clearIncorrectValues(this.getRowValue(i));
        }
    };
    QuestionMatrixDropdownModelBase.prototype.clearErrors = function () {
        _super.prototype.clearErrors.call(this);
        this.runFuncForCellQuestions(function (q) { q.clearErrors(); });
    };
    QuestionMatrixDropdownModelBase.prototype.localeChanged = function () {
        _super.prototype.localeChanged.call(this);
        this.runFuncForCellQuestions(function (q) { q.localeChanged(); });
    };
    QuestionMatrixDropdownModelBase.prototype.runFuncForCellQuestions = function (func) {
        if (!!this.generatedVisibleRows) {
            for (var i = 0; i < this.generatedVisibleRows.length; i++) {
                var row = this.generatedVisibleRows[i];
                for (var j = 0; j < row.cells.length; j++) {
                    func(row.cells[j].question);
                }
            }
        }
    };
    QuestionMatrixDropdownModelBase.prototype.runCondition = function (values, properties) {
        _super.prototype.runCondition.call(this, values, properties);
        var counter = 0;
        var prevTotalValue;
        do {
            prevTotalValue = helpers_Helpers.getUnbindValue(this.totalValue);
            this.runCellsCondition(values, properties);
            this.runTotalsCondition(values, properties);
            counter++;
        } while (!helpers_Helpers.isTwoValueEquals(prevTotalValue, this.totalValue) &&
            counter < 3);
    };
    QuestionMatrixDropdownModelBase.prototype.runTriggers = function (name, value) {
        _super.prototype.runTriggers.call(this, name, value);
        this.runFuncForCellQuestions(function (q) { q.runTriggers(name, value); });
    };
    QuestionMatrixDropdownModelBase.prototype.shouldRunColumnExpression = function () {
        return false;
    };
    QuestionMatrixDropdownModelBase.prototype.runCellsCondition = function (values, properties) {
        if (!this.generatedVisibleRows)
            return;
        var newValues = this.getRowConditionValues(values);
        var rows = this.generatedVisibleRows;
        for (var i = 0; i < rows.length; i++) {
            rows[i].runCondition(newValues, properties);
        }
        this.checkColumnsVisibility();
        this.checkColumnsRenderedRequired();
    };
    QuestionMatrixDropdownModelBase.prototype.checkColumnsVisibility = function () {
        if (this.isDesignMode)
            return;
        var hasChanged = false;
        for (var i = 0; i < this.visibleColumns.length; i++) {
            var column = this.visibleColumns[i];
            if (!column.visibleIf && !column.isFilteredMultipleColumns)
                continue;
            hasChanged = this.isColumnVisibilityChanged(column) || hasChanged;
        }
        if (hasChanged) {
            this.resetRenderedTable();
        }
    };
    QuestionMatrixDropdownModelBase.prototype.checkColumnsRenderedRequired = function () {
        var rows = this.generatedVisibleRows;
        for (var i = 0; i < this.visibleColumns.length; i++) {
            var column = this.visibleColumns[i];
            if (!column.requiredIf)
                continue;
            var required = rows.length > 0;
            for (var j = 0; j < rows.length; j++) {
                if (!rows[j].cells[i].question.isRequired) {
                    required = false;
                    break;
                }
            }
            column.updateIsRenderedRequired(required);
        }
    };
    QuestionMatrixDropdownModelBase.prototype.isColumnVisibilityChanged = function (column) {
        var curVis = column.isColumnVisible;
        var isMultipleColumnsVisibility = column.isFilteredMultipleColumns;
        var curVisibleChoices = isMultipleColumnsVisibility ? column.getVisibleChoicesInCell : [];
        var newVisibleChoices = new Array();
        var hasVisCell = false;
        var rows = this.generatedVisibleRows;
        for (var i = 0; i < rows.length; i++) {
            var cell = rows[i].cells[column.index];
            var q = cell === null || cell === void 0 ? void 0 : cell.question;
            if (!!q && q.isVisible) {
                hasVisCell = true;
                if (isMultipleColumnsVisibility) {
                    this.updateNewVisibleChoices(q, newVisibleChoices);
                }
                else
                    break;
            }
        }
        column.hasVisibleCell = hasVisCell;
        if (isMultipleColumnsVisibility) {
            column.setVisibleChoicesInCell(newVisibleChoices);
            if (!helpers_Helpers.isArraysEqual(curVisibleChoices, newVisibleChoices, true, false, false))
                return true;
        }
        return curVis !== column.isColumnVisible;
    };
    QuestionMatrixDropdownModelBase.prototype.updateNewVisibleChoices = function (q, dest) {
        var choices = q.visibleChoices;
        if (!Array.isArray(choices))
            return;
        for (var i = 0; i < choices.length; i++) {
            var ch = choices[i];
            if (dest.indexOf(ch.value) < 0)
                dest.push(ch.value);
        }
    };
    QuestionMatrixDropdownModelBase.prototype.runTotalsCondition = function (values, properties) {
        if (!this.generatedTotalRow)
            return;
        this.generatedTotalRow.runCondition(this.getRowConditionValues(values), properties);
    };
    QuestionMatrixDropdownModelBase.prototype.getRowConditionValues = function (values) {
        var newValues = values;
        if (!newValues)
            newValues = {};
        /*
        var newValues: { [index: string]: any } = {};
        if (values && values instanceof Object) {
          newValues = JSON.parse(JSON.stringify(values));
        }
        */
        var totalRow = {};
        if (!this.isValueEmpty(this.totalValue)) {
            totalRow = JSON.parse(JSON.stringify(this.totalValue));
        }
        newValues["row"] = {};
        newValues["totalRow"] = totalRow;
        return newValues;
    };
    QuestionMatrixDropdownModelBase.prototype.IsMultiplyColumn = function (column) {
        return column.isShowInMultipleColumns && !this.isMobile;
    };
    QuestionMatrixDropdownModelBase.prototype.locStrsChanged = function () {
        _super.prototype.locStrsChanged.call(this);
        var columns = this.columns;
        for (var i = 0; i < columns.length; i++) {
            columns[i].locStrsChanged();
        }
        var rows = this.generatedVisibleRows;
        if (!rows)
            return;
        for (var i = 0; i < rows.length; i++) {
            rows[i].locStrsChanged();
        }
        if (!!this.generatedTotalRow) {
            this.generatedTotalRow.locStrsChanged();
        }
    };
    /**
     * Returns a matrix column with a given `name` or `null` if a column with this is not found.
     * @param columnName A column name.
     */
    QuestionMatrixDropdownModelBase.prototype.getColumnByName = function (columnName) {
        for (var i = 0; i < this.columns.length; i++) {
            if (this.columns[i].name == columnName)
                return this.columns[i];
        }
        return null;
    };
    QuestionMatrixDropdownModelBase.prototype.getColumnName = function (columnName) {
        return this.getColumnByName(columnName);
    };
    QuestionMatrixDropdownModelBase.prototype.getColumnWidth = function (column) {
        var _a;
        return column.minWidth ? column.minWidth : this.columnMinWidth ? this.columnMinWidth : (((_a = settings.matrix.columnWidthsByType[column.cellType]) === null || _a === void 0 ? void 0 : _a.minWidth) || "");
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "choices", {
        /**
         * Gets or sets choice items for Dropdown, Checkbox, and Radiogroup matrix cells. You can override this property for individual columns.
         *
         * This property accepts an array of objects with the following structure:
         *
         * ```js
         * {
         *   "value": any, // A value to be saved in survey results
         *   "text": String, // A display text. This property supports Markdown. When `text` is undefined, `value` is used.
         *   "customProperty": any // Any property that you find useful.
         * }
         * ```
         *
         * To enable Markdown support for the `text` property, implement Markdown-to-HTML conversion in the [onTextMarkdown](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onTextMarkdown) event handler. For an example, refer to the following demo: [Convert Markdown to HTML with Showdown](https://surveyjs.io/form-library/examples/edit-survey-questions-markdown/).
         *
         * If you add custom properties, refer to the following help topic to learn how to serialize them into JSON: [Add Custom Properties to Property Grid](https://surveyjs.io/survey-creator/documentation/property-grid#add-custom-properties-to-the-property-grid).
         *
         * If you need to specify only the `value` property, you can set the `choices` property to an array of primitive values, for example, `[ "item1", "item2", "item3" ]`. These values are both saved in survey results and used as display text.
         * @see cellType
         */
        get: function () {
            return this.getPropertyValue("choices");
        },
        set: function (val) {
            this.setPropertyValue("choices", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "placeholder", {
        /**
         * A placeholder for Dropdown matrix cells.
         * @see cellType
         */
        get: function () {
            return this.getLocalizableStringText("placeholder");
        },
        set: function (val) {
            this.setLocalizableStringText("placeholder", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "locPlaceholder", {
        get: function () {
            return this.getLocalizableString("placeholder");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "optionsCaption", {
        get: function () {
            return this.placeholder;
        },
        set: function (val) {
            this.placeholder = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "keyDuplicationError", {
        /**
         * An error message displayed when users enter a duplicate value into a column that accepts only unique values (`isUnique` is set to `true` or `keyName` is specified).
         *
         * A default value for this property is taken from a [localization dictionary](https://github.com/surveyjs/survey-library/tree/master/src/localization). Refer to the following help topic for more information: [Localization & Globalization](https://surveyjs.io/form-library/documentation/localization).
         * @see isUniqueCaseSensitive
         */
        get: function () {
            return this.getLocalizableStringText("keyDuplicationError");
        },
        set: function (val) {
            this.setLocalizableStringText("keyDuplicationError", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "locKeyDuplicationError", {
        get: function () {
            return this.getLocalizableString("keyDuplicationError");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "storeOthersAsComment", {
        get: function () {
            return !!this.survey ? this.survey.storeOthersAsComment : false;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.addColumn = function (name, title) {
        if (title === void 0) { title = null; }
        var column = new question_matrixdropdowncolumn_MatrixDropdownColumn(name, title);
        this.columns.push(column);
        return column;
    };
    QuestionMatrixDropdownModelBase.prototype.getVisibleRows = function () {
        var _this = this;
        if (this.isUpdateLocked)
            return null;
        if (!this.generatedVisibleRows) {
            this.generatedVisibleRows = this.generateRows();
            this.generatedVisibleRows.forEach(function (row) { return _this.onMatrixRowCreated(row); });
            if (this.data) {
                this.runCellsCondition(this.data.getFilteredValues(), this.data.getFilteredProperties());
            }
            this.updateValueOnRowsGeneration(this.generatedVisibleRows);
            this.updateIsAnswered();
        }
        return this.generatedVisibleRows;
    };
    QuestionMatrixDropdownModelBase.prototype.updateValueOnRowsGeneration = function (rows) {
        var oldValue = this.createNewValue(true);
        var newValue = this.createNewValue();
        for (var i = 0; i < rows.length; i++) {
            var row = rows[i];
            if (!!row.editingObj)
                continue;
            var rowValue = this.getRowValue(i);
            var rValue = row.value;
            if (this.isTwoValueEquals(rowValue, rValue))
                continue;
            newValue = this.getNewValueOnRowChanged(row, "", rValue, false, newValue)
                .value;
        }
        if (this.isTwoValueEquals(oldValue, newValue))
            return;
        this.isRowChanging = true;
        this.setNewValue(newValue);
        this.isRowChanging = false;
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "totalValue", {
        get: function () {
            if (!this.hasTotal || !this.visibleTotalRow)
                return {};
            return this.visibleTotalRow.value;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.getVisibleTotalRow = function () {
        if (this.isUpdateLocked)
            return null;
        if (this.hasTotal) {
            if (!this.generatedTotalRow) {
                this.generatedTotalRow = this.generateTotalRow();
                if (this.data) {
                    var properties = { survey: this.survey };
                    this.runTotalsCondition(this.data.getAllValues(), properties);
                }
            }
        }
        else {
            this.generatedTotalRow = null;
        }
        return this.generatedTotalRow;
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "visibleTotalRow", {
        get: function () {
            return this.getVisibleTotalRow();
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.onSurveyLoad = function () {
        _super.prototype.onSurveyLoad.call(this);
        this.updateColumnsIndexes(this.columns);
        this.clearGeneratedRows();
        this.generatedTotalRow = null;
        this.updateHasFooter();
    };
    /**
     * Returns an object with row values. If a row has no answers, this method returns an empty object.
     * @param rowIndex A zero-based row index.
     * @see setRowValue
     */
    QuestionMatrixDropdownModelBase.prototype.getRowValue = function (rowIndex) {
        if (rowIndex < 0)
            return null;
        var visRows = this.visibleRows;
        if (rowIndex >= visRows.length)
            return null;
        var newValue = this.createNewValue();
        return this.getRowValueCore(visRows[rowIndex], newValue);
    };
    QuestionMatrixDropdownModelBase.prototype.checkIfValueInRowDuplicated = function (checkedRow, cellQuestion) {
        if (!this.generatedVisibleRows)
            return false;
        return this.isValueInColumnDuplicated(cellQuestion.name, true, checkedRow);
    };
    /**
     * Assigns values to a row.
     * @param rowIndex A zero-based row index.
     * @param rowValue An object with the following structure: `{ "column_name": columnValue, ... }`
     * @see getRowValue
     */
    QuestionMatrixDropdownModelBase.prototype.setRowValue = function (rowIndex, rowValue) {
        if (rowIndex < 0)
            return null;
        var visRows = this.visibleRows;
        if (rowIndex >= visRows.length)
            return null;
        visRows[rowIndex].value = rowValue;
        this.onRowChanged(visRows[rowIndex], "", rowValue, false);
    };
    QuestionMatrixDropdownModelBase.prototype.generateRows = function () {
        return null;
    };
    QuestionMatrixDropdownModelBase.prototype.generateTotalRow = function () {
        return new question_matrixdropdownbase_MatrixDropdownTotalRowModel(this);
    };
    QuestionMatrixDropdownModelBase.prototype.createNewValue = function (nullOnEmpty) {
        if (nullOnEmpty === void 0) { nullOnEmpty = false; }
        var res = !this.value ? {} : this.createValueCopy();
        if (nullOnEmpty && this.isMatrixValueEmpty(res))
            return null;
        return res;
    };
    QuestionMatrixDropdownModelBase.prototype.getRowValueCore = function (row, questionValue, create) {
        if (create === void 0) { create = false; }
        var result = !!questionValue && !!questionValue[row.rowName]
            ? questionValue[row.rowName]
            : null;
        if (!result && create) {
            result = {};
            if (!!questionValue) {
                questionValue[row.rowName] = result;
            }
        }
        return result;
    };
    QuestionMatrixDropdownModelBase.prototype.getRowObj = function (row) {
        var obj = this.getRowValueCore(row, this.value);
        return !!obj && !!obj.getType ? obj : null;
    };
    QuestionMatrixDropdownModelBase.prototype.getRowDisplayValue = function (keysAsText, row, rowValue) {
        if (!rowValue)
            return rowValue;
        if (!!row.editingObj)
            return rowValue;
        var keys = Object.keys(rowValue);
        for (var i = 0; i < keys.length; i++) {
            var key = keys[i];
            var question = row.getQuestionByName(key);
            if (!question) {
                question = this.getSharedQuestionByName(key, row);
            }
            if (!!question) {
                var displayvalue = question.getDisplayValue(keysAsText, rowValue[key]);
                if (keysAsText && !!question.title && question.title !== key) {
                    rowValue[question.title] = displayvalue;
                    delete rowValue[key];
                }
                else {
                    rowValue[key] = displayvalue;
                }
            }
        }
        return rowValue;
    };
    QuestionMatrixDropdownModelBase.prototype.getPlainData = function (options) {
        var _this = this;
        if (options === void 0) { options = { includeEmpty: true }; }
        var questionPlainData = _super.prototype.getPlainData.call(this, options);
        if (!!questionPlainData) {
            questionPlainData.isNode = true;
            var prevData = Array.isArray(questionPlainData.data) ? [].concat(questionPlainData.data) : [];
            questionPlainData.data = this.visibleRows.map(function (row) {
                var rowDataItem = {
                    name: row.dataName,
                    title: row.text,
                    value: row.value,
                    displayValue: _this.getRowDisplayValue(false, row, row.value),
                    getString: function (val) {
                        return typeof val === "object" ? JSON.stringify(val) : val;
                    },
                    isNode: true,
                    data: row.cells
                        .map(function (cell) {
                        return cell.question.getPlainData(options);
                    })
                        .filter(function (d) { return !!d; }),
                };
                (options.calculations || []).forEach(function (calculation) {
                    rowDataItem[calculation.propertyName] = row[calculation.propertyName];
                });
                return rowDataItem;
            });
            questionPlainData.data = questionPlainData.data.concat(prevData);
        }
        return questionPlainData;
    };
    QuestionMatrixDropdownModelBase.prototype.addConditionObjectsByContext = function (objects, context) {
        var rowElements = [].concat(this.columns);
        if (this.detailPanelMode !== "none") {
            rowElements = rowElements.concat(this.detailPanel.questions);
        }
        var hasColumnContext = !!context && rowElements.indexOf(context) > -1;
        var hasContext = context === true || hasColumnContext;
        var rowsIndeces = this.getConditionObjectsRowIndeces();
        if (hasContext) {
            rowsIndeces.push(-1);
        }
        for (var i = 0; i < rowsIndeces.length; i++) {
            var index = rowsIndeces[i];
            var rowName = index > -1 ? this.getConditionObjectRowName(index) : "row";
            if (!rowName)
                continue;
            var rowText = index > -1 ? this.getConditionObjectRowText(index) : "row";
            var hasQuestionPrefix = index > -1 || context === true;
            var dot = hasQuestionPrefix && index === -1 ? "." : "";
            var prefixName = (hasQuestionPrefix ? this.getValueName() : "") + dot + rowName + ".";
            var prefixTitle = (hasQuestionPrefix ? this.processedTitle : "") + dot + rowText + ".";
            for (var j = 0; j < rowElements.length; j++) {
                var rowElement = rowElements[j];
                if (index === -1 && context === rowElement)
                    continue;
                var obj = {
                    name: prefixName + rowElement.name,
                    text: prefixTitle + rowElement.fullTitle,
                    question: this
                };
                if (index === -1 && context === true) {
                    obj.context = this;
                }
                else {
                    if (hasColumnContext && prefixName.startsWith("row.")) {
                        obj.context = context;
                    }
                }
                objects.push(obj);
            }
        }
    };
    QuestionMatrixDropdownModelBase.prototype.onHidingContent = function () {
        _super.prototype.onHidingContent.call(this);
        var questions = [];
        this.collectNestedQuestions(questions, true);
        questions.forEach(function (q) { return q.onHidingContent(); });
    };
    QuestionMatrixDropdownModelBase.prototype.getIsReadyNestedQuestions = function () {
        if (!this.generatedVisibleRows)
            return [];
        var res = new Array();
        this.collectNestedQuestonsInRows(this.generatedVisibleRows, res, false);
        if (!!this.generatedTotalRow) {
            this.collectNestedQuestonsInRows([this.generatedTotalRow], res, false);
        }
        return res;
    };
    QuestionMatrixDropdownModelBase.prototype.collectNestedQuestionsCore = function (questions, visibleOnly) {
        this.collectNestedQuestonsInRows(this.visibleRows, questions, visibleOnly);
    };
    QuestionMatrixDropdownModelBase.prototype.collectNestedQuestonsInRows = function (rows, questions, visibleOnly) {
        if (!Array.isArray(rows))
            return;
        rows.forEach(function (row) {
            row.questions.forEach(function (q) { return q.collectNestedQuestions(questions, visibleOnly); });
        });
    };
    QuestionMatrixDropdownModelBase.prototype.getConditionObjectRowName = function (index) {
        return "";
    };
    QuestionMatrixDropdownModelBase.prototype.getConditionObjectRowText = function (index) {
        return this.getConditionObjectRowName(index);
    };
    QuestionMatrixDropdownModelBase.prototype.getConditionObjectsRowIndeces = function () {
        return [];
    };
    QuestionMatrixDropdownModelBase.prototype.getProgressInfo = function () {
        if (!!this.generatedVisibleRows)
            return survey_element_SurveyElement.getProgressInfoByElements(this.getCellQuestions(), this.isRequired);
        var res = base_Base.createProgressInfo();
        this.updateProgressInfoByValues(res);
        if (res.requiredQuestionCount === 0 && this.isRequired) {
            res.requiredQuestionCount = 1;
            res.requiredAnsweredQuestionCount = !this.isEmpty() ? 1 : 0;
        }
        return res;
    };
    QuestionMatrixDropdownModelBase.prototype.updateProgressInfoByValues = function (res) { };
    QuestionMatrixDropdownModelBase.prototype.updateProgressInfoByRow = function (res, rowValue) {
        for (var i = 0; i < this.columns.length; i++) {
            var col = this.columns[i];
            if (!col.templateQuestion.hasInput)
                continue;
            var hasValue = !helpers_Helpers.isValueEmpty(rowValue[col.name]);
            if (!hasValue && !!col.templateQuestion.visibleIf)
                continue;
            res.questionCount += 1;
            res.requiredQuestionCount += col.isRequired;
            res.answeredQuestionCount += hasValue ? 1 : 0;
            res.requiredAnsweredQuestionCount += hasValue && col.isRequired ? 1 : 0;
        }
    };
    QuestionMatrixDropdownModelBase.prototype.getCellQuestions = function () {
        var res = [];
        this.runFuncForCellQuestions(function (q) { res.push(q); });
        return res;
    };
    QuestionMatrixDropdownModelBase.prototype.onBeforeValueChanged = function (val) { };
    QuestionMatrixDropdownModelBase.prototype.onSetQuestionValue = function () {
        if (this.isRowChanging)
            return;
        this.onBeforeValueChanged(this.value);
        if (!this.generatedVisibleRows || this.generatedVisibleRows.length == 0)
            return;
        this.isRowChanging = true;
        var val = this.createNewValue();
        for (var i = 0; i < this.generatedVisibleRows.length; i++) {
            var row = this.generatedVisibleRows[i];
            this.generatedVisibleRows[i].value = this.getRowValueCore(row, val);
        }
        this.isRowChanging = false;
    };
    QuestionMatrixDropdownModelBase.prototype.setQuestionValue = function (newValue) {
        _super.prototype.setQuestionValue.call(this, newValue, false);
        this.onSetQuestionValue();
        this.updateIsAnswered();
    };
    QuestionMatrixDropdownModelBase.prototype.supportGoNextPageAutomatic = function () {
        var rows = this.generatedVisibleRows;
        if (!rows)
            rows = this.visibleRows;
        if (!rows)
            return true;
        for (var i = 0; i < rows.length; i++) {
            var cells = this.generatedVisibleRows[i].cells;
            if (!cells)
                continue;
            for (var colIndex = 0; colIndex < cells.length; colIndex++) {
                var question = cells[colIndex].question;
                if (question &&
                    (!question.supportGoNextPageAutomatic() || !question.value))
                    return false;
            }
        }
        return true;
    };
    QuestionMatrixDropdownModelBase.prototype.getContainsErrors = function () {
        return (_super.prototype.getContainsErrors.call(this) ||
            this.checkForAnswersOrErrors(function (question) { return question.containsErrors; }, false));
    };
    QuestionMatrixDropdownModelBase.prototype.getIsAnswered = function () {
        return (_super.prototype.getIsAnswered.call(this) &&
            this.checkForAnswersOrErrors(function (question) { return question.isAnswered; }, true));
    };
    QuestionMatrixDropdownModelBase.prototype.checkForAnswersOrErrors = function (predicate, every) {
        if (every === void 0) { every = false; }
        var rows = this.generatedVisibleRows;
        if (!rows)
            return false;
        for (var i = 0; i < rows.length; i++) {
            var cells = rows[i].cells;
            if (!cells)
                continue;
            for (var colIndex = 0; colIndex < cells.length; colIndex++) {
                if (!cells[colIndex])
                    continue;
                var question = cells[colIndex].question;
                if (question && question.isVisible)
                    if (predicate(question)) {
                        if (!every)
                            return true;
                    }
                    else {
                        if (every)
                            return false;
                    }
            }
        }
        return every ? true : false;
    };
    QuestionMatrixDropdownModelBase.prototype.hasErrors = function (fireCallback, rec) {
        if (fireCallback === void 0) { fireCallback = true; }
        if (rec === void 0) { rec = null; }
        var errosInRows = this.hasErrorInRows(fireCallback, rec);
        var isDuplicated = this.isValueDuplicated();
        return _super.prototype.hasErrors.call(this, fireCallback, rec) || errosInRows || isDuplicated;
    };
    QuestionMatrixDropdownModelBase.prototype.getIsRunningValidators = function () {
        if (_super.prototype.getIsRunningValidators.call(this))
            return true;
        if (!this.generatedVisibleRows)
            return false;
        for (var i = 0; i < this.generatedVisibleRows.length; i++) {
            var cells = this.generatedVisibleRows[i].cells;
            if (!cells)
                continue;
            for (var colIndex = 0; colIndex < cells.length; colIndex++) {
                if (!cells[colIndex])
                    continue;
                var question = cells[colIndex].question;
                if (!!question && question.isRunningValidators)
                    return true;
            }
        }
        return false;
    };
    QuestionMatrixDropdownModelBase.prototype.getAllErrors = function () {
        var result = _super.prototype.getAllErrors.call(this);
        var rows = this.generatedVisibleRows;
        if (rows === null)
            return result;
        for (var i = 0; i < rows.length; i++) {
            var row = rows[i];
            for (var j = 0; j < row.cells.length; j++) {
                var errors = row.cells[j].question.getAllErrors();
                if (errors && errors.length > 0) {
                    result = result.concat(errors);
                }
            }
        }
        return result;
    };
    QuestionMatrixDropdownModelBase.prototype.hasErrorInRows = function (fireCallback, rec) {
        var _this = this;
        var rows = this.generatedVisibleRows;
        if (!this.generatedVisibleRows) {
            rows = this.visibleRows;
        }
        var res = false;
        if (!rec)
            rec = {};
        if (!rows)
            return rec;
        rec.validationValues = this.getDataFilteredValues();
        rec.isSingleDetailPanel = this.detailPanelMode === "underRowSingle";
        for (var i = 0; i < rows.length; i++) {
            res = rows[i].hasErrors(fireCallback, rec, function () {
                _this.raiseOnCompletedAsyncValidators();
            }) || res;
        }
        return res;
    };
    QuestionMatrixDropdownModelBase.prototype.isValueDuplicated = function () {
        if (!this.generatedVisibleRows)
            return false;
        var names = this.getUniqueColumnsNames();
        var res = false;
        for (var i = 0; i < names.length; i++) {
            res = this.isValueInColumnDuplicated(names[i], true) || res;
        }
        return res;
    };
    QuestionMatrixDropdownModelBase.prototype.getUniqueColumnsNames = function () {
        var res = new Array();
        for (var i = 0; i < this.columns.length; i++) {
            if (this.columns[i].isUnique) {
                res.push(this.columns[i].name);
            }
        }
        return res;
    };
    QuestionMatrixDropdownModelBase.prototype.isValueInColumnDuplicated = function (columnName, showErrors, row) {
        var rows = this.getDuplicatedRows(columnName);
        if (showErrors) {
            this.showDuplicatedErrorsInRows(rows, columnName);
        }
        this.removeDuplicatedErrorsInRows(rows, columnName);
        return !!row ? rows.indexOf(row) > -1 : rows.length > 0;
    };
    QuestionMatrixDropdownModelBase.prototype.getDuplicatedRows = function (columnName) {
        var keyValues = {};
        var res = [];
        var rows = this.generatedVisibleRows;
        for (var i = 0; i < rows.length; i++) {
            var val = undefined;
            var question = rows[i].getQuestionByName(columnName);
            if (!!question) {
                val = question.value;
            }
            else {
                var rowVal = this.getRowValue(i);
                val = !!rowVal ? rowVal[columnName] : undefined;
            }
            if (!this.isValueEmpty(val)) {
                if (!this.isUniqueCaseSensitive && typeof val === "string") {
                    val = val.toLocaleLowerCase();
                }
                if (!keyValues[val]) {
                    keyValues[val] = [];
                }
                keyValues[val].push(rows[i]);
            }
        }
        for (var key in keyValues) {
            if (keyValues[key].length > 1) {
                keyValues[key].forEach(function (row) { return res.push(row); });
            }
        }
        return res;
    };
    QuestionMatrixDropdownModelBase.prototype.showDuplicatedErrorsInRows = function (duplicatedRows, columnName) {
        var _this = this;
        duplicatedRows.forEach(function (row) {
            var question = row.getQuestionByName(columnName);
            var inDetailPanel = _this.detailPanel.getQuestionByName(columnName);
            if (!question && inDetailPanel) {
                row.showDetailPanel();
                if (row.detailPanel) {
                    question = row.detailPanel.getQuestionByName(columnName);
                }
            }
            if (question) {
                if (inDetailPanel) {
                    row.showDetailPanel();
                }
                _this.addDuplicationError(question);
            }
        });
    };
    QuestionMatrixDropdownModelBase.prototype.removeDuplicatedErrorsInRows = function (duplicatedRows, columnName) {
        var _this = this;
        this.generatedVisibleRows.forEach(function (row) {
            if (duplicatedRows.indexOf(row) < 0) {
                var question = row.getQuestionByName(columnName);
                if (question) {
                    _this.removeDuplicationError(question);
                }
            }
        });
    };
    QuestionMatrixDropdownModelBase.prototype.getDuplicationError = function (question) {
        var errors = question.errors;
        for (var i = 0; i < errors.length; i++) {
            if (errors[i].getErrorType() === "keyduplicationerror")
                return errors[i];
        }
        return null;
    };
    QuestionMatrixDropdownModelBase.prototype.addDuplicationError = function (question) {
        if (!this.getDuplicationError(question)) {
            question.addError(new KeyDuplicationError(this.keyDuplicationError, this));
        }
    };
    QuestionMatrixDropdownModelBase.prototype.removeDuplicationError = function (question) {
        question.removeError(this.getDuplicationError(question));
    };
    QuestionMatrixDropdownModelBase.prototype.getFirstQuestionToFocus = function (withError) {
        return this.getFirstCellQuestion(withError);
    };
    QuestionMatrixDropdownModelBase.prototype.getFirstInputElementId = function () {
        var question = this.getFirstCellQuestion(false);
        return question ? question.inputId : _super.prototype.getFirstInputElementId.call(this);
    };
    QuestionMatrixDropdownModelBase.prototype.getFirstErrorInputElementId = function () {
        var question = this.getFirstCellQuestion(true);
        return question ? question.inputId : _super.prototype.getFirstErrorInputElementId.call(this);
    };
    QuestionMatrixDropdownModelBase.prototype.getFirstCellQuestion = function (onError) {
        if (!this.generatedVisibleRows)
            return null;
        for (var i = 0; i < this.generatedVisibleRows.length; i++) {
            var cells = this.generatedVisibleRows[i].cells;
            for (var colIndex = 0; colIndex < cells.length; colIndex++) {
                if (!onError)
                    return cells[colIndex].question;
                if (cells[colIndex].question.currentErrorCount > 0)
                    return cells[colIndex].question;
            }
        }
        return null;
    };
    QuestionMatrixDropdownModelBase.prototype.onReadOnlyChanged = function () {
        _super.prototype.onReadOnlyChanged.call(this);
        if (!this.generateRows)
            return;
        for (var i = 0; i < this.visibleRows.length; i++) {
            this.visibleRows[i].onQuestionReadOnlyChanged();
        }
    };
    //IMatrixDropdownData
    QuestionMatrixDropdownModelBase.prototype.createQuestion = function (row, column) {
        return this.createQuestionCore(row, column);
    };
    QuestionMatrixDropdownModelBase.prototype.createQuestionCore = function (row, column) {
        var question = column.createCellQuestion(row);
        question.setSurveyImpl(row);
        question.setParentQuestion(this);
        question.inMatrixMode = true;
        return question;
    };
    QuestionMatrixDropdownModelBase.prototype.deleteRowValue = function (newValue, row) {
        if (!newValue)
            return newValue;
        delete newValue[row.rowName];
        return this.isObject(newValue) && Object.keys(newValue).length == 0
            ? null
            : newValue;
    };
    QuestionMatrixDropdownModelBase.prototype.onAnyValueChanged = function (name, questionName) {
        if (this.isUpdateLocked ||
            this.isDoingonAnyValueChanged ||
            !this.generatedVisibleRows)
            return;
        this.isDoingonAnyValueChanged = true;
        var rows = this.visibleRows;
        for (var i = 0; i < rows.length; i++) {
            rows[i].onAnyValueChanged(name, questionName);
        }
        var totalRow = this.visibleTotalRow;
        if (!!totalRow) {
            totalRow.onAnyValueChanged(name, questionName);
        }
        this.isDoingonAnyValueChanged = false;
    };
    QuestionMatrixDropdownModelBase.prototype.isObject = function (value) {
        return value !== null && typeof value === "object";
    };
    QuestionMatrixDropdownModelBase.prototype.getOnCellValueChangedOptions = function (row, columnName, rowValue) {
        var getQuestion = function (colName) {
            return row.getQuestionByName(colName);
        };
        return {
            row: row,
            columnName: columnName,
            rowValue: rowValue,
            value: !!rowValue ? rowValue[columnName] : null,
            getCellQuestion: getQuestion,
            cellQuestion: row.getQuestionByName(columnName),
            column: this.getColumnByName(columnName)
        };
    };
    QuestionMatrixDropdownModelBase.prototype.onCellValueChanged = function (row, columnName, rowValue) {
        if (!this.survey)
            return;
        var options = this.getOnCellValueChangedOptions(row, columnName, rowValue);
        if (!!this.onCellValueChangedCallback) {
            this.onCellValueChangedCallback(options);
        }
        this.survey.matrixCellValueChanged(this, options);
    };
    QuestionMatrixDropdownModelBase.prototype.validateCell = function (row, columnName, rowValue) {
        if (!this.survey)
            return;
        var options = this.getOnCellValueChangedOptions(row, columnName, rowValue);
        return this.survey.matrixCellValidate(this, options);
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "isValidateOnValueChanging", {
        get: function () {
            return !!this.survey ? this.survey.isValidateOnValueChanging : false;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.onRowChanging = function (row, columnName, rowValue) {
        if (!this.survey && !this.cellValueChangingCallback)
            return !!rowValue ? rowValue[columnName] : null;
        var options = this.getOnCellValueChangedOptions(row, columnName, rowValue);
        var oldRowValue = this.getRowValueCore(row, this.createNewValue(), true);
        options.oldValue = !!oldRowValue ? oldRowValue[columnName] : null;
        if (!!this.cellValueChangingCallback) {
            options.value = this.cellValueChangingCallback(row, columnName, options.value, options.oldValue);
        }
        if (!!this.survey) {
            this.survey.matrixCellValueChanging(this, options);
        }
        return options.value;
    };
    QuestionMatrixDropdownModelBase.prototype.onRowChanged = function (row, columnName, newRowValue, isDeletingValue) {
        var rowObj = !!columnName ? this.getRowObj(row) : null;
        if (!!rowObj) {
            var columnValue = null;
            if (!!newRowValue && !isDeletingValue) {
                columnValue = newRowValue[columnName];
            }
            this.isRowChanging = true;
            Serializer.setObjPropertyValue(rowObj, columnName, columnValue);
            this.isRowChanging = false;
            this.onCellValueChanged(row, columnName, rowObj);
        }
        else {
            var oldValue = this.createNewValue(true);
            var combine = this.getNewValueOnRowChanged(row, columnName, newRowValue, isDeletingValue, this.createNewValue());
            if (this.isTwoValueEquals(oldValue, combine.value))
                return;
            this.isRowChanging = true;
            this.setNewValue(combine.value);
            this.isRowChanging = false;
            if (columnName) {
                this.onCellValueChanged(row, columnName, combine.rowValue);
            }
        }
        if (this.getUniqueColumnsNames().indexOf(columnName) > -1) {
            this.isValueInColumnDuplicated(columnName, !!rowObj);
        }
    };
    QuestionMatrixDropdownModelBase.prototype.getNewValueOnRowChanged = function (row, columnName, newRowValue, isDeletingValue, newValue) {
        var rowValue = this.getRowValueCore(row, newValue, true);
        if (isDeletingValue) {
            delete rowValue[columnName];
        }
        for (var i = 0; i < row.cells.length; i++) {
            var key = row.cells[i].question.getValueName();
            delete rowValue[key];
        }
        if (newRowValue) {
            newRowValue = JSON.parse(JSON.stringify(newRowValue));
            for (var key in newRowValue) {
                if (!this.isValueEmpty(newRowValue[key])) {
                    rowValue[key] = newRowValue[key];
                }
            }
        }
        if (this.isObject(rowValue) && Object.keys(rowValue).length === 0) {
            newValue = this.deleteRowValue(newValue, row);
        }
        return { value: newValue, rowValue: rowValue };
    };
    QuestionMatrixDropdownModelBase.prototype.getRowIndex = function (row) {
        if (!this.generatedVisibleRows)
            return -1;
        return this.visibleRows.indexOf(row);
    };
    QuestionMatrixDropdownModelBase.prototype.getElementsInDesign = function (includeHidden) {
        if (includeHidden === void 0) { includeHidden = false; }
        var elements;
        if (this.detailPanelMode == "none") {
            elements = _super.prototype.getElementsInDesign.call(this, includeHidden);
        }
        else {
            elements = includeHidden ? [this.detailPanel] : this.detailElements;
        }
        return this.columns.concat(elements);
    };
    QuestionMatrixDropdownModelBase.prototype.hasDetailPanel = function (row) {
        if (this.detailPanelMode == "none")
            return false;
        if (this.isDesignMode)
            return true;
        if (!!this.onHasDetailPanelCallback)
            return this.onHasDetailPanelCallback(row);
        return this.detailElements.length > 0;
    };
    QuestionMatrixDropdownModelBase.prototype.getIsDetailPanelShowing = function (row) {
        if (this.detailPanelMode == "none")
            return false;
        if (this.isDesignMode) {
            var res = this.visibleRows.indexOf(row) == 0;
            if (res) {
                if (!row.detailPanel) {
                    row.showDetailPanel();
                }
            }
            return res;
        }
        return this.getPropertyValue("isRowShowing" + row.id, false);
    };
    QuestionMatrixDropdownModelBase.prototype.setIsDetailPanelShowing = function (row, val) {
        if (val == this.getIsDetailPanelShowing(row))
            return;
        this.setPropertyValue("isRowShowing" + row.id, val);
        this.updateDetailPanelButtonCss(row);
        if (!!this.renderedTable) {
            this.renderedTable.onDetailPanelChangeVisibility(row, val);
        }
        if (this.survey) {
            this.survey.matrixDetailPanelVisibleChanged(this, row.rowIndex - 1, row, val);
        }
        if (val && this.detailPanelMode === "underRowSingle") {
            var rows = this.visibleRows;
            for (var i = 0; i < rows.length; i++) {
                if (rows[i].id !== row.id && rows[i].isDetailPanelShowing) {
                    rows[i].hideDetailPanel();
                }
            }
        }
    };
    QuestionMatrixDropdownModelBase.prototype.getDetailPanelButtonCss = function (row) {
        var builder = new CssClassBuilder().append(this.getPropertyValue("detailButtonCss" + row.id));
        return builder.append(this.cssClasses.detailButton, builder.toString() === "").toString();
    };
    QuestionMatrixDropdownModelBase.prototype.getDetailPanelIconCss = function (row) {
        var builder = new CssClassBuilder().append(this.getPropertyValue("detailIconCss" + row.id));
        return builder.append(this.cssClasses.detailIcon, builder.toString() === "").toString();
    };
    QuestionMatrixDropdownModelBase.prototype.getDetailPanelIconId = function (row) {
        return this.getIsDetailPanelShowing(row) ? this.cssClasses.detailIconExpandedId : this.cssClasses.detailIconId;
    };
    QuestionMatrixDropdownModelBase.prototype.updateDetailPanelButtonCss = function (row) {
        var classes = this.cssClasses;
        var isPanelShowing = this.getIsDetailPanelShowing(row);
        var iconBuilder = new CssClassBuilder().append(classes.detailIcon)
            .append(classes.detailIconExpanded, isPanelShowing);
        this.setPropertyValue("detailIconCss" + row.id, iconBuilder.toString());
        var buttonBuilder = new CssClassBuilder().append(classes.detailButton)
            .append(classes.detailButtonExpanded, isPanelShowing);
        this.setPropertyValue("detailButtonCss" + row.id, buttonBuilder.toString());
    };
    QuestionMatrixDropdownModelBase.prototype.createRowDetailPanel = function (row) {
        var _this = this;
        if (this.isDesignMode)
            return this.detailPanel;
        var panel = this.createNewDetailPanel();
        panel.readOnly = this.isReadOnly || !row.isRowEnabled();
        panel.setSurveyImpl(row);
        var json = this.detailPanel.toJSON();
        new jsonobject_JsonObject().toObject(json, panel);
        panel.renderWidth = "100%";
        panel.updateCustomWidgets();
        if (!!this.onCreateDetailPanelCallback) {
            this.onCreateDetailPanelCallback(row, panel);
        }
        panel.questions.forEach(function (q) { return q.setParentQuestion(_this); });
        panel.onSurveyLoad();
        return panel;
    };
    QuestionMatrixDropdownModelBase.prototype.getSharedQuestionByName = function (columnName, row) {
        if (!this.survey || !this.valueName)
            return null;
        var index = this.getRowIndex(row);
        if (index < 0)
            return null;
        return (this.survey.getQuestionByValueNameFromArray(this.valueName, columnName, index));
    };
    QuestionMatrixDropdownModelBase.prototype.onTotalValueChanged = function () {
        if (!!this.data &&
            !!this.visibleTotalRow &&
            !this.isUpdateLocked &&
            !this.isSett) {
            this.data.setValue(this.getValueName() + settings.matrix.totalsSuffix, this.totalValue, false);
        }
    };
    QuestionMatrixDropdownModelBase.prototype.getDataFilteredValues = function () {
        return this.data ? this.data.getFilteredValues() : {};
    };
    QuestionMatrixDropdownModelBase.prototype.getParentTextProcessor = function () {
        if (!this.parentQuestion || !this.parent)
            return null;
        var data = this.parent.data;
        if (!!data && !!data.getTextProcessor)
            return data.getTextProcessor();
        return null;
    };
    QuestionMatrixDropdownModelBase.prototype.isMatrixReadOnly = function () { return this.isReadOnly; };
    QuestionMatrixDropdownModelBase.prototype.getQuestionFromArray = function (name, index) {
        if (index >= this.visibleRows.length)
            return null;
        return this.visibleRows[index].getQuestionByName(name);
    };
    QuestionMatrixDropdownModelBase.prototype.isMatrixValueEmpty = function (val) {
        if (!val)
            return;
        if (Array.isArray(val)) {
            for (var i = 0; i < val.length; i++) {
                if (this.isObject(val[i]) && Object.keys(val[i]).length > 0)
                    return false;
            }
            return true;
        }
        return Object.keys(val).length == 0;
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "SurveyModel", {
        get: function () {
            return this.survey;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.getCellTemplateData = function (cell) {
        // return cell.cell.column.templateQuestion;
        return this.SurveyModel.getMatrixCellTemplateData(cell);
    };
    QuestionMatrixDropdownModelBase.prototype.getCellWrapperComponentName = function (cell) {
        return this.SurveyModel.getElementWrapperComponentName(cell, cell.row instanceof question_matrixdropdownbase_MatrixDropdownTotalRowModel ? "row-footer" : "cell");
    };
    QuestionMatrixDropdownModelBase.prototype.getCellWrapperComponentData = function (cell) {
        return this.SurveyModel.getElementWrapperComponentData(cell, cell.row instanceof question_matrixdropdownbase_MatrixDropdownTotalRowModel ? "row-footer" : "cell");
    };
    QuestionMatrixDropdownModelBase.prototype.getColumnHeaderWrapperComponentName = function (cell) {
        return this.SurveyModel.getElementWrapperComponentName(cell, "column-header");
    };
    QuestionMatrixDropdownModelBase.prototype.getColumnHeaderWrapperComponentData = function (cell) {
        return this.SurveyModel.getElementWrapperComponentData(cell, "column-header");
    };
    QuestionMatrixDropdownModelBase.prototype.getRowHeaderWrapperComponentName = function (cell) {
        return this.SurveyModel.getElementWrapperComponentName(cell, "row-header");
    };
    QuestionMatrixDropdownModelBase.prototype.getRowHeaderWrapperComponentData = function (cell) {
        return this.SurveyModel.getElementWrapperComponentData(cell, "row-header");
    };
    Object.defineProperty(QuestionMatrixDropdownModelBase.prototype, "showHorizontalScroll", {
        get: function () {
            return !this.isDefaultV2Theme && this.horizontalScroll;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModelBase.prototype.getRootCss = function () {
        return new CssClassBuilder().append(_super.prototype.getRootCss.call(this)).append(this.cssClasses.rootScroll, this.horizontalScroll).toString();
    };
    return QuestionMatrixDropdownModelBase;
}(martixBase_QuestionMatrixBaseModel));

Serializer.addClass("matrixdropdownbase", [
    {
        name: "columns:matrixdropdowncolumns",
        className: "matrixdropdowncolumn", isArray: true
    },
    {
        name: "columnLayout",
        alternativeName: "columnsLocation",
        choices: ["horizontal", "vertical"],
        visible: false, isSerializable: false
    },
    {
        name: "transposeData:boolean", version: "1.9.130", oldName: "columnLayout"
    },
    {
        name: "detailElements",
        baseClassName: "question",
        visible: false,
        isLightSerializable: false,
    },
    { name: "columnsVisibleIf", visible: false },
    {
        name: "detailPanelMode",
        choices: ["none", "underRow", "underRowSingle"],
        default: "none",
    },
    { name: "cellErrorLocation", default: "default", choices: ["default", "top", "bottom"] },
    {
        name: "detailErrorLocation", default: "default", choices: ["default", "top", "bottom"],
        visibleIf: function (obj) { return !!obj && obj.detailPanelMode != "none"; }
    },
    { name: "horizontalScroll:boolean", visible: false, },
    {
        name: "choices:itemvalue[]", uniqueProperty: "value",
        visibleIf: function (obj) { return obj.isSelectCellType(); }
    },
    { name: "placeholder", alternativeName: "optionsCaption", serializationProperty: "locPlaceholder" },
    {
        name: "keyDuplicationError",
        serializationProperty: "locKeyDuplicationError",
    },
    {
        name: "cellType",
        default: "dropdown",
        choices: function () {
            return question_matrixdropdowncolumn_MatrixDropdownColumn.getColumnTypes();
        },
    },
    { name: "columnColCount", default: 0, choices: [0, 1, 2, 3, 4] },
    "columnMinWidth",
    { name: "allowAdaptiveActions:boolean", default: false, visible: false },
], function () {
    return new question_matrixdropdownbase_QuestionMatrixDropdownModelBase("");
}, "matrixbase");

// CONCATENATED MODULE: ./packages/survey-core/src/question_matrixdropdown.ts
var question_matrixdropdown_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();





var MatrixDropdownRowModel = /** @class */ (function (_super) {
    question_matrixdropdown_extends(MatrixDropdownRowModel, _super);
    function MatrixDropdownRowModel(name, item, data, value) {
        var _this = _super.call(this, data, value) || this;
        _this.name = name;
        _this.item = item;
        _this.buildCells(value);
        return _this;
    }
    Object.defineProperty(MatrixDropdownRowModel.prototype, "rowName", {
        get: function () {
            return this.name;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownRowModel.prototype, "text", {
        get: function () {
            return this.item.text;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDropdownRowModel.prototype, "locText", {
        get: function () {
            return this.item.locText;
        },
        enumerable: false,
        configurable: true
    });
    MatrixDropdownRowModel.prototype.isRowEnabled = function () { return this.item.isEnabled; };
    MatrixDropdownRowModel.prototype.isRowHasEnabledCondition = function () { return !!this.item.enableIf; };
    return MatrixDropdownRowModel;
}(question_matrixdropdownbase_MatrixDropdownRowModelBase));

/**
  * A class that describes the Multi-Select Matrix question type. Multi-Select Matrix allows you to use the [Dropdown](https://surveyjs.io/form-library/documentation/questiondropdownmodel), [Checkbox](https://surveyjs.io/form-library/documentation/questioncheckboxmodel), [Radiogroup](https://surveyjs.io/form-library/documentation/questionradiogroupmodel), [Text](https://surveyjs.io/form-library/documentation/questiontextmodel), and [Comment](https://surveyjs.io/form-library/documentation/questioncommentmodel) question types as cell editors.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/questiontype-matrixdropdown/ (linkStyle))
 */
var question_matrixdropdown_QuestionMatrixDropdownModel = /** @class */ (function (_super) {
    question_matrixdropdown_extends(QuestionMatrixDropdownModel, _super);
    function QuestionMatrixDropdownModel(name) {
        var _this = _super.call(this, name) || this;
        _this.defaultValuesInRows = {};
        _this.createLocalizableString("totalText", _this, true);
        _this.registerPropertyChangedHandlers(["rows"], function () {
            _this.clearGeneratedRows();
            _this.resetRenderedTable();
            if (!_this.filterItems()) {
                _this.onRowsChanged();
            }
            _this.clearIncorrectValues();
        });
        _this.registerPropertyChangedHandlers(["hideIfRowsEmpty"], function () {
            _this.updateVisibilityBasedOnRows();
        });
        return _this;
    }
    QuestionMatrixDropdownModel.prototype.getType = function () {
        return "matrixdropdown";
    };
    Object.defineProperty(QuestionMatrixDropdownModel.prototype, "totalText", {
        /**
         * A title for the total row. Applies if at least one column displays total values.
         * @see rowTitleWidth
         * @see columns
         */
        get: function () {
            return this.getLocalizableStringText("totalText", "");
        },
        set: function (val) {
            this.setLocalizableStringText("totalText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDropdownModel.prototype, "locTotalText", {
        get: function () {
            return this.getLocalizableString("totalText");
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModel.prototype.getFooterText = function () {
        return this.locTotalText;
    };
    QuestionMatrixDropdownModel.prototype.getRowTitleWidth = function () {
        return this.rowTitleWidth;
    };
    Object.defineProperty(QuestionMatrixDropdownModel.prototype, "hideIfRowsEmpty", {
        /**
         * Specifies whether to hide the question when the matrix has no visible rows.
         * @see rowsVisibleIf
         */
        get: function () {
            return this.getPropertyValue("hideIfRowsEmpty");
        },
        set: function (val) {
            this.setPropertyValue("hideIfRowsEmpty", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDropdownModel.prototype.getDisplayValueCore = function (keysAsText, value) {
        if (!value)
            return value;
        var rows = this.visibleRows;
        var res = {};
        if (!rows)
            return res;
        for (var i = 0; i < rows.length; i++) {
            var rowValue = rows[i].rowName;
            var val = value[rowValue];
            if (!val)
                continue;
            if (keysAsText) {
                var displayRowValue = itemvalue_ItemValue.getTextOrHtmlByValue(this.rows, rowValue);
                if (!!displayRowValue) {
                    rowValue = displayRowValue;
                }
            }
            res[rowValue] = this.getRowDisplayValue(keysAsText, rows[i], val);
        }
        return res;
    };
    QuestionMatrixDropdownModel.prototype.getConditionObjectRowName = function (index) {
        return "." + this.rows[index].value;
    };
    QuestionMatrixDropdownModel.prototype.getConditionObjectRowText = function (index) {
        return "." + this.rows[index].calculatedText;
    };
    QuestionMatrixDropdownModel.prototype.getConditionObjectsRowIndeces = function () {
        var res = [];
        for (var i = 0; i < this.rows.length; i++)
            res.push(i);
        return res;
    };
    QuestionMatrixDropdownModel.prototype.isNewValueCorrect = function (val) {
        return helpers_Helpers.isValueObject(val, true);
    };
    QuestionMatrixDropdownModel.prototype.clearIncorrectValues = function () {
        var val = this.value;
        if (!val)
            return;
        var newVal = null;
        var isChanged = false;
        var rows = !!this.filteredRows ? this.filteredRows : this.rows;
        for (var key in val) {
            if (itemvalue_ItemValue.getItemByValue(rows, key)) {
                if (newVal == null)
                    newVal = {};
                newVal[key] = val[key];
            }
            else {
                isChanged = true;
            }
        }
        if (isChanged) {
            this.value = newVal;
        }
        _super.prototype.clearIncorrectValues.call(this);
    };
    QuestionMatrixDropdownModel.prototype.clearValueIfInvisibleCore = function (reason) {
        _super.prototype.clearValueIfInvisibleCore.call(this, reason);
        this.clearInvisibleValuesInRows();
    };
    QuestionMatrixDropdownModel.prototype.clearGeneratedRows = function () {
        var _this = this;
        if (!this.generatedVisibleRows)
            return;
        if (!this.isDisposed) {
            this.generatedVisibleRows.forEach(function (row) {
                _this.defaultValuesInRows[row.rowName] = row.getNamesWithDefaultValues();
            });
        }
        _super.prototype.clearGeneratedRows.call(this);
    };
    QuestionMatrixDropdownModel.prototype.getRowValueForCreation = function (val, rowValue) {
        var res = val[rowValue];
        if (!res)
            return res;
        var names = this.defaultValuesInRows[rowValue];
        if (!Array.isArray(names) || names.length === 0)
            return res;
        names.forEach(function (name) {
            delete res[name];
        });
        return res;
    };
    QuestionMatrixDropdownModel.prototype.generateRows = function () {
        var result = new Array();
        var rows = !!this.filteredRows ? this.filteredRows : this.rows;
        if (!rows || rows.length === 0)
            return result;
        var val = this.value;
        if (!val)
            val = {};
        for (var i = 0; i < rows.length; i++) {
            var row = rows[i];
            if (this.isValueEmpty(row.value))
                continue;
            result.push(this.createMatrixRow(row, this.getRowValueForCreation(val, row.value)));
        }
        return result;
    };
    QuestionMatrixDropdownModel.prototype.createMatrixRow = function (item, value) {
        return new MatrixDropdownRowModel(item.value, item, this, value);
    };
    QuestionMatrixDropdownModel.prototype.getSearchableItemValueKeys = function (keys) {
        keys.push("rows");
    };
    QuestionMatrixDropdownModel.prototype.updateProgressInfoByValues = function (res) {
        var val = this.value;
        if (!val)
            val = {};
        for (var i = 0; i < this.rows.length; i++) {
            var row = this.rows[i];
            var rowValue = val[row.value];
            this.updateProgressInfoByRow(res, !!rowValue ? rowValue : {});
        }
    };
    return QuestionMatrixDropdownModel;
}(question_matrixdropdownbase_QuestionMatrixDropdownModelBase));

Serializer.addClass("matrixdropdown", [
    {
        name: "rows:itemvalue[]", uniqueProperty: "value"
    },
    "rowsVisibleIf:condition",
    "rowTitleWidth",
    { name: "totalText", serializationProperty: "locTotalText" },
    "hideIfRowsEmpty:boolean"
], function () {
    return new question_matrixdropdown_QuestionMatrixDropdownModel("");
}, "matrixdropdownbase");
questionfactory_QuestionFactory.Instance.registerQuestion("matrixdropdown", function (name) {
    var q = new question_matrixdropdown_QuestionMatrixDropdownModel(name);
    q.choices = [1, 2, 3, 4, 5];
    q.rows = questionfactory_QuestionFactory.DefaultRows;
    question_matrixdropdownbase_QuestionMatrixDropdownModelBase.addDefaultColumns(q);
    return q;
});

// CONCATENATED MODULE: ./packages/survey-core/src/utils/devices.ts

// isMobile
var _isMobile = false;
var vendor = null;
if (typeof navigator !== "undefined" && !!navigator && DomWindowHelper.isAvailable()) {
    vendor = navigator.userAgent || navigator.vendor || DomWindowHelper.hasOwn("opera");
}
(function (a) {
    if (!a)
        return;
    if ((navigator.platform === "MacIntel" && navigator.maxTouchPoints > 0) || navigator.platform === "iPad") {
        _isMobile = true;
    }
    else if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) ||
        /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substring(0, 4)))
        _isMobile = true;
})(vendor);
var _IPad = false;
var IsMobile = _isMobile || _IPad;
var mouseInfo = {
    get isTouch() {
        return !this.hasMouse && this.hasTouchEvent;
    },
    get hasTouchEvent() {
        return DomWindowHelper.isAvailable() && (DomWindowHelper.hasOwn("ontouchstart") || navigator.maxTouchPoints > 0);
    },
    hasMouse: true
};
var matchMediaMethod = DomWindowHelper.matchMedia;
mouseInfo.hasMouse = detectMouseSupport(matchMediaMethod);
var IsTouch = mouseInfo.isTouch;
//for tests
function _setIsTouch(val) {
    IsTouch = val;
}
function detectMouseSupport(matchMedia) {
    if (!matchMedia)
        return false;
    if (IsMobile)
        return false;
    var pointerQuery = matchMedia("(pointer:fine)");
    var hoverQuery = matchMedia("(any-hover:hover)");
    return !!pointerQuery && pointerQuery.matches || !!hoverQuery && hoverQuery.matches;
}

// CONCATENATED MODULE: ./packages/survey-core/src/dragdrop/dom-adapter.ts
var dom_adapter_spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
    for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
        to[j] = from[i];
    return to;
};
/* eslint-disable no-restricted-globals */



// WebKit requires cancelable `touchmove` events to be added as early as possible
// see https://bugs.webkit.org/show_bug.cgi?id=184250
if (typeof window !== "undefined") {
    window.addEventListener("touchmove", function (event) {
        if (!dom_adapter_DragDropDOMAdapter.PreventScrolling) {
            return;
        }
        // Prevent scrolling
        event.preventDefault();
    }, { passive: false });
}
var dom_adapter_DragDropDOMAdapter = /** @class */ (function () {
    function DragDropDOMAdapter(dd, longTap, fitToContainer) {
        var _this = this;
        if (longTap === void 0) { longTap = true; }
        if (fitToContainer === void 0) { fitToContainer = false; }
        this.dd = dd;
        this.longTap = longTap;
        this.fitToContainer = fitToContainer;
        this.scrollIntervalId = null;
        this.stopLongTapIfMoveEnough = function (pointerMoveEvent) {
            pointerMoveEvent.preventDefault();
            _this.currentX = pointerMoveEvent.pageX;
            _this.currentY = pointerMoveEvent.pageY;
            if (_this.isMicroMovement)
                return;
            _this.returnUserSelectBack();
            _this.stopLongTap();
        };
        this.stopLongTap = function (e) {
            clearTimeout(_this.timeoutID);
            _this.timeoutID = null;
            document.removeEventListener("pointerup", _this.stopLongTap);
            document.removeEventListener("pointermove", _this.stopLongTapIfMoveEnough);
        };
        this.handlePointerCancel = function (event) {
            _this.clear();
        };
        this.handleEscapeButton = function (event) {
            if (event.keyCode == 27) {
                _this.clear();
            }
        };
        this.onContextMenu = function (event) {
            event.preventDefault();
            event.stopPropagation();
        };
        this.dragOver = function (event) {
            _this.moveShortcutElement(event);
            _this.draggedElementShortcut.style.cursor = "grabbing";
            _this.dd.dragOver(event);
        };
        this.clear = function () {
            cancelAnimationFrame(_this.scrollIntervalId);
            document.removeEventListener("pointermove", _this.dragOver);
            document.removeEventListener("pointercancel", _this.handlePointerCancel);
            document.removeEventListener("keydown", _this.handleEscapeButton);
            document.removeEventListener("pointerup", _this.drop);
            _this.draggedElementShortcut.removeEventListener("pointerup", _this.drop);
            if (IsTouch) {
                _this.draggedElementShortcut.removeEventListener("contextmenu", _this.onContextMenu);
            }
            _this.draggedElementShortcut.parentElement.removeChild(_this.draggedElementShortcut);
            _this.dd.clear();
            _this.draggedElementShortcut = null;
            _this.scrollIntervalId = null;
            if (IsTouch) {
                _this.savedTargetNode.style.cssText = null;
                _this.savedTargetNode && _this.savedTargetNode.parentElement.removeChild(_this.savedTargetNode);
                _this.insertNodeToParentAtIndex(_this.savedTargetNodeParent, _this.savedTargetNode, _this.savedTargetNodeIndex);
                DragDropDOMAdapter.PreventScrolling = false;
            }
            _this.savedTargetNode = null;
            _this.savedTargetNodeParent = null;
            _this.savedTargetNodeIndex = null;
            _this.returnUserSelectBack();
        };
        this.drop = function () {
            _this.dd.drop();
            _this.clear();
        };
        this.draggedElementShortcut = null;
    }
    Object.defineProperty(DragDropDOMAdapter.prototype, "documentOrShadowRoot", {
        get: function () {
            return settings.environment.root;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DragDropDOMAdapter.prototype, "rootElement", {
        get: function () {
            if (isShadowDOM(settings.environment.root)) {
                return this.rootContainer || settings.environment.root.host;
            }
            else {
                return this.rootContainer || settings.environment.root.documentElement || document.body;
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DragDropDOMAdapter.prototype, "isMicroMovement", {
        // see https://stackoverflow.com/questions/6042202/how-to-distinguish-mouse-click-and-drag
        get: function () {
            var delta = 5;
            var diffX = Math.abs(this.currentX - this.startX);
            var diffY = Math.abs(this.currentY - this.startY);
            return diffX < delta && diffY < delta;
        },
        enumerable: false,
        configurable: true
    });
    DragDropDOMAdapter.prototype.startLongTapProcessing = function (event, draggedElement, parentElement, draggedElementNode, preventSaveTargetNode) {
        var _this = this;
        if (preventSaveTargetNode === void 0) { preventSaveTargetNode = false; }
        this.startX = event.pageX;
        this.startY = event.pageY;
        document.body.style.setProperty("touch-action", "none", "important");
        //document.body.style.setProperty("-webkit-touch-callout", "none", "important");
        this.timeoutID = setTimeout(function () {
            _this.doStartDrag(event, draggedElement, parentElement, draggedElementNode);
            if (!preventSaveTargetNode) {
                _this.savedTargetNode = event.target;
                _this.savedTargetNode.style.cssText =
                    "\n          position: absolute;\n          height: 1px!important;\n          width: 1px!important;\n          overflow: hidden;\n          clip: rect(1px 1px 1px 1px);\n          clip: rect(1px, 1px, 1px, 1px);\n        ";
                _this.savedTargetNodeParent = _this.savedTargetNode.parentElement;
                _this.savedTargetNodeIndex = _this.getNodeIndexInParent(_this.savedTargetNode);
                _this.rootElement.appendChild(_this.savedTargetNode);
            }
            _this.stopLongTap();
        }, this.longTap ? 500 : 0);
        document.addEventListener("pointerup", this.stopLongTap);
        document.addEventListener("pointermove", this.stopLongTapIfMoveEnough);
    };
    DragDropDOMAdapter.prototype.moveShortcutElement = function (event) {
        var rootElementX = this.rootElement.getBoundingClientRect().x;
        var rootElementY = this.rootElement.getBoundingClientRect().y;
        var rootElementScrollLeft = this.rootElement.scrollLeft;
        var rootElementScrollTop = this.rootElement.scrollTop;
        this.doScroll(event.clientY, event.clientX);
        var shortcutHeight = this.draggedElementShortcut.offsetHeight;
        var shortcutWidth = this.draggedElementShortcut.offsetWidth;
        var shortcutXOffset = this.draggedElementShortcut.shortcutXOffset || shortcutWidth / 2;
        var shortcutYOffset = this.draggedElementShortcut.shortcutYOffset || shortcutHeight / 2;
        // TODO this is hot fix for RTL support. Probably we need better global strategy for it. https://github.com/surveyjs/survey-library/issues/4554
        if (document.querySelectorAll("[dir='rtl']").length !== 0) {
            shortcutXOffset = shortcutWidth / 2;
            shortcutYOffset = shortcutHeight / 2;
        }
        var documentBottom = document.documentElement.clientHeight;
        var documentRight = document.documentElement.clientWidth;
        var pageX = event.pageX;
        var pageY = event.pageY;
        var clientX = event.clientX;
        var clientY = event.clientY;
        //https://github.com/surveyjs/survey-creator/issues/5484
        rootElementX -= rootElementScrollLeft;
        rootElementY -= rootElementScrollTop;
        var shortcutBottomCoordinate = this.getShortcutBottomCoordinate(clientY, shortcutHeight, shortcutYOffset);
        var shortcutRightCoordinate = this.getShortcutRightCoordinate(clientX, shortcutWidth, shortcutXOffset);
        if (shortcutRightCoordinate >= documentRight) { // right boundary
            this.draggedElementShortcut.style.left =
                // pageX -
                // clientX +
                documentRight -
                    shortcutWidth -
                    rootElementX +
                    "px";
            this.draggedElementShortcut.style.top =
                /*pageY*/ clientY - shortcutYOffset - rootElementY + "px";
            return;
        }
        if (clientX - shortcutXOffset <= 0) { // left boundary
            this.draggedElementShortcut.style.left =
                pageX - clientX - rootElementX + "px";
            this.draggedElementShortcut.style.top =
                /*pageY*/ clientY - rootElementY - shortcutYOffset + "px";
            return;
        }
        if (shortcutBottomCoordinate >= documentBottom) { // bottom boundary
            this.draggedElementShortcut.style.left =
                /*pageX*/ clientX - shortcutXOffset - rootElementX + "px";
            this.draggedElementShortcut.style.top =
                // pageY -
                // clientY +
                documentBottom -
                    shortcutHeight -
                    rootElementY +
                    "px";
            return;
        }
        if (clientY - shortcutYOffset <= 0) { // top  boundary
            this.draggedElementShortcut.style.left =
                clientX - shortcutXOffset - rootElementX + "px";
            this.draggedElementShortcut.style.top =
                pageY - clientY - rootElementY + "px";
            return;
        }
        this.draggedElementShortcut.style.left =
            clientX - rootElementX - shortcutXOffset + "px";
        this.draggedElementShortcut.style.top =
            clientY - rootElementY - shortcutYOffset + "px";
    };
    DragDropDOMAdapter.prototype.getShortcutBottomCoordinate = function (currentY, shortcutHeight, shortcutYOffset) {
        return currentY + shortcutHeight - shortcutYOffset;
    };
    DragDropDOMAdapter.prototype.getShortcutRightCoordinate = function (currentX, shortcutWidth, shortcutXOffset) {
        return currentX + shortcutWidth - shortcutXOffset;
    };
    DragDropDOMAdapter.prototype.requestAnimationFrame = function (callback) {
        return requestAnimationFrame(callback);
    };
    DragDropDOMAdapter.prototype.scrollByDrag = function (scrollableParentNode, clientY, clientX) {
        var _this = this;
        var startScrollBoundary = 100;
        var top;
        var bottom;
        var left;
        var right;
        if (scrollableParentNode.tagName === "HTML") {
            top = 0;
            bottom = document.documentElement.clientHeight;
            left = 0;
            right = document.documentElement.clientWidth;
        }
        else {
            top = scrollableParentNode.getBoundingClientRect().top;
            bottom = scrollableParentNode.getBoundingClientRect().bottom;
            left = scrollableParentNode.getBoundingClientRect().left;
            right = scrollableParentNode.getBoundingClientRect().right;
        }
        var repeat = function () {
            var isTop = clientY - top <= startScrollBoundary;
            var isBottom = bottom - clientY <= startScrollBoundary;
            var isLeft = clientX - left <= startScrollBoundary;
            var isRight = right - clientX <= startScrollBoundary;
            if (isTop && !isLeft && !isRight) {
                scrollableParentNode.scrollTop -= 15;
            }
            else if (isBottom && !isLeft && !isRight) {
                scrollableParentNode.scrollTop += 15;
            }
            else if (isRight && !isTop && !isBottom) {
                scrollableParentNode.scrollLeft += 15;
            }
            else if (isLeft && !isTop && !isBottom) {
                scrollableParentNode.scrollLeft -= 15;
            }
            _this.scrollIntervalId = _this.requestAnimationFrame(repeat);
        };
        this.scrollIntervalId = this.requestAnimationFrame(repeat);
    };
    DragDropDOMAdapter.prototype.doScroll = function (clientY, clientX) {
        cancelAnimationFrame(this.scrollIntervalId);
        var displayProp = this.draggedElementShortcut.style.display;
        //this.draggedElementShortcut.hidden = true;
        this.draggedElementShortcut.style.display = "none";
        var dragOverNode = this.documentOrShadowRoot.elementFromPoint(clientX, clientY);
        //this.draggedElementShortcut.hidden = false;
        this.draggedElementShortcut.style.display = displayProp || "block";
        var scrollableParentNode = findScrollableParent(dragOverNode);
        this.scrollByDrag(scrollableParentNode, clientY, clientX);
    };
    DragDropDOMAdapter.prototype.doStartDrag = function (event, draggedElement, parentElement, draggedElementNode) {
        if (IsTouch) {
            DragDropDOMAdapter.PreventScrolling = true;
        }
        if (event.which === 3)
            return; //right mouse btn
        this.dd.dragInit(event, draggedElement, parentElement, draggedElementNode);
        this.rootElement.append(this.draggedElementShortcut);
        this.moveShortcutElement(event);
        document.addEventListener("pointermove", this.dragOver);
        document.addEventListener("pointercancel", this.handlePointerCancel);
        document.addEventListener("keydown", this.handleEscapeButton);
        document.addEventListener("pointerup", this.drop);
        if (!IsTouch) {
            this.draggedElementShortcut.addEventListener("pointerup", this.drop);
        }
        else {
            this.draggedElementShortcut.addEventListener("contextmenu", this.onContextMenu);
        }
    };
    DragDropDOMAdapter.prototype.returnUserSelectBack = function () {
        document.body.style.setProperty("touch-action", "auto");
        document.body.style.setProperty("user-select", "auto");
        document.body.style.setProperty("-webkit-user-select", "auto");
        //document.body.style.setProperty("-webkit-touch-callout", "default");
    };
    DragDropDOMAdapter.prototype.startDrag = function (event, draggedElement, parentElement, draggedElementNode, preventSaveTargetNode) {
        if (preventSaveTargetNode === void 0) { preventSaveTargetNode = false; }
        document.body.style.setProperty("user-select", "none", "important");
        document.body.style.setProperty("-webkit-user-select", "none", "important");
        if (IsTouch) {
            this.startLongTapProcessing(event, draggedElement, parentElement, draggedElementNode, preventSaveTargetNode);
            return;
        }
        this.doStartDrag(event, draggedElement, parentElement, draggedElementNode);
    };
    DragDropDOMAdapter.prototype.getNodeIndexInParent = function (node) {
        return dom_adapter_spreadArray([], node.parentElement.childNodes).indexOf(node);
    };
    DragDropDOMAdapter.prototype.insertNodeToParentAtIndex = function (parent, node, index) {
        parent.insertBefore(node, parent.childNodes[index]);
    };
    DragDropDOMAdapter.PreventScrolling = false;
    return DragDropDOMAdapter;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/dragdrop/core.ts



var core_DragDropCore = /** @class */ (function () {
    function DragDropCore(surveyValue, creator, longTap, domAdapter) {
        var _this = this;
        var _a;
        this.surveyValue = surveyValue;
        this.creator = creator;
        this._isBottom = null;
        this.onGhostPositionChanged = new EventBase();
        this.onDragStart = new EventBase();
        this.onDragEnd = new EventBase();
        this.onDragClear = new EventBase();
        this.onBeforeDrop = this.onDragStart;
        this.onAfterDrop = this.onDragEnd;
        this.draggedElement = null;
        this.dropTarget = null;
        this.prevDropTarget = null;
        this.allowDropHere = false;
        this.banDropHere = function () {
            _this.allowDropHere = false;
            _this.doBanDropHere();
            _this.dropTarget = null;
            _this.domAdapter.draggedElementShortcut.style.cursor = "not-allowed";
            _this.isBottom = null;
        };
        this.doBanDropHere = function () { };
        this.domAdapter = domAdapter || new dom_adapter_DragDropDOMAdapter(this, longTap, (_a = this.survey) === null || _a === void 0 ? void 0 : _a.fitToContainer);
    }
    Object.defineProperty(DragDropCore.prototype, "isBottom", {
        get: function () {
            return !!this._isBottom;
        },
        set: function (val) {
            this._isBottom = val;
            this.ghostPositionChanged();
        },
        enumerable: false,
        configurable: true
    });
    DragDropCore.prototype.ghostPositionChanged = function () {
        this.onGhostPositionChanged.fire({}, {});
    };
    Object.defineProperty(DragDropCore.prototype, "dropTargetDataAttributeName", {
        get: function () {
            return "[data-sv-drop-target-" + this.draggedElementType + "]";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DragDropCore.prototype, "survey", {
        get: function () {
            var _a;
            return this.surveyValue || ((_a = this.creator) === null || _a === void 0 ? void 0 : _a.survey);
        },
        enumerable: false,
        configurable: true
    });
    DragDropCore.prototype.startDrag = function (event, draggedElement, parentElement, draggedElementNode, preventSaveTargetNode) {
        if (preventSaveTargetNode === void 0) { preventSaveTargetNode = false; }
        this.domAdapter.rootContainer = this.getRootElement(this.survey, this.creator);
        this.domAdapter.startDrag(event, draggedElement, parentElement, draggedElementNode, preventSaveTargetNode);
    };
    DragDropCore.prototype.getRootElement = function (survey, creator) {
        return creator ? creator.rootElement : survey.rootElement;
    };
    DragDropCore.prototype.dragInit = function (event, draggedElement, parentElement, draggedElementNode) {
        this.draggedElement = draggedElement;
        this.parentElement = parentElement;
        var shortcutText = this.getShortcutText(this.draggedElement);
        this.domAdapter.draggedElementShortcut = this.createDraggedElementShortcut(shortcutText, draggedElementNode, event);
        this.onStartDrag(event);
        var fromElement = this.draggedElement && this.draggedElement.parent;
        this.onDragStart.fire(this, { fromElement: fromElement, draggedElement: this.draggedElement });
    };
    DragDropCore.prototype.onStartDrag = function (event) {
    };
    DragDropCore.prototype.isDropTargetDoesntChanged = function (newIsBottom) {
        return (this.dropTarget === this.prevDropTarget && newIsBottom === this.isBottom);
    };
    DragDropCore.prototype.getShortcutText = function (draggedElement) {
        return draggedElement === null || draggedElement === void 0 ? void 0 : draggedElement.shortcutText;
    };
    DragDropCore.prototype.createDraggedElementShortcut = function (text, draggedElementNode, event) {
        var draggedElementShortcut = DomDocumentHelper.createElement("div");
        if (!!draggedElementShortcut) {
            draggedElementShortcut.innerText = text;
            draggedElementShortcut.className = this.getDraggedElementClass();
        }
        return draggedElementShortcut;
    };
    DragDropCore.prototype.getDraggedElementClass = function () {
        return "sv-dragged-element-shortcut";
    };
    DragDropCore.prototype.doDragOver = function () { };
    DragDropCore.prototype.afterDragOver = function (dropTargetNode) { };
    DragDropCore.prototype.findDropTargetNodeFromPoint = function (clientX, clientY) {
        var displayProp = this.domAdapter.draggedElementShortcut.style.display;
        //this.domAdapter.draggedElementShortcut.hidden = true;
        this.domAdapter.draggedElementShortcut.style.display = "none";
        if (!DomDocumentHelper.isAvailable())
            return null;
        var dragOverNode = this.domAdapter.documentOrShadowRoot.elementFromPoint(clientX, clientY);
        // this.domAdapter.draggedElementShortcut.hidden = false;
        this.domAdapter.draggedElementShortcut.style.display = displayProp || "block";
        if (!dragOverNode)
            return null;
        return this.findDropTargetNodeByDragOverNode(dragOverNode);
    };
    DragDropCore.prototype.getDataAttributeValueByNode = function (node) {
        var _this = this;
        var datasetName = "svDropTarget";
        var words = this.draggedElementType.split("-");
        words.forEach(function (word) {
            datasetName += _this.capitalizeFirstLetter(word);
        });
        return node.dataset[datasetName];
    };
    DragDropCore.prototype.getDropTargetByNode = function (dropTargetNode, event) {
        var dataAttributeValue = this.getDataAttributeValueByNode(dropTargetNode);
        return this.getDropTargetByDataAttributeValue(dataAttributeValue, dropTargetNode, event);
    };
    DragDropCore.prototype.capitalizeFirstLetter = function (string) {
        return string.charAt(0).toUpperCase() + string.slice(1);
    };
    DragDropCore.prototype.calculateVerticalMiddleOfHTMLElement = function (HTMLElement) {
        var rect = HTMLElement.getBoundingClientRect();
        return rect.y + rect.height / 2;
    };
    DragDropCore.prototype.calculateHorizontalMiddleOfHTMLElement = function (HTMLElement) {
        var rect = HTMLElement.getBoundingClientRect();
        return rect.x + rect.width / 2;
    };
    DragDropCore.prototype.calculateIsBottom = function (clientY, dropTargetNode) {
        return false;
    };
    DragDropCore.prototype.findDropTargetNodeByDragOverNode = function (dragOverNode) {
        var dropTargetNode = dragOverNode.closest(this.dropTargetDataAttributeName);
        return dropTargetNode;
    };
    DragDropCore.prototype.dragOver = function (event) {
        var dropTargetNode = this.findDropTargetNodeFromPoint(event.clientX, event.clientY);
        if (!dropTargetNode) {
            this.banDropHere();
            return;
        }
        this.dropTarget = this.getDropTargetByNode(dropTargetNode, event);
        var isDropTargetValid = this.isDropTargetValid(this.dropTarget, dropTargetNode);
        this.doDragOver();
        if (!isDropTargetValid) {
            this.banDropHere();
            return;
        }
        var isBottom = this.calculateIsBottom(event.clientY, dropTargetNode);
        this.allowDropHere = true;
        if (this.isDropTargetDoesntChanged(isBottom))
            return;
        this.isBottom = null; //TODO need for property change trigger with guarantee but it would be better not to watch on isBottom property but have some event like onValidTargetDragOver
        this.isBottom = isBottom;
        if (this.draggedElement != this.dropTarget) {
            this.afterDragOver(dropTargetNode);
        }
        this.prevDropTarget = this.dropTarget;
    };
    DragDropCore.prototype.drop = function () {
        if (this.allowDropHere) {
            var fromElement = this.draggedElement.parent;
            var newElement = this.doDrop();
            this.onDragEnd.fire(this, { fromElement: fromElement, draggedElement: newElement, toElement: this.dropTarget });
        }
    };
    DragDropCore.prototype.clear = function () {
        this.dropTarget = null;
        this.prevDropTarget = null;
        this.draggedElement = null;
        this.isBottom = null;
        this.parentElement = null;
        this.onDragClear.fire(this, {});
    };
    return DragDropCore;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/dragdrop/matrix-rows.ts
var matrix_rows_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();


var matrix_rows_DragDropMatrixRows = /** @class */ (function (_super) {
    matrix_rows_extends(DragDropMatrixRows, _super);
    function DragDropMatrixRows() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.fromIndex = null;
        _this.toIndex = null;
        _this.doDrop = function () {
            _this.parentElement.moveRowByIndex(_this.fromIndex, _this.toIndex);
            return _this.parentElement;
        };
        return _this;
    }
    Object.defineProperty(DragDropMatrixRows.prototype, "draggedElementType", {
        get: function () {
            return "matrix-row";
        },
        enumerable: false,
        configurable: true
    });
    DragDropMatrixRows.prototype.onStartDrag = function () {
        var _body = DomDocumentHelper.getBody();
        if (!!_body) {
            this.restoreUserSelectValue = _body.style.userSelect;
            _body.style.userSelect = "none";
        }
    };
    DragDropMatrixRows.prototype.createDraggedElementShortcut = function (text, draggedElementNode, event) {
        var _this = this;
        var draggedElementShortcut = DomDocumentHelper.createElement("div");
        if (!draggedElementShortcut)
            return;
        // draggedElementShortcut.innerText = text;
        draggedElementShortcut.style.cssText = " \n          cursor: grabbing;\n          position: absolute;\n          z-index: 10000;\n          font-family: var(--sjs-font-family, var(--font-family, var(--sjs-default-font-family)));\n        ";
        var isDeepClone = true;
        if (!!draggedElementNode) {
            var row = (draggedElementNode
                .closest("[data-sv-drop-target-matrix-row]"));
            var clone = (row.cloneNode(isDeepClone));
            clone.style.cssText = "\n        box-shadow: var(--sjs-shadow-large, 0px 8px 16px 0px rgba(0, 0, 0, 0.1)), var(--sjs-shadow-medium, 0px 2px 6px 0px rgba(0, 0, 0, 0.1));\n        background-color: var(--sjs-general-backcolor, var(--background, #fff));\n        display: flex;\n        flex-grow: 0;\n        flex-shrink: 0;\n        align-items: center;\n        line-height: 0;\n        width: " + row.offsetWidth + "px;\n      ";
            clone.classList.remove("sv-matrix__drag-drop--moveup");
            clone.classList.remove("sv-matrix__drag-drop--movedown");
            this.draggedElement.isDragDropMoveDown = false;
            this.draggedElement.isDragDropMoveUp = false;
            draggedElementShortcut.appendChild(clone);
            var rect = draggedElementNode.getBoundingClientRect();
            draggedElementShortcut.shortcutXOffset = event.clientX - rect.x;
            draggedElementShortcut.shortcutYOffset = event.clientY - rect.y;
        }
        //this.isBottom = null;
        var renderedRows = this.parentElement.renderedTable.rows;
        renderedRows.forEach(function (renderedRow, index) {
            if (renderedRow.row === _this.draggedElement) {
                renderedRow.isGhostRow = true;
            }
        });
        this.fromIndex = this.parentElement.visibleRows.indexOf(this.draggedElement);
        return draggedElementShortcut;
    };
    // protected ghostPositionChanged(): void {
    //   let ghostPosition;
    //   this.parentElement.renderedTable.rows.forEach(
    //     (renderedRow: QuestionMatrixDropdownRenderedRow) => {
    //       ghostPosition = this.getGhostPosition(
    //         renderedRow.row
    //       );
    //       renderedRow.isGhostRow = !ghostPosition;
    //     }
    //   );
    //   super.ghostPositionChanged();
    // }
    DragDropMatrixRows.prototype.getDropTargetByDataAttributeValue = function (dataAttributeValue) {
        var matrix = this.parentElement;
        var dropTargetRenderedRow;
        dropTargetRenderedRow = matrix.renderedTable.rows.filter(function (renderedRow) { return renderedRow.row && renderedRow.row.id === dataAttributeValue; })[0];
        return dropTargetRenderedRow.row;
    };
    DragDropMatrixRows.prototype.canInsertIntoThisRow = function (row) {
        var lockedRows = this.parentElement.lockedRowCount;
        return lockedRows <= 0 || row.rowIndex > lockedRows;
    };
    DragDropMatrixRows.prototype.isDropTargetValid = function (dropTarget, dropTargetNode) {
        return this.canInsertIntoThisRow(dropTarget);
    };
    DragDropMatrixRows.prototype.calculateIsBottom = function (clientY) {
        var rendreredRows = this.parentElement.renderedTable.rows;
        var rows = rendreredRows.map(function (rendredRow) { return rendredRow.row; });
        return (rows.indexOf(this.dropTarget) - rows.indexOf(this.draggedElement) > 0);
    };
    DragDropMatrixRows.prototype.afterDragOver = function (dropTargetNode) {
        var _this = this;
        if (this.isDropTargetDoesntChanged(this.isBottom))
            return;
        var dropTargetIndex;
        var draggedElementIndex;
        var draggedRenderedRow;
        var renderedRows = this.parentElement.renderedTable.rows;
        renderedRows.forEach(function (renderedRow, index) {
            if (renderedRow.row === _this.dropTarget) {
                // renderedRow.isGhostRow = true;
                dropTargetIndex = index;
            }
            if (renderedRow.row === _this.draggedElement) {
                draggedRenderedRow = renderedRow;
                draggedElementIndex = index;
                draggedRenderedRow.isGhostRow = true;
            }
        });
        renderedRows.splice(draggedElementIndex, 1);
        renderedRows.splice(dropTargetIndex, 0, draggedRenderedRow);
        this.toIndex = this.parentElement.visibleRows.indexOf(this.dropTarget);
        // const matrix = this.parentElement;
        // const fromIndex = matrix.visibleRows.indexOf(this.draggedElement);
        // const toIndex = matrix.visibleRows.indexOf(this.dropTarget);
        // matrix.moveRowByIndex(fromIndex, toIndex);
        // if (draggedElementIndex !== dropTargetIndex) {
        //   dropTargetNode.classList.remove("sv-matrix__drag-drop--moveup");
        //   dropTargetNode.classList.remove("sv-matrix__drag-drop--movedown");
        //   this.dropTarget.isDragDropMoveDown = false;
        //   this.dropTarget.isDragDropMoveUp = false;
        // }
        // if (draggedElementIndex > dropTargetIndex) {
        //   this.dropTarget.isDragDropMoveDown = true;
        // }
        // if (draggedElementIndex < dropTargetIndex) {
        //   this.dropTarget.isDragDropMoveUp = true;
        // }
        _super.prototype.ghostPositionChanged.call(this);
    };
    DragDropMatrixRows.prototype.clear = function () {
        var renderedRows = this.parentElement.renderedTable.rows;
        renderedRows.forEach(function (renderedRow) {
            renderedRow.isGhostRow = false;
        });
        this.parentElement.clearOnDrop();
        this.fromIndex = null;
        this.toIndex = null;
        var _body = DomDocumentHelper.getBody();
        if (!!_body) {
            _body.style.userSelect = this.restoreUserSelectValue || "initial";
        }
        _super.prototype.clear.call(this);
    };
    return DragDropMatrixRows;
}(core_DragDropCore));


// CONCATENATED MODULE: ./packages/survey-core/src/utils/dragOrClickHelper.ts


var dragOrClickHelper_DragOrClickHelper = /** @class */ (function () {
    function DragOrClickHelper(dragHandler) {
        var _this = this;
        this.dragHandler = dragHandler;
        this.onPointerUp = function (pointerUpEvent) {
            _this.clearListeners();
        };
        this.tryToStartDrag = function (pointerMoveEvent) {
            _this.currentX = pointerMoveEvent.pageX;
            _this.currentY = pointerMoveEvent.pageY;
            if (_this.isMicroMovement)
                return;
            _this.clearListeners();
            _this.dragHandler(_this.pointerDownEvent, _this.currentTarget, _this.itemModel);
            return true;
        };
    }
    DragOrClickHelper.prototype.onPointerDown = function (pointerDownEvent, itemModel) {
        if (IsTouch) {
            this.dragHandler(pointerDownEvent, pointerDownEvent.currentTarget, itemModel); //TODO handle inside in the library's drag drop core, need refactoring
            return;
        }
        this.pointerDownEvent = pointerDownEvent;
        this.currentTarget = pointerDownEvent.currentTarget;
        this.startX = pointerDownEvent.pageX;
        this.startY = pointerDownEvent.pageY;
        DomDocumentHelper.addEventListener("pointermove", this.tryToStartDrag);
        this.currentTarget.addEventListener("pointerup", this.onPointerUp);
        this.itemModel = itemModel;
    };
    Object.defineProperty(DragOrClickHelper.prototype, "isMicroMovement", {
        // see https://stackoverflow.com/questions/6042202/how-to-distinguish-mouse-click-and-drag
        get: function () {
            var delta = 10;
            var diffX = Math.abs(this.currentX - this.startX);
            var diffY = Math.abs(this.currentY - this.startY);
            return diffX < delta && diffY < delta;
        },
        enumerable: false,
        configurable: true
    });
    DragOrClickHelper.prototype.clearListeners = function () {
        if (!this.pointerDownEvent)
            return;
        DomDocumentHelper.removeEventListener("pointermove", this.tryToStartDrag);
        this.currentTarget.removeEventListener("pointerup", this.onPointerUp);
    };
    return DragOrClickHelper;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/question_matrixdynamic.ts
var question_matrixdynamic_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();










var MatrixDynamicRowModel = /** @class */ (function (_super) {
    question_matrixdynamic_extends(MatrixDynamicRowModel, _super);
    function MatrixDynamicRowModel(index, data, value) {
        var _this = _super.call(this, data, value) || this;
        _this.index = index;
        _this.buildCells(value);
        return _this;
    }
    Object.defineProperty(MatrixDynamicRowModel.prototype, "rowName", {
        get: function () {
            return this.id;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDynamicRowModel.prototype, "dataName", {
        get: function () {
            return "row" + (this.index + 1);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixDynamicRowModel.prototype, "text", {
        get: function () {
            return "row " + (this.index + 1);
        },
        enumerable: false,
        configurable: true
    });
    MatrixDynamicRowModel.prototype.getAccessbilityText = function () {
        return (this.index + 1).toString();
    };
    Object.defineProperty(MatrixDynamicRowModel.prototype, "shortcutText", {
        get: function () {
            var matrix = this.data;
            var index = matrix.visibleRows.indexOf(this) + 1;
            var questionValue1 = this.cells.length > 1 ? this.cells[1]["questionValue"] : undefined;
            var questionValue0 = this.cells.length > 0 ? this.cells[0]["questionValue"] : undefined;
            return (questionValue1 && questionValue1.value ||
                questionValue0 && questionValue0.value ||
                "" + index);
        },
        enumerable: false,
        configurable: true
    });
    return MatrixDynamicRowModel;
}(question_matrixdropdownbase_MatrixDropdownRowModelBase));

/**
  * A class that describes the Dynamic Matrix question type.
  *
  * Dynamic Matrix allows respondents to add and delete matrix rows. You can use the [Dropdown](https://surveyjs.io/form-library/documentation/questiondropdownmodel), [Checkbox](https://surveyjs.io/form-library/documentation/questioncheckboxmodel), [Radiogroup](https://surveyjs.io/form-library/documentation/questionradiogroupmodel), [Text](https://surveyjs.io/form-library/documentation/questiontextmodel), and [Comment](https://surveyjs.io/form-library/documentation/questioncommentmodel) question types as cell editors.
  *
  * [View Demo](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/ (linkStyle))
  */
var question_matrixdynamic_QuestionMatrixDynamicModel = /** @class */ (function (_super) {
    question_matrixdynamic_extends(QuestionMatrixDynamicModel, _super);
    function QuestionMatrixDynamicModel(name) {
        var _this = _super.call(this, name) || this;
        _this.rowCounter = 0;
        _this.setRowCountValueFromData = false;
        _this.startDragMatrixRow = function (event, currentTarget) {
            _this.dragDropMatrixRows.startDrag(event, _this.draggedRow, _this, event.target);
        };
        _this.initialRowCount = _this.getDefaultPropertyValue("rowCount");
        _this.createLocalizableString("confirmDeleteText", _this, false, "confirmDelete");
        var locAddRowText = _this.createLocalizableString("addRowText", _this);
        locAddRowText.onGetTextCallback = function (text) {
            return !!text ? text : _this.defaultAddRowText;
        };
        _this.createLocalizableString("removeRowText", _this, false, "removeRow");
        _this.createLocalizableString("emptyRowsText", _this, false, true);
        _this.registerPropertyChangedHandlers(["hideColumnsIfEmpty", "allowAddRows"], function () {
            _this.updateShowTableAndAddRow();
        });
        _this.registerPropertyChangedHandlers(["allowRowsDragAndDrop", "isReadOnly", "lockedRowCount"], function () { _this.clearRowsAndResetRenderedTable(); });
        _this.dragOrClickHelper = new dragOrClickHelper_DragOrClickHelper(_this.startDragMatrixRow);
        return _this;
    }
    QuestionMatrixDynamicModel.prototype.setSurveyImpl = function (value, isLight) {
        _super.prototype.setSurveyImpl.call(this, value, isLight);
        this.dragDropMatrixRows = new matrix_rows_DragDropMatrixRows(this.survey, null, true);
    };
    QuestionMatrixDynamicModel.prototype.isBanStartDrag = function (pointerDownEvent) {
        var target = pointerDownEvent.target;
        return target.getAttribute("contenteditable") === "true" || target.nodeName === "INPUT" || !this.isDragHandleAreaValid(target);
    };
    QuestionMatrixDynamicModel.prototype.isDragHandleAreaValid = function (node) {
        if (this.survey.matrixDragHandleArea === "icon") {
            return node.classList.contains(this.cssClasses.dragElementDecorator);
        }
        return true;
    };
    QuestionMatrixDynamicModel.prototype.onPointerDown = function (pointerDownEvent, row) {
        if (!row || !this.isRowsDragAndDrop)
            return;
        if (this.isBanStartDrag(pointerDownEvent))
            return;
        if (row.isDetailPanelShowing)
            return;
        this.draggedRow = row;
        this.dragOrClickHelper.onPointerDown(pointerDownEvent);
    };
    QuestionMatrixDynamicModel.prototype.getType = function () {
        return "matrixdynamic";
    };
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "isRowsDynamic", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "confirmDelete", {
        /**
         * Specifies whether to display a confirmation dialog when a respondent wants to delete a row.
         *
         * Default value: `false`
         * @see confirmDeleteText
         */
        get: function () {
            return this.getPropertyValue("confirmDelete");
        },
        set: function (val) {
            this.setPropertyValue("confirmDelete", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "isValueArray", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "keyName", {
        /**
         * Specifies a key column. Set this property to a column name, and the question will display `keyDuplicationError` if a user tries to enter a duplicate value in this column.
         * @see keyDuplicationError
         */
        get: function () {
            return this.getPropertyValue("keyName", "");
        },
        set: function (val) {
            this.setPropertyValue("keyName", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "defaultRowValue", {
        /**
         * If it is not empty, then this value is set to every new row, including rows created initially, unless the defaultValue is not empty
         * @see defaultValue
         * @see defaultValueFromLastRow
         */
        get: function () {
            return this.getPropertyValue("defaultRowValue");
        },
        set: function (val) {
            this.setPropertyValue("defaultRowValue", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "defaultValueFromLastRow", {
        /**
         * Specifies whether default values for a new row/column should be copied from the last row/column.
         *
         * If you also specify `defaultValue`, it will be merged with the copied values.
         * @see defaultValue
         */
        get: function () {
            return this.getPropertyValue("defaultValueFromLastRow");
        },
        set: function (val) {
            this.setPropertyValue("defaultValueFromLastRow", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDynamicModel.prototype.isDefaultValueEmpty = function () {
        return (_super.prototype.isDefaultValueEmpty.call(this) && this.isValueEmpty(this.defaultRowValue));
    };
    QuestionMatrixDynamicModel.prototype.valueFromData = function (val) {
        if (this.minRowCount < 1)
            return _super.prototype.valueFromData.call(this, val);
        if (!Array.isArray(val))
            val = [];
        for (var i = val.length; i < this.minRowCount; i++)
            val.push({});
        return val;
    };
    QuestionMatrixDynamicModel.prototype.isNewValueCorrect = function (val) {
        return Array.isArray(val);
    };
    QuestionMatrixDynamicModel.prototype.setDefaultValue = function () {
        if (this.isValueEmpty(this.defaultRowValue) ||
            !this.isValueEmpty(this.defaultValue)) {
            _super.prototype.setDefaultValue.call(this);
            return;
        }
        if (!this.isEmpty() || this.rowCount == 0)
            return;
        var newValue = [];
        for (var i = 0; i < this.rowCount; i++) {
            newValue.push(this.defaultRowValue);
        }
        this.value = newValue;
    };
    QuestionMatrixDynamicModel.prototype.moveRowByIndex = function (fromIndex, toIndex) {
        var value = this.createNewValue();
        if (!Array.isArray(value) && Math.max(fromIndex, toIndex) >= value.length)
            return;
        var movableRow = value[fromIndex];
        value.splice(fromIndex, 1);
        value.splice(toIndex, 0, movableRow);
        this.value = value;
    };
    QuestionMatrixDynamicModel.prototype.clearOnDrop = function () {
        if (!this.isEditingSurveyElement) {
            this.resetRenderedTable();
        }
    };
    QuestionMatrixDynamicModel.prototype.initDataUI = function () {
        if (!this.generatedVisibleRows) {
            this.visibleRows;
        }
    };
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "rowCount", {
        /**
         * The number of rows in the matrix.
         * @see minRowCount
         * @see maxRowCount
         */
        get: function () {
            return this.rowCountValue;
        },
        set: function (val) {
            if (val < 0 || val > settings.matrix.maxRowCount)
                return;
            this.setRowCountValueFromData = false;
            var prevValue = this.rowCountValue;
            this.rowCountValue = val;
            if (this.value && this.value.length > val) {
                var qVal = this.value;
                qVal.splice(val);
                this.value = qVal;
            }
            if (this.isUpdateLocked) {
                this.initialRowCount = val;
                return;
            }
            if (this.generatedVisibleRows || prevValue == 0) {
                if (!this.generatedVisibleRows) {
                    this.generatedVisibleRows = [];
                }
                this.generatedVisibleRows.splice(val);
                for (var i = prevValue; i < val; i++) {
                    var newRow = this.createMatrixRow(this.getValueForNewRow());
                    this.generatedVisibleRows.push(newRow);
                    this.onMatrixRowCreated(newRow);
                }
                this.runCondition(this.getDataFilteredValues(), this.getDataFilteredProperties());
            }
            this.onRowsChanged();
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDynamicModel.prototype.updateProgressInfoByValues = function (res) {
        var val = this.value;
        if (!Array.isArray(val))
            val = [];
        for (var i = 0; i < this.rowCount; i++) {
            var rowValue = i < val.length ? val[i] : {};
            this.updateProgressInfoByRow(res, rowValue);
        }
    };
    QuestionMatrixDynamicModel.prototype.getValueForNewRow = function () {
        var res = null;
        if (!!this.onGetValueForNewRowCallBack) {
            res = this.onGetValueForNewRowCallBack(this);
        }
        return res;
    };
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "allowRowsDragAndDrop", {
        /**
         * Specifies whether users can drag and drop matrix rows to reorder them. Applies only if [`transposeData`](#transposeData) is `false`.
         *
         * Default value: `false`
         */
        get: function () {
            return this.getPropertyValue("allowRowsDragAndDrop");
        },
        set: function (val) {
            this.setPropertyValue("allowRowsDragAndDrop", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "isRowsDragAndDrop", {
        get: function () {
            return this.allowRowsDragAndDrop && !this.isReadOnly;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "lockedRowCount", {
        get: function () {
            return this.getPropertyValue("lockedRowCount", 0);
        },
        set: function (val) {
            this.setPropertyValue("lockedRowCount", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "iconDragElement", {
        get: function () {
            return this.cssClasses.iconDragElement;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDynamicModel.prototype.createRenderedTable = function () {
        return new QuestionMatrixDynamicRenderedTable(this);
    };
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "rowCountValue", {
        get: function () {
            return this.getPropertyValue("rowCount");
        },
        set: function (val) {
            this.setPropertyValue("rowCount", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "minRowCount", {
        /**
         * A minimum number of rows in the matrix. Users cannot delete rows if `rowCount` equals `minRowCount`.
         *
         * Default value: 0
         * @see rowCount
         * @see maxRowCount
         * @see allowRemoveRows
         */
        get: function () {
            return this.getPropertyValue("minRowCount");
        },
        set: function (val) {
            if (val < 0)
                val = 0;
            this.setPropertyValue("minRowCount", val);
            if (val > this.maxRowCount)
                this.maxRowCount = val;
            if (this.rowCount < val)
                this.rowCount = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "maxRowCount", {
        /**
         * A maximum number of rows in the matrix. Users cannot add new rows if `rowCount` equals `maxRowCount`.
         *
         * Default value: 1000 (inherited from [`settings.matrix.maxRowCount`](https://surveyjs.io/form-library/documentation/settings#matrixMaximumRowCount))
         * @see rowCount
         * @see minRowCount
         * @see allowAddRows
         */
        get: function () {
            return this.getPropertyValue("maxRowCount");
        },
        set: function (val) {
            if (val <= 0)
                return;
            if (val > settings.matrix.maxRowCount)
                val = settings.matrix.maxRowCount;
            if (val == this.maxRowCount)
                return;
            this.setPropertyValue("maxRowCount", val);
            if (val < this.minRowCount)
                this.minRowCount = val;
            if (this.rowCount > val)
                this.rowCount = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "allowAddRows", {
        /**
         * Specifies whether users are allowed to add new rows.
         *
         * Default value: `true`
         * @see canAddRow
         * @see allowRemoveRows
         */
        get: function () {
            return this.getPropertyValue("allowAddRows");
        },
        set: function (val) {
            this.setPropertyValue("allowAddRows", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "allowRemoveRows", {
        /**
         * Specifies whether users are allowed to delete rows.
         *
         * Default value: `true`
         * @see canRemoveRows
         * @see allowAddRows
         */
        get: function () {
            return this.getPropertyValue("allowRemoveRows");
        },
        set: function (val) {
            this.setPropertyValue("allowRemoveRows", val);
            if (!this.isUpdateLocked) {
                this.resetRenderedTable();
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "canAddRow", {
        /**
         * Indicates whether it is possible to add a new row.
         *
         * This property returns `true` when all of the following conditions apply:
         *
         * - Users are allowed to add new rows (`allowAddRows` is `true`).
         * - The question, its parent panel, or survey is not in read-only state.
         * - `rowCount` is less than `maxRowCount`.
         * @see allowAddRows
         * @see isReadOnly
         * @see rowCount
         * @see maxRowCount
         * @see canRemoveRows
         */
        get: function () {
            return (this.allowAddRows && !this.isReadOnly && this.rowCount < this.maxRowCount);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "canRemoveRows", {
        /**
         * Indicates whether it is possible to delete rows.
         *
         * This property returns `true` when all of the following conditions apply:
         *
         * - Users are allowed to delete rows (`allowRemoveRows` is `true`).
         * - The question, its parent panel, or survey is not in read-only state.
         * - `rowCount` exceeds `minRowCount`.
         * @see allowRemoveRows
         * @see isReadOnly
         * @see rowCount
         * @see minRowCount
         * @see canAddRow
         */
        get: function () {
            var res = this.allowRemoveRows &&
                !this.isReadOnly &&
                this.rowCount > this.minRowCount;
            return !!this.canRemoveRowsCallback ? this.canRemoveRowsCallback(res) : res;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDynamicModel.prototype.canRemoveRow = function (row) {
        if (!this.survey)
            return true;
        var index = row.rowIndex - 1;
        if (this.lockedRowCount > 0 && index < this.lockedRowCount)
            return false;
        return this.survey.matrixAllowRemoveRow(this, index, row);
    };
    QuestionMatrixDynamicModel.prototype.addRowUI = function () {
        this.addRow(true);
    };
    QuestionMatrixDynamicModel.prototype.getQuestionToFocusOnAddingRow = function () {
        var row = this.visibleRows[this.visibleRows.length - 1];
        for (var i = 0; i < row.cells.length; i++) {
            var q = row.cells[i].question;
            if (!!q && q.isVisible && !q.isReadOnly) {
                return q;
            }
        }
        return null;
    };
    /**
     * Creates and adds a new row to the matrix.
     * @param setFocus *(Optional)* Pass `true` to focus the cell in the first column.
     */
    QuestionMatrixDynamicModel.prototype.addRow = function (setFocus) {
        var oldRowCount = this.rowCount;
        var allow = this.canAddRow;
        var options = { question: this, canAddRow: allow, allow: allow };
        if (!!this.survey) {
            this.survey.matrixBeforeRowAdded(options);
        }
        var newAllow = allow !== options.allow ? options.allow :
            (allow !== options.canAddRow ? options.canAddRow : allow);
        if (!newAllow)
            return;
        this.onStartRowAddingRemoving();
        this.addRowCore();
        this.onEndRowAdding();
        if (this.detailPanelShowOnAdding && this.visibleRows.length > 0) {
            this.visibleRows[this.visibleRows.length - 1].showDetailPanel();
        }
        if (setFocus && oldRowCount !== this.rowCount) {
            var q = this.getQuestionToFocusOnAddingRow();
            if (!!q) {
                q.focus();
            }
        }
    };
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "detailPanelShowOnAdding", {
        /**
         * Specifies whether to expand the detail section immediately when a respondent adds a new row.
         * @see detailPanelMode
         */
        get: function () {
            return this.getPropertyValue("detailPanelShowOnAdding");
        },
        set: function (val) {
            this.setPropertyValue("detailPanelShowOnAdding", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDynamicModel.prototype.hasRowsAsItems = function () {
        return false;
    };
    QuestionMatrixDynamicModel.prototype.unbindValue = function () {
        this.clearGeneratedRows();
        this.clearPropertyValue("value");
        this.rowCountValue = 0;
        _super.prototype.unbindValue.call(this);
    };
    QuestionMatrixDynamicModel.prototype.isValueSurveyElement = function (val) {
        return this.isEditingSurveyElement || _super.prototype.isValueSurveyElement.call(this, val);
    };
    QuestionMatrixDynamicModel.prototype.addRowCore = function () {
        var prevRowCount = this.rowCount;
        this.rowCount = this.rowCount + 1;
        var defaultValue = this.getDefaultRowValue(true);
        var newValue = null;
        if (!this.isValueEmpty(defaultValue)) {
            newValue = this.createNewValue();
            if (newValue.length == this.rowCount) {
                newValue[newValue.length - 1] = defaultValue;
                this.value = newValue;
            }
        }
        if (this.data) {
            this.runCellsCondition(this.getDataFilteredValues(), this.getDataFilteredProperties());
            if (this.isValueEmpty(defaultValue)) {
                var row = this.visibleRows[this.rowCount - 1];
                if (!this.isValueEmpty(row.value)) {
                    if (!newValue) {
                        newValue = this.createNewValue();
                    }
                    if (!this.isValueSurveyElement(newValue) &&
                        !this.isTwoValueEquals(newValue[newValue.length - 1], row.value)) {
                        newValue[newValue.length - 1] = row.value;
                        this.value = newValue;
                    }
                }
            }
        }
        if (this.survey) {
            if (prevRowCount + 1 == this.rowCount) {
                this.survey.matrixRowAdded(this, this.visibleRows[this.visibleRows.length - 1]);
                this.onRowsChanged();
            }
        }
    };
    QuestionMatrixDynamicModel.prototype.getDefaultRowValue = function (isRowAdded) {
        var res = null;
        for (var i = 0; i < this.columns.length; i++) {
            var q = this.columns[i].templateQuestion;
            if (!!q && !this.isValueEmpty(q.getDefaultValue())) {
                res = res || {};
                res[this.columns[i].name] = q.getDefaultValue();
            }
        }
        if (!this.isValueEmpty(this.defaultRowValue)) {
            for (var key in this.defaultRowValue) {
                res = res || {};
                res[key] = this.defaultRowValue[key];
            }
        }
        if (isRowAdded && this.defaultValueFromLastRow) {
            var val = this.value;
            if (!!val && Array.isArray(val) && val.length >= this.rowCount - 1) {
                var rowValue = val[this.rowCount - 2];
                for (var key in rowValue) {
                    res = res || {};
                    res[key] = rowValue[key];
                }
            }
        }
        return res;
    };
    QuestionMatrixDynamicModel.prototype.removeRowUI = function (value) {
        if (!!value && !!value.rowName) {
            var index = this.visibleRows.indexOf(value);
            if (index < 0)
                return;
            value = index;
        }
        this.removeRow(value);
    };
    QuestionMatrixDynamicModel.prototype.isRequireConfirmOnRowDelete = function (index) {
        if (!this.confirmDelete)
            return false;
        if (index < 0 || index >= this.rowCount)
            return false;
        var value = this.createNewValue();
        if (this.isValueEmpty(value) || !Array.isArray(value))
            return false;
        if (index >= value.length)
            return false;
        return !this.isValueEmpty(value[index]);
    };
    /**
     * Removes a matrix row with a specified index.
     * @param index A zero-based row index.
     * @param confirmDelete *(Optional)* A Boolean value that specifies whether to display a confirmation dialog. If you do not specify this parameter, the [`confirmDelete`](https://surveyjs.io/form-library/documentation/api-reference/dynamic-matrix-table-question-model#confirmDelete) property value is used.
     */
    QuestionMatrixDynamicModel.prototype.removeRow = function (index, confirmDelete) {
        var _this = this;
        if (!this.canRemoveRows)
            return;
        if (index < 0 || index >= this.rowCount)
            return;
        var row = !!this.visibleRows && index < this.visibleRows.length
            ? this.visibleRows[index]
            : null;
        if (confirmDelete === undefined) {
            confirmDelete = this.isRequireConfirmOnRowDelete(index);
        }
        if (confirmDelete) {
            confirmActionAsync(this.confirmDeleteText, function () { _this.removeRowAsync(index, row); }, undefined, this.getLocale(), this.survey.rootElement);
            return;
        }
        this.removeRowAsync(index, row);
    };
    QuestionMatrixDynamicModel.prototype.removeRowAsync = function (index, row) {
        if (!!row && !!this.survey && !this.survey.matrixRowRemoving(this, index, row))
            return;
        this.onStartRowAddingRemoving();
        this.removeRowCore(index);
        this.onEndRowRemoving(row);
    };
    QuestionMatrixDynamicModel.prototype.removeRowCore = function (index) {
        var row = this.generatedVisibleRows
            ? this.generatedVisibleRows[index]
            : null;
        if (this.generatedVisibleRows && index < this.generatedVisibleRows.length) {
            this.generatedVisibleRows.splice(index, 1);
        }
        this.rowCountValue--;
        if (this.value) {
            var val = [];
            if (Array.isArray(this.value) && index < this.value.length) {
                val = this.createValueCopy();
            }
            else {
                val = this.createNewValue();
            }
            val.splice(index, 1);
            val = this.deleteRowValue(val, null);
            this.isRowChanging = true;
            this.value = val;
            this.isRowChanging = false;
        }
        this.onRowsChanged();
        if (this.survey) {
            this.survey.matrixRowRemoved(this, index, row);
        }
    };
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "confirmDeleteText", {
        /**
         * A message displayed in a confirmation dialog that appears when a respondent wants to delete a row.
         * @see confirmDelete
         */
        get: function () {
            return this.getLocalizableStringText("confirmDeleteText");
        },
        set: function (val) {
            this.setLocalizableStringText("confirmDeleteText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "locConfirmDeleteText", {
        get: function () {
            return this.getLocalizableString("confirmDeleteText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "addRowText", {
        /**
         * A caption for the Add Row button.
         * @see addRowLocation
         */
        get: function () {
            return this.getLocalizableStringText("addRowText", this.defaultAddRowText);
        },
        set: function (val) {
            this.setLocalizableStringText("addRowText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "locAddRowText", {
        get: function () {
            return this.getLocalizableString("addRowText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "defaultAddRowText", {
        get: function () {
            return this.getLocalizationString(this.isColumnLayoutHorizontal ? "addRow" : "addColumn");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "addRowLocation", {
        /**
         * Specifies the location of the Add Row button.
         *
         * Possible values:
         *
         * - `"top"` - Displays the Add Row button at the top of the matrix.
         * - `"bottom"` - Displays the Add Row button at the bottom of the matrix.
         * - `"topBottom"` - Displays the Add Row button at the top and bottom of the matrix.
         *
         * Default value: `"top"` if [`transposeData`](#transposeData) is `true`; `"bottom"` if `transposeData` is `false` or the matrix is in compact mode.
         * @see addRowText
         */
        get: function () {
            return this.getPropertyValue("addRowLocation");
        },
        set: function (val) {
            this.setPropertyValue("addRowLocation", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDynamicModel.prototype.getAddRowLocation = function () {
        return this.addRowLocation;
    };
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "hideColumnsIfEmpty", {
        /**
         * Specifies whether to hide columns when the matrix does not contain any rows. If you enable this property, the matrix displays the `emptyRowsText` message and the Add Row button.
         *
         * Default value: `false`
         * @see emptyRowsText
         */
        get: function () {
            return this.getPropertyValue("hideColumnsIfEmpty");
        },
        set: function (val) {
            this.setPropertyValue("hideColumnsIfEmpty", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDynamicModel.prototype.getShowColumnsIfEmpty = function () {
        return this.hideColumnsIfEmpty;
    };
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "removeRowText", {
        /**
         * Use this property to change the default value of remove row button text.
         */
        get: function () {
            return this.getLocalizableStringText("removeRowText");
        },
        set: function (val) {
            this.setLocalizableStringText("removeRowText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "locRemoveRowText", {
        get: function () {
            return this.getLocalizableString("removeRowText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "emptyRowsText", {
        /**
         * A message displayed when the matrix does not contain any rows. Applies only if `hideColumnsIfEmpty` is enabled.
         * @see hideColumnsIfEmpty
         */
        get: function () {
            return this.getLocalizableStringText("emptyRowsText");
        },
        set: function (val) {
            this.setLocalizableStringText("emptyRowsText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "locEmptyRowsText", {
        get: function () {
            return this.getLocalizableString("emptyRowsText");
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDynamicModel.prototype.getDisplayValueCore = function (keysAsText, value) {
        if (!value || !Array.isArray(value))
            return value;
        var values = this.getUnbindValue(value);
        var rows = this.visibleRows;
        for (var i = 0; i < rows.length && i < values.length; i++) {
            var val = values[i];
            if (!val)
                continue;
            values[i] = this.getRowDisplayValue(keysAsText, rows[i], val);
        }
        return values;
    };
    QuestionMatrixDynamicModel.prototype.getConditionObjectRowName = function (index) {
        return "[" + index.toString() + "]";
    };
    QuestionMatrixDynamicModel.prototype.getConditionObjectsRowIndeces = function () {
        var res = [];
        var rowCount = Math.max(this.rowCount, 1);
        for (var i = 0; i < Math.min(settings.matrix.maxRowCountInCondition, rowCount); i++) {
            res.push(i);
        }
        return res;
    };
    QuestionMatrixDynamicModel.prototype.supportGoNextPageAutomatic = function () {
        return false;
    };
    Object.defineProperty(QuestionMatrixDynamicModel.prototype, "hasRowText", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixDynamicModel.prototype.onCheckForErrors = function (errors, isOnValueChanged) {
        _super.prototype.onCheckForErrors.call(this, errors, isOnValueChanged);
        if (!isOnValueChanged && this.hasErrorInMinRows()) {
            errors.push(new error_MinRowCountError(this.minRowCount, this));
        }
    };
    QuestionMatrixDynamicModel.prototype.hasErrorInMinRows = function () {
        if (this.minRowCount <= 0 || !this.isRequired || !this.generatedVisibleRows)
            return false;
        var setRowCount = 0;
        for (var rowIndex = 0; rowIndex < this.generatedVisibleRows.length; rowIndex++) {
            var row = this.generatedVisibleRows[rowIndex];
            if (!row.isEmpty)
                setRowCount++;
        }
        return setRowCount < this.minRowCount;
    };
    QuestionMatrixDynamicModel.prototype.getUniqueColumnsNames = function () {
        var res = _super.prototype.getUniqueColumnsNames.call(this);
        var name = this.keyName;
        if (!!name && res.indexOf(name) < 0) {
            res.push(name);
        }
        return res;
    };
    QuestionMatrixDynamicModel.prototype.generateRows = function () {
        var result = new Array();
        if (this.rowCount === 0)
            return result;
        var val = this.createNewValue();
        for (var i = 0; i < this.rowCount; i++) {
            result.push(this.createMatrixRow(this.getRowValueByIndex(val, i)));
        }
        if (!this.isValueEmpty(this.getDefaultRowValue(false))) {
            this.value = val;
        }
        return result;
    };
    QuestionMatrixDynamicModel.prototype.createMatrixRow = function (value) {
        return new MatrixDynamicRowModel(this.rowCounter++, this, value);
    };
    QuestionMatrixDynamicModel.prototype.getInsertedDeletedIndex = function (rows, val) {
        var len = Math.min(rows.length, val.length);
        for (var i = 0; i < len; i++) {
            if (val[i] !== rows[i].editingObj)
                return i;
        }
        return len;
    };
    QuestionMatrixDynamicModel.prototype.isEditingObjectValueChanged = function () {
        var val = this.value;
        if (!this.generatedVisibleRows || !this.isValueSurveyElement(val))
            return false;
        var lastDelRow = this.lastDeletedRow;
        this.lastDeletedRow = undefined;
        var rows = this.generatedVisibleRows;
        if (!Array.isArray(val) || Math.abs(rows.length - val.length) > 1 || rows.length === val.length)
            return false;
        var index = this.getInsertedDeletedIndex(rows, val);
        if (rows.length > val.length) {
            this.lastDeletedRow = rows[index];
            var row = rows[index];
            rows.splice(index, 1);
            if (this.isRendredTableCreated) {
                this.renderedTable.onRemovedRow(row);
            }
        }
        else {
            var newRow = undefined;
            if (!!lastDelRow && lastDelRow.editingObj === val[index]) {
                newRow = lastDelRow;
            }
            else {
                newRow = this.createMatrixRow(val[index]);
            }
            rows.splice(index, 0, newRow);
            if (!lastDelRow) {
                this.onMatrixRowCreated(newRow);
            }
            if (this.isRendredTableCreated) {
                this.renderedTable.onAddedRow(newRow, index);
            }
        }
        this.setPropertyValueDirectly("rowCount", val.length);
        return true;
    };
    QuestionMatrixDynamicModel.prototype.updateValueFromSurvey = function (newValue, clearData) {
        if (clearData === void 0) { clearData = false; }
        this.setRowCountValueFromData = true;
        _super.prototype.updateValueFromSurvey.call(this, newValue, clearData);
        this.setRowCountValueFromData = false;
    };
    QuestionMatrixDynamicModel.prototype.onBeforeValueChanged = function (val) {
        if (!val || !Array.isArray(val))
            return;
        var newRowCount = val.length;
        if (newRowCount == this.rowCount)
            return;
        if (!this.setRowCountValueFromData && newRowCount < this.initialRowCount)
            return;
        if (this.isEditingObjectValueChanged())
            return;
        this.setRowCountValueFromData = true;
        this.rowCountValue = newRowCount;
        if (!this.generatedVisibleRows)
            return;
        if (newRowCount == this.generatedVisibleRows.length + 1) {
            this.onStartRowAddingRemoving();
            var newValue = this.getRowValueByIndex(val, newRowCount - 1);
            var newRow = this.createMatrixRow(newValue);
            this.generatedVisibleRows.push(newRow);
            this.onMatrixRowCreated(newRow);
            this.onEndRowAdding();
        }
        else {
            this.clearGeneratedRows();
            this.generatedVisibleRows = this.visibleRows;
            this.onRowsChanged();
        }
        this.setRowCountValueFromData = false;
    };
    QuestionMatrixDynamicModel.prototype.createNewValue = function () {
        var result = this.createValueCopy();
        if (!result || !Array.isArray(result))
            result = [];
        if (result.length > this.rowCount)
            result.splice(this.rowCount);
        var rowValue = this.getDefaultRowValue(false);
        rowValue = rowValue || {};
        for (var i = result.length; i < this.rowCount; i++) {
            result.push(this.getUnbindValue(rowValue));
        }
        return result;
    };
    QuestionMatrixDynamicModel.prototype.deleteRowValue = function (newValue, row) {
        var isEmpty = true;
        for (var i = 0; i < newValue.length; i++) {
            if (this.isObject(newValue[i]) && Object.keys(newValue[i]).length > 0) {
                isEmpty = false;
                break;
            }
        }
        return isEmpty ? null : newValue;
    };
    QuestionMatrixDynamicModel.prototype.getRowValueByIndex = function (questionValue, index) {
        return Array.isArray(questionValue) &&
            index >= 0 &&
            index < questionValue.length
            ? questionValue[index]
            : null;
    };
    QuestionMatrixDynamicModel.prototype.getRowValueCore = function (row, questionValue, create) {
        if (create === void 0) { create = false; }
        if (!this.generatedVisibleRows)
            return {};
        var res = this.getRowValueByIndex(questionValue, this.generatedVisibleRows.indexOf(row));
        if (!res && create)
            res = {};
        return res;
    };
    QuestionMatrixDynamicModel.prototype.getAddRowButtonCss = function (isEmptySection) {
        if (isEmptySection === void 0) { isEmptySection = false; }
        return new CssClassBuilder()
            .append(this.cssClasses.button)
            .append(this.cssClasses.buttonAdd)
            .append(this.cssClasses.emptyRowsButton, isEmptySection)
            .toString();
    };
    QuestionMatrixDynamicModel.prototype.getRemoveRowButtonCss = function () {
        return new CssClassBuilder()
            .append(this.cssClasses.button)
            .append(this.cssClasses.buttonRemove)
            .toString();
    };
    QuestionMatrixDynamicModel.prototype.getRootCss = function () {
        var _a;
        return new CssClassBuilder().append(_super.prototype.getRootCss.call(this)).append(this.cssClasses.empty, !((_a = this.renderedTable) === null || _a === void 0 ? void 0 : _a.showTable)).toString();
    };
    return QuestionMatrixDynamicModel;
}(question_matrixdropdownbase_QuestionMatrixDropdownModelBase));

var QuestionMatrixDynamicRenderedTable = /** @class */ (function (_super) {
    question_matrixdynamic_extends(QuestionMatrixDynamicRenderedTable, _super);
    function QuestionMatrixDynamicRenderedTable() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    QuestionMatrixDynamicRenderedTable.prototype.setDefaultRowActions = function (row, actions) {
        _super.prototype.setDefaultRowActions.call(this, row, actions);
    };
    return QuestionMatrixDynamicRenderedTable;
}(question_matrixdropdownrendered_QuestionMatrixDropdownRenderedTable));
Serializer.addClass("matrixdynamic", [
    { name: "rowsVisibleIf:condition", visible: false },
    { name: "allowAddRows:boolean", default: true },
    { name: "allowRemoveRows:boolean", default: true },
    { name: "rowCount:number", default: 2, minValue: 0, isBindable: true },
    { name: "minRowCount:number", default: 0, minValue: 0 },
    {
        name: "maxRowCount:number",
        default: settings.matrix.maxRowCount,
    },
    { name: "keyName" },
    "defaultRowValue:rowvalue",
    "defaultValueFromLastRow:boolean",
    { name: "confirmDelete:boolean" },
    {
        name: "confirmDeleteText",
        dependsOn: "confirmDelete",
        visibleIf: function (obj) {
            return !obj || obj.confirmDelete;
        },
        serializationProperty: "locConfirmDeleteText",
    },
    {
        name: "addRowLocation",
        default: "default",
        choices: ["default", "top", "bottom", "topBottom"],
    },
    { name: "addRowText", serializationProperty: "locAddRowText" },
    { name: "removeRowText", serializationProperty: "locRemoveRowText" },
    "hideColumnsIfEmpty:boolean",
    {
        name: "emptyRowsText:text",
        serializationProperty: "locEmptyRowsText",
        dependsOn: "hideColumnsIfEmpty",
        visibleIf: function (obj) {
            return !obj || obj.hideColumnsIfEmpty;
        },
    },
    {
        name: "detailPanelShowOnAdding:boolean",
        dependsOn: "detailPanelMode",
        visibleIf: function (obj) {
            return obj.detailPanelMode !== "none";
        },
    },
    "allowRowsDragAndDrop:switch"
], function () {
    return new question_matrixdynamic_QuestionMatrixDynamicModel("");
}, "matrixdropdownbase");
questionfactory_QuestionFactory.Instance.registerQuestion("matrixdynamic", function (name) {
    var q = new question_matrixdynamic_QuestionMatrixDynamicModel(name);
    q.choices = [1, 2, 3, 4, 5];
    question_matrixdropdownbase_QuestionMatrixDropdownModelBase.addDefaultColumns(q);
    return q;
});

// CONCATENATED MODULE: ./packages/survey-core/src/defaultCss/defaultV2Css.ts
var surveyCss = {
    currentType: "",
    getCss: function () {
        var loc = this.currentType ? this[this.currentType] : defaultV2Css;
        if (!loc)
            loc = defaultV2Css;
        return loc;
    },
    getAvailableThemes: function () {
        return Object.keys(this).filter(function (propertyName) { return ["currentType", "getCss", "getAvailableThemes"].indexOf(propertyName) === -1; });
    }
};
var defaultV2Css = {
    root: "sd-root-modern",
    rootProgress: "sd-progress",
    rootMobile: "sd-root-modern--mobile",
    rootAnimationDisabled: "sd-root-modern--animation-disabled",
    rootReadOnly: "sd-root--readonly",
    rootCompact: "sd-root--compact",
    rootFitToContainer: "sd-root-modern--full-container",
    rootWrapper: "sd-root-modern__wrapper",
    rootWrapperFixed: "sd-root-modern__wrapper--fixed",
    rootWrapperHasImage: "sd-root-modern__wrapper--has-image",
    rootBackgroundImage: "sd-root_background-image",
    container: "sd-container-modern",
    header: "sd-title sd-container-modern__title",
    bodyContainer: "sv-components-row",
    body: "sd-body",
    bodyWithTimer: "sd-body--with-timer",
    clockTimerRoot: "sd-timer",
    clockTimerRootTop: "sd-timer--top",
    clockTimerRootBottom: "sd-timer--bottom",
    clockTimerProgress: "sd-timer__progress",
    clockTimerProgressAnimation: "sd-timer__progress--animation",
    clockTimerTextContainer: "sd-timer__text-container",
    clockTimerMinorText: "sd-timer__text--minor",
    clockTimerMajorText: "sd-timer__text--major",
    bodyEmpty: "sd-body sd-body--empty",
    bodyLoading: "sd-body--loading",
    footer: "sd-footer sd-body__navigation sd-clearfix",
    title: "sd-title",
    description: "sd-description",
    logo: "sd-logo",
    logoImage: "sd-logo__image",
    headerText: "sd-header__text",
    headerClose: "sd-hidden",
    navigationButton: "",
    bodyNavigationButton: "sd-btn",
    completedPage: "sd-completedpage",
    completedBeforePage: "sd-completed-before-page",
    timerRoot: "sd-body__timer",
    navigation: {
        complete: "sd-btn--action sd-navigation__complete-btn",
        prev: "sd-navigation__prev-btn",
        next: "sd-navigation__next-btn",
        start: "sd-navigation__start-btn",
        preview: "sd-navigation__preview-btn",
        edit: "sd-btn sd-btn--small",
    },
    panel: {
        contentFadeIn: "sd-element__content--fade-in",
        contentFadeOut: "sd-element__content--fade-out",
        fadeIn: "sd-element-wrapper--fade-in",
        fadeOut: "sd-element-wrapper--fade-out",
        asPage: "sd-panel--as-page",
        number: "sd-element__num",
        title: "sd-title sd-element__title sd-panel__title",
        titleExpandable: "sd-element__title--expandable",
        titleNumInline: "sd-element__title--num-inline",
        titleExpanded: "sd-element__title--expanded",
        titleCollapsed: "sd-element__title--collapsed",
        titleDisabled: "sd-element__title--disabled",
        titleHidden: "sd-element__title--hidden",
        titleOnExpand: "sd-panel__title--expanded",
        titleOnError: "sd-panel__title--error",
        titleBar: "sd-action-title-bar",
        description: "sd-description sd-panel__description",
        container: "sd-element sd-element--complex sd-panel sd-row__panel",
        withFrame: "sd-element--with-frame",
        content: "sd-element__content sd-panel__content",
        icon: "sd-panel__icon",
        iconExpanded: "sd-panel__icon--expanded",
        footer: "sd-panel__footer",
        requiredText: "sd-panel__required-text",
        header: "sd-panel__header sd-element__header sd-element__header--location-top",
        headerHidden: "sd-panel__header--hidden",
        collapsed: "sd-element--collapsed",
        expanded: "sd-element--expanded",
        expandable: "sd-element--expandable",
        expandableAnimating: "sd-elemenet--expandable--animating",
        nested: "sd-element--nested sd-element--nested-with-borders",
        invisible: "sd-element--invisible",
        navigationButton: "",
        compact: "sd-element--with-frame sd-element--compact",
        errorsContainer: "sd-panel__errbox sd-element__erbox sd-element__erbox--above-element"
    },
    paneldynamic: {
        mainRoot: "sd-element  sd-question sd-question--paneldynamic sd-element--complex sd-question--complex sd-row__question",
        empty: "sd-question--empty",
        root: "sd-paneldynamic",
        iconRemove: "sd-hidden",
        navigation: "sd-paneldynamic__navigation",
        title: "sd-title sd-element__title sd-question__title",
        header: "sd-paneldynamic__header sd-element__header",
        headerTab: "sd-paneldynamic__header-tab",
        button: "sd-action sd-paneldynamic__btn",
        buttonRemove: "sd-action--negative sd-paneldynamic__remove-btn",
        buttonAdd: "sd-paneldynamic__add-btn",
        buttonPrev: "sd-paneldynamic__prev-btn sd-action--icon sd-action",
        buttonPrevDisabled: "sd-action--disabled",
        buttonNextDisabled: "sd-action--disabled",
        buttonNext: "sd-paneldynamic__next-btn sd-action--icon sd-action",
        progressContainer: "sd-paneldynamic__progress-container",
        progress: "sd-progress",
        progressBar: "sd-progress__bar",
        nested: "sd-element--nested sd-element--nested-with-borders",
        progressText: "sd-paneldynamic__progress-text",
        separator: "sd-paneldynamic__separator",
        panelWrapper: "sd-paneldynamic__panel-wrapper",
        footer: "sd-paneldynamic__footer",
        panelFooter: "sd-paneldynamic__panel-footer",
        footerButtonsContainer: "sd-paneldynamic__buttons-container",
        panelsContainer: "sd-paneldynamic__panels-container",
        panelWrapperInRow: "sd-paneldynamic__panel-wrapper--in-row",
        panelWrapperFadeIn: "sd-paneldynamic__panel-wrapper--fade-in",
        panelWrapperFadeOut: "sd-paneldynamic__panel-wrapper--fade-out",
        panelWrapperList: "sd-paneldynamic__panel-wrapper--list",
        progressBtnIcon: "icon-progressbuttonv2",
        noEntriesPlaceholder: "sd-paneldynamic__placeholder sd-question__placeholder",
        compact: "sd-element--with-frame sd-element--compact",
        tabsRoot: "sd-tabs-toolbar",
        tabsLeft: "sd-tabs-toolbar--left",
        tabsRight: "sd-tabs-toolbar--right",
        tabsCenter: "sd-tabs-toolbar--center",
        tabs: {
            item: "sd-tab-item",
            itemPressed: "sd-tab-item--pressed",
            itemAsIcon: "sd-tab-item--icon",
            itemIcon: "sd-tab-item__icon",
            itemTitle: "sd-tab-item__title"
        }
    },
    progress: "sd-progress sd-body__progress",
    progressTop: "sd-body__progress--top",
    progressBottom: "sd-body__progress--bottom",
    progressBar: "sd-progress__bar",
    progressText: "sd-progress__text",
    progressButtonsRoot: "sd-progress-buttons",
    progressButtonsNumbered: "sd-progress-buttons--numbered",
    progressButtonsFitSurveyWidth: "sd-progress-buttons--fit-survey-width",
    progressButtonsContainerCenter: "sd-progress-buttons__container-center",
    progressButtonsContainer: "sd-progress-buttons__container",
    progressButtonsConnector: "sd-progress-buttons__connector",
    progressButtonsButton: "sd-progress-buttons__button",
    progressButtonsButtonBackground: "sd-progress-buttons__button-background",
    progressButtonsButtonContent: "sd-progress-buttons__button-content",
    progressButtonsHeader: "sd-progress-buttons__header",
    progressButtonsFooter: "sd-progress-buttons__footer",
    progressButtonsImageButtonLeft: "sd-progress-buttons__image-button-left",
    progressButtonsImageButtonRight: "sd-progress-buttons__image-button-right",
    progressButtonsImageButtonHidden: "sd-progress-buttons__image-button--hidden",
    progressButtonsListContainer: "sd-progress-buttons__list-container",
    progressButtonsList: "sd-progress-buttons__list",
    progressButtonsListElementPassed: "sd-progress-buttons__list-element--passed",
    progressButtonsListElementCurrent: "sd-progress-buttons__list-element--current",
    progressButtonsListElementNonClickable: "sd-progress-buttons__list-element--nonclickable",
    progressButtonsPageTitle: "sd-progress-buttons__page-title",
    progressButtonsPageDescription: "sd-progress-buttons__page-description",
    progressTextInBar: "sd-hidden",
    page: {
        root: "sd-page sd-body__page",
        emptyHeaderRoot: "sd-page__empty-header",
        title: "sd-title sd-page__title",
        description: "sd-description sd-page__description",
        errorsContainer: "sd-page__errbox"
    },
    pageTitle: "sd-title sd-page__title",
    pageDescription: "sd-description sd-page__description",
    row: "sd-row sd-clearfix",
    rowMultiple: "sd-row--multiple",
    rowCompact: "sd-row--compact",
    rowFadeIn: "sd-row--fade-in",
    rowDelayedFadeIn: "sd-row--delayed-fade-in",
    rowFadeOut: "sd-row--fade-out",
    pageRow: "sd-page__row",
    question: {
        contentFadeIn: "sd-element__content--fade-in",
        contentFadeOut: "sd-element__content--fade-out",
        fadeIn: "sd-element-wrapper--fade-in",
        fadeOut: "sd-element-wrapper--fade-out",
        mainRoot: "sd-element sd-question sd-row__question",
        flowRoot: "sd-element sd-question sd-row__question sd-row__question--flow",
        withFrame: "sd-element--with-frame",
        asCell: "sd-table__cell",
        answered: "sd-question--answered",
        header: "sd-question__header sd-element__header",
        headerLeft: "sd-question__header--location--left",
        headerTop: "sd-question__header--location-top sd-element__header--location-top",
        headerBottom: "sd-question__header--location--bottom",
        content: "sd-element__content sd-question__content",
        contentSupportContainerQueries: "sd-question__content--support-container-queries",
        contentLeft: "sd-question__content--left",
        titleNumInline: "sd-element__title--num-inline",
        titleLeftRoot: "sd-question--left",
        titleTopRoot: "sd-question--title-top",
        descriptionUnderInputRoot: "sd-question--description-under-input",
        titleBottomRoot: "sd-question--title-bottom",
        titleOnAnswer: "sd-question__title--answer",
        titleEmpty: "sd-question__title--empty",
        titleOnError: "sd-question__title--error",
        title: "sd-title sd-element__title sd-question__title",
        titleExpandable: "sd-element__title--expandable",
        titleExpanded: "sd-element__title--expanded",
        titleCollapsed: "sd-element__title--collapsed",
        titleDisabled: "sd-element__title--disabled",
        titleReadOnly: "sd-element__title--readonly",
        titleBar: "sd-action-title-bar",
        requiredText: "sd-question__required-text",
        number: "sd-element__num",
        description: "sd-description sd-question__description",
        descriptionUnderInput: "sd-description sd-question__description sd-question__description--under-input",
        comment: "sd-input sd-comment",
        other: "sd-input sd-comment",
        required: "sd-question--required",
        titleRequired: "sd-question__title--required",
        indent: 20,
        footer: "sd-question__footer",
        commentArea: "sd-question__comment-area",
        formGroup: "sd-question__form-group",
        hasError: "sd-question--error",
        hasErrorTop: "sd-question--error-top",
        hasErrorBottom: "sd-question--error-bottom",
        collapsed: "sd-element--collapsed",
        expandable: "sd-element--expandable",
        expandableAnimating: "sd-elemenet--expandable--animating",
        expanded: "sd-element--expanded",
        nested: "sd-element--nested",
        invisible: "sd-element--invisible",
        composite: "sd-element--complex sd-composite",
        disabled: "sd-question--disabled",
        readOnly: "sd-question--readonly",
        preview: "sd-question--preview",
        noPointerEventsMode: "sd-question--no-pointer-events",
        errorsContainer: "sd-element__erbox sd-question__erbox",
        errorsContainerTop: "sd-element__erbox--above-element sd-question__erbox--above-question",
        errorsContainerBottom: "sd-question__erbox--below-question"
    },
    image: {
        mainRoot: "sd-question sd-question--image",
        root: "sd-image",
        image: "sd-image__image",
        adaptive: "sd-image__image--adaptive",
        noImage: "sd-image__no-image",
        noImageSvgIconId: "icon-no-image",
        withFrame: ""
    },
    html: {
        mainRoot: "sd-question sd-row__question sd-question--html",
        root: "sd-html",
        withFrame: "",
        nested: "sd-element--nested sd-html--nested"
    },
    error: {
        root: "sd-error",
        icon: "",
        item: "",
        locationTop: "",
        locationBottom: ""
    },
    checkbox: {
        root: "sd-selectbase",
        rootMobile: "sd-selectbase--mobile",
        rootRow: "sd-selectbase--row",
        rootMultiColumn: "sd-selectbase--multi-column",
        item: "sd-item sd-checkbox sd-selectbase__item",
        itemOnError: "sd-item--error",
        itemSelectAll: "sd-checkbox--selectall",
        itemNone: "sd-checkbox--none",
        itemDisabled: "sd-item--disabled sd-checkbox--disabled",
        itemReadOnly: "sd-item--readonly sd-checkbox--readonly",
        itemPreview: "sd-item--preview sd-checkbox--preview",
        itemPreviewSvgIconId: "#icon-v2check",
        itemChecked: "sd-item--checked sd-checkbox--checked",
        itemHover: "sd-item--allowhover sd-checkbox--allowhover",
        itemInline: "sd-selectbase__item--inline",
        label: "sd-selectbase__label",
        labelChecked: "",
        itemControl: "sd-visuallyhidden sd-item__control sd-checkbox__control",
        itemDecorator: "sd-item__svg sd-checkbox__svg",
        itemSvgIconId: "#icon-v2check",
        controlLabel: "sd-item__control-label",
        materialDecorator: "sd-item__decorator sd-checkbox__decorator",
        other: "sd-input sd-comment sd-selectbase__other",
        column: "sd-selectbase__column",
    },
    radiogroup: {
        root: "sd-selectbase",
        rootMobile: "sd-selectbase--mobile",
        rootRow: "sd-selectbase--row",
        rootMultiColumn: "sd-selectbase--multi-column",
        item: "sd-item sd-radio sd-selectbase__item",
        itemOnError: "sd-item--error",
        itemInline: "sd-selectbase__item--inline",
        label: "sd-selectbase__label",
        labelChecked: "",
        itemDisabled: "sd-item--disabled sd-radio--disabled",
        itemReadOnly: "sd-item--readonly sd-radio--readonly",
        itemPreview: "sd-item--preview sd-radio--preview",
        itemPreviewSvgIconId: "#icon-v2check",
        itemChecked: "sd-item--checked sd-radio--checked",
        itemHover: "sd-item--allowhover sd-radio--allowhover",
        itemControl: "sd-visuallyhidden sd-item__control sd-radio__control",
        itemDecorator: "sd-item__svg sd-radio__svg",
        controlLabel: "sd-item__control-label",
        materialDecorator: "sd-item__decorator sd-radio__decorator",
        other: "sd-input sd-comment sd-selectbase__other",
        clearButton: "",
        column: "sd-selectbase__column"
    },
    boolean: {
        mainRoot: "sd-element sd-question sd-row__question sd-question--boolean",
        root: "sv_qcbc sv_qbln sd-scrollable-container sd-boolean-root",
        rootRadio: "sv_qcbc sv_qbln sd-scrollable-container sd-scrollable-container--compact",
        item: "sd-boolean",
        itemOnError: "sd-boolean--error",
        control: "sd-boolean__control sd-visuallyhidden",
        itemChecked: "sd-boolean--checked",
        itemExchanged: "sd-boolean--exchanged",
        itemIndeterminate: "sd-boolean--indeterminate",
        itemDisabled: "sd-boolean--disabled",
        itemReadOnly: "sd-boolean--readonly",
        itemPreview: "sd-boolean--preview",
        itemHover: "sd-boolean--allowhover",
        label: "sd-boolean__label",
        labelTrue: "sd-boolean__label--true",
        labelFalse: "sd-boolean__label--false",
        switch: "sd-boolean__switch",
        disabledLabel: "sd-checkbox__label--disabled",
        labelReadOnly: "sd-checkbox__label--readonly",
        labelPreview: "sd-checkbox__label--preview",
        sliderText: "sd-boolean__thumb-text",
        slider: "sd-boolean__thumb",
        sliderGhost: "sd-boolean__thumb-ghost",
        //radio
        radioItem: "sd-item",
        radioItemChecked: "sd-item--checked sd-radio--checked",
        radioItemDisabled: "sd-item--disabled sd-radio--disabled",
        radioItemReadOnly: "sd-item--readonly sd-radio--readonly",
        radioItemPreview: "sd-item--preview sd-radio--preview",
        itemPreviewSvgIconId: "#icon-v2check",
        radioLabel: "sd-selectbase__label",
        radioControlLabel: "sd-item__control-label",
        radioFieldset: "sd-selectbase",
        itemRadioDecorator: "sd-item__svg sd-radio__svg",
        materialRadioDecorator: "sd-item__decorator sd-radio__decorator",
        itemRadioControl: "sd-visuallyhidden sd-item__control sd-radio__control",
        //end radio
        //checkbox
        rootCheckbox: "sd-selectbase",
        checkboxItem: "sd-item sd-selectbase__item sd-checkbox",
        checkboxLabel: "sd-selectbase__label",
        checkboxItemOnError: "sd-item--error",
        checkboxItemIndeterminate: "sd-checkbox--intermediate",
        checkboxItemChecked: "sd-item--checked sd-checkbox--checked",
        checkboxItemDecorator: "sd-item__svg sd-checkbox__svg",
        checkboxItemDisabled: "sd-item--disabled sd-checkbox--disabled",
        checkboxItemReadOnly: "sd-item--readonly sd-checkbox--readonly",
        checkboxItemPreview: "sd-item--preview sd-checkbox--preview",
        controlCheckbox: "sd-visuallyhidden sd-item__control sd-checkbox__control",
        checkboxMaterialDecorator: "sd-item__decorator sd-checkbox__decorator",
        checkboxControlLabel: "sd-item__control-label",
        svgIconCheckedId: "#icon-v2check",
    },
    text: {
        root: "sd-input sd-text",
        small: "sd-row__question--small",
        controlDisabled: "sd-input--disabled",
        controlReadOnly: "sd-input--readonly",
        controlPreview: "sd-input--preview",
        constrolWithCharacterCounter: "sd-text__character-counter",
        characterCounterBig: "sd-text__character-counter--big",
        content: "sd-text__content sd-question__content",
        remainingCharacterCounter: "sd-remaining-character-counter",
        onError: "sd-input--error"
    },
    multipletext: {
        root: "sd-multipletext",
        rootMobile: "sd-multipletext--mobile",
        itemLabel: "sd-multipletext__item-container sd-input",
        itemLabelReadOnly: "sd-input--readonly",
        itemLabelDisabled: "sd-input--disabled",
        itemLabelPreview: "sd-input--preview",
        itemLabelOnError: "sd-multipletext__item-container--error",
        itemLabelAllowFocus: "sd-multipletext__item-container--allow-focus",
        itemLabelAnswered: "sd-multipletext__item-container--answered",
        itemWithCharacterCounter: "sd-multipletext-item__character-counter",
        item: "sd-multipletext__item",
        itemTitle: "sd-multipletext__item-title",
        content: "sd-multipletext__content sd-question__content",
        row: "sd-multipletext__row",
        cell: "sd-multipletext__cell",
        cellError: "sd-multipletext__cell--error",
        cellErrorTop: "sd-multipletext__cell--error-top",
        cellErrorBottom: "sd-multipletext__cell--error-bottom"
    },
    dropdown: {
        root: "sd-selectbase",
        popup: "sv-dropdown-popup",
        small: "sd-row__question--small",
        selectWrapper: "sv-dropdown_select-wrapper",
        other: "sd-input sd-comment sd-selectbase__other",
        onError: "sd-input--error",
        label: "sd-selectbase__label",
        item: "sd-item sd-radio sd-selectbase__item",
        itemDisabled: "sd-item--disabled sd-radio--disabled",
        itemChecked: "sd-item--checked sd-radio--checked",
        itemHover: "sd-item--allowhover sd-radio--allowhover",
        itemControl: "sd-visuallyhidden sd-item__control sd-radio__control",
        itemDecorator: "sd-item__svg sd-radio__svg",
        cleanButton: "sd-dropdown_clean-button",
        cleanButtonSvg: "sd-dropdown_clean-button-svg",
        cleanButtonIconId: "icon-clear",
        chevronButton: "sd-dropdown_chevron-button",
        chevronButtonSvg: "sd-dropdown_chevron-button-svg",
        chevronButtonIconId: "icon-chevron",
        control: "sd-input sd-dropdown",
        controlInputFieldComponent: "sd-dropdown__input-field-component",
        controlValue: "sd-dropdown__value",
        controlDisabled: "sd-input--disabled",
        controlReadOnly: "sd-input--readonly",
        controlPreview: "sd-input--preview",
        controlEmpty: "sd-dropdown--empty",
        controlLabel: "sd-item__control-label",
        filterStringInput: "sd-dropdown__filter-string-input",
        materialDecorator: "sd-item__decorator sd-radio__decorator",
        hintPrefix: "sd-dropdown__hint-prefix",
        hintSuffix: "sd-dropdown__hint-suffix"
    },
    imagepicker: {
        mainRoot: "sd-element sd-question sd-row__question",
        root: "sd-selectbase sd-imagepicker",
        rootColumn: "sd-imagepicker--column",
        item: "sd-imagepicker__item",
        itemOnError: "sd-imagepicker__item--error",
        itemInline: "sd-imagepicker__item--inline",
        itemChecked: "sd-imagepicker__item--checked",
        itemDisabled: "sd-imagepicker__item--disabled",
        itemReadOnly: "sd-imagepicker__item--readonly",
        itemPreview: "sd-imagepicker__item--preview",
        itemHover: "sd-imagepicker__item--allowhover",
        label: "sd-imagepicker__label",
        itemDecorator: "sd-imagepicker__item-decorator",
        imageContainer: "sd-imagepicker__image-container",
        itemControl: "sd-imagepicker__control sd-visuallyhidden",
        image: "sd-imagepicker__image",
        itemText: "sd-imagepicker__text",
        other: "sd-input sd-comment",
        itemNoImage: "sd-imagepicker__no-image",
        itemNoImageSvgIcon: "sd-imagepicker__no-image-svg",
        itemNoImageSvgIconId: "icon-no-image",
        column: "sd-selectbase__column sd-imagepicker__column",
        checkedItemDecorator: "sd-imagepicker__check-decorator",
        checkedItemSvgIcon: "sd-imagepicker__check-icon",
        checkedItemSvgIconId: "icon-v2check_24x24",
    },
    matrix: {
        mainRoot: "sd-element sd-question sd-row__question sd-element--complex sd-question--complex sd-question--table",
        tableWrapper: "sd-matrix sd-table-wrapper",
        root: "sd-table sd-matrix__table",
        columnsAutoWidth: "sd-table--columnsautowidth",
        noHeader: "sd-table--no-header",
        rootVerticalAlignTop: "sd-table--align-top",
        rootVerticalAlignMiddle: "sd-table--align-middle",
        rootAlternateRows: "sd-table--alternate-rows",
        rowError: "sd-matrix__row--error",
        cell: "sd-table__cell sd-matrix__cell",
        row: "sd-table__row",
        rowDisabled: "sd-table__row-disabled",
        rowReadOnly: "sd-table__row-readonly",
        headerCell: "sd-table__cell sd-table__cell--header",
        rowTextCell: "sd-table__cell sd-matrix__cell sd-table__cell--row-text",
        label: "sd-item sd-radio sd-matrix__label",
        itemOnError: "sd-item--error",
        itemValue: "sd-visuallyhidden sd-item__control sd-radio__control",
        itemChecked: "sd-item--checked sd-radio--checked",
        itemDisabled: "sd-item--disabled sd-radio--disabled",
        itemReadOnly: "sd-item--readonly sd-radio--readonly",
        itemPreview: "sd-item--preview sd-radio--preview",
        itemPreviewSvgIconId: "#icon-v2check",
        itemHover: "sd-radio--allowhover",
        materialDecorator: "sd-item__decorator sd-radio__decorator",
        itemDecorator: "sd-item__svg sd-radio__svg",
        cellText: "sd-matrix__text",
        cellTextSelected: "sd-matrix__text--checked",
        cellTextDisabled: "sd-matrix__text--disabled",
        cellResponsiveTitle: "sd-matrix__responsive-title",
        compact: "sd-element--with-frame sd-element--compact"
    },
    matrixdropdown: {
        mainRoot: "sd-element sd-question sd-row__question sd-element--complex sd-question--complex sd-question--table",
        rootScroll: "sd-question--scroll",
        root: "sd-table sd-matrixdropdown",
        columnsAutoWidth: "sd-table--columnsautowidth",
        noHeader: "sd-table--no-header",
        hasFooter: "sd-table--has-footer",
        rootVerticalAlignTop: "sd-table--align-top",
        rootVerticalAlignMiddle: "sd-table--align-middle",
        tableWrapper: "sd-table-wrapper",
        rootAlternateRows: "sd-table--alternate-rows",
        cell: "sd-table__cell",
        cellResponsiveTitle: "sd-table__responsive-title",
        errorsCell: "sd-table__cell--error",
        errorsCellTop: "sd-table__cell--error-top",
        errorsCellBottom: "sd-table__cell--error-bottom",
        itemCell: "sd-table__cell--item",
        row: "sd-table__row",
        rowFadeIn: "sd-table__row--fade-in",
        rowFadeOut: "sd-table__row--fade-out",
        expandedRow: "sd-table__row--expanded",
        rowHasPanel: "sd-table__row--has-panel",
        rowHasEndActions: "sd-table__row--has-end-actions",
        headerCell: "sd-table__cell sd-table__cell--header",
        rowTextCell: "sd-table__cell sd-table__cell--row-text",
        footerCell: "sd-table__cell sd-table__cell--footer",
        footerTotalCell: "sd-table__cell sd-table__cell--footer-total",
        columnTitleCell: "sd-table__cell--column-title",
        cellRequiredText: "sd-question__required-text",
        detailButton: "sd-table__cell--detail-button",
        detailButtonExpanded: "sd-table__cell--detail-button--expanded",
        detailIcon: "sd-detail-panel__icon",
        detailIconExpanded: "sd-detail-panel__icon--expanded",
        detailIconId: "icon-expanddetail",
        detailIconExpandedId: "icon-collapsedetail",
        detailPanelCell: "sd-table__cell--detail-panel",
        detailRowCell: "sd-table__cell--detail",
        actionsCellPrefix: "sd-table__cell-action",
        actionsCell: "sd-table__cell sd-table__cell--actions",
        actionsCellDrag: "sd-table__cell--drag",
        emptyCell: "sd-table__cell--empty",
        verticalCell: "sd-table__cell--vertical",
        cellQuestionWrapper: "sd-table__question-wrapper",
        compact: "sd-element--with-frame sd-element--compact"
    },
    matrixdynamic: {
        mainRoot: "sd-element sd-question sd-row__question sd-element--complex sd-question--complex sd-question--table",
        rootScroll: "sd-question--scroll",
        empty: "sd-question--empty",
        root: "sd-table sd-matrixdynamic",
        columnsAutoWidth: "sd-table--columnsautowidth",
        noHeader: "sd-table--no-header",
        hasFooter: "sd-table--has-footer",
        tableWrapper: "sd-table-wrapper",
        rootAlternateRows: "sd-table--alternate-rows",
        content: "sd-matrixdynamic__content sd-question__content",
        cell: "sd-table__cell",
        cellResponsiveTitle: "sd-table__responsive-title",
        row: "sd-table__row",
        rowFadeIn: "sd-table__row--fade-in",
        rowFadeOut: "sd-table__row--fade-out",
        rowHasPanel: "sd-table__row--has-panel",
        rowHasEndActions: "sd-table__row--has-end-actions",
        expandedRow: "sd-table__row--expanded",
        itemCell: "sd-table__cell--item",
        headerCell: "sd-table__cell sd-table__cell--header",
        rowTextCell: "sd-table__cell sd-table__cell--row-text",
        footerCell: "sd-table__cell sd-table__cell--footer",
        columnTitleCell: "sd-table__cell--column-title",
        cellRequiredText: "sd-question__required-text",
        button: "sd-action sd-matrixdynamic__btn",
        detailRow: "sd-table__row sd-table__row--detail",
        detailButton: "sd-table__cell--detail-button",
        detailButtonExpanded: "sd-table__cell--detail-button--expanded",
        detailIcon: "sd-detail-panel__icon",
        detailIconExpanded: "sd-detail-panel__icon--expanded",
        detailIconId: "icon-expanddetail",
        detailIconExpandedId: "icon-collapsedetail",
        detailPanelCell: "sd-table__cell--detail-panel",
        detailRowCell: "sd-table__cell--detail",
        actionsCellPrefix: "sd-table__cell-action",
        actionsCell: "sd-table__cell sd-table__cell--actions",
        actionsCellDrag: "sd-table__cell--drag",
        buttonAdd: "sd-matrixdynamic__add-btn",
        buttonRemove: "sd-action--negative sd-matrixdynamic__remove-btn",
        iconAdd: "sd-hidden",
        iconRemove: "",
        dragElementDecorator: "sd-drag-element__svg",
        iconDragElement: "#icon-v2dragelement_16x16",
        footer: "sd-matrixdynamic__footer",
        footerTotalCell: "sd-table__cell sd-table__cell--footer-total",
        emptyRowsSection: "sd-matrixdynamic__placeholder sd-question__placeholder",
        iconDrag: "sv-matrixdynamic__drag-icon",
        ghostRow: "sv-matrix-row--drag-drop-ghost-mod",
        emptyCell: "sd-table__cell--empty",
        verticalCell: "sd-table__cell--vertical",
        cellQuestionWrapper: "sd-table__question-wrapper",
        errorsCell: "sd-table__cell--error",
        errorsCellTop: "sd-table__cell--error-top",
        errorsCellBottom: "sd-table__cell--error-bottom",
        compact: "sd-element--with-frame sd-element--compact",
    },
    rating: {
        rootDropdown: "sd-scrollable-container sd-scrollable-container--compact sd-selectbase",
        root: "sd-scrollable-container sd-rating",
        rootWrappable: "sd-rating--wrappable",
        rootLabelsTop: "sd-rating--labels-top",
        rootLabelsBottom: "sd-rating--labels-bottom",
        rootLabelsDiagonal: "sd-rating--labels-diagonal",
        item: "sd-rating__item",
        itemOnError: "sd-rating__item--error",
        itemHover: "sd-rating__item--allowhover",
        selected: "sd-rating__item--selected",
        itemStar: "sd-rating__item-star",
        itemStarOnError: "sd-rating__item-star--error",
        itemStarHover: "sd-rating__item-star--allowhover",
        itemStarSelected: "sd-rating__item-star--selected",
        itemStarDisabled: "sd-rating__item-star--disabled",
        itemStarReadOnly: "sd-rating__item-star--readonly",
        itemStarPreview: "sd-rating__item-star--preview",
        itemStarHighlighted: "sd-rating__item-star--highlighted",
        itemStarUnhighlighted: "sd-rating__item-star--unhighlighted",
        itemStarSmall: "sd-rating__item-star--small",
        itemSmiley: "sd-rating__item-smiley",
        itemSmileyOnError: "sd-rating__item-smiley--error",
        itemSmileyHover: "sd-rating__item-smiley--allowhover",
        itemSmileySelected: "sd-rating__item-smiley--selected",
        itemSmileyDisabled: "sd-rating__item-smiley--disabled",
        itemSmileyReadOnly: "sd-rating__item-smiley--readonly",
        itemSmileyPreview: "sd-rating__item-smiley--preview",
        itemSmileyHighlighted: "sd-rating__item-star--highlighted",
        itemSmileyScaleColored: "sd-rating__item-smiley--scale-colored",
        itemSmileyRateColored: "sd-rating__item-smiley--rate-colored",
        itemSmileySmall: "sd-rating__item-smiley--small",
        minText: "sd-rating__item-text sd-rating__min-text",
        itemText: "sd-rating__item-text",
        maxText: "sd-rating__item-text sd-rating__max-text",
        itemDisabled: "sd-rating__item--disabled",
        itemReadOnly: "sd-rating__item--readonly",
        itemPreview: "sd-rating__item--preview",
        itemFixedSize: "sd-rating__item--fixed-size",
        control: "sd-input sd-dropdown",
        itemSmall: "sd-rating--small",
        selectWrapper: "sv-dropdown_select-wrapper",
        controlValue: "sd-dropdown__value",
        controlDisabled: "sd-input--disabled",
        controlReadOnly: "sd-input--readonly",
        controlPreview: "sd-input--preview",
        controlEmpty: "sd-dropdown--empty",
        filterStringInput: "sd-dropdown__filter-string-input",
        chevronButton: "sd-dropdown_chevron-button",
        chevronButtonSvg: "sd-dropdown_chevron-button-svg",
        chevronButtonIconId: "icon-chevron",
        popup: "sv-dropdown-popup",
        onError: "sd-input--error",
    },
    comment: {
        root: "sd-input sd-comment",
        small: "sd-row__question--small",
        controlDisabled: "sd-input--disabled",
        controlReadOnly: "sd-input--readonly",
        controlPreview: "sd-input--preview",
        content: "sd-comment__content sd-question__content",
        remainingCharacterCounter: "sd-remaining-character-counter",
        onError: "sd-input--error"
    },
    expression: "sd-expression",
    file: {
        root: "sd-file",
        rootDragging: "sd-file--dragging",
        rootAnswered: "sd-file--answered",
        rootDisabled: "sd-file--disabled",
        rootReadOnly: "sd-file--readonly",
        rootPreview: "sd-file--preview",
        other: "sd-input sd-comment",
        placeholderInput: "sd-visuallyhidden",
        previewItem: "sd-file__preview-item",
        fileSign: "",
        fileList: "sd-file__list",
        fileSignBottom: "sd-file__sign",
        dragArea: "sd-file__drag-area",
        dragAreaActive: "sd-file__drag-area--active",
        fileDecorator: "sd-file__decorator",
        onError: "sd-file__decorator--error",
        fileDecoratorDrag: "sd-file__decorator--drag",
        fileInput: "sd-visuallyhidden",
        noFileChosen: "sd-description sd-file__no-file-chosen",
        chooseFile: "sd-file__choose-btn",
        chooseFileAsText: "sd-action sd-file__choose-btn--text",
        chooseFileAsTextDisabled: "sd-action--disabled",
        chooseFileAsIcon: "sd-file__choose-btn--icon",
        chooseFileIconId: "icon-choosefile",
        disabled: "sd-file__choose-btn--disabled",
        controlDisabled: "sd-file__choose-file-btn--disabled",
        //todo: remove it in v2
        removeButton: "sd-context-btn--negative",
        removeButtonBottom: "",
        //
        removeButtonIconId: "icon-clear",
        removeFile: "sd-hidden",
        removeFileSvg: "",
        removeFileSvgIconId: "icon-close_16x16",
        wrapper: "sd-file__wrapper",
        defaultImage: "sd-file__default-image",
        defaultImageIconId: "icon-defaultfile",
        leftIconId: "icon-arrowleft",
        rightIconId: "icon-arrowright",
        removeFileButton: "sd-context-btn--small sd-context-btn--with-border sd-context-btn--colorful sd-context-btn--negative sd-file__remove-file-button",
        dragAreaPlaceholder: "sd-file__drag-area-placeholder",
        imageWrapper: "sd-file__image-wrapper",
        imageWrapperDefaultImage: "sd-file__image-wrapper--default-image",
        single: "sd-file--single",
        singleImage: "sd-file--single-image",
        mobile: "sd-file--mobile",
        videoContainer: "sd-file__video-container",
        contextButton: "sd-context-btn",
        video: "sd-file__video",
        actionsContainer: "sd-file__actions-container",
        closeCameraButton: "sd-file__close-camera-button",
        changeCameraButton: "sd-file__change-camera-button",
        takePictureButton: "sd-file__take-picture-button",
        loadingIndicator: "sd-file__loading-indicator",
    },
    signaturepad: {
        mainRoot: "sd-element sd-question sd-question--signature sd-row__question",
        root: "sd-signaturepad sjs_sp_container",
        small: "sd-row__question--small",
        controls: "sjs_sp_controls sd-signaturepad__controls",
        placeholder: "sjs_sp_placeholder",
        canvas: "sjs_sp_canvas sd-signaturepad__canvas",
        backgroundImage: "sjs_sp__background-image sd-signaturepad__background-image",
        clearButton: "sjs_sp_clear sd-context-btn sd-context-btn--negative sd-signaturepad__clear",
        clearButtonIconId: "icon-clear",
        loadingIndicator: "sd-signaturepad__loading-indicator"
    },
    saveData: {
        root: "sv-save-data_root",
        rootWithButtons: "sv-save-data_root--with-buttons",
        info: "sv-save-data_info",
        error: "sv-save-data_error",
        success: "sv-save-data_success",
        button: "sv-save-data_button",
        shown: "sv-save-data_root--shown"
    },
    window: {
        root: "sv_window",
        rootCollapsedMod: "sv_window--collapsed",
        rootFullScreenMode: "sv_window--full-screen",
        rootContent: "sv_window_root-content",
        body: "sv_window_content",
        header: {
            root: "sv_window_header",
            titleCollapsed: "sv_window_header_title_collapsed",
            buttonsContainer: "sv_window_buttons_container",
            button: "sv_window_button",
            buttonExpanded: "",
            buttonCollapsed: "",
            collapseButton: "sv_window_button sv_window_button_collapse",
            closeButton: "sv_window_button sv_window_button_close",
            fullScreenButton: "sv_window_button sv_window_button_full_screen"
        }
    },
    ranking: {
        root: "sv-ranking",
        rootMobileMod: "sv-ranking--mobile",
        rootDragMod: "sv-ranking--drag",
        rootDisabled: "sd-ranking--disabled",
        rootReadOnly: "sd-ranking--readonly",
        rootPreview: "sd-ranking--preview",
        rootDesignMode: "sv-ranking--design-mode",
        rootDragHandleAreaIcon: "sv-ranking--drag-handle-area-icon",
        rootSelectToRankMod: "sv-ranking--select-to-rank",
        rootSelectToRankEmptyValueMod: "sv-ranking--select-to-rank-empty-value",
        rootSelectToRankAlignVertical: "sv-ranking--select-to-rank-vertical",
        rootSelectToRankAlignHorizontal: "sv-ranking--select-to-rank-horizontal",
        item: "sv-ranking-item",
        itemContent: "sv-ranking-item__content sd-ranking-item__content",
        itemIndex: "sv-ranking-item__index sd-ranking-item__index",
        itemIndexEmptyMode: "sv-ranking-item__index--empty sd-ranking-item__index--empty",
        // itemText: "sv-ranking-item__text",
        itemDisabled: "sv-ranking-item--disabled",
        itemReadOnly: "sv-ranking-item--readonly",
        itemPreview: "sv-ranking-item--preview",
        controlLabel: "sv-ranking-item__text",
        itemGhostNode: "sv-ranking-item__ghost",
        itemIconContainer: "sv-ranking-item__icon-container",
        itemIcon: "sv-ranking-item__icon",
        itemIconHoverMod: "sv-ranking-item__icon--hover",
        itemIconFocusMod: "sv-ranking-item__icon--focus",
        itemGhostMod: "sv-ranking-item--ghost",
        itemDragMod: "sv-ranking--drag",
        itemOnError: "sv-ranking-item--error",
        container: "sv-ranking__container",
        containerEmptyMode: "sv-ranking__container--empty",
        containerFromMode: "sv-ranking__container--from",
        containerToMode: "sv-ranking__container--to",
        containerPlaceholder: "sv-ranking__container-placeholder",
        containersDivider: "sv-ranking__containers-divider",
    },
    buttongroup: {
        root: "sv-button-group",
        item: "sv-button-group__item",
        itemIcon: "sv-button-group__item-icon",
        itemDecorator: "sv-button-group__item-decorator",
        itemCaption: "sv-button-group__item-caption",
        itemHover: "sv-button-group__item--hover",
        itemSelected: "sv-button-group__item--selected",
        itemDisabled: "sv-button-group__item--disabled",
        itemControl: "sv-visuallyhidden",
    },
    list: {
        root: "sv-list__container sd-list",
        item: "sv-list__item sd-list__item",
        itemBody: "sv-list__item-body sd-list__item-body",
        itemSelected: "sv-list__item--selected sd-list__item--selected",
        itemFocused: "sv-list__item--focused sd-list__item--focused",
    },
    actionBar: {
        root: "sd-action-bar",
        item: "sd-action",
        defaultSizeMode: "",
        smallSizeMode: "",
        itemPressed: "sd-action--pressed",
        itemAsIcon: "sd-action--icon",
        itemIcon: "sd-action__icon",
        itemTitle: "sd-action__title",
    },
    variables: {
        mobileWidth: "--sd-mobile-width",
        themeMark: "--sv-defaultV2-mark"
    },
    tagbox: {
        root: "sd-selectbase",
        popup: "sv-dropdown-popup",
        small: "sd-row__question--small",
        selectWrapper: "sv-dropdown_select-wrapper",
        other: "sd-input sd-comment sd-selectbase__other",
        onError: "sd-input--error",
        label: "sd-selectbase__label",
        itemSvgIconId: "#icon-v2check",
        item: "sd-item sd-checkbox sd-selectbase__item",
        itemDisabled: "sd-item--disabled sd-checkbox--disabled",
        itemChecked: "sd-item--checked sd-checkbox--checked",
        itemHover: "sd-item--allowhover sd-checkbox--allowhover",
        itemControl: "sd-visuallyhidden sd-item__control sd-checkbox__control",
        itemDecorator: "sd-item__svg sd-checkbox__svg",
        cleanButton: "sd-tagbox_clean-button sd-dropdown_clean-button",
        cleanButtonSvg: "sd-tagbox_clean-button-svg sd-dropdown_clean-button-svg",
        cleanButtonIconId: "icon-clear",
        cleanItemButton: "sd-tagbox-item_clean-button",
        cleanItemButtonSvg: "sd-tagbox-item_clean-button-svg",
        cleanItemButtonIconId: "icon-clear_16x16",
        chevronButton: "sd-dropdown_chevron-button",
        chevronButtonSvg: "sd-dropdown_chevron-button-svg",
        chevronButtonIconId: "icon-chevron",
        control: "sd-input sd-tagbox sd-dropdown",
        controlValue: "sd-tagbox__value sd-dropdown__value",
        controlValueItems: "sd-tagbox__value-items",
        placeholderInput: "sd-tagbox__placeholder",
        controlEditable: "sd-input--editable",
        controlDisabled: "sd-input--disabled",
        controlReadOnly: "sd-input--readonly",
        controlPreview: "sd-input--preview",
        controlEmpty: "sd-dropdown--empty sd-tagbox--empty",
        controlLabel: "sd-item__control-label",
        filterStringInput: "sd-tagbox__filter-string-input sd-dropdown__filter-string-input",
        materialDecorator: "sd-item__decorator sd-checkbox__decorator",
        hint: "sd-tagbox__hint",
        hintPrefix: "sd-dropdown__hint-prefix sd-tagbox__hint-prefix",
        hintSuffix: "sd-dropdown__hint-suffix sd-tagbox__hint-suffix",
        hintSuffixWrapper: "sd-tagbox__hint-suffix-wrapper"
    },
};
var defaultV2ThemeName = "defaultV2";
surveyCss[defaultV2ThemeName] = defaultV2Css;

// CONCATENATED MODULE: ./packages/survey-core/src/dxSurveyService.ts


var surveyIOSite = "surveyjs.io";
var surveyIOMaxPostSize = 65536;
/**
 * The class contains methods to work with api.surveyjs.io service.
 */
var dxSurveyService_dxSurveyService = /** @class */ (function () {
    function dxSurveyService() {
    }
    Object.defineProperty(dxSurveyService, "serviceUrl", {
        get: function () {
            return settings.web.surveyServiceUrl;
        },
        set: function (val) {
            settings.web.surveyServiceUrl = val;
        },
        enumerable: false,
        configurable: true
    });
    dxSurveyService.prototype.loadSurvey = function (surveyId, onLoad) {
        var xhr = new XMLHttpRequest();
        xhr.open("GET", this.serviceUrl + "/getSurvey?surveyId=" + surveyId);
        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        xhr.onload = function () {
            var result = JSON.parse(xhr.response);
            onLoad(xhr.status == 200, result, xhr.response);
        };
        xhr.send();
    };
    dxSurveyService.prototype.getSurveyJsonAndIsCompleted = function (surveyId, clientId, onLoad) {
        var xhr = new XMLHttpRequest();
        xhr.open("GET", this.serviceUrl +
            "/getSurveyAndIsCompleted?surveyId=" +
            surveyId +
            "&clientId=" +
            clientId);
        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        xhr.onload = function () {
            var result = JSON.parse(xhr.response);
            var surveyJson = result ? result.survey : null;
            var isCompleted = result ? result.isCompleted : null;
            onLoad(xhr.status == 200, surveyJson, isCompleted, xhr.response);
        };
        xhr.send();
    };
    dxSurveyService.prototype.canSendResult = function (result) {
        if (!this.isSurveJSIOService)
            return true;
        var str = JSON.stringify(result);
        return str.length < surveyIOMaxPostSize;
    };
    Object.defineProperty(dxSurveyService.prototype, "isSurveJSIOService", {
        get: function () {
            return this.serviceUrl.indexOf(surveyIOSite) >= 0;
        },
        enumerable: false,
        configurable: true
    });
    dxSurveyService.prototype.sendResult = function (postId, result, onSendResult, clientId, isPartialCompleted) {
        if (clientId === void 0) { clientId = null; }
        if (isPartialCompleted === void 0) { isPartialCompleted = false; }
        if (!this.canSendResult(result)) {
            onSendResult(false, surveyLocalization.getString("savingExceedSize", this.locale), undefined);
        }
        else {
            this.sendResultCore(postId, result, onSendResult, clientId, isPartialCompleted);
        }
    };
    dxSurveyService.prototype.sendResultCore = function (postId, result, onSendResult, clientId, isPartialCompleted) {
        if (clientId === void 0) { clientId = null; }
        if (isPartialCompleted === void 0) { isPartialCompleted = false; }
        var xhr = new XMLHttpRequest();
        xhr.open("POST", this.serviceUrl + "/post/");
        xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        var data = { postId: postId, surveyResult: JSON.stringify(result) };
        if (clientId)
            data["clientId"] = clientId;
        if (isPartialCompleted)
            data["isPartialCompleted"] = true;
        var dataStringify = JSON.stringify(data);
        xhr.onload = xhr.onerror = function () {
            if (!onSendResult)
                return;
            onSendResult(xhr.status === 200, xhr.response, xhr);
        };
        xhr.send(dataStringify);
    };
    dxSurveyService.prototype.sendFile = function (postId, file, onSendFile) {
        var xhr = new XMLHttpRequest();
        xhr.onload = xhr.onerror = function () {
            if (!onSendFile)
                return;
            onSendFile(xhr.status == 200, JSON.parse(xhr.response));
        };
        xhr.open("POST", this.serviceUrl + "/upload/", true);
        var formData = new FormData();
        formData.append("file", file);
        formData.append("postId", postId);
        xhr.send(formData);
    };
    dxSurveyService.prototype.getResult = function (resultId, name, onGetResult) {
        var xhr = new XMLHttpRequest();
        var data = "resultId=" + resultId + "&name=" + name;
        xhr.open("GET", this.serviceUrl + "/getResult?" + data);
        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        var self = this;
        xhr.onload = function () {
            var result = null;
            var list = null;
            if (xhr.status == 200) {
                result = JSON.parse(xhr.response);
                list = [];
                for (var key in result.QuestionResult) {
                    var el = { name: key, value: result.QuestionResult[key] };
                    list.push(el);
                }
            }
            onGetResult(xhr.status == 200, result, list, xhr.response);
        };
        xhr.send();
    };
    dxSurveyService.prototype.isCompleted = function (resultId, clientId, onIsCompleted) {
        var xhr = new XMLHttpRequest();
        var data = "resultId=" + resultId + "&clientId=" + clientId;
        xhr.open("GET", this.serviceUrl + "/isCompleted?" + data);
        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        var self = this;
        xhr.onload = function () {
            var result = null;
            if (xhr.status == 200) {
                result = JSON.parse(xhr.response);
            }
            onIsCompleted(xhr.status == 200, result, xhr.response);
        };
        xhr.send();
    };
    Object.defineProperty(dxSurveyService.prototype, "serviceUrl", {
        get: function () {
            return dxSurveyService.serviceUrl || "";
        },
        enumerable: false,
        configurable: true
    });
    return dxSurveyService;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/surveytimer.ts

var surveyTimerFunctions = {
    setTimeout: function (func) {
        return surveyTimerFunctions.safeTimeOut(func, 1000);
    },
    clearTimeout: function (timerId) {
        clearTimeout(timerId);
    },
    safeTimeOut: function (func, delay) {
        if (delay <= 0) {
            func();
            return 0;
        }
        else {
            return setTimeout(func, delay);
        }
    },
    now: function () { return Date.now(); }
};
var surveytimer_SurveyTimer = /** @class */ (function () {
    function SurveyTimer() {
        this.listenerCounter = 0;
        this.timerId = -1;
        this.onTimer = new EventBase();
    }
    Object.defineProperty(SurveyTimer, "instance", {
        get: function () {
            if (!SurveyTimer.instanceValue) {
                SurveyTimer.instanceValue = new SurveyTimer();
            }
            return SurveyTimer.instanceValue;
        },
        enumerable: false,
        configurable: true
    });
    SurveyTimer.prototype.start = function (func) {
        var _this = this;
        if (func === void 0) { func = null; }
        if (func) {
            this.onTimer.add(func);
        }
        this.prevTimeInMs = surveyTimerFunctions.now();
        if (this.timerId < 0) {
            this.timerId = surveyTimerFunctions.setTimeout(function () {
                _this.doTimer();
            });
        }
        this.listenerCounter++;
    };
    SurveyTimer.prototype.stop = function (func) {
        if (func === void 0) { func = null; }
        if (func) {
            this.onTimer.remove(func);
        }
        this.listenerCounter--;
        if (this.listenerCounter == 0 && this.timerId > -1) {
            surveyTimerFunctions.clearTimeout(this.timerId);
            this.timerId = -1;
        }
    };
    SurveyTimer.prototype.doTimer = function () {
        var _this = this;
        if (this.onTimer.isEmpty || this.listenerCounter == 0) {
            this.timerId = -1;
        }
        if (this.timerId < 0)
            return;
        var newTimer = surveyTimerFunctions.now();
        var seconds = Math.floor((newTimer - this.prevTimeInMs) / 1000);
        this.prevTimeInMs = newTimer;
        if (seconds < 0) {
            seconds = 1;
        }
        var prevItem = this.timerId;
        this.onTimer.fire(this, { seconds: seconds });
        //We have to check that we have the same timerId
        //It could be changed during events execution and it will lead to double timer events
        if (prevItem !== this.timerId)
            return;
        this.timerId = surveyTimerFunctions.setTimeout(function () {
            _this.doTimer();
        });
    };
    SurveyTimer.instanceValue = null;
    return SurveyTimer;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/surveyTimerModel.ts
var surveyTimerModel_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var surveyTimerModel_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};




var surveyTimerModel_SurveyTimerModel = /** @class */ (function (_super) {
    surveyTimerModel_extends(SurveyTimerModel, _super);
    function SurveyTimerModel(survey) {
        var _this = _super.call(this) || this;
        _this.timerFunc = null;
        _this.surveyValue = survey;
        _this.onCreating();
        return _this;
    }
    Object.defineProperty(SurveyTimerModel.prototype, "survey", {
        get: function () { return this.surveyValue; },
        enumerable: false,
        configurable: true
    });
    SurveyTimerModel.prototype.onCreating = function () { };
    SurveyTimerModel.prototype.start = function () {
        var _this = this;
        if (!this.survey)
            return;
        if (this.isRunning || this.isDesignMode)
            return;
        this.survey.onCurrentPageChanged.add(function () {
            _this.update();
        });
        this.timerFunc = function (sender, options) { _this.doTimer(options.seconds); };
        this.setIsRunning(true);
        this.update();
        surveytimer_SurveyTimer.instance.start(this.timerFunc);
    };
    SurveyTimerModel.prototype.stop = function () {
        if (!this.isRunning)
            return;
        this.setIsRunning(false);
        surveytimer_SurveyTimer.instance.stop(this.timerFunc);
    };
    Object.defineProperty(SurveyTimerModel.prototype, "isRunning", {
        get: function () {
            return this.getPropertyValue("isRunning", false);
        },
        enumerable: false,
        configurable: true
    });
    SurveyTimerModel.prototype.setIsRunning = function (val) {
        this.setPropertyValue("isRunning", val);
    };
    SurveyTimerModel.prototype.update = function () {
        this.updateText();
        this.updateProgress();
    };
    SurveyTimerModel.prototype.doTimer = function (seconds) {
        var page = this.survey.currentPage;
        if (page) {
            var pageMaxTime = page.getMaxTimeToFinish();
            if (pageMaxTime > 0 && pageMaxTime < page.timeSpent + seconds) {
                seconds = pageMaxTime - page.timeSpent;
            }
            page.timeSpent = page.timeSpent + seconds;
        }
        this.spent = this.spent + seconds;
        this.update();
        if (this.onTimer) {
            this.onTimer(page);
        }
    };
    SurveyTimerModel.prototype.updateProgress = function () {
        var _this = this;
        var _a = this.survey.timerInfo, spent = _a.spent, limit = _a.limit;
        if (!limit) {
            this.progress = undefined;
        }
        else {
            if (spent == 0) {
                this.progress = 0;
                setTimeout(function () {
                    _this.progress = Math.floor((spent + 1) / limit * 100) / 100;
                }, 0);
            }
            else if (spent <= limit) {
                this.progress = Math.floor((spent + 1) / limit * 100) / 100;
            }
            if (this.progress > 1) {
                this.progress = undefined;
            }
        }
    };
    SurveyTimerModel.prototype.updateText = function () {
        var timerClock = this.survey.timerClock;
        this.clockMajorText = timerClock.majorText;
        this.clockMinorText = timerClock.minorText;
        this.text = this.survey.timerInfoText;
    };
    Object.defineProperty(SurveyTimerModel.prototype, "showProgress", {
        get: function () {
            return this.progress !== undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyTimerModel.prototype, "showTimerAsClock", {
        get: function () {
            return !!this.survey.getCss().clockTimerRoot;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyTimerModel.prototype, "rootCss", {
        get: function () {
            return new CssClassBuilder()
                .append(this.survey.getCss().clockTimerRoot)
                .append(this.survey.getCss().clockTimerRootTop, this.survey.isTimerPanelShowingOnTop)
                .append(this.survey.getCss().clockTimerRootBottom, this.survey.isTimerPanelShowingOnBottom)
                .toString();
        },
        enumerable: false,
        configurable: true
    });
    SurveyTimerModel.prototype.getProgressCss = function () {
        return new CssClassBuilder()
            .append(this.survey.getCss().clockTimerProgress)
            .append(this.survey.getCss().clockTimerProgressAnimation, this.progress > 0)
            .toString();
    };
    Object.defineProperty(SurveyTimerModel.prototype, "textContainerCss", {
        get: function () {
            return this.survey.getCss().clockTimerTextContainer;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyTimerModel.prototype, "minorTextCss", {
        get: function () {
            return this.survey.getCss().clockTimerMinorText;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyTimerModel.prototype, "majorTextCss", {
        get: function () {
            return this.survey.getCss().clockTimerMajorText;
        },
        enumerable: false,
        configurable: true
    });
    surveyTimerModel_decorate([
        jsonobject_property()
    ], SurveyTimerModel.prototype, "text", void 0);
    surveyTimerModel_decorate([
        jsonobject_property()
    ], SurveyTimerModel.prototype, "progress", void 0);
    surveyTimerModel_decorate([
        jsonobject_property()
    ], SurveyTimerModel.prototype, "clockMajorText", void 0);
    surveyTimerModel_decorate([
        jsonobject_property()
    ], SurveyTimerModel.prototype, "clockMinorText", void 0);
    surveyTimerModel_decorate([
        jsonobject_property({ defaultValue: 0 })
    ], SurveyTimerModel.prototype, "spent", void 0);
    return SurveyTimerModel;
}(base_Base));


// CONCATENATED MODULE: ./packages/survey-core/src/notifier.ts
var notifier_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var notifier_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};





var notifier_Notifier = /** @class */ (function (_super) {
    notifier_extends(Notifier, _super);
    function Notifier(cssClasses) {
        var _this = _super.call(this) || this;
        _this.cssClasses = cssClasses;
        _this.timeout = settings.notifications.lifetime;
        _this.timer = undefined;
        _this.actionsVisibility = {};
        _this.showActions = true;
        _this.actionBar = new container_ActionContainer();
        _this.actionBar.updateCallback = function (isResetInitialized) {
            _this.actionBar.actions.forEach(function (action) { return action.cssClasses = {}; });
        };
        _this.css = _this.cssClasses.root;
        return _this;
    }
    Notifier.prototype.getCssClass = function (type) {
        return new CssClassBuilder()
            .append(this.cssClasses.root)
            .append(this.cssClasses.rootWithButtons, this.actionBar.visibleActions.length > 0)
            .append(this.cssClasses.info, type !== "error" && type !== "success")
            .append(this.cssClasses.error, type === "error")
            .append(this.cssClasses.success, type === "success")
            .append(this.cssClasses.shown, this.active)
            .toString();
    };
    Notifier.prototype.updateActionsVisibility = function (type) {
        var _this = this;
        this.actionBar.actions.forEach(function (action) { return action.visible = _this.showActions && (_this.actionsVisibility[action.id] === type); });
    };
    Notifier.prototype.notify = function (message, type, waitUserAction) {
        var _this = this;
        if (type === void 0) { type = "info"; }
        if (waitUserAction === void 0) { waitUserAction = false; }
        this.isDisplayed = true;
        setTimeout(function () {
            _this.updateActionsVisibility(type);
            _this.message = message;
            _this.active = true;
            _this.css = _this.getCssClass(type);
            if (!!_this.timer) {
                clearTimeout(_this.timer);
                _this.timer = undefined;
            }
            if (!waitUserAction) {
                _this.timer = setTimeout(function () {
                    _this.timer = undefined;
                    _this.active = false;
                    _this.css = _this.getCssClass(type);
                }, _this.timeout);
            }
        }, 1);
    };
    Notifier.prototype.addAction = function (action, notificationType) {
        action.visible = false;
        action.innerCss = this.cssClasses.button;
        var res = this.actionBar.addAction(action);
        this.actionsVisibility[res.id] = notificationType;
    };
    notifier_decorate([
        jsonobject_property({ defaultValue: false })
    ], Notifier.prototype, "active", void 0);
    notifier_decorate([
        jsonobject_property({ defaultValue: false })
    ], Notifier.prototype, "isDisplayed", void 0);
    notifier_decorate([
        jsonobject_property()
    ], Notifier.prototype, "message", void 0);
    notifier_decorate([
        jsonobject_property()
    ], Notifier.prototype, "css", void 0);
    return Notifier;
}(base_Base));


// CONCATENATED MODULE: ./packages/survey-core/src/header.ts
var header_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var header_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};




var CoverCell = /** @class */ (function () {
    function CoverCell(cover, positionX, positionY) {
        this.cover = cover;
        this.positionX = positionX;
        this.positionY = positionY;
    }
    CoverCell.prototype.calcRow = function (positionY) {
        return positionY === "top" ? 1 : (positionY === "middle" ? 2 : 3);
    };
    CoverCell.prototype.calcColumn = function (positionX) {
        return positionX === "left" ? 1 : (positionX === "center" ? 2 : 3);
    };
    CoverCell.prototype.calcAlignItems = function (positionX) {
        return positionX === "left" ? "flex-start" : (positionX === "center" ? "center" : "flex-end");
    };
    CoverCell.prototype.calcAlignText = function (positionX) {
        return positionX === "left" ? "start" : (positionX === "center" ? "center" : "end");
    };
    CoverCell.prototype.calcJustifyContent = function (positionY) {
        return positionY === "top" ? "flex-start" : (positionY === "middle" ? "center" : "flex-end");
    };
    Object.defineProperty(CoverCell.prototype, "survey", {
        get: function () {
            return this.cover.survey;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CoverCell.prototype, "css", {
        get: function () {
            var result = CoverCell.CLASSNAME + " " + CoverCell.CLASSNAME + "--" + this.positionX + " " + CoverCell.CLASSNAME + "--" + this.positionY;
            return result;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CoverCell.prototype, "style", {
        get: function () {
            var result = {};
            result["gridColumn"] = this.calcColumn(this.positionX);
            result["gridRow"] = this.calcRow(this.positionY);
            return result;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CoverCell.prototype, "contentStyle", {
        get: function () {
            var result = {};
            result["textAlign"] = this.calcAlignText(this.positionX);
            result["alignItems"] = this.calcAlignItems(this.positionX);
            result["justifyContent"] = this.calcJustifyContent(this.positionY);
            return result;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CoverCell.prototype, "showLogo", {
        get: function () {
            return this.survey.hasLogo && this.positionX === this.cover.logoPositionX && this.positionY === this.cover.logoPositionY;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CoverCell.prototype, "showTitle", {
        get: function () {
            return this.survey.hasTitle && this.positionX === this.cover.titlePositionX && this.positionY === this.cover.titlePositionY;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CoverCell.prototype, "showDescription", {
        get: function () {
            return this.survey.renderedHasDescription && this.positionX === this.cover.descriptionPositionX && this.positionY === this.cover.descriptionPositionY;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CoverCell.prototype, "textAreaWidth", {
        get: function () {
            if (!this.cover.textAreaWidth) {
                return "";
            }
            return "" + this.cover.textAreaWidth + "px";
        },
        enumerable: false,
        configurable: true
    });
    CoverCell.CLASSNAME = "sv-header__cell";
    return CoverCell;
}());

var header_Cover = /** @class */ (function (_super) {
    header_extends(Cover, _super);
    function Cover() {
        var _this = _super.call(this) || this;
        _this.cells = [];
        ["top", "middle", "bottom"].forEach(function (positionY) {
            return ["left", "center", "right"].forEach(function (positionX) { return _this.cells.push(new CoverCell(_this, positionX, positionY)); });
        });
        _this.init();
        return _this;
    }
    Cover.prototype.calcBackgroundSize = function (backgroundImageFit) {
        if (backgroundImageFit === "fill") {
            return "100% 100%";
        }
        if (backgroundImageFit === "tile") {
            return "auto";
        }
        return backgroundImageFit;
    };
    Cover.prototype.updateHeaderClasses = function () {
        this.headerClasses = new CssClassBuilder()
            .append("sv-header")
            .append("sv-header__without-background", (this.backgroundColor === "transparent") && !this.backgroundImage)
            .append("sv-header__background-color--none", this.backgroundColor === "transparent" && !this.titleColor && !this.descriptionColor)
            .append("sv-header__background-color--accent", !this.backgroundColor && !this.titleColor && !this.descriptionColor)
            .append("sv-header__background-color--custom", !!this.backgroundColor && this.backgroundColor !== "transparent" && !this.titleColor && !this.descriptionColor)
            .append("sv-header__overlap", this.overlapEnabled)
            .toString();
    };
    Cover.prototype.updateContentClasses = function () {
        var surveyWidthMode = !!this.survey && this.survey.calculateWidthMode();
        this.maxWidth = this.inheritWidthFrom === "survey" && !!surveyWidthMode && surveyWidthMode === "static" && this.survey.renderedWidth;
        this.contentClasses = new CssClassBuilder()
            .append("sv-header__content")
            .append("sv-header__content--static", this.inheritWidthFrom === "survey" && !!surveyWidthMode && surveyWidthMode === "static")
            .append("sv-header__content--responsive", this.inheritWidthFrom === "container" || (!!surveyWidthMode && surveyWidthMode === "responsive"))
            .toString();
    };
    Cover.prototype.updateBackgroundImageClasses = function () {
        this.backgroundImageClasses = new CssClassBuilder()
            .append("sv-header__background-image")
            .append("sv-header__background-image--contain", this.backgroundImageFit === "contain")
            .append("sv-header__background-image--tile", this.backgroundImageFit === "tile")
            .toString();
    };
    Cover.prototype.fromTheme = function (theme) {
        _super.prototype.fromJSON.call(this, theme.header || {});
        if (!!theme.cssVariables) {
            this.backgroundColor = theme.cssVariables["--sjs-header-backcolor"];
            this.titleColor = theme.cssVariables["--sjs-font-headertitle-color"];
            this.descriptionColor = theme.cssVariables["--sjs-font-headerdescription-color"];
        }
        this.init();
    };
    Cover.prototype.init = function () {
        this.renderBackgroundImage = wrapUrlForBackgroundImage(this.backgroundImage);
        this.updateHeaderClasses();
        this.updateContentClasses();
        this.updateBackgroundImageClasses();
    };
    Cover.prototype.getType = function () {
        return "cover";
    };
    Object.defineProperty(Cover.prototype, "renderedHeight", {
        get: function () {
            return this.height && (this.survey && !this.survey.isMobile || !this.survey) ? Math.max(this.height, this.actualHeight + 40) + "px" : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Cover.prototype, "renderedtextAreaWidth", {
        get: function () {
            return this.textAreaWidth ? this.textAreaWidth + "px" : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Cover.prototype, "survey", {
        get: function () {
            return this._survey;
        },
        set: function (newValue) {
            var _this = this;
            if (this._survey === newValue)
                return;
            this._survey = newValue;
            if (!!newValue) {
                this.updateContentClasses();
                this._survey.onPropertyChanged.add(function (sender, options) {
                    if (options.name == "widthMode" || options.name == "width") {
                        _this.updateContentClasses();
                    }
                });
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Cover.prototype, "backgroundImageStyle", {
        get: function () {
            if (!this.backgroundImage)
                return null;
            return {
                opacity: this.backgroundImageOpacity,
                backgroundImage: this.renderBackgroundImage,
                backgroundSize: this.calcBackgroundSize(this.backgroundImageFit),
            };
        },
        enumerable: false,
        configurable: true
    });
    Cover.prototype.propertyValueChanged = function (name, oldValue, newValue) {
        _super.prototype.propertyValueChanged.call(this, name, oldValue, newValue);
        if (name === "backgroundColor" || name === "backgroundImage" || name === "overlapEnabled") {
            this.updateHeaderClasses();
        }
        if (name === "inheritWidthFrom") {
            this.updateContentClasses();
        }
        if (name === "backgroundImageFit") {
            this.updateBackgroundImageClasses();
        }
    };
    Cover.prototype.calculateActualHeight = function (logoHeight, titleHeight, descriptionHeight) {
        var positionsY = ["top", "middle", "bottom"];
        var logoIndex = positionsY.indexOf(this.logoPositionY);
        var titleIndex = positionsY.indexOf(this.titlePositionY);
        var descriptionIndex = positionsY.indexOf(this.descriptionPositionY);
        var positionsX = ["left", "center", "right"];
        var logoIndexX = positionsX.indexOf(this.logoPositionX);
        var titleIndexX = positionsX.indexOf(this.titlePositionX);
        var descriptionIndexX = positionsX.indexOf(this.descriptionPositionX);
        var heights = [
            [0, 0, 0],
            [0, 0, 0],
            [0, 0, 0]
        ];
        heights[logoIndex][logoIndexX] = logoHeight;
        heights[titleIndex][titleIndexX] += titleHeight;
        heights[descriptionIndex][descriptionIndexX] += descriptionHeight;
        return heights.reduce(function (total, rowArr) { return total + Math.max.apply(Math, rowArr); }, 0);
    };
    Cover.prototype.processResponsiveness = function (width) {
        if (this.survey && this.survey.rootElement) {
            var logoEl = this.survey.rootElement.querySelectorAll(".sv-header__logo")[0];
            var titleEl = this.survey.rootElement.querySelectorAll(".sv-header__title")[0];
            var descriptionEl = this.survey.rootElement.querySelectorAll(".sv-header__description")[0];
            var logoHeight = logoEl ? logoEl.getBoundingClientRect().height : 0;
            var titleHeight = titleEl ? titleEl.getBoundingClientRect().height : 0;
            var descriptionHeight = descriptionEl ? descriptionEl.getBoundingClientRect().height : 0;
            this.actualHeight = this.calculateActualHeight(logoHeight, titleHeight, descriptionHeight);
        }
    };
    Object.defineProperty(Cover.prototype, "hasBackground", {
        get: function () {
            return !!this.backgroundImage || this.backgroundColor !== "transparent";
        },
        enumerable: false,
        configurable: true
    });
    header_decorate([
        jsonobject_property({ defaultValue: 0 })
    ], Cover.prototype, "actualHeight", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "height", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "inheritWidthFrom", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "textAreaWidth", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "textGlowEnabled", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "overlapEnabled", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "backgroundColor", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "titleColor", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "descriptionColor", void 0);
    header_decorate([
        jsonobject_property({
            onSet: function (newVal, target) {
                target.renderBackgroundImage = wrapUrlForBackgroundImage(newVal);
            }
        })
    ], Cover.prototype, "backgroundImage", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "renderBackgroundImage", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "backgroundImageFit", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "backgroundImageOpacity", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "logoPositionX", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "logoPositionY", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "titlePositionX", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "titlePositionY", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "descriptionPositionX", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "descriptionPositionY", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "logoStyle", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "titleStyle", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "descriptionStyle", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "headerClasses", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "contentClasses", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "maxWidth", void 0);
    header_decorate([
        jsonobject_property()
    ], Cover.prototype, "backgroundImageClasses", void 0);
    return Cover;
}(base_Base));

Serializer.addClass("cover", [
    { name: "height:number", minValue: 0, default: 256 },
    { name: "inheritWidthFrom", default: "container" },
    { name: "textAreaWidth:number", minValue: 0, default: 512 },
    { name: "textGlowEnabled:boolean" },
    { name: "overlapEnabled:boolean" },
    { name: "backgroundImage:file" },
    { name: "backgroundImageOpacity:number", minValue: 0, maxValue: 1, default: 1 },
    { name: "backgroundImageFit", default: "cover", choices: ["cover", "fill", "contain"] },
    { name: "logoPositionX", default: "right" },
    { name: "logoPositionY", default: "top" },
    { name: "titlePositionX", default: "left" },
    { name: "titlePositionY", default: "bottom" },
    { name: "descriptionPositionX", default: "left" },
    { name: "descriptionPositionY", default: "bottom" }
], function () {
    return new header_Cover();
});

// CONCATENATED MODULE: ./packages/survey-core/src/surveyTaskManager.ts
var surveyTaskManager_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var surveyTaskManager_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};


var SurveyTaskModel = /** @class */ (function () {
    function SurveyTaskModel(type) {
        this.type = type;
        this.timestamp = new Date();
    }
    return SurveyTaskModel;
}());
var surveyTaskManager_SurveyTaskManagerModel = /** @class */ (function (_super) {
    surveyTaskManager_extends(SurveyTaskManagerModel, _super);
    function SurveyTaskManagerModel() {
        var _this = _super.call(this) || this;
        _this.taskList = [];
        _this.onAllTasksCompleted = _this.addEvent();
        return _this;
    }
    SurveyTaskManagerModel.prototype.runTask = function (type, func) {
        var _this = this;
        var task = new SurveyTaskModel(type);
        this.taskList.push(task);
        this.hasActiveTasks = true;
        func(function () { return _this.taskFinished(task); });
        return task;
    };
    SurveyTaskManagerModel.prototype.waitAndExecute = function (action) {
        if (!this.hasActiveTasks) {
            action();
            return;
        }
        this.onAllTasksCompleted.add(function () { action(); });
    };
    SurveyTaskManagerModel.prototype.taskFinished = function (task) {
        var index = this.taskList.indexOf(task);
        if (index > -1) {
            this.taskList.splice(index, 1);
        }
        if (this.hasActiveTasks && this.taskList.length == 0) {
            this.hasActiveTasks = false;
            this.onAllTasksCompleted.fire(this, {});
        }
    };
    surveyTaskManager_decorate([
        jsonobject_property({ defaultValue: false })
    ], SurveyTaskManagerModel.prototype, "hasActiveTasks", void 0);
    return SurveyTaskManagerModel;
}(base_Base));


// CONCATENATED MODULE: ./packages/survey-core/src/drag-drop-helper-v1.ts
var DragDropInfo = /** @class */ (function () {
    function DragDropInfo(source, target, nestedPanelDepth) {
        if (nestedPanelDepth === void 0) { nestedPanelDepth = -1; }
        this.source = source;
        this.target = target;
        this.nestedPanelDepth = nestedPanelDepth;
    }
    return DragDropInfo;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/drag-drop-panel-helper-v1.ts

var drag_drop_panel_helper_v1_DragDropPanelHelperV1 = /** @class */ (function () {
    function DragDropPanelHelperV1(panel) {
        this.panel = panel;
    }
    DragDropPanelHelperV1.prototype.dragDropAddTarget = function (dragDropInfo) {
        var prevRow = this.dragDropFindRow(dragDropInfo.target);
        if (this.dragDropAddTargetToRow(dragDropInfo, prevRow)) {
            this.panel.updateRowsRemoveElementFromRow(dragDropInfo.target, prevRow);
        }
    };
    DragDropPanelHelperV1.prototype.dragDropFindRow = function (findElement) {
        if (!findElement || findElement.isPage)
            return null;
        var element = findElement;
        var rows = this.panel.rows;
        for (var i = 0; i < rows.length; i++) {
            if (rows[i].elements.indexOf(element) > -1)
                return rows[i];
        }
        for (var i = 0; i < this.panel.elements.length; i++) {
            var pnl = this.panel.elements[i].getPanel();
            if (!pnl)
                continue;
            var row = pnl.dragDropFindRow(element);
            if (!!row)
                return row;
        }
        return null;
    };
    DragDropPanelHelperV1.prototype.dragDropMoveElement = function (src, target, targetIndex) {
        var srcIndex = src.parent.elements.indexOf(src);
        if (targetIndex > srcIndex) {
            targetIndex--;
        }
        this.panel.removeElement(src);
        this.panel.addElement(target, targetIndex);
    };
    DragDropPanelHelperV1.prototype.updateRowsOnElementAdded = function (element, index, dragDropInfo, thisElement) {
        if (!dragDropInfo) {
            dragDropInfo = new DragDropInfo(null, element);
            dragDropInfo.target = element;
            dragDropInfo.isEdge = this.panel.elements.length > 1;
            if (this.panel.elements.length < 2) {
                dragDropInfo.destination = thisElement;
            }
            else {
                dragDropInfo.isBottom = index > 0;
                if (index == 0) {
                    dragDropInfo.destination = this.panel.elements[1];
                }
                else {
                    dragDropInfo.destination = this.panel.elements[index - 1];
                }
            }
        }
        this.dragDropAddTargetToRow(dragDropInfo, null);
    };
    DragDropPanelHelperV1.prototype.dragDropAddTargetToRow = function (dragDropInfo, prevRow) {
        if (!dragDropInfo.destination)
            return true;
        if (this.dragDropAddTargetToEmptyPanel(dragDropInfo))
            return true;
        var dest = dragDropInfo.destination;
        var destRow = this.dragDropFindRow(dest);
        if (!destRow)
            return true;
        // if (settings.supportCreatorV2 && this.panel.isDesignMode) {
        //   if (destRow.elements.length > 1)
        //     return this.dragDropAddTargetToExistingRow(
        //       dragDropInfo,
        //       destRow,
        //       prevRow
        //     );
        //   else
        //     return this.dragDropAddTargetToNewRow(dragDropInfo, destRow, prevRow);
        // }
        if (!dragDropInfo.target.startWithNewLine)
            return this.dragDropAddTargetToExistingRow(dragDropInfo, destRow, prevRow);
        return this.dragDropAddTargetToNewRow(dragDropInfo, destRow, prevRow);
    };
    DragDropPanelHelperV1.prototype.dragDropAddTargetToEmptyPanel = function (dragDropInfo) {
        if (dragDropInfo.destination.isPage) {
            this.dragDropAddTargetToEmptyPanelCore(this.panel.root, dragDropInfo.target, dragDropInfo.isBottom);
            return true;
        }
        var dest = dragDropInfo.destination;
        if (dest.isPanel && !dragDropInfo.isEdge) {
            var panel = dest;
            if (dragDropInfo.target["template"] === dest) {
                return false;
            }
            if (dragDropInfo.nestedPanelDepth < 0 ||
                dragDropInfo.nestedPanelDepth >= panel.depth) {
                this.dragDropAddTargetToEmptyPanelCore(dest, dragDropInfo.target, dragDropInfo.isBottom);
                return true;
            }
        }
        return false;
    };
    DragDropPanelHelperV1.prototype.dragDropAddTargetToExistingRow = function (dragDropInfo, destRow, prevRow) {
        var index = destRow.elements.indexOf(dragDropInfo.destination);
        if (index == 0 &&
            !dragDropInfo.isBottom) {
            if (this.panel.isDesignModeV2) {
            }
            else if (destRow.elements[0].startWithNewLine) {
                if (destRow.index > 0) {
                    dragDropInfo.isBottom = true;
                    destRow = destRow.panel.rows[destRow.index - 1];
                    dragDropInfo.destination =
                        destRow.elements[destRow.elements.length - 1];
                    return this.dragDropAddTargetToExistingRow(dragDropInfo, destRow, prevRow);
                }
                else {
                    return this.dragDropAddTargetToNewRow(dragDropInfo, destRow, prevRow);
                }
            }
        }
        var prevRowIndex = -1;
        if (prevRow == destRow) {
            prevRowIndex = destRow.elements.indexOf(dragDropInfo.target);
        }
        if (dragDropInfo.isBottom)
            index++;
        var srcRow = this.panel.findRowByElement(dragDropInfo.source);
        if (srcRow == destRow &&
            srcRow.elements.indexOf(dragDropInfo.source) == index)
            return false;
        if (index == prevRowIndex)
            return false;
        if (prevRowIndex > -1) {
            destRow.elements.splice(prevRowIndex, 1);
            if (prevRowIndex < index)
                index--;
        }
        destRow.elements.splice(index, 0, dragDropInfo.target);
        destRow.updateVisible();
        return prevRowIndex < 0;
    };
    DragDropPanelHelperV1.prototype.dragDropAddTargetToNewRow = function (dragDropInfo, destRow, prevRow) {
        var targetRow = destRow.panel.createRowAndSetLazy(destRow.panel.rows.length);
        if (this.panel.isDesignModeV2) {
            targetRow.setIsLazyRendering(false);
        }
        targetRow.addElement(dragDropInfo.target);
        var index = destRow.index;
        if (dragDropInfo.isBottom) {
            index++;
        }
        //same row
        if (!!prevRow && prevRow.panel == targetRow.panel && prevRow.index == index)
            return false;
        var srcRow = this.panel.findRowByElement(dragDropInfo.source);
        if (!!srcRow &&
            srcRow.panel == targetRow.panel &&
            srcRow.elements.length == 1 &&
            srcRow.index == index)
            return false;
        destRow.panel.rows.splice(index, 0, targetRow);
        return true;
    };
    DragDropPanelHelperV1.prototype.dragDropAddTargetToEmptyPanelCore = function (panel, target, isBottom) {
        var targetRow = panel.createRow();
        targetRow.addElement(target);
        if (panel.elements.length == 0 || isBottom) {
            panel.rows.push(targetRow);
        }
        else {
            panel.rows.splice(0, 0, targetRow);
        }
    };
    return DragDropPanelHelperV1;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/panel-layout-column.ts
var panel_layout_column_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var panel_layout_column_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};


var panel_layout_column_PanelLayoutColumnModel = /** @class */ (function (_super) {
    panel_layout_column_extends(PanelLayoutColumnModel, _super);
    function PanelLayoutColumnModel(width, questionTitleWidth) {
        var _this = _super.call(this) || this;
        _this.effectiveWidth = width;
        _this.questionTitleWidth = questionTitleWidth;
        return _this;
    }
    PanelLayoutColumnModel.prototype.getType = function () {
        return "panellayoutcolumn";
    };
    PanelLayoutColumnModel.prototype.isEmpty = function () {
        return !this.width && !this.questionTitleWidth;
    };
    panel_layout_column_decorate([
        jsonobject_property()
    ], PanelLayoutColumnModel.prototype, "width", void 0);
    panel_layout_column_decorate([
        jsonobject_property({
            onSet: function (newValue, target, prevVal) {
                if (newValue !== prevVal) {
                    target.width = newValue;
                }
            }
        })
    ], PanelLayoutColumnModel.prototype, "effectiveWidth", void 0);
    panel_layout_column_decorate([
        jsonobject_property()
    ], PanelLayoutColumnModel.prototype, "questionTitleWidth", void 0);
    return PanelLayoutColumnModel;
}(base_Base));

Serializer.addClass("panellayoutcolumn", [
    { name: "effectiveWidth:number", isSerializable: false, minValue: 0 },
    { name: "width:number", visible: false },
    "questionTitleWidth",
], function (value) { return new panel_layout_column_PanelLayoutColumnModel(); });

// CONCATENATED MODULE: ./packages/survey-core/src/panel.ts
var panel_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var panel_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var panel_spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
    for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
        to[j] = from[i];
    return to;
};















var panel_QuestionRowModel = /** @class */ (function (_super) {
    panel_extends(QuestionRowModel, _super);
    function QuestionRowModel(panel) {
        var _this = _super.call(this) || this;
        _this.panel = panel;
        _this._scrollableParent = undefined;
        _this._updateVisibility = undefined;
        _this.visibleElementsAnimation = new animation_AnimationGroup(_this.getVisibleElementsAnimationOptions(), function (value) {
            _this.setWidth(value);
            _this.setPropertyValue("visibleElements", value);
        }, function () { return _this.visibleElements; });
        _this.idValue = QuestionRowModel.getRowId();
        _this.visible = panel.areInvisibleElementsShowing;
        _this.createNewArray("elements");
        _this.createNewArray("visibleElements");
        return _this;
    }
    QuestionRowModel.getRowId = function () {
        return "pr_" + QuestionRowModel.rowCounter++;
    };
    QuestionRowModel.prototype.startLazyRendering = function (rowContainerDiv, findScrollableContainer) {
        var _this = this;
        if (findScrollableContainer === void 0) { findScrollableContainer = findScrollableParent; }
        if (!DomDocumentHelper.isAvailable())
            return;
        this._scrollableParent = findScrollableContainer(rowContainerDiv);
        // if  this._scrollableParent is html the scroll event isn't fired, so we should use window
        if (this._scrollableParent === DomDocumentHelper.getDocumentElement()) {
            this._scrollableParent = DomWindowHelper.getWindow();
        }
        var hasScroll = this._scrollableParent.scrollHeight > this._scrollableParent.clientHeight;
        this.isNeedRender = !hasScroll;
        if (hasScroll) {
            this._updateVisibility = function () {
                var isRowContainerDivVisible = isElementVisible(rowContainerDiv, 50);
                if (!_this.isNeedRender && isRowContainerDivVisible) {
                    _this.isNeedRender = true;
                    _this.stopLazyRendering();
                }
            };
            setTimeout(function () {
                if (!!_this._scrollableParent &&
                    !!_this._scrollableParent.addEventListener) {
                    _this._scrollableParent.addEventListener("scroll", _this._updateVisibility);
                }
                _this.ensureVisibility();
            }, 10);
        }
    };
    QuestionRowModel.prototype.ensureVisibility = function () {
        if (!!this._updateVisibility) {
            this._updateVisibility();
        }
    };
    QuestionRowModel.prototype.stopLazyRendering = function () {
        if (!!this._scrollableParent &&
            !!this._updateVisibility &&
            !!this._scrollableParent.removeEventListener) {
            this._scrollableParent.removeEventListener("scroll", this._updateVisibility);
        }
        this._scrollableParent = undefined;
        this._updateVisibility = undefined;
    };
    QuestionRowModel.prototype.setIsLazyRendering = function (val) {
        this.isLazyRenderingValue = val;
        this.isNeedRender = !val;
    };
    QuestionRowModel.prototype.isLazyRendering = function () {
        return this.isLazyRenderingValue === true;
    };
    Object.defineProperty(QuestionRowModel.prototype, "id", {
        get: function () {
            return this.idValue;
        },
        enumerable: false,
        configurable: true
    });
    QuestionRowModel.prototype.equalsCore = function (obj) {
        return this == obj;
    };
    Object.defineProperty(QuestionRowModel.prototype, "elements", {
        get: function () {
            return this.getPropertyValue("elements");
        },
        enumerable: false,
        configurable: true
    });
    QuestionRowModel.prototype.getIsAnimationAllowed = function () {
        var _a;
        return _super.prototype.getIsAnimationAllowed.call(this) && this.visible && ((_a = this.panel) === null || _a === void 0 ? void 0 : _a.animationAllowed);
    };
    QuestionRowModel.prototype.getVisibleElementsAnimationOptions = function () {
        var _this = this;
        var beforeRunAnimation = function (el) {
            el.style.setProperty("--animation-height", el.offsetHeight + "px");
            el.style.setProperty("--animation-width", getElementWidth(el) + "px");
        };
        return {
            getRerenderEvent: function () { return _this.onElementRerendered; },
            isAnimationEnabled: function () { return _this.animationAllowed; },
            allowSyncRemovalAddition: false,
            getAnimatedElement: function (element) { return element.getWrapperElement(); },
            getLeaveOptions: function (element) {
                var surveyElement = element;
                var cssClasses = element.isPanel ? surveyElement.cssClasses.panel : surveyElement.cssClasses;
                return {
                    cssClass: cssClasses.fadeOut,
                    onBeforeRunAnimation: beforeRunAnimation
                };
            },
            getEnterOptions: function (element) {
                var surveyElement = element;
                var cssClasses = element.isPanel ? surveyElement.cssClasses.panel : surveyElement.cssClasses;
                return {
                    cssClass: cssClasses.fadeIn,
                    onBeforeRunAnimation: beforeRunAnimation
                };
            }
        };
    };
    Object.defineProperty(QuestionRowModel.prototype, "visibleElements", {
        get: function () {
            return this.getPropertyValue("visibleElements");
        },
        set: function (val) {
            if (!val.length) {
                this.visible = false;
                this.visibleElementsAnimation.cancel();
                return;
            }
            else {
                this.visible = true;
            }
            this.visibleElementsAnimation.sync(val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRowModel.prototype, "visible", {
        get: function () {
            return this.getPropertyValue("visible", true);
        },
        set: function (val) {
            this.setPropertyValue("visible", val);
            this.onVisibleChangedCallback && this.onVisibleChangedCallback();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRowModel.prototype, "isNeedRender", {
        get: function () {
            return this.getPropertyValue("isneedrender", true);
        },
        set: function (val) {
            this.setPropertyValue("isneedrender", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionRowModel.prototype.updateVisible = function () {
        var visElements = [];
        for (var i = 0; i < this.elements.length; i++) {
            if (this.elements[i].isVisible) {
                visElements.push(this.elements[i]);
            }
        }
        this.visibleElements = visElements;
        return;
    };
    QuestionRowModel.prototype.addElement = function (q) {
        this.elements.push(q);
        this.updateVisible();
    };
    Object.defineProperty(QuestionRowModel.prototype, "index", {
        get: function () {
            return this.panel.rows.indexOf(this);
        },
        enumerable: false,
        configurable: true
    });
    QuestionRowModel.prototype.setWidth = function (visibleElement) {
        var _a;
        var visCount = visibleElement.length;
        if (visCount == 0)
            return;
        var isSingleInRow = visibleElement.length === 1;
        var counter = 0;
        var preSetWidthElements = [];
        for (var i = 0; i < this.elements.length; i++) {
            var el = this.elements[i];
            if (el.isVisible) {
                el.isSingleInRow = isSingleInRow;
                var width = this.getElementWidth(el);
                if (!!width) {
                    el.renderWidth = this.getRenderedWidthFromWidth(width);
                    preSetWidthElements.push(el);
                }
                if (counter < visCount - 1 && !(this.panel.isDefaultV2Theme || ((_a = this.panel.parentQuestion) === null || _a === void 0 ? void 0 : _a.isDefaultV2Theme))) {
                    el.rightIndent = 1;
                }
                else {
                    el.rightIndent = 0;
                }
                counter++;
            }
            else {
                el.renderWidth = "";
            }
        }
        for (var i = 0; i < this.elements.length; i++) {
            var el = this.elements[i];
            if (!el.isVisible || preSetWidthElements.indexOf(el) > -1)
                continue;
            if (preSetWidthElements.length == 0) {
                el.renderWidth = Number.parseFloat((100 / visCount).toFixed(6)) + "%";
            }
            else {
                el.renderWidth = this.getRenderedCalcWidth(el, preSetWidthElements, visCount);
            }
        }
    };
    QuestionRowModel.prototype.getRenderedCalcWidth = function (el, preSetWidthElements, visCount) {
        var expression = "100%";
        for (var i = 0; i < preSetWidthElements.length; i++) {
            expression += " - " + preSetWidthElements[i].renderWidth;
        }
        var calcWidthEl = visCount - preSetWidthElements.length;
        if (calcWidthEl > 1) {
            expression = "(" + expression + ")/" + calcWidthEl.toString();
        }
        return "calc(" + expression + ")";
    };
    QuestionRowModel.prototype.getElementWidth = function (el) {
        var width = el.width;
        if (!width || typeof width !== "string")
            return "";
        return width.trim();
    };
    QuestionRowModel.prototype.getRenderedWidthFromWidth = function (width) {
        return helpers_Helpers.isNumber(width) ? width + "px" : width;
    };
    QuestionRowModel.prototype.dispose = function () {
        _super.prototype.dispose.call(this);
        this.stopLazyRendering();
    };
    QuestionRowModel.prototype.getRowCss = function () {
        return new CssClassBuilder()
            .append(this.panel.cssClasses.row)
            .append(this.panel.cssClasses.rowCompact, this.panel["isCompact"])
            .append(this.panel.cssClasses.pageRow, this.panel.isPage || this.panel.showPanelAsPage)
            .append(this.panel.cssClasses.rowMultiple, this.visibleElements.length > 1)
            .toString();
    };
    QuestionRowModel.prototype.setRootElement = function (element) {
        this.rootElement = element;
    };
    QuestionRowModel.prototype.getRootElement = function () {
        return this.rootElement;
    };
    QuestionRowModel.rowCounter = 100;
    panel_decorate([
        jsonobject_property({ defaultValue: null })
    ], QuestionRowModel.prototype, "dragTypeOverMe", void 0);
    return QuestionRowModel;
}(base_Base));

/**
 * A base class for the [PanelModel](https://surveyjs.io/form-library/documentation/panelmodel) and [PageModel](https://surveyjs.io/form-library/documentation/pagemodel) classes.
 */
var panel_PanelModelBase = /** @class */ (function (_super) {
    panel_extends(PanelModelBase, _super);
    function PanelModelBase(name) {
        if (name === void 0) { name = ""; }
        var _this = _super.call(this, name) || this;
        _this.isQuestionsReady = false;
        _this.questionsValue = new Array();
        _this._columns = undefined;
        _this._columnsReady = false;
        _this.rowsAnimation = new animation_AnimationGroup(_this.getRowsAnimationOptions(), function (value) {
            _this.setPropertyValue("visibleRows", value);
        }, function () { return _this.visibleRows; });
        _this.isRandomizing = false;
        _this.onColumnPropertyValueChangedCallback = function (name, oldValue, newValue, sender, arrayChanges) {
            if (_this._columnsReady) {
                _this.updateColumnWidth(_this.layoutColumns);
                _this.updateRootStyle();
            }
        };
        _this.locCountRowUpdates = 0;
        _this.createNewArray("rows", function (el, index) { _this.onAddRow(el); }, function (el) { _this.onRemoveRow(el); });
        _this.createNewArray("visibleRows");
        _this.elementsValue = _this.createNewArray("elements", _this.onAddElement.bind(_this), _this.onRemoveElement.bind(_this));
        _this.id = PanelModelBase.getPanelId();
        _this.addExpressionProperty("visibleIf", function (obj, res) { _this.visible = res === true; }, function (obj) { return !_this.areInvisibleElementsShowing; });
        _this.addExpressionProperty("enableIf", function (obj, res) { _this.readOnly = res === false; });
        _this.addExpressionProperty("requiredIf", function (obj, res) { _this.isRequired = res === true; });
        _this.createLocalizableString("requiredErrorText", _this);
        _this.createLocalizableString("navigationTitle", _this, true).onGetTextCallback = function (text) {
            return text || _this.title || _this.name;
        };
        _this.registerPropertyChangedHandlers(["questionTitleLocation"], function () {
            _this.onVisibleChanged.bind(_this);
            _this.updateElementCss(true);
        });
        _this.registerPropertyChangedHandlers(["questionStartIndex", "showQuestionNumbers"], function () {
            _this.updateVisibleIndexes();
        });
        _this.dragDropPanelHelper = new drag_drop_panel_helper_v1_DragDropPanelHelperV1(_this);
        return _this;
    }
    PanelModelBase.getPanelId = function () {
        return "sp_" + PanelModelBase.panelCounter++;
    };
    PanelModelBase.prototype.onAddRow = function (row) {
        var _this = this;
        this.onRowVisibleChanged();
        row.onVisibleChangedCallback = function () { return _this.onRowVisibleChanged(); };
    };
    PanelModelBase.prototype.getRowsAnimationOptions = function () {
        var _this = this;
        var beforeRunAnimation = function (el) {
            el.style.setProperty("--animation-height", el.offsetHeight + "px");
        };
        return {
            getRerenderEvent: function () { return _this.onElementRerendered; },
            isAnimationEnabled: function () { return _this.animationAllowed; },
            getAnimatedElement: function (row) { return row.getRootElement(); },
            getLeaveOptions: function (_) {
                return {
                    cssClass: _this.cssClasses.rowFadeOut,
                    onBeforeRunAnimation: beforeRunAnimation
                };
            },
            getEnterOptions: function (_, animationInfo) {
                var cssClasses = _this.cssClasses;
                return {
                    cssClass: new CssClassBuilder().append(cssClasses.rowFadeIn).append(cssClasses.rowDelayedFadeIn, animationInfo.isDeletingRunning).toString(),
                    onBeforeRunAnimation: beforeRunAnimation
                };
            }
        };
    };
    Object.defineProperty(PanelModelBase.prototype, "visibleRows", {
        get: function () {
            return this.getPropertyValue("visibleRows");
        },
        set: function (val) {
            this.rowsAnimation.sync(val);
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.onRemoveRow = function (row) {
        row.visibleElementsAnimation.cancel();
        this.visibleRows = this.rows.filter(function (row) { return row.visible; });
        row.onVisibleChangedCallback = undefined;
    };
    PanelModelBase.prototype.onRowVisibleChanged = function () {
        this.visibleRows = this.rows.filter(function (row) { return row.visible; });
    };
    PanelModelBase.prototype.getType = function () {
        return "panelbase";
    };
    PanelModelBase.prototype.setSurveyImpl = function (value, isLight) {
        this.blockAnimations();
        _super.prototype.setSurveyImpl.call(this, value, isLight);
        if (this.isDesignMode)
            this.onVisibleChanged();
        for (var i = 0; i < this.elements.length; i++) {
            this.elements[i].setSurveyImpl(value, isLight);
        }
        this.releaseAnimations();
    };
    PanelModelBase.prototype.endLoadingFromJson = function () {
        var _this = this;
        _super.prototype.endLoadingFromJson.call(this);
        this.updateDescriptionVisibility(this.description);
        this.markQuestionListDirty();
        this.onRowsChanged();
        this.layoutColumns.forEach(function (col) {
            col.onPropertyValueChangedCallback = _this.onColumnPropertyValueChangedCallback;
        });
    };
    Object.defineProperty(PanelModelBase.prototype, "hasTitle", {
        get: function () {
            return ((this.canShowTitle() && this.locTitle.textOrHtml.length > 0) ||
                (this.isDesignMode && (this.showTitle && this.isInteractiveDesignElement && settings.designMode.showEmptyTitles)));
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.delete = function (doDispose) {
        if (doDispose === void 0) { doDispose = true; }
        this.deletePanel();
        this.removeFromParent();
        if (doDispose) {
            this.dispose();
        }
    };
    PanelModelBase.prototype.deletePanel = function () {
        var els = this.elements;
        for (var i = 0; i < els.length; i++) {
            var el = els[i];
            if (el.isPanel) {
                el.deletePanel();
            }
            this.onRemoveElementNotifySurvey(el);
        }
    };
    PanelModelBase.prototype.removeFromParent = function () { };
    PanelModelBase.prototype.canShowTitle = function () { return true; };
    Object.defineProperty(PanelModelBase.prototype, "_showDescription", {
        get: function () {
            if (!this.hasTitle && this.isDesignMode)
                return false;
            return this.survey && this.survey.showPageTitles && this.hasDescription ||
                (this.showDescription && this.isDesignMode &&
                    settings.designMode.showEmptyDescriptions);
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.localeChanged = function () {
        _super.prototype.localeChanged.call(this);
        for (var i = 0; i < this.elements.length; i++) {
            this.elements[i].localeChanged();
        }
    };
    PanelModelBase.prototype.locStrsChanged = function () {
        _super.prototype.locStrsChanged.call(this);
        for (var i = 0; i < this.elements.length; i++) {
            this.elements[i].locStrsChanged();
        }
    };
    PanelModelBase.prototype.getMarkdownHtml = function (text, name) {
        if (name === "navigationTitle" && this.locNavigationTitle.isEmpty) {
            return this.locTitle.renderedHtml || this.name;
        }
        return _super.prototype.getMarkdownHtml.call(this, text, name);
    };
    Object.defineProperty(PanelModelBase.prototype, "locNavigationTitle", {
        get: function () {
            return this.getLocalizableString("navigationTitle");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "renderedNavigationTitle", {
        get: function () {
            return this.locNavigationTitle.renderedHtml;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "requiredText", {
        /**
         * Returns a character or text string that indicates a required panel/page.
         * @see SurveyModel.requiredText
         * @see isRequired
         */
        get: function () {
            return !!this.survey && this.isRequired
                ? this.survey.requiredText
                : "";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "titlePattern", {
        get: function () {
            return !!this.survey ? this.survey.questionTitlePattern : "numTitleRequire";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "isRequireTextOnStart", {
        get: function () {
            return this.isRequired && this.titlePattern == "requireNumTitle";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "isRequireTextBeforeTitle", {
        get: function () {
            return this.isRequired && this.titlePattern == "numRequireTitle";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "isRequireTextAfterTitle", {
        get: function () {
            return this.isRequired && this.titlePattern == "numTitleRequire";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "requiredErrorText", {
        /**
         * Specifies a custom error message for a required panel/page.
         * @see isRequired
         * @see requiredIf
         */
        get: function () {
            return this.getLocalizableStringText("requiredErrorText");
        },
        set: function (val) {
            this.setLocalizableStringText("requiredErrorText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "locRequiredErrorText", {
        get: function () {
            return this.getLocalizableString("requiredErrorText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "questionsOrder", {
        /**
         * Specifies the sort order of questions in the panel/page.
         *
         * Possible values:
         *
         * - `"initial"` - Preserves the original order of questions.
         * - `"random"` - Displays questions in random order.
         * - `"default"` (default) - Inherits the setting from the Survey's `questionsOrder` property.
         * @see SurveyModel.questionsOrder
         * @see areQuestionsRandomized
         */
        get: function () {
            return this.getPropertyValue("questionsOrder");
        },
        set: function (val) {
            this.setPropertyValue("questionsOrder", val);
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.canRandomize = function (isRandom) {
        return isRandom && (this.questionsOrder !== "initial") || this.questionsOrder === "random";
    };
    PanelModelBase.prototype.randomizeElements = function (isRandom) {
        if (!this.canRandomize(isRandom) || this.isRandomizing)
            return;
        this.isRandomizing = true;
        var oldElements = [];
        var elements = this.elements;
        for (var i = 0; i < elements.length; i++) {
            oldElements.push(elements[i]);
        }
        var newElements = helpers_Helpers.randomizeArray(oldElements);
        this.setArrayPropertyDirectly("elements", newElements, false);
        this.updateRows();
        this.updateVisibleIndexes();
        this.isRandomizing = false;
    };
    Object.defineProperty(PanelModelBase.prototype, "areQuestionsRandomized", {
        /**
         * Returns `true` if elements in this panel/page are arranged in random order.
         * @see questionsOrder
         */
        get: function () {
            var order = this.questionsOrder == "default" && this.survey
                ? this.survey.questionsOrder
                : this.questionsOrder;
            return order == "random";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "parent", {
        /**
         * Returns a survey element (panel or page) that contains this panel and allows you to move this question to a different survey element.
         *
         * This property is always `null` for the `PageModel` object.
         */
        get: function () {
            return this.getPropertyValue("parent", null);
        },
        set: function (val) {
            this.setPropertyValue("parent", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "depth", {
        get: function () {
            if (this.parent == null)
                return 0;
            return this.parent.depth + 1;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "visibleIf", {
        /**
         * A Boolean expression. If it evaluates to `false`, this panel/page becomes hidden.
         *
         * A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
         *
         * Refer to the following help topic for more information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see visible
         * @see isVisible
         */
        get: function () {
            return this.getPropertyValue("visibleIf", "");
        },
        set: function (val) {
            this.setPropertyValue("visibleIf", val);
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.calcCssClasses = function (css) {
        var classes = { panel: {}, error: {}, row: "", rowFadeIn: "", rowFadeOut: "", rowDelayedFadeIn: "", rowMultiple: "", pageRow: "", rowCompact: "" };
        this.copyCssClasses(classes.panel, css.panel);
        this.copyCssClasses(classes.error, css.error);
        if (!!css.pageRow) {
            classes.pageRow = css.pageRow;
        }
        if (!!css.rowCompact) {
            classes.rowCompact = css.rowCompact;
        }
        if (!!css.row) {
            classes.row = css.row;
        }
        if (!!css.rowFadeIn) {
            classes.rowFadeIn = css.rowFadeIn;
        }
        if (!!css.rowFadeOut) {
            classes.rowFadeOut = css.rowFadeOut;
        }
        if (!!css.rowDelayedFadeIn) {
            classes.rowDelayedFadeIn = css.rowDelayedFadeIn;
        }
        if (!!css.rowMultiple) {
            classes.rowMultiple = css.rowMultiple;
        }
        if (this.survey) {
            this.survey.updatePanelCssClasses(this, classes);
        }
        return classes;
    };
    Object.defineProperty(PanelModelBase.prototype, "id", {
        /**
         * An auto-generated unique element identifier.
         */
        get: function () {
            return this.getPropertyValue("id");
        },
        set: function (val) {
            this.setPropertyValue("id", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "isPanel", {
        /**
         * Returns `true` if the survey element is a panel.
         * @see Base.getType
         */
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.getPanel = function () {
        return this;
    };
    PanelModelBase.prototype.getLayoutType = function () {
        return "row";
    };
    PanelModelBase.prototype.isLayoutTypeSupported = function (layoutType) {
        return layoutType !== "flow";
    };
    Object.defineProperty(PanelModelBase.prototype, "questions", {
        /**
         * An array of all questions within this panel/page. Includes questions within nested panels.
         * @see elements
         */
        get: function () {
            if (!this.isQuestionsReady) {
                this.questionsValue = [];
                for (var i = 0; i < this.elements.length; i++) {
                    var el = this.elements[i];
                    if (el.isPanel) {
                        var qs = el.questions;
                        for (var j = 0; j < qs.length; j++) {
                            this.questionsValue.push(qs[j]);
                        }
                    }
                    else {
                        this.questionsValue.push(el);
                    }
                }
                this.isQuestionsReady = true;
            }
            return this.questionsValue;
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.getQuestions = function (includeNested) {
        var res = this.questions;
        if (!includeNested)
            return res;
        var res2 = [];
        res.forEach(function (q) {
            res2.push(q);
            q.getNestedQuestions().forEach(function (nQ) { return res2.push(nQ); });
        });
        return res2;
    };
    PanelModelBase.prototype.getValidName = function (name) {
        if (!!name)
            return name.trim();
        return name;
    };
    /**
     * Returns a question with a specified `name`. This method does not find questions within nested panels.
     * @param name A question name.
     */
    PanelModelBase.prototype.getQuestionByName = function (name) {
        var questions = this.questions;
        for (var i = 0; i < questions.length; i++) {
            if (questions[i].name == name)
                return questions[i];
        }
        return null;
    };
    /**
     * Returns a survey element with a specified `name`. This method can find survey elements within nested elements.
     * @param name An element name.
     */
    PanelModelBase.prototype.getElementByName = function (name) {
        var elements = this.elements;
        for (var i = 0; i < elements.length; i++) {
            var el = elements[i];
            if (el.name == name)
                return el;
            var pnl = el.getPanel();
            if (!!pnl) {
                var res = pnl.getElementByName(name);
                if (!!res)
                    return res;
            }
        }
        return null;
    };
    PanelModelBase.prototype.getQuestionByValueName = function (valueName) {
        var res = this.getQuestionsByValueName(valueName);
        return res.length > 0 ? res[0] : null;
    };
    PanelModelBase.prototype.getQuestionsByValueName = function (valueName) {
        var res = [];
        var questions = this.questions;
        for (var i = 0; i < questions.length; i++) {
            if (questions[i].getValueName() == valueName)
                res.push(questions[i]);
        }
        return res;
    };
    /**
     * Returns a JSON object with question values nested in the panel/page.
     * @see getDisplayValue
     */
    PanelModelBase.prototype.getValue = function () {
        var data = {};
        this.collectValues(data, 0);
        return data;
    };
    PanelModelBase.prototype.collectValues = function (data, level) {
        var elements = this.elements;
        if (level === 0) {
            elements = this.questions;
        }
        var hasValue = false;
        for (var i = 0; i < elements.length; i++) {
            var el = elements[i];
            if (el.isPanel || el.isPage) {
                var panelData = {};
                if (el.collectValues(panelData, level - 1)) {
                    data[el.name] = panelData;
                    hasValue = true;
                }
            }
            else {
                var q = el;
                if (!q.isEmpty()) {
                    var valueName = q.getValueName();
                    data[valueName] = q.value;
                    if (!!this.data) {
                        var comment = this.data.getComment(valueName);
                        if (!!comment) {
                            data[valueName + base_Base.commentSuffix] = comment;
                        }
                    }
                }
                hasValue = true;
            }
        }
        return true;
    };
    /**
     * Returns a JSON object with display texts that correspond to question values nested in the panel/page.
     * @param keysAsText Pass `true` if not only values in the object should be display texts, but also keys. Default value: `false`.
     * @see getValue
     */
    PanelModelBase.prototype.getDisplayValue = function (keysAsText) {
        var data = {};
        var questions = this.questions;
        for (var i = 0; i < questions.length; i++) {
            var q = questions[i];
            if (q.isEmpty())
                continue;
            var valueName = keysAsText ? q.title : q.getValueName();
            data[valueName] = q.getDisplayValue(keysAsText);
        }
        return data;
    };
    /**
     * Returns a JSON object with comments left to questions within this panel/page. Question names are used as keys.
     */
    PanelModelBase.prototype.getComments = function () {
        var comments = {};
        if (!this.data)
            return comments;
        var questions = this.questions;
        for (var i = 0; i < questions.length; i++) {
            var q = questions[i];
            var comment = this.data.getComment(q.getValueName());
            if (!!comment) {
                comments[q.getValueName()] = comment;
            }
        }
        return comments;
    };
    /**
     * Removes values that cannot be assigned to nested questions, for example, choices unlisted in the `choices` array.
     *
     * Call this method after you assign new question values in code to ensure that they are acceptable.
     *
     * > This method does not remove values for invisible questions and values that fail validation. Call the `validate()` method to validate newly assigned values.
     *
     * @see validate
     */
    PanelModelBase.prototype.clearIncorrectValues = function () {
        for (var i = 0; i < this.elements.length; i++) {
            this.elements[i].clearIncorrectValues();
        }
    };
    /**
     * Empties the `errors` array for this panel/page and all its child elements (panels and questions).
     * @see errors
     */
    PanelModelBase.prototype.clearErrors = function () {
        for (var i = 0; i < this.elements.length; i++) {
            this.elements[i].clearErrors();
        }
        this.errors = [];
    };
    PanelModelBase.prototype.markQuestionListDirty = function () {
        this.isQuestionsReady = false;
        if (this.parent)
            this.parent.markQuestionListDirty();
    };
    Object.defineProperty(PanelModelBase.prototype, "elements", {
        /**
         * An array of all survey elements (questions or panels) within this panel/page. Does not include questions within nested panels.
         * @see questions
         */
        get: function () {
            return this.elementsValue;
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.getElementsInDesign = function (includeHidden) {
        if (includeHidden === void 0) { includeHidden = false; }
        return this.elements;
    };
    /**
     * Checks whether a given element belongs to this panel/page or nested panels.
     * @param element A survey element to check.
     */
    PanelModelBase.prototype.containsElement = function (element) {
        for (var i = 0; i < this.elements.length; i++) {
            var el = this.elements[i];
            if (el == element)
                return true;
            var pnl = el.getPanel();
            if (!!pnl) {
                if (pnl.containsElement(element))
                    return true;
            }
        }
        return false;
    };
    Object.defineProperty(PanelModelBase.prototype, "isRequired", {
        /**
         * Makes the panel/page require an answer at least in one nested question. If a respondent leaves the panel/page without any answers, the survey displays a validation error.
         * @see requiredIf
         * @see [Data Validation](https://surveyjs.io/form-library/documentation/data-validation)
         */
        get: function () {
            return this.getPropertyValue("isRequired");
        },
        set: function (val) {
            this.setPropertyValue("isRequired", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "requiredIf", {
        /**
         * A Boolean expression. If it evaluates to `true`, this panel/page becomes required (at least one question in the panel/page should have an answer).
         *
         * A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
         *
         * Refer to the following help topic for more information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see isRequired
         */
        get: function () {
            return this.getPropertyValue("requiredIf", "");
        },
        set: function (val) {
            this.setPropertyValue("requiredIf", val);
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.searchText = function (text, founded) {
        _super.prototype.searchText.call(this, text, founded);
        for (var i = 0; i < this.elements.length; i++) {
            this.elements[i].searchText(text, founded);
        }
    };
    PanelModelBase.prototype.hasErrors = function (fireCallback, focusOnFirstError, rec) {
        if (fireCallback === void 0) { fireCallback = true; }
        if (focusOnFirstError === void 0) { focusOnFirstError = false; }
        if (rec === void 0) { rec = null; }
        return !this.validate(fireCallback, focusOnFirstError, rec);
    };
    /**
     * Validates questions within this panel or page and returns `false` if the validation fails.
     * @param fireCallback *(Optional)* Pass `false` if you do not want to show validation errors in the UI.
     * @param focusOnFirstError *(Optional)* Pass `true` if you want to focus the first question with a validation error.
     * @see [Data Validation](https://surveyjs.io/form-library/documentation/data-validation)
     */
    PanelModelBase.prototype.validate = function (fireCallback, focusOnFirstError, rec) {
        if (fireCallback === void 0) { fireCallback = true; }
        if (focusOnFirstError === void 0) { focusOnFirstError = false; }
        if (rec === void 0) { rec = null; }
        rec = !!rec
            ? rec
            : {
                fireCallback: fireCallback,
                focusOnFirstError: focusOnFirstError,
                firstErrorQuestion: null,
                result: false,
            };
        if (rec.result !== true)
            rec.result = false;
        this.hasErrorsCore(rec);
        return !rec.result;
    };
    PanelModelBase.prototype.validateContainerOnly = function () {
        this.hasErrorsInPanels({ fireCallback: true });
        if (!!this.parent) {
            this.parent.validateContainerOnly();
        }
    };
    PanelModelBase.prototype.onQuestionValueChanged = function (el) {
        var index = this.questions.indexOf(el);
        if (index < 0)
            return;
        var dif = 5;
        var max = this.questions.length - 1;
        var start = index - dif > 0 ? index - dif : 0;
        var end = index + dif < max ? index + dif : max;
        for (var i = start; i <= end; i++) {
            if (i === index)
                continue;
            var q = this.questions[i];
            if (q.errors.length > 0 && q.validate(false)) {
                q.validate(true);
            }
        }
    };
    PanelModelBase.prototype.hasErrorsInPanels = function (rec) {
        var errors = [];
        this.hasRequiredError(rec, errors);
        if (this.survey) {
            var customError = this.survey.validatePanel(this);
            if (customError) {
                errors.push(customError);
                rec.result = true;
            }
        }
        if (!!rec.fireCallback) {
            if (!!this.survey) {
                this.survey.beforeSettingPanelErrors(this, errors);
            }
            this.errors = errors;
        }
    };
    //ISurveyErrorOwner
    PanelModelBase.prototype.getErrorCustomText = function (text, error) {
        if (!!this.survey)
            return this.survey.getSurveyErrorCustomText(this, text, error);
        return text;
    };
    PanelModelBase.prototype.hasRequiredError = function (rec, errors) {
        if (!this.isRequired)
            return;
        var visQuestions = [];
        this.addQuestionsToList(visQuestions, true);
        if (visQuestions.length == 0)
            return;
        for (var i = 0; i < visQuestions.length; i++) {
            if (!visQuestions[i].isEmpty())
                return;
        }
        rec.result = true;
        errors.push(new OneAnswerRequiredError(this.requiredErrorText, this));
        if (rec.focusOnFirstError && !rec.firstErrorQuestion) {
            rec.firstErrorQuestion = visQuestions[0];
        }
    };
    PanelModelBase.prototype.hasErrorsCore = function (rec) {
        var elements = this.elements;
        var element = null;
        var firstErroredEl = null;
        for (var i = 0; i < elements.length; i++) {
            element = elements[i];
            if (!element.isVisible)
                continue;
            if (element.isPanel) {
                element.hasErrorsCore(rec);
            }
            else {
                var question = element;
                if (!question.validate(rec.fireCallback, rec)) {
                    if (!firstErroredEl) {
                        firstErroredEl = question;
                    }
                    if (!rec.firstErrorQuestion) {
                        rec.firstErrorQuestion = question;
                    }
                    rec.result = true;
                }
            }
        }
        this.hasErrorsInPanels(rec);
        this.updateContainsErrors();
        if (!firstErroredEl && this.errors.length > 0) {
            firstErroredEl = this.getFirstQuestionToFocus(false, true);
            if (!rec.firstErrorQuestion) {
                rec.firstErrorQuestion = firstErroredEl;
            }
        }
        if (rec.fireCallback && firstErroredEl) {
            if (firstErroredEl === rec.firstErrorQuestion && rec.focusOnFirstError) {
                firstErroredEl.focus(true);
            }
            else {
                firstErroredEl.expandAllParents();
            }
        }
    };
    PanelModelBase.prototype.getContainsErrors = function () {
        var res = _super.prototype.getContainsErrors.call(this);
        if (res)
            return res;
        var elements = this.elements;
        for (var i = 0; i < elements.length; i++) {
            if (elements[i].containsErrors)
                return true;
        }
        return false;
    };
    PanelModelBase.prototype.updateElementVisibility = function () {
        for (var i = 0; i < this.elements.length; i++) {
            var el = this.elements[i];
            el.setPropertyValue("isVisible", el.isVisible);
            if (el.isPanel) {
                el.updateElementVisibility();
            }
        }
    };
    PanelModelBase.prototype.getFirstQuestionToFocus = function (withError, ignoreCollapseState) {
        if (withError === void 0) { withError = false; }
        if (ignoreCollapseState === void 0) { ignoreCollapseState = false; }
        if (!withError && !ignoreCollapseState && this.isCollapsed)
            return null;
        var elements = this.elements;
        for (var i = 0; i < elements.length; i++) {
            var el = elements[i];
            if (!el.isVisible || !ignoreCollapseState && el.isCollapsed)
                continue;
            if (el.isPanel) {
                var res = el.getFirstQuestionToFocus(withError, ignoreCollapseState);
                if (!!res)
                    return res;
            }
            else {
                var q = el.getFirstQuestionToFocus(withError);
                if (!!q)
                    return q;
            }
        }
        return null;
    };
    /**
     * Focuses the first question in this panel/page.
     * @see focusFirstErrorQuestion
     */
    PanelModelBase.prototype.focusFirstQuestion = function () {
        var q = this.getFirstQuestionToFocus();
        if (!!q) {
            q.focus();
        }
    };
    /**
     * Focuses the first question with a validation error in this panel/page.
     * @see validate
     * @see focusFirstQuestion
     */
    PanelModelBase.prototype.focusFirstErrorQuestion = function () {
        var q = this.getFirstQuestionToFocus(true);
        if (!!q) {
            q.focus();
        }
    };
    PanelModelBase.prototype.addQuestionsToList = function (list, visibleOnly, includingDesignTime) {
        if (visibleOnly === void 0) { visibleOnly = false; }
        if (includingDesignTime === void 0) { includingDesignTime = false; }
        this.addElementsToList(list, visibleOnly, includingDesignTime, false);
    };
    PanelModelBase.prototype.addPanelsIntoList = function (list, visibleOnly, includingDesignTime) {
        if (visibleOnly === void 0) { visibleOnly = false; }
        if (includingDesignTime === void 0) { includingDesignTime = false; }
        this.addElementsToList(list, visibleOnly, includingDesignTime, true);
    };
    PanelModelBase.prototype.addElementsToList = function (list, visibleOnly, includingDesignTime, isPanel) {
        if (visibleOnly && !this.visible)
            return;
        this.addElementsToListCore(list, this.elements, visibleOnly, includingDesignTime, isPanel);
    };
    PanelModelBase.prototype.addElementsToListCore = function (list, elements, visibleOnly, includingDesignTime, isPanel) {
        for (var i = 0; i < elements.length; i++) {
            var el = elements[i];
            if (visibleOnly && !el.visible)
                continue;
            if ((isPanel && el.isPanel) || (!isPanel && !el.isPanel)) {
                list.push(el);
            }
            if (el.isPanel) {
                el.addElementsToListCore(list, el.elements, visibleOnly, includingDesignTime, isPanel);
            }
            else {
                if (includingDesignTime) {
                    this.addElementsToListCore(list, el.getElementsInDesign(false), visibleOnly, includingDesignTime, isPanel);
                }
            }
        }
    };
    PanelModelBase.prototype.calcMaxRowColSpan = function () {
        var maxRowColSpan = 0;
        this.rows.forEach(function (row) {
            var curRowSpan = 0;
            var userDefinedRow = false;
            row.elements.forEach(function (el) {
                if (!!el.width) {
                    userDefinedRow = true;
                }
                curRowSpan += (el.colSpan || 1);
            });
            if (!userDefinedRow && curRowSpan > maxRowColSpan)
                maxRowColSpan = curRowSpan;
        });
        return maxRowColSpan;
    };
    PanelModelBase.prototype.updateColumnWidth = function (columns) {
        var remainingSpace = 0, remainingColCount = 0;
        columns.forEach(function (col) {
            if (!col.width) {
                remainingColCount++;
            }
            else {
                remainingSpace += col.width;
                col.setPropertyValue("effectiveWidth", col.width);
            }
        });
        if (!!remainingColCount) {
            var oneColumnWidth = roundTo2Decimals((100 - remainingSpace) / remainingColCount);
            for (var index = 0; index < columns.length; index++) {
                if (!columns[index].width) {
                    columns[index].setPropertyValue("effectiveWidth", oneColumnWidth);
                }
            }
        }
    };
    PanelModelBase.prototype.updateColumns = function () {
        this._columns = undefined;
        this.updateRootStyle();
    };
    PanelModelBase.prototype.updateRootStyle = function () {
        var _a;
        _super.prototype.updateRootStyle.call(this);
        (_a = this.elements) === null || _a === void 0 ? void 0 : _a.forEach(function (el) { return el.updateRootStyle(); });
    };
    PanelModelBase.prototype.updateCustomWidgets = function () {
        for (var i = 0; i < this.elements.length; i++) {
            this.elements[i].updateCustomWidgets();
        }
    };
    Object.defineProperty(PanelModelBase.prototype, "questionTitleLocation", {
        /**
         * Sets a title location relative to the input field for questions that belong to this panel/page.
         *
         * Use this property to override the `questionTitleLocation` property specified for the survey. You can also set the `titleLocation` property for individual questions.
         *
         * Possible values:
         *
         * - `"default"` (default) - Inherits the setting from the `questionTitleLocation` property specified for the survey.
         * - `"top"` - Displays the title above the input field.
         * - `"bottom"` - Displays the title below the input field.
         * - `"left"` - Displays the title to the left of the input field.
         * - `"hidden"` - Hides the question title.
         *
         * > Certain question types (Matrix, Multiple Text) do not support the `"left"` value. For them, the `"top"` value is used.
         * @see SurveyModel.questionTitleLocation
         */
        get: function () {
            return this.getPropertyValue("questionTitleLocation");
        },
        set: function (value) {
            this.setPropertyValue("questionTitleLocation", value.toLowerCase());
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.getQuestionTitleLocation = function () {
        if (this.onGetQuestionTitleLocation)
            return this.onGetQuestionTitleLocation();
        if (this.questionTitleLocation != "default")
            return this.questionTitleLocation;
        if (this.parent)
            return this.parent.getQuestionTitleLocation();
        return this.survey ? this.survey.questionTitleLocation : "top";
    };
    PanelModelBase.prototype.availableQuestionTitleWidth = function () {
        var questionTitleLocation = this.getQuestionTitleLocation();
        if (questionTitleLocation === "left")
            return true;
        return this.hasElementWithTitleLocationLeft();
    };
    PanelModelBase.prototype.hasElementWithTitleLocationLeft = function () {
        var result = this.elements.some(function (el) {
            if (el instanceof PanelModelBase) {
                return el.hasElementWithTitleLocationLeft();
            }
            else if (el instanceof question_Question) {
                return el.getTitleLocation() === "left";
            }
        });
        return result;
    };
    PanelModelBase.prototype.getQuestionTitleWidth = function () {
        return this.questionTitleWidth || this.parent && this.parent.getQuestionTitleWidth();
    };
    Object.defineProperty(PanelModelBase.prototype, "columns", {
        get: function () {
            if (!this._columns) {
                this.generateColumns();
            }
            return this._columns || [];
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.generateColumns = function () {
        var maxRowColSpan = this.calcMaxRowColSpan();
        var columns = [].concat(this.layoutColumns);
        if (maxRowColSpan <= this.layoutColumns.length) {
            columns = this.layoutColumns.slice(0, maxRowColSpan);
        }
        else {
            for (var index = this.layoutColumns.length; index < maxRowColSpan; index++) {
                var newCol = new panel_layout_column_PanelLayoutColumnModel();
                newCol.onPropertyValueChangedCallback = this.onColumnPropertyValueChangedCallback;
                columns.push(newCol);
            }
        }
        this._columns = columns;
        try {
            this._columnsReady = false;
            this.updateColumnWidth(columns);
        }
        finally {
            this._columnsReady = true;
        }
        this.layoutColumns = columns;
    };
    PanelModelBase.prototype.getColumsForElement = function (el) {
        var row = this.findRowByElement(el);
        if (!row || !this.survey || !this.survey.gridLayoutEnabled)
            return [];
        var lastExpandableElementIndex = row.elements.length - 1;
        while (lastExpandableElementIndex >= 0) {
            if (!row.elements[lastExpandableElementIndex].getPropertyValueWithoutDefault("colSpan")) {
                break;
            }
            lastExpandableElementIndex--;
        }
        var elementIndex = row.elements.indexOf(el);
        var startIndex = 0;
        for (var index = 0; index < elementIndex; index++) {
            startIndex += row.elements[index].colSpan;
        }
        var currentColSpan = el.getPropertyValueWithoutDefault("colSpan");
        if (!currentColSpan && elementIndex === lastExpandableElementIndex) {
            var usedSpans = 0;
            for (var index = 0; index < row.elements.length; index++) {
                if (index !== lastExpandableElementIndex) {
                    usedSpans += row.elements[index].colSpan;
                }
            }
            currentColSpan = this.columns.length - usedSpans;
        }
        var result = this.columns.slice(startIndex, startIndex + (currentColSpan || 1));
        el.setPropertyValue("effectiveColSpan", result.length);
        return result;
    };
    PanelModelBase.prototype.getStartIndex = function () {
        if (!!this.parent)
            return this.parent.getQuestionStartIndex();
        if (!!this.survey)
            return this.survey.questionStartIndex;
        return "";
    };
    PanelModelBase.prototype.getQuestionStartIndex = function () {
        return this.getStartIndex();
    };
    PanelModelBase.prototype.getChildrenLayoutType = function () {
        return "row";
    };
    PanelModelBase.prototype.getProgressInfo = function () {
        return survey_element_SurveyElement.getProgressInfoByElements(this.elements, this.isRequired);
    };
    Object.defineProperty(PanelModelBase.prototype, "root", {
        get: function () {
            var res = this;
            while (res.parent)
                res = res.parent;
            return res;
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.childVisibilityChanged = function () {
        var newIsVisibleValue = this.getIsPageVisible(null);
        var oldIsVisibleValue = this.getPropertyValue("isVisible", true);
        if (newIsVisibleValue !== oldIsVisibleValue) {
            this.onVisibleChanged();
        }
    };
    PanelModelBase.prototype.createRowAndSetLazy = function (index) {
        var row = this.createRow();
        row.setIsLazyRendering(this.isLazyRenderInRow(index));
        return row;
    };
    PanelModelBase.prototype.createRow = function () {
        return new panel_QuestionRowModel(this);
    };
    PanelModelBase.prototype.onSurveyLoad = function () {
        this.blockAnimations();
        _super.prototype.onSurveyLoad.call(this);
        for (var i = 0; i < this.elements.length; i++) {
            this.elements[i].onSurveyLoad();
        }
        this.onElementVisibilityChanged(this);
        this.releaseAnimations();
    };
    PanelModelBase.prototype.onFirstRendering = function () {
        _super.prototype.onFirstRendering.call(this);
        for (var i = 0; i < this.elements.length; i++) {
            this.elements[i].onFirstRendering();
        }
        this.onRowsChanged();
    };
    PanelModelBase.prototype.updateRows = function () {
        if (this.isLoadingFromJson)
            return;
        for (var i = 0; i < this.elements.length; i++) {
            if (this.elements[i].isPanel) {
                this.elements[i].updateRows();
            }
        }
        this.onRowsChanged();
    };
    Object.defineProperty(PanelModelBase.prototype, "rows", {
        get: function () {
            return this.getPropertyValue("rows");
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.ensureRowsVisibility = function () {
        this.rows.forEach(function (row) {
            row.ensureVisibility();
        });
    };
    PanelModelBase.prototype.onRowsChanged = function () {
        if (this.isLoadingFromJson)
            return;
        this.blockAnimations();
        this.setArrayPropertyDirectly("rows", this.buildRows());
        this.updateColumns();
        this.releaseAnimations();
    };
    PanelModelBase.prototype.blockRowsUpdates = function () {
        this.locCountRowUpdates++;
    };
    PanelModelBase.prototype.releaseRowsUpdates = function () {
        this.locCountRowUpdates--;
    };
    PanelModelBase.prototype.updateRowsBeforeElementRemoved = function (element) {
        var _this = this;
        var elementRow = this.findRowByElement(element);
        var elementRowIndex = this.rows.indexOf(elementRow);
        var elementIndexInRow = elementRow.elements.indexOf(element);
        elementRow.elements.splice(elementIndexInRow, 1);
        if (elementRow.elements.length == 0) {
            this.rows.splice(elementRowIndex, 1);
        }
        else if (!elementRow.elements[0].startWithNewLine && this.rows[elementRowIndex - 1]) {
            elementRow.elements.forEach(function (el) { return _this.rows[elementRowIndex - 1].addElement(el); });
            this.rows.splice(elementRowIndex, 1);
        }
        else {
            elementRow.updateVisible();
        }
    };
    PanelModelBase.prototype.updateRowsOnElementAdded = function (element) {
        var _this = this;
        var index = this.elements.indexOf(element);
        var targetElement = this.elements[index + 1];
        var createRowAtIndex = function (index) {
            var row = _this.createRowAndSetLazy(index);
            if (_this.isDesignModeV2) {
                row.setIsLazyRendering(false);
            }
            _this.rows.splice(index, 0, row);
            return row;
        };
        var updateRow = function (row, start, deleteCount) {
            var _a;
            var elements = [];
            for (var _i = 3; _i < arguments.length; _i++) {
                elements[_i - 3] = arguments[_i];
            }
            var removedElements = (_a = row.elements).splice.apply(_a, panel_spreadArray([start, deleteCount], elements));
            row.updateVisible();
            return removedElements;
        };
        if (!targetElement) {
            if (index == 0 || element.startWithNewLine) {
                updateRow(createRowAtIndex(this.rows.length), 0, 0, element);
            }
            else {
                this.rows[this.rows.length - 1].addElement(element);
            }
            return;
        }
        var targetRow = this.findRowByElement(targetElement);
        if (!targetRow)
            return;
        var targetRowIndex = this.rows.indexOf(targetRow);
        var targetElementIndexInRow = targetRow.elements.indexOf(targetElement);
        if (targetElementIndexInRow == 0) {
            if (!targetElement.startWithNewLine) {
                updateRow(targetRow, 0, 0, element);
            }
            else if (element.startWithNewLine || targetRowIndex < 1) {
                createRowAtIndex(targetRowIndex).addElement(element);
            }
            else {
                this.rows[targetRowIndex - 1].addElement(element);
            }
        }
        else {
            if (element.startWithNewLine) {
                updateRow.apply(void 0, panel_spreadArray([createRowAtIndex(targetRowIndex + 1), 0, 0], [element].concat(updateRow(targetRow, targetElementIndexInRow, targetRow.elements.length))));
            }
            else {
                updateRow(targetRow, targetElementIndexInRow, 0, element);
            }
        }
    };
    PanelModelBase.prototype.onAddElement = function (element, index) {
        var _this = this;
        element.setSurveyImpl(this.surveyImpl);
        element.parent = this;
        this.markQuestionListDirty();
        if (this.canBuildRows()) {
            this.updateRowsOnElementAdded(element);
        }
        if (element.isPanel) {
            var p = element;
            if (this.survey) {
                this.survey.panelAdded(p, index, this, this.root);
            }
        }
        else {
            if (this.survey) {
                var q = element;
                this.survey.questionAdded(q, index, this, this.root);
            }
        }
        if (!!this.addElementCallback)
            this.addElementCallback(element);
        var self = this;
        element.registerPropertyChangedHandlers(["visible", "isVisible"], function () {
            _this.onElementVisibilityChanged(element);
        }, this.id);
        element.registerPropertyChangedHandlers(["startWithNewLine"], function () {
            _this.onElementStartWithNewLineChanged(element);
        }, this.id);
        this.onElementVisibilityChanged(this);
    };
    PanelModelBase.prototype.onRemoveElement = function (element) {
        element.parent = null;
        this.markQuestionListDirty();
        element.unregisterPropertyChangedHandlers(["visible", "isVisible", "startWithNewLine"], this.id);
        this.updateRowsOnElementRemoved(element);
        if (this.isRandomizing)
            return;
        this.onRemoveElementNotifySurvey(element);
        if (!!this.removeElementCallback)
            this.removeElementCallback(element);
        this.onElementVisibilityChanged(this);
    };
    PanelModelBase.prototype.onRemoveElementNotifySurvey = function (element) {
        if (!this.survey)
            return;
        if (!element.isPanel) {
            this.survey.questionRemoved(element);
        }
        else {
            this.survey.panelRemoved(element);
        }
    };
    PanelModelBase.prototype.onElementVisibilityChanged = function (element) {
        if (this.isLoadingFromJson || this.isRandomizing)
            return;
        this.updateRowsVisibility(element);
        this.childVisibilityChanged();
        if (!!this.parent) {
            this.parent.onElementVisibilityChanged(this);
        }
    };
    PanelModelBase.prototype.onElementStartWithNewLineChanged = function (element) {
        if (this.locCountRowUpdates > 0)
            return;
        this.updateRowsBeforeElementRemoved(element);
        this.updateRowsOnElementAdded(element);
    };
    PanelModelBase.prototype.updateRowsVisibility = function (element) {
        var rows = this.rows;
        for (var i = 0; i < rows.length; i++) {
            var row = rows[i];
            if (row.elements.indexOf(element) > -1) {
                row.updateVisible();
                if (row.visible && !row.isNeedRender) {
                    row.isNeedRender = true;
                }
                break;
            }
        }
    };
    PanelModelBase.prototype.canBuildRows = function () {
        return !this.isLoadingFromJson && this.getChildrenLayoutType() == "row";
    };
    PanelModelBase.prototype.buildRows = function () {
        if (!this.canBuildRows())
            return [];
        var result = new Array();
        for (var i = 0; i < this.elements.length; i++) {
            var el = this.elements[i];
            var isNewRow = i == 0 || el.startWithNewLine;
            var row = isNewRow ? this.createRowAndSetLazy(result.length) : result[result.length - 1];
            if (isNewRow)
                result.push(row);
            row.addElement(el);
        }
        for (var i = 0; i < result.length; i++) {
            result[i].updateVisible();
        }
        return result;
    };
    PanelModelBase.prototype.isLazyRenderInRow = function (rowIndex) {
        if (!this.survey || !this.survey.isLazyRendering)
            return false;
        return (rowIndex >= this.survey.lazyRenderingFirstBatchSize ||
            !this.canRenderFirstRows());
    };
    PanelModelBase.prototype.canRenderFirstRows = function () {
        return this.isPage;
    };
    PanelModelBase.prototype.getDragDropInfo = function () {
        var page = this.getPage(this.parent);
        return !!page ? page.getDragDropInfo() : undefined;
    };
    PanelModelBase.prototype.updateRowsOnElementRemoved = function (element) {
        if (!this.canBuildRows())
            return;
        this.updateRowsRemoveElementFromRow(element, this.findRowByElement(element));
        this.updateColumns();
    };
    PanelModelBase.prototype.updateRowsRemoveElementFromRow = function (element, row) {
        if (!row || !row.panel)
            return;
        var elIndex = row.elements.indexOf(element);
        if (elIndex < 0)
            return;
        row.elements.splice(elIndex, 1);
        if (row.elements.length > 0) {
            this.blockRowsUpdates();
            row.elements[0].startWithNewLine = true;
            this.releaseRowsUpdates();
            row.updateVisible();
        }
        else {
            if (row.index >= 0) {
                row.panel.rows.splice(row.index, 1);
            }
        }
    };
    PanelModelBase.prototype.findRowByElement = function (el) {
        var rows = this.rows;
        for (var i = 0; i < rows.length; i++) {
            if (rows[i].elements.indexOf(el) > -1)
                return rows[i];
        }
        return null;
    };
    PanelModelBase.prototype.elementWidthChanged = function (el) {
        if (this.isLoadingFromJson)
            return;
        var row = this.findRowByElement(el);
        if (!!row) {
            row.updateVisible();
        }
    };
    Object.defineProperty(PanelModelBase.prototype, "processedTitle", {
        get: function () {
            return this.getRenderedTitle(this.locTitle.textOrHtml);
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.getRenderedTitle = function (str) {
        return this.textProcessor != null
            ? this.textProcessor.processText(str, true)
            : str;
    };
    Object.defineProperty(PanelModelBase.prototype, "visible", {
        /**
         * Gets or sets panel/page visibility.
         *
         * If you want to display or hide a survey element based on a condition, specify the `visibleIf` property. Refer to the following help topic for information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see visibleIf
         * @see isVisible
         */
        get: function () {
            return this.getPropertyValue("visible", true);
        },
        set: function (value) {
            if (value === this.visible)
                return;
            this.setPropertyValue("visible", value);
            this.setPropertyValue("isVisible", this.isVisible);
            if (!this.isLoadingFromJson)
                this.onVisibleChanged();
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.onHidingContent = function () {
        this.questions.forEach(function (q) { return q.onHidingContent(); });
    };
    PanelModelBase.prototype.onVisibleChanged = function () {
        if (this.isRandomizing)
            return;
        this.setPropertyValue("isVisible", this.isVisible);
        if (!!this.survey && this.survey.getQuestionClearIfInvisible("default") !== "none" &&
            !this.isLoadingFromJson) {
            var questions = this.questions;
            var isVisible = this.isVisible;
            for (var i = 0; i < questions.length; i++) {
                var q = questions[i];
                if (!isVisible) {
                    q.clearValueIfInvisible("onHiddenContainer");
                    q.onHidingContent();
                }
                else {
                    q.updateValueWithDefaults();
                }
            }
        }
    };
    PanelModelBase.prototype.notifyStateChanged = function (prevState) {
        _super.prototype.notifyStateChanged.call(this, prevState);
        if (this.isCollapsed) {
            this.questions.forEach(function (q) { return q.onHidingContent(); });
        }
    };
    Object.defineProperty(PanelModelBase.prototype, "isVisible", {
        /**
         * Returns `true` if the panel/page is visible or the survey is currently in design mode.
         *
         * If you want to display or hide a question based on a condition, specify the `visibleIf` property. Refer to the following help topic for information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see visibleIf
         * @see visible
         */
        get: function () {
            return this.areInvisibleElementsShowing || this.getIsPageVisible(null);
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.getIsContentVisible = function (exceptionQuestion) {
        if (this.areInvisibleElementsShowing)
            return true;
        for (var i = 0; i < this.elements.length; i++) {
            if (this.elements[i] == exceptionQuestion)
                continue;
            if (this.elements[i].isVisible)
                return true;
        }
        return false;
    };
    PanelModelBase.prototype.getIsPageVisible = function (exceptionQuestion) {
        return this.visible && this.getIsContentVisible(exceptionQuestion);
    };
    PanelModelBase.prototype.setVisibleIndex = function (index) {
        if (!this.isVisible || index < 0) {
            this.resetVisibleIndexes();
            return 0;
        }
        this.lastVisibleIndex = index;
        var startIndex = index;
        index += this.beforeSetVisibleIndex(index);
        var panelStartIndex = this.getPanelStartIndex(index);
        var panelIndex = panelStartIndex;
        for (var i = 0; i < this.elements.length; i++) {
            panelIndex += this.elements[i].setVisibleIndex(panelIndex);
        }
        if (this.isContinueNumbering()) {
            index += panelIndex - panelStartIndex;
        }
        return index - startIndex;
    };
    PanelModelBase.prototype.updateVisibleIndexes = function () {
        if (this.lastVisibleIndex === undefined)
            return;
        this.resetVisibleIndexes();
        this.setVisibleIndex(this.lastVisibleIndex);
    };
    PanelModelBase.prototype.resetVisibleIndexes = function () {
        for (var i = 0; i < this.elements.length; i++) {
            this.elements[i].setVisibleIndex(-1);
        }
    };
    PanelModelBase.prototype.beforeSetVisibleIndex = function (index) {
        return 0;
    };
    PanelModelBase.prototype.getPanelStartIndex = function (index) {
        return index;
    };
    PanelModelBase.prototype.isContinueNumbering = function () {
        return true;
    };
    Object.defineProperty(PanelModelBase.prototype, "isReadOnly", {
        get: function () {
            var isParentReadOnly = !!this.parent && this.parent.isReadOnly;
            var isSurveyReadOnly = !!this.survey && this.survey.isDisplayMode;
            return this.readOnly || isParentReadOnly || isSurveyReadOnly;
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.onReadOnlyChanged = function () {
        for (var i = 0; i < this.elements.length; i++) {
            var el = this.elements[i];
            el.setPropertyValue("isReadOnly", el.isReadOnly);
        }
        _super.prototype.onReadOnlyChanged.call(this);
    };
    PanelModelBase.prototype.updateElementCss = function (reNew) {
        _super.prototype.updateElementCss.call(this, reNew);
        for (var i = 0; i < this.elements.length; i++) {
            var el = this.elements[i];
            el.updateElementCss(reNew);
        }
    };
    Object.defineProperty(PanelModelBase.prototype, "enableIf", {
        /**
         * A Boolean expression. If it evaluates to `false`, this panel/page becomes read-only.
         *
         * A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
         *
         * Refer to the following help topic for more information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see readOnly
         * @see isReadOnly
         */
        get: function () {
            return this.getPropertyValue("enableIf", "");
        },
        set: function (val) {
            this.setPropertyValue("enableIf", val);
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Adds a survey element (question or panel) to this panel/page. Returns `true` if the element was added successfully; `false` otherwise.
     * @param element A survey element to add.
     * @param index A desired index of this element in the `elements` array.
     * @see addNewQuestion
     * @see addNewPanel
     */
    PanelModelBase.prototype.addElement = function (element, index) {
        if (index === void 0) { index = -1; }
        if (!this.canAddElement(element))
            return false;
        if (index < 0 || index >= this.elements.length) {
            this.elements.push(element);
        }
        else {
            this.elements.splice(index, 0, element);
        }
        if (this.wasRendered) {
            element.onFirstRendering();
        }
        this.updateColumns();
        return true;
    };
    PanelModelBase.prototype.insertElement = function (element, dest, location) {
        if (location === void 0) { location = "bottom"; }
        if (!dest) {
            this.addElement(element);
            return;
        }
        this.blockRowsUpdates();
        var index = this.elements.indexOf(dest);
        var destRow = this.findRowByElement(dest);
        if (location == "left" || location == "right") {
            if (location == "right") {
                element.startWithNewLine = false;
                index++;
            }
            else {
                if (destRow.elements.indexOf(dest) == 0) {
                    dest.startWithNewLine = false;
                    element.startWithNewLine = true;
                }
                else {
                    element.startWithNewLine = false;
                }
            }
        }
        else {
            element.startWithNewLine = true;
            if (location == "top") {
                index = this.elements.indexOf(destRow.elements[0]);
            }
            else {
                index = this.elements.indexOf(destRow.elements[destRow.elements.length - 1]) + 1;
            }
        }
        this.releaseRowsUpdates();
        this.addElement(element, index);
    };
    PanelModelBase.prototype.insertElementAfter = function (element, after) {
        var index = this.elements.indexOf(after);
        if (index >= 0)
            this.addElement(element, index + 1);
    };
    PanelModelBase.prototype.insertElementBefore = function (element, before) {
        var index = this.elements.indexOf(before);
        if (index >= 0)
            this.addElement(element, index);
    };
    PanelModelBase.prototype.canAddElement = function (element) {
        return (!!element && element.isLayoutTypeSupported(this.getChildrenLayoutType()));
    };
    PanelModelBase.prototype.addQuestion = function (question, index) {
        if (index === void 0) { index = -1; }
        return this.addElement(question, index);
    };
    PanelModelBase.prototype.addPanel = function (panel, index) {
        if (index === void 0) { index = -1; }
        return this.addElement(panel, index);
    };
    /**
     * Creates a new question of a given type and adds it to the `elements` array at a specified index.
     *
     * This method returns `null` if the question cannot be created or added to this panel/page; otherwise, the method returns the created question.
     *
     * @param questionType A [question type](https://surveyjs.io/form-library/documentation/question#getType).
     * @param name A question name.
     * @param index A desired index of the new question in the `elements` array.
     * @see elements
     * @see addElement
     */
    PanelModelBase.prototype.addNewQuestion = function (questionType, name, index) {
        if (name === void 0) { name = null; }
        if (index === void 0) { index = -1; }
        var question = questionfactory_QuestionFactory.Instance.createQuestion(questionType, name);
        if (!this.addQuestion(question, index))
            return null;
        return question;
    };
    /**
     * Creates a new panel and adds it to the end of the `elements` array.
     *
     * This method returns `null` if the panel cannot be created or added to this panel/page; otherwise, the method returns the created panel.
     * @param name A panel name.
     * @see elementsup
     * @see addElement
     */
    PanelModelBase.prototype.addNewPanel = function (name) {
        if (name === void 0) { name = null; }
        var panel = this.createNewPanel(name);
        if (!this.addPanel(panel))
            return null;
        return panel;
    };
    PanelModelBase.prototype.indexOf = function (element) {
        return this.elements.indexOf(element);
    };
    PanelModelBase.prototype.createNewPanel = function (name) {
        var res = Serializer.createClass("panel");
        res.name = name;
        return res;
    };
    /**
     * Deletes a survey element (question or panel) from this panel/page. Returns `true` if the element was deleted successfully; `false` otherwise.
     * @param element A survey element to delete.
     * @see elements
     */
    PanelModelBase.prototype.removeElement = function (element) {
        var index = this.elements.indexOf(element);
        if (index < 0) {
            for (var i = 0; i < this.elements.length; i++) {
                if (this.elements[i].removeElement(element))
                    return true;
            }
            return false;
        }
        this.elements.splice(index, 1);
        this.updateColumns();
        return true;
    };
    PanelModelBase.prototype.removeQuestion = function (question) {
        this.removeElement(question);
    };
    PanelModelBase.prototype.runCondition = function (values, properties) {
        if (this.isDesignMode || this.isLoadingFromJson)
            return;
        var elements = this.elements.slice();
        for (var i = 0; i < elements.length; i++) {
            elements[i].runCondition(values, properties);
        }
        this.runConditionCore(values, properties);
    };
    PanelModelBase.prototype.onAnyValueChanged = function (name, questionName) {
        var els = this.elements;
        for (var i = 0; i < els.length; i++) {
            els[i].onAnyValueChanged(name, questionName);
        }
    };
    PanelModelBase.prototype.checkBindings = function (valueName, value) {
        var els = this.elements;
        for (var i = 0; i < els.length; i++) {
            els[i].checkBindings(valueName, value);
        }
    };
    PanelModelBase.prototype.dragDropAddTarget = function (dragDropInfo) {
        this.dragDropPanelHelper.dragDropAddTarget(dragDropInfo);
    };
    PanelModelBase.prototype.dragDropFindRow = function (findElement) {
        return this.dragDropPanelHelper.dragDropFindRow(findElement);
    };
    PanelModelBase.prototype.dragDropMoveElement = function (src, target, targetIndex) {
        this.dragDropPanelHelper.dragDropMoveElement(src, target, targetIndex);
    };
    PanelModelBase.prototype.needResponsiveWidth = function () {
        var result = false;
        this.elements.forEach(function (e) {
            if (e.needResponsiveWidth())
                result = true;
        });
        this.rows.forEach(function (r) {
            if (r.elements.length > 1)
                result = true;
        });
        return result;
    };
    Object.defineProperty(PanelModelBase.prototype, "hasDescriptionUnderTitle", {
        get: function () {
            return this.hasDescription;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "cssHeader", {
        get: function () {
            return this.cssClasses.panel.header;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "cssDescription", {
        get: function () {
            return this.cssClasses.panel.description;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "questionErrorLocation", {
        /**
         * Specifies the error message position for questions that belong to this page/panel.
         *
         * Use this property to override the [`questionErrorLocation`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#questionErrorLocation) property specified for the survey. You can also set the [`errorLocation`](https://surveyjs.io/form-library/documentation/question#errorLocation) property for individual questions.
         *
         * Possible values:
         *
         * - `"default"` (default) - Inherits the setting from the `questionErrorLocation` property specified for the survey.
         * - `"top"` - Displays error messages above questions.
         * - `"bottom"` - Displays error messages below questions.
         */
        get: function () {
            return this.getPropertyValue("questionErrorLocation");
        },
        set: function (val) {
            this.setPropertyValue("questionErrorLocation", val);
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.getQuestionErrorLocation = function () {
        if (this.questionErrorLocation !== "default")
            return this.questionErrorLocation;
        if (this.parent)
            return this.parent.getQuestionErrorLocation();
        return this.survey ? this.survey.questionErrorLocation : "top";
    };
    Object.defineProperty(PanelModelBase.prototype, "no", {
        //ITitleOwner
        get: function () { return ""; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModelBase.prototype, "cssError", {
        get: function () {
            return this.getCssError(this.cssClasses);
        },
        enumerable: false,
        configurable: true
    });
    PanelModelBase.prototype.getCssError = function (cssClasses) {
        return new CssClassBuilder().append(cssClasses.error.root).toString();
    };
    PanelModelBase.prototype.getSerializableColumnsValue = function () {
        var tailIndex = -1;
        for (var index = this.layoutColumns.length - 1; index >= 0; index--) {
            if (!this.layoutColumns[index].isEmpty()) {
                tailIndex = index;
                break;
            }
        }
        return this.layoutColumns.slice(0, tailIndex + 1);
    };
    PanelModelBase.prototype.dispose = function () {
        _super.prototype.dispose.call(this);
        if (this.rows) {
            for (var i = 0; i < this.rows.length; i++) {
                this.rows[i].dispose();
            }
            this.rows.splice(0, this.rows.length);
        }
        for (var i = 0; i < this.elements.length; i++) {
            this.elements[i].dispose();
        }
        this.elements.splice(0, this.elements.length);
    };
    PanelModelBase.panelCounter = 100;
    panel_decorate([
        propertyArray()
    ], PanelModelBase.prototype, "layoutColumns", void 0);
    panel_decorate([
        jsonobject_property({ defaultValue: true })
    ], PanelModelBase.prototype, "showTitle", void 0);
    panel_decorate([
        jsonobject_property({ defaultValue: true })
    ], PanelModelBase.prototype, "showDescription", void 0);
    panel_decorate([
        jsonobject_property()
    ], PanelModelBase.prototype, "questionTitleWidth", void 0);
    return PanelModelBase;
}(survey_element_SurveyElement));

/**
 * A class that describes the Panel container element.
 *
 * A panel can contain questions and other panels. Refer to the following help topic for an illustration: [Survey Structure](https://surveyjs.io/form-library/documentation/design-survey-create-a-simple-survey#survey-structure).
 *
 * [View Demo](https://surveyjs.io/form-library/examples/questiontype-panel/ (linkStyle))
 */
var panel_PanelModel = /** @class */ (function (_super) {
    panel_extends(PanelModel, _super);
    function PanelModel(name) {
        if (name === void 0) { name = ""; }
        var _this = _super.call(this, name) || this;
        _this.createNewArray("footerActions");
        _this.registerPropertyChangedHandlers(["width"], function () {
            if (!!_this.parent) {
                _this.parent.elementWidthChanged(_this);
            }
        });
        _this.registerPropertyChangedHandlers(["indent", "innerIndent", "rightIndent"], function () { _this.onIndentChanged(); });
        _this.registerPropertyChangedHandlers(["colSpan"], function () { var _a; (_a = _this.parent) === null || _a === void 0 ? void 0 : _a.updateColumns(); });
        _this.registerPropertyChangedHandlers(["title"], function () {
            _this.calcHasTextInTitle();
        });
        return _this;
    }
    PanelModel.prototype.getType = function () {
        return "panel";
    };
    Object.defineProperty(PanelModel.prototype, "contentId", {
        get: function () {
            return this.id + "_content";
        },
        enumerable: false,
        configurable: true
    });
    PanelModel.prototype.getSurvey = function (live) {
        if (live === void 0) { live = false; }
        if (live) {
            return !!this.parent ? this.parent.getSurvey(live) : null;
        }
        return _super.prototype.getSurvey.call(this, live);
    };
    Object.defineProperty(PanelModel.prototype, "hasTextInTitle", {
        get: function () {
            return this.getPropertyValue("hasTextInTitle");
        },
        enumerable: false,
        configurable: true
    });
    PanelModel.prototype.calcHasTextInTitle = function () {
        this.setPropertyValue("hasTextInTitle", !!this.title);
    };
    PanelModel.prototype.onSurveyLoad = function () {
        _super.prototype.onSurveyLoad.call(this);
        this.onIndentChanged();
        this.calcHasTextInTitle();
    };
    PanelModel.prototype.onSetData = function () {
        _super.prototype.onSetData.call(this);
        this.onIndentChanged();
        this.calcHasTextInTitle();
    };
    Object.defineProperty(PanelModel.prototype, "cssHeader", {
        get: function () {
            return new CssClassBuilder()
                .append(this.cssClasses.panel.header)
                .append(this.cssClasses.panel.headerHidden, !this.hasTextInTitle &&
                !this.hasDescription &&
                this.isDesignMode).toString();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModel.prototype, "isPanel", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModel.prototype, "page", {
        /**
         * Returns a page to which the panel belongs and allows you to move this panel to a different page.
         * @see PanelModelBase.parent
         */
        get: function () {
            return this.getPage(this.parent);
        },
        set: function (val) {
            this.setPage(this.parent, val);
        },
        enumerable: false,
        configurable: true
    });
    PanelModel.prototype.removeFromParent = function () {
        if (!!this.parent) {
            this.removeSelfFromList(this.parent.elements);
        }
    };
    PanelModel.prototype.moveTo = function (container, insertBefore) {
        if (insertBefore === void 0) { insertBefore = null; }
        return this.moveToBase(this.parent, container, insertBefore);
    };
    Object.defineProperty(PanelModel.prototype, "visibleIndex", {
        /**
         * Returns the visible index of the panel in the survey. Commonly it is -1 and it doesn't show.
         * You have to set showNumber to true to show index/numbering for the Panel
         * @see showNumber
         */
        get: function () {
            return this.getPropertyValue("visibleIndex", -1);
        },
        enumerable: false,
        configurable: true
    });
    PanelModel.prototype.getTitleOwner = function () { return this; };
    Object.defineProperty(PanelModel.prototype, "showNumber", {
        /**
         * Specifies whether to show the panel number in the title.
         *
         * Default value: `false`
         * @see SurveyModel.showQuestionNumbers
         * @see SurveyModel.questionTitlePattern
         */
        get: function () {
            return this.getPropertyValue("showNumber");
        },
        set: function (val) {
            this.setPropertyValue("showNumber", val);
            this.notifySurveyOnVisibilityChanged();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModel.prototype, "showQuestionNumbers", {
        /**
         * Gets or sets a value that specifies how the elements numbers inside panel are displayed.
         *
         * The following options are available:
         *
         * - `default` - display questions numbers as defined in parent panel or survey
         * - `onpanel` - display questions numbers, start numbering from beginning of this page
         * - `off` - turn off the numbering for questions titles
         * @see showNumber
         */
        get: function () {
            return this.getPropertyValue("showQuestionNumbers");
        },
        set: function (value) {
            this.setPropertyValue("showQuestionNumbers", value);
            this.notifySurveyOnVisibilityChanged();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModel.prototype, "questionStartIndex", {
        /**
         * Specifies a number or letter used to start numbering of elements inside the panel.
         *
         * You can include desired prefixes and postfixes alongside the number or letter:
         *
         * ```js
         * "questionStartIndex": "a.", // a., b., c., ...
         * "questionStartIndex": "#3", // #3, #4, #5, ...
         * "questionStartIndex": "(B)." // (B)., (C)., (D)., ...
         * ```
         * Default value: `"1."` (inherited from `SurveyModel`'s `questionStartIndex` property)
         * @see SurveyModel.questionStartIndex
         * @see showQuestionNumbers
         */
        get: function () {
            return this.getPropertyValue("questionStartIndex", "");
        },
        set: function (val) {
            this.setPropertyValue("questionStartIndex", val);
        },
        enumerable: false,
        configurable: true
    });
    PanelModel.prototype.getQuestionStartIndex = function () {
        if (!!this.questionStartIndex)
            return this.questionStartIndex;
        return _super.prototype.getQuestionStartIndex.call(this);
    };
    Object.defineProperty(PanelModel.prototype, "no", {
        /**
         * A question number or letter (depends on the `questionStartIndex` property).
         *
         * When the question number, title, or the entire question is invisible, this property returns an empty string.
         * @see questionStartIndex
         * @see showNumber
         * @see visibleIf
         */
        get: function () {
            return this.getPropertyValue("no", "");
        },
        enumerable: false,
        configurable: true
    });
    PanelModel.prototype.setNo = function (visibleIndex) {
        this.setPropertyValue("no", helpers_Helpers.getNumberByIndex(this.visibleIndex, this.getStartIndex()));
    };
    PanelModel.prototype.notifyStateChanged = function (prevState) {
        if (!this.isLoadingFromJson) {
            this.locTitle.strChanged();
        }
        _super.prototype.notifyStateChanged.call(this, prevState);
    };
    PanelModel.prototype.createLocTitleProperty = function () {
        var _this = this;
        var locTitleValue = _super.prototype.createLocTitleProperty.call(this);
        locTitleValue.onGetTextCallback = function (text) {
            if (!text && (_this.state !== "default" || (_this.isDesignMode && _this.isDefaultV2Theme && _this.isInteractiveDesignElement))) {
                text = _this.name;
            }
            return text;
        };
        return locTitleValue;
    };
    PanelModel.prototype.beforeSetVisibleIndex = function (index) {
        var visibleIndex = -1;
        if (this.showNumber && (this.isDesignMode || !this.locTitle.isEmpty)) {
            visibleIndex = index;
        }
        this.setPropertyValue("visibleIndex", visibleIndex);
        this.setNo(visibleIndex);
        return visibleIndex < 0 ? 0 : 1;
    };
    PanelModel.prototype.getPanelStartIndex = function (index) {
        if (this.showQuestionNumbers == "off")
            return -1;
        if (this.showQuestionNumbers == "onpanel")
            return 0;
        return index;
    };
    PanelModel.prototype.isContinueNumbering = function () {
        return (this.showQuestionNumbers != "off" && this.showQuestionNumbers != "onpanel");
    };
    PanelModel.prototype.notifySurveyOnVisibilityChanged = function () {
        if (this.survey != null && !this.isLoadingFromJson) {
            this.survey.panelVisibilityChanged(this, this.isVisible);
        }
    };
    PanelModel.prototype.getRenderedTitle = function (str) {
        if (!str) {
            if (this.isCollapsed || this.isExpanded)
                return this.name;
            if (this.isDesignMode)
                return "[" + this.name + "]";
        }
        return _super.prototype.getRenderedTitle.call(this, str);
    };
    Object.defineProperty(PanelModel.prototype, "innerIndent", {
        /**
         * Increases or decreases an indent of panel content from the left edge. Accepts positive integer values and 0.
         */
        get: function () {
            return this.getPropertyValue("innerIndent");
        },
        set: function (val) {
            this.setPropertyValue("innerIndent", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModel.prototype, "startWithNewLine", {
        /**
         * Disable this property if you want to render the current panel on the same line or row with the previous question or panel.
         */
        get: function () {
            return this.getPropertyValue("startWithNewLine");
        },
        set: function (value) {
            this.setPropertyValue("startWithNewLine", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModel.prototype, "allowAdaptiveActions", {
        get: function () {
            return this.getPropertyValue("allowAdaptiveActions");
        },
        set: function (val) {
            this.setPropertyValue("allowAdaptiveActions", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModel.prototype, "innerPaddingLeft", {
        get: function () {
            return this.getPropertyValue("innerPaddingLeft", "");
        },
        set: function (val) {
            this.setPropertyValue("innerPaddingLeft", val);
        },
        enumerable: false,
        configurable: true
    });
    PanelModel.prototype.onIndentChanged = function () {
        if (!this.getSurvey())
            return;
        this.innerPaddingLeft = this.getIndentSize(this.innerIndent);
        this.paddingLeft = this.getIndentSize(this.indent);
        this.paddingRight = this.getIndentSize(this.rightIndent);
    };
    PanelModel.prototype.getIndentSize = function (indent) {
        if (indent < 1)
            return "";
        var css = this.survey["css"];
        if (!css || !css.question.indent)
            return "";
        return indent * css.question.indent + "px";
    };
    PanelModel.prototype.clearOnDeletingContainer = function () {
        this.elements.forEach(function (element) {
            if (element instanceof question_Question || element instanceof PanelModel) {
                element.clearOnDeletingContainer();
            }
        });
    };
    Object.defineProperty(PanelModel.prototype, "footerActions", {
        get: function () {
            return this.getPropertyValue("footerActions");
        },
        enumerable: false,
        configurable: true
    });
    PanelModel.prototype.getFooterToolbar = function () {
        var _this = this;
        var _a, _b;
        if (!this.footerToolbarValue) {
            var actions = this.footerActions;
            if (this.hasEditButton) {
                actions.push({
                    id: "cancel-preview",
                    locTitle: this.survey.locEditText,
                    innerCss: this.survey.cssNavigationEdit,
                    component: "sv-nav-btn",
                    action: function () { _this.cancelPreview(); }
                });
            }
            if (!!this.onGetFooterActionsCallback) {
                actions = this.onGetFooterActionsCallback();
            }
            else {
                actions = (_a = this.survey) === null || _a === void 0 ? void 0 : _a.getUpdatedPanelFooterActions(this, actions);
            }
            this.footerToolbarValue = this.createActionContainer(this.allowAdaptiveActions);
            var footerCss = this.onGetFooterToolbarCssCallback ? this.onGetFooterToolbarCssCallback() : "";
            if (!footerCss) {
                footerCss = (_b = this.cssClasses.panel) === null || _b === void 0 ? void 0 : _b.footer;
            }
            if (footerCss) {
                this.footerToolbarValue.containerCss = footerCss;
            }
            this.footerToolbarValue.setItems(actions);
        }
        return this.footerToolbarValue;
    };
    Object.defineProperty(PanelModel.prototype, "hasEditButton", {
        get: function () {
            if (this.survey && this.survey.state === "preview")
                return (this.parent && this.parent instanceof page_PageModel);
            return false;
        },
        enumerable: false,
        configurable: true
    });
    PanelModel.prototype.cancelPreview = function () {
        if (!this.hasEditButton)
            return;
        this.survey.cancelPreviewByPage(this);
    };
    Object.defineProperty(PanelModel.prototype, "cssTitle", {
        get: function () {
            return new CssClassBuilder()
                .append(this.getCssTitle(this.cssClasses.panel))
                .append(this.cssClasses.panel.titleHidden, !this.hasTextInTitle && this.isDesignMode)
                .toString();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PanelModel.prototype, "showErrorsAbovePanel", {
        get: function () {
            return this.isDefaultV2Theme && !this.showPanelAsPage;
        },
        enumerable: false,
        configurable: true
    });
    PanelModel.prototype.getCssError = function (cssClasses) {
        var builder = new CssClassBuilder()
            .append(_super.prototype.getCssError.call(this, cssClasses))
            .append(cssClasses.panel.errorsContainer);
        return builder.append("panel-error-root", builder.isEmpty()).toString();
    };
    PanelModel.prototype.onVisibleChanged = function () {
        _super.prototype.onVisibleChanged.call(this);
        this.notifySurveyOnVisibilityChanged();
    };
    PanelModel.prototype.needResponsiveWidth = function () {
        if (!this.startWithNewLine) {
            return true;
        }
        else {
            return _super.prototype.needResponsiveWidth.call(this);
        }
    };
    PanelModel.prototype.focusIn = function () {
        if (!this.survey)
            return;
        this.survey.whenPanelFocusIn(this);
    };
    PanelModel.prototype.getHasFrameV2 = function () {
        return _super.prototype.getHasFrameV2.call(this) && !this.showPanelAsPage;
    };
    PanelModel.prototype.getIsNested = function () {
        return _super.prototype.getIsNested.call(this) && this.parent !== undefined;
    };
    Object.defineProperty(PanelModel.prototype, "showPanelAsPage", {
        get: function () {
            var panel = this;
            if (!!panel.originalPage)
                return true;
            return panel.survey.isShowingPreview && panel.survey.isSinglePage && !!panel.parent && !!panel.parent.originalPage;
        },
        enumerable: false,
        configurable: true
    });
    PanelModel.prototype.onElementExpanded = function (elementIsRendered) {
        var _this = this;
        if (this.survey != null && !this.isLoadingFromJson) {
            var q_1 = this.getFirstQuestionToFocus(false);
            if (!!q_1) {
                setTimeout(function () {
                    if (!_this.isDisposed && !!_this.survey) {
                        _this.survey.scrollElementToTop(q_1, q_1, null, q_1.inputId, false, { behavior: "smooth" });
                    }
                }, elementIsRendered ? 0 : 15);
            }
        }
    };
    PanelModel.prototype.getCssRoot = function (cssClasses) {
        return new CssClassBuilder()
            .append(_super.prototype.getCssRoot.call(this, cssClasses))
            .append(cssClasses.container)
            .append(cssClasses.asPage, this.showPanelAsPage)
            .append(cssClasses.invisible, !this.isDesignMode && this.areInvisibleElementsShowing && !this.visible)
            .toString();
    };
    PanelModel.prototype.getContainerCss = function () {
        return this.getCssRoot(this.cssClasses.panel);
    };
    return PanelModel;
}(panel_PanelModelBase));

Serializer.addClass("panelbase", [
    "name",
    {
        name: "elements",
        alternativeName: "questions",
        baseClassName: "question",
        visible: false,
        isLightSerializable: false,
    },
    { name: "visible:switch", default: true, overridingProperty: "visibleIf" },
    { name: "readOnly:boolean", overridingProperty: "enableIf" },
    "visibleIf:condition",
    "enableIf:condition",
    "requiredIf:condition",
    {
        name: "questionTitleWidth",
        visibleIf: function (obj) {
            return !!obj && obj["availableQuestionTitleWidth"]();
        }
    },
    {
        name: "questionTitleLocation",
        default: "default",
        choices: ["default", "top", "bottom", "left", "hidden"],
    },
    {
        name: "layoutColumns:panellayoutcolumns",
        className: "panellayoutcolumn", isArray: true,
        onSerializeValue: function (obj) { return obj.getSerializableColumnsValue(); },
        visibleIf: function (obj) { return !!obj && !!obj.survey && obj.survey.gridLayoutEnabled; }
    },
    { name: "title:text", serializationProperty: "locTitle" },
    { name: "description:text", serializationProperty: "locDescription" },
    {
        name: "questionsOrder",
        default: "default",
        choices: ["default", "initial", "random"],
    },
    { name: "questionErrorLocation", default: "default", choices: ["default", "top", "bottom"] }
], function () {
    return new panel_PanelModelBase();
});
Serializer.addClass("panel", [
    {
        name: "state",
        default: "default",
        choices: ["default", "collapsed", "expanded"],
    },
    { name: "isRequired:switch", overridingProperty: "requiredIf" },
    {
        name: "requiredErrorText:text",
        serializationProperty: "locRequiredErrorText",
    },
    { name: "startWithNewLine:boolean", default: true },
    "width",
    { name: "minWidth", defaultFunc: function () { return "auto"; } },
    { name: "maxWidth", defaultFunc: function () { return settings.maxWidth; } },
    {
        name: "colSpan:number", visible: false,
        onSerializeValue: function (obj) { return obj.getPropertyValue("colSpan"); },
    },
    {
        name: "effectiveColSpan:number", minValue: 1, isSerializable: false,
        visibleIf: function (obj) { return !!obj && !!obj.survey && obj.survey.gridLayoutEnabled; }
    },
    { name: "innerIndent:number", default: 0, choices: [0, 1, 2, 3] },
    { name: "indent:number", default: 0, choices: [0, 1, 2, 3], visible: false },
    {
        name: "page",
        isSerializable: false,
        visibleIf: function (obj) {
            var survey = obj ? obj.survey : null;
            return !survey || !survey.pages || survey.pages.length > 1;
        },
        choices: function (obj) {
            var survey = obj ? obj.survey : null;
            return survey
                ? survey.pages.map(function (p) {
                    return { value: p.name, text: p.title };
                })
                : [];
        },
    },
    "showNumber:boolean",
    {
        name: "showQuestionNumbers",
        default: "default",
        choices: ["default", "onpanel", "off"],
    },
    "questionStartIndex",
    { name: "allowAdaptiveActions:boolean", default: true, visible: false },
], function () {
    return new panel_PanelModel();
}, "panelbase");
questionfactory_ElementFactory.Instance.registerElement("panel", function (name) {
    return new panel_PanelModel(name);
});

// CONCATENATED MODULE: ./packages/survey-core/src/drag-drop-page-helper-v1.ts

var drag_drop_page_helper_v1_DragDropPageHelperV1 = /** @class */ (function () {
    function DragDropPageHelperV1(page) {
        this.page = page;
    }
    DragDropPageHelperV1.prototype.getDragDropInfo = function () { return this.dragDropInfo; };
    DragDropPageHelperV1.prototype.dragDropStart = function (src, target, nestedPanelDepth) {
        if (nestedPanelDepth === void 0) { nestedPanelDepth = -1; }
        this.dragDropInfo = new DragDropInfo(src, target, nestedPanelDepth);
    };
    DragDropPageHelperV1.prototype.dragDropMoveTo = function (destination, isBottom, isEdge) {
        if (isBottom === void 0) { isBottom = false; }
        if (isEdge === void 0) { isEdge = false; }
        if (!this.dragDropInfo)
            return false;
        this.dragDropInfo.destination = destination;
        this.dragDropInfo.isBottom = isBottom;
        this.dragDropInfo.isEdge = isEdge;
        this.correctDragDropInfo(this.dragDropInfo);
        if (!this.dragDropCanDropTagert())
            return false;
        if (!this.dragDropCanDropSource() || !this.dragDropAllowFromSurvey()) {
            if (!!this.dragDropInfo.source) {
                var row = this.page.dragDropFindRow(this.dragDropInfo.target);
                this.page.updateRowsRemoveElementFromRow(this.dragDropInfo.target, row);
            }
            return false;
        }
        this.page.dragDropAddTarget(this.dragDropInfo);
        return true;
    };
    DragDropPageHelperV1.prototype.correctDragDropInfo = function (dragDropInfo) {
        if (!dragDropInfo.destination)
            return;
        var panel = dragDropInfo.destination.isPanel
            ? dragDropInfo.destination
            : null;
        if (!panel)
            return;
        if (!dragDropInfo.target.isLayoutTypeSupported(panel.getChildrenLayoutType())) {
            dragDropInfo.isEdge = true;
        }
    };
    DragDropPageHelperV1.prototype.dragDropAllowFromSurvey = function () {
        var dest = this.dragDropInfo.destination;
        if (!dest || !this.page.survey)
            return true;
        var insertBefore = null;
        var insertAfter = null;
        var parent = dest.isPage || (!this.dragDropInfo.isEdge && dest.isPanel)
            ? dest
            : dest.parent;
        if (!dest.isPage) {
            var container = dest.parent;
            if (!!container) {
                var elements = container.elements;
                var index = elements.indexOf(dest);
                if (index > -1) {
                    insertBefore = dest;
                    insertAfter = dest;
                    if (this.dragDropInfo.isBottom) {
                        insertBefore =
                            index < elements.length - 1 ? elements[index + 1] : null;
                    }
                    else {
                        insertAfter = index > 0 ? elements[index - 1] : null;
                    }
                }
            }
        }
        var options = {
            allow: true,
            target: this.dragDropInfo.target,
            source: this.dragDropInfo.source,
            toElement: this.dragDropInfo.target,
            draggedElement: this.dragDropInfo.source,
            parent: parent,
            fromElement: this.dragDropInfo.source ? this.dragDropInfo.source.parent : null,
            insertAfter: insertAfter,
            insertBefore: insertBefore,
        };
        return this.page.survey.dragAndDropAllow(options);
    };
    DragDropPageHelperV1.prototype.dragDropFinish = function (isCancel) {
        if (isCancel === void 0) { isCancel = false; }
        if (!this.dragDropInfo)
            return;
        var target = this.dragDropInfo.target;
        var src = this.dragDropInfo.source;
        var dest = this.dragDropInfo.destination;
        var row = this.page.dragDropFindRow(target);
        var targetIndex = this.dragDropGetElementIndex(target, row);
        this.page.updateRowsRemoveElementFromRow(target, row);
        var elementsToSetSWNL = [];
        var elementsToResetSWNL = [];
        if (!isCancel && !!row) {
            var isSamePanel = false;
            if (this.page.isDesignModeV2) {
                var srcRow = src && src.parent && src.parent.dragDropFindRow(src);
                if (row.panel.elements[targetIndex] && row.panel.elements[targetIndex].startWithNewLine && row.elements.length > 1 && row.panel.elements[targetIndex] === dest) {
                    elementsToSetSWNL.push(target);
                    elementsToResetSWNL.push(row.panel.elements[targetIndex]);
                }
                if (target.startWithNewLine && row.elements.length > 1 && (!row.panel.elements[targetIndex] || !row.panel.elements[targetIndex].startWithNewLine)) {
                    elementsToResetSWNL.push(target);
                }
                if (srcRow && srcRow.elements[0] === src && srcRow.elements[1]) {
                    elementsToSetSWNL.push(srcRow.elements[1]);
                }
                if (row.elements.length <= 1) {
                    elementsToSetSWNL.push(target);
                }
                if (target.startWithNewLine && row.elements.length > 1 && row.elements[0] !== dest) {
                    elementsToResetSWNL.push(target);
                }
            }
            this.page.survey.startMovingQuestion();
            if (!!src && !!src.parent) {
                isSamePanel = row.panel == src.parent;
                if (isSamePanel) {
                    row.panel.dragDropMoveElement(src, target, targetIndex);
                    targetIndex = -1;
                }
                else {
                    src.parent.removeElement(src);
                }
            }
            if (targetIndex > -1) {
                row.panel.addElement(target, targetIndex);
            }
            this.page.survey.stopMovingQuestion();
        }
        elementsToSetSWNL.map(function (e) { e.startWithNewLine = true; });
        elementsToResetSWNL.map(function (e) { e.startWithNewLine = false; });
        this.dragDropInfo = null;
        return !isCancel ? target : null;
    };
    DragDropPageHelperV1.prototype.dragDropGetElementIndex = function (target, row) {
        if (!row)
            return -1;
        var index = row.elements.indexOf(target);
        if (row.index == 0)
            return index;
        var prevRow = row.panel.rows[row.index - 1];
        var prevElement = prevRow.elements[prevRow.elements.length - 1];
        return index + row.panel.elements.indexOf(prevElement) + 1;
    };
    DragDropPageHelperV1.prototype.dragDropCanDropTagert = function () {
        var destination = this.dragDropInfo.destination;
        if (!destination || destination.isPage)
            return true;
        return this.dragDropCanDropCore(this.dragDropInfo.target, destination);
    };
    DragDropPageHelperV1.prototype.dragDropCanDropSource = function () {
        var source = this.dragDropInfo.source;
        if (!source)
            return true;
        var destination = this.dragDropInfo.destination;
        if (!this.dragDropCanDropCore(source, destination))
            return false;
        if (this.page.isDesignModeV2) {
            var rowSource = this.page.dragDropFindRow(source);
            var rowDestination = this.page.dragDropFindRow(destination);
            if (rowSource !== rowDestination) {
                if (!source.startWithNewLine && destination.startWithNewLine)
                    return true;
                if (source.startWithNewLine && !destination.startWithNewLine) {
                    return true;
                }
            }
            var row = this.page.dragDropFindRow(destination);
            if (row && row.elements.length == 1)
                return true;
        }
        return this.dragDropCanDropNotNext(source, destination, this.dragDropInfo.isEdge, this.dragDropInfo.isBottom);
    };
    DragDropPageHelperV1.prototype.dragDropCanDropCore = function (target, destination) {
        if (!destination)
            return true;
        if (this.dragDropIsSameElement(destination, target))
            return false;
        if (target.isPanel) {
            var pnl = target;
            if (pnl.containsElement(destination) ||
                !!pnl.getElementByName(destination.name))
                return false;
        }
        return true;
    };
    DragDropPageHelperV1.prototype.dragDropCanDropNotNext = function (source, destination, isEdge, isBottom) {
        if (!destination || (destination.isPanel && !isEdge))
            return true;
        if (typeof source.parent === "undefined" || source.parent !== destination.parent)
            return true;
        var pnl = source.parent;
        var srcIndex = pnl.elements.indexOf(source);
        var destIndex = pnl.elements.indexOf(destination);
        if (destIndex < srcIndex && !isBottom)
            destIndex--;
        if (isBottom)
            destIndex++;
        return srcIndex < destIndex
            ? destIndex - srcIndex > 1
            : srcIndex - destIndex > 0;
    };
    DragDropPageHelperV1.prototype.dragDropIsSameElement = function (el1, el2) {
        return el1 == el2 || el1.name == el2.name;
    };
    return DragDropPageHelperV1;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/page.ts
var page_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var page_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};




/**
 * The `PageModel` object describes a survey page and contains properties and methods that allow you to control the page and access its elements (panels and questions).
 *
 * [View Demo](https://surveyjs.io/form-library/examples/nps-question/ (linkStyle))
 */
var page_PageModel = /** @class */ (function (_super) {
    page_extends(PageModel, _super);
    function PageModel(name) {
        if (name === void 0) { name = ""; }
        var _this = _super.call(this, name) || this;
        _this.hasShownValue = false;
        /**
         * A time period that a respondent has spent on this page so far; measured in seconds. Applies only to [quiz surveys](https://surveyjs.io/form-library/documentation/design-survey-create-a-quiz).
         * @see maxTimeToFinish
         */
        _this.timeSpent = 0;
        _this.locTitle.onGetTextCallback = function (text) {
            if (_this.canShowPageNumber() && text)
                return _this.num + ". " + text;
            return text;
        };
        _this.createLocalizableString("navigationDescription", _this, true);
        _this.dragDropPageHelper = new drag_drop_page_helper_v1_DragDropPageHelperV1(_this);
        return _this;
    }
    PageModel.prototype.getType = function () {
        return "page";
    };
    PageModel.prototype.toString = function () {
        return this.name;
    };
    Object.defineProperty(PageModel.prototype, "isPage", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    PageModel.prototype.canShowPageNumber = function () {
        return this.survey && this.survey.showPageNumbers;
    };
    PageModel.prototype.canShowTitle = function () {
        return this.survey && this.survey.showPageTitles;
    };
    Object.defineProperty(PageModel.prototype, "navigationTitle", {
        /**
         * A caption displayed on a navigation button in the TOC or progress bar. Applies when [`showTOC`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#showTOC) is `true` or when the [progress bar is visible](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#showProgressBar), [`progressBarType`](https://surveyjs.io/form-library/documentation/surveymodel#progressBarType) is set to `"pages"`, and [`progressBarShowPageTitles`](https://surveyjs.io/form-library/documentation/surveymodel#progressBarShowPageTitles) is `true`.
         *
         * If navigation titles are unspecified, the navigation buttons display page [titles](https://surveyjs.io/form-library/documentation/api-reference/page-model#title) or [names](https://surveyjs.io/form-library/documentation/pagemodel#name).
         */
        get: function () {
            return this.getLocalizableStringText("navigationTitle");
        },
        set: function (val) {
            this.setLocalizableStringText("navigationTitle", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PageModel.prototype, "navigationDescription", {
        /**
         * Explanatory text displayed under a navigation button in the progress bar. Applies when the [progress bar is visible](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#showProgressBar), `SurveyModel`'s [`progressBarType`](https://surveyjs.io/form-library/documentation/surveymodel#progressBarType) is set to `"pages"`, and [`progressBarShowPageTitles`](https://surveyjs.io/form-library/documentation/surveymodel#progressBarShowPageTitles) is `true`.
         */
        get: function () {
            return this.getLocalizableStringText("navigationDescription");
        },
        set: function (val) {
            this.setLocalizableStringText("navigationDescription", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PageModel.prototype, "locNavigationDescription", {
        get: function () {
            return this.getLocalizableString("navigationDescription");
        },
        enumerable: false,
        configurable: true
    });
    PageModel.prototype.navigationLocStrChanged = function () {
        if (this.locNavigationTitle.isEmpty) {
            this.locTitle.strChanged();
        }
        this.locNavigationTitle.strChanged();
        this.locNavigationDescription.strChanged();
    };
    Object.defineProperty(PageModel.prototype, "passed", {
        get: function () {
            return this.getPropertyValue("passed", false);
        },
        set: function (val) {
            this.setPropertyValue("passed", val);
        },
        enumerable: false,
        configurable: true
    });
    PageModel.prototype.removeFromParent = function () {
        if (!!this.survey) {
            this.removeSelfFromList(this.survey.pages);
        }
    };
    PageModel.prototype.onFirstRendering = function () {
        if (this.wasShown)
            return;
        _super.prototype.onFirstRendering.call(this);
    };
    Object.defineProperty(PageModel.prototype, "visibleIndex", {
        /**
         * The visible index of the page. It has values from 0 to visible page count - 1.
         * @see SurveyModel.visiblePages
         * @see SurveyModel.pages
         */
        get: function () {
            return this.getPropertyValue("visibleIndex", -1);
        },
        set: function (val) {
            this.setPropertyValue("visibleIndex", val);
        },
        enumerable: false,
        configurable: true
    });
    PageModel.prototype.canRenderFirstRows = function () {
        return !this.isDesignMode || this.visibleIndex == 0;
    };
    Object.defineProperty(PageModel.prototype, "isStartPage", {
        /**
         * Returns `true` if this page is a start page.
         *
         * Refer to the following help topic for more information on how to configure a start page: [Start Page](https://surveyjs.io/form-library/documentation/design-survey-create-a-multi-page-survey#start-page).
         */
        get: function () {
            return this.survey && this.survey.isPageStarted(this);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PageModel.prototype, "isStarted", {
        get: function () { return this.isStartPage; },
        enumerable: false,
        configurable: true
    });
    PageModel.prototype.calcCssClasses = function (css) {
        var classes = { page: {}, error: {}, pageTitle: "", pageDescription: "", row: "", rowMultiple: "", pageRow: "", rowCompact: "", rowFadeIn: "", rowFadeOut: "", rowDelayedFadeIn: "" };
        this.copyCssClasses(classes.page, css.page);
        this.copyCssClasses(classes.error, css.error);
        if (!!css.pageTitle) {
            classes.pageTitle = css.pageTitle;
        }
        if (!!css.pageDescription) {
            classes.pageDescription = css.pageDescription;
        }
        if (!!css.row) {
            classes.row = css.row;
        }
        if (!!css.pageRow) {
            classes.pageRow = css.pageRow;
        }
        if (!!css.rowMultiple) {
            classes.rowMultiple = css.rowMultiple;
        }
        if (!!css.rowCompact) {
            classes.rowCompact = css.rowCompact;
        }
        if (!!css.rowFadeIn) {
            classes.rowFadeIn = css.rowFadeIn;
        }
        if (!!css.rowDelayedFadeIn) {
            classes.rowDelayedFadeIn = css.rowDelayedFadeIn;
        }
        if (!!css.rowFadeOut) {
            classes.rowFadeOut = css.rowFadeOut;
        }
        if (this.survey) {
            this.survey.updatePageCssClasses(this, classes);
        }
        return classes;
    };
    Object.defineProperty(PageModel.prototype, "cssTitle", {
        get: function () {
            if (!this.cssClasses.page)
                return "";
            return new CssClassBuilder()
                .append(this.cssClasses.page.title)
                .toString();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PageModel.prototype, "cssRoot", {
        get: function () {
            if (!this.cssClasses.page || !this.survey)
                return "";
            return new CssClassBuilder()
                .append(this.cssClasses.page.root)
                .append(this.cssClasses.page.emptyHeaderRoot, !this.survey.renderedHasHeader &&
                !(this.survey.isShowProgressBarOnTop && !this.survey.isStaring))
                .toString();
        },
        enumerable: false,
        configurable: true
    });
    PageModel.prototype.getCssError = function (cssClasses) {
        return new CssClassBuilder()
            .append(_super.prototype.getCssError.call(this, cssClasses))
            .append(cssClasses.page.errorsContainer).toString();
    };
    Object.defineProperty(PageModel.prototype, "navigationButtonsVisibility", {
        /**
         * Set this property to "hide" to make "Prev", "Next" and "Complete" buttons are invisible for this page. Set this property to "show" to make these buttons visible, even if survey showNavigationButtons property is false.
         * @see SurveyMode.showNavigationButtons
         */
        get: function () {
            return this.getPropertyValue("navigationButtonsVisibility");
        },
        set: function (val) {
            this.setPropertyValue("navigationButtonsVisibility", val.toLowerCase());
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PageModel.prototype, "isActive", {
        /**
         * Returns `true` if this is the current page.
         * @see SurveyModel.currentPage
         */
        get: function () {
            return !!this.survey && this.survey.currentPage === this;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PageModel.prototype, "wasShown", {
        /**
         * Returns `true` if the respondent has already seen this page during the current session.
         */
        get: function () {
            return this.hasShownValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PageModel.prototype, "hasShown", {
        get: function () {
            return this.wasShown;
        },
        enumerable: false,
        configurable: true
    });
    PageModel.prototype.setWasShown = function (val) {
        if (val == this.hasShownValue)
            return;
        this.hasShownValue = val;
        if (this.isDesignMode || val !== true)
            return;
        var els = this.elements;
        for (var i = 0; i < els.length; i++) {
            if (els[i].isPanel) {
                els[i].randomizeElements(this.areQuestionsRandomized);
            }
        }
        this.randomizeElements(this.areQuestionsRandomized);
    };
    /**
     * Scrolls this page to the top.
     */
    PageModel.prototype.scrollToTop = function () {
        if (!!this.survey) {
            this.survey.scrollElementToTop(this, null, this, this.id);
        }
    };
    // public get timeSpent(): number {
    //   return this.getPropertyValue("timeSpent", 0);
    // }
    // public set timeSpent(val: number) {
    //   this.setPropertyValue("timeSpent", val);
    // }
    /**
     * Returns a list of all panels on this page.
     * @param visibleOnly A Boolean value that specifies whether to include only visible panels.
     * @param includingDesignTime For internal use.
     */
    PageModel.prototype.getAllPanels = function (visibleOnly, includingDesignTime) {
        if (visibleOnly === void 0) { visibleOnly = false; }
        if (includingDesignTime === void 0) { includingDesignTime = false; }
        var result = new Array();
        this.addPanelsIntoList(result, visibleOnly, includingDesignTime);
        return result;
    };
    PageModel.prototype.getPanels = function (visibleOnly, includingDesignTime) {
        if (visibleOnly === void 0) { visibleOnly = false; }
        if (includingDesignTime === void 0) { includingDesignTime = false; }
        return this.getAllPanels(visibleOnly, includingDesignTime);
    };
    Object.defineProperty(PageModel.prototype, "maxTimeToFinish", {
        /**
         * A time period that a respondent has to complete this page; measured in seconds. Applies only to [quiz surveys](https://surveyjs.io/form-library/documentation/design-survey-create-a-quiz).
         *
         * A negative value or 0 sets an unlimited time period.
         *
         * Alternatively, you can use the `SurveyModel`'s [`maxTimeToFinishPage`](https://surveyjs.io/form-library/documentation/surveymodel#maxTimeToFinishPage) property to specify identical time periods for all survey pages.
         * @see timeSpent
         */
        get: function () {
            return this.getPropertyValue("maxTimeToFinish", 0);
        },
        set: function (val) {
            this.setPropertyValue("maxTimeToFinish", val);
        },
        enumerable: false,
        configurable: true
    });
    PageModel.prototype.getMaxTimeToFinish = function () {
        if (this.maxTimeToFinish !== 0)
            return this.maxTimeToFinish;
        var res = !!this.survey ? this.survey.maxTimeToFinishPage : 0;
        return res > 0 ? res : 0;
    };
    PageModel.prototype.onNumChanged = function (value) { };
    PageModel.prototype.onVisibleChanged = function () {
        if (this.isRandomizing)
            return;
        _super.prototype.onVisibleChanged.call(this);
        if (this.survey != null) {
            this.survey.pageVisibilityChanged(this, this.isVisible);
        }
    };
    PageModel.prototype.getDragDropInfo = function () { return this.dragDropPageHelper.getDragDropInfo(); };
    PageModel.prototype.dragDropStart = function (src, target, nestedPanelDepth) {
        if (nestedPanelDepth === void 0) { nestedPanelDepth = -1; }
        this.dragDropPageHelper.dragDropStart(src, target, nestedPanelDepth);
    };
    PageModel.prototype.dragDropMoveTo = function (destination, isBottom, isEdge) {
        if (isBottom === void 0) { isBottom = false; }
        if (isEdge === void 0) { isEdge = false; }
        return this.dragDropPageHelper.dragDropMoveTo(destination, isBottom, isEdge);
    };
    PageModel.prototype.dragDropFinish = function (isCancel) {
        if (isCancel === void 0) { isCancel = false; }
        return this.dragDropPageHelper.dragDropFinish(isCancel);
    };
    PageModel.prototype.ensureRowsVisibility = function () {
        _super.prototype.ensureRowsVisibility.call(this);
        this.getPanels().forEach(function (panel) { return panel.ensureRowsVisibility(); });
    };
    page_decorate([
        jsonobject_property({ defaultValue: -1, onSet: function (val, target) { return target.onNumChanged(val); } })
    ], PageModel.prototype, "num", void 0);
    return PageModel;
}(panel_PanelModelBase));

Serializer.addClass("page", [
    {
        name: "navigationButtonsVisibility",
        default: "inherit",
        choices: ["inherit", "show", "hide"],
    },
    { name: "maxTimeToFinish:number", default: 0, minValue: 0 },
    {
        name: "navigationTitle",
        visibleIf: function (obj) {
            return !!obj.survey && (obj.survey.progressBarType === "buttons" || obj.survey.showTOC);
        },
        serializationProperty: "locNavigationTitle",
    },
    {
        name: "navigationDescription",
        visibleIf: function (obj) {
            return !!obj.survey && obj.survey.progressBarType === "buttons";
        },
        serializationProperty: "locNavigationDescription",
    },
    { name: "title:text", serializationProperty: "locTitle" },
    { name: "description:text", serializationProperty: "locDescription" },
], function () {
    return new page_PageModel();
}, "panelbase");

// CONCATENATED MODULE: ./packages/survey-core/src/progress-buttons.ts
var progress_buttons_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();




var progress_buttons_ProgressButtons = /** @class */ (function (_super) {
    progress_buttons_extends(ProgressButtons, _super);
    function ProgressButtons(survey) {
        var _this = _super.call(this) || this;
        _this.survey = survey;
        _this.onResize = _this.addEvent();
        return _this;
    }
    ProgressButtons.prototype.isListElementClickable = function (index) {
        if (!this.survey.onServerValidateQuestions ||
            this.survey.onServerValidateQuestions.isEmpty ||
            this.survey.checkErrorsMode === "onComplete") {
            return true;
        }
        return index <= this.survey.currentPageNo + 1;
    };
    ProgressButtons.prototype.getRootCss = function (container) {
        if (container === void 0) { container = "center"; }
        var result = this.survey.css.progressButtonsContainerCenter;
        if (this.survey.css.progressButtonsRoot) {
            result += " " + this.survey.css.progressButtonsRoot + " " + this.survey.css.progressButtonsRoot + "--" + (["footer", "contentBottom"].indexOf(container) !== -1 ? "bottom" : "top");
            result += " " + this.survey.css.progressButtonsRoot + "--" + (this.showItemTitles ? "with-titles" : "no-titles");
        }
        if (this.showItemNumbers && this.survey.css.progressButtonsNumbered) {
            result += " " + this.survey.css.progressButtonsNumbered;
        }
        if (this.isFitToSurveyWidth) {
            result += " " + this.survey.css.progressButtonsFitSurveyWidth;
        }
        return result;
    };
    ProgressButtons.prototype.getListElementCss = function (index) {
        if (index >= this.survey.visiblePages.length)
            return;
        return new CssClassBuilder()
            .append(this.survey.css.progressButtonsListElementPassed, this.survey.visiblePages[index].passed)
            .append(this.survey.css.progressButtonsListElementCurrent, this.survey.currentPageNo === index)
            .append(this.survey.css.progressButtonsListElementNonClickable, !this.isListElementClickable(index))
            .toString();
    };
    ProgressButtons.prototype.getScrollButtonCss = function (hasScroller, isLeftScroll) {
        return new CssClassBuilder()
            .append(this.survey.css.progressButtonsImageButtonLeft, isLeftScroll)
            .append(this.survey.css.progressButtonsImageButtonRight, !isLeftScroll)
            .append(this.survey.css.progressButtonsImageButtonHidden, !hasScroller)
            .toString();
    };
    ProgressButtons.prototype.clickListElement = function (element) {
        if (!(element instanceof page_PageModel)) {
            element = this.survey.visiblePages[element];
        }
        this.survey.tryNavigateToPage(element);
    };
    ProgressButtons.prototype.isListContainerHasScroller = function (element) {
        var listContainerElement = element.querySelector("." + this.survey.css.progressButtonsListContainer);
        if (!!listContainerElement) {
            return listContainerElement.scrollWidth > listContainerElement.offsetWidth;
        }
        return false;
    };
    ProgressButtons.prototype.isCanShowItemTitles = function (element) {
        var listContainerElement = element.querySelector("ul");
        if (!listContainerElement || listContainerElement.children.length < 2)
            return true;
        if (listContainerElement.clientWidth > listContainerElement.parentElement.clientWidth) {
            return false;
        }
        var expectedElementWidth = listContainerElement.children[0].clientWidth;
        for (var i = 0; i < listContainerElement.children.length; i++) {
            if (Math.abs(listContainerElement.children[i].clientWidth - expectedElementWidth) > 5) {
                return false;
            }
        }
        return true;
    };
    ProgressButtons.prototype.clearConnectorsWidth = function (element) {
        var listContainerElements = element.querySelectorAll(".sd-progress-buttons__connector");
        for (var i = 0; i < listContainerElements.length; i++) {
            listContainerElements[i].style.width = "";
        }
    };
    ProgressButtons.prototype.adjustConnectors = function (element) {
        var listContainerElement = element.querySelector("ul");
        if (!listContainerElement)
            return;
        var listContainerElements = element.querySelectorAll(".sd-progress-buttons__connector");
        var circleWidth = this.showItemNumbers ? 36 : 20;
        // const sideCorrection = this.survey.isMobile ? circleWidth : listContainerElement.children[0].clientWidth;
        // const connectorWidth = (listContainerElement.clientWidth - sideCorrection) / (listContainerElement.children.length - 1) - circleWidth;
        var connectorWidth = (listContainerElement.clientWidth - circleWidth) / (listContainerElement.children.length - 1) - circleWidth;
        for (var i = 0; i < listContainerElements.length; i++) {
            listContainerElements[i].style.width = connectorWidth + "px";
        }
    };
    Object.defineProperty(ProgressButtons.prototype, "isFitToSurveyWidth", {
        get: function () {
            if (surveyCss.currentType !== "defaultV2") {
                return false;
            }
            return this.survey.progressBarInheritWidthFrom === "survey" && this.survey.widthMode == "static";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ProgressButtons.prototype, "progressWidth", {
        get: function () {
            if (this.isFitToSurveyWidth) {
                return this.survey.renderedWidth;
            }
            return "";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ProgressButtons.prototype, "showItemNumbers", {
        get: function () {
            if (surveyCss.currentType !== "defaultV2") {
                return false;
            }
            return this.survey.progressBarShowPageNumbers;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ProgressButtons.prototype, "showItemTitles", {
        get: function () {
            if (surveyCss.currentType !== "defaultV2") {
                return true;
            }
            return this.survey.progressBarShowPageTitles;
        },
        enumerable: false,
        configurable: true
    });
    ProgressButtons.prototype.getItemNumber = function (page) {
        var result = "";
        if (this.showItemNumbers) {
            result += this.survey.visiblePages.indexOf(page) + 1;
        }
        return result;
    };
    Object.defineProperty(ProgressButtons.prototype, "headerText", {
        get: function () {
            return this.survey.currentPage ? this.survey.currentPage.renderedNavigationTitle : "";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ProgressButtons.prototype, "footerText", {
        get: function () {
            return this.survey.progressText;
        },
        enumerable: false,
        configurable: true
    });
    ProgressButtons.prototype.processResponsiveness = function (width) {
        this.onResize.fire(this, { width: width });
    };
    return ProgressButtons;
}(base_Base));

var ProgressButtonsResponsivityManager = /** @class */ (function () {
    function ProgressButtonsResponsivityManager(model, element, viewModel) {
        var _this = this;
        this.model = model;
        this.element = element;
        this.viewModel = viewModel;
        this.criticalProperties = ["progressBarType", "progressBarShowPageTitles"];
        this.canShowItemTitles = true;
        this.processResponsiveness = function (model, options) {
            _this.viewModel.onUpdateScroller(model.isListContainerHasScroller(_this.element));
            _this.model.clearConnectorsWidth(_this.element);
            if (!model.showItemTitles) {
                _this.model.adjustConnectors(_this.element);
                return;
            }
            if (model.survey.isMobile) {
                _this.prevWidth = options.width;
                _this.canShowItemTitles = false;
                _this.model.adjustConnectors(_this.element);
                _this.viewModel.onResize(_this.canShowItemTitles);
                return;
            }
            if (_this.timer !== undefined) {
                clearTimeout(_this.timer);
            }
            _this.timer = setTimeout(function () {
                if (_this.prevWidth === undefined || _this.prevWidth < options.width && !_this.canShowItemTitles || _this.prevWidth > options.width && _this.canShowItemTitles) {
                    _this.prevWidth = options.width;
                    _this.canShowItemTitles = model.isCanShowItemTitles(_this.element);
                    _this.viewModel.onResize(_this.canShowItemTitles);
                    _this.timer = undefined;
                }
            }, 10);
        };
        this.model.survey.registerFunctionOnPropertiesValueChanged(this.criticalProperties, function () { return _this.forceUpdate(); }, "ProgressButtonsResponsivityManager" + this.viewModel.container);
        this.model.onResize.add(this.processResponsiveness);
        this.forceUpdate();
    }
    ProgressButtonsResponsivityManager.prototype.forceUpdate = function () {
        this.viewModel.onUpdateSettings();
        this.processResponsiveness(this.model, {});
    };
    ProgressButtonsResponsivityManager.prototype.dispose = function () {
        clearTimeout(this.timer);
        this.model.onResize.remove(this.processResponsiveness);
        this.model.survey.unRegisterFunctionOnPropertiesValueChanged(this.criticalProperties, "ProgressButtonsResponsivityManager" + this.viewModel.container);
        this.element = undefined;
        this.model = undefined;
    };
    return ProgressButtonsResponsivityManager;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/surveyToc.ts






function tryFocusPage(survey, panel) {
    if (survey.isDesignMode)
        return true;
    panel.focusFirstQuestion();
    return true;
}
function createTOCListModel(survey, onAction) {
    var _a;
    var pagesSource = survey.questionsOnPageMode === "singlePage" ? (_a = survey.pages[0]) === null || _a === void 0 ? void 0 : _a.elements : survey.pages;
    var items = (pagesSource || []).map(function (page) {
        return new action_Action({
            id: page.name,
            locTitle: page.locNavigationTitle,
            action: function () {
                DomDocumentHelper.activeElementBlur();
                !!onAction && onAction();
                if (page instanceof page_PageModel) {
                    return survey.tryNavigateToPage(page);
                }
                return tryFocusPage(survey, page);
            },
            visible: new ComputedUpdater(function () { return page.isVisible && !(page["isStartPage"]); })
        });
    });
    var selectedItem = items.filter(function (i) { return !!survey.currentPage && i.id === survey.currentPage.name; })[0] || items.filter(function (i) { return i.id === pagesSource[0].name; })[0];
    var listOptions = {
        items: items,
        onSelectionChanged: function (item) {
            if (!!item.action()) {
                listModel.selectedItem = item;
            }
        },
        allowSelection: true,
        searchEnabled: false,
        locOwner: survey,
        selectedItem: selectedItem
    };
    var listModel = new list_ListModel(listOptions);
    listModel.allowSelection = false;
    survey.onCurrentPageChanged.add(function (s, o) {
        listModel.selectedItem = items.filter(function (i) { return !!survey.currentPage && i.id === survey.currentPage.name; })[0];
    });
    return listModel;
}
function getTocRootCss(survey, isMobile) {
    if (isMobile === void 0) { isMobile = false; }
    var rootCss = surveyToc_TOCModel.RootStyle;
    if (isMobile) {
        return rootCss + " " + surveyToc_TOCModel.RootStyle + "--mobile";
    }
    rootCss += (" " + surveyToc_TOCModel.RootStyle + "--" + (survey.tocLocation || "").toLowerCase());
    if (surveyToc_TOCModel.StickyPosition) {
        rootCss += " " + surveyToc_TOCModel.RootStyle + "--sticky";
    }
    return rootCss;
}
var surveyToc_TOCModel = /** @class */ (function () {
    function TOCModel(survey) {
        var _this = this;
        this.survey = survey;
        this.icon = "icon-navmenu_24x24";
        this.togglePopup = function () {
            _this.popupModel.toggleVisibility();
        };
        this.listModel = createTOCListModel(survey, function () { _this.popupModel.isVisible = false; });
        this.popupModel = new popup_PopupModel("sv-list", { model: this.listModel });
        this.popupModel.overlayDisplayMode = "plain";
        this.popupModel.displayMode = new ComputedUpdater(function () { return _this.isMobile ? "overlay" : "popup"; });
        if (TOCModel.StickyPosition) {
            survey.onAfterRenderSurvey.add(function (s, o) { return _this.initStickyTOCSubscriptions(o.htmlElement); });
            this.initStickyTOCSubscriptions(survey.rootElement);
        }
    }
    TOCModel.prototype.initStickyTOCSubscriptions = function (rootElement) {
        var _this = this;
        if (TOCModel.StickyPosition && !!rootElement) {
            rootElement.addEventListener("scroll", function (event) {
                _this.updateStickyTOCSize(rootElement);
            });
            this.updateStickyTOCSize(rootElement);
        }
    };
    TOCModel.prototype.updateStickyTOCSize = function (rootElement) {
        if (!rootElement) {
            return;
        }
        var tocRootElement = rootElement.querySelector("." + TOCModel.RootStyle);
        if (!!tocRootElement) {
            tocRootElement.style.height = "";
            if (!this.isMobile && TOCModel.StickyPosition && !!rootElement) {
                var rootHeight = rootElement.getBoundingClientRect().height;
                var titleSelector = this.survey.headerView === "advanced" ? ".sv-header" : ".sv_custom_header+div div." + (this.survey.css.title || "sd-title");
                var titleElement = rootElement.querySelector(titleSelector);
                var titleElementHeight = titleElement ? titleElement.getBoundingClientRect().height : 0;
                var scrollCompensationHeight = rootElement.scrollTop > titleElementHeight ? 0 : titleElementHeight - rootElement.scrollTop;
                tocRootElement.style.height = (rootHeight - scrollCompensationHeight - 1) + "px";
            }
        }
    };
    Object.defineProperty(TOCModel.prototype, "isMobile", {
        get: function () {
            return this.survey.isMobile;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(TOCModel.prototype, "containerCss", {
        get: function () {
            return getTocRootCss(this.survey, this.isMobile);
        },
        enumerable: false,
        configurable: true
    });
    TOCModel.prototype.dispose = function () {
        this.popupModel.dispose();
        this.listModel.dispose();
    };
    TOCModel.RootStyle = "sv_progress-toc";
    TOCModel.StickyPosition = true;
    return TOCModel;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/survey.ts
var survey_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var survey_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};











// import { StylesManager } from "./stylesmanager";














/**
 * The `SurveyModel` object contains properties and methods that allow you to control the survey and access its elements.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/nps-question/ (linkStyle))
 */
var survey_SurveyModel = /** @class */ (function (_super) {
    survey_extends(SurveyModel, _super);
    //#endregion
    function SurveyModel(jsonObj, renderedElement) {
        if (jsonObj === void 0) { jsonObj = null; }
        if (renderedElement === void 0) { renderedElement = null; }
        var _this = _super.call(this) || this;
        _this.valuesHash = {};
        _this.variablesHash = {};
        //#region Event declarations
        /**
         * An event that is raised after a [trigger](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#triggers) is executed.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [Conditional Survey Logic (Triggers)](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#conditional-survey-logic-triggers (linkStyle)).
         * @see triggers
         * @see runTriggers
         */
        _this.onTriggerExecuted = _this.addEvent();
        /**
         * An event that is raised before the survey is completed. Use this event to prevent survey completion.
         * @see onComplete
         * @see doComplete
         * @see allowCompleteSurveyAutomatic
         */
        _this.onCompleting = _this.addEvent();
        /**
         * An event that is raised after the survey is completed. Use this event to send survey results to the server.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * For an example of how to use the methods described above, refer to the following help topic: [Store Survey Results in Your Own Database](https://surveyjs.io/form-library/documentation/handle-survey-results-store#store-survey-results-in-your-own-database).
         *
         * > Do not disable the [`showCompletedPage`](https://surveyjs.io/form-library/documentation/surveymodel#showCompletedPage) property if you call one of the `options.showSave...` methods. This is required because the UI that indicates data saving progress is integrated into the complete page. If you hide the complete page, the UI also becomes invisible.
         * @see onPartialSend
         * @see doComplete
         * @see allowCompleteSurveyAutomatic
         */
        _this.onComplete = _this.addEvent();
        /**
         * An event that is raised before the survey displays a [preview of given answers](https://surveyjs.io/form-library/documentation/design-survey/create-a-multi-page-survey#preview-page). Use this event to cancel the preview.
         * @see showPreviewBeforeComplete
         * @see showPreview
         * @see cancelPreview
         */
        _this.onShowingPreview = _this.addEvent();
        /**
         * An event that is raised before the survey navigates to a specified URL. Use this event to change the URL or cancel the navigation.
         * @see navigateToUrl
         * @see navigateToUrlOnCondition
         */
        _this.onNavigateToUrl = _this.addEvent();
        /**
         * An event that is raised when the survey [`state`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#state) changes to `"running"`.
         * @see firstPageIsStarted
         */
        _this.onStarted = _this.addEvent();
        /**
         * An event that is raised to save incomplete survey results. Enable the [`sendResultOnPageNext`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#sendResultOnPageNext) property for this event to occur.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * Alternatively, you can handle the [`onCurrentPageChanged`](#onCurrentPageChanged) and [`onValueChanged`](#onValueChanged) events, as shown in the following demo: [Continue an Incomplete Survey](https://surveyjs.io/form-library/examples/survey-editprevious/).
         */
        _this.onPartialSend = _this.addEvent();
        /**
         * An event that is raised before the current page is switched.
         *
         * @see currentPageNo
         * @see nextPage
         * @see prevPage
         **/
        _this.onCurrentPageChanging = _this.addEvent();
        /**
         * An event that is raised after the current page is switched.
         *
         * @see currentPageNo
         * @see nextPage
         * @see prevPage
         */
        _this.onCurrentPageChanged = _this.addEvent();
        /**
         * An event that is raised before a question value is changed.
         * @see setValue
         */
        _this.onValueChanging = _this.addEvent();
        /**
         * An event that is raised after a question value is changed.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * To handle value changes in matrix cells or panels within a [Dynamic Panel](https://surveyjs.io/form-library/documentation/api-reference/dynamic-panel-model), use the [`onMatrixCellValueChanged`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onMatrixCellValueChanged) or [`onDynamicPanelItemValueChanged`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onDynamicPanelItemValueChanged) event.
         * @see setValue
         */
        _this.onValueChanged = _this.addEvent();
        /**
         * An event that is raised after a [variable](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#variables) or [calculated value](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#calculated-values) is changed.
         *
         * @see setVariable
         * @see calculatedValues
         */
        _this.onVariableChanged = _this.addEvent();
        /**
         * An event that is raised after question visibility is changed.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * Refer to the following help topic for information on how to implement conditional visibility: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#conditional-visibility).
         */
        _this.onQuestionVisibleChanged = _this.addEvent();
        _this.onVisibleChanged = _this.onQuestionVisibleChanged;
        /**
         * An event that is raised after page visibility is changed.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * Refer to the following help topic for information on how to implement conditional visibility: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#conditional-visibility).
         */
        _this.onPageVisibleChanged = _this.addEvent();
        /**
         * An event that is raised after panel visibility is changed.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * Refer to the following help topic for information on how to implement conditional visibility: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#conditional-visibility).
         */
        _this.onPanelVisibleChanged = _this.addEvent();
        /**
         * An event that is raised when the survey creates any new object derived from [`Question`](https://surveyjs.io/form-library/documentation/api-reference/question).
         *
         * In a survey, complex elements ([Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/), [Multiple Text](https://surveyjs.io/form-library/examples/questiontype-multipletext/), and [Dynamic Panel](https://surveyjs.io/form-library/examples/questiontype-paneldynamic/)) are composed of questions. Use this event to customize any question regardless of which survey element it belongs to.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * To use this event for questions loaded from JSON, create an empty survey model, add an event handler, and only then populate the model from the JSON object:
         *
         * ```js
         * import { Model } from "survey-core";
         *
         * const surveyJson = {
         *    // ...
         * };
         * // Create an empty model
         * const survey = new Model();
         * // Add an event handler
         * survey.onQuestionCreated.add((sender, options) => {
         *   //...
         * });
         * // Load the survey JSON schema
         * survey.fromJSON(surveyJson);
         * ```
         * @see onQuestionAdded
         */
        _this.onQuestionCreated = _this.addEvent();
        /**
         * An event that is raised when a new question is added to a panel or page.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * To use this event for questions loaded from JSON, create an empty survey model, add an event handler, and only then populate the model from the JSON object:
         *
         * ```js
         * import { Model } from "survey-core";
         *
         * const surveyJson = {
         *    // ...
         * };
         * // Create an empty model
         * const survey = new Model();
         * // Add an event handler
         * survey.onQuestionAdded.add((sender, options) => {
         *   //...
         * });
         * // Load the survey JSON schema
         * survey.fromJSON(surveyJson);
         * ```
         * @see onQuestionCreated
         */
        _this.onQuestionAdded = _this.addEvent();
        /**
         * An event that is raised after a question is deleted from the survey.
         */
        _this.onQuestionRemoved = _this.addEvent();
        /**
         * An event that is raised when a new panel is added to a page.
         */
        _this.onPanelAdded = _this.addEvent();
        /**
         * An event that is raised after a panel is deleted from the survey.
         */
        _this.onPanelRemoved = _this.addEvent();
        /**
         * An event that is raised when a new page is added to the survey.
         * @see PanelModel
         */
        _this.onPageAdded = _this.addEvent();
        /**
         * An event that is raised when a question value is being validated. Use this event to specify a custom error message.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/add-custom-input-validation/ (linkStyle))
         * @see onServerValidateQuestions
         * @see onValidatePanel
         * @see onMatrixCellValidate
         * @see onSettingQuestionErrors
         */
        _this.onValidateQuestion = _this.addEvent();
        /**
         * An event that is raised before errors are assigned to a question. Use this event to add/remove/modify errors.
         * @see onValidateQuestion
         */
        _this.onSettingQuestionErrors = _this.addEvent();
        /**
         * Use this event to validate data on your server.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/javascript-server-side-form-validation/ (linkStyle))
         * @see onValidateQuestion
         * @see onValidatePanel
         * @see isValidatingOnServer
         */
        _this.onServerValidateQuestions = _this.addEvent();
        /**
         * An event that is raised when a panel is being validated. Use this event to specify a custom error message.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/add-custom-input-validation/ (linkStyle))
         * @see onValidateQuestion
         * @see onServerValidateQuestions
         */
        _this.onValidatePanel = _this.addEvent();
        /**
         * An event that is raised to change default error messages.
         */
        _this.onErrorCustomText = _this.addEvent();
        /**
         * An event that is raised when the [current page](#currentPage) is being validated. Handle this event to be notified of current page validation.
         */
        _this.onValidatedErrorsOnCurrentPage = _this.addEvent();
        /**
         * An event that is raised when the survey processes HTML content. Handle this event to modify HTML content before displaying.
         * @see completedHtml
         * @see loadingHtml
         * @see QuestionHtmlModel.html
         */
        _this.onProcessHtml = _this.addEvent();
        /**
         * Use this event to change a question's display text.
         */
        _this.onGetQuestionDisplayValue = _this.addEvent();
        /**
         * An event that is raised before the survey displays a question title. Handle this event to modify question titles.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * If you want to modify question numbers, handle the [`onGetQuestionNo`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onGetQuestionNo) event.
         * @see requiredText
         */
        _this.onGetQuestionTitle = _this.addEvent();
        /**
         * An event that is raised when the survey calculates heading levels (`<h1>`, `<h2>`, etc.) for a survey, page, panel, and question title. Handle this event to change the heading level of individual titles.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * If you want to specify heading levels for all titles, use the [`titleTags`](https://surveyjs.io/form-library/documentation/api-reference/settings#titleTags) object in [global settings](https://surveyjs.io/form-library/documentation/api-reference/settings).
         *
         * [View Demo](https://surveyjs.io/form-library/examples/survey-titletagnames/ (linkStyle))
         * @see onGetQuestionTitle
         * @see onGetQuestionNo
         */
        _this.onGetTitleTagName = _this.addEvent();
        /**
         * An event that is raised before the survey calculates a question number. Handle this event to modify question numbers.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * If you want to hide question numbers, disable the [`showQuestionNumbers`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#showQuestionNumbers) property.
         * @see onGetQuestionTitle
         * @see questionStartIndex
         */
        _this.onGetQuestionNo = _this.addEvent();
        /**
         * An event that is raised before the survey displays progress text. Handle this event to change the progress text in code.
         * @see showProgressBar
         * @see progressBarType
         */
        _this.onProgressText = _this.addEvent();
        /**
         * An event that is raised to convert Markdown content to HTML.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/edit-survey-questions-markdown/ (linkStyle))
         */
        _this.onTextMarkdown = _this.addEvent();
        _this.onTextRenderAs = _this.addEvent();
        /**
         * An event that is raised after a request to save survey results on [SurveyJS Service](https://api.surveyjs.io/) has been completed. Use this event to find out if the results have been saved successfully.
         */
        _this.onSendResult = _this.addEvent();
        /**
         * An event that is raised when the [`getResult(resultId, questionName)`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#getResult) method is called. Use this event to obtain answers to an individual question from [SurveyJS Service](https://api.surveyjs.io/).
         * @see getResult
         */
        _this.onGetResult = _this.addEvent();
        /**
         * An event that is raised when Survey Creator opens a dialog window for users to select files.
         * @see onUploadFile
         * @see uploadFiles
         */
        _this.onOpenFileChooser = _this.addEvent();
        /**
         * An event that is raised when a File Upload or Signature Pad question starts to upload a file. Applies only if [`storeDataAsText`](https://surveyjs.io/form-library/documentation/api-reference/file-model#storeDataAsText) is `false`. Use this event to upload files to your server.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/file-upload/ (linkStyle))
         * @see uploadFiles
         * @see onDownloadFile
         * @see onClearFiles
         */
        _this.onUploadFiles = _this.addEvent();
        /**
         * An event that is raised when a File Upload question starts to download a file. Use this event to implement file preview when your server stores only file names.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/store-file-names-in-survey-results/ (linkStyle))
         * @see downloadFile
         * @see onClearFiles
         * @see onUploadFiles
         */
        _this.onDownloadFile = _this.addEvent();
        /**
         * An event that is raised when users clear files in a [File Upload](https://surveyjs.io/form-library/documentation/api-reference/file-model) question or clear signature in a [Signature Pad](https://surveyjs.io/form-library/documentation/api-reference/signature-pad-model) question. Use this event to delete files from your server.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/file-delayed-upload/ (linkStyle))
         * @see clearFiles
         * @see onDownloadFile
         * @see onUploadFiles
         */
        _this.onClearFiles = _this.addEvent();
        /**
         * An event that is raised after choices are loaded from a server but before they are assigned to a choice-based question, such as [Dropdown](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model) or [Checkboxes](https://surveyjs.io/form-library/documentation/api-reference/checkbox-question-model). Handle this event if you need to modify the loaded choices.
         */
        _this.onLoadChoicesFromServer = _this.addEvent();
        /**
         * An event that is raised after a survey JSON schema is loaded from the [SurveyJS Service](https://api.surveyjs.io). Use this event to modify the loaded schema.
         * @see surveyId
         * @see clientId
         * @see loadSurveyFromService
         */
        _this.onLoadedSurveyFromService = _this.addEvent();
        /**
         * An event that is raised when the survey processes [dynamic texts](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#dynamic-texts) and any text in curly brackets. Use this event, for instance, to substitute parameters in a RESTful URL with real values when you [load choices by URL](https://surveyjs.io/form-library/documentation/api-reference/checkbox-question-model#choicesByUrl).
         */
        _this.onProcessTextValue = _this.addEvent();
        /**
         * An event that is raised before rendering a question. Use it to override default question CSS classes.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/customize-survey-with-css/ (linkStyle))
         * @see css
         */
        _this.onUpdateQuestionCssClasses = _this.addEvent();
        /**
         * An event that is raised before rendering a standalone panel and panels within [Dynamic Panel](https://surveyjs.io/form-library/examples/duplicate-group-of-fields-in-form/). Use it to override default panel CSS classes.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/customize-survey-with-css/ (linkStyle))
         * @see css
         */
        _this.onUpdatePanelCssClasses = _this.addEvent();
        /**
         * An event that is raised before rendering a page. Use it to override default page CSS classes.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/customize-survey-with-css/ (linkStyle))
         * @see css
         */
        _this.onUpdatePageCssClasses = _this.addEvent();
        /**
         * An event that is raised before rendering a choice item in Radio Button Group and Checkboxes questions. Use it to override default CSS classes applied to choice items.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/customize-survey-with-css/ (linkStyle))
         * @see css
         */
        _this.onUpdateChoiceItemCss = _this.addEvent();
        /**
         * An event that is raised after the survey is rendered to the DOM. Use this event to modify survey markup.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/survey-animation/ (linkStyle))
         */
        _this.onAfterRenderSurvey = _this.addEvent();
        _this.onAfterRenderHeader = _this.addEvent();
        /**
         * An event that is raised after a page is rendered to the DOM. Use it to modify page markup.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/survey-afterrender/ (linkStyle))
         */
        _this.onAfterRenderPage = _this.addEvent();
        /**
         * An event that is raised after a question is rendered to the DOM. Use it to modify question markup.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/survey-afterrender/ (linkStyle))
         */
        _this.onAfterRenderQuestion = _this.addEvent();
        /**
         * An event that is raised after a question with a single input field is rendered to the DOM. Use it to modify question markup.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * > This event is not raised for questions without input fields ([HTML](https://surveyjs.io/form-library/documentation/questionhtmlmodel), [Image](https://surveyjs.io/form-library/documentation/questionimagemodel)) or questions with multiple input fields ([Matrix](https://surveyjs.io/form-library/documentation/questionmatrixmodel), [Multiple Text](https://surveyjs.io/form-library/documentation/questionmultipletextmodel)).
         */
        _this.onAfterRenderQuestionInput = _this.addEvent();
        /**
         * An event that is raised after a panel is rendered to the DOM. Use it to modify panel markup.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * > This event is raised for static [Panels](https://surveyjs.io/form-library/examples/set-properties-on-multiple-questions-using-panel/) as well as panels within a [Dynamic Panel](https://surveyjs.io/form-library/examples/duplicate-group-of-fields-in-form/).
         */
        _this.onAfterRenderPanel = _this.addEvent();
        /**
         * An event that is raised when an element (input field, checkbox, radio button) within a question gets focus.
         * @see onFocusInPanel
         * @see focusFirstQuestionAutomatic
         * @see focusQuestion
         */
        _this.onFocusInQuestion = _this.addEvent();
        /**
         * An event that is raised when an element within a panel gets focus.
         * @see onFocusInQuestion
         * @see focusFirstQuestionAutomatic
         * @see focusQuestion
         */
        _this.onFocusInPanel = _this.addEvent();
        /**
         * An event that is raised before a [choice item](https://surveyjs.io/form-library/documentation/api-reference/questionselectbase#choices) is displayed. Use this event to change the visibility of individual choice items in [Checkboxes](https://surveyjs.io/form-library/documentation/api-reference/checkbox-question-model), [Dropdown](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model), [Radio Button Group](https://surveyjs.io/form-library/documentation/api-reference/radio-button-question-model), and other similar question types.
         */
        _this.onShowingChoiceItem = _this.addEvent();
        /**
         * Use this event to load choice items in [Dropdown](https://surveyjs.io/form-library/documentation/questiondropdownmodel) and [Tag Box](https://surveyjs.io/form-library/documentation/questiontagboxmodel) questions on demand.
         *
         * This event is raised only for those questions that have the [`choicesLazyLoadEnabled`](https://surveyjs.io/form-library/documentation/questiondropdownmodel#choicesLazyLoadEnabled) property set to `true`.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/lazy-loading-dropdown/ (linkStyle))
         */
        _this.onChoicesLazyLoad = _this.addEvent();
        /**
         * An event that is raised each time a search string in a [Dropdown](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model) or [Tag Box](https://surveyjs.io/form-library/documentation/api-reference/dropdown-tag-box-model) question changes. Use this event to implement custom filtering of choice options.
         * @see [QuestionDropdownModel.searchEnabled](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model#searchEnabled)
         * @see [QuestionDropdownModel.searchMode](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model#searchMode)
         */
        _this.onChoicesSearch = _this.addEvent();
        /**
         * Use this event to load a display text for the [default choice item](https://surveyjs.io/form-library/documentation/questiondropdownmodel#defaultValue) in [Dropdown](https://surveyjs.io/form-library/documentation/questiondropdownmodel) and [Tag Box](https://surveyjs.io/form-library/documentation/questiontagboxmodel) questions.
         *
         * If you load choices from a server (use [`choicesByUrl`](https://surveyjs.io/form-library/documentation/questiondropdownmodel#choicesByUrl) or [`onChoicesLazyLoad`](https://surveyjs.io/form-library/documentation/surveymodel#onChoicesLazyLoad)), display texts become available only when data is loaded, which does not happen until a user opens the drop-down menu. However, a display text for a default choice item is required before that. In this case, you can load data individually for the default item within the `onGetChoiceDisplayValue` event handler.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/lazy-loading-dropdown/ (linkStyle))
         */
        _this.onGetChoiceDisplayValue = _this.addEvent();
        /**
         * An event that is raised after a new row is added to a [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/).
         */
        _this.onMatrixRowAdded = _this.addEvent();
        /**
         * An event that is raised before a new row is added to a [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/).
         */
        _this.onMatrixRowAdding = _this.addEvent();
        /**
         * This event is obsolete. Use the [`onMatrixRowAdding`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onMatrixRowAdding) event instead.
         */
        _this.onMatrixBeforeRowAdded = _this.onMatrixRowAdding;
        /**
         * An event that is raised before a row is deleted from a [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/). You can cancel row deletion and clear row data instead.
         * @see onMatrixRenderRemoveButton
         */
        _this.onMatrixRowRemoving = _this.addEvent();
        /**
         * An event that is raised after a row is deleted from a [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/).
         * @see onMatrixRenderRemoveButton
         */
        _this.onMatrixRowRemoved = _this.addEvent();
        /**
         * An event that is raised before rendering the Remove button in a row of a [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/). Use this event to hide the Remove button for individual matrix rows.
         * @see onMatrixRowRemoving
         * @see onMatrixRowRemoved
         */
        _this.onMatrixRenderRemoveButton = _this.addEvent();
        /**
         * This event is obsolete. Use the [`onMatrixRenderRemoveButton`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onMatrixRenderRemoveButton) event instead.
         */
        _this.onMatrixAllowRemoveRow = _this.onMatrixRenderRemoveButton;
        /**
         * An event that is raised after the visibility of an [expandable detail section](https://surveyjs.io/form-library/examples/add-expandable-details-section-under-matrix-rows/) is changed. This event can be raised for [Multi-Select](https://surveyjs.io/form-library/documentation/api-reference/matrix-table-with-dropdown-list) and [Dynamic Matrix](https://surveyjs.io/form-library/documentation/api-reference/dynamic-matrix-table-question-model) questions.
         */
        _this.onMatrixDetailPanelVisibleChanged = _this.addEvent();
        /**
         * An event that is raised before a cell in a [Multi-Select Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdropdown/) or [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/) is created. Use this event to change the type of individual matrix cells.
         * @see onAfterRenderMatrixCell
         */
        _this.onMatrixCellCreating = _this.addEvent();
        /**
          * An event that is raised after a cell in a [Multi-Select Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdropdown/) or [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/) is created.
          * @see onAfterRenderMatrixCell
          */
        _this.onMatrixCellCreated = _this.addEvent();
        /**
         * An event that is raised for every matrix cell after it is rendered to the DOM.
         * @see onMatrixCellCreated
         */
        _this.onAfterRenderMatrixCell = _this.addEvent();
        /**
         * This event is obsolete. Use the [`onAfterRenderMatrixCell`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onAfterRenderMatrixCell) event instead.
         */
        _this.onMatrixAfterCellRender = _this.onAfterRenderMatrixCell;
        /**
         * An event that is raised after a cell value is changed in a [Multi-Select Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdropdown/) or [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/).
         * @see onMatrixRowAdding
         */
        _this.onMatrixCellValueChanged = _this.addEvent();
        /**
         * An event that is raised before a cell value is changed in a [Multi-Select Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdropdown/) or [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/). Use this event to change the cell value.
         * @see onMatrixRowAdding
         */
        _this.onMatrixCellValueChanging = _this.addEvent();
        /**
         * An event that is raised for [Multi-Select Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdropdown/) and [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/) questions when they validate a cell value. Use this event to display a custom error message based on a condition.
         * @see onMatrixRowAdding
         */
        _this.onMatrixCellValidate = _this.addEvent();
        /**
         * An event that is raised after a new column is added to a [Multi-Select Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdropdown/) or [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/).
         */
        _this.onMatrixColumnAdded = _this.addEvent();
        /**
         * An event that is raised on adding a new item in Multiple Text question.
         */
        _this.onMultipleTextItemAdded = _this.addEvent();
        /**
         * An event that is raised after a new panel is added to a [Dynamic Panel](https://surveyjs.io/form-library/examples/questiontype-paneldynamic/) question.
         */
        _this.onDynamicPanelAdded = _this.addEvent();
        /**
         * An event that is raised after a panel is deleted from a [Dynamic Panel](https://surveyjs.io/form-library/examples/questiontype-paneldynamic/) question.
         */
        _this.onDynamicPanelRemoved = _this.addEvent();
        /**
         * An event that is raised before a panel is deleted from a [Dynamic Panel](https://surveyjs.io/form-library/examples/questiontype-paneldynamic/) question. Use this event to cancel the deletion.
         */
        _this.onDynamicPanelRemoving = _this.addEvent();
        /**
        * An event that is raised every second while the timer is running.
        *
        * Use the [`timeSpent`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#timeSpent) property to find out how many seconds have elapsed.
        * @see maxTimeToFinish
        * @see maxTimeToFinishPage
        * @see showTimerPanel
        * @see startTimer
        */
        _this.onTimer = _this.addEvent();
        _this.onTimerPanelInfoText = _this.addEvent();
        /**
         * An event that is raised after an item value is changed in a panel within a [Dynamic Panel](https://surveyjs.io/form-library/examples/questiontype-paneldynamic/) question.
         */
        _this.onDynamicPanelItemValueChanged = _this.addEvent();
        /**
         * An event that is raised before a [Dynamic Panel](https://surveyjs.io/form-library/examples/questiontype-paneldynamic/) renders [tab titles](https://surveyjs.io/form-library/documentation/api-reference/dynamic-panel-model#templateTabTitle). Use this event to change individual tab titles.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/tabbed-interface-for-duplicate-group-option/ (linkStyle))
         */
        _this.onGetDynamicPanelTabTitle = _this.addEvent();
        /**
         * An event that is raised after the current panel is changed in a [Dynamic Panel](https://surveyjs.io/form-library/examples/questiontype-paneldynamic/) question.
         */
        _this.onDynamicPanelCurrentIndexChanged = _this.addEvent();
        /**
         * An event that is raised to define whether a question answer is correct. Applies only to [quiz surveys](https://surveyjs.io/form-library/documentation/design-survey/create-a-quiz).
         */
        _this.onIsAnswerCorrect = _this.addEvent();
        /**
         * An event that is raised when users drag and drop survey elements while designing the survey in [Survey Creator](https://surveyjs.io/survey-creator/documentation/overview). Use this event to control drag and drop operations.
         * @see isDesignMode
         */
        _this.onDragDropAllow = _this.addEvent();
        /**
         * An event this is raised before a survey element (usually page) is scrolled to the top. Use this event to cancel the scroll operation.
         */
        _this.onScrollingElementToTop = _this.addEvent();
        _this.onLocaleChangedEvent = _this.addEvent();
        /**
         * An event that allows you to add, delete, or modify actions in a question title.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/survey-titleactions/ (linkStyle))
         * @see [IAction](https://surveyjs.io/form-library/documentation/api-reference/iaction)
        */
        _this.onGetQuestionTitleActions = _this.addEvent();
        /**
         * An event that allows you to add, delete, or modify actions in a panel title.
         * @see [IAction](https://surveyjs.io/form-library/documentation/api-reference/iaction)
         */
        _this.onGetPanelTitleActions = _this.addEvent();
        /**
         * An event that allows you to add, delete, or modify actions in a page title.
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/modify-titles-of-survey-elements/ (linkStyle))
         * @see [IAction](https://surveyjs.io/form-library/documentation/api-reference/iaction)
         */
        _this.onGetPageTitleActions = _this.addEvent();
        /**
         * An event that allows you to add, delete, or modify actions in the footer of a [Panel](https://surveyjs.io/form-library/documentation/panelmodel).
         * @see [IAction](https://surveyjs.io/form-library/documentation/api-reference/iaction)
         */
        _this.onGetPanelFooterActions = _this.addEvent();
        /**
         * An event that allows you to add, delete, or modify actions in rows of a [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/).
         *
         * For information on event handler parameters, refer to descriptions within the interface.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/employee-information-form/ (linkStyle))
         * @see [IAction](https://surveyjs.io/form-library/documentation/api-reference/iaction)
         */
        _this.onGetMatrixRowActions = _this.addEvent();
        /**
         * An event that is raised after a survey element is [expanded or collapsed](https://surveyjs.io/form-library/documentation/api-reference/question#state).
         */
        _this.onElementContentVisibilityChanged = _this.addEvent();
        /**
         * An event that is raised before an [Expression](https://surveyjs.io/form-library/documentation/api-reference/expression-model) question displays a value. Use this event to override the display value.
         */
        _this.onGetExpressionDisplayValue = _this.addEvent();
        /**
         * An event that is raised after the visibility of a popup is changed.
         *
         * This event can be raised for [Single-](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model) and [Multi-Select Dropdown](https://surveyjs.io/form-library/documentation/api-reference/dropdown-tag-box-model) questions and [Rating Scale](https://surveyjs.io/form-library/documentation/api-reference/rating-scale-question-model) questions [rendered as drop-down menus](https://surveyjs.io/form-library/documentation/api-reference/rating-scale-question-model#displayMode), and [Multi-Select Matrix](https://surveyjs.io/form-library/documentation/api-reference/matrix-table-with-dropdown-list) questions that contain columns of the `"dropdown"` or `"tagbox"` [`cellType`](https://surveyjs.io/form-library/documentation/api-reference/matrix-table-with-dropdown-list#cellType).
         */
        _this.onPopupVisibleChanged = _this.addEvent();
        /**
         * An event that is raised when users open a drop-down menu.
         *
         * This event can be raised for [Single-](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model) and [Multi-Select Dropdown](https://surveyjs.io/form-library/documentation/api-reference/dropdown-tag-box-model) questions, [Rating Scale](https://surveyjs.io/form-library/documentation/api-reference/rating-scale-question-model) questions [rendered as drop-down menus](https://surveyjs.io/form-library/documentation/api-reference/rating-scale-question-model#displayMode), and [Multi-Select Matrix](https://surveyjs.io/form-library/documentation/api-reference/matrix-table-with-dropdown-list) questions that contain columns of the `"dropdown"` or `"tagbox"` [`cellType`](https://surveyjs.io/form-library/documentation/api-reference/matrix-table-with-dropdown-list#cellType). Handle this event to change the drop-down menu type for specific questions or device types.
         */
        _this.onOpenDropdownMenu = _this.addEvent();
        _this.onElementWrapperComponentName = _this.addEvent();
        _this.onElementWrapperComponentData = _this.addEvent();
        /**
         * A list of errors in a survey JSON schema.
         * @see ensureUniqueNames
         */
        _this.jsonErrors = null;
        _this.cssValue = null;
        /**
         * Specifies whether to hide validation errors thrown by the Required validation in the UI.
         *
         * [Built-In Client-Side Validators](https://surveyjs.io/form-library/documentation/data-validation#built-in-client-side-validators (linkStyle))
         * @see validationEnabled
         * @see validationAllowSwitchPages
         */
        _this.hideRequiredErrors = false;
        //#endregion
        _this.cssVariables = {};
        _this._isMobile = false;
        _this._isCompact = false;
        _this._isDesignMode = false;
        /**
         * Specifies whether respondents can switch the current page even if it contains validation errors.
         *
         * Default value: `false`
         * @see checkErrorsMode
         */
        _this.validationAllowSwitchPages = false;
        /**
         * Specifies whether respondents can end a survey with validation errors.
         *
         * Default value: `false`
         * @see checkErrorsMode
         */
        _this.validationAllowComplete = false;
        _this.isNavigationButtonPressed = false;
        _this.mouseDownPage = null;
        _this.isCalculatingProgressText = false;
        _this.isCurrentPageRendering = true;
        _this.isCurrentPageRendered = undefined;
        _this.isTriggerIsRunning = false;
        _this.triggerValues = null;
        _this.triggerKeys = null;
        _this.conditionValues = null;
        _this.isValueChangedOnRunningCondition = false;
        _this.conditionRunnerCounter = 0;
        _this.conditionUpdateVisibleIndexes = false;
        _this.conditionNotifyElementsOnAnyValueOrVariableChanged = false;
        _this.isEndLoadingFromJson = null;
        _this.questionHashes = {
            names: {},
            namesInsensitive: {},
            valueNames: {},
            valueNamesInsensitive: {},
        };
        _this.needRenderIcons = true;
        _this.skippedPages = [];
        _this.skeletonComponentName = "sv-skeleton";
        _this.taskManager = new surveyTaskManager_SurveyTaskManagerModel();
        _this.questionErrorComponent = "sv-question-error";
        _this.onBeforeRunConstructor();
        // if (DomDocumentHelper.isAvailable()) {
        //   SurveyModel.stylesManager = new StylesManager();
        // }
        var htmlCallBack = function (str) { return "<h3>" + str + "</h3>"; };
        _this.createHtmlLocString("completedHtml", "completingSurvey", htmlCallBack);
        _this.createHtmlLocString("completedBeforeHtml", "completingSurveyBefore", htmlCallBack, "completed-before");
        _this.createHtmlLocString("loadingHtml", "loadingSurvey", htmlCallBack, "loading");
        _this.createLocalizableString("emptySurveyText", _this, true, "emptySurvey");
        _this.createLocalizableString("logo", _this, false);
        _this.createLocalizableString("startSurveyText", _this, false, true);
        _this.createLocalizableString("pagePrevText", _this, false, true);
        _this.createLocalizableString("pageNextText", _this, false, true);
        _this.createLocalizableString("completeText", _this, false, true);
        _this.createLocalizableString("previewText", _this, false, true);
        _this.createLocalizableString("editText", _this, false, true);
        _this.createLocalizableString("questionTitleTemplate", _this, true);
        _this.timerModelValue = new surveyTimerModel_SurveyTimerModel(_this);
        _this.timerModelValue.onTimer = function (page) {
            _this.doTimer(page);
        };
        _this.createNewArray("pages", function (value) {
            _this.doOnPageAdded(value);
        }, function (value) {
            _this.doOnPageRemoved(value);
        });
        _this.createNewArray("triggers", function (value) {
            value.setOwner(_this);
        });
        _this.createNewArray("calculatedValues", function (value) {
            value.setOwner(_this);
        });
        _this.createNewArray("completedHtmlOnCondition", function (value) {
            value.locOwner = _this;
        });
        _this.createNewArray("navigateToUrlOnCondition", function (value) {
            value.locOwner = _this;
        });
        _this.registerPropertyChangedHandlers(["locale"], function () {
            _this.onSurveyLocaleChanged();
        });
        _this.registerPropertyChangedHandlers(["firstPageIsStarted"], function () {
            _this.onFirstPageIsStartedChanged();
        });
        _this.registerPropertyChangedHandlers(["mode"], function () {
            _this.onModeChanged();
        });
        _this.registerPropertyChangedHandlers(["progressBarType"], function () {
            _this.updateProgressText();
        });
        _this.registerPropertyChangedHandlers(["questionStartIndex", "requiredText", "questionTitlePattern"], function () {
            _this.resetVisibleIndexes();
        });
        _this.registerPropertyChangedHandlers(["isLoading", "isCompleted", "isCompletedBefore", "mode", "isStartedState", "currentPage", "isShowingPreview"], function () { _this.updateState(); });
        _this.registerPropertyChangedHandlers(["state", "currentPage", "showPreviewBeforeComplete"], function () { _this.onStateAndCurrentPageChanged(); });
        _this.registerPropertyChangedHandlers(["logo", "logoPosition"], function () { _this.updateHasLogo(); });
        _this.registerPropertyChangedHandlers(["backgroundImage"], function () { _this.updateRenderBackgroundImage(); });
        _this.registerPropertyChangedHandlers(["renderBackgroundImage", "backgroundOpacity", "backgroundImageFit", "fitToContainer", "backgroundImageAttachment"], function () {
            _this.updateBackgroundImageStyle();
        });
        _this.registerPropertyChangedHandlers(["showPrevButton", "showCompleteButton"], function () { _this.updateButtonsVisibility(); });
        _this.onGetQuestionNo.onCallbacksChanged = function () {
            _this.resetVisibleIndexes();
        };
        _this.onProgressText.onCallbacksChanged = function () {
            _this.updateProgressText();
        };
        _this.onTextMarkdown.onCallbacksChanged = function () {
            _this.locStrsChanged();
        };
        _this.onProcessHtml.onCallbacksChanged = function () {
            _this.locStrsChanged();
        };
        _this.onGetQuestionTitle.onCallbacksChanged = function () {
            _this.locStrsChanged();
        };
        _this.onUpdatePageCssClasses.onCallbacksChanged = function () {
            _this.currentPage && _this.currentPage.updateElementCss();
        };
        _this.onUpdatePanelCssClasses.onCallbacksChanged = function () {
            _this.currentPage && _this.currentPage.updateElementCss();
        };
        _this.onUpdateQuestionCssClasses.onCallbacksChanged = function () {
            _this.currentPage && _this.currentPage.updateElementCss();
        };
        _this.onShowingChoiceItem.onCallbacksChanged = function () {
            _this.rebuildQuestionChoices();
        };
        _this.navigationBarValue = _this.createNavigationBar();
        _this.navigationBar.locOwner = _this;
        _this.onBeforeCreating();
        if (jsonObj) {
            if (typeof jsonObj === "string" || jsonObj instanceof String) {
                jsonObj = JSON.parse(jsonObj);
            }
            if (jsonObj && jsonObj.clientId) {
                _this.clientId = jsonObj.clientId;
            }
            _this.fromJSON(jsonObj);
            if (_this.surveyId) {
                _this.loadSurveyFromService(_this.surveyId, _this.clientId);
            }
        }
        _this.onCreating();
        if (!!renderedElement) {
            _this.render(renderedElement);
        }
        _this.updateCss();
        _this.setCalculatedWidthModeUpdater();
        _this.notifier = new notifier_Notifier(_this.css.saveData);
        _this.notifier.addAction(_this.createTryAgainAction(), "error");
        _this.onPopupVisibleChanged.add(function (_, opt) {
            if (opt.visible) {
                _this.onScrollCallback = function () {
                    opt.popup.hide();
                };
            }
            else {
                _this.onScrollCallback = undefined;
            }
        });
        _this.progressBarValue = new progress_buttons_ProgressButtons(_this);
        _this.layoutElements.push({
            id: "timerpanel",
            template: "survey-timerpanel",
            component: "sv-timerpanel",
            data: _this.timerModel
        });
        _this.layoutElements.push({
            id: "progress-buttons",
            component: "sv-progress-buttons",
            data: _this.progressBar,
            processResponsiveness: function (width) { return _this.progressBar.processResponsiveness && _this.progressBar.processResponsiveness(width); }
        });
        _this.layoutElements.push({
            id: "progress-questions",
            component: "sv-progress-questions",
            data: _this
        });
        _this.layoutElements.push({
            id: "progress-pages",
            component: "sv-progress-pages",
            data: _this
        });
        _this.layoutElements.push({
            id: "progress-correctquestions",
            component: "sv-progress-correctquestions",
            data: _this
        });
        _this.layoutElements.push({
            id: "progress-requiredquestions",
            component: "sv-progress-requiredquestions",
            data: _this
        });
        var tocModel = new surveyToc_TOCModel(_this);
        _this.addLayoutElement({
            id: "toc-navigation",
            component: "sv-navigation-toc",
            data: tocModel,
            processResponsiveness: function (width) { return tocModel.updateStickyTOCSize(_this.rootElement); }
        });
        _this.layoutElements.push({
            id: "buttons-navigation",
            component: "sv-action-bar",
            data: _this.navigationBar
        });
        _this.locTitle.onStringChanged.add(function () { return _this.titleIsEmpty = _this.locTitle.isEmpty; });
        return _this;
    }
    Object.defineProperty(SurveyModel.prototype, "platformName", {
        get: function () {
            return SurveyModel.platform;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "commentSuffix", {
        /**
         * A suffix added to the name of the property that stores comments.
         *
         * Default value: "-Comment"
         *
         * Many question types allow respondents to leave comments. To enable this functionality, set a question's [`showCommentArea`](https://surveyjs.io/form-library/documentation/api-reference/checkbox-question-model#showCommentArea) property to `true`. Comment values are saved in a separate property. The property name is composed of the question `name` and `commentSuffix`.
         *
         * Respondents can also leave comments when they select "Other" in choice-based questions, such as Dropdown or Checkboxes. The property name for the comment value is composed according to the same rules. However, you can use the question `name` as a key to store the comment value instead. Disable the [`storeOthersAsComment`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#storeOthersAsComment) property in this case.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/create-checkboxes-question-in-javascript/ (linkStyle))
         */
        get: function () {
            return settings.commentSuffix;
        },
        set: function (val) {
            settings.commentSuffix = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "commentPrefix", {
        get: function () {
            return this.commentSuffix;
        },
        set: function (val) {
            this.commentSuffix = val;
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.processClosedPopup = function (question, popupModel) {
        throw new Error("Method not implemented.");
    };
    SurveyModel.prototype.createTryAgainAction = function () {
        var _this = this;
        return {
            id: "save-again",
            title: this.getLocalizationString("saveAgainButton"),
            action: function () {
                if (_this.isCompleted) {
                    _this.saveDataOnComplete();
                }
                else {
                    _this.doComplete();
                }
            }
        };
    };
    SurveyModel.prototype.createHtmlLocString = function (name, locName, func, reason) {
        var _this = this;
        var res = this.createLocalizableString(name, this, false, locName);
        res.onGetLocalizationTextCallback = func;
        if (reason) {
            res.onGetTextCallback = function (str) { return _this.processHtml(str, reason); };
        }
    };
    SurveyModel.prototype.getType = function () {
        return "survey";
    };
    SurveyModel.prototype.onPropertyValueChanged = function (name, oldValue, newValue) {
        if (name === "questionsOnPageMode") {
            this.onQuestionsOnPageModeChanged(oldValue);
        }
    };
    Object.defineProperty(SurveyModel.prototype, "pages", {
        /**
         * Returns an array of all pages in the survey.
         *
         * To get an array of only visible pages, use the [`visiblePages`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#visiblePages) array.
         * @see PageModel
         */
        get: function () {
            return this.getPropertyValue("pages");
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.render = function (element) {
        if (element === void 0) { element = null; }
        if (this.renderCallback) {
            this.renderCallback();
        }
    };
    SurveyModel.prototype.updateSurvey = function (newProps, oldProps) {
        var _loop_1 = function () {
            if (key == "model" || key == "children")
                return "continue";
            if (key.indexOf("on") == 0 && this_1[key] && this_1[key].add) {
                var funcBody_1 = newProps[key];
                var func = function (sender, options) {
                    funcBody_1(sender, options);
                };
                this_1[key].add(func);
            }
            else {
                this_1[key] = newProps[key];
            }
        };
        var this_1 = this;
        for (var key in newProps) {
            _loop_1();
        }
        if (newProps && newProps.data)
            this.onValueChanged.add(function (sender, options) {
                newProps.data[options.name] = options.value;
            });
    };
    SurveyModel.prototype.getCss = function () {
        return this.css;
    };
    SurveyModel.prototype.updateCompletedPageCss = function () {
        this.containerCss = this.css.container;
        this.completedCss = new CssClassBuilder().append(this.css.body)
            .append(this.css.completedPage).toString(); // for completed page
        this.completedBeforeCss = new CssClassBuilder()
            .append(this.css.body)
            .append(this.css.completedBeforePage)
            .toString();
        this.loadingBodyCss = new CssClassBuilder()
            .append(this.css.body)
            .append(this.css.bodyLoading)
            .toString();
    };
    SurveyModel.prototype.updateCss = function () {
        this.rootCss = this.getRootCss();
        this.updateNavigationCss();
        this.updateCompletedPageCss();
        this.updateWrapperFormCss();
    };
    Object.defineProperty(SurveyModel.prototype, "css", {
        /**
         * Gets or sets an object in which keys are UI elements and values are CSS classes applied to them.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/customize-survey-with-css/ (linkStyle))
         */
        get: function () {
            if (!this.cssValue) {
                this.cssValue = {};
                this.copyCssClasses(this.cssValue, surveyCss.getCss());
            }
            return this.cssValue;
        },
        set: function (value) {
            this.setCss(value);
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.setCss = function (value, needMerge) {
        if (needMerge === void 0) { needMerge = true; }
        if (needMerge) {
            this.mergeValues(value, this.css);
        }
        else {
            this.cssValue = value;
        }
        this.updateCss();
        this.updateElementCss(false);
    };
    Object.defineProperty(SurveyModel.prototype, "cssTitle", {
        get: function () {
            return this.css.title;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "cssNavigationComplete", {
        get: function () {
            return this.getNavigationCss(this.cssSurveyNavigationButton, this.css.navigation.complete);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "cssNavigationPreview", {
        get: function () {
            return this.getNavigationCss(this.cssSurveyNavigationButton, this.css.navigation.preview);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "cssNavigationEdit", {
        get: function () {
            return this.getNavigationCss(this.css.navigationButton, this.css.navigation.edit);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "cssNavigationPrev", {
        get: function () {
            return this.getNavigationCss(this.cssSurveyNavigationButton, this.css.navigation.prev);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "cssNavigationStart", {
        get: function () {
            return this.getNavigationCss(this.cssSurveyNavigationButton, this.css.navigation.start);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "cssNavigationNext", {
        get: function () {
            return this.getNavigationCss(this.cssSurveyNavigationButton, this.css.navigation.next);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "cssSurveyNavigationButton", {
        get: function () {
            return new CssClassBuilder().append(this.css.navigationButton).append(this.css.bodyNavigationButton).toString();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "bodyCss", {
        get: function () {
            return new CssClassBuilder().append(this.css.body)
                .append(this.css.bodyWithTimer, this.showTimerPanel != "none" && this.state === "running")
                .append(this.css.body + "--" + this.calculatedWidthMode).toString();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "bodyContainerCss", {
        get: function () {
            return this.css.bodyContainer;
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.insertAdvancedHeader = function (advHeader) {
        advHeader.survey = this;
        this.layoutElements.push({
            id: "advanced-header",
            container: "header",
            component: "sv-header",
            index: -100,
            data: advHeader,
            processResponsiveness: function (width) { return advHeader.processResponsiveness(width); }
        });
    };
    SurveyModel.prototype.getNavigationCss = function (main, btn) {
        return new CssClassBuilder().append(main)
            .append(btn).toString();
    };
    Object.defineProperty(SurveyModel.prototype, "lazyRendering", {
        /**
         * Specifies whether to enable lazy rendering.
         *
         * In default mode, a survey renders the entire current page. With lazy rendering, the survey renders the page gradually as a user scrolls it. This helps reduce survey startup time and optimizes large surveys for low-end devices.
         *
         * Default value: `false`
         *
         * [View Demo](https://surveyjs.io/form-library/examples/survey-lazy/ (linkStyle))
         * @see [settings.lazyRender](https://surveyjs.io/form-library/documentation/api-reference/settings#lazyRender)
         */
        get: function () {
            return this.lazyRenderingValue === true;
        },
        set: function (val) {
            if (this.lazyRendering === val)
                return;
            this.lazyRenderingValue = val;
            var page = this.currentPage;
            if (!!page) {
                page.updateRows();
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isLazyRendering", {
        get: function () {
            return this.lazyRendering || settings.lazyRender.enabled;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "lazyRenderingFirstBatchSize", {
        get: function () {
            return this.lazyRenderingFirstBatchSizeValue || settings.lazyRender.firstBatchSize;
        },
        set: function (val) {
            this.lazyRenderingFirstBatchSizeValue = val;
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.updateLazyRenderingRowsOnRemovingElements = function () {
        if (!this.isLazyRendering)
            return;
        var page = this.currentPage;
        if (!!page) {
            scrollElementByChildId(page.id);
        }
    };
    Object.defineProperty(SurveyModel.prototype, "triggers", {
        /**
         * A list of triggers in the survey.
         *
         * [Conditional Survey Logic (Triggers)](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#conditional-survey-logic-triggers (linkStyle))
         * @see runTriggers
         * @see onTriggerExecuted
         */
        get: function () {
            return this.getPropertyValue("triggers");
        },
        set: function (val) {
            this.setPropertyValue("triggers", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "calculatedValues", {
        /**
         * An array of [calculated values](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#calculated-values).
         */
        get: function () {
            return this.getPropertyValue("calculatedValues");
        },
        set: function (val) {
            this.setPropertyValue("calculatedValues", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "surveyId", {
        /**
         * The identifier of a survey JSON schema to load from [SurveyJS Service](https://api.surveyjs.io).
         *
         * Refer to the following help topic for more information: [Store Survey Results in the SurveyJS Service](https://surveyjs.io/form-library/documentation/handle-survey-results-store#store-survey-results-in-the-surveyjs-service).
         * @see loadSurveyFromService
         * @see onLoadedSurveyFromService
         */
        get: function () {
            return this.getPropertyValue("surveyId", "");
        },
        set: function (val) {
            this.setPropertyValue("surveyId", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "surveyPostId", {
        /**
         * An identifier used to save survey results to [SurveyJS Service](https://api.surveyjs.io).
         *
         * Refer to the following help topic for more information: [Store Survey Results in the SurveyJS Service](https://surveyjs.io/form-library/documentation/handle-survey-results-store#store-survey-results-in-the-surveyjs-service).
         * @see onComplete
         * @see surveyShowDataSaving
         */
        get: function () {
            return this.getPropertyValue("surveyPostId", "");
        },
        set: function (val) {
            this.setPropertyValue("surveyPostId", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "clientId", {
        /**
         * A user identifier (e-mail or other unique ID).
         *
         * If your application works with [SurveyJS Service](https://api.surveyjs.io), the ID ensures that users do not pass the same survey twice. On the second run, they will see the [Completed Before page](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#completedBeforeHtml).
         * @see cookieName
         */
        get: function () {
            return this.getPropertyValue("clientId", "");
        },
        set: function (val) {
            this.setPropertyValue("clientId", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "cookieName", {
        /**
         * A cookie name used to save information about survey completion.
         *
         * When this property has a value, the survey creates a cookie with the specified name on completion. This cookie helps ensure that users do not pass the same survey twice. On the second run, they will see the [Completed Before page](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#completedBeforeHtml).
         * @see clientId
         */
        get: function () {
            return this.getPropertyValue("cookieName", "");
        },
        set: function (val) {
            this.setPropertyValue("cookieName", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "sendResultOnPageNext", {
        /**
         * Specifies whether to save survey results when respondents switch between pages. Handle the [`onPartialSend`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onPartialSend) event to implement the save operation.
         *
         * Alternatively, you can handle the [`onCurrentPageChanged`](#onCurrentPageChanged) and [`onValueChanged`](#onValueChanged) events, as shown in the following demo: [Continue an Incomplete Survey](https://surveyjs.io/form-library/examples/survey-editprevious/).
         */
        get: function () {
            return this.getPropertyValue("sendResultOnPageNext");
        },
        set: function (val) {
            this.setPropertyValue("sendResultOnPageNext", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "surveyShowDataSaving", {
        /**
         * Specifies whether to show progress when the survey sends data to [SurveyJS Service](https://api.surveyjs.io).
         *
         * [View Demo](https://surveyjs.io/form-library/examples/save-survey-results-and-load-surveys-from-surveyjs-service/ (linkStyle))
         * @see surveyPostId
         */
        get: function () {
            return this.getPropertyValue("surveyShowDataSaving");
        },
        set: function (val) {
            this.setPropertyValue("surveyShowDataSaving", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "focusFirstQuestionAutomatic", {
        /**
         * Specifies whether to focus the first question on the page on survey startup or when users switch between pages.
         *
         * Default value: `false` in v1.9.114 and later, `true` in earlier versions
         * @see focusOnFirstError
         * @see focusFirstQuestion
         * @see focusQuestion
         */
        get: function () {
            return this.getPropertyValue("focusFirstQuestionAutomatic");
        },
        set: function (val) {
            this.setPropertyValue("focusFirstQuestionAutomatic", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "focusOnFirstError", {
        /**
         * Specifies whether to focus the first question with a validation error on the current page.
         *
         * Default value: `true`
         * @see validate
         * @see focusFirstQuestionAutomatic
         */
        get: function () {
            return this.getPropertyValue("focusOnFirstError");
        },
        set: function (val) {
            this.setPropertyValue("focusOnFirstError", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "showNavigationButtons", {
        /**
         * Gets or sets the position of the Start, Next, Previous, and Complete navigation buttons and controls their visibility.
         *
         * Possible values:
         *
         * - `"bottom"` (default) - Displays the navigation buttons below survey content.
         * - `"top"` - Displays the navigation buttons above survey content.
         * - `"both"` - Displays the navigation buttons above and below survey content.
         * - `"none"` - Hides the navigation buttons. This setting may be useful if you [implement custom external navigation](https://surveyjs.io/form-library/examples/external-form-navigation-system/).
         * @see goNextPageAutomatic
         * @see showPrevButton
         * @see showCompleteButton
         */
        get: function () {
            return this.getPropertyValue("showNavigationButtons");
        },
        set: function (val) {
            if (val === true || val === undefined) {
                val = "bottom";
            }
            if (val === false) {
                val = "none";
            }
            this.setPropertyValue("showNavigationButtons", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "showPrevButton", {
        /**
         * Specifies whether to display the Previous button. Set this property to `false` if respondents should not move backward along the survey.
         * @see showNavigationButtons
         * @see showCompleteButton
         */
        get: function () {
            return this.getPropertyValue("showPrevButton");
        },
        set: function (val) {
            this.setPropertyValue("showPrevButton", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "showCompleteButton", {
        /**
         * Specifies whether to display the Complete button. Set this property to `false` if respondents should not complete the survey.
         * @see showNavigationButtons
         * @see showPrevButton
         */
        get: function () {
            return this.getPropertyValue("showCompleteButton", true);
        },
        set: function (val) {
            this.setPropertyValue("showCompleteButton", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "showTOC", {
        /**
         * Gets or sets the visibility of the table of contents.
         *
         * Default value: `false`
         *
         * [View Demo](https://surveyjs.io/form-library/examples/toc-feature/ (linkStyle))
         * @see tocLocation
         */
        get: function () {
            return this.getPropertyValue("showTOC");
        },
        set: function (val) {
            this.setPropertyValue("showTOC", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "tocLocation", {
        /**
         * Gets or sets the position of the table of contents. Applies only when the table of contents is visible.
         *
         * Possible values:
         *
         * - `"left"` (default)
         * - `"right"`
         *
         * [View Demo](https://surveyjs.io/form-library/examples/toc-feature/ (linkStyle))
         * @see showTOC
         */
        get: function () {
            return this.getPropertyValue("tocLocation");
        },
        set: function (val) {
            this.setPropertyValue("tocLocation", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "showTitle", {
        /**
         * Specifies whether to display the [survey title](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#title).
         *
         * [View Demo](https://surveyjs.io/form-library/examples/brand-your-survey-header/ (linkStyle))
         * @see title
         */
        get: function () {
            return this.getPropertyValue("showTitle");
        },
        set: function (val) {
            this.setPropertyValue("showTitle", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "showPageTitles", {
        /**
         * Specifies whether to display [page titles](https://surveyjs.io/form-library/documentation/api-reference/page-model#title).
         */
        get: function () {
            return this.getPropertyValue("showPageTitles");
        },
        set: function (val) {
            this.setPropertyValue("showPageTitles", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "showCompletedPage", {
        /**
         * Specifies whether to show the [complete page](https://surveyjs.io/form-library/documentation/design-survey/create-a-multi-page-survey#complete-page).
         * @see onComplete
         * @see navigateToUrl
         */
        get: function () {
            return this.getPropertyValue("showCompletedPage");
        },
        set: function (val) {
            this.setPropertyValue("showCompletedPage", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "navigateToUrl", {
        /**
         * A URL to which respondents should be navigated after survey completion.
         * @see onNavigateToUrl
         * @see navigateToUrlOnCondition
         */
        get: function () {
            return this.getPropertyValue("navigateToUrl");
        },
        set: function (val) {
            this.setPropertyValue("navigateToUrl", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "navigateToUrlOnCondition", {
        /**
         * An array of objects that allows you to navigate respondents to different URLs after survey completion.
         *
         * Each object should include the [`expression`](https://surveyjs.io/form-library/documentation/api-reference/urlconditionitem#url) and [`url`](https://surveyjs.io/form-library/documentation/api-reference/urlconditionitem#expression) properties. When `expression` evaluates to `true`, the survey navigates to the corresponding `url`. Refer to the following help topic for more information about expressions: [Expressions](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#expressions).
         * @see onNavigateToUrl
         * @see navigateToUrl
         */
        get: function () {
            return this.getPropertyValue("navigateToUrlOnCondition");
        },
        set: function (val) {
            this.setPropertyValue("navigateToUrlOnCondition", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.getNavigateToUrl = function () {
        var item = this.getExpressionItemOnRunCondition(this.navigateToUrlOnCondition);
        var url = !!item ? item.url : this.navigateToUrl;
        if (!!url) {
            url = this.processText(url, false);
        }
        return url;
    };
    SurveyModel.prototype.navigateTo = function () {
        var url = this.getNavigateToUrl();
        var options = { url: url, allow: true };
        this.onNavigateToUrl.fire(this, options);
        if (!options.url || !options.allow)
            return;
        navigateToUrl(options.url);
    };
    Object.defineProperty(SurveyModel.prototype, "requiredText", {
        /**
         * Specifies one or multiple characters that designate required questions.
         *
         * Default value: `*`
         *
         * [View Demo](https://surveyjs.io/form-library/examples/modify-question-title/ (linkStyle))
         */
        get: function () {
            return this.getPropertyValue("requiredText", "*");
        },
        set: function (val) {
            this.setPropertyValue("requiredText", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.beforeSettingQuestionErrors = function (question, errors) {
        this.makeRequiredErrorsInvisible(errors);
        this.onSettingQuestionErrors.fire(this, {
            question: question,
            errors: errors,
        });
    };
    SurveyModel.prototype.beforeSettingPanelErrors = function (question, errors) {
        this.makeRequiredErrorsInvisible(errors);
    };
    SurveyModel.prototype.makeRequiredErrorsInvisible = function (errors) {
        if (!this.hideRequiredErrors)
            return;
        for (var i = 0; i < errors.length; i++) {
            var erType = errors[i].getErrorType();
            if (erType == "required" || erType == "requireoneanswer") {
                errors[i].visible = false;
            }
        }
    };
    Object.defineProperty(SurveyModel.prototype, "questionStartIndex", {
        /**
         * Specifies the initial number or letter from which to start question numbering.
         *
         * [Question Numbers](https://surveyjs.io/form-library/documentation/design-survey/configure-question-titles#question-numbers (linkStyle))
         */
        get: function () {
            return this.getPropertyValue("questionStartIndex", "");
        },
        set: function (val) {
            this.setPropertyValue("questionStartIndex", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "storeOthersAsComment", {
        /**
         * Specifies whether to store the "Other" option response in a separate property.
         *
         * Default value: `true`
         *
         * Respondents can leave comments when they select "Other" in choice-based questions, such as Dropdown or Checkboxes. Comment values are saved in a separate property. The property name is composed of the question `name` and [`commentSuffix`](#commentSuffix). However, you can use the question `name` as a key to store the comment value instead. Disable the `storeOthersAsComment` property in this case.
         * @see maxOthersLength
         */
        get: function () {
            return this.getPropertyValue("storeOthersAsComment");
        },
        set: function (val) {
            this.setPropertyValue("storeOthersAsComment", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "maxTextLength", {
        /**
         * Specifies the maximum text length in textual questions ([Single-Line Input](https://surveyjs.io/form-library/examples/text-entry-question/), [Long Text](https://surveyjs.io/form-library/examples/add-open-ended-question-to-a-form/), [Multiple Textboxes](https://surveyjs.io/form-library/examples/multiple-text-box-question/)), measured in characters.
         *
         * Default value: 0 (unlimited)
         *
         * You can override this setting for individual questions if you specify their [`maxLength`](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model#maxLength) property.
         * @see maxOthersLength
         */
        get: function () {
            return this.getPropertyValue("maxTextLength");
        },
        set: function (val) {
            this.setPropertyValue("maxTextLength", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "maxOthersLength", {
        /**
         * Specifies the maximum text length for question comments. Applies to questions with the [`showCommentArea`](https://surveyjs.io/form-library/documentation/api-reference/question#showCommentArea) or [`showOtherItem`](https://surveyjs.io/form-library/documentation/api-reference/question#showOtherItem) property set to `true`.
         *
         * Default value: 0 (unlimited)
         * @see maxTextLength
         */
        get: function () {
            return this.getPropertyValue("maxOthersLength");
        },
        set: function (val) {
            this.setPropertyValue("maxOthersLength", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "goNextPageAutomatic", {
        /**
         * Specifies whether the survey switches to the next page automatically after a user answers all questions on the current page.
         *
         * Default value: `false`
         *
         * If you enable this property, the survey is also completed automatically. Set the [`allowCompleteSurveyAutomatic`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#allowCompleteSurveyAutomatic) property to `false` if you want to disable this behavior.
         *
         * > If any of the following questions is answered last, the survey does not switch to the next page: Checkboxes, Yes/No (Boolean) (rendered as Checkbox), Long Text, Signature, Image Picker (with Multi Select), File Upload, Single-Select Matrix (not all rows are answered), Dynamic Matrix, Dynamic Panel.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/automatically-move-to-next-page-if-answer-selected/ (linkStyle))
         * @see [`settings.autoAdvanceDelay`](https://surveyjs.io/form-library/documentation/api-reference/settings#autoAdvanceDelay)
         */
        get: function () {
            return this.getPropertyValue("goNextPageAutomatic");
        },
        set: function (val) {
            this.setPropertyValue("goNextPageAutomatic", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "allowCompleteSurveyAutomatic", {
        /**
         * Specifies whether to complete the survey automatically after a user answers all questions on the last page. Applies only if the [`goNextPageAutomatic`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#goNextPageAutomatic) property is `true`.
         *
         * Default value: `true`
         * @see [`settings.autoAdvanceDelay`](https://surveyjs.io/form-library/documentation/api-reference/settings#autoAdvanceDelay)
         */
        get: function () {
            return this.getPropertyValue("allowCompleteSurveyAutomatic");
        },
        set: function (val) {
            this.setPropertyValue("allowCompleteSurveyAutomatic", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "checkErrorsMode", {
        /**
         * Specifies when the survey validates answers.
         *
         * Possible values:
         *
         * - `"onNextPage"` (default) - Triggers validation before the survey is switched to the next page or completed.
         * - `"onValueChanged"` - Triggers validation each time a question value is changed.
         * - `"onComplete"` - Triggers validation when a user clicks the Complete button. If previous pages contain errors, the survey switches to the page with the first error.
         *
         * > The `"onValueChanged"` doesn't work with date input fields because of the way browsers process date values. In most browsers, the value is considered changed as soon as a user starts entering the date in a text input field. This means that a user may only enter the day without having the chance to enter the month and year before validation is triggered. For this reason, date input fields are validated before the survey is switched to the next page or completed.
         *
         * Refer to the following help topic for more information: [Data Validation](https://surveyjs.io/form-library/documentation/data-validation).
         * @see validationEnabled
         * @see validationAllowSwitchPages
         * @see validationAllowComplete
         * @see validate
         */
        get: function () {
            return this.getPropertyValue("checkErrorsMode");
        },
        set: function (val) {
            this.setPropertyValue("checkErrorsMode", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "validateVisitedEmptyFields", {
        /**
         * Specifies whether to trigger validation when a user focuses on an empty input field and then leaves it without making any changes. Applies only if [`checkErrorsMode`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#checkErrorsMode) is set to `"onValueChanged"`.
         *
         * Default value: `false`
         *
         * This property changes validation behavior for the following question types:
         *
         * - [Single-Line Input](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model)
         * - [Long Text](https://surveyjs.io/form-library/documentation/api-reference/comment-field-model)
         * - [Dropdown](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model)
         * @see validationEnabled
         * @see validationAllowSwitchPages
         * @see validationAllowComplete
         * @see validate
         */
        get: function () {
            return this.getPropertyValue("validateVisitedEmptyFields");
        },
        set: function (val) {
            this.setPropertyValue("validateVisitedEmptyFields", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.getValidateVisitedEmptyFields = function () { return this.validateVisitedEmptyFields && this.isValidateOnValueChange; };
    Object.defineProperty(SurveyModel.prototype, "autoGrowComment", {
        /**
         * Specifies whether to increase the height of [Long Text](https://surveyjs.io/form-library/examples/add-open-ended-question-to-a-form/) questions and other text areas to accommodate multi-line text content.
         *
         * Default value: `false`
         *
         * You can override this property for individual Long Text questions: [`autoGrow`](https://surveyjs.io/form-library/documentation/api-reference/comment-field-model#autoGrow).
         * @see allowResizeComment
         * @see commentAreaRows
         */
        get: function () {
            return this.getPropertyValue("autoGrowComment");
        },
        set: function (val) {
            this.setPropertyValue("autoGrowComment", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "allowResizeComment", {
        /**
         * Specifies whether to display a resize handle for [Long Text](https://surveyjs.io/form-library/examples/add-open-ended-question-to-a-form/) questions and other text areas intended for multi-line text content.
         *
         * Default value: `true`
         *
         * You can override this property for individual Long Text questions: [`allowResize`](https://surveyjs.io/form-library/documentation/api-reference/comment-field-model#allowResize).
         * @see autoGrowComment
         * @see commentAreaRows
         */
        get: function () {
            return this.getPropertyValue("allowResizeComment");
        },
        set: function (val) {
            this.setPropertyValue("allowResizeComment", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "commentAreaRows", {
        /**
         * Specifies the visible height of comment areas, measured in lines. Applies to the questions with the [`showCommentArea`](https://surveyjs.io/form-library/documentation/api-reference/question#showCommentArea) or [`showOtherItem`](https://surveyjs.io/form-library/documentation/api-reference/question#showOtherItem) property enabled.
         *
         * Default value: 2
         *
         * The value of this property is passed on to the `rows` attribute of the underlying `<textarea>` element.
         * @see autoGrowComment
         * @see allowResizeComment
         */
        get: function () {
            return this.getPropertyValue("commentAreaRows");
        },
        set: function (val) {
            this.setPropertyValue("commentAreaRows", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "textUpdateMode", {
        /**
         * Specifies when to update the question value in questions with a text input field.
         *
         * Possible values:
         *
         * - `"onBlur"` (default) - Updates the value after the input field loses focus.
         * - `"onTyping"` - Updates the value on every key press.
         *
         * > Do not use the `"onTyping"` mode if your survey contains many expressions. Expressions are reevaluated each time a question value is changed. In `"onTyping"` mode, the question value changes frequently. This may cause performance degradation.
         *
         * You can override this setting for individual questions: [`textUpdateMode`](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model#textUpdateMode).
         */
        get: function () {
            return this.getPropertyValue("textUpdateMode");
        },
        set: function (val) {
            this.setPropertyValue("textUpdateMode", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "clearInvisibleValues", {
        /**
         * Specifies when to remove values of invisible questions from [survey results](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#data).
         *
         * Possible values:
         *
         * - `"onComplete"` (default) - Clears invisible question values when the survey is complete.
         * - `"onHidden"` - Clears a question value when the question becomes invisible. If the question is invisible initially, its value is removed on survey completion.
         * - `"onHiddenContainer"` - Clears a question value when the question or its containter (page or panel) becomes invisible. If the question is invisible initially, its value is removed on survey completion.
         * - `"none"` - Keeps invisible values in survey results.
         * - `true` - Equivalent to `"onComplete"`.
         * - `false` - Equivalent to `"none"`.
         * @see [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#conditional-visibility)
         * @see onComplete
         */
        get: function () {
            return this.getPropertyValue("clearInvisibleValues");
        },
        set: function (val) {
            if (val === true)
                val = "onComplete";
            if (val === false)
                val = "none";
            this.setPropertyValue("clearInvisibleValues", val);
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Removes values that cannot be assigned to a question, for example, choices unlisted in the `choices` array.
     *
     * Call this method after you assign new question values in code to ensure that they are acceptable.
     *
     * > This method does not remove values that fail validation. Call the [`validate()`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#validate) method to validate newly assigned values.
     * @param removeNonExistingRootKeys Pass `true` to remove values that do not correspond to any question or [calculated value](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#calculated-values).
     */
    SurveyModel.prototype.clearIncorrectValues = function (removeNonExistingRootKeys) {
        if (removeNonExistingRootKeys === void 0) { removeNonExistingRootKeys = false; }
        for (var i = 0; i < this.pages.length; i++) {
            this.pages[i].clearIncorrectValues();
        }
        if (!removeNonExistingRootKeys)
            return;
        var data = this.data;
        var hasChanges = false;
        for (var key in data) {
            if (!!this.getQuestionByValueName(key))
                continue;
            if (this.iscorrectValueWithPostPrefix(key, settings.commentSuffix) ||
                this.iscorrectValueWithPostPrefix(key, settings.matrix.totalsSuffix))
                continue;
            var calcValue = this.getCalculatedValueByName(key);
            if (!!calcValue && calcValue.includeIntoResult)
                continue;
            hasChanges = true;
            delete data[key];
        }
        if (hasChanges) {
            this.data = data;
        }
    };
    SurveyModel.prototype.iscorrectValueWithPostPrefix = function (key, postPrefix) {
        if (key.indexOf(postPrefix) !== key.length - postPrefix.length)
            return false;
        return !!this.getQuestionByValueName(key.substring(0, key.indexOf(postPrefix)));
    };
    Object.defineProperty(SurveyModel.prototype, "keepIncorrectValues", {
        /**
         * Specifies whether to keep values that cannot be assigned to questions, for example, choices unlisted in the `choices` array.
         *
         * > This property cannot be specified in the survey JSON schema. Use dot notation to specify it.
         * @see clearIncorrectValues
         */
        get: function () {
            return this.getPropertyValue("keepIncorrectValues");
        },
        set: function (val) {
            this.setPropertyValue("keepIncorrectValues", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "locale", {
        /**
         * Specifies the survey's locale.
         *
         * Default value: `""` (a default locale is used)
         *
         * [Localization & Globalization help topic](https://surveyjs.io/form-library/documentation/survey-localization (linkStyle))
         *
         * [Survey Localization demo](https://surveyjs.io/form-library/examples/survey-localization/ (linkStyle))
         */
        get: function () {
            return this.getPropertyValueWithoutDefault("locale") || surveyLocalization.currentLocale;
        },
        set: function (value) {
            if (value === surveyLocalization.defaultLocale && !surveyLocalization.currentLocale) {
                value = "";
            }
            this.setPropertyValue("locale", value);
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.onSurveyLocaleChanged = function () {
        this.notifyElementsOnAnyValueOrVariableChanged("locale");
        this.localeChanged();
        this.onLocaleChangedEvent.fire(this, this.locale);
    };
    Object.defineProperty(SurveyModel.prototype, "localeDir", {
        get: function () {
            return surveyLocalization.localeDirections[this.locale];
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Returns an array of locales whose translations are used in the survey.
     *
     * [Localization & Globalization help topic](https://surveyjs.io/form-library/documentation/survey-localization (linkStyle))
     *
     * [Survey Localization demo](https://surveyjs.io/form-library/examples/survey-localization/ (linkStyle))
     */
    SurveyModel.prototype.getUsedLocales = function () {
        var locs = new Array();
        this.addUsedLocales(locs);
        //Replace the default locale with the real one
        var index = locs.indexOf("default");
        if (index > -1) {
            var defaultLoc = surveyLocalization.defaultLocale;
            //Remove the defaultLoc
            var defIndex = locs.indexOf(defaultLoc);
            if (defIndex > -1) {
                locs.splice(defIndex, 1);
            }
            index = locs.indexOf("default");
            locs[index] = defaultLoc;
        }
        return locs;
    };
    SurveyModel.prototype.localeChanged = function () {
        for (var i = 0; i < this.pages.length; i++) {
            this.pages[i].localeChanged();
        }
    };
    //ILocalizableOwner
    SurveyModel.prototype.getLocale = function () {
        return this.locale;
    };
    SurveyModel.prototype.locStrsChanged = function () {
        if (this.isClearingUnsedValues)
            return;
        _super.prototype.locStrsChanged.call(this);
        if (!this.currentPage)
            return;
        if (this.isDesignMode) {
            this.pages.forEach(function (page) { return page.locStrsChanged(); });
        }
        else {
            var page = this.activePage;
            if (!!page) {
                page.locStrsChanged();
            }
            var visPages = this.visiblePages;
            for (var i = 0; i < visPages.length; i++) {
                visPages[i].navigationLocStrChanged();
            }
        }
        if (!this.isShowStartingPage) {
            this.updateProgressText();
        }
        this.navigationBar.locStrsChanged();
    };
    SurveyModel.prototype.getMarkdownHtml = function (text, name) {
        return this.getSurveyMarkdownHtml(this, text, name);
    };
    SurveyModel.prototype.getRenderer = function (name) {
        return this.getRendererForString(this, name);
    };
    SurveyModel.prototype.getRendererContext = function (locStr) {
        return this.getRendererContextForString(this, locStr);
    };
    SurveyModel.prototype.getRendererForString = function (element, name) {
        var renderAs = this.getBuiltInRendererForString(element, name);
        renderAs = this.elementWrapperComponentNameCore(renderAs, element, "string", name);
        var options = { element: element, name: name, renderAs: renderAs };
        this.onTextRenderAs.fire(this, options);
        return options.renderAs;
    };
    SurveyModel.prototype.getRendererContextForString = function (element, locStr) {
        return this.elementWrapperDataCore(locStr, element, "string");
    };
    SurveyModel.prototype.getExpressionDisplayValue = function (question, value, displayValue) {
        var options = {
            question: question,
            value: value,
            displayValue: displayValue,
        };
        this.onGetExpressionDisplayValue.fire(this, options);
        return options.displayValue;
    };
    SurveyModel.prototype.getBuiltInRendererForString = function (element, name) {
        if (this.isDesignMode)
            return localizablestring_LocalizableString.editableRenderer;
        return undefined;
    };
    SurveyModel.prototype.getProcessedText = function (text) {
        return this.processText(text, true);
    };
    SurveyModel.prototype.getLocString = function (str) {
        return this.getLocalizationString(str);
    };
    //ISurveyErrorOwner
    SurveyModel.prototype.getErrorCustomText = function (text, error) {
        return this.getSurveyErrorCustomText(this, text, error);
    };
    SurveyModel.prototype.getSurveyErrorCustomText = function (obj, text, error) {
        var options = {
            text: text,
            name: error.getErrorType(),
            obj: obj,
            error: error
        };
        this.onErrorCustomText.fire(this, options);
        return options.text;
    };
    SurveyModel.prototype.getQuestionDisplayValue = function (question, displayValue) {
        var options = { question: question, displayValue: displayValue };
        this.onGetQuestionDisplayValue.fire(this, options);
        return options.displayValue;
    };
    Object.defineProperty(SurveyModel.prototype, "emptySurveyText", {
        /**
         * A message that is displayed when a survey does not contain visible pages or questions.
         * @see [Localization & Globalization](https://surveyjs.io/form-library/documentation/survey-localization)
         */
        get: function () {
            return this.getLocalizableStringText("emptySurveyText");
        },
        set: function (val) {
            this.setLocalizableStringText("emptySurveyText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "logo", {
        //#region Title/Header options
        /**
         * An image URL or a Base64-encoded image to use as a survey logo.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/survey-logo/ (linkStyle))
         * @see logoPosition
         * @see logoFit
         */
        get: function () {
            return this.getLocalizableStringText("logo");
        },
        set: function (value) {
            this.setLocalizableStringText("logo", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "locLogo", {
        get: function () {
            return this.getLocalizableString("logo");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "logoWidth", {
        /**
         * A logo width in CSS-accepted values.
         *
         * Default value: `300px`
         *
         * [View Demo](https://surveyjs.io/form-library/examples/survey-logo/ (linkStyle))
         * @see logoHeight
         * @see logo
         * @see logoPosition
         * @see logoFit
         */
        get: function () {
            return this.getPropertyValue("logoWidth");
        },
        set: function (value) {
            this.setPropertyValue("logoWidth", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "renderedLogoWidth", {
        get: function () {
            return this.logoWidth ? getRenderedSize(this.logoWidth) : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "renderedStyleLogoWidth", {
        get: function () {
            return this.logoWidth ? getRenderedStyleSize(this.logoWidth) : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "logoHeight", {
        /**
         * A logo height in CSS-accepted values.
         *
         * Default value: `200px`
         *
         * [View Demo](https://surveyjs.io/form-library/examples/survey-logo/ (linkStyle))
         * @see logoHeight
         * @see logo
         * @see logoPosition
         * @see logoFit
         */
        get: function () {
            return this.getPropertyValue("logoHeight");
        },
        set: function (value) {
            this.setPropertyValue("logoHeight", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "renderedLogoHeight", {
        get: function () {
            return this.logoHeight ? getRenderedSize(this.logoHeight) : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "renderedStyleLogoHeight", {
        get: function () {
            return this.logoHeight ? getRenderedStyleSize(this.logoHeight) : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "logoPosition", {
        /**
         * A logo position relative to the [survey title](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#title).
         *
         * Possible values:
         *
         * - `"left"` (default) - Places the logo to the left of the survey title.
         * - `"right"` - Places the logo to the right of the survey title.
         * - `"none"` - Hides the logo.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/survey-logo/ (linkStyle))
         * @see logo
         * @see logoFit
         */
        get: function () {
            return this.getPropertyValue("logoPosition");
        },
        set: function (value) {
            this.setPropertyValue("logoPosition", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "hasLogo", {
        get: function () {
            return this.getPropertyValue("hasLogo", false);
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.updateHasLogo = function () {
        this.setPropertyValue("hasLogo", !!this.logo && this.logoPosition !== "none");
    };
    Object.defineProperty(SurveyModel.prototype, "isLogoBefore", {
        get: function () {
            if (this.isDesignMode)
                return false;
            return (this.renderedHasLogo &&
                (this.logoPosition === "left" || this.logoPosition === "top"));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isLogoAfter", {
        get: function () {
            if (this.isDesignMode)
                return this.renderedHasLogo;
            return (this.renderedHasLogo &&
                (this.logoPosition === "right" || this.logoPosition === "bottom"));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "logoClassNames", {
        get: function () {
            var logoClasses = {
                left: "sv-logo--left",
                right: "sv-logo--right",
                top: "sv-logo--top",
                bottom: "sv-logo--bottom",
            };
            return new CssClassBuilder().append(this.css.logo)
                .append(logoClasses[this.logoPosition]).toString();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "renderedHasTitle", {
        get: function () {
            if (this.isDesignMode)
                return this.isPropertyVisible("title");
            return !this.titleIsEmpty && this.showTitle;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "renderedHasDescription", {
        get: function () {
            if (this.isDesignMode)
                return this.isPropertyVisible("description");
            return !!this.hasDescription;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "hasTitle", {
        get: function () {
            return this.renderedHasTitle;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "renderedHasLogo", {
        get: function () {
            if (this.isDesignMode)
                return this.isPropertyVisible("logo");
            return this.hasLogo;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "renderedHasHeader", {
        get: function () {
            return this.renderedHasTitle || this.renderedHasLogo;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "logoFit", {
        /**
         * Specifies how to resize a logo to fit it into its container.
         *
         * Possible values:
         *
         * - `"contain"` (default)
         * - `"cover"`
         * - `"fill"`
         * - `"none"`
         *
         * Refer to the [`object-fit`](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) CSS property description for information on the possible values.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/survey-logo/ (linkStyle))
         * @see logo
         * @see logoPosition
         */
        get: function () {
            return this.getPropertyValue("logoFit");
        },
        set: function (val) {
            this.setPropertyValue("logoFit", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "themeVariables", {
        get: function () {
            return Object.assign({}, this.cssVariables);
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.setIsMobile = function (newVal) {
        if (newVal === void 0) { newVal = true; }
        if (this._isMobile !== newVal) {
            this._isMobile = newVal;
            this.updateCss();
            this.getAllQuestions().forEach(function (q) { return q.setIsMobile(newVal); });
        }
    };
    Object.defineProperty(SurveyModel.prototype, "isMobile", {
        get: function () {
            return this._isMobile && !this.isDesignMode;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isCompact", {
        get: function () {
            return this._isCompact;
        },
        set: function (newVal) {
            if (newVal !== this._isCompact) {
                this._isCompact = newVal;
                this.updateElementCss();
                this.triggerResponsiveness(true);
            }
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.isLogoImageChoosen = function () {
        return this.locLogo.renderedHtml;
    };
    Object.defineProperty(SurveyModel.prototype, "titleMaxWidth", {
        get: function () {
            if (!(isMobile() || this.isMobile) &&
                !this.isValueEmpty(this.isLogoImageChoosen()) &&
                !settings.supportCreatorV2) {
                var logoWidth = this.logoWidth;
                if (this.logoPosition === "left" || this.logoPosition === "right") {
                    return "calc(100% - 5px - 2em - " + logoWidth + ")";
                }
            }
            return "";
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.updateRenderBackgroundImage = function () {
        var path = this.backgroundImage;
        this.renderBackgroundImage = wrapUrlForBackgroundImage(path);
    };
    Object.defineProperty(SurveyModel.prototype, "backgroundOpacity", {
        /**
         * A value from 0 to 1 that specifies how transparent the [background image](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#backgroundImage) should be: 0 makes the image completely transparent, and 1 makes it opaque.
         */
        get: function () {
            return this.getPropertyValue("backgroundOpacity");
        },
        set: function (val) {
            this.setPropertyValue("backgroundOpacity", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.updateBackgroundImageStyle = function () {
        this.backgroundImageStyle = {
            opacity: this.backgroundOpacity,
            backgroundImage: this.renderBackgroundImage,
            backgroundSize: this.backgroundImageFit,
            backgroundAttachment: !this.fitToContainer ? this.backgroundImageAttachment : undefined
        };
    };
    SurveyModel.prototype.updateWrapperFormCss = function () {
        this.wrapperFormCss = new CssClassBuilder()
            .append(this.css.rootWrapper)
            .append(this.css.rootWrapperHasImage, !!this.backgroundImage)
            .append(this.css.rootWrapperFixed, !!this.backgroundImage && this.backgroundImageAttachment === "fixed")
            .toString();
    };
    Object.defineProperty(SurveyModel.prototype, "completedHtml", {
        /**
         * HTML content displayed on the [complete page](https://surveyjs.io/form-library/documentation/design-survey/create-a-multi-page-survey#complete-page).
         *
         * [View Demo](https://surveyjs.io/form-library/examples/modify-survey-navigation-settings/ (linkStyle))
         * @see showCompletedPage
         * @see completedHtmlOnCondition
         */
        get: function () {
            return this.getLocalizableStringText("completedHtml");
        },
        set: function (value) {
            this.setLocalizableStringText("completedHtml", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "locCompletedHtml", {
        get: function () {
            return this.getLocalizableString("completedHtml");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "completedHtmlOnCondition", {
        /**
         * An array of objects that allows you to specify different HTML content for the [complete page](https://surveyjs.io/form-library/documentation/design-survey/create-a-multi-page-survey#complete-page).
         *
         * Each object should include the [`expression`](https://surveyjs.io/form-library/documentation/api-reference/htmlconditionitem#expression) and [`html`](https://surveyjs.io/form-library/documentation/api-reference/htmlconditionitem#html) properties. When `expression` evaluates to `true`, the survey uses the corresponding HTML markup instead of [`completedHtml`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#completedHtml). Refer to the following help topic for more information about expressions: [Expressions](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#expressions).
         *
         * [View Demo](https://surveyjs.io/form-library/examples/nps-question/ (linkStyle))
         */
        get: function () {
            return this.getPropertyValue("completedHtmlOnCondition");
        },
        set: function (val) {
            this.setPropertyValue("completedHtmlOnCondition", val);
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Calculates a given [expression](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#expressions) and returns a result value.
     * @param expression An expression to calculate.
     */
    SurveyModel.prototype.runExpression = function (expression) {
        if (!expression)
            return null;
        var values = this.getFilteredValues();
        var properties = this.getFilteredProperties();
        return new ExpressionRunner(expression).run(values, properties);
    };
    /**
     * Calculates a given [expression](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#expressions) and returns `true` or `false`.
     * @param expression An expression to calculate.
     */
    SurveyModel.prototype.runCondition = function (expression) {
        if (!expression)
            return false;
        var values = this.getFilteredValues();
        var properties = this.getFilteredProperties();
        return new ConditionRunner(expression).run(values, properties);
    };
    /**
     * Executes [all triggers](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#triggers), except ["complete"](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#complete).
     *
     * [Conditional Survey Logic (Triggers)](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#conditional-survey-logic-triggers (linkStyle))
     * @see onTriggerExecuted
     */
    SurveyModel.prototype.runTriggers = function () {
        this.checkTriggers(this.getFilteredValues(), false);
    };
    Object.defineProperty(SurveyModel.prototype, "renderedCompletedHtml", {
        get: function () {
            var item = this.getExpressionItemOnRunCondition(this.completedHtmlOnCondition);
            return !!item ? item.html : this.completedHtml;
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.getExpressionItemOnRunCondition = function (items) {
        if (items.length == 0)
            return null;
        var values = this.getFilteredValues();
        var properties = this.getFilteredProperties();
        for (var i = 0; i < items.length; i++) {
            if (items[i].runCondition(values, properties)) {
                return items[i];
            }
        }
        return null;
    };
    Object.defineProperty(SurveyModel.prototype, "completedBeforeHtml", {
        /**
         * HTML content displayed to a user who has completed the survey before. To identify such users, the survey uses a [cookie name](#cookieName) or [client ID](#clientId).
         * @see processedCompletedBeforeHtml
         */
        get: function () {
            return this.getLocalizableStringText("completedBeforeHtml");
        },
        set: function (value) {
            this.setLocalizableStringText("completedBeforeHtml", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "locCompletedBeforeHtml", {
        get: function () {
            return this.getLocalizableString("completedBeforeHtml");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "loadingHtml", {
        /**
         * HTML content displayed while a survey JSON schema is being loaded from [SurveyJS Service](https://api.surveyjs.io).
         * @see surveyId
         * @see processedLoadingHtml
         */
        get: function () {
            return this.getLocalizableStringText("loadingHtml");
        },
        set: function (value) {
            this.setLocalizableStringText("loadingHtml", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "locLoadingHtml", {
        get: function () {
            return this.getLocalizableString("loadingHtml");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "defaultLoadingHtml", {
        get: function () {
            return "<h3>" + this.getLocalizationString("loadingSurvey") + "</h3>";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "navigationBar", {
        get: function () {
            return this.navigationBarValue;
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Adds a custom navigation item similar to the Previous Page, Next Page, and Complete buttons.
     * Accepts an object described in the [IAction](https://surveyjs.io/Documentation/Library?id=IAction) help section.
     *
     * [View Demo](https://surveyjs.io/form-library/examples/survey-changenavigation/ (linkStyle))
    */
    SurveyModel.prototype.addNavigationItem = function (val) {
        if (!val.component) {
            val.component = "sv-nav-btn";
        }
        if (!val.innerCss) {
            val.innerCss = this.cssSurveyNavigationButton;
        }
        return this.navigationBar.addAction(val);
    };
    Object.defineProperty(SurveyModel.prototype, "startSurveyText", {
        /**
         * Gets or sets a caption for the Start button.
         * @see firstPageIsStarted
         * @see [Localization & Globalization](https://surveyjs.io/form-library/documentation/survey-localization)
         */
        get: function () {
            return this.getLocalizableStringText("startSurveyText");
        },
        set: function (newValue) {
            this.setLocalizableStringText("startSurveyText", newValue);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "locStartSurveyText", {
        get: function () {
            return this.getLocalizableString("startSurveyText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "pagePrevText", {
        /**
         * Gets or sets a caption for the Previous button.
         * @see [Localization & Globalization](https://surveyjs.io/form-library/documentation/survey-localization)
         */
        get: function () {
            return this.getLocalizableStringText("pagePrevText");
        },
        set: function (newValue) {
            this.setLocalizableStringText("pagePrevText", newValue);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "locPagePrevText", {
        get: function () {
            return this.getLocalizableString("pagePrevText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "pageNextText", {
        /**
         * Gets or sets a caption for the Next button.
         * @see [Localization & Globalization](https://surveyjs.io/form-library/documentation/survey-localization)
         */
        get: function () {
            return this.getLocalizableStringText("pageNextText");
        },
        set: function (newValue) {
            this.setLocalizableStringText("pageNextText", newValue);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "locPageNextText", {
        get: function () {
            return this.getLocalizableString("pageNextText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "completeText", {
        /**
         * Gets or sets a caption for the Complete button.
         * @see [Localization & Globalization](https://surveyjs.io/form-library/documentation/survey-localization)
         */
        get: function () {
            return this.getLocalizableStringText("completeText");
        },
        set: function (newValue) {
            this.setLocalizableStringText("completeText", newValue);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "locCompleteText", {
        get: function () {
            return this.getLocalizableString("completeText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "previewText", {
        /**
         * Gets or sets a caption for the Preview button.
         * @see showPreviewBeforeComplete
         * @see showPreview
         * @see editText
         */
        get: function () {
            return this.getLocalizableStringText("previewText");
        },
        set: function (newValue) {
            this.setLocalizableStringText("previewText", newValue);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "locPreviewText", {
        get: function () {
            return this.getLocalizableString("previewText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "editText", {
        /**
         * Gets or sets a caption for the Edit button displayed when the survey shows a [preview of given answers](https://surveyjs.io/form-library/documentation/design-survey/create-a-multi-page-survey#preview-page).
         * @see showPreviewBeforeComplete
         * @see cancelPreview
         * @see previewText
         */
        get: function () {
            return this.getLocalizableStringText("editText");
        },
        set: function (newValue) {
            this.setLocalizableStringText("editText", newValue);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "locEditText", {
        get: function () {
            return this.getLocalizableString("editText");
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.getElementTitleTagName = function (element, tagName) {
        if (this.onGetTitleTagName.isEmpty)
            return tagName;
        var options = { element: element, tagName: tagName };
        this.onGetTitleTagName.fire(this, options);
        return options.tagName;
    };
    Object.defineProperty(SurveyModel.prototype, "questionTitlePattern", {
        /**
         * Specifies a pattern for question titles.
         *
         * Refer to the following help topic for more information: [Title Pattern](https://surveyjs.io/form-library/documentation/design-survey/configure-question-titles#title-pattern).
         */
        get: function () {
            return this.getPropertyValue("questionTitlePattern", "numTitleRequire");
        },
        set: function (val) {
            if (val !== "numRequireTitle" &&
                val !== "requireNumTitle" &&
                val != "numTitle") {
                val = "numTitleRequire";
            }
            this.setPropertyValue("questionTitlePattern", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.getQuestionTitlePatternOptions = function () {
        var res = new Array();
        var title = this.getLocalizationString("questionTitlePatternText");
        var num = !!this.questionStartIndex ? this.questionStartIndex : "1.";
        res.push({
            value: "numTitleRequire",
            text: num + " " + title + " " + this.requiredText
        });
        res.push({
            value: "numRequireTitle",
            text: num + " " + this.requiredText + " " + title
        });
        // res.push({
        //   value: "requireNumTitle",
        //   text: this.requiredText + " " + num + " " + title
        // });
        res.push({
            value: "numTitle",
            text: num + " " + title
        });
        return res;
    };
    Object.defineProperty(SurveyModel.prototype, "questionTitleTemplate", {
        get: function () {
            return this.getLocalizableStringText("questionTitleTemplate");
        },
        set: function (value) {
            this.setLocalizableStringText("questionTitleTemplate", value);
            this.questionTitlePattern = this.getNewTitlePattern(value);
            this.questionStartIndex = this.getNewQuestionTitleElement(value, "no", this.questionStartIndex, "1");
            this.requiredText = this.getNewQuestionTitleElement(value, "require", this.requiredText, "*");
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.getNewTitlePattern = function (template) {
        if (!!template) {
            var strs = [];
            while (template.indexOf("{") > -1) {
                template = template.substring(template.indexOf("{") + 1);
                var ind = template.indexOf("}");
                if (ind < 0)
                    break;
                strs.push(template.substring(0, ind));
                template = template.substring(ind + 1);
            }
            if (strs.length > 1) {
                if (strs[0] == "require")
                    return "requireNumTitle";
                if (strs[1] == "require" && strs.length == 3)
                    return "numRequireTitle";
                if (strs.indexOf("require") < 0)
                    return "numTitle";
            }
            if (strs.length == 1 && strs[0] == "title") {
                return "numTitle";
            }
        }
        return "numTitleRequire";
    };
    SurveyModel.prototype.getNewQuestionTitleElement = function (template, name, currentValue, defaultValue) {
        name = "{" + name + "}";
        if (!template || template.indexOf(name) < 0)
            return currentValue;
        var ind = template.indexOf(name);
        var prefix = "";
        var postfix = "";
        var i = ind - 1;
        for (; i >= 0; i--) {
            if (template[i] == "}")
                break;
        }
        if (i < ind - 1) {
            prefix = template.substring(i + 1, ind);
        }
        ind += name.length;
        i = ind;
        for (; i < template.length; i++) {
            if (template[i] == "{")
                break;
        }
        if (i > ind) {
            postfix = template.substring(ind, i);
        }
        i = 0;
        while (i < prefix.length && prefix.charCodeAt(i) < 33)
            i++;
        prefix = prefix.substring(i);
        i = postfix.length - 1;
        while (i >= 0 && postfix.charCodeAt(i) < 33)
            i--;
        postfix = postfix.substring(0, i + 1);
        if (!prefix && !postfix)
            return currentValue;
        var value = !!currentValue ? currentValue : defaultValue;
        return prefix + value + postfix;
    };
    Object.defineProperty(SurveyModel.prototype, "locQuestionTitleTemplate", {
        get: function () {
            return this.getLocalizableString("questionTitleTemplate");
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.getUpdatedQuestionTitle = function (question, title) {
        if (this.onGetQuestionTitle.isEmpty)
            return title;
        var options = { question: question, title: title };
        this.onGetQuestionTitle.fire(this, options);
        return options.title;
    };
    SurveyModel.prototype.getUpdatedQuestionNo = function (question, no) {
        if (this.onGetQuestionNo.isEmpty)
            return no;
        var options = { question: question, no: no };
        this.onGetQuestionNo.fire(this, options);
        return options.no;
    };
    Object.defineProperty(SurveyModel.prototype, "showPageNumbers", {
        /**
         * Specifies whether page titles contain page numbers.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/how-to-number-pages-and-questions/ (linkStyle))
         */
        get: function () {
            return this.getPropertyValue("showPageNumbers");
        },
        set: function (value) {
            if (value === this.showPageNumbers)
                return;
            this.setPropertyValue("showPageNumbers", value);
            this.updateVisibleIndexes();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "showQuestionNumbers", {
        /**
         * Specifies whether to display question numbers and how to calculate them.
         *
         * Possible values:
         *
         * - `true` or `"on"` - Displays question numbers.
         * - `"onpage"` - Displays question numbers and starts numbering on each page from scratch.
         * - `false` or `"off"` - Hides question numbers.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/how-to-number-pages-and-questions/ (linkStyle))
         *
         * If you want to hide the number of an individual question, enable its [`hideNumber`](https://surveyjs.io/form-library/documentation/api-reference/question#hideNumber) property.
         */
        get: function () {
            return this.getPropertyValue("showQuestionNumbers");
        },
        set: function (value) {
            if (value === true) {
                value = "on";
            }
            if (value === false) {
                value = "off";
            }
            value = value.toLowerCase();
            value = value === "onpage" ? "onPage" : value;
            if (value === this.showQuestionNumbers)
                return;
            this.setPropertyValue("showQuestionNumbers", value);
            this.updateVisibleIndexes();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "progressBar", {
        get: function () {
            return this.progressBarValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "showProgressBar", {
        /**
         * Controls the visibility of the progress bar and specifies its position.
         *
         * Possible values:
         *
         * - `"off"` (default) - Hides the progress bar.
         * - `"aboveHeader"` - Displays the progress bar above the survey header.
         * - `"belowHeader"` - Displays the progress bar below the survey header.
         * - `"bottom"` - Displays the progress bar below survey content.
         * - `"topBottom"` - Displays the progress bar above and below survey content.
         * - `"auto"` - Displays the progress bar below the survey header if the header has a [background image](https://surveyjs.io/form-library/documentation/api-reference/iheader#backgroundImage) or color. Otherwise, the progress bar is displayed above the header.
         * - `"top"` - *(Obsolete)* Use the `"aboveHeader"` or `"belowHeader"` property value instead.
         * - `"both"` - *(Obsolete)* Use the `"topBottom"` property value instead.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/navigation-default/ (linkStyle))
         * @see progressBarType
         * @see progressValue
         */
        get: function () {
            return this.getPropertyValue("showProgressBar");
        },
        set: function (newValue) {
            this.setPropertyValue("showProgressBar", newValue.toLowerCase());
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "progressBarType", {
        /**
         * Specifies the type of information displayed by the progress bar. Applies only when [`showProgressBar`](#showProgressBar) is not `"off"`.
         *
         * Possible values:
         *
         * - `"pages"` (default) - The number of completed pages.
         * - `"questions"` - The number of answered questions.
         * - `"requiredQuestions"` - The number of answered [required questions](https://surveyjs.io/form-library/documentation/api-reference/question#isRequired).
         * - `"correctQuestions"` - The number of correct questions in a [quiz](https://surveyjs.io/form-library/documentation/design-survey/create-a-quiz).
         * - `"buttons"` - *(Obsolete)* Use the `"pages"` property value with the [`progressBarShowPageTitles`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#progressBarShowPageTitles) property set to `true` instead.
         *
         * > When `progressBarType` is set to `"pages"`, you can also enable the [`progressBarShowPageNumbers`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#progressBarShowPageNumbers) and [`progressBarShowPageTitles`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#progressBarShowPageTitles) properties if you want to display page numbers and titles in the progress bar.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/navigation-buttons/ (linkStyle))
         * @see progressValue
         */
        get: function () {
            return this.getPropertyValue("progressBarType");
        },
        set: function (newValue) {
            if (newValue === "correctquestion")
                newValue = "correctQuestion";
            if (newValue === "requiredquestion")
                newValue = "requiredQuestion";
            // if (newValue === "buttons") {
            //   newValue = "pages";
            //   this.progressBarShowPageTitles = true;
            // }
            this.setPropertyValue("progressBarType", newValue);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "progressBarComponentName", {
        get: function () {
            var actualProgressBarType = this.progressBarType;
            if (!settings.legacyProgressBarView && surveyCss.currentType === "defaultV2") {
                if (isStrCiEqual(actualProgressBarType, "pages")) {
                    actualProgressBarType = "buttons";
                }
            }
            return "progress-" + actualProgressBarType;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isShowProgressBarOnTop", {
        get: function () {
            if (!this.canShowProresBar())
                return false;
            return ["auto", "aboveheader", "belowheader", "topbottom", "top", "both"].indexOf(this.showProgressBar) !== -1;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isShowProgressBarOnBottom", {
        get: function () {
            if (!this.canShowProresBar())
                return false;
            return this.showProgressBar === "bottom" || this.showProgressBar === "both" || this.showProgressBar === "topbottom";
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.getProgressTypeComponent = function () {
        return "sv-progress-" + this.progressBarType.toLowerCase();
    };
    SurveyModel.prototype.getProgressCssClasses = function (container) {
        if (container === void 0) { container = ""; }
        return new CssClassBuilder()
            .append(this.css.progress)
            .append(this.css.progressTop, this.isShowProgressBarOnTop && (!container || container == "header"))
            .append(this.css.progressBottom, this.isShowProgressBarOnBottom && (!container || container == "footer"))
            .toString();
    };
    SurveyModel.prototype.canShowProresBar = function () {
        return (!this.isShowingPreview ||
            this.showPreviewBeforeComplete != "showAllQuestions");
    };
    Object.defineProperty(SurveyModel.prototype, "processedTitle", {
        get: function () {
            return this.locTitle.renderedHtml;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "questionTitleLocation", {
        /**
         * Gets or sets question title location relative to the input field: `"top"`, `"bottom"`, or `"left"`.
         *
         * > Certain question types (Matrix, Multiple Text) do not support the `"left"` value. For them, the `"top"` value is used.
         *
         * You can override this setting if you specify the `questionTitleLocation` property for an [individual page](https://surveyjs.io/form-library/documentation/pagemodel#questionTitleLocation) or [panel](https://surveyjs.io/form-library/documentation/panelmodel#questionTitleLocation) or set the `titleLocation` property for a [specific question](https://surveyjs.io/form-library/documentation/question#titleLocation).
         */
        get: function () {
            return this.getPropertyValue("questionTitleLocation");
        },
        set: function (value) {
            this.setPropertyValue("questionTitleLocation", value.toLowerCase());
            if (!this.isLoadingFromJson) {
                this.updateElementCss(true);
            }
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.updateElementCss = function (reNew) {
        if (!!this.startedPage) {
            this.startedPage.updateElementCss(reNew);
        }
        var pages = this.visiblePages;
        for (var i = 0; i < pages.length; i++) {
            pages[i].updateElementCss(reNew);
        }
        this.updateCss();
    };
    Object.defineProperty(SurveyModel.prototype, "questionErrorLocation", {
        /**
         * Specifies the error message position.
         *
         * Possible values:
         *
         * - `"top"` (default) - Displays error messages above questions.
         * - `"bottom"` - Displays error messages below questions.
         *
         * You can override this setting if you specify the `questionErrorLocation` property for an [individual page](https://surveyjs.io/form-library/documentation/pagemodel#questionErrorLocation) or [panel](https://surveyjs.io/form-library/documentation/panelmodel#questionErrorLocation) or set the `errorLocation` property for a [specific question](https://surveyjs.io/form-library/documentation/question#errorLocation).
         */
        get: function () {
            return this.getPropertyValue("questionErrorLocation");
        },
        set: function (value) {
            this.setPropertyValue("questionErrorLocation", value.toLowerCase());
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "questionDescriptionLocation", {
        /**
         * Specifies where to display question descriptions.
         *
         * Possible values:
         *
         * - `"underTitle"` (default) - Displays descriptions under question titles.
         * - `"underInput"` - Displays descriptions under the interactive area.
         *
         * You can override this setting for individual questions if you specify their [`descriptionLocation`](https://surveyjs.io/form-library/documentation/api-reference/question#descriptionLocation) property.
         *
         */
        get: function () {
            return this.getPropertyValue("questionDescriptionLocation");
        },
        set: function (value) {
            this.setPropertyValue("questionDescriptionLocation", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "mode", {
        /**
         * Specifies whether users can take the survey or only view it.
         *
         * Possible values:
         *
         * - `"edit"` (default) - Allows users to take the survey.
         * - `"display"` - Makes the survey read-only.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/survey-displaymode/ (linkStyle))
         */
        get: function () {
            return this.getPropertyValue("mode");
        },
        set: function (value) {
            value = value.toLowerCase();
            if (value == this.mode)
                return;
            if (value != "edit" && value != "display")
                return;
            this.setPropertyValue("mode", value);
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.onModeChanged = function () {
        for (var i = 0; i < this.pages.length; i++) {
            var page = this.pages[i];
            page.setPropertyValue("isReadOnly", page.isReadOnly);
        }
        this.updateButtonsVisibility();
        this.updateCss();
    };
    Object.defineProperty(SurveyModel.prototype, "data", {
        /**
         * Gets or sets an object with survey results. You can set this property with an object of the following structure:
         *
         * ```js
         * {
         *   question1Name: question1Value,
         *   question2Name: question2Value,
         *   // ...
         * }
         * ```
         *
         * When you set this property in code, the new object overrides the old object that may contain default question values and entered data. If you want to *merge* the new and old objects, call the [`mergeData(newDataObj)`](https://surveyjs.io/form-library/documentation/surveymodel#mergeData) method.
         *
         * If you assign a new object while a respondent takes the survey, set the [`currentPageNo`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#currentPageNo) property to 0 to start the survey from the beginning. This will also cause the survey to re-evaluate the [`visibleIf`](https://surveyjs.io/form-library/documentation/api-reference/question#visibleIf), [`enableIf`](https://surveyjs.io/form-library/documentation/api-reference/question#enableIf), and other [expressions](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#expressions).
         * @see setValue
         * @see getValue
         */
        get: function () {
            var result = {};
            var keys = this.getValuesKeys();
            for (var i = 0; i < keys.length; i++) {
                var key = keys[i];
                var dataValue = this.getDataValueCore(this.valuesHash, key);
                if (dataValue !== undefined) {
                    result[key] = dataValue;
                }
            }
            this.setCalculatedValuesIntoResult(result);
            return result;
        },
        set: function (data) {
            this.valuesHash = {};
            this.setDataCore(data, !data);
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Merges a specified data object with the object from the [`data`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#data) property.
     *
     * Refer to the following help topic for more information: [Populate Form Fields | Multiple Question Values](https://surveyjs.io/form-library/documentation/design-survey/pre-populate-form-fields#multiple-question-values).
     *
     * @param data A data object to merge. It should have the following structure: `{ questionName: questionValue, ... }`
     * @see setValue
     */
    SurveyModel.prototype.mergeData = function (data) {
        if (!data)
            return;
        var newData = this.data;
        this.mergeValues(data, newData);
        this.setDataCore(newData);
    };
    SurveyModel.prototype.setDataCore = function (data, clearData) {
        if (clearData === void 0) { clearData = false; }
        if (clearData) {
            this.valuesHash = {};
        }
        if (data) {
            for (var key in data) {
                var dataKey = typeof key === "string" ? key.trim() : key;
                this.setDataValueCore(this.valuesHash, dataKey, data[key]);
            }
        }
        this.updateAllQuestionsValue(clearData);
        this.notifyAllQuestionsOnValueChanged();
        this.notifyElementsOnAnyValueOrVariableChanged("");
        this.runConditions();
        this.updateAllQuestionsValue(clearData);
    };
    Object.defineProperty(SurveyModel.prototype, "isSurvey", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    /**
     * Returns an object with survey results.
     *
     * If you want to get a survey results object that mirrors the survey structure, call the `getData()` method with an object that has the `includePages` and `includePanels` properties enabled. Without this object, the `getData()` method returns the [`data`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#data) property value.
     *
     * ```js
     * import { Model } from "survey-core";
     *
     * const surveyJson = { ... };
     * const survey = new Model(surveyJson);
     * survey.getData({ includePages: true, includePanels: true });
     * ```
     */
    SurveyModel.prototype.getData = function (options) {
        var opt = options || { includePages: false, includePanels: false };
        if (!opt.includePages && !opt.includePanels)
            return this.data;
        return this.getStructuredData(!!opt.includePages, !opt.includePanels ? (opt.includePages ? 1 : 0) : -1);
    };
    SurveyModel.prototype.getStructuredData = function (includePages, level) {
        if (includePages === void 0) { includePages = true; }
        if (level === void 0) { level = -1; }
        if (level === 0)
            return this.data;
        var data = {};
        this.pages.forEach(function (p) {
            if (includePages) {
                var pageValues = {};
                if (p.collectValues(pageValues, level - 1)) {
                    data[p.name] = pageValues;
                }
            }
            else {
                p.collectValues(data, level);
            }
        });
        return data;
    };
    SurveyModel.prototype.setStructuredData = function (data, doMerge) {
        if (doMerge === void 0) { doMerge = false; }
        if (!data)
            return;
        var res = {};
        for (var key in data) {
            var q = this.getQuestionByValueName(key);
            if (q) {
                res[key] = data[key];
            }
            else {
                var panel = this.getPageByName(key);
                if (!panel) {
                    panel = this.getPanelByName(key);
                }
                if (panel) {
                    this.collectDataFromPanel(panel, res, data[key]);
                }
            }
        }
        if (doMerge) {
            this.mergeData(res);
        }
        else {
            this.data = res;
        }
    };
    SurveyModel.prototype.collectDataFromPanel = function (panel, output, data) {
        for (var key in data) {
            var el = panel.getElementByName(key);
            if (!el)
                continue;
            if (el.isPanel) {
                this.collectDataFromPanel(el, output, data[key]);
            }
            else {
                output[key] = data[key];
            }
        }
    };
    Object.defineProperty(SurveyModel.prototype, "editingObj", {
        get: function () {
            return this.editingObjValue;
        },
        set: function (val) {
            var _this = this;
            if (this.editingObj == val)
                return;
            this.unConnectEditingObj();
            this.editingObjValue = val;
            if (this.isDisposed)
                return;
            if (!val) {
                var questions = this.getAllQuestions();
                for (var i = 0; i < questions.length; i++) {
                    questions[i].unbindValue();
                }
            }
            if (!!this.editingObj) {
                this.setDataCore({});
                this.onEditingObjPropertyChanged = function (sender, options) {
                    if (!Serializer.hasOriginalProperty(_this.editingObj, options.name))
                        return;
                    if (options.name === "locale") {
                        _this.setDataCore({});
                    }
                    _this.updateOnSetValue(options.name, _this.editingObj[options.name], options.oldValue);
                };
                this.editingObj.onPropertyChanged.add(this.onEditingObjPropertyChanged);
            }
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.unConnectEditingObj = function () {
        if (!!this.editingObj && !this.editingObj.isDisposed) {
            this.editingObj.onPropertyChanged.remove(this.onEditingObjPropertyChanged);
        }
    };
    Object.defineProperty(SurveyModel.prototype, "isEditingSurveyElement", {
        get: function () {
            return !!this.editingObj;
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.setCalculatedValuesIntoResult = function (result) {
        for (var i = 0; i < this.calculatedValues.length; i++) {
            var calValue = this.calculatedValues[i];
            if (calValue.includeIntoResult &&
                !!calValue.name &&
                this.getVariable(calValue.name) !== undefined) {
                result[calValue.name] = this.getVariable(calValue.name);
            }
        }
    };
    SurveyModel.prototype.getAllValues = function () {
        return this.data;
    };
    /**
     * Returns survey results as an array of objects in which the question name, title, value, and other parameters are stored as individual properties.
     *
     * If a question can have more than one value (Matrix, Multiple Text), its object enables the `isNode` flag and stores information about these values in the `data` property. Refer to the following help topic for more information: [Access Full Survey Results](https://surveyjs.io/form-library/documentation/handle-survey-results-access#access-full-survey-results).
     *
     * If you want to skip empty answers, pass an object with the `includeEmpty` property set to `false`.
     */
    SurveyModel.prototype.getPlainData = function (options) {
        if (!options) {
            options = { includeEmpty: true, includeQuestionTypes: false, includeValues: false };
        }
        var result = [];
        var questionValueNames = [];
        this.getAllQuestions().forEach(function (question) {
            var resultItem = question.getPlainData(options);
            if (!!resultItem) {
                result.push(resultItem);
                questionValueNames.push(question.valueName || question.name);
            }
        });
        if (!!options.includeValues) {
            var keys = this.getValuesKeys();
            for (var i = 0; i < keys.length; i++) {
                var key = keys[i];
                if (questionValueNames.indexOf(key) == -1) {
                    var dataValue = this.getDataValueCore(this.valuesHash, key);
                    if (!!dataValue) {
                        result.push({
                            name: key,
                            title: key,
                            value: dataValue,
                            displayValue: dataValue,
                            isNode: false,
                            getString: function (val) {
                                return typeof val === "object" ? JSON.stringify(val) : val;
                            },
                        });
                    }
                }
            }
        }
        return result;
    };
    SurveyModel.prototype.getFilteredValues = function () {
        var values = {};
        for (var key in this.variablesHash)
            values[key] = this.variablesHash[key];
        this.addCalculatedValuesIntoFilteredValues(values);
        var keys = this.getValuesKeys();
        for (var i = 0; i < keys.length; i++) {
            var key = keys[i];
            values[key] = this.getDataValueCore(this.valuesHash, key);
        }
        this.getAllQuestions().forEach(function (q) {
            if (q.hasFilteredValue) {
                values[q.getFilteredName()] = q.getFilteredValue();
            }
        });
        return values;
    };
    SurveyModel.prototype.addCalculatedValuesIntoFilteredValues = function (values) {
        var caclValues = this.calculatedValues;
        for (var i = 0; i < caclValues.length; i++)
            values[caclValues[i].name] = caclValues[i].value;
    };
    SurveyModel.prototype.getFilteredProperties = function () {
        return { survey: this };
    };
    SurveyModel.prototype.getValuesKeys = function () {
        if (!this.editingObj)
            return Object.keys(this.valuesHash);
        var props = Serializer.getPropertiesByObj(this.editingObj);
        var res = [];
        for (var i = 0; i < props.length; i++) {
            res.push(props[i].name);
        }
        return res;
    };
    SurveyModel.prototype.getDataValueCore = function (valuesHash, key) {
        if (!!this.editingObj)
            return Serializer.getObjPropertyValue(this.editingObj, key);
        return this.getDataFromValueHash(valuesHash, key);
    };
    SurveyModel.prototype.setDataValueCore = function (valuesHash, key, value) {
        if (!!this.editingObj) {
            Serializer.setObjPropertyValue(this.editingObj, key, value);
        }
        else {
            this.setDataToValueHash(valuesHash, key, value);
        }
    };
    SurveyModel.prototype.deleteDataValueCore = function (valuesHash, key) {
        if (!!this.editingObj) {
            this.editingObj[key] = null;
        }
        else {
            this.deleteDataFromValueHash(valuesHash, key);
        }
    };
    SurveyModel.prototype.getDataFromValueHash = function (valuesHash, key) {
        if (!!this.valueHashGetDataCallback)
            return this.valueHashGetDataCallback(valuesHash, key);
        return valuesHash[key];
    };
    SurveyModel.prototype.setDataToValueHash = function (valuesHash, key, value) {
        if (!!this.valueHashSetDataCallback) {
            this.valueHashSetDataCallback(valuesHash, key, value);
        }
        else {
            valuesHash[key] = value;
        }
    };
    SurveyModel.prototype.deleteDataFromValueHash = function (valuesHash, key) {
        if (!!this.valueHashDeleteDataCallback) {
            this.valueHashDeleteDataCallback(valuesHash, key);
        }
        else {
            delete valuesHash[key];
        }
    };
    Object.defineProperty(SurveyModel.prototype, "comments", {
        /**
         * An object with all comment values.
         * @see Question.showCommentArea
         * @see storeOthersAsComment
         */
        get: function () {
            var result = {};
            var keys = this.getValuesKeys();
            for (var i = 0; i < keys.length; i++) {
                var key = keys[i];
                if (key.indexOf(this.commentSuffix) > 0) {
                    result[key] = this.getDataValueCore(this.valuesHash, key);
                }
            }
            return result;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "visiblePages", {
        /**
         * Returns an array of visible pages without the start page.
         *
         * To get an array of all pages, use the [`pages`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#pages) property. If all pages are visible, the `pages` and `visiblePages` arrays are identical.
         * @see [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#conditional-visibility)
         */
        get: function () {
            if (this.isDesignMode)
                return this.pages;
            var result = new Array();
            for (var i = 0; i < this.pages.length; i++) {
                if (this.isPageInVisibleList(this.pages[i])) {
                    result.push(this.pages[i]);
                }
            }
            return result;
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.isPageInVisibleList = function (page) {
        return this.isDesignMode || page.isVisible && !page.isStartPage;
    };
    Object.defineProperty(SurveyModel.prototype, "isEmpty", {
        /**
         * Returns `true` if the survey contains zero pages.
         * @see emptySurveyText
         */
        get: function () {
            return this.pages.length == 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "PageCount", {
        get: function () {
            return this.pageCount;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "pageCount", {
        /**
         * Returns a total number of survey pages.
         *
         * To get the number of visible pages, use the [`visiblePageCount`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#visiblePageCount) property.
         * @see pages
         */
        get: function () {
            return this.pages.length;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "visiblePageCount", {
        /**
         * Returns the number of visible survey pages.
         *
         * To get a total number of survey pages, use the [`pageCount`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#pageCount) property.
         * @see visiblePages
         * @see [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#conditional-visibility)
         */
        get: function () {
            return this.visiblePages.length;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "startedPage", {
        /**
         * Returns the start page. Applies only if the [`firstPageIsStarted`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#firstPageIsStarted) property is set to `true`.
         *
         * Refer to the following help topic for more information: [Start Page](https://surveyjs.io/form-library/documentation/design-survey/create-a-multi-page-survey#start-page).
         * @see firstPageIsStarted
         * @see activePage
         */
        get: function () {
            var page = this.firstPageIsStarted && this.pages.length > 1 ? this.pages[0] : null;
            if (!!page) {
                page.onFirstRendering();
                page.setWasShown(true);
            }
            return page;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "currentPage", {
        /**
         * Gets or sets the current page.
         *
         * If you want to change the current page, set this property to a `PageModel` object. You can get this object in different ways. For example, you can call the [`getPageByName()`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#getPageByName) method to obtain a `PageModel` object with a specific name:
         *
         * ```js
         * survey.currentPage = survey.getPageByName("my-page-name");
         * ```
         *
         * Alternatively, you can change the current page if you set the [`currentPageNo`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#currentPageNo) property to the index of the required page.
         *
         * The `currentPage` property does not return the start page even if it is current. Use the [`activePage`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#activePage) property instead if your survey contains a start page.
         */
        get: function () {
            return this.getPropertyValue("currentPage", null);
        },
        set: function (value) {
            if (this.isLoadingFromJson)
                return;
            var newPage = this.getPageByObject(value);
            if (!!value && !newPage)
                return;
            if (!newPage && this.isCurrentPageAvailable)
                return;
            var vPages = this.visiblePages;
            if (newPage != null && vPages.indexOf(newPage) < 0)
                return;
            if (newPage == this.currentPage)
                return;
            var oldValue = this.currentPage;
            if (!this.isShowingPreview && !this.currentPageChanging(newPage, oldValue))
                return;
            this.setPropertyValue("currentPage", newPage);
            if (!!newPage) {
                newPage.onFirstRendering();
                newPage.updateCustomWidgets();
                newPage.setWasShown(true);
            }
            this.locStrsChanged();
            if (!this.isShowingPreview) {
                this.currentPageChanged(newPage, oldValue);
            }
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.tryNavigateToPage = function (page) {
        if (this.isDesignMode)
            return false;
        var index = this.visiblePages.indexOf(page);
        if (index < 0 || index >= this.visiblePageCount)
            return false;
        if (index === this.currentPageNo)
            return false;
        if (index < this.currentPageNo || this.isValidateOnComplete) {
            this.currentPageNo = index;
            return true;
        }
        for (var i = this.currentPageNo; i < index; i++) {
            var page_1 = this.visiblePages[i];
            if (!page_1.validate(true, true))
                return false;
            page_1.passed = true;
        }
        this.currentPage = page;
        return true;
    };
    SurveyModel.prototype.updateCurrentPage = function () {
        if (this.isCurrentPageAvailable)
            return;
        this.currentPage = this.firstVisiblePage;
    };
    Object.defineProperty(SurveyModel.prototype, "isCurrentPageAvailable", {
        get: function () {
            var page = this.currentPage;
            return !!page && this.isPageInVisibleList(page) && this.isPageExistsInSurvey(page);
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.isPageExistsInSurvey = function (page) {
        if (this.pages.indexOf(page) > -1)
            return true;
        return !!this.onContainsPageCallback && this.onContainsPageCallback(page);
    };
    Object.defineProperty(SurveyModel.prototype, "activePage", {
        /**
         * Returns [`startedPage`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#startedPage) if the survey currently displays a start page; otherwise, returns [`currentPage`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#currentPage).
         * @see startedPage
         * @see currentPage
         * @see firstPageIsStarted
         */
        get: function () {
            return this.getPropertyValue("activePage");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isShowStartingPage", {
        /**
         * A Boolean value that indicates whether the [start page](https://surveyjs.io/form-library/documentation/design-survey/create-a-multi-page-survey#start-page) is currently displayed.
         */
        get: function () {
            return this.state === "starting";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "matrixDragHandleArea", {
        /**
         * Specifies which part of a matrix row responds to a drag gesture in [Dynamic Matrix](https://surveyjs.io/form-library/examples/questiontype-matrixdynamic/) questions.
         *
         * Possible values:
         *
         * - `"entireItem"` (default) - Users can use the entire matrix row as a drag handle.
         * - `"icon"` - Users can only use a drag icon as a drag handle.
         */
        get: function () {
            return this.getPropertyValue("matrixDragHandleArea", "entireItem");
        },
        set: function (val) {
            this.setPropertyValue("matrixDragHandleArea", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isShowingPage", {
        get: function () {
            return this.state == "running" || this.state == "preview" || this.isShowStartingPage;
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.updateActivePage = function () {
        var newPage = this.isShowStartingPage ? this.startedPage : this.currentPage;
        if (newPage !== this.activePage) {
            this.setPropertyValue("activePage", newPage);
        }
    };
    SurveyModel.prototype.onStateAndCurrentPageChanged = function () {
        this.updateActivePage();
        this.updateButtonsVisibility();
    };
    SurveyModel.prototype.getPageByObject = function (value) {
        if (!value)
            return null;
        if (value.getType && value.getType() == "page")
            return value;
        if (typeof value === "string" || value instanceof String)
            return this.getPageByName(String(value));
        if (!isNaN(value)) {
            var index = Number(value);
            var vPages = this.visiblePages;
            if (value < 0 || value >= vPages.length)
                return null;
            return vPages[index];
        }
        return value;
    };
    Object.defineProperty(SurveyModel.prototype, "currentPageNo", {
        /**
         * A zero-based index of the current page in the [`visiblePages`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#visiblePages) array.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/survey-editprevious/ (linkStyle))
         * @see visiblePages
         */
        get: function () {
            return this.visiblePages.indexOf(this.currentPage);
        },
        set: function (value) {
            var vPages = this.visiblePages;
            if (value < 0 || value >= vPages.length)
                return;
            this.currentPage = vPages[value];
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "questionsOrder", {
        /**
         * Specifies the sort order of questions in the survey.
         *
         * Possible values:
         *
         * - `"initial"` (default) - Preserves the original order of questions.
         * - `"random"` - Displays questions in random order.
         *
         * You can override this property for individual pages and panels.
         * @see PageModel.questionsOrder
         * @see PanelModel.questionsOrder
         */
        get: function () {
            return this.getPropertyValue("questionsOrder");
        },
        set: function (val) {
            this.setPropertyValue("questionsOrder", val);
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Focuses the first question on the current page.
     * @see focusQuestion
     * @see focusFirstQuestionAutomatic
     */
    SurveyModel.prototype.focusFirstQuestion = function () {
        if (this.focusingQuestionInfo)
            return;
        var page = this.activePage;
        if (page) {
            page.scrollToTop();
            page.focusFirstQuestion();
        }
    };
    SurveyModel.prototype.scrollToTopOnPageChange = function (doScroll) {
        if (doScroll === void 0) { doScroll = true; }
        var page = this.activePage;
        if (!page)
            return;
        if (doScroll) {
            page.scrollToTop();
        }
        if (this.isCurrentPageRendering && this.focusFirstQuestionAutomatic && !this.focusingQuestionInfo) {
            page.focusFirstQuestion();
            this.isCurrentPageRendering = false;
        }
    };
    Object.defineProperty(SurveyModel.prototype, "state", {
        /**
         * Returns the current survey state.
         *
         * Possible values:
         *
         * - `"loading"` - The survey is being loaded from a JSON schema.
         * - `"empty"` - The survey has no elements to display.
         * - `"starting"` - The survey displays a [start page](https://surveyjs.io/form-library/documentation/design-survey/create-a-multi-page-survey#start-page).
         * - `"running"` - A respondent is taking the survey.
         * - `"preview"` - A respondent is [previewing](https://surveyjs.io/form-library/examples/survey-showpreview/) answers before submitting them.
         * - `"completed"` - A respondent has completed the survey and submitted the results.
         */
        get: function () {
            return this.getPropertyValue("state", "empty");
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.updateState = function () {
        this.setPropertyValue("state", this.calcState());
    };
    SurveyModel.prototype.calcState = function () {
        if (this.isLoading)
            return "loading";
        if (this.isCompleted)
            return "completed";
        if (this.isCompletedBefore)
            return "completedbefore";
        if (!this.isDesignMode &&
            this.isEditMode &&
            this.isStartedState &&
            this.startedPage)
            return "starting";
        if (this.isShowingPreview)
            return this.currentPage ? "preview" : "empty";
        return this.currentPage ? "running" : "empty";
    };
    Object.defineProperty(SurveyModel.prototype, "isCompleted", {
        get: function () {
            return this.getPropertyValue("isCompleted", false);
        },
        set: function (val) {
            this.setPropertyValue("isCompleted", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isShowingPreview", {
        get: function () {
            return this.getPropertyValue("isShowingPreview", false);
        },
        set: function (val) {
            if (this.isShowingPreview == val)
                return;
            this.setPropertyValue("isShowingPreview", val);
            this.onShowingPreviewChanged();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isStartedState", {
        get: function () {
            return this.getPropertyValue("isStartedState", false);
        },
        set: function (val) {
            this.setPropertyValue("isStartedState", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isCompletedBefore", {
        get: function () {
            return this.getPropertyValue("isCompletedBefore", false);
        },
        set: function (val) {
            this.setPropertyValue("isCompletedBefore", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isLoading", {
        get: function () {
            return this.getPropertyValue("isLoading", false);
        },
        set: function (val) {
            this.setPropertyValue("isLoading", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "completedState", {
        get: function () {
            return this.getPropertyValue("completedState", "");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "completedStateText", {
        get: function () {
            return this.getPropertyValue("completedStateText", "");
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.setCompletedState = function (value, text) {
        this.setPropertyValue("completedState", value);
        if (!text) {
            if (value == "saving")
                text = this.getLocalizationString("savingData");
            if (value == "error")
                text = this.getLocalizationString("savingDataError");
            if (value == "success")
                text = this.getLocalizationString("savingDataSuccess");
        }
        this.setPropertyValue("completedStateText", text);
        if (this.state === "completed" && this.showCompletedPage && !!this.completedState) {
            this.notify(this.completedStateText, this.completedState, value === "error");
        }
    };
    /**
     * Displays a toast notification with a specified message.
     *
     * Depending on the `type` argument, a survey can display the following notification types:
     *
     * ![Toast notification types in SurveyJS Form Library](https://surveyjs.io//Content/Images/docs/notification-types.png)
     * @param message A message to display.
     * @param type A notification type: `"info"` (default), `"success"`, or `"error"`.
     * @param showActions For internal use.
     */
    SurveyModel.prototype.notify = function (message, type, showActions) {
        if (showActions === void 0) { showActions = false; }
        this.notifier.showActions = showActions;
        this.notifier.notify(message, type, showActions);
    };
    /**
     * Resets the survey [`state`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#state) and, optionally, [`data`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#data). If `state` is `"completed"`, it becomes `"running"`.
     * @param clearData *(Optional)* Specifies whether to clear survey data. Default value: `true`.
     * @param goToFirstPage *(Optional)* Specifies whether to switch the survey to the first page. Default value: `true`.
     */
    SurveyModel.prototype.clear = function (clearData, goToFirstPage) {
        if (clearData === void 0) { clearData = true; }
        if (goToFirstPage === void 0) { goToFirstPage = true; }
        this.isCompleted = false;
        this.isCompletedBefore = false;
        this.isLoading = false;
        this.completedByTriggers = undefined;
        if (clearData) {
            this.setDataCore(null, true);
        }
        this.timerModel.spent = 0;
        for (var i = 0; i < this.pages.length; i++) {
            this.pages[i].timeSpent = 0;
            this.pages[i].setWasShown(false);
            this.pages[i].passed = false;
        }
        this.onFirstPageIsStartedChanged();
        if (goToFirstPage) {
            this.currentPage = this.firstVisiblePage;
        }
        if (clearData) {
            this.updateValuesWithDefaults();
        }
    };
    SurveyModel.prototype.mergeValues = function (src, dest) {
        mergeValues(src, dest);
    };
    SurveyModel.prototype.updateValuesWithDefaults = function () {
        if (this.isDesignMode || this.isLoading)
            return;
        for (var i = 0; i < this.pages.length; i++) {
            var questions = this.pages[i].questions;
            for (var j = 0; j < questions.length; j++) {
                questions[j].updateValueWithDefaults();
            }
        }
    };
    SurveyModel.prototype.updateCustomWidgets = function (page) {
        if (!page)
            return;
        page.updateCustomWidgets();
    };
    SurveyModel.prototype.currentPageChanging = function (newValue, oldValue) {
        var options = this.createPageChangeEventOptions(newValue, oldValue);
        options.allow = true;
        options.allowChanging = true;
        this.onCurrentPageChanging.fire(this, options);
        var allow = options.allowChanging && options.allow;
        if (allow) {
            this.isCurrentPageRendering = true;
        }
        return allow;
    };
    SurveyModel.prototype.currentPageChanged = function (newValue, oldValue) {
        this.notifyQuestionsOnHidingContent(oldValue);
        var options = this.createPageChangeEventOptions(newValue, oldValue);
        if (oldValue && !oldValue.passed) {
            if (oldValue.validate(false)) {
                oldValue.passed = true;
            }
        }
        if (this.isCurrentPageRendered === true) {
            this.isCurrentPageRendered = false;
        }
        this.onCurrentPageChanged.fire(this, options);
    };
    SurveyModel.prototype.notifyQuestionsOnHidingContent = function (page) {
        if (!page)
            return;
        page.questions.forEach(function (q) { return q.onHidingContent(); });
    };
    SurveyModel.prototype.createPageChangeEventOptions = function (newValue, oldValue) {
        var diff = !!newValue && !!oldValue ? newValue.visibleIndex - oldValue.visibleIndex : 0;
        return {
            oldCurrentPage: oldValue,
            newCurrentPage: newValue,
            isNextPage: diff === 1,
            isPrevPage: diff === -1,
            isGoingForward: diff > 0,
            isGoingBackward: diff < 0,
            isAfterPreview: this.changeCurrentPageFromPreview === true
        };
    };
    SurveyModel.prototype.getProgress = function () {
        if (this.currentPage == null)
            return 0;
        if (this.progressBarType !== "pages") {
            var info = this.getProgressInfo();
            if (this.progressBarType === "requiredQuestions") {
                return info.requiredQuestionCount >= 1
                    ? Math.ceil((info.requiredAnsweredQuestionCount * 100) /
                        info.requiredQuestionCount)
                    : 100;
            }
            return info.questionCount >= 1
                ? Math.ceil((info.answeredQuestionCount * 100) / info.questionCount)
                : 100;
        }
        var visPages = this.visiblePages;
        var index = visPages.indexOf(this.currentPage);
        return Math.ceil((index * 100) / visPages.length);
    };
    Object.defineProperty(SurveyModel.prototype, "progressValue", {
        /**
         * Returns a percentage value that indicates user progress in the survey.
         * @see showProgressBar
         * @see progressBarType
         * @see progressText
         */
        get: function () {
            return this.getPropertyValue("progressValue", 0);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isNavigationButtonsShowing", {
        get: function () {
            if (this.isDesignMode)
                return "none";
            var page = this.currentPage;
            if (!page)
                return "none";
            if (page.navigationButtonsVisibility === "show") {
                return this.showNavigationButtons === "none" ? "bottom" : this.showNavigationButtons;
            }
            if (page.navigationButtonsVisibility === "hide") {
                return "none";
            }
            return this.showNavigationButtons;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isNavigationButtonsShowingOnTop", {
        get: function () {
            return this.getIsNavigationButtonsShowingOn("top");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isNavigationButtonsShowingOnBottom", {
        get: function () {
            return this.getIsNavigationButtonsShowingOn("bottom");
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.getIsNavigationButtonsShowingOn = function (buttonPosition) {
        var res = this.isNavigationButtonsShowing;
        return res == "both" || res == buttonPosition;
    };
    Object.defineProperty(SurveyModel.prototype, "isEditMode", {
        get: function () {
            return this.mode == "edit";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isDisplayMode", {
        get: function () {
            return this.mode == "display" && !this.isDesignMode || this.state == "preview";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isUpdateValueTextOnTyping", {
        get: function () {
            return this.textUpdateMode == "onTyping";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isDesignMode", {
        /**
         * Indicates whether the survey is being designed in [Survey Creator](https://surveyjs.io/survey-creator/documentation/overview).
         */
        get: function () {
            return this._isDesignMode;
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.setDesignMode = function (value) {
        if (!!this._isDesignMode != !!value) {
            this._isDesignMode = !!value;
            this.onQuestionsOnPageModeChanged("standard");
        }
    };
    Object.defineProperty(SurveyModel.prototype, "showInvisibleElements", {
        /**
         * Specifies whether to show all survey elements, regardless of their visibility.
         *
         * Default value: `false`
         */
        get: function () {
            return this.getPropertyValue("showInvisibleElements", false);
        },
        set: function (val) {
            var visPages = this.visiblePages;
            this.setPropertyValue("showInvisibleElements", val);
            if (this.isLoadingFromJson)
                return;
            this.runConditions();
            this.updateAllElementsVisibility(visPages);
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.updateAllElementsVisibility = function (visPages) {
        for (var i = 0; i < this.pages.length; i++) {
            var page = this.pages[i];
            page.updateElementVisibility();
            if (visPages.indexOf(page) > -1 != page.isVisible) {
                this.onPageVisibleChanged.fire(this, {
                    page: page,
                    visible: page.isVisible,
                });
            }
        }
    };
    Object.defineProperty(SurveyModel.prototype, "areInvisibleElementsShowing", {
        get: function () {
            return this.isDesignMode || this.showInvisibleElements;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "areEmptyElementsHidden", {
        get: function () {
            return (this.isShowingPreview &&
                this.showPreviewBeforeComplete == "showAnsweredQuestions" && this.isAnyQuestionAnswered);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isAnyQuestionAnswered", {
        get: function () {
            var questions = this.getAllQuestions(true);
            for (var i = 0; i < questions.length; i++) {
                if (!questions[i].isEmpty())
                    return true;
            }
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "hasCookie", {
        /**
         * Indicates whether the browser has a cookie with a specified [`cookieName`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#cookieName). If this property's value is `true`, the respondent has passed the survey previously.
         * @see setCookie
         * @see deleteCookie
         */
        get: function () {
            if (!this.cookieName)
                return false;
            var cookies = DomDocumentHelper.getCookie();
            return cookies && cookies.indexOf(this.cookieName + "=true") > -1;
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Sets a cookie with a specified [`cookieName`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#cookieName) in the browser. If the `cookieName` property value is defined, this method is automatically called on survey completion.
     * @see hasCookie
     * @see deleteCookie
     */
    SurveyModel.prototype.setCookie = function () {
        if (!this.cookieName)
            return;
        DomDocumentHelper.setCookie(this.cookieName + "=true; expires=Fri, 31 Dec 9999 0:0:0 GMT");
    };
    /**
     * Deletes a cookie with a specified [`cookieName`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#cookieName) from the browser.
     * @see hasCookie
     * @see setCookie
     */
    SurveyModel.prototype.deleteCookie = function () {
        if (!this.cookieName)
            return;
        DomDocumentHelper.setCookie(this.cookieName + "=;");
    };
    Object.defineProperty(SurveyModel.prototype, "ignoreValidation", {
        /**
         * This property is obsolete. Use the [`validationEnabled`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#validationEnabled) property instead.
         */
        get: function () { return !this.validationEnabled; },
        set: function (val) { this.validationEnabled = !val; },
        enumerable: false,
        configurable: true
    });
    /**
     * Switches the survey to the next page.
     *
     * This method returns a Boolean value that indicates whether the page was successfully switched. `false` is returned if the current page is the last page or if it contains validation errors.
     * @returns `true` if the page was successfully switched; `false` otherwise.
     * @see isLastPage
     * @see prevPage
     * @see completeLastPage
     */
    SurveyModel.prototype.nextPage = function () {
        if (this.isLastPage)
            return false;
        return this.doCurrentPageComplete(false);
    };
    SurveyModel.prototype.hasErrorsOnNavigate = function (doComplete) {
        var _this = this;
        if (!this.isEditMode || this.ignoreValidation)
            return false;
        var skipValidation = doComplete && this.validationAllowComplete || !doComplete && this.validationAllowSwitchPages;
        var func = function (hasErrors) {
            if (!hasErrors || skipValidation) {
                _this.doCurrentPageCompleteCore(doComplete);
            }
        };
        if (this.isValidateOnComplete) {
            if (!this.isLastPage)
                return false;
            return this.validate(true, this.focusOnFirstError, func, true) !== true && !skipValidation;
        }
        return this.validateCurrentPage(func) !== true && !skipValidation;
    };
    SurveyModel.prototype.checkForAsyncQuestionValidation = function (questions, func) {
        var _this = this;
        this.clearAsyncValidationQuesitons();
        var _loop_2 = function () {
            if (questions[i].isRunningValidators) {
                var q_1 = questions[i];
                q_1.onCompletedAsyncValidators = function (hasErrors) {
                    _this.onCompletedAsyncQuestionValidators(q_1, func, hasErrors);
                };
                this_2.asyncValidationQuesitons.push(questions[i]);
            }
        };
        var this_2 = this;
        for (var i = 0; i < questions.length; i++) {
            _loop_2();
        }
        return this.asyncValidationQuesitons.length > 0;
    };
    SurveyModel.prototype.clearAsyncValidationQuesitons = function () {
        if (!!this.asyncValidationQuesitons) {
            var asynQuestions = this.asyncValidationQuesitons;
            for (var i = 0; i < asynQuestions.length; i++) {
                asynQuestions[i].onCompletedAsyncValidators = null;
            }
        }
        this.asyncValidationQuesitons = [];
    };
    SurveyModel.prototype.onCompletedAsyncQuestionValidators = function (question, func, hasErrors) {
        if (hasErrors) {
            this.clearAsyncValidationQuesitons();
            func(true);
            if (this.focusOnFirstError && !!question && !!question.page && question.page === this.currentPage) {
                var questions = this.currentPage.questions;
                for (var i_1 = 0; i_1 < questions.length; i_1++) {
                    if (questions[i_1] !== question && questions[i_1].errors.length > 0)
                        return;
                }
                question.focus(true);
            }
            return;
        }
        var asynQuestions = this.asyncValidationQuesitons;
        for (var i = 0; i < asynQuestions.length; i++) {
            if (asynQuestions[i].isRunningValidators)
                return;
        }
        func(false);
    };
    Object.defineProperty(SurveyModel.prototype, "isCurrentPageHasErrors", {
        get: function () {
            return this.checkIsCurrentPageHasErrors();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isCurrentPageValid", {
        /**
         * Returns `true` if the current page does not contain errors.
         * @see currentPage
         */
        get: function () {
            return !this.checkIsCurrentPageHasErrors();
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.hasCurrentPageErrors = function (onAsyncValidation) {
        return this.hasPageErrors(undefined, onAsyncValidation);
    };
    /**
     * Validates all questions on the current page and returns `false` if the validation fails.
     *
     * If you use validation expressions and at least one of them calls an async function, the `validateCurrentPage` method returns `undefined`. In this case, you should pass a callback function as the `onAsyncValidation` parameter. The function's `hasErrors` Boolean parameter will contain the validation result.
     * @param onAsyncValidation *(Optional)* Pass a callback function. It accepts a Boolean `hasErrors` parameter that equals `true` if the validation fails or `false` otherwise.
     * @see currentPage
     * @see validate
     * @see validateCurrentPage
     */
    SurveyModel.prototype.validateCurrentPage = function (onAsyncValidation) {
        return this.validatePage(undefined, onAsyncValidation);
    };
    SurveyModel.prototype.hasPageErrors = function (page, onAsyncValidation) {
        var res = this.validatePage(page, onAsyncValidation);
        if (res === undefined)
            return res;
        return !res;
    };
    /**
     * Validates all questions on a specified page and returns `false` if the validation fails.
     *
     * If you use validation expressions and at least one of them calls an async function, the `validatePage` method returns `undefined`. In this case, you should pass a callback function as the `onAsyncValidation` parameter. The function's `hasErrors` Boolean parameter will contain the validation result.
     * @param page Pass the `PageModel` that you want to validate. You can pass `undefined` to validate the [`activePage`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#activePage).
     * @param onAsyncValidation *(Optional)* Pass a callback function. It accepts a Boolean `hasErrors` parameter that equals `true` if the validation fails or `false` otherwise.
     * @see validate
     * @see validateCurrentPage
     */
    SurveyModel.prototype.validatePage = function (page, onAsyncValidation) {
        if (!page) {
            page = this.activePage;
        }
        if (!page)
            return true;
        if (this.checkIsPageHasErrors(page))
            return false;
        if (!onAsyncValidation)
            return true;
        return this.checkForAsyncQuestionValidation(page.questions, function (hasErrors) { return onAsyncValidation(hasErrors); })
            ? undefined
            : true;
    };
    SurveyModel.prototype.hasErrors = function (fireCallback, focusOnFirstError, onAsyncValidation) {
        if (fireCallback === void 0) { fireCallback = true; }
        if (focusOnFirstError === void 0) { focusOnFirstError = false; }
        var res = this.validate(fireCallback, focusOnFirstError, onAsyncValidation);
        if (res === undefined)
            return res;
        return !res;
    };
    /**
     * Validates all questions and returns `false` if the validation fails.
     *
     * If you use validation expressions and at least one of them calls an async function, the `validate` method returns `undefined`. In this case, you should pass a callback function as the `onAsyncValidation` parameter. The function's `hasErrors` Boolean parameter will contain the validation result.
     * @param fireCallback *(Optional)* Pass `false` if you do not want to show validation errors in the UI.
     * @param focusOnFirstError *(Optional)* Pass `true` if you want to focus the first question with a validation error. The survey will be switched to the page that contains this question if required.
     * @param onAsyncValidation *(Optional)* Pass a callback function. It accepts a Boolean `hasErrors` parameter that equals `true` if the validation fails or `false` otherwise.
     * @see validateCurrentPage
     * @see validatePage
     */
    SurveyModel.prototype.validate = function (fireCallback, focusOnFirstError, onAsyncValidation, changeCurrentPage) {
        if (fireCallback === void 0) { fireCallback = true; }
        if (focusOnFirstError === void 0) { focusOnFirstError = false; }
        if (!!onAsyncValidation) {
            fireCallback = true;
        }
        var visPages = this.visiblePages;
        var res = true;
        var rec = { fireCallback: fireCallback, focusOnFirstError: focusOnFirstError, firstErrorQuestion: null, result: false };
        for (var i = 0; i < visPages.length; i++) {
            if (!visPages[i].validate(fireCallback, focusOnFirstError, rec)) {
                res = false;
            }
        }
        if (!!rec.firstErrorQuestion && (focusOnFirstError || changeCurrentPage)) {
            if (focusOnFirstError) {
                rec.firstErrorQuestion.focus(true);
            }
            else {
                this.currentPage = rec.firstErrorQuestion.page;
            }
        }
        if (!res || !onAsyncValidation)
            return res;
        return this.checkForAsyncQuestionValidation(this.getAllQuestions(), function (hasErrors) { return onAsyncValidation(hasErrors); })
            ? undefined
            : true;
    };
    SurveyModel.prototype.ensureUniqueNames = function (element) {
        if (element === void 0) { element = null; }
        if (element == null) {
            for (var i = 0; i < this.pages.length; i++) {
                this.ensureUniqueName(this.pages[i]);
            }
        }
        else {
            this.ensureUniqueName(element);
        }
    };
    SurveyModel.prototype.ensureUniqueName = function (element) {
        if (element.isPage) {
            this.ensureUniquePageName(element);
        }
        if (element.isPanel) {
            this.ensureUniquePanelName(element);
        }
        if (element.isPage || element.isPanel) {
            var elements = element.elements;
            for (var i = 0; i < elements.length; i++) {
                this.ensureUniqueNames(elements[i]);
            }
        }
        else {
            this.ensureUniqueQuestionName(element);
        }
    };
    SurveyModel.prototype.ensureUniquePageName = function (element) {
        var _this = this;
        return this.ensureUniqueElementName(element, function (name) {
            return _this.getPageByName(name);
        });
    };
    SurveyModel.prototype.ensureUniquePanelName = function (element) {
        var _this = this;
        return this.ensureUniqueElementName(element, function (name) {
            return _this.getPanelByName(name);
        });
    };
    SurveyModel.prototype.ensureUniqueQuestionName = function (element) {
        var _this = this;
        return this.ensureUniqueElementName(element, function (name) {
            return _this.getQuestionByName(name);
        });
    };
    SurveyModel.prototype.ensureUniqueElementName = function (element, getElementByName) {
        var existingElement = getElementByName(element.name);
        if (!existingElement || existingElement == element)
            return;
        var newName = this.getNewName(element.name);
        while (!!getElementByName(newName)) {
            var newName = this.getNewName(element.name);
        }
        element.name = newName;
    };
    SurveyModel.prototype.getNewName = function (name) {
        var pos = name.length;
        while (pos > 0 && name[pos - 1] >= "0" && name[pos - 1] <= "9") {
            pos--;
        }
        var base = name.substring(0, pos);
        var num = 0;
        if (pos < name.length) {
            num = parseInt(name.substring(pos));
        }
        num++;
        return base + num;
    };
    SurveyModel.prototype.checkIsCurrentPageHasErrors = function (isFocuseOnFirstError) {
        if (isFocuseOnFirstError === void 0) { isFocuseOnFirstError = undefined; }
        return this.checkIsPageHasErrors(this.activePage, isFocuseOnFirstError);
    };
    SurveyModel.prototype.checkIsPageHasErrors = function (page, isFocuseOnFirstError) {
        if (isFocuseOnFirstError === void 0) { isFocuseOnFirstError = undefined; }
        if (isFocuseOnFirstError === undefined) {
            isFocuseOnFirstError = this.focusOnFirstError;
        }
        if (!page)
            return true;
        var res = !page.validate(true, isFocuseOnFirstError);
        this.fireValidatedErrorsOnPage(page);
        return res;
    };
    SurveyModel.prototype.fireValidatedErrorsOnPage = function (page) {
        if (this.onValidatedErrorsOnCurrentPage.isEmpty || !page)
            return;
        var questionsOnPage = page.questions;
        var questions = new Array();
        var errors = new Array();
        for (var i = 0; i < questionsOnPage.length; i++) {
            var q = questionsOnPage[i];
            if (q.errors.length > 0) {
                questions.push(q);
                for (var j = 0; j < q.errors.length; j++) {
                    errors.push(q.errors[j]);
                }
            }
        }
        this.onValidatedErrorsOnCurrentPage.fire(this, {
            questions: questions,
            errors: errors,
            page: page,
        });
    };
    /**
     * Switches the survey to the previous page.
     *
     * This method returns a Boolean value that indicates whether the page was successfully switched. `false` is returned if the current page is the first page.
     * @returns `true` if the page was successfully switched; `false` otherwise.
     * @see isFirstPage
     * @see nextPage
     */
    SurveyModel.prototype.prevPage = function () {
        var _this = this;
        if (this.isFirstPage || this.state === "starting")
            return false;
        this.resetNavigationButton();
        var skipped = this.skippedPages.find(function (sp) { return sp.to == _this.currentPage; });
        if (skipped) {
            this.currentPage = skipped.from;
            this.skippedPages.splice(this.skippedPages.indexOf(skipped), 1);
        }
        else {
            var vPages = this.visiblePages;
            var index = vPages.indexOf(this.currentPage);
            this.currentPage = vPages[index - 1];
        }
        return true;
    };
    /**
     * Completes the survey if it currently displays the last page and the page contains no validation errors. If both these conditions are met, this method returns `true`; otherwise, `false`.
     *
     * If you want to complete the survey regardless of the current page and validation errors, use the [`doComplete()`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#completeLastPage) event.
     * @see isCurrentPageValid
     * @see nextPage
     */
    SurveyModel.prototype.completeLastPage = function () {
        if (this.isValidateOnComplete) {
            this.cancelPreview();
        }
        var res = this.doCurrentPageComplete(true);
        if (res) {
            this.cancelPreview();
        }
        return res;
    };
    SurveyModel.prototype.navigationMouseDown = function () {
        this.isNavigationButtonPressed = true;
        return true;
    };
    SurveyModel.prototype.resetNavigationButton = function () {
        this.isNavigationButtonPressed = false;
    };
    SurveyModel.prototype.nextPageUIClick = function () {
        if (!!this.mouseDownPage && this.mouseDownPage !== this.activePage)
            return;
        this.mouseDownPage = null;
        return this.nextPage();
    };
    SurveyModel.prototype.nextPageMouseDown = function () {
        this.mouseDownPage = this.activePage;
        return this.navigationMouseDown();
    };
    /**
     * Displays a [preview of given answers](https://surveyjs.io/form-library/documentation/design-survey/create-a-multi-page-survey#preview-page). Returns `false` if the preview cannot be displayed because of validation errors.
     * @see cancelPreview
     * @see showPreviewBeforeComplete
     * @see onShowingPreview
     * @see state
     */
    SurveyModel.prototype.showPreview = function () {
        this.resetNavigationButton();
        if (!this.isValidateOnComplete) {
            if (this.hasErrorsOnNavigate(true))
                return false;
            if (this.doServerValidation(true, true))
                return false;
        }
        this.showPreviewCore();
        return true;
    };
    SurveyModel.prototype.showPreviewCore = function () {
        var options = { allowShowPreview: true, allow: true };
        this.onShowingPreview.fire(this, options);
        this.isShowingPreview = options.allowShowPreview && options.allow;
    };
    /**
     * Cancels a [preview of given answers](https://surveyjs.io/form-library/documentation/design-survey/create-a-multi-page-survey#preview-page) and switches the survey to the page specified by the `currentPage` parameter.
     * @param currentPage A new current page. If you do not specify this parameter, the survey displays the last page.
     * @see showPreview
     * @see showPreviewBeforeComplete
     * @see state
     */
    SurveyModel.prototype.cancelPreview = function (currentPage) {
        if (currentPage === void 0) { currentPage = null; }
        if (!this.isShowingPreview)
            return;
        this.gotoPageFromPreview = currentPage;
        this.isShowingPreview = false;
    };
    SurveyModel.prototype.cancelPreviewByPage = function (panel) {
        this.cancelPreview(panel["originalPage"]);
    };
    SurveyModel.prototype.doCurrentPageComplete = function (doComplete) {
        if (this.isValidatingOnServer)
            return false;
        this.resetNavigationButton();
        if (this.hasErrorsOnNavigate(doComplete))
            return false;
        return this.doCurrentPageCompleteCore(doComplete);
    };
    SurveyModel.prototype.doCurrentPageCompleteCore = function (doComplete) {
        if (this.doServerValidation(doComplete))
            return false;
        if (doComplete) {
            this.currentPage.passed = true;
            return this.doComplete(this.canBeCompletedByTrigger, this.completedTrigger);
        }
        this.doNextPage();
        return true;
    };
    Object.defineProperty(SurveyModel.prototype, "isSinglePage", {
        get: function () {
            return this.questionsOnPageMode == "singlePage";
        },
        set: function (val) {
            this.questionsOnPageMode = val ? "singlePage" : "standard";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "questionsOnPageMode", {
        /**
         * Specifies how to distribute survey elements between pages.
         *
         * Possible values:
         *
         * - `"singlePage"` - Combines all survey pages into a single page.
         * - `"questionPerPage"` - Creates a separate page for every question.
         * - `"standard"` (default) - Retains the original structure specified in the JSON schema.
         */
        get: function () {
            return this.getPropertyValue("questionsOnPageMode");
        },
        set: function (val) {
            this.setPropertyValue("questionsOnPageMode", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "firstPageIsStarted", {
        /**
         * Gets or sets a Boolean value that specifies whether the first page is a start page.
         *
         * Refer to the following help topic for more information: [Start Page](https://surveyjs.io/form-library/documentation/design-survey/create-a-multi-page-survey#start-page).
         * @see startedPage
         * @see activePage
         */
        get: function () {
            return this.getPropertyValue("firstPageIsStarted");
        },
        set: function (val) {
            this.setPropertyValue("firstPageIsStarted", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.isPageStarted = function (page) {
        return (this.firstPageIsStarted && this.pages.length > 1 && this.pages[0] === page);
    };
    Object.defineProperty(SurveyModel.prototype, "showPreviewBeforeComplete", {
        /**
         * Allows respondents to preview answers before they are submitted.
         *
         * Possible values:
         *
         * - `"showAllQuestions"` - Displays all questions in the preview.
         * - `"showAnsweredQuestions"` - Displays only answered questions in the preview.
         * - `"noPreview"` (default) - Hides the preview.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/survey-showpreview/ (linkStyle))
         * @see showPreview
         * @see cancelPreview
         */
        get: function () {
            return this.getPropertyValue("showPreviewBeforeComplete");
        },
        set: function (val) {
            this.setPropertyValue("showPreviewBeforeComplete", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isShowPreviewBeforeComplete", {
        get: function () {
            var preview = this.showPreviewBeforeComplete;
            return preview == "showAllQuestions" || preview == "showAnsweredQuestions";
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.onFirstPageIsStartedChanged = function () {
        this.isStartedState = this.firstPageIsStarted && this.pages.length > 1;
        this.pageVisibilityChanged(this.pages[0], !this.isStartedState);
    };
    SurveyModel.prototype.onShowingPreviewChanged = function () {
        if (this.isDesignMode)
            return;
        if (this.isShowingPreview) {
            this.runningPages = this.pages.slice(0, this.pages.length);
            this.setupPagesForPageModes(true, false);
        }
        else {
            if (this.runningPages) {
                this.restoreOriginalPages(this.runningPages);
            }
            this.runningPages = undefined;
        }
        this.runConditions();
        this.updateAllElementsVisibility(this.pages);
        this.updateVisibleIndexes();
        if (this.isShowingPreview) {
            this.currentPageNo = 0;
        }
        else {
            var curPage = this.gotoPageFromPreview;
            this.gotoPageFromPreview = null;
            if (helpers_Helpers.isValueEmpty(curPage) && this.visiblePageCount > 0) {
                curPage = this.visiblePages[this.visiblePageCount - 1];
            }
            if (!!curPage) {
                this.changeCurrentPageFromPreview = true;
                this.currentPage = curPage;
                this.changeCurrentPageFromPreview = false;
            }
        }
    };
    SurveyModel.prototype.onQuestionsOnPageModeChanged = function (oldValue, isFirstLoad) {
        if (isFirstLoad === void 0) { isFirstLoad = false; }
        if (this.isShowingPreview)
            return;
        if (this.questionsOnPageMode == "standard" || this.isDesignMode) {
            if (this.originalPages) {
                this.restoreOriginalPages(this.originalPages);
            }
            this.originalPages = undefined;
        }
        else {
            if (!oldValue || oldValue == "standard") {
                this.originalPages = this.pages.slice(0, this.pages.length);
            }
            this.setupPagesForPageModes(this.isSinglePage, isFirstLoad);
        }
        this.runConditions();
        this.updateVisibleIndexes();
    };
    SurveyModel.prototype.restoreOriginalPages = function (originalPages) {
        this.questionHashesClear();
        this.pages.splice(0, this.pages.length);
        for (var i = 0; i < originalPages.length; i++) {
            var page = originalPages[i];
            page.setWasShown(false);
            this.pages.push(page);
        }
    };
    SurveyModel.prototype.getPageStartIndex = function () {
        return this.firstPageIsStarted && this.pages.length > 0 ? 1 : 0;
    };
    SurveyModel.prototype.setupPagesForPageModes = function (isSinglePage, isFirstLoad) {
        var _this = this;
        this.questionHashesClear();
        if (this.firstPageIsStarted && this.pages.length > 0) {
            this.pages[0].questions.forEach(function (q) { return _this.questionHashesAdded(q); });
        }
        this.isLockingUpdateOnPageModes = !isFirstLoad;
        var startIndex = this.getPageStartIndex();
        _super.prototype.startLoadingFromJson.call(this);
        var newPages = this.createPagesForQuestionOnPageMode(isSinglePage, startIndex);
        var deletedLen = this.pages.length - startIndex;
        this.pages.splice(startIndex, deletedLen);
        for (var i = 0; i < newPages.length; i++) {
            this.pages.push(newPages[i]);
        }
        _super.prototype.endLoadingFromJson.call(this);
        for (var i = 0; i < newPages.length; i++) {
            newPages[i].setSurveyImpl(this, true);
        }
        this.doElementsOnLoad();
        this.updateCurrentPage();
        this.isLockingUpdateOnPageModes = false;
    };
    SurveyModel.prototype.createPagesForQuestionOnPageMode = function (isSinglePage, startIndex) {
        if (isSinglePage) {
            return [this.createSinglePage(startIndex)];
        }
        return this.createPagesForEveryQuestion(startIndex);
    };
    SurveyModel.prototype.createSinglePage = function (startIndex) {
        var single = this.createNewPage("all");
        single.setSurveyImpl(this);
        for (var i = startIndex; i < this.pages.length; i++) {
            var page = this.pages[i];
            var panel = Serializer.createClass("panel");
            panel.originalPage = page;
            single.addPanel(panel);
            var json = new jsonobject_JsonObject().toJsonObject(page);
            new jsonobject_JsonObject().toObject(json, panel);
            if (!this.showPageTitles) {
                panel.title = "";
            }
        }
        return single;
    };
    SurveyModel.prototype.createPagesForEveryQuestion = function (startIndex) {
        var res = [];
        for (var i = startIndex; i < this.pages.length; i++) {
            var originalPage = this.pages[i];
            // Initialize randomization
            originalPage.setWasShown(true);
            for (var j = 0; j < originalPage.elements.length; j++) {
                var originalElement = originalPage.elements[j];
                var element = Serializer.createClass(originalElement.getType());
                if (!element)
                    continue;
                var jsonObj = new jsonobject_JsonObject();
                //Deserialize page properties only, excluding elements
                jsonObj.lightSerializing = true;
                var pageJson = jsonObj.toJsonObject(originalPage);
                var page = Serializer.createClass(originalPage.getType());
                page.fromJSON(pageJson);
                page.name = originalElement.name;
                page.setSurveyImpl(this);
                res.push(page);
                var json = new jsonobject_JsonObject().toJsonObject(originalElement);
                page.addElement(element);
                new jsonobject_JsonObject().toObject(json, element);
                for (var k = 0; k < page.questions.length; k++) {
                    this.questionHashesAdded(page.questions[k]);
                }
            }
        }
        return res;
    };
    Object.defineProperty(SurveyModel.prototype, "isFirstPage", {
        /**
         * Indicates whether the [current page](#currentPage) is the first page.
         *
         * > If the survey displays the [start page](https://surveyjs.io/form-library/documentation/design-survey/create-a-multi-page-survey#start-page), this property contains `false`. Use the [`isShowStartingPage`](#isShowStartingPage) property to find out whether the start page is currently displayed.
         */
        get: function () {
            return this.getPropertyValue("isFirstPage");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isLastPage", {
        /**
         * Indicates whether the [current page](#currentPage) is the last page.
         */
        get: function () {
            return this.getPropertyValue("isLastPage");
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.updateButtonsVisibility = function () {
        this.updateIsFirstLastPageState();
        this.setPropertyValue("isShowPrevButton", this.calcIsShowPrevButton());
        this.setPropertyValue("isShowNextButton", this.calcIsShowNextButton());
        this.setPropertyValue("isCompleteButtonVisible", this.calcIsCompleteButtonVisible());
        this.setPropertyValue("isPreviewButtonVisible", this.calcIsPreviewButtonVisible());
        this.setPropertyValue("isCancelPreviewButtonVisible", this.calcIsCancelPreviewButtonVisible());
    };
    Object.defineProperty(SurveyModel.prototype, "isShowPrevButton", {
        get: function () {
            return this.getPropertyValue("isShowPrevButton");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isShowNextButton", {
        get: function () {
            return this.getPropertyValue("isShowNextButton");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isCompleteButtonVisible", {
        get: function () {
            return this.getPropertyValue("isCompleteButtonVisible");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isPreviewButtonVisible", {
        get: function () {
            return this.getPropertyValue("isPreviewButtonVisible");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isCancelPreviewButtonVisible", {
        get: function () {
            return this.getPropertyValue("isCancelPreviewButtonVisible");
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.updateIsFirstLastPageState = function () {
        var curPage = this.currentPage;
        this.setPropertyValue("isFirstPage", !!curPage && curPage === this.firstVisiblePage);
        this.setPropertyValue("isLastPage", !!curPage && curPage === this.lastVisiblePage);
    };
    SurveyModel.prototype.calcIsShowPrevButton = function () {
        if (this.isFirstPage || !this.showPrevButton || this.state !== "running")
            return false;
        var page = this.visiblePages[this.currentPageNo - 1];
        return page && page.getMaxTimeToFinish() <= 0;
    };
    SurveyModel.prototype.calcIsShowNextButton = function () {
        return this.state === "running" && !this.isLastPage && !this.canBeCompletedByTrigger;
    };
    SurveyModel.prototype.calcIsCompleteButtonVisible = function () {
        var state = this.state;
        return this.isEditMode && (this.state === "running" &&
            (this.isLastPage && !this.isShowPreviewBeforeComplete || this.canBeCompletedByTrigger)
            || state === "preview") && this.showCompleteButton;
    };
    SurveyModel.prototype.calcIsPreviewButtonVisible = function () {
        return (this.isEditMode &&
            this.isShowPreviewBeforeComplete &&
            this.state == "running" && this.isLastPage);
    };
    SurveyModel.prototype.calcIsCancelPreviewButtonVisible = function () {
        return (this.isEditMode &&
            this.isShowPreviewBeforeComplete &&
            this.state == "preview");
    };
    Object.defineProperty(SurveyModel.prototype, "firstVisiblePage", {
        get: function () {
            var pages = this.pages;
            for (var i = 0; i < pages.length; i++) {
                if (this.isPageInVisibleList(pages[i]))
                    return pages[i];
            }
            return null;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "lastVisiblePage", {
        get: function () {
            var pages = this.pages;
            for (var i = pages.length - 1; i >= 0; i--) {
                if (this.isPageInVisibleList(pages[i]))
                    return pages[i];
            }
            return null;
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Completes the survey.
     *
     * When you call this method, Form Library performs the following actions:
     *
     * 1. Saves a cookie if the [`cookieName`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#cookieName) property is set.
     * 1. Switches the survey [`state`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#state) to `"completed"`.
     * 1. Raises the [`onComplete`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onComplete) event.
     * 1. Navigates the user to a URL specified by the [`navigateToUrl`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#navigateToUrl) or [`navigateToUrlOnCondition`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#navigateToUrlOnCondition) property.
     * 1. Calls the [`sendResult()`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#sendResult) method if Form Library works with [SurveyJS Service](https://api.surveyjs.io/).
     *
     * The `doComplete()` method completes the survey regardless of validation errors and the current page. If you need to ensure that survey results are valid and full, call the [`completeLastPage()`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#completeLastPage) method instead.
     *
     * @param isCompleteOnTrigger For internal use.
     * @param completeTrigger For internal use.
     * @returns `false` if survey completion is cancelled within the [`onCompleting`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onCompleting) event handler; otherwise, `true`.
     * @see surveyPostId
     */
    SurveyModel.prototype.doComplete = function (isCompleteOnTrigger, completeTrigger) {
        if (isCompleteOnTrigger === void 0) { isCompleteOnTrigger = false; }
        if (this.isCompleted)
            return;
        if (!this.checkOnCompletingEvent(isCompleteOnTrigger, completeTrigger)) {
            this.isCompleted = false;
            return false;
        }
        this.checkOnPageTriggers(true);
        this.stopTimer();
        this.notifyQuestionsOnHidingContent(this.currentPage);
        this.isCompleted = true;
        this.clearUnusedValues();
        this.saveDataOnComplete(isCompleteOnTrigger, completeTrigger);
        this.setCookie();
        return true;
    };
    SurveyModel.prototype.saveDataOnComplete = function (isCompleteOnTrigger, completeTrigger) {
        var _this = this;
        if (isCompleteOnTrigger === void 0) { isCompleteOnTrigger = false; }
        var previousCookie = this.hasCookie;
        var showSaveInProgress = function (text) {
            savingDataStarted = true;
            _this.setCompletedState("saving", text);
        };
        var showSaveError = function (text) {
            _this.setCompletedState("error", text);
        };
        var showSaveSuccess = function (text) {
            _this.setCompletedState("success", text);
            _this.navigateTo();
        };
        var clearSaveMessages = function (text) {
            _this.setCompletedState("", "");
        };
        var savingDataStarted = false;
        var onCompleteOptions = {
            isCompleteOnTrigger: isCompleteOnTrigger,
            completeTrigger: completeTrigger,
            showSaveInProgress: showSaveInProgress,
            showSaveError: showSaveError,
            showSaveSuccess: showSaveSuccess,
            clearSaveMessages: clearSaveMessages,
            //Obsolete functions
            showDataSaving: showSaveInProgress,
            showDataSavingError: showSaveError,
            showDataSavingSuccess: showSaveSuccess,
            showDataSavingClear: clearSaveMessages
        };
        this.onComplete.fire(this, onCompleteOptions);
        if (!previousCookie && this.surveyPostId) {
            this.sendResult();
        }
        if (!savingDataStarted) {
            this.navigateTo();
        }
    };
    SurveyModel.prototype.checkOnCompletingEvent = function (isCompleteOnTrigger, completeTrigger) {
        var options = {
            allowComplete: true,
            allow: true,
            isCompleteOnTrigger: isCompleteOnTrigger,
            completeTrigger: completeTrigger
        };
        this.onCompleting.fire(this, options);
        return options.allowComplete && options.allow;
    };
    /**
     * Starts the survey. Applies only if the survey has a [start page](https://surveyjs.io/form-library/documentation/design-survey/create-a-multi-page-survey#start-page).
     * @see firstPageIsStarted
     * @see completeLastPage
     */
    SurveyModel.prototype.start = function () {
        if (!this.firstPageIsStarted)
            return false;
        this.isCurrentPageRendering = true;
        if (this.checkIsPageHasErrors(this.startedPage, true))
            return false;
        this.isStartedState = false;
        this.notifyQuestionsOnHidingContent(this.pages[0]);
        this.startTimerFromUI();
        this.onStarted.fire(this, {});
        this.updateVisibleIndexes();
        if (!!this.currentPage) {
            this.currentPage.locStrsChanged();
        }
        return true;
    };
    Object.defineProperty(SurveyModel.prototype, "isValidatingOnServer", {
        /**
         * Indicates whether the current page is being [validated on a server](#onServerValidateQuestions).
         */
        get: function () {
            return this.getPropertyValue("isValidatingOnServer", false);
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.setIsValidatingOnServer = function (val) {
        if (val == this.isValidatingOnServer)
            return;
        this.setPropertyValue("isValidatingOnServer", val);
        this.onIsValidatingOnServerChanged();
    };
    SurveyModel.prototype.createServerValidationOptions = function (doComplete, isPreview) {
        var self = this;
        var options = {
            data: {},
            errors: {},
            survey: this,
            complete: function () {
                self.completeServerValidation(options, isPreview);
            },
        };
        if (doComplete && this.isValidateOnComplete) {
            options.data = this.data;
        }
        else {
            var questions = this.activePage.questions;
            for (var i = 0; i < questions.length; i++) {
                var question = questions[i];
                if (!question.visible)
                    continue;
                var value = this.getValue(question.getValueName());
                if (!this.isValueEmpty(value))
                    options.data[question.getValueName()] = value;
            }
        }
        return options;
    };
    SurveyModel.prototype.onIsValidatingOnServerChanged = function () { };
    SurveyModel.prototype.doServerValidation = function (doComplete, isPreview) {
        var _this = this;
        if (isPreview === void 0) { isPreview = false; }
        if (!this.onServerValidateQuestions ||
            this.onServerValidateQuestions.isEmpty)
            return false;
        if (!doComplete && this.isValidateOnComplete)
            return false;
        this.setIsValidatingOnServer(true);
        var isFunc = typeof this.onServerValidateQuestions === "function";
        this.serverValidationEventCount = !isFunc ? this.onServerValidateQuestions.length : 1;
        if (isFunc) {
            this.onServerValidateQuestions(this, this.createServerValidationOptions(doComplete, isPreview));
        }
        else {
            this.onServerValidateQuestions.fireByCreatingOptions(this, function () { return _this.createServerValidationOptions(doComplete, isPreview); });
        }
        return true;
    };
    SurveyModel.prototype.completeServerValidation = function (options, isPreview) {
        if (this.serverValidationEventCount > 1) {
            this.serverValidationEventCount--;
            if (!!options && !!options.errors && Object.keys(options.errors).length === 0)
                return;
        }
        this.serverValidationEventCount = 0;
        this.setIsValidatingOnServer(false);
        if (!options && !options.survey)
            return;
        var self = options.survey;
        var hasErrors = false;
        if (options.errors) {
            var hasToFocus = this.focusOnFirstError;
            for (var name in options.errors) {
                var question = self.getQuestionByName(name);
                if (question && question["errors"]) {
                    hasErrors = true;
                    question.addError(new CustomError(options.errors[name], this));
                    if (hasToFocus) {
                        hasToFocus = false;
                        if (!!question.page) {
                            this.currentPage = question.page;
                        }
                        question.focus(true);
                    }
                }
            }
            this.fireValidatedErrorsOnPage(this.currentPage);
        }
        if (!hasErrors) {
            if (isPreview) {
                this.showPreviewCore();
            }
            else {
                if (self.isLastPage)
                    self.doComplete();
                else
                    self.doNextPage();
            }
        }
    };
    SurveyModel.prototype.doNextPage = function () {
        var curPage = this.currentPage;
        this.checkOnPageTriggers(false);
        if (!this.isCompleted) {
            if (this.sendResultOnPageNext) {
                this.sendResult(this.surveyPostId, this.clientId, true);
            }
            if (curPage === this.currentPage) {
                var vPages = this.visiblePages;
                var index = vPages.indexOf(this.currentPage);
                this.currentPage = vPages[index + 1];
            }
        }
        else {
            this.doComplete(true);
        }
    };
    SurveyModel.prototype.setCompleted = function (trigger) {
        this.doComplete(true, trigger);
    };
    SurveyModel.prototype.canBeCompleted = function (trigger, isCompleted) {
        var _a;
        if (!settings.triggers.changeNavigationButtonsOnComplete)
            return;
        var prevCanBeCompleted = this.canBeCompletedByTrigger;
        if (!this.completedByTriggers)
            this.completedByTriggers = {};
        if (isCompleted) {
            this.completedByTriggers[trigger.id] = { trigger: trigger, pageId: (_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.id };
        }
        else {
            delete this.completedByTriggers[trigger.id];
        }
        if (prevCanBeCompleted !== this.canBeCompletedByTrigger) {
            this.updateButtonsVisibility();
        }
    };
    Object.defineProperty(SurveyModel.prototype, "canBeCompletedByTrigger", {
        get: function () {
            var _a;
            if (!this.completedByTriggers)
                return false;
            var keys = Object.keys(this.completedByTriggers);
            if (keys.length === 0)
                return false;
            var id = (_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.id;
            if (!id)
                return true;
            for (var i = 0; i < keys.length; i++) {
                if (id === this.completedByTriggers[keys[i]].pageId)
                    return true;
            }
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "completedTrigger", {
        get: function () {
            if (!this.canBeCompletedByTrigger)
                return undefined;
            var key = Object.keys(this.completedByTriggers)[0];
            return this.completedByTriggers[key].trigger;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "processedCompletedHtml", {
        /**
         * Returns HTML content displayed on the [complete page](https://surveyjs.io/form-library/documentation/design-survey/create-a-multi-page-survey#complete-page).
         *
         * To specify HTML content, use the [`completedHtml`](#completedHtml) property.
         */
        get: function () {
            var html = this.renderedCompletedHtml;
            return !!html ? this.processHtml(html, "completed") : "";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "processedCompletedBeforeHtml", {
        /**
         * Returns HTML content displayed to a user who has completed the survey before. To identify such users, the survey uses a [cookie name](#cookieName) or [client ID](#clientId).
         *
         * To specify HTML content, use the [`completedBeforeHtml`](#completedBeforeHtml) property.
         */
        get: function () {
            return this.locCompletedBeforeHtml.textOrHtml;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "processedLoadingHtml", {
        /**
         * Returns HTML content displayed while a survey JSON schema is being loaded from [SurveyJS Service](https://api.surveyjs.io).
         *
         * To specify HTML content, use the [`loadingHtml`](#loadingHtml) property.
         */
        get: function () {
            return this.locLoadingHtml.textOrHtml;
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.getProgressInfo = function () {
        var pages = this.isDesignMode ? this.pages : this.visiblePages;
        return survey_element_SurveyElement.getProgressInfoByElements(pages, false);
    };
    Object.defineProperty(SurveyModel.prototype, "progressText", {
        /**
         * Returns text displayed by the progress bar (for instance, "Page 2 of 3" or "Answered 3/8 questions"). Handle the [`onProgressText`](#onProgressText) event to change this text.
         * @see progressValue
         * @see showProgressBar
         * @see progressBarType
         */
        get: function () {
            var res = this.getPropertyValue("progressText", "");
            if (!res) {
                this.updateProgressText();
                res = this.getPropertyValue("progressText", "");
            }
            return res;
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.updateProgressText = function (onValueChanged) {
        if (onValueChanged === void 0) { onValueChanged = false; }
        if (this.isCalculatingProgressText || this.isShowingPreview || this.isLockingUpdateOnPageModes)
            return;
        if (onValueChanged &&
            this.progressBarType == "pages" &&
            this.onProgressText.isEmpty)
            return;
        this.isCalculatingProgressText = true;
        this.setPropertyValue("progressText", this.getProgressText());
        this.setPropertyValue("progressValue", this.getProgress());
        this.isCalculatingProgressText = false;
    };
    SurveyModel.prototype.getProgressText = function () {
        if (!this.isDesignMode && this.currentPage == null)
            return "";
        var options = {
            questionCount: 0,
            answeredQuestionCount: 0,
            requiredQuestionCount: 0,
            requiredAnsweredQuestionCount: 0,
            text: "",
        };
        var type = this.progressBarType.toLowerCase();
        if (type === "questions" ||
            type === "requiredquestions" ||
            type === "correctquestions" ||
            !this.onProgressText.isEmpty) {
            var info = this.getProgressInfo();
            options.questionCount = info.questionCount;
            options.answeredQuestionCount = info.answeredQuestionCount;
            options.requiredQuestionCount = info.requiredQuestionCount;
            options.requiredAnsweredQuestionCount =
                info.requiredAnsweredQuestionCount;
        }
        options.text = this.getProgressTextCore(options);
        this.onProgressText.fire(this, options);
        return options.text;
    };
    SurveyModel.prototype.getProgressTextCore = function (info) {
        var type = this.progressBarType.toLowerCase();
        if (type === "questions") {
            return this.getLocalizationFormatString("questionsProgressText", info.answeredQuestionCount, info.questionCount);
        }
        if (type === "requiredquestions") {
            return this.getLocalizationFormatString("questionsProgressText", info.requiredAnsweredQuestionCount, info.requiredQuestionCount);
        }
        if (type === "correctquestions") {
            var correctAnswersCount = this.getCorrectedAnswerCount();
            return this.getLocalizationFormatString("questionsProgressText", correctAnswersCount, info.questionCount);
        }
        var vPages = this.isDesignMode ? this.pages : this.visiblePages;
        var index = vPages.indexOf(this.currentPage) + 1;
        return this.getLocalizationFormatString("progressText", index, vPages.length);
    };
    SurveyModel.prototype.getRootCss = function () {
        return new CssClassBuilder()
            .append(this.css.root)
            .append(this.css.rootProgress + "--" + this.progressBarType)
            .append(this.css.rootMobile, this.isMobile)
            .append(this.css.rootAnimationDisabled, !settings.animationEnabled)
            .append(this.css.rootReadOnly, this.mode === "display" && !this.isDesignMode)
            .append(this.css.rootCompact, this.isCompact)
            .append(this.css.rootFitToContainer, this.fitToContainer)
            .toString();
    };
    SurveyModel.prototype.afterRenderSurvey = function (htmlElement) {
        var _this = this;
        this.destroyResizeObserver();
        if (Array.isArray(htmlElement)) {
            htmlElement = survey_element_SurveyElement.GetFirstNonTextElement(htmlElement);
        }
        var observedElement = htmlElement;
        var cssVariables = this.css.variables;
        if (!!cssVariables) {
            var mobileWidth_1 = Number.parseFloat(DomDocumentHelper.getComputedStyle(observedElement).getPropertyValue(cssVariables.mobileWidth));
            if (!!mobileWidth_1) {
                var isProcessed_1 = false;
                this.resizeObserver = new ResizeObserver(function (entries) {
                    DomWindowHelper.requestAnimationFrame(function () {
                        if (isProcessed_1 || !isContainerVisible(observedElement)) {
                            isProcessed_1 = false;
                        }
                        else {
                            isProcessed_1 = _this.processResponsiveness(observedElement.offsetWidth, mobileWidth_1);
                        }
                    });
                });
                this.resizeObserver.observe(observedElement);
            }
        }
        this.onAfterRenderSurvey.fire(this, {
            survey: this,
            htmlElement: htmlElement,
        });
        this.rootElement = htmlElement;
        this.addScrollEventListener();
    };
    SurveyModel.prototype.processResponsiveness = function (width, mobileWidth) {
        var isMobile = width < mobileWidth;
        var isMobileChanged = this.isMobile !== isMobile;
        if (isMobileChanged) {
            this.setIsMobile(isMobile);
        }
        this.layoutElements.forEach(function (layoutElement) { return layoutElement.processResponsiveness && layoutElement.processResponsiveness(width); });
        return isMobileChanged;
    };
    SurveyModel.prototype.triggerResponsiveness = function (hard) {
        this.getAllQuestions().forEach(function (question) {
            question.triggerResponsiveness(hard);
        });
    };
    SurveyModel.prototype.destroyResizeObserver = function () {
        if (!!this.resizeObserver) {
            this.resizeObserver.disconnect();
            this.resizeObserver = undefined;
        }
    };
    SurveyModel.prototype.updateQuestionCssClasses = function (question, cssClasses) {
        this.onUpdateQuestionCssClasses.fire(this, {
            question: question,
            cssClasses: cssClasses,
        });
    };
    SurveyModel.prototype.updatePanelCssClasses = function (panel, cssClasses) {
        this.onUpdatePanelCssClasses.fire(this, {
            panel: panel,
            cssClasses: cssClasses,
        });
    };
    SurveyModel.prototype.updatePageCssClasses = function (page, cssClasses) {
        this.onUpdatePageCssClasses.fire(this, {
            page: page,
            cssClasses: cssClasses,
        });
    };
    SurveyModel.prototype.updateChoiceItemCss = function (question, options) {
        options.question = question;
        this.onUpdateChoiceItemCss.fire(this, options);
    };
    SurveyModel.prototype.afterRenderPage = function (htmlElement) {
        var _this = this;
        if (!this.isDesignMode && !this.focusingQuestionInfo) {
            var doScroll_1 = this.isCurrentPageRendered === false;
            setTimeout(function () { return _this.scrollToTopOnPageChange(doScroll_1); }, 1);
        }
        this.focusQuestionInfo();
        this.isCurrentPageRendered = true;
        if (this.onAfterRenderPage.isEmpty)
            return;
        this.onAfterRenderPage.fire(this, {
            page: this.activePage,
            htmlElement: htmlElement,
        });
    };
    SurveyModel.prototype.afterRenderHeader = function (htmlElement) {
        if (this.onAfterRenderHeader.isEmpty)
            return;
        this.onAfterRenderHeader.fire(this, {
            htmlElement: htmlElement,
        });
    };
    SurveyModel.prototype.afterRenderQuestion = function (question, htmlElement) {
        this.onAfterRenderQuestion.fire(this, {
            question: question,
            htmlElement: htmlElement,
        });
    };
    SurveyModel.prototype.afterRenderQuestionInput = function (question, htmlElement) {
        if (this.onAfterRenderQuestionInput.isEmpty)
            return;
        var id = question.inputId;
        var root = settings.environment.root;
        if (!!id && htmlElement.id !== id && typeof root !== "undefined") {
            var el = root.getElementById(id);
            if (!!el) {
                htmlElement = el;
            }
        }
        this.onAfterRenderQuestionInput.fire(this, {
            question: question,
            htmlElement: htmlElement,
        });
    };
    SurveyModel.prototype.afterRenderPanel = function (panel, htmlElement) {
        this.onAfterRenderPanel.fire(this, {
            panel: panel,
            htmlElement: htmlElement,
        });
    };
    SurveyModel.prototype.whenQuestionFocusIn = function (question) {
        this.onFocusInQuestion.fire(this, {
            question: question
        });
    };
    SurveyModel.prototype.whenPanelFocusIn = function (panel) {
        this.onFocusInPanel.fire(this, {
            panel: panel
        });
    };
    SurveyModel.prototype.rebuildQuestionChoices = function () {
        this.getAllQuestions().forEach(function (q) { return q.surveyChoiceItemVisibilityChange(); });
    };
    SurveyModel.prototype.canChangeChoiceItemsVisibility = function () {
        return !this.onShowingChoiceItem.isEmpty;
    };
    SurveyModel.prototype.getChoiceItemVisibility = function (question, item, val) {
        var options = { question: question, item: item, visible: val };
        this.onShowingChoiceItem.fire(this, options);
        return options.visible;
    };
    SurveyModel.prototype.loadQuestionChoices = function (options) {
        this.onChoicesLazyLoad.fire(this, options);
    };
    SurveyModel.prototype.getChoiceDisplayValue = function (options) {
        if (this.onGetChoiceDisplayValue.isEmpty) {
            options.setItems(null);
        }
        else {
            this.onGetChoiceDisplayValue.fire(this, options);
        }
    };
    SurveyModel.prototype.matrixBeforeRowAdded = function (options) {
        this.onMatrixRowAdding.fire(this, options);
    };
    SurveyModel.prototype.matrixRowAdded = function (question, row) {
        this.onMatrixRowAdded.fire(this, { question: question, row: row });
    };
    SurveyModel.prototype.matrixColumnAdded = function (question, column) {
        this.onMatrixColumnAdded.fire(this, { question: question, column: column });
    };
    SurveyModel.prototype.multipleTextItemAdded = function (question, item) {
        this.onMultipleTextItemAdded.fire(this, { question: question, item: item });
    };
    SurveyModel.prototype.getQuestionByValueNameFromArray = function (valueName, name, index) {
        var questions = this.getQuestionsByValueName(valueName);
        if (!questions)
            return;
        for (var i = 0; i < questions.length; i++) {
            var res = questions[i].getQuestionFromArray(name, index);
            if (!!res)
                return res;
        }
        return null;
    };
    SurveyModel.prototype.matrixRowRemoved = function (question, rowIndex, row) {
        this.onMatrixRowRemoved.fire(this, {
            question: question,
            rowIndex: rowIndex,
            row: row,
        });
    };
    SurveyModel.prototype.matrixRowRemoving = function (question, rowIndex, row) {
        var options = {
            question: question,
            rowIndex: rowIndex,
            row: row,
            allow: true,
        };
        this.onMatrixRowRemoving.fire(this, options);
        return options.allow;
    };
    SurveyModel.prototype.matrixAllowRemoveRow = function (question, rowIndex, row) {
        var options = { question: question, rowIndex: rowIndex, row: row, allow: true };
        this.onMatrixRenderRemoveButton.fire(this, options);
        return options.allow;
    };
    SurveyModel.prototype.matrixDetailPanelVisibleChanged = function (question, rowIndex, row, visible) {
        var options = { question: question, rowIndex: rowIndex, row: row, visible: visible, detailPanel: row.detailPanel };
        this.onMatrixDetailPanelVisibleChanged.fire(this, options);
    };
    SurveyModel.prototype.matrixCellCreating = function (question, options) {
        options.question = question;
        this.onMatrixCellCreating.fire(this, options);
    };
    SurveyModel.prototype.matrixCellCreated = function (question, options) {
        options.question = question;
        this.onMatrixCellCreated.fire(this, options);
    };
    SurveyModel.prototype.matrixAfterCellRender = function (question, options) {
        options.question = question;
        this.onAfterRenderMatrixCell.fire(this, options);
    };
    SurveyModel.prototype.matrixCellValueChanged = function (question, options) {
        options.question = question;
        this.onMatrixCellValueChanged.fire(this, options);
    };
    SurveyModel.prototype.matrixCellValueChanging = function (question, options) {
        options.question = question;
        this.onMatrixCellValueChanging.fire(this, options);
    };
    Object.defineProperty(SurveyModel.prototype, "isValidateOnValueChanging", {
        get: function () {
            return this.checkErrorsMode === "onValueChanging";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isValidateOnValueChanged", {
        get: function () {
            return this.checkErrorsMode === "onValueChanged";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isValidateOnValueChange", {
        get: function () {
            return this.isValidateOnValueChanged || this.isValidateOnValueChanging;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isValidateOnComplete", {
        get: function () {
            return this.checkErrorsMode === "onComplete" || this.validationAllowSwitchPages && !this.validationAllowComplete;
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.matrixCellValidate = function (question, options) {
        options.question = question;
        this.onMatrixCellValidate.fire(this, options);
        return options.error ? new CustomError(options.error, this) : null;
    };
    SurveyModel.prototype.dynamicPanelAdded = function (question, panelIndex, panel) {
        if (!this.isLoadingFromJson) {
            this.updateVisibleIndexes();
        }
        if (this.onDynamicPanelAdded.isEmpty)
            return;
        var panels = question.panels;
        if (panelIndex === undefined) {
            panelIndex = panels.length - 1;
            panel = panels[panelIndex];
        }
        this.onDynamicPanelAdded.fire(this, { question: question, panel: panel, panelIndex: panelIndex });
    };
    SurveyModel.prototype.dynamicPanelRemoved = function (question, panelIndex, panel) {
        var questions = !!panel ? panel.questions : [];
        for (var i = 0; i < questions.length; i++) {
            questions[i].clearOnDeletingContainer();
        }
        this.updateVisibleIndexes();
        this.onDynamicPanelRemoved.fire(this, {
            question: question,
            panelIndex: panelIndex,
            panel: panel,
        });
    };
    SurveyModel.prototype.dynamicPanelRemoving = function (question, panelIndex, panel) {
        var options = {
            question: question,
            panelIndex: panelIndex,
            panel: panel,
            allow: true
        };
        this.onDynamicPanelRemoving.fire(this, options);
        return options.allow;
    };
    SurveyModel.prototype.dynamicPanelItemValueChanged = function (question, options) {
        options.question = question;
        options.panelIndex = options.itemIndex;
        options.panelData = options.itemValue;
        this.onDynamicPanelItemValueChanged.fire(this, options);
    };
    SurveyModel.prototype.dynamicPanelGetTabTitle = function (question, options) {
        options.question = question;
        this.onGetDynamicPanelTabTitle.fire(this, options);
    };
    SurveyModel.prototype.dynamicPanelCurrentIndexChanged = function (question, options) {
        options.question = question;
        this.onDynamicPanelCurrentIndexChanged.fire(this, options);
    };
    SurveyModel.prototype.dragAndDropAllow = function (options) {
        this.onDragDropAllow.fire(this, options);
        return options.allow;
    };
    SurveyModel.prototype.elementContentVisibilityChanged = function (element) {
        if (this.currentPage) {
            this.currentPage.ensureRowsVisibility();
        }
        this.onElementContentVisibilityChanged.fire(this, { element: element });
    };
    SurveyModel.prototype.getUpdatedPanelFooterActions = function (panel, actions, question) {
        var options = {
            question: question,
            panel: panel,
            actions: actions,
        };
        this.onGetPanelFooterActions.fire(this, options);
        return options.actions;
    };
    SurveyModel.prototype.getUpdatedElementTitleActions = function (element, titleActions) {
        if (element.isPage)
            return this.getUpdatedPageTitleActions(element, titleActions);
        if (element.isPanel)
            return this.getUpdatedPanelTitleActions(element, titleActions);
        return this.getUpdatedQuestionTitleActions(element, titleActions);
    };
    SurveyModel.prototype.getUpdatedQuestionTitleActions = function (question, titleActions) {
        var options = {
            question: question,
            titleActions: titleActions,
        };
        this.onGetQuestionTitleActions.fire(this, options);
        return options.titleActions;
    };
    SurveyModel.prototype.getUpdatedPanelTitleActions = function (panel, titleActions) {
        var options = {
            panel: panel,
            titleActions: titleActions,
        };
        this.onGetPanelTitleActions.fire(this, options);
        return options.titleActions;
    };
    SurveyModel.prototype.getUpdatedPageTitleActions = function (page, titleActions) {
        var options = {
            page: page,
            titleActions: titleActions,
        };
        this.onGetPageTitleActions.fire(this, options);
        return options.titleActions;
    };
    SurveyModel.prototype.getUpdatedMatrixRowActions = function (question, row, actions) {
        var options = {
            question: question,
            actions: actions,
            row: row,
        };
        this.onGetMatrixRowActions.fire(this, options);
        return options.actions;
    };
    SurveyModel.prototype.scrollElementToTop = function (element, question, page, id, scrollIfVisible, scrollIntoViewOptions) {
        var options = {
            element: element,
            question: question,
            page: page,
            elementId: id,
            cancel: false,
        };
        this.onScrollingElementToTop.fire(this, options);
        if (!options.cancel) {
            survey_element_SurveyElement.ScrollElementToTop(options.elementId, scrollIfVisible, scrollIntoViewOptions);
        }
    };
    /**
     * Opens a dialog window for users to select files.
     * @param input A [file input HTML element](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement).
     * @param callback A callback function that you can use to process selected files. Accepts an array of JavaScript <a href="https://developer.mozilla.org/en-US/docs/Web/API/File" target="_blank">File</a> objects.
     * @see onOpenFileChooser
     * @see onUploadFile
     */
    SurveyModel.prototype.chooseFiles = function (input, callback, context) {
        if (this.onOpenFileChooser.isEmpty) {
            chooseFiles(input, callback);
        }
        else {
            this.onOpenFileChooser.fire(this, {
                input: input,
                element: context && context.element || this.survey,
                elementType: context && context.elementType,
                item: context && context.item,
                propertyName: context && context.propertyName,
                callback: callback,
                context: context
            });
        }
    };
    /**
     * Uploads files to a server.
     *
     * The following code shows how to call this method:
     *
     * ```js
     * const question = survey.getQuestionByName("myFileQuestion");
     * survey.uploadFiles(
     *   question,
     *   question.name,
     *   question.value,
     *   (data, errors) => {
     *     // ...
     *   }
     * );
     * ```
     * @param question A [File Upload question instance](https://surveyjs.io/form-library/documentation/api-reference/file-model) or [Signature Pad question instance](https://surveyjs.io/form-library/documentation/api-reference/signature-pad-model).
     * @param name The File Upload question's [`name`](https://surveyjs.io/form-library/documentation/api-reference/file-model#name) or Signature Pad question's [`name`](https://surveyjs.io/form-library/documentation/api-reference/signature-pad-model#name).
     * @param files An array of JavaScript <a href="https://developer.mozilla.org/en-US/docs/Web/API/File" target="_blank">File</a> objects that represent files to upload.
     * @param callback A callback function that allows you to access successfully uploaded files as the first argument. If any files fail to upload, the second argument contains an array of error messages.
     * @see onUploadFiles
     * @see downloadFile
     */
    SurveyModel.prototype.uploadFiles = function (question, name, files, callback) {
        var _this = this;
        if (this.onUploadFiles.isEmpty) {
            callback("error", this.getLocString("noUploadFilesHandler"));
        }
        else {
            this.taskManager.runTask("file", function (done) {
                _this.onUploadFiles.fire(_this, {
                    question: question,
                    name: name,
                    files: files || [],
                    callback: function (status, data) {
                        callback(status, data);
                        done();
                    },
                });
            });
        }
        if (this.surveyPostId) {
            this.uploadFilesCore(name, files, callback);
        }
    };
    /**
     * Downloads a file from a server.
     *
     * The following code shows how to call this method:
     *
     * ```js
     * const question = survey.getQuestionByName("myFileQuestion");
     * survey.downloadFile(
     *   question,
     *   question.name,
     *   // Download the first uploaded file
     *   question.value[0],
     *   (status, data) => {
     *     if (status === "success") {
     *       // Use `data` to retrieve the file
     *     }
     *     if (status === "error") {
     *       // Handle error
     *     }
     *   }
     * );
     * ```
     *
     * @param question A [File Upload question instance](https://surveyjs.io/form-library/documentation/api-reference/file-model).
     * @param questionName The File Upload question's [`name`](https://surveyjs.io/form-library/documentation/api-reference/file-model#name).
     * @param fileValue An object from File Upload's [`value`](https://surveyjs.io/form-library/documentation/api-reference/file-model#value) array. This object contains metadata about the file you want to download.
     * @param callback A callback function that allows you to get the download status (`"success"` or `"error"`) and the file identifier (URL, file name, etc.) that you can use to retrieve the file.
     * @see onDownloadFile
     * @see uploadFiles
     */
    SurveyModel.prototype.downloadFile = function (question, questionName, fileValue, callback) {
        if (this.onDownloadFile.isEmpty) {
            !!callback && callback("skipped", fileValue.content || fileValue);
        }
        this.onDownloadFile.fire(this, {
            question: question,
            name: questionName,
            content: fileValue.content || fileValue,
            fileValue: fileValue,
            callback: callback,
        });
    };
    SurveyModel.prototype.clearFiles = function (question, name, value, fileName, callback) {
        if (this.onClearFiles.isEmpty) {
            !!callback && callback("success", value);
        }
        this.onClearFiles.fire(this, {
            question: question,
            name: name,
            value: value,
            fileName: fileName,
            callback: callback,
        });
    };
    SurveyModel.prototype.updateChoicesFromServer = function (question, choices, serverResult) {
        var options = {
            question: question,
            choices: choices,
            serverResult: serverResult,
        };
        this.onLoadChoicesFromServer.fire(this, options);
        return options.choices;
    };
    SurveyModel.prototype.loadedChoicesFromServer = function (question) {
        this.locStrsChanged();
    };
    SurveyModel.prototype.createSurveyService = function () {
        return new dxSurveyService_dxSurveyService();
    };
    SurveyModel.prototype.uploadFilesCore = function (name, files, uploadingCallback) {
        var _this = this;
        var responses = [];
        files.forEach(function (file) {
            if (uploadingCallback)
                uploadingCallback("uploading", file);
            _this.createSurveyService().sendFile(_this.surveyPostId, file, function (success, response) {
                if (success) {
                    responses.push({ content: response, file: file });
                    if (responses.length === files.length) {
                        if (uploadingCallback)
                            uploadingCallback("success", responses);
                    }
                }
                else {
                    if (uploadingCallback)
                        uploadingCallback("error", {
                            response: response,
                            file: file,
                        });
                }
            });
        });
    };
    SurveyModel.prototype.getPage = function (index) {
        return this.pages[index];
    };
    /**
     * Adds an existing page to the survey.
     * @param page A page to add.
     * @param index An index at which to insert the page. If you do not specify this parameter, the page will be added to the end.
     * @see addNewPage
     * @see createNewPage
     */
    SurveyModel.prototype.addPage = function (page, index) {
        if (index === void 0) { index = -1; }
        if (page == null)
            return;
        if (index < 0 || index >= this.pages.length) {
            this.pages.push(page);
        }
        else {
            this.pages.splice(index, 0, page);
        }
    };
    /**
     * Creates a new page and adds it to the survey.
     *
     * If you want to switch a survey to the newly added page, assign its index to the [`currentPageNo`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#currentPageNo) property or assign the entire page to the [`currentPage`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#currentPage) property.
     *
     * @param name A page name. If you do not specify this parameter, it will be generated automatically.
     * @param index An index at which to insert the page. If you do not specify this parameter, the page will be added to the end.
     * @returns The created and added page.
     * @see addPage
     * @see createNewPage
     */
    SurveyModel.prototype.addNewPage = function (name, index) {
        if (name === void 0) { name = null; }
        if (index === void 0) { index = -1; }
        var page = this.createNewPage(name);
        this.addPage(page, index);
        return page;
    };
    /**
     * Removes a page from the survey.
     *
     * Pass a `PageModel` object to this method. You can get this object in different ways. For example, you can call the [`getPageByName()`](#getPageByName) method to obtain a `PageModel` object with a specific name or use the [`currentPage`](#currentPage) property to access and delete the current page, as shown in the code below.
     *
     * ```js
     * // Delete the current page
     * survey.removePage(survey.currentPage);
     * ```
     * @param page A page to remove.
     * @see addNewPage
     */
    SurveyModel.prototype.removePage = function (page) {
        var index = this.pages.indexOf(page);
        if (index < 0)
            return;
        this.pages.splice(index, 1);
        if (this.currentPage == page) {
            this.currentPage = this.pages.length > 0 ? this.pages[0] : null;
        }
    };
    /**
     * Returns a question with a specified [`name`](https://surveyjs.io/form-library/documentation/api-reference/question#name).
     * @param name A question name
     * @param caseInsensitive *(Optional)* A Boolean value that specifies case sensitivity when searching for the question. Default value: `false` (uppercase and lowercase letters are treated as distinct).
     * @returns A question with a specified name.
     * @see getAllQuestions
     * @see getQuestionByValueName
     */
    SurveyModel.prototype.getQuestionByName = function (name, caseInsensitive) {
        if (caseInsensitive === void 0) { caseInsensitive = false; }
        if (!name)
            return null;
        if (caseInsensitive) {
            name = name.toLowerCase();
        }
        var hash = !!caseInsensitive
            ? this.questionHashes.namesInsensitive
            : this.questionHashes.names;
        var res = hash[name];
        if (!res)
            return null;
        return res[0];
    };
    SurveyModel.prototype.findQuestionByName = function (name) {
        return this.getQuestionByName(name);
    };
    SurveyModel.prototype.getEditingSurveyElement = function () { return this.editingObjValue; };
    /**
     * Returns a question with a specified [`valueName`](https://surveyjs.io/form-library/documentation/api-reference/question#valueName).
     *
     * > Since `valueName` does not have to be unique, multiple questions can have the same `valueName` value. In this case, the `getQuestionByValueName()` method returns the first such question. If you need to get all questions with the same `valueName`, call the `getQuestionsByValueName()` method.
     * @param valueName A question's `valueName` property value.
     * @param caseInsensitive *(Optional)* A Boolean value that specifies case sensitivity when searching for the question. Default value: `false` (uppercase and lowercase letters are treated as distinct).
     * @returns A question with a specified `valueName`.
     * @see getAllQuestions
     * @see getQuestionByName
     */
    SurveyModel.prototype.getQuestionByValueName = function (valueName, caseInsensitive) {
        if (caseInsensitive === void 0) { caseInsensitive = false; }
        var res = this.getQuestionsByValueName(valueName, caseInsensitive);
        return !!res ? res[0] : null;
    };
    /**
     * Returns all questions with a specified [`valueName`](https://surveyjs.io/form-library/documentation/api-reference/question#valueName). If a question's `valueName` is undefined, its [`name`](https://surveyjs.io/form-library/documentation/api-reference/question#name) property is used.
     * @param valueName A question's `valueName` property value.
     * @param caseInsensitive *(Optional)* A Boolean value that specifies case sensitivity when searching for the questions. Default value: `false` (uppercase and lowercase letters are treated as distinct).
     * @returns An array of questions with a specified `valueName`.
     * @see getAllQuestions
     * @see getQuestionByName
     */
    SurveyModel.prototype.getQuestionsByValueName = function (valueName, caseInsensitive) {
        if (caseInsensitive === void 0) { caseInsensitive = false; }
        var hash = !!caseInsensitive
            ? this.questionHashes.valueNamesInsensitive
            : this.questionHashes.valueNames;
        var res = hash[valueName];
        if (!res)
            return null;
        return res;
    };
    SurveyModel.prototype.getCalculatedValueByName = function (name) {
        for (var i = 0; i < this.calculatedValues.length; i++) {
            if (name == this.calculatedValues[i].name)
                return this.calculatedValues[i];
        }
        return null;
    };
    /**
     * Returns an array of questions with specified [names](https://surveyjs.io/form-library/documentation/api-reference/question#name).
     * @param names An array of question names.
     * @param caseInsensitive *(Optional)* A Boolean value that specifies case sensitivity when searching for the questions. Default value: `false` (uppercase and lowercase letters are treated as distinct).
     * @returns An array of questions with specified names
     * @see getAllQuestions
     */
    SurveyModel.prototype.getQuestionsByNames = function (names, caseInsensitive) {
        if (caseInsensitive === void 0) { caseInsensitive = false; }
        var result = [];
        if (!names)
            return result;
        for (var i = 0; i < names.length; i++) {
            if (!names[i])
                continue;
            var question = this.getQuestionByName(names[i], caseInsensitive);
            if (question)
                result.push(question);
        }
        return result;
    };
    /**
     * Returns a page to which a specified survey element (question or panel) belongs.
     * @param element A question or panel instance.
     */
    SurveyModel.prototype.getPageByElement = function (element) {
        for (var i = 0; i < this.pages.length; i++) {
            var page = this.pages[i];
            if (page.containsElement(element))
                return page;
        }
        return null;
    };
    /**
     * Returns a page to which a specified question belongs.
     * @param question A question instance.
     */
    SurveyModel.prototype.getPageByQuestion = function (question) {
        return this.getPageByElement(question);
    };
    /**
     * Returns a page with a specified name.
     * @param name A page [name](https://surveyjs.io/form-library/documentation/api-reference/page-model#name).
     */
    SurveyModel.prototype.getPageByName = function (name) {
        for (var i = 0; i < this.pages.length; i++) {
            if (this.pages[i].name == name)
                return this.pages[i];
        }
        return null;
    };
    /**
     * Returns an array of pages with specified names.
     * @param names An array of page names.
     */
    SurveyModel.prototype.getPagesByNames = function (names) {
        var result = [];
        if (!names)
            return result;
        for (var i = 0; i < names.length; i++) {
            if (!names[i])
                continue;
            var page = this.getPageByName(names[i]);
            if (page)
                result.push(page);
        }
        return result;
    };
    /**
     * Returns a list of all [questions](https://surveyjs.io/form-library/documentation/api-reference/question) in the survey.
     * @param visibleOnly A Boolean value that specifies whether to include only visible questions.
     * @param includeDesignTime For internal use.
     * @param includeNested A Boolean value that specifies whether to include nested questions, such as questions within matrix cells.
     * @returns An array of questions.
     * @see getQuestionByName
     */
    SurveyModel.prototype.getAllQuestions = function (visibleOnly, includeDesignTime, includeNested) {
        if (visibleOnly === void 0) { visibleOnly = false; }
        if (includeDesignTime === void 0) { includeDesignTime = false; }
        if (includeNested === void 0) { includeNested = false; }
        if (includeNested)
            includeDesignTime = false;
        var res = [];
        for (var i = 0; i < this.pages.length; i++) {
            this.pages[i].addQuestionsToList(res, visibleOnly, includeDesignTime);
        }
        if (!includeNested)
            return res;
        var res2 = [];
        res.forEach(function (q) {
            res2.push(q);
            q.getNestedQuestions(visibleOnly).forEach(function (nQ) { return res2.push(nQ); });
        });
        return res2;
    };
    /**
     * Returns an array of quiz questions. A question counts if it is visible, has an input field, and specifies [`correctAnswer`](https://surveyjs.io/form-library/documentation/api-reference/checkbox-question-model#correctAnswer).
     *
     * For more information about quizzes, refer to the following tutorial: [Create a Quiz](https://surveyjs.io/form-library/documentation/design-survey/create-a-quiz).
     * @returns An array of quiz questions.
     * @see getQuizQuestionCount
     */
    SurveyModel.prototype.getQuizQuestions = function () {
        var result = new Array();
        var startIndex = this.getPageStartIndex();
        for (var i = startIndex; i < this.pages.length; i++) {
            if (!this.pages[i].isVisible)
                continue;
            var questions = this.pages[i].questions;
            for (var j = 0; j < questions.length; j++) {
                var q = questions[j];
                if (q.quizQuestionCount > 0) {
                    result.push(q);
                }
            }
        }
        return result;
    };
    /**
     * Returns a [panel](https://surveyjs.io/form-library/documentation/api-reference/panel-model) with a specified [`name`](https://surveyjs.io/form-library/documentation/api-reference/panel-model#name).
     * @param name A panel name.
     * @param caseInsensitive *(Optional)* A Boolean value that specifies case sensitivity when searching for the panel. Default value: `false` (uppercase and lowercase letters are treated as distinct).
     * @returns A panel with a specified name.
     * @see getAllPanels
     */
    SurveyModel.prototype.getPanelByName = function (name, caseInsensitive) {
        if (caseInsensitive === void 0) { caseInsensitive = false; }
        var panels = this.getAllPanels();
        if (caseInsensitive)
            name = name.toLowerCase();
        for (var i = 0; i < panels.length; i++) {
            var panelName = panels[i].name;
            if (caseInsensitive)
                panelName = panelName.toLowerCase();
            if (panelName == name)
                return panels[i];
        }
        return null;
    };
    /**
     * Returns a list of all [panels](https://surveyjs.io/form-library/documentation/api-reference/panel-model) in the survey.
     * @param visibleOnly A Boolean value that specifies whether to include only visible panels.
     * @param includeDesignTime For internal use.
     * @returns An array of panels.
     * @see getPanelByName
     */
    SurveyModel.prototype.getAllPanels = function (visibleOnly, includeDesignTime) {
        if (visibleOnly === void 0) { visibleOnly = false; }
        if (includeDesignTime === void 0) { includeDesignTime = false; }
        var result = new Array();
        for (var i = 0; i < this.pages.length; i++) {
            this.pages[i].addPanelsIntoList(result, visibleOnly, includeDesignTime);
        }
        return result;
    };
    /**
     * Creates and returns a new page but does not add it to the survey.
     *
     * Call the [`addPage(page)`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#addPage) method to add the created page to the survey later or the [`addNewPage(name, index)`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#addNewPage) method to create _and_ add a page to the survey.
     * @see addPage
     * @see addNewPage
     */
    SurveyModel.prototype.createNewPage = function (name) {
        var page = Serializer.createClass("page");
        page.name = name;
        return page;
    };
    SurveyModel.prototype.questionOnValueChanging = function (valueName, newValue, questionValueName) {
        if (!!this.editingObj) {
            var prop = Serializer.findProperty(this.editingObj.getType(), valueName);
            if (!!prop)
                newValue = prop.settingValue(this.editingObj, newValue);
        }
        if (this.onValueChanging.isEmpty)
            return newValue;
        var options = {
            name: valueName,
            question: this.getQuestionByValueName(questionValueName || valueName),
            value: this.getUnbindValue(newValue),
            oldValue: this.getValue(valueName),
        };
        this.onValueChanging.fire(this, options);
        return options.value;
    };
    SurveyModel.prototype.updateQuestionValue = function (valueName, newValue) {
        if (this.isLoadingFromJson)
            return;
        var questions = this.getQuestionsByValueName(valueName);
        if (!!questions) {
            for (var i = 0; i < questions.length; i++) {
                var qValue = questions[i].value;
                if ((qValue === newValue && Array.isArray(qValue) && !!this.editingObj) ||
                    !this.isTwoValueEquals(qValue, newValue)) {
                    questions[i].updateValueFromSurvey(newValue, false);
                }
            }
        }
    };
    SurveyModel.prototype.checkQuestionErrorOnValueChanged = function (question) {
        if (!this.isNavigationButtonPressed &&
            (this.isValidateOnValueChanged ||
                question.getAllErrors().length > 0)) {
            this.checkQuestionErrorOnValueChangedCore(question);
        }
    };
    SurveyModel.prototype.checkQuestionErrorOnValueChangedCore = function (question) {
        var oldErrorCount = question.getAllErrors().length;
        var res = !question.validate(true, {
            isOnValueChanged: !this.isValidateOnValueChanging,
        });
        if (!!question.page && this.isValidateOnValueChange &&
            (oldErrorCount > 0 || question.getAllErrors().length > 0)) {
            this.fireValidatedErrorsOnPage(question.page);
        }
        return res;
    };
    SurveyModel.prototype.checkErrorsOnValueChanging = function (valueName, newValue) {
        if (this.isLoadingFromJson)
            return false;
        var questions = this.getQuestionsByValueName(valueName);
        if (!questions)
            return false;
        var res = false;
        for (var i = 0; i < questions.length; i++) {
            var q = questions[i];
            if (!this.isTwoValueEquals(q.valueForSurvey, newValue)) {
                q.value = newValue;
            }
            if (this.checkQuestionErrorOnValueChangedCore(q))
                res = true;
            res = res || q.errors.length > 0;
        }
        return res;
    };
    SurveyModel.prototype.notifyQuestionOnValueChanged = function (valueName, newValue, questionName) {
        if (this.isLoadingFromJson)
            return;
        var questions = this.getQuestionsByValueName(valueName);
        if (!!questions) {
            for (var i = 0; i < questions.length; i++) {
                var question = questions[i];
                this.checkQuestionErrorOnValueChanged(question);
                question.onSurveyValueChanged(newValue);
                this.onValueChanged.fire(this, {
                    name: valueName,
                    question: question,
                    value: newValue,
                });
            }
        }
        else {
            this.onValueChanged.fire(this, {
                name: valueName,
                question: null,
                value: newValue,
            });
        }
        if (this.isDisposed)
            return;
        this.checkElementsBindings(valueName, newValue);
        this.notifyElementsOnAnyValueOrVariableChanged(valueName, questionName);
    };
    SurveyModel.prototype.checkElementsBindings = function (valueName, newValue) {
        this.isRunningElementsBindings = true;
        for (var i = 0; i < this.pages.length; i++) {
            this.pages[i].checkBindings(valueName, newValue);
        }
        this.isRunningElementsBindings = false;
        if (this.updateVisibleIndexAfterBindings) {
            this.updateVisibleIndexes();
            this.updateVisibleIndexAfterBindings = false;
        }
    };
    SurveyModel.prototype.notifyElementsOnAnyValueOrVariableChanged = function (name, questionName) {
        if (this.isEndLoadingFromJson === "processing")
            return;
        if (this.isRunningConditions) {
            this.conditionNotifyElementsOnAnyValueOrVariableChanged = true;
            return;
        }
        for (var i = 0; i < this.pages.length; i++) {
            this.pages[i].onAnyValueChanged(name, questionName);
        }
        if (!this.isEndLoadingFromJson) {
            this.locStrsChanged();
        }
    };
    SurveyModel.prototype.updateAllQuestionsValue = function (clearData) {
        var questions = this.getAllQuestions();
        for (var i = 0; i < questions.length; i++) {
            var q = questions[i];
            var valName = q.getValueName();
            q.updateValueFromSurvey(this.getValue(valName), clearData);
            if (q.requireUpdateCommentValue) {
                q.updateCommentFromSurvey(this.getComment(valName));
            }
        }
    };
    SurveyModel.prototype.notifyAllQuestionsOnValueChanged = function () {
        var questions = this.getAllQuestions();
        for (var i = 0; i < questions.length; i++) {
            questions[i].onSurveyValueChanged(this.getValue(questions[i].getValueName()));
        }
    };
    SurveyModel.prototype.checkOnPageTriggers = function (isOnComplete) {
        var questions = this.getCurrentPageQuestions(true);
        var values = {};
        for (var i = 0; i < questions.length; i++) {
            var question = questions[i];
            var name = question.getValueName();
            values[name] = this.getValue(name);
        }
        this.addCalculatedValuesIntoFilteredValues(values);
        this.checkTriggers(values, true, isOnComplete);
    };
    SurveyModel.prototype.getCurrentPageQuestions = function (includeInvsible) {
        if (includeInvsible === void 0) { includeInvsible = false; }
        var result = [];
        var page = this.currentPage;
        if (!page)
            return result;
        for (var i = 0; i < page.questions.length; i++) {
            var question = page.questions[i];
            if ((!includeInvsible && !question.visible) || !question.name)
                continue;
            result.push(question);
        }
        return result;
    };
    SurveyModel.prototype.checkTriggers = function (key, isOnNextPage, isOnComplete, name) {
        if (isOnComplete === void 0) { isOnComplete = false; }
        if (this.isCompleted || this.triggers.length == 0 || this.isDisplayMode)
            return;
        if (this.isTriggerIsRunning) {
            this.triggerValues = this.getFilteredValues();
            for (var k in key) {
                this.triggerKeys[k] = key[k];
            }
            return;
        }
        var isQuestionInvalid = false;
        if (!isOnComplete && name && this.hasRequiredValidQuestionTrigger) {
            var question = this.getQuestionByValueName(name);
            isQuestionInvalid = question && !question.validate(false);
        }
        this.isTriggerIsRunning = true;
        this.triggerKeys = key;
        this.triggerValues = this.getFilteredValues();
        var properties = this.getFilteredProperties();
        var prevCanBeCompleted = this.canBeCompletedByTrigger;
        for (var i = 0; i < this.triggers.length; i++) {
            var trigger = this.triggers[i];
            if (isQuestionInvalid && trigger.requireValidQuestion)
                continue;
            trigger.checkExpression(isOnNextPage, isOnComplete, this.triggerKeys, this.triggerValues, properties);
        }
        if (prevCanBeCompleted !== this.canBeCompletedByTrigger) {
            this.updateButtonsVisibility();
        }
        this.isTriggerIsRunning = false;
    };
    SurveyModel.prototype.checkTriggersAndRunConditions = function (name, newValue, oldValue) {
        var triggerKeys = {};
        triggerKeys[name] = { newValue: newValue, oldValue: oldValue };
        this.runConditionOnValueChanged(name, newValue);
        this.checkTriggers(triggerKeys, false, false, name);
    };
    Object.defineProperty(SurveyModel.prototype, "hasRequiredValidQuestionTrigger", {
        get: function () {
            for (var i = 0; i < this.triggers.length; i++) {
                if (this.triggers[i].requireValidQuestion)
                    return true;
            }
            return false;
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.doElementsOnLoad = function () {
        for (var i = 0; i < this.pages.length; i++) {
            this.pages[i].onSurveyLoad();
        }
    };
    Object.defineProperty(SurveyModel.prototype, "isRunningConditions", {
        get: function () {
            return !!this.conditionValues;
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Recalculates all [expressions](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#expressions) in the survey.
     */
    SurveyModel.prototype.runExpressions = function () {
        this.runConditions();
    };
    SurveyModel.prototype.runConditions = function () {
        if (this.isCompleted ||
            this.isEndLoadingFromJson === "processing" ||
            this.isRunningConditions)
            return;
        this.conditionValues = this.getFilteredValues();
        var properties = this.getFilteredProperties();
        var oldCurrentPageIndex = this.pages.indexOf(this.currentPage);
        this.runConditionsCore(properties);
        this.checkIfNewPagesBecomeVisible(oldCurrentPageIndex);
        this.conditionValues = null;
        if (this.isValueChangedOnRunningCondition &&
            this.conditionRunnerCounter <
                settings.maxConditionRunCountOnValueChanged) {
            this.isValueChangedOnRunningCondition = false;
            this.conditionRunnerCounter++;
            this.runConditions();
        }
        else {
            this.isValueChangedOnRunningCondition = false;
            this.conditionRunnerCounter = 0;
            if (this.conditionUpdateVisibleIndexes) {
                this.conditionUpdateVisibleIndexes = false;
                this.updateVisibleIndexes();
            }
            if (this.conditionNotifyElementsOnAnyValueOrVariableChanged) {
                this.conditionNotifyElementsOnAnyValueOrVariableChanged = false;
                this.notifyElementsOnAnyValueOrVariableChanged("");
            }
        }
    };
    SurveyModel.prototype.runConditionOnValueChanged = function (name, value) {
        if (this.isRunningConditions) {
            this.conditionValues[name] = value;
            this.isValueChangedOnRunningCondition = true;
        }
        else {
            this.runConditions();
            this.runQuestionsTriggers(name, value);
        }
    };
    SurveyModel.prototype.runConditionsCore = function (properties) {
        var pages = this.pages;
        for (var i = 0; i < this.calculatedValues.length; i++) {
            this.calculatedValues[i].resetCalculation();
        }
        for (var i = 0; i < this.calculatedValues.length; i++) {
            this.calculatedValues[i].doCalculation(this.calculatedValues, this.conditionValues, properties);
        }
        _super.prototype.runConditionCore.call(this, this.conditionValues, properties);
        for (var i_2 = 0; i_2 < pages.length; i_2++) {
            pages[i_2].runCondition(this.conditionValues, properties);
        }
    };
    SurveyModel.prototype.runQuestionsTriggers = function (name, value) {
        if (this.isDisplayMode || this.isDesignMode)
            return;
        var questions = this.getAllQuestions();
        questions.forEach(function (q) { return q.runTriggers(name, value); });
    };
    SurveyModel.prototype.checkIfNewPagesBecomeVisible = function (oldCurrentPageIndex) {
        var newCurrentPageIndex = this.pages.indexOf(this.currentPage);
        if (newCurrentPageIndex <= oldCurrentPageIndex + 1)
            return;
        for (var i = oldCurrentPageIndex + 1; i < newCurrentPageIndex; i++) {
            if (this.pages[i].isVisible) {
                this.currentPage = this.pages[i];
                break;
            }
        }
    };
    /**
     * Posts a survey result to [SurveyJS Service](https://api.surveyjs.io/).
     * @param postId An identifier used to save survey results. You can find it on the [My Surveys](https://surveyjs.io/service/mysurveys) page. If you do not specify this parameter, the survey uses the [`surveyPostId`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#surveyPostId) property value.
     * @param clientId A respondent identifier (e-mail or other unique ID). This ID ensures that the respondent does not pass the same survey twice.
     * @param isPartial Pass `true` to save partial survey results (see [Continue an Incomplete Survey](https://surveyjs.io/form-library/documentation/handle-survey-results-continue-incomplete)).
     */
    SurveyModel.prototype.sendResult = function (postId, clientId, isPartial) {
        var _this = this;
        if (postId === void 0) { postId = null; }
        if (clientId === void 0) { clientId = null; }
        if (isPartial === void 0) { isPartial = false; }
        if (!this.isEditMode)
            return;
        if (isPartial && this.onPartialSend) {
            this.onPartialSend.fire(this, null);
        }
        if (!postId && this.surveyPostId) {
            postId = this.surveyPostId;
        }
        if (!postId)
            return;
        if (clientId) {
            this.clientId = clientId;
        }
        if (isPartial && !this.clientId)
            return;
        var service = this.createSurveyService();
        service.locale = this.getLocale();
        var showSaving = this.surveyShowDataSaving || (!isPartial && service.isSurveJSIOService);
        if (showSaving) {
            this.setCompletedState("saving", "");
        }
        service.sendResult(postId, this.data, function (success, response, request) {
            if (showSaving || service.isSurveJSIOService) {
                if (success) {
                    _this.setCompletedState("success", "");
                }
                else {
                    _this.setCompletedState("error", response);
                }
            }
            var options = { success: success, response: response, request: request };
            _this.onSendResult.fire(_this, options);
        }, this.clientId, isPartial);
    };
    /**
     * Requests [SurveyJS Service](https://api.surveyjs.io/) to retrieve all answers to a specified question. Handle the [`onGetResult`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onGetResult) event to access the answers.
     * @param resultId A result ID that identifies the required survey. You can find it on the [My Surveys](https://surveyjs.io/service/mysurveys) page.
     * @param questionName A question name.
     */
    SurveyModel.prototype.getResult = function (resultId, questionName) {
        var self = this;
        this.createSurveyService().getResult(resultId, questionName, function (success, data, dataList, response) {
            self.onGetResult.fire(self, {
                success: success,
                data: data,
                dataList: dataList,
                response: response,
            });
        });
    };
    /**
     * Loads a survey JSON schema from the [SurveyJS Service](https://api.surveyjs.io). You can handle the [`onLoadedSurveyFromService`](#onLoadedSurveyFromService) event to modify the schema after loading if required.
     * @param surveyId The identifier of a survey JSON schema to load. Refer to the following help topic for more information: [Store Survey Results in the SurveyJS Service](https://surveyjs.io/form-library/documentation/handle-survey-results-store#store-survey-results-in-the-surveyjs-service).
     * @param clientId A user identifier (e-mail or other unique ID) used to determine whether the user has already taken the survey.
     */
    SurveyModel.prototype.loadSurveyFromService = function (surveyId, clientId) {
        if (surveyId === void 0) { surveyId = null; }
        if (clientId === void 0) { clientId = null; }
        if (surveyId) {
            this.surveyId = surveyId;
        }
        if (clientId) {
            this.clientId = clientId;
        }
        var self = this;
        this.isLoading = true;
        this.onLoadingSurveyFromService();
        if (clientId) {
            this.createSurveyService().getSurveyJsonAndIsCompleted(this.surveyId, this.clientId, function (success, json, isCompleted, response) {
                if (success) {
                    self.isCompletedBefore = isCompleted == "completed";
                    self.loadSurveyFromServiceJson(json);
                }
                self.isLoading = false;
            });
        }
        else {
            this.createSurveyService().loadSurvey(this.surveyId, function (success, result, response) {
                if (success) {
                    self.loadSurveyFromServiceJson(result);
                }
                self.isLoading = false;
            });
        }
    };
    SurveyModel.prototype.loadSurveyFromServiceJson = function (json) {
        if (!json)
            return;
        this.fromJSON(json);
        this.notifyAllQuestionsOnValueChanged();
        this.onLoadSurveyFromService();
        this.onLoadedSurveyFromService.fire(this, {});
    };
    SurveyModel.prototype.onLoadingSurveyFromService = function () { };
    SurveyModel.prototype.onLoadSurveyFromService = function () { };
    SurveyModel.prototype.resetVisibleIndexes = function () {
        var questions = this.getAllQuestions(true);
        for (var i = 0; i < questions.length; i++) {
            questions[i].setVisibleIndex(-1);
        }
        this.updateVisibleIndexes();
    };
    SurveyModel.prototype.updateVisibleIndexes = function () {
        if (this.isLoadingFromJson || !!this.isEndLoadingFromJson || this.isLockingUpdateOnPageModes)
            return;
        if (this.isRunningConditions &&
            this.onQuestionVisibleChanged.isEmpty &&
            this.onPageVisibleChanged.isEmpty) {
            //Run update visible index only one time on finishing running conditions
            this.conditionUpdateVisibleIndexes = true;
            return;
        }
        if (this.isRunningElementsBindings) {
            this.updateVisibleIndexAfterBindings = true;
            return;
        }
        this.updatePageVisibleIndexes(this.showPageNumbers);
        if (this.showQuestionNumbers == "onPage") {
            var visPages = this.visiblePages;
            for (var i = 0; i < visPages.length; i++) {
                visPages[i].setVisibleIndex(0);
            }
        }
        else {
            var index = this.showQuestionNumbers == "on" ? 0 : -1;
            for (var i = 0; i < this.pages.length; i++) {
                index += this.pages[i].setVisibleIndex(index);
            }
        }
        this.updateProgressText(true);
    };
    SurveyModel.prototype.updatePageVisibleIndexes = function (showIndex) {
        this.updateButtonsVisibility();
        var index = 0;
        for (var i = 0; i < this.pages.length; i++) {
            var page = this.pages[i];
            var isPageVisible = page.isVisible && (i > 0 || !page.isStartPage);
            page.visibleIndex = isPageVisible ? index++ : -1;
            page.num = isPageVisible ? page.visibleIndex + 1 : -1;
        }
    };
    SurveyModel.prototype.fromJSON = function (json, options) {
        if (!json)
            return;
        this.questionHashesClear();
        this.jsonErrors = null;
        var jsonConverter = new jsonobject_JsonObject();
        jsonConverter.toObject(json, this, options);
        if (jsonConverter.errors.length > 0) {
            this.jsonErrors = jsonConverter.errors;
        }
        this.onStateAndCurrentPageChanged();
        this.updateState();
    };
    SurveyModel.prototype.startLoadingFromJson = function (json) {
        _super.prototype.startLoadingFromJson.call(this, json);
        if (json && json.locale) {
            this.locale = json.locale;
        }
    };
    SurveyModel.prototype.setJsonObject = function (jsonObj) {
        this.fromJSON(jsonObj);
    };
    SurveyModel.prototype.endLoadingFromJson = function () {
        this.isEndLoadingFromJson = "processing";
        this.onFirstPageIsStartedChanged();
        this.onQuestionsOnPageModeChanged("standard", true);
        _super.prototype.endLoadingFromJson.call(this);
        if (this.hasCookie) {
            this.isCompletedBefore = true;
        }
        this.doElementsOnLoad();
        this.isEndLoadingFromJson = "conditions";
        this.runConditions();
        this.notifyElementsOnAnyValueOrVariableChanged("");
        this.isEndLoadingFromJson = null;
        this.updateVisibleIndexes();
        this.updateHasLogo();
        this.updateRenderBackgroundImage();
        this.updateCurrentPage();
        this.hasDescription = !!this.description;
        this.titleIsEmpty = this.locTitle.isEmpty;
        this.setCalculatedWidthModeUpdater();
    };
    SurveyModel.prototype.updateNavigationCss = function () {
        if (!!this.navigationBar) {
            this.updateNavigationBarCss();
            !!this.updateNavigationItemCssCallback && this.updateNavigationItemCssCallback();
        }
    };
    SurveyModel.prototype.updateNavigationBarCss = function () {
        var val = this.navigationBar;
        val.cssClasses = this.css.actionBar;
        val.containerCss = this.css.footer;
    };
    SurveyModel.prototype.createNavigationBar = function () {
        var res = new container_ActionContainer();
        res.setItems(this.createNavigationActions());
        return res;
    };
    SurveyModel.prototype.createNavigationActions = function () {
        var _this = this;
        var defaultComponent = "sv-nav-btn";
        var navStart = new action_Action({
            id: "sv-nav-start",
            visible: new ComputedUpdater(function () { return _this.isShowStartingPage; }),
            visibleIndex: 10,
            locTitle: this.locStartSurveyText,
            action: function () { return _this.start(); },
            component: defaultComponent
        });
        var navPrev = new action_Action({
            id: "sv-nav-prev",
            visible: new ComputedUpdater(function () { return _this.isShowPrevButton; }),
            visibleIndex: 20,
            data: {
                mouseDown: function () { return _this.navigationMouseDown(); },
            },
            locTitle: this.locPagePrevText,
            action: function () { return _this.prevPage(); },
            component: defaultComponent
        });
        var navNext = new action_Action({
            id: "sv-nav-next",
            visible: new ComputedUpdater(function () { return _this.isShowNextButton; }),
            visibleIndex: 30,
            data: {
                mouseDown: function () { return _this.nextPageMouseDown(); },
            },
            locTitle: this.locPageNextText,
            action: function () { return _this.nextPageUIClick(); },
            component: defaultComponent
        });
        var navPreview = new action_Action({
            id: "sv-nav-preview",
            visible: new ComputedUpdater(function () { return _this.isPreviewButtonVisible; }),
            visibleIndex: 40,
            data: {
                mouseDown: function () { return _this.navigationMouseDown(); },
            },
            locTitle: this.locPreviewText,
            action: function () { return _this.showPreview(); },
            component: defaultComponent
        });
        var navComplete = new action_Action({
            id: "sv-nav-complete",
            visible: new ComputedUpdater(function () { return _this.isCompleteButtonVisible; }),
            visibleIndex: 50,
            data: {
                mouseDown: function () { return _this.navigationMouseDown(); },
            },
            locTitle: this.locCompleteText,
            action: function () { return _this.taskManager.waitAndExecute(function () { return _this.completeLastPage(); }); },
            component: defaultComponent
        });
        this.updateNavigationItemCssCallback = function () {
            navStart.innerCss = _this.cssNavigationStart;
            navPrev.innerCss = _this.cssNavigationPrev;
            navNext.innerCss = _this.cssNavigationNext;
            navPreview.innerCss = _this.cssNavigationPreview;
            navComplete.innerCss = _this.cssNavigationComplete;
        };
        return [navStart, navPrev, navNext, navPreview, navComplete];
    };
    SurveyModel.prototype.onBeforeRunConstructor = function () { };
    SurveyModel.prototype.onBeforeCreating = function () { };
    SurveyModel.prototype.onCreating = function () { };
    SurveyModel.prototype.getProcessedTextValue = function (textValue) {
        this.getProcessedTextValueCore(textValue);
        if (!this.onProcessTextValue.isEmpty) {
            var wasEmpty = this.isValueEmpty(textValue.value);
            this.onProcessTextValue.fire(this, textValue);
            textValue.isExists =
                textValue.isExists || (wasEmpty && !this.isValueEmpty(textValue.value));
        }
    };
    SurveyModel.prototype.getBuiltInVariableValue = function (name) {
        if (name === "pageno") {
            var page = this.currentPage;
            return page != null ? this.visiblePages.indexOf(page) + 1 : 0;
        }
        if (name === "pagecount") {
            return this.visiblePageCount;
        }
        if (name === "correctedanswers" || name === "correctanswers" || name === "correctedanswercount") {
            return this.getCorrectedAnswerCount();
        }
        if (name === "incorrectedanswers" || name === "incorrectanswers" || name === "incorrectedanswercount") {
            return this.getInCorrectedAnswerCount();
        }
        if (name === "questioncount") {
            return this.getQuizQuestionCount();
        }
        return undefined;
    };
    SurveyModel.prototype.getProcessedTextValueCore = function (textValue) {
        var name = textValue.name.toLocaleLowerCase();
        if (["no", "require", "title"].indexOf(name) !== -1) {
            return;
        }
        var builtInVar = this.getBuiltInVariableValue(name);
        if (builtInVar !== undefined) {
            textValue.isExists = true;
            textValue.value = builtInVar;
            return;
        }
        if (name === "locale") {
            textValue.isExists = true;
            textValue.value = !!this.locale
                ? this.locale
                : surveyLocalization.defaultLocale;
            return;
        }
        var variable = this.getVariable(name);
        if (variable !== undefined) {
            textValue.isExists = true;
            textValue.value = variable;
            return;
        }
        var question = this.getFirstName(name);
        if (question) {
            var questionUseDisplayText = question.useDisplayValuesInDynamicTexts;
            textValue.isExists = true;
            var firstName = question.getValueName().toLowerCase();
            name = firstName + name.substring(firstName.length);
            name = name.toLocaleLowerCase();
            var values = {};
            values[firstName] = textValue.returnDisplayValue && questionUseDisplayText
                ? question.getDisplayValue(false, undefined)
                : question.value;
            textValue.value = new conditionProcessValue_ProcessValue().getValue(name, values);
            return;
        }
        this.getProcessedValuesWithoutQuestion(textValue);
    };
    SurveyModel.prototype.getProcessedValuesWithoutQuestion = function (textValue) {
        var value = this.getValue(textValue.name);
        if (value !== undefined) {
            textValue.isExists = true;
            textValue.value = value;
            return;
        }
        var processor = new conditionProcessValue_ProcessValue();
        var firstName = processor.getFirstName(textValue.name);
        if (firstName === textValue.name)
            return;
        var data = {};
        var val = this.getValue(firstName);
        if (helpers_Helpers.isValueEmpty(val)) {
            val = this.getVariable(firstName);
        }
        if (helpers_Helpers.isValueEmpty(val))
            return;
        data[firstName] = val;
        textValue.value = processor.getValue(textValue.name, data);
        textValue.isExists = processor.hasValue(textValue.name, data);
    };
    SurveyModel.prototype.getFirstName = function (name) {
        name = name.toLowerCase();
        var question;
        do {
            question = this.getQuestionByValueName(name, true);
            name = this.reduceFirstName(name);
        } while (!question && !!name);
        return question;
    };
    SurveyModel.prototype.reduceFirstName = function (name) {
        var pos1 = name.lastIndexOf(".");
        var pos2 = name.lastIndexOf("[");
        if (pos1 < 0 && pos2 < 0)
            return "";
        var pos = Math.max(pos1, pos2);
        return name.substring(0, pos);
    };
    SurveyModel.prototype.clearUnusedValues = function () {
        this.isClearingUnsedValues = true;
        var questions = this.getAllQuestions();
        for (var i = 0; i < questions.length; i++) {
            questions[i].clearUnusedValues();
        }
        this.clearInvisibleQuestionValues();
        this.isClearingUnsedValues = false;
    };
    SurveyModel.prototype.hasVisibleQuestionByValueName = function (valueName) {
        var questions = this.getQuestionsByValueName(valueName);
        if (!questions)
            return false;
        for (var i = 0; i < questions.length; i++) {
            var q = questions[i];
            if (q.isVisible && q.isParentVisible && !q.parentQuestion)
                return true;
        }
        return false;
    };
    SurveyModel.prototype.questionsByValueName = function (valueName) {
        var questions = this.getQuestionsByValueName(valueName);
        return !!questions ? questions : [];
    };
    SurveyModel.prototype.clearInvisibleQuestionValues = function () {
        var reason = this.clearInvisibleValues === "none" ? "none" : "onComplete";
        var questions = this.getAllQuestions();
        for (var i = 0; i < questions.length; i++) {
            questions[i].clearValueIfInvisible(reason);
        }
    };
    /**
     * Returns a variable value.
     *
     * [Variables help topic](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#variables (linkStyle))
     * @param name A variable name.
     * @return A variable value.
     * @see setVariable
     * @see getVariableNames
     */
    SurveyModel.prototype.getVariable = function (name) {
        if (!name)
            return null;
        name = name.toLowerCase();
        var res = this.variablesHash[name];
        if (!this.isValueEmpty(res))
            return res;
        if (name.indexOf(".") > -1 || name.indexOf("[") > -1) {
            if (new conditionProcessValue_ProcessValue().hasValue(name, this.variablesHash))
                return new conditionProcessValue_ProcessValue().getValue(name, this.variablesHash);
        }
        return res;
    };
    /**
     * Sets a variable value.
     *
     * [Variables help topic](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#variables (linkStyle))
     * @param name A variable name.
     * @param newValue A new variable value.
     * @see getVariable
     * @see getVariableNames
     */
    SurveyModel.prototype.setVariable = function (name, newValue) {
        if (!name)
            return;
        var oldValue = this.getVariable(name);
        if (!!this.valuesHash) {
            delete this.valuesHash[name];
        }
        name = name.toLowerCase();
        this.variablesHash[name] = newValue;
        this.notifyElementsOnAnyValueOrVariableChanged(name);
        if (!helpers_Helpers.isTwoValueEquals(oldValue, newValue)) {
            this.checkTriggersAndRunConditions(name, newValue, oldValue);
            this.onVariableChanged.fire(this, { name: name, value: newValue });
        }
    };
    /**
     * Returns the names of all variables in the survey.
     *
     * [Variables help topic](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#variables (linkStyle))
     * @returns An array of variable names.
     * @see getVariable
     * @see setVariable
     */
    SurveyModel.prototype.getVariableNames = function () {
        var res = [];
        for (var key in this.variablesHash) {
            res.push(key);
        }
        return res;
    };
    //ISurvey data
    SurveyModel.prototype.getUnbindValue = function (value) {
        if (!!this.editingObj)
            return value;
        return helpers_Helpers.getUnbindValue(value);
    };
    /**
     * Returns a value (answer) for a question with a specified `name`.
     * @param name A question name.
     * @returns A question value (answer).
     * @see data
     * @see setValue
     */
    SurveyModel.prototype.getValue = function (name) {
        if (!name || name.length == 0)
            return null;
        var value = this.getDataValueCore(this.valuesHash, name);
        return this.getUnbindValue(value);
    };
    /**
     * Sets a question value (answer).
     *
     * > This method executes all triggers and reevaluates conditions (`visibleIf`, `requiredId`, and others). It also switches the survey to the next page if the [`goNextPageAutomatic`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#goNextPageAutomatic) property is enabled and all questions on the current page have correct answers.
     * @param name A question name.
     * @param newValue A new question value.
     * @param locNotification For internal use.
     * @param allowNotifyValueChanged For internal use.
     * @see data
     * @see getValue
     */
    SurveyModel.prototype.setValue = function (name, newQuestionValue, locNotification, allowNotifyValueChanged, questionName) {
        if (locNotification === void 0) { locNotification = false; }
        if (allowNotifyValueChanged === void 0) { allowNotifyValueChanged = true; }
        if (this.isLockingUpdateOnPageModes)
            return;
        var newValue = newQuestionValue;
        if (allowNotifyValueChanged) {
            newValue = this.questionOnValueChanging(name, newQuestionValue);
        }
        if (this.isValidateOnValueChanging &&
            this.checkErrorsOnValueChanging(name, newValue))
            return;
        if (!this.editingObj &&
            this.isValueEqual(name, newValue) &&
            this.isTwoValueEquals(newValue, newQuestionValue))
            return;
        var oldValue = this.getValue(name);
        if (this.isValueEmpyOnSetValue(name, newValue)) {
            this.deleteDataValueCore(this.valuesHash, name);
        }
        else {
            newValue = this.getUnbindValue(newValue);
            this.setDataValueCore(this.valuesHash, name, newValue);
        }
        this.updateOnSetValue(name, newValue, oldValue, locNotification, allowNotifyValueChanged, questionName);
    };
    SurveyModel.prototype.isValueEmpyOnSetValue = function (name, val) {
        if (!this.isValueEmpty(val, false))
            return false;
        if (!this.editingObj || val === null || val === undefined)
            return true;
        return this.editingObj.getDefaultPropertyValue(name) === val;
    };
    SurveyModel.prototype.updateOnSetValue = function (name, newValue, oldValue, locNotification, allowNotifyValueChanged, questionName) {
        if (locNotification === void 0) { locNotification = false; }
        if (allowNotifyValueChanged === void 0) { allowNotifyValueChanged = true; }
        this.updateQuestionValue(name, newValue);
        if (locNotification === true || this.isDisposed || this.isRunningElementsBindings)
            return;
        questionName = questionName || name;
        this.checkTriggersAndRunConditions(name, newValue, oldValue);
        if (allowNotifyValueChanged)
            this.notifyQuestionOnValueChanged(name, newValue, questionName);
        if (locNotification !== "text") {
            this.tryGoNextPageAutomatic(name);
        }
    };
    SurveyModel.prototype.isValueEqual = function (name, newValue) {
        if (newValue === "" || newValue === undefined)
            newValue = null;
        var oldValue = this.getValue(name);
        if (oldValue === "" || oldValue === undefined)
            oldValue = null;
        if (newValue === null || oldValue === null)
            return newValue === oldValue;
        return this.isTwoValueEquals(newValue, oldValue);
    };
    SurveyModel.prototype.doOnPageAdded = function (page) {
        page.setSurveyImpl(this);
        if (!page.name)
            page.name = this.generateNewName(this.pages, "page");
        this.questionHashesPanelAdded(page);
        this.updateVisibleIndexes();
        if (!!this.runningPages)
            return;
        if (!this.isLoadingFromJson) {
            this.updateProgressText();
            this.updateCurrentPage();
        }
        var options = { page: page };
        this.onPageAdded.fire(this, options);
    };
    SurveyModel.prototype.doOnPageRemoved = function (page) {
        page.setSurveyImpl(null);
        if (!!this.runningPages)
            return;
        if (page === this.currentPage) {
            this.updateCurrentPage();
        }
        this.updateVisibleIndexes();
        this.updateProgressText();
        this.updateLazyRenderingRowsOnRemovingElements();
    };
    SurveyModel.prototype.generateNewName = function (elements, baseName) {
        var keys = {};
        for (var i = 0; i < elements.length; i++)
            keys[elements[i]["name"]] = true;
        var index = 1;
        while (keys[baseName + index])
            index++;
        return baseName + index;
    };
    SurveyModel.prototype.tryGoNextPageAutomatic = function (name) {
        var _this = this;
        if (!!this.isEndLoadingFromJson ||
            !this.goNextPageAutomatic ||
            !this.currentPage)
            return;
        var question = this.getQuestionByValueName(name);
        if (!question ||
            (!!question &&
                (!question.visible || !question.supportGoNextPageAutomatic())))
            return;
        if (!question.validate(false) && !question.supportGoNextPageError())
            return;
        var questions = this.getCurrentPageQuestions();
        if (questions.indexOf(question) < 0)
            return;
        for (var i = 0; i < questions.length; i++) {
            if (questions[i].hasInput && questions[i].isEmpty())
                return;
        }
        if (this.isLastPage && (this.goNextPageAutomatic !== true || !this.allowCompleteSurveyAutomatic))
            return;
        if (this.checkIsCurrentPageHasErrors(false))
            return;
        var curPage = this.currentPage;
        var goNextPage = function () {
            if (curPage !== _this.currentPage)
                return;
            if (!_this.isLastPage) {
                _this.nextPage();
            }
            else {
                if (_this.isShowPreviewBeforeComplete) {
                    _this.showPreview();
                }
                else {
                    _this.completeLastPage();
                }
            }
        };
        surveyTimerFunctions.safeTimeOut(goNextPage, settings.autoAdvanceDelay);
    };
    /**
     * Returns a comment value from a question with a specified `name`.
     * @param name A question name.
     * @returns A comment.
     * @see setComment
     */
    SurveyModel.prototype.getComment = function (name) {
        var res = this.getValue(name + this.commentSuffix);
        return res || "";
    };
    /**
     * Sets a comment value to a question with a specified `name`.
     * @param name A question name.
     * @param newValue A new comment value.
     * @param locNotification For internal use.
     * @see getComment
     */
    SurveyModel.prototype.setComment = function (name, newValue, locNotification) {
        if (locNotification === void 0) { locNotification = false; }
        if (!newValue)
            newValue = "";
        if (this.isTwoValueEquals(newValue, this.getComment(name)))
            return;
        var commentName = name + this.commentSuffix;
        newValue = this.questionOnValueChanging(commentName, newValue, name);
        if (this.isValueEmpty(newValue)) {
            this.deleteDataValueCore(this.valuesHash, commentName);
        }
        else {
            this.setDataValueCore(this.valuesHash, commentName, newValue);
        }
        var questions = this.getQuestionsByValueName(name);
        if (!!questions) {
            for (var i = 0; i < questions.length; i++) {
                questions[i].updateCommentFromSurvey(newValue);
                this.checkQuestionErrorOnValueChanged(questions[i]);
            }
        }
        if (!locNotification) {
            this.checkTriggersAndRunConditions(name, this.getValue(name), undefined);
        }
        if (locNotification !== "text") {
            this.tryGoNextPageAutomatic(name);
        }
        var question = this.getQuestionByValueName(name);
        if (question) {
            this.onValueChanged.fire(this, {
                name: commentName,
                question: question,
                value: newValue,
            });
            question.comment = newValue;
            if (question.comment != newValue) {
                question.comment = newValue;
            }
        }
    };
    /**
     * Deletes an answer from survey results.
     * @param {string} name An object property that stores the answer to delete. Pass a question's [`valueName`](https://surveyjs.io/form-library/documentation/api-reference/question#valueName) or [`name`](https://surveyjs.io/form-library/documentation/api-reference/question#name).
     */
    SurveyModel.prototype.clearValue = function (name) {
        this.setValue(name, null);
        this.setComment(name, null);
    };
    Object.defineProperty(SurveyModel.prototype, "clearValueOnDisableItems", {
        /**
         * Specifies whether to remove disabled choices from the value in [Dropdown](https://surveyjs.io/form-library/documentation/api-reference/dropdown-menu-model), [Checkboxes](https://surveyjs.io/form-library/documentation/api-reference/checkbox-question-model), and [Radio Button Group](https://surveyjs.io/form-library/documentation/api-reference/radio-button-question-model) questions.
         *
         * Default value: `false`
         *
         * > This property cannot be specified in the survey JSON schema. Use dot notation to specify it.
         */
        get: function () {
            return this.getPropertyValue("clearValueOnDisableItems", false);
        },
        set: function (val) {
            this.setPropertyValue("clearValueOnDisableItems", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.getQuestionClearIfInvisible = function (questionClearIf) {
        if (this.isShowingPreview || this.runningPages)
            return "none";
        if (questionClearIf !== "default")
            return questionClearIf;
        return this.clearInvisibleValues;
    };
    SurveyModel.prototype.questionVisibilityChanged = function (question, newValue, resetIndexes) {
        if (resetIndexes) {
            this.updateVisibleIndexes();
        }
        this.onQuestionVisibleChanged.fire(this, {
            question: question,
            name: question.name,
            visible: newValue,
        });
    };
    SurveyModel.prototype.pageVisibilityChanged = function (page, newValue) {
        if (this.isLoadingFromJson)
            return;
        if (newValue && !this.currentPage || page === this.currentPage) {
            this.updateCurrentPage();
        }
        this.updateVisibleIndexes();
        this.onPageVisibleChanged.fire(this, {
            page: page,
            visible: newValue,
        });
    };
    SurveyModel.prototype.panelVisibilityChanged = function (panel, newValue) {
        this.updateVisibleIndexes();
        this.onPanelVisibleChanged.fire(this, {
            panel: panel,
            visible: newValue,
        });
    };
    SurveyModel.prototype.questionCreated = function (question) {
        this.onQuestionCreated.fire(this, { question: question });
    };
    SurveyModel.prototype.questionAdded = function (question, index, parentPanel, rootPanel) {
        if (!question.name) {
            question.name = this.generateNewName(this.getAllQuestions(false, true), "question");
        }
        if (!!question.page) {
            this.questionHashesAdded(question);
        }
        if (!this.currentPage) {
            this.updateCurrentPage();
        }
        this.updateVisibleIndexes();
        this.setCalculatedWidthModeUpdater();
        if (this.canFireAddElement()) {
            this.onQuestionAdded.fire(this, {
                question: question,
                name: question.name,
                index: index,
                parent: parentPanel,
                page: rootPanel,
                parentPanel: parentPanel,
                rootPanel: rootPanel,
            });
        }
    };
    SurveyModel.prototype.canFireAddElement = function () {
        return !this.isMovingQuestion || this.isDesignMode && !settings.supportCreatorV2;
    };
    SurveyModel.prototype.questionRemoved = function (question) {
        this.questionHashesRemoved(question, question.name, question.getValueName());
        this.updateVisibleIndexes();
        this.onQuestionRemoved.fire(this, {
            question: question,
            name: question.name,
        });
        this.updateLazyRenderingRowsOnRemovingElements();
    };
    SurveyModel.prototype.questionRenamed = function (question, oldName, oldValueName) {
        this.questionHashesRemoved(question, oldName, oldValueName);
        this.questionHashesAdded(question);
    };
    SurveyModel.prototype.questionHashesClear = function () {
        this.questionHashes.names = {};
        this.questionHashes.namesInsensitive = {};
        this.questionHashes.valueNames = {};
        this.questionHashes.valueNamesInsensitive = {};
    };
    SurveyModel.prototype.questionHashesPanelAdded = function (panel) {
        if (this.isLoadingFromJson)
            return;
        var questions = panel.questions;
        for (var i = 0; i < questions.length; i++) {
            this.questionHashesAdded(questions[i]);
        }
    };
    SurveyModel.prototype.questionHashesAdded = function (question) {
        this.questionHashAddedCore(this.questionHashes.names, question, question.name);
        this.questionHashAddedCore(this.questionHashes.namesInsensitive, question, question.name.toLowerCase());
        this.questionHashAddedCore(this.questionHashes.valueNames, question, question.getValueName());
        this.questionHashAddedCore(this.questionHashes.valueNamesInsensitive, question, question.getValueName().toLowerCase());
    };
    SurveyModel.prototype.questionHashesRemoved = function (question, name, valueName) {
        if (!!name) {
            this.questionHashRemovedCore(this.questionHashes.names, question, name);
            this.questionHashRemovedCore(this.questionHashes.namesInsensitive, question, name.toLowerCase());
        }
        if (!!valueName) {
            this.questionHashRemovedCore(this.questionHashes.valueNames, question, valueName);
            this.questionHashRemovedCore(this.questionHashes.valueNamesInsensitive, question, valueName.toLowerCase());
        }
    };
    SurveyModel.prototype.questionHashAddedCore = function (hash, question, name) {
        var res = hash[name];
        if (!!res) {
            var res = hash[name];
            if (res.indexOf(question) < 0) {
                res.push(question);
            }
        }
        else {
            hash[name] = [question];
        }
    };
    SurveyModel.prototype.questionHashRemovedCore = function (hash, question, name) {
        var res = hash[name];
        if (!res)
            return;
        var index = res.indexOf(question);
        if (index > -1) {
            res.splice(index, 1);
        }
        if (res.length == 0) {
            delete hash[name];
        }
    };
    SurveyModel.prototype.panelAdded = function (panel, index, parentPanel, rootPanel) {
        if (!panel.name) {
            panel.name = this.generateNewName(this.getAllPanels(false, true), "panel");
        }
        this.questionHashesPanelAdded(panel);
        this.updateVisibleIndexes();
        if (this.canFireAddElement()) {
            this.onPanelAdded.fire(this, {
                panel: panel,
                name: panel.name,
                index: index,
                parent: parentPanel,
                page: rootPanel,
                parentPanel: parentPanel,
                rootPanel: rootPanel,
            });
        }
    };
    SurveyModel.prototype.panelRemoved = function (panel) {
        this.updateVisibleIndexes();
        this.onPanelRemoved.fire(this, { panel: panel, name: panel.name });
        this.updateLazyRenderingRowsOnRemovingElements();
    };
    SurveyModel.prototype.validateQuestion = function (question) {
        if (this.onValidateQuestion.isEmpty)
            return null;
        var options = {
            name: question.name,
            question: question,
            value: question.value,
            error: null,
        };
        this.onValidateQuestion.fire(this, options);
        return options.error ? new CustomError(options.error, this) : null;
    };
    SurveyModel.prototype.validatePanel = function (panel) {
        if (this.onValidatePanel.isEmpty)
            return null;
        var options = {
            name: panel.name,
            panel: panel,
            error: null,
        };
        this.onValidatePanel.fire(this, options);
        return options.error ? new CustomError(options.error, this) : null;
    };
    SurveyModel.prototype.processHtml = function (html, reason) {
        if (!reason)
            reason = "";
        var options = { html: html, reason: reason };
        this.onProcessHtml.fire(this, options);
        return this.processText(options.html, true);
    };
    SurveyModel.prototype.processText = function (text, returnDisplayValue) {
        return this.processTextEx(text, returnDisplayValue, false).text;
    };
    SurveyModel.prototype.processTextEx = function (text, returnDisplayValue, doEncoding) {
        var res = {
            text: this.processTextCore(text, returnDisplayValue, doEncoding),
            hasAllValuesOnLastRun: true,
        };
        res.hasAllValuesOnLastRun = this.textPreProcessor.hasAllValuesOnLastRun;
        return res;
    };
    Object.defineProperty(SurveyModel.prototype, "textPreProcessor", {
        get: function () {
            var _this = this;
            if (!this.textPreProcessorValue) {
                this.textPreProcessorValue = new textPreProcessor_TextPreProcessor();
                this.textPreProcessorValue.onProcess = function (textValue) {
                    _this.getProcessedTextValue(textValue);
                };
            }
            return this.textPreProcessorValue;
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.processTextCore = function (text, returnDisplayValue, doEncoding) {
        if (doEncoding === void 0) { doEncoding = false; }
        if (this.isDesignMode)
            return text;
        return this.textPreProcessor.process(text, returnDisplayValue, doEncoding);
    };
    SurveyModel.prototype.getSurveyMarkdownHtml = function (element, text, name) {
        var options = {
            element: element,
            text: text,
            name: name,
            html: null,
        };
        this.onTextMarkdown.fire(this, options);
        return options.html;
    };
    SurveyModel.prototype.getCorrectedAnswerCount = function () {
        return this.getCorrectAnswerCount();
    };
    /**
     * Returns the number of correct answers in a quiz.
     *
     * For more information about quizzes, refer to the following tutorial: [Create a Quiz](https://surveyjs.io/form-library/documentation/design-survey/create-a-quiz).
     * @returns The number of correct answers in a quiz.
     * @see getQuizQuestionCount
     * @see getInCorrectAnswerCount
     */
    SurveyModel.prototype.getCorrectAnswerCount = function () {
        return this.getCorrectedAnswerCountCore(true);
    };
    /**
     * Returns the number of quiz questions. A question counts if it is visible, has an input field, and specifies [`correctAnswer`](https://surveyjs.io/form-library/documentation/api-reference/checkbox-question-model#correctAnswer).
     *
     * This number may be different from `getQuizQuestions().length` because certain question types (for instance, matrix-like types) include more than one question.
     *
     * For more information about quizzes, refer to the following tutorial: [Create a Quiz](https://surveyjs.io/form-library/documentation/design-survey/create-a-quiz).
     * @returns The number of quiz questions.
     * @see getQuizQuestions
     */
    SurveyModel.prototype.getQuizQuestionCount = function () {
        var questions = this.getQuizQuestions();
        var res = 0;
        for (var i = 0; i < questions.length; i++) {
            res += questions[i].quizQuestionCount;
        }
        return res;
    };
    SurveyModel.prototype.getInCorrectedAnswerCount = function () {
        return this.getInCorrectAnswerCount();
    };
    /**
     * Returns the number of incorrect answers in a quiz.
     *
     * For more information about quizzes, refer to the following tutorial: [Create a Quiz](https://surveyjs.io/form-library/documentation/design-survey/create-a-quiz).
     * @returns The number of incorrect answers in a quiz.
     * @see getCorrectAnswerCount
     */
    SurveyModel.prototype.getInCorrectAnswerCount = function () {
        return this.getCorrectedAnswerCountCore(false);
    };
    SurveyModel.prototype.onCorrectQuestionAnswer = function (question, options) {
        if (this.onIsAnswerCorrect.isEmpty)
            return;
        options.question = question;
        this.onIsAnswerCorrect.fire(this, options);
    };
    SurveyModel.prototype.getCorrectedAnswerCountCore = function (isCorrect) {
        var questions = this.getQuizQuestions();
        var counter = 0;
        for (var i = 0; i < questions.length; i++) {
            var q = questions[i];
            var correctCount = q.correctAnswerCount;
            if (isCorrect) {
                counter += correctCount;
            }
            else {
                counter += q.quizQuestionCount - correctCount;
            }
        }
        return counter;
    };
    SurveyModel.prototype.getCorrectedAnswers = function () {
        return this.getCorrectedAnswerCount();
    };
    SurveyModel.prototype.getInCorrectedAnswers = function () {
        return this.getInCorrectedAnswerCount();
    };
    Object.defineProperty(SurveyModel.prototype, "showTimerPanel", {
        /**
         * Displays the timer panel and specifies its position. Applies only to [quiz surveys](https://surveyjs.io/form-library/documentation/design-survey-create-a-quiz).
         *
         * Possible values:
         *
         * - `"top"` - Displays the timer panel at the top of the survey.
         * - `"bottom"` - Displays the timer panel at the bottom of the survey.
         * - `"none"` (default) - Hides the timer panel.
         *
         * If the timer panel is displayed, the timer starts automatically when the survey begins. To specify time limits, use the [`maxTimeToFinish`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#maxTimeToFinish) and [`maxTimeToFinishPage`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#maxTimeToFinishPage) properties.
         *
         * The timer panel displays information about time spent on an individual page and the entire survey. If you want to display only the page timer or the survey timer, set the [`showTimerPanelMode`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#showTimerPanelMode) property to `"page"` or `"survey"`.
         * @see startTimer
         * @see stopTimer
         * @see timeSpent
         * @see onTimer
         */
        get: function () {
            return this.getPropertyValue("showTimerPanel");
        },
        set: function (val) {
            this.setPropertyValue("showTimerPanel", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isTimerPanelShowingOnTop", {
        get: function () {
            return this.showTimerPanel == "top";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "isTimerPanelShowingOnBottom", {
        get: function () {
            return this.showTimerPanel == "bottom";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "showTimerPanelMode", {
        /**
         * Specifies whether the timer panel displays timers for the current page, the entire survey, or both. Applies only if the timer panel is [visible](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#showTimerPanel).
         *
         * Possible values:
         *
         * - `"survey"` - Displays only the survey timer.
         * - `"page"` - Displays only the page timer.
         * - `"all"` (default) - Displays both the survey and page timers.
         * @see timeSpent
         * @see onTimer
         * @see startTimer
         * @see stopTimer
         */
        get: function () {
            return this.getPropertyValue("showTimerPanelMode");
        },
        set: function (val) {
            this.setPropertyValue("showTimerPanelMode", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "widthMode", {
        /**
          * Specifies how to calculate the survey width.
          *
          * Possible values:
          *
          * - `"static"` - A survey has a [fixed width](#width).
          * - `"responsive"` - A survey occupies all available horizontal space and stretches or shrinks horizontally to fit in the screen size.
          * - `"auto"` (default) - Survey width depends on a question type and corresponds to the `"static"` or `"responsive"` mode.
        */
        // `custom/precise` - The survey width is specified by the width property. // in-future
        get: function () {
            return this.getPropertyValue("widthMode");
        },
        set: function (val) {
            this.setPropertyValue("widthMode", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.setCalculatedWidthModeUpdater = function () {
        var _this = this;
        if (this.calculatedWidthModeUpdater)
            this.calculatedWidthModeUpdater.dispose();
        this.calculatedWidthModeUpdater = new ComputedUpdater(function () { return _this.calculateWidthMode(); });
        this.calculatedWidthMode = this.calculatedWidthModeUpdater;
    };
    SurveyModel.prototype.calculateWidthMode = function () {
        if (this.widthMode == "auto") {
            var isResponsive_1 = false;
            this.pages.forEach(function (page) {
                if (page.needResponsiveWidth())
                    isResponsive_1 = true;
            });
            return isResponsive_1 ? "responsive" : "static";
        }
        return this.widthMode;
    };
    Object.defineProperty(SurveyModel.prototype, "width", {
        /**
         * A survey width in CSS values.
         *
         * Default value: `undefined` (the survey inherits the width from its container)
         */
        get: function () {
            return this.getPropertyValue("width");
        },
        set: function (val) {
            this.setPropertyValue("width", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "renderedWidth", {
        get: function () {
            var width = this.getPropertyValue("width");
            if (width && !isNaN(width))
                width = width + "px";
            return this.getPropertyValue("calculatedWidthMode") == "static" && width || undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "timerInfo", {
        get: function () {
            return this.getTimerInfo();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "timerClock", {
        get: function () {
            var major;
            var minor;
            if (!!this.currentPage) {
                var _a = this.getTimerInfo(), spent = _a.spent, limit = _a.limit, minorSpent = _a.minorSpent, minorLimit = _a.minorLimit;
                if (limit > 0)
                    major = this.getDisplayClockTime(limit - spent);
                else {
                    major = this.getDisplayClockTime(spent);
                }
                if (minorSpent !== undefined) {
                    if (minorLimit > 0) {
                        minor = this.getDisplayClockTime(minorLimit - minorSpent);
                    }
                    else {
                        minor = this.getDisplayClockTime(minorSpent);
                    }
                }
            }
            return { majorText: major, minorText: minor };
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "timerInfoText", {
        get: function () {
            var options = { text: this.getTimerInfoText() };
            this.onTimerPanelInfoText.fire(this, options);
            var loc = new localizablestring_LocalizableString(this, true);
            loc.text = options.text;
            return loc.textOrHtml;
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.getTimerInfo = function () {
        var page = this.currentPage;
        if (!page)
            return { spent: 0, limit: 0 };
        var pageSpent = page.timeSpent;
        var surveySpent = this.timeSpent;
        var pageLimitSec = page.getMaxTimeToFinish();
        var surveyLimit = this.maxTimeToFinish;
        if (this.showTimerPanelMode == "page") {
            return { spent: pageSpent, limit: pageLimitSec };
        }
        if (this.showTimerPanelMode == "survey") {
            return { spent: surveySpent, limit: surveyLimit };
        }
        else {
            if (pageLimitSec > 0 && surveyLimit > 0) {
                return { spent: pageSpent, limit: pageLimitSec, minorSpent: surveySpent, minorLimit: surveyLimit };
            }
            else if (pageLimitSec > 0) {
                return { spent: pageSpent, limit: pageLimitSec, minorSpent: surveySpent };
            }
            else if (surveyLimit > 0) {
                return { spent: surveySpent, limit: surveyLimit, minorSpent: pageSpent };
            }
            else {
                return { spent: pageSpent, minorSpent: surveySpent };
            }
        }
    };
    SurveyModel.prototype.getTimerInfoText = function () {
        var page = this.currentPage;
        if (!page)
            return "";
        var pageSpent = this.getDisplayTime(page.timeSpent);
        var surveySpent = this.getDisplayTime(this.timeSpent);
        var pageLimitSec = page.getMaxTimeToFinish();
        var pageLimit = this.getDisplayTime(pageLimitSec);
        var surveyLimit = this.getDisplayTime(this.maxTimeToFinish);
        if (this.showTimerPanelMode == "page")
            return this.getTimerInfoPageText(page, pageSpent, pageLimit);
        if (this.showTimerPanelMode == "survey")
            return this.getTimerInfoSurveyText(surveySpent, surveyLimit);
        if (this.showTimerPanelMode == "all") {
            if (pageLimitSec <= 0 && this.maxTimeToFinish <= 0) {
                return this.getLocalizationFormatString("timerSpentAll", pageSpent, surveySpent);
            }
            if (pageLimitSec > 0 && this.maxTimeToFinish > 0) {
                return this.getLocalizationFormatString("timerLimitAll", pageSpent, pageLimit, surveySpent, surveyLimit);
            }
            var pageText = this.getTimerInfoPageText(page, pageSpent, pageLimit);
            var surveyText = this.getTimerInfoSurveyText(surveySpent, surveyLimit);
            return pageText + " " + surveyText;
        }
        return "";
    };
    SurveyModel.prototype.getTimerInfoPageText = function (page, pageSpent, pageLimit) {
        return !!page && page.getMaxTimeToFinish() > 0
            ? this.getLocalizationFormatString("timerLimitPage", pageSpent, pageLimit)
            : this.getLocalizationFormatString("timerSpentPage", pageSpent, pageLimit);
    };
    SurveyModel.prototype.getTimerInfoSurveyText = function (surveySpent, surveyLimit) {
        var strName = this.maxTimeToFinish > 0 ? "timerLimitSurvey" : "timerSpentSurvey";
        return this.getLocalizationFormatString(strName, surveySpent, surveyLimit);
    };
    SurveyModel.prototype.getDisplayClockTime = function (val) {
        if (val < 0) {
            val = 0;
        }
        var min = Math.floor(val / 60);
        var sec = val % 60;
        var secStr = sec.toString();
        if (sec < 10) {
            secStr = "0" + secStr;
        }
        return min + ":" + secStr;
    };
    SurveyModel.prototype.getDisplayTime = function (val) {
        var min = Math.floor(val / 60);
        var sec = val % 60;
        var res = "";
        if (min > 0) {
            res += min + " " + this.getLocalizationString("timerMin");
        }
        if (res && sec == 0)
            return res;
        if (res)
            res += " ";
        return res + sec + " " + this.getLocalizationString("timerSec");
    };
    Object.defineProperty(SurveyModel.prototype, "timerModel", {
        get: function () { return this.timerModelValue; },
        enumerable: false,
        configurable: true
    });
    /**
     * Starts a timer that calculates how many seconds a respondent has spent on the survey. Applies only to [quiz surveys](https://surveyjs.io/form-library/documentation/design-survey-create-a-quiz).
     * @see stopTimer
     * @see maxTimeToFinish
     * @see maxTimeToFinishPage
     * @see timeSpent
     * @see onTimer
     */
    SurveyModel.prototype.startTimer = function () {
        if (this.isEditMode) {
            this.timerModel.start();
        }
    };
    SurveyModel.prototype.startTimerFromUI = function () {
        if (this.showTimerPanel != "none" && this.state === "running") {
            this.startTimer();
        }
    };
    /**
     * Stops the timer. Applies only to [quiz surveys](https://surveyjs.io/form-library/documentation/design-survey-create-a-quiz).
     * @see startTimer
     * @see maxTimeToFinish
     * @see maxTimeToFinishPage
     * @see timeSpent
     * @see onTimer
     */
    SurveyModel.prototype.stopTimer = function () {
        this.timerModel.stop();
    };
    Object.defineProperty(SurveyModel.prototype, "timeSpent", {
        /**
         * A time period that a respondent has spent on the survey so far; measured in seconds. Applies only to [quiz surveys](https://surveyjs.io/form-library/documentation/design-survey-create-a-quiz).
         *
         * Assign a number to this property if you need to start the quiz timer from a specific time (for instance, if you want to continue an interrupted quiz).
         *
         * You can also find out how many seconds a respondent has spent on an individual survey page. To do this, use the [`timeSpent`](https://surveyjs.io/form-library/documentation/api-reference/page-model#timeSpent) property of a [`PageModel`](https://surveyjs.io/form-library/documentation/api-reference/page-model) object.
         * @see maxTimeToFinish
         * @see maxTimeToFinishPage
         * @see startTimer
         */
        get: function () { return this.timerModel.spent; },
        set: function (val) { this.timerModel.spent = val; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "maxTimeToFinish", {
        /**
         * A time period that a respondent has to complete the survey; measured in seconds. Applies only to [quiz surveys](https://surveyjs.io/form-library/documentation/design-survey-create-a-quiz).
         *
         * A negative value or 0 sets an unlimited time period.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/make-quiz-javascript/ (linkStyle))
         * @see maxTimeToFinishPage
         * @see startTimer
         * @see timeSpent
         */
        get: function () {
            return this.getPropertyValue("maxTimeToFinish", 0);
        },
        set: function (val) {
            this.setPropertyValue("maxTimeToFinish", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyModel.prototype, "maxTimeToFinishPage", {
        /**
         * A time period that a respondent has to complete each survey page; measured in seconds. Applies only to [quiz surveys](https://surveyjs.io/form-library/documentation/design-survey-create-a-quiz).
         *
         * A negative value or 0 sets an unlimited time period.
         *
         * You can also use `PageModel`'s [`maxTimeToFinish`](https://surveyjs.io/form-library/documentation/api-reference/page-model#maxTimeToFinish) property to specify a time period for an individual survey page.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/make-quiz-javascript/ (linkStyle))
         * @see maxTimeToFinish
         * @see startTimer
         * @see timeSpent
         */
        get: function () {
            return this.getPropertyValue("maxTimeToFinishPage", 0);
        },
        set: function (val) {
            this.setPropertyValue("maxTimeToFinishPage", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyModel.prototype.doTimer = function (page) {
        this.onTimer.fire(this, {});
        if (this.maxTimeToFinish > 0 && this.maxTimeToFinish <= this.timeSpent) {
            this.timeSpent = this.maxTimeToFinish;
            this.completeLastPage();
        }
        if (page) {
            var pageLimit = page.getMaxTimeToFinish();
            if (pageLimit > 0 && pageLimit == page.timeSpent) {
                if (this.isLastPage) {
                    this.completeLastPage();
                }
                else {
                    this.nextPage();
                }
            }
        }
    };
    Object.defineProperty(SurveyModel.prototype, "inSurvey", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    //ISurveyImplementor
    SurveyModel.prototype.getSurveyData = function () {
        return this;
    };
    SurveyModel.prototype.getSurvey = function () {
        return this;
    };
    SurveyModel.prototype.getTextProcessor = function () {
        return this;
    };
    //ISurveyTriggerOwner
    SurveyModel.prototype.getObjects = function (pages, questions) {
        var result = [];
        Array.prototype.push.apply(result, this.getPagesByNames(pages));
        Array.prototype.push.apply(result, this.getQuestionsByNames(questions));
        return result;
    };
    SurveyModel.prototype.setTriggerValue = function (name, value, isVariable) {
        if (!name)
            return;
        if (isVariable) {
            this.setVariable(name, value);
        }
        else {
            var question = this.getQuestionByName(name);
            if (!!question) {
                question.value = value;
            }
            else {
                var processor = new conditionProcessValue_ProcessValue();
                var firstName = processor.getFirstName(name);
                if (firstName == name) {
                    this.setValue(name, value);
                }
                else {
                    if (!this.getQuestionByName(firstName))
                        return;
                    var data = this.getUnbindValue(this.getFilteredValues());
                    processor.setValue(data, name, value);
                    this.setValue(firstName, data[firstName]);
                }
            }
        }
    };
    SurveyModel.prototype.copyTriggerValue = function (name, fromName, copyDisplayValue) {
        if (!name || !fromName)
            return;
        var value;
        if (copyDisplayValue) {
            value = this.processText("{" + fromName + "}", true);
        }
        else {
            var processor = new conditionProcessValue_ProcessValue();
            value = processor.getValue(fromName, this.getFilteredValues());
        }
        this.setTriggerValue(name, value, false);
    };
    SurveyModel.prototype.triggerExecuted = function (trigger) {
        this.onTriggerExecuted.fire(this, { trigger: trigger });
    };
    SurveyModel.prototype.startMovingQuestion = function () {
        this.isMovingQuestion = true;
    };
    SurveyModel.prototype.stopMovingQuestion = function () {
        this.isMovingQuestion = false;
    };
    Object.defineProperty(SurveyModel.prototype, "isQuestionDragging", {
        get: function () { return this.isMovingQuestion; },
        enumerable: false,
        configurable: true
    });
    /**
     * Focuses a question with a specified name. Switches the current page if needed.
     * @param name A question name.
     * @returns `false` if the survey does not contain a question with a specified name or this question is hidden; otherwise, `true`.
     * @see focusFirstQuestion
     * @see focusFirstQuestionAutomatic
     */
    SurveyModel.prototype.focusQuestion = function (name) {
        return this.focusQuestionByInstance(this.getQuestionByName(name, true));
    };
    SurveyModel.prototype.focusQuestionByInstance = function (question, onError) {
        var _a;
        if (onError === void 0) { onError = false; }
        if (!question || !question.isVisible || !question.page)
            return false;
        var oldQuestion = (_a = this.focusingQuestionInfo) === null || _a === void 0 ? void 0 : _a.question;
        if (oldQuestion === question)
            return false;
        this.focusingQuestionInfo = { question: question, onError: onError };
        this.skippedPages.push({ from: this.currentPage, to: question.page });
        var isNeedWaitForPageRendered = this.activePage !== question.page && !question.page.isStartPage;
        if (isNeedWaitForPageRendered) {
            this.currentPage = question.page;
        }
        if (!isNeedWaitForPageRendered) {
            this.focusQuestionInfo();
        }
        return true;
    };
    SurveyModel.prototype.focusQuestionInfo = function () {
        var _a;
        var question = (_a = this.focusingQuestionInfo) === null || _a === void 0 ? void 0 : _a.question;
        if (!!question && !question.isDisposed) {
            question.focus(this.focusingQuestionInfo.onError);
        }
        this.focusingQuestionInfo = undefined;
    };
    SurveyModel.prototype.questionEditFinishCallback = function (question, event) {
        var enterKeyAction = this.enterKeyAction || settings.enterKeyAction;
        if (enterKeyAction == "loseFocus")
            event.target.blur();
        if (enterKeyAction == "moveToNextEditor") {
            var allQuestions = this.currentPage.questions;
            var questionIndex = allQuestions.indexOf(question);
            if (questionIndex > -1 && questionIndex < allQuestions.length - 1) {
                allQuestions[questionIndex + 1].focus();
            }
            else {
                event.target.blur();
            }
        }
    };
    SurveyModel.prototype.elementWrapperComponentNameCore = function (componentName, element, wrapperName, reason, item) {
        if (this.onElementWrapperComponentName.isEmpty)
            return componentName;
        var options = { componentName: componentName, element: element, wrapperName: wrapperName, reason: reason, item: item };
        this.onElementWrapperComponentName.fire(this, options);
        return options.componentName;
    };
    SurveyModel.prototype.elementWrapperDataCore = function (data, element, wrapperName, reason, item) {
        if (this.onElementWrapperComponentData.isEmpty)
            return data;
        var options = { data: data, element: element, wrapperName: wrapperName, reason: reason, item: item };
        this.onElementWrapperComponentData.fire(this, options);
        return options.data;
    };
    SurveyModel.prototype.getElementWrapperComponentName = function (element, reason) {
        var res = reason === "logo-image" ? "sv-logo-image" : SurveyModel.TemplateRendererComponentName;
        return this.elementWrapperComponentNameCore(res, element, "component", reason);
    };
    SurveyModel.prototype.getQuestionContentWrapperComponentName = function (element) {
        return this.elementWrapperComponentNameCore(SurveyModel.TemplateRendererComponentName, element, "content-component");
    };
    SurveyModel.prototype.getRowWrapperComponentName = function (row) {
        return this.elementWrapperComponentNameCore(SurveyModel.TemplateRendererComponentName, row, "row");
    };
    SurveyModel.prototype.getItemValueWrapperComponentName = function (item, question) {
        return this.elementWrapperComponentNameCore(SurveyModel.TemplateRendererComponentName, question, "itemvalue", undefined, item);
    };
    SurveyModel.prototype.getElementWrapperComponentData = function (element, reason) {
        return this.elementWrapperDataCore(element, element, "component", reason);
    };
    SurveyModel.prototype.getRowWrapperComponentData = function (row) {
        return this.elementWrapperDataCore(row, row, "row");
    };
    SurveyModel.prototype.getItemValueWrapperComponentData = function (item, question) {
        return this.elementWrapperDataCore(item, question, "itemvalue", undefined, item);
    };
    SurveyModel.prototype.getMatrixCellTemplateData = function (cell) {
        var res = cell.question;
        return this.elementWrapperDataCore(res, res, "cell");
    };
    SurveyModel.prototype.searchText = function (text) {
        if (!!text)
            text = text.toLowerCase();
        var res = [];
        for (var i = 0; i < this.pages.length; i++) {
            this.pages[i].searchText(text, res);
        }
        return res;
    };
    SurveyModel.prototype.getSkeletonComponentName = function (element) {
        return this.skeletonComponentName;
    };
    /**
     * Adds an element to the survey layout.
     *
     * This method accepts an object with the following layout element properties:
     *
     * - `id`: `string` | `"timerpanel"` | `"progress-buttons"` | `"progress-questions"` | `"progress-pages"` | `"progress-correctquestions"` | `"progress-requiredquestions"` | `"toc-navigation"` | `"buttons-navigation"`\
     * A layout element identifier. You can use possible values to access and relocate or customize predefined layout elements.
     *
     * - `container`: `"header"` | `"footer"` | `"left"` | `"right"` | `"contentTop"` | `"contentBottom"`\
     * A layout container that holds the element. If you want to display the element within multiple containers, set this property to an array of possible values.
     *
     * - `component`: `string`\
     * The name of the component that renders the layout element.
     *
     * - `data`: `any`\
     * Data passed as props to `component`.
     *
     * [View Demo](https://surveyjs.io/form-library/examples/progress-bar-with-percentage/ (linkStyle))
     * @param layoutElement A layout element configuration.
     * @returns The configuration of the previous layout element with the same `id`.
     */
    SurveyModel.prototype.addLayoutElement = function (layoutElement) {
        var existingLayoutElement = this.removeLayoutElement(layoutElement.id);
        this.layoutElements.push(layoutElement);
        return existingLayoutElement;
    };
    SurveyModel.prototype.findLayoutElement = function (layoutElementId) {
        var layoutElement = this.layoutElements.filter(function (a) { return a.id === layoutElementId; })[0];
        return layoutElement;
    };
    SurveyModel.prototype.removeLayoutElement = function (layoutElementId) {
        var layoutElement = this.findLayoutElement(layoutElementId);
        if (!!layoutElement) {
            var layoutElementIndex = this.layoutElements.indexOf(layoutElement);
            this.layoutElements.splice(layoutElementIndex, 1);
        }
        return layoutElement;
    };
    SurveyModel.prototype.getContainerContent = function (container) {
        var containerLayoutElements = [];
        for (var _i = 0, _a = this.layoutElements; _i < _a.length; _i++) {
            var layoutElement = _a[_i];
            if (this.mode !== "display" && isStrCiEqual(layoutElement.id, "timerpanel")) {
                if (container === "header") {
                    if (this.isTimerPanelShowingOnTop && !this.isShowStartingPage) {
                        containerLayoutElements.push(layoutElement);
                    }
                }
                if (container === "footer") {
                    if (this.isTimerPanelShowingOnBottom && !this.isShowStartingPage) {
                        containerLayoutElements.push(layoutElement);
                    }
                }
            }
            else if (this.state === "running" && isStrCiEqual(layoutElement.id, this.progressBarComponentName)) {
                if (this.questionsOnPageMode != "singlePage") {
                    var headerLayoutElement = this.findLayoutElement("advanced-header");
                    var advHeader = headerLayoutElement && headerLayoutElement.data;
                    var isBelowHeader = !advHeader || advHeader.hasBackground;
                    if (isStrCiEqual(this.showProgressBar, "aboveHeader")) {
                        isBelowHeader = false;
                    }
                    if (isStrCiEqual(this.showProgressBar, "belowHeader")) {
                        isBelowHeader = true;
                    }
                    if (container === "header" && !isBelowHeader) {
                        layoutElement.index = -150;
                        if (this.isShowProgressBarOnTop && !this.isShowStartingPage) {
                            containerLayoutElements.push(layoutElement);
                        }
                    }
                    if (container === "center" && isBelowHeader) {
                        if (!!layoutElement.index) {
                            delete layoutElement.index;
                        }
                        if (this.isShowProgressBarOnTop && !this.isShowStartingPage) {
                            containerLayoutElements.push(layoutElement);
                        }
                    }
                    if (container === "footer") {
                        if (this.isShowProgressBarOnBottom && !this.isShowStartingPage) {
                            containerLayoutElements.push(layoutElement);
                        }
                    }
                }
            }
            else if (isStrCiEqual(layoutElement.id, "buttons-navigation")) {
                if (container === "contentTop") {
                    if (["top", "both"].indexOf(this.isNavigationButtonsShowing) !== -1) {
                        containerLayoutElements.push(layoutElement);
                    }
                }
                if (container === "contentBottom") {
                    if (["bottom", "both"].indexOf(this.isNavigationButtonsShowing) !== -1) {
                        containerLayoutElements.push(layoutElement);
                    }
                }
            }
            else if (this.state === "running" && isStrCiEqual(layoutElement.id, "toc-navigation") && this.showTOC) {
                if (container === "left") {
                    if (["left", "both"].indexOf(this.tocLocation) !== -1) {
                        containerLayoutElements.push(layoutElement);
                    }
                }
                if (container === "right") {
                    if (["right", "both"].indexOf(this.tocLocation) !== -1) {
                        containerLayoutElements.push(layoutElement);
                    }
                }
            }
            else if (isStrCiEqual(layoutElement.id, "advanced-header")) {
                if ((this.state === "running" || this.state === "starting") && layoutElement.container === container) {
                    containerLayoutElements.push(layoutElement);
                }
            }
            else {
                if (Array.isArray(layoutElement.container) && layoutElement.container.indexOf(container) !== -1 || layoutElement.container === container) {
                    containerLayoutElements.push(layoutElement);
                }
            }
        }
        containerLayoutElements.sort(function (a, b) { return (a.index || 0) - (b.index || 0); });
        return containerLayoutElements;
    };
    SurveyModel.prototype.processPopupVisiblityChanged = function (question, popup, visible) {
        this.onPopupVisibleChanged.fire(this, { question: question, popup: popup, visible: visible });
    };
    SurveyModel.prototype.processOpenDropdownMenu = function (question, options) {
        var newOptions = Object.assign({ question: question }, options);
        this.onOpenDropdownMenu.fire(this, newOptions);
        options.menuType = newOptions.menuType;
    };
    /**
     * Applies a specified theme to the survey.
     *
     * [Themes & Styles](https://surveyjs.io/form-library/documentation/manage-default-themes-and-styles (linkStyle))
     * @param theme An [`ITheme`](https://surveyjs.io/form-library/documentation/api-reference/itheme) object with theme settings.
     */
    SurveyModel.prototype.applyTheme = function (theme) {
        var _this = this;
        if (!theme)
            return;
        Object.keys(theme).forEach(function (key) {
            if (key === "header") {
                return;
            }
            if (key === "isPanelless") {
                _this.isCompact = theme[key];
            }
            else {
                _this[key] = theme[key];
            }
        });
        if (this.headerView === "advanced" || "header" in theme) {
            this.removeLayoutElement("advanced-header");
            var advHeader = new header_Cover();
            advHeader.fromTheme(theme);
            this.insertAdvancedHeader(advHeader);
        }
        this.themeChanged(theme);
    };
    SurveyModel.prototype.themeChanged = function (theme) {
        this.getAllQuestions().forEach(function (q) { return q.themeChanged(theme); });
    };
    /**
     * Disposes of the survey model.
     *
     * Call this method to release resources if your application contains multiple survey models or if you re-create a survey model at runtime.
     */
    SurveyModel.prototype.dispose = function () {
        this.unConnectEditingObj();
        this.removeScrollEventListener();
        this.destroyResizeObserver();
        this.rootElement = undefined;
        if (this.layoutElements) {
            for (var i = 0; i < this.layoutElements.length; i++) {
                if (!!this.layoutElements[i].data && this.layoutElements[i].data !== this && this.layoutElements[i].data.dispose) {
                    this.layoutElements[i].data.dispose();
                }
            }
            this.layoutElements.splice(0, this.layoutElements.length);
        }
        _super.prototype.dispose.call(this);
        this.editingObj = null;
        if (!this.pages)
            return;
        this.currentPage = null;
        for (var i = 0; i < this.pages.length; i++) {
            this.pages[i].setSurveyImpl(undefined);
            this.pages[i].dispose();
        }
        this.pages.splice(0, this.pages.length);
        if (this.disposeCallback) {
            this.disposeCallback();
        }
    };
    // private _lastScrollTop = 0;
    SurveyModel.prototype._isElementShouldBeSticky = function (selector) {
        if (!selector)
            return false;
        var topStickyContainer = this.rootElement.querySelector(selector);
        if (!!topStickyContainer) {
            // const scrollDirection = this.rootElement.scrollTop > this._lastScrollTop ? "down" : "up";
            // this._lastScrollTop = this.rootElement.scrollTop;
            return this.rootElement.scrollTop > 0 && topStickyContainer.getBoundingClientRect().y <= this.rootElement.getBoundingClientRect().y;
        }
        return false;
    };
    SurveyModel.prototype.onScroll = function () {
        if (!!this.rootElement) {
            if (this._isElementShouldBeSticky(".sv-components-container-center")) {
                this.rootElement.classList && this.rootElement.classList.add("sv-root--sticky-top");
            }
            else {
                this.rootElement.classList && this.rootElement.classList.remove("sv-root--sticky-top");
            }
        }
        if (this.onScrollCallback) {
            this.onScrollCallback();
        }
    };
    SurveyModel.prototype.addScrollEventListener = function () {
        var _this = this;
        var _a;
        this.scrollHandler = function () { _this.onScroll(); };
        this.rootElement.addEventListener("scroll", this.scrollHandler);
        if (!!this.rootElement.getElementsByTagName("form")[0]) {
            this.rootElement.getElementsByTagName("form")[0].addEventListener("scroll", this.scrollHandler);
        }
        if (!!this.css.rootWrapper) {
            (_a = this.rootElement.getElementsByClassName(this.css.rootWrapper)[0]) === null || _a === void 0 ? void 0 : _a.addEventListener("scroll", this.scrollHandler);
        }
    };
    SurveyModel.prototype.removeScrollEventListener = function () {
        var _a;
        if (!!this.rootElement && !!this.scrollHandler) {
            this.rootElement.removeEventListener("scroll", this.scrollHandler);
            if (!!this.rootElement.getElementsByTagName("form")[0]) {
                this.rootElement.getElementsByTagName("form")[0].removeEventListener("scroll", this.scrollHandler);
            }
            if (!!this.css.rootWrapper) {
                (_a = this.rootElement.getElementsByClassName(this.css.rootWrapper)[0]) === null || _a === void 0 ? void 0 : _a.removeEventListener("scroll", this.scrollHandler);
            }
        }
    };
    SurveyModel.TemplateRendererComponentName = "sv-template-renderer";
    // private static stylesManager: StylesManager = null;
    SurveyModel.platform = "unknown";
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "completedCss", void 0);
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "completedBeforeCss", void 0);
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "loadingBodyCss", void 0);
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "containerCss", void 0);
    survey_decorate([
        jsonobject_property({ onSet: function (newValue, target) { target.updateCss(); } })
    ], SurveyModel.prototype, "fitToContainer", void 0);
    survey_decorate([
        jsonobject_property({
            onSet: function (newValue, target) {
                if (newValue === "advanced") {
                    var layoutElement = target.findLayoutElement("advanced-header");
                    if (!layoutElement) {
                        var advHeader = new header_Cover();
                        advHeader.logoPositionX = target.logoPosition === "right" ? "right" : "left";
                        advHeader.logoPositionY = "middle";
                        advHeader.titlePositionX = target.logoPosition === "right" ? "left" : "right";
                        advHeader.titlePositionY = "middle";
                        advHeader.descriptionPositionX = target.logoPosition === "right" ? "left" : "right";
                        advHeader.descriptionPositionY = "middle";
                        target.insertAdvancedHeader(advHeader);
                    }
                }
                else {
                    target.removeLayoutElement("advanced-header");
                }
            }
        })
    ], SurveyModel.prototype, "headerView", void 0);
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "showBrandInfo", void 0);
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "enterKeyAction", void 0);
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "lazyRenderingFirstBatchSizeValue", void 0);
    survey_decorate([
        jsonobject_property({ defaultValue: true })
    ], SurveyModel.prototype, "titleIsEmpty", void 0);
    survey_decorate([
        jsonobject_property({ defaultValue: {} })
    ], SurveyModel.prototype, "cssVariables", void 0);
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "_isMobile", void 0);
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "_isCompact", void 0);
    survey_decorate([
        jsonobject_property({
            onSet: function (newValue, target) {
                target.updateCss();
            }
        })
    ], SurveyModel.prototype, "backgroundImage", void 0);
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "renderBackgroundImage", void 0);
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "backgroundImageFit", void 0);
    survey_decorate([
        jsonobject_property({
            onSet: function (newValue, target) {
                target.updateCss();
            }
        })
    ], SurveyModel.prototype, "backgroundImageAttachment", void 0);
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "backgroundImageStyle", void 0);
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "wrapperFormCss", void 0);
    survey_decorate([
        jsonobject_property({
            getDefaultValue: function (self) {
                return self.progressBarType === "buttons";
            },
        })
    ], SurveyModel.prototype, "progressBarShowPageTitles", void 0);
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "progressBarShowPageNumbers", void 0);
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "progressBarInheritWidthFrom", void 0);
    survey_decorate([
        jsonobject_property({ defaultValue: true })
    ], SurveyModel.prototype, "validationEnabled", void 0);
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "rootCss", void 0);
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "gridLayoutEnabled", void 0);
    survey_decorate([
        jsonobject_property()
    ], SurveyModel.prototype, "calculatedWidthMode", void 0);
    survey_decorate([
        propertyArray()
    ], SurveyModel.prototype, "layoutElements", void 0);
    return SurveyModel;
}(survey_element_SurveyElementCore));

function isStrCiEqual(a, b) {
    if (!a)
        return false;
    if (!b)
        return false;
    return a.toUpperCase() === b.toUpperCase();
}
Serializer.addClass("survey", [
    {
        name: "locale",
        choices: function () {
            return surveyLocalization.getLocales(true);
        },
        onGetValue: function (obj) {
            return obj.locale == surveyLocalization.defaultLocale ? null : obj.locale;
        },
    },
    { name: "title", serializationProperty: "locTitle", dependsOn: "locale" },
    {
        name: "description:text",
        serializationProperty: "locDescription",
        dependsOn: "locale",
    },
    { name: "logo:file", serializationProperty: "locLogo" },
    { name: "logoWidth", default: "300px", minValue: 0 },
    { name: "logoHeight", default: "200px", minValue: 0 },
    {
        name: "logoFit",
        default: "contain",
        choices: ["none", "contain", "cover", "fill"],
    },
    {
        name: "logoPosition",
        default: "left",
        choices: ["none", "left", "right", "top", "bottom"],
    },
    { name: "focusFirstQuestionAutomatic:boolean" },
    { name: "focusOnFirstError:boolean", default: true },
    { name: "completedHtml:html", serializationProperty: "locCompletedHtml" },
    {
        name: "completedBeforeHtml:html",
        serializationProperty: "locCompletedBeforeHtml",
    },
    {
        name: "completedHtmlOnCondition:htmlconditions",
        className: "htmlconditionitem", isArray: true
    },
    { name: "loadingHtml:html", serializationProperty: "locLoadingHtml" },
    { name: "pages:surveypages", className: "page", isArray: true, onSerializeValue: function (obj) { return obj.originalPages || obj.pages; } },
    {
        name: "elements",
        alternativeName: "questions",
        baseClassName: "question",
        visible: false,
        isLightSerializable: false,
        onGetValue: function (obj) {
            return null;
        },
        onSetValue: function (obj, value, jsonConverter) {
            obj.pages.splice(0, obj.pages.length);
            var page = obj.addNewPage("");
            jsonConverter.toObject({ questions: value }, page, jsonConverter === null || jsonConverter === void 0 ? void 0 : jsonConverter.options);
        },
    },
    {
        name: "triggers:triggers",
        baseClassName: "surveytrigger",
        classNamePart: "trigger",
    },
    {
        name: "calculatedValues:calculatedvalues",
        className: "calculatedvalue", isArray: true
    },
    { name: "surveyId", visible: false },
    { name: "surveyPostId", visible: false },
    { name: "surveyShowDataSaving:boolean", visible: false },
    "cookieName",
    "sendResultOnPageNext:boolean",
    {
        name: "showNavigationButtons",
        default: "bottom",
        choices: ["none", "top", "bottom", "both"],
    },
    {
        name: "showPrevButton:boolean",
        default: true,
        visibleIf: function (obj) { return obj.showNavigationButtons !== "none"; }
    },
    { name: "showTitle:boolean", default: true },
    { name: "showPageTitles:boolean", default: true },
    { name: "showCompletedPage:boolean", default: true },
    "navigateToUrl",
    {
        name: "navigateToUrlOnCondition:urlconditions",
        className: "urlconditionitem", isArray: true
    },
    {
        name: "questionsOrder",
        default: "initial",
        choices: ["initial", "random"],
    },
    {
        name: "matrixDragHandleArea",
        visible: false,
        default: "entireItem",
        choices: ["entireItem", "icon"]
    },
    "showPageNumbers:boolean",
    {
        name: "showQuestionNumbers",
        default: "on",
        choices: ["on", "onPage", "off"],
    },
    {
        name: "questionTitleLocation",
        default: "top",
        choices: ["top", "bottom", "left"],
    },
    {
        name: "questionDescriptionLocation",
        default: "underTitle",
        choices: ["underInput", "underTitle"],
    },
    { name: "questionErrorLocation", default: "top", choices: ["top", "bottom"] },
    {
        name: "showProgressBar",
        default: "off",
        choices: ["off", "auto", "aboveheader", "belowheader", "bottom", "topbottom"],
    },
    {
        name: "progressBarType",
        default: "pages",
        choices: [
            "pages",
            "questions",
            "requiredQuestions",
            "correctQuestions",
        ],
        visibleIf: function (obj) { return obj.showProgressBar !== "off"; }
    },
    {
        name: "progressBarShowPageTitles:switch",
        category: "navigation",
        visibleIf: function (obj) { return obj.showProgressBar !== "off" && obj.progressBarType === "pages"; }
    },
    {
        name: "progressBarShowPageNumbers:switch",
        default: false,
        category: "navigation",
        visibleIf: function (obj) { return obj.showProgressBar !== "off" && obj.progressBarType === "pages"; }
    },
    {
        name: "progressBarInheritWidthFrom",
        default: "container",
        choices: ["container", "survey"],
        category: "navigation",
        visibleIf: function (obj) { return obj.showProgressBar !== "off" && obj.progressBarType === "pages"; }
    },
    {
        name: "showTOC:switch",
        default: false
    },
    {
        name: "tocLocation", default: "left", choices: ["left", "right"],
        dependsOn: ["showTOC"],
        visibleIf: function (survey) { return !!survey && survey.showTOC; }
    },
    { name: "mode", default: "edit", choices: ["edit", "display"] },
    { name: "storeOthersAsComment:boolean", default: true },
    { name: "maxTextLength:number", default: 0, minValue: 0 },
    { name: "maxOthersLength:number", default: 0, minValue: 0 },
    {
        name: "goNextPageAutomatic:boolean",
        onSetValue: function (obj, value) {
            if (value !== "autogonext") {
                value = helpers_Helpers.isTwoValueEquals(value, true);
            }
            obj.setPropertyValue("goNextPageAutomatic", value);
        }
    },
    {
        name: "allowCompleteSurveyAutomatic:boolean", default: true,
        visibleIf: function (obj) { return obj.goNextPageAutomatic === true; }
    },
    {
        name: "clearInvisibleValues",
        default: "onComplete",
        choices: ["none", "onComplete", "onHidden", "onHiddenContainer"],
    },
    {
        name: "checkErrorsMode",
        default: "onNextPage",
        choices: ["onNextPage", "onValueChanged", "onComplete"],
    },
    { name: "validateVisitedEmptyFields:boolean", dependsOn: "checkErrorsMode", visibleIf: function (obj) { return obj.checkErrorsMode === "onValueChanged"; } },
    {
        name: "textUpdateMode",
        default: "onBlur",
        choices: ["onBlur", "onTyping"],
    },
    { name: "autoGrowComment:boolean", default: false },
    { name: "allowResizeComment:boolean", default: true },
    { name: "commentAreaRows:number", minValue: 1 },
    {
        name: "startSurveyText",
        serializationProperty: "locStartSurveyText",
        visibleIf: function (obj) { return obj.firstPageIsStarted; }
    },
    {
        name: "pagePrevText",
        serializationProperty: "locPagePrevText",
        visibleIf: function (obj) { return obj.showNavigationButtons !== "none" && obj.showPrevButton; }
    },
    {
        name: "pageNextText",
        serializationProperty: "locPageNextText",
        visibleIf: function (obj) { return obj.showNavigationButtons !== "none"; }
    },
    {
        name: "completeText",
        serializationProperty: "locCompleteText",
        visibleIf: function (obj) { return obj.showNavigationButtons !== "none"; }
    },
    {
        name: "previewText",
        serializationProperty: "locPreviewText",
        visibleIf: function (obj) { return obj.showPreviewBeforeComplete !== "noPreview"; }
    },
    {
        name: "editText",
        serializationProperty: "locEditText",
        visibleIf: function (obj) { return obj.showPreviewBeforeComplete !== "noPreview"; }
    },
    { name: "requiredText", default: "*" },
    {
        name: "questionStartIndex",
        dependsOn: ["showQuestionNumbers"],
        visibleIf: function (survey) { return !survey || survey.showQuestionNumbers !== "off"; }
    },
    {
        name: "questionTitlePattern",
        default: "numTitleRequire",
        dependsOn: ["questionStartIndex", "requiredText"],
        choices: function (obj) {
            if (!obj)
                return [];
            return obj.getQuestionTitlePatternOptions();
        },
    },
    {
        name: "questionTitleTemplate",
        visible: false,
        isSerializable: false,
        serializationProperty: "locQuestionTitleTemplate",
    },
    { name: "firstPageIsStarted:boolean", default: false },
    {
        name: "isSinglePage:boolean",
        default: false,
        visible: false,
        isSerializable: false,
    },
    {
        name: "questionsOnPageMode",
        default: "standard",
        choices: ["standard", "singlePage", "questionPerPage"],
    },
    {
        name: "showPreviewBeforeComplete",
        default: "noPreview",
        choices: ["noPreview", "showAllQuestions", "showAnsweredQuestions"],
    },
    { name: "maxTimeToFinish:number", default: 0, minValue: 0 },
    { name: "maxTimeToFinishPage:number", default: 0, minValue: 0 },
    {
        name: "showTimerPanel",
        default: "none",
        choices: ["none", "top", "bottom"],
    },
    {
        name: "showTimerPanelMode",
        default: "all",
        choices: ["page", "survey", "all"],
    },
    {
        name: "widthMode",
        default: "auto",
        choices: ["auto", "static", "responsive"],
    },
    { name: "gridLayoutEnabled:boolean", default: false },
    { name: "width", visibleIf: function (obj) { return obj.widthMode === "static"; } },
    { name: "fitToContainer:boolean", default: true, visible: false },
    { name: "headerView", default: "basic", choices: ["basic", "advanced"], visible: false },
    { name: "backgroundImage:file", visible: false },
    { name: "backgroundImageFit", default: "cover", choices: ["auto", "contain", "cover"], visible: false },
    { name: "backgroundImageAttachment", default: "scroll", choices: ["scroll", "fixed"], visible: false },
    { name: "backgroundOpacity:number", minValue: 0, maxValue: 1, default: 1, visible: false },
    { name: "showBrandInfo:boolean", default: false, visible: false }
]);

// CONCATENATED MODULE: ./packages/survey-core/src/question_baseselect.ts
var question_baseselect_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var question_baseselect_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};












/**
 * A base class for multiple-choice question types ([Checkboxes](https://surveyjs.io/form-library/documentation/questioncheckboxmodel), [Dropdown](https://surveyjs.io/form-library/documentation/questiondropdownmodel), [Radio Button Group](https://surveyjs.io/form-library/documentation/questionradiogroupmodel), etc.).
 */
var question_baseselect_QuestionSelectBase = /** @class */ (function (_super) {
    question_baseselect_extends(QuestionSelectBase, _super);
    function QuestionSelectBase(name) {
        var _this = _super.call(this, name) || this;
        _this.otherItemValue = new itemvalue_ItemValue("other");
        _this.isSettingDefaultValue = false;
        _this.isSettingComment = false;
        _this.isRunningChoices = false;
        _this.isFirstLoadChoicesFromUrl = true;
        _this.isUpdatingChoicesDependedQuestions = false;
        _this.headItemsCount = 0;
        _this.footItemsCount = 0;
        _this.prevIsOtherSelected = false;
        _this.noneItemValue = _this.createDefaultItem(settings.noneItemValue, "noneText", "noneItemText");
        _this.refuseItemValue = _this.createDefaultItem(settings.refuseItemValue, "refuseText", "refuseItemText");
        _this.dontKnowItemValue = _this.createDefaultItem(settings.dontKnowItemValue, "dontKnowText", "dontKnowItemText");
        _this.createItemValues("choices");
        _this.registerPropertyChangedHandlers(["choices"], function () {
            if (!_this.filterItems()) {
                _this.onVisibleChoicesChanged();
            }
        });
        _this.registerPropertyChangedHandlers(["choicesFromQuestion", "choicesFromQuestionMode", "choiceValuesFromQuestion",
            "choiceTextsFromQuestion", "showNoneItem", "showRefuseItem", "showDontKnowItem", "isUsingRestful", "isMessagePanelVisible"], function () {
            _this.onVisibleChoicesChanged();
        });
        _this.registerPropertyChangedHandlers(["hideIfChoicesEmpty"], function () {
            _this.onVisibleChanged();
        });
        _this.createNewArray("visibleChoices");
        _this.setNewRestfulProperty();
        var locOtherText = _this.createLocalizableString("otherText", _this.otherItemValue, true, "otherItemText");
        _this.createLocalizableString("otherErrorText", _this, true, "otherRequiredError");
        _this.otherItemValue.locOwner = _this;
        _this.otherItemValue.setLocText(locOtherText);
        _this.choicesByUrl.createItemValue = function (value) {
            return _this.createItemValue(value);
        };
        _this.choicesByUrl.beforeSendRequestCallback = function () {
            _this.onBeforeSendRequest();
        };
        _this.choicesByUrl.getResultCallback = function (items) {
            _this.onLoadChoicesFromUrl(items);
        };
        _this.choicesByUrl.updateResultCallback = function (items, serverResult) {
            if (_this.survey) {
                return _this.survey.updateChoicesFromServer(_this, items, serverResult);
            }
            return items;
        };
        return _this;
    }
    Object.defineProperty(QuestionSelectBase.prototype, "waitingChoicesByURL", {
        get: function () {
            return !this.isChoicesLoaded && this.hasChoicesUrl;
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.getType = function () {
        return "selectbase";
    };
    QuestionSelectBase.prototype.dispose = function () {
        _super.prototype.dispose.call(this);
        var q = this.getQuestionWithChoices();
        if (!!q) {
            q.removeDependedQuestion(this);
        }
    };
    QuestionSelectBase.prototype.resetDependedQuestion = function () {
        this.choicesFromQuestion = "";
    };
    Object.defineProperty(QuestionSelectBase.prototype, "otherId", {
        get: function () {
            return this.id + "_other";
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.getCommentElementsId = function () {
        return [this.commentId, this.otherId];
    };
    QuestionSelectBase.prototype.getItemValueType = function () {
        return "itemvalue";
    };
    QuestionSelectBase.prototype.createItemValue = function (value, text) {
        var res = Serializer.createClass(this.getItemValueType(), { value: value });
        res.locOwner = this;
        if (!!text)
            res.text = text;
        return res;
    };
    Object.defineProperty(QuestionSelectBase.prototype, "isUsingCarryForward", {
        get: function () {
            return !!this.carryForwardQuestionType;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "carryForwardQuestionType", {
        get: function () {
            return this.getPropertyValue("carryForwardQuestionType");
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.setCarryForwardQuestionType = function (selBaseQuestion, arrayQuestion) {
        var mode = selBaseQuestion ? "select" : (arrayQuestion ? "array" : undefined);
        this.setPropertyValue("carryForwardQuestionType", mode);
    };
    Object.defineProperty(QuestionSelectBase.prototype, "isUsingRestful", {
        get: function () {
            return this.getPropertyValueWithoutDefault("isUsingRestful") || false;
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.updateIsUsingRestful = function () {
        this.setPropertyValueDirectly("isUsingRestful", this.hasChoicesUrl);
    };
    QuestionSelectBase.prototype.supportGoNextPageError = function () {
        return !this.isOtherSelected || !!this.otherValue;
    };
    QuestionSelectBase.prototype.isLayoutTypeSupported = function (layoutType) {
        return true;
    };
    QuestionSelectBase.prototype.localeChanged = function () {
        _super.prototype.localeChanged.call(this);
        if (this.choicesOrder !== "none") {
            this.updateVisibleChoices();
            this.onVisibleChoicesChanged();
        }
    };
    QuestionSelectBase.prototype.locStrsChanged = function () {
        _super.prototype.locStrsChanged.call(this);
        if (!!this.choicesFromUrl) {
            itemvalue_ItemValue.locStrsChanged(this.choicesFromUrl);
            itemvalue_ItemValue.locStrsChanged(this.visibleChoices);
        }
        if (this.isUsingCarryForward) {
            itemvalue_ItemValue.locStrsChanged(this.visibleChoices);
        }
    };
    QuestionSelectBase.prototype.updatePrevOtherErrorValue = function (val) {
        var oldVal = this.otherValue;
        if (val !== oldVal) {
            this.prevOtherErrorValue = oldVal;
        }
    };
    Object.defineProperty(QuestionSelectBase.prototype, "otherValue", {
        get: function () {
            if (!this.showCommentArea)
                return this.comment;
            return this.otherValueCore;
        },
        set: function (val) {
            this.updatePrevOtherErrorValue(val);
            if (!this.showCommentArea) {
                this.comment = val;
            }
            else {
                this.setOtherValueInternally(val);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "otherValueCore", {
        get: function () {
            return this.getPropertyValue("otherValue");
        },
        set: function (val) {
            this.setPropertyValue("otherValue", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "otherItem", {
        /**
         * Returns the "Other" choice item. Use this property to change the item's `value` or `text`.
         * @see showOtherItem
         */
        get: function () {
            return this.otherItemValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "isOtherSelected", {
        /**
         * Returns `true` if the "Other" choice item is selected.
         * @see showOtherItem
         */
        get: function () {
            return this.hasOther && this.getHasOther(this.renderedValue);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "isNoneSelected", {
        get: function () {
            return this.showNoneItem && this.getIsItemValue(this.renderedValue, this.noneItem);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "showNoneItem", {
        /**
         * Specifies whether to display the "None" choice item.
         *
         * When users select the "None" item in multi-select questions, all other items become unselected.
         * @see noneItem
         * @see noneText
         * @see [settings.noneItemValue](https://surveyjs.io/form-library/documentation/api-reference/settings#noneItemValue)
         * @see [settings.specialChoicesOrder](https://surveyjs.io/form-library/documentation/api-reference/settings#specialChoicesOrder)
         */
        get: function () {
            return this.getPropertyValue("showNoneItem");
        },
        set: function (val) {
            this.setPropertyValue("showNoneItem", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "hasNone", {
        get: function () {
            return this.showNoneItem;
        },
        set: function (val) {
            this.showNoneItem = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "noneItem", {
        /**
         * Returns the "None" choice item. Use this property to change the item's `value` or `text`.
         * @see showNoneItem
         */
        get: function () {
            return this.noneItemValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "noneText", {
        /**
         * Gets or sets a caption for the "None" choice item.
         * @see showNoneItem
         */
        get: function () {
            return this.getLocalizableStringText("noneText");
        },
        set: function (val) {
            this.setLocalizableStringText("noneText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "locNoneText", {
        get: function () {
            return this.getLocalizableString("noneText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "showRefuseItem", {
        /**
         * Specifies whether to display the "Refuse to answer" choice item.
         *
         * When users select the "Refuse to answer" item in multi-select questions, all other items become unselected.
         * @see refuseItem
         * @see refuseItemText
         * @see [settings.refuseItemValue](https://surveyjs.io/form-library/documentation/api-reference/settings#refuseItemValue)
         * @see [settings.specialChoicesOrder](https://surveyjs.io/form-library/documentation/api-reference/settings#specialChoicesOrder)
         */
        get: function () {
            return this.getPropertyValue("showRefuseItem");
        },
        set: function (val) {
            this.setPropertyValue("showRefuseItem", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "refuseItem", {
        /**
         * Returns the "Refuse to answer" choice item. Use this property to change the item's `value` or `text`.
         * @see showRefuseItem
         */
        get: function () {
            return this.refuseItemValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "refuseText", {
        /**
         * Gets or sets a caption for the "Refuse to answer" choice item.
         * @see showRefuseItem
         */
        get: function () {
            return this.getLocalizableStringText("refuseText");
        },
        set: function (val) {
            this.setLocalizableStringText("refuseText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "locRefuseText", {
        get: function () {
            return this.getLocalizableString("refuseText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "showDontKnowItem", {
        /**
         * Specifies whether to display the "Don't know" choice item.
         *
         * When users select the "Don't know" item in multi-select questions, all other items become unselected.
         * @see dontKnowItem
         * @see dontKnowItemText
         * @see [settings.dontKnowItemValue](https://surveyjs.io/form-library/documentation/api-reference/settings#dontKnowItemValue)
         * @see [settings.specialChoicesOrder](https://surveyjs.io/form-library/documentation/api-reference/settings#specialChoicesOrder)
         */
        get: function () {
            return this.getPropertyValue("showDontKnowItem");
        },
        set: function (val) {
            this.setPropertyValue("showDontKnowItem", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "dontKnowItem", {
        /**
         * Returns the "Don't know" choice item. Use this property to change the item's `value` or `text`.
         * @see showDontKnowItem
         */
        get: function () {
            return this.dontKnowItemValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "dontKnowText", {
        /**
         * Gets or sets a caption for the "Don't know" choice item.
         * @see showDontKnowItem
         */
        get: function () {
            return this.getLocalizableStringText("dontKnowText");
        },
        set: function (val) {
            this.setLocalizableStringText("dontKnowText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "locDontKnowText", {
        get: function () {
            return this.getLocalizableString("dontKnowText");
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.createDefaultItem = function (defaultValue, name, locName) {
        var item = new itemvalue_ItemValue(defaultValue);
        var locStr = this.createLocalizableString(name, item, true, locName);
        item.locOwner = this;
        item.setLocText(locStr);
        return item;
    };
    Object.defineProperty(QuestionSelectBase.prototype, "choicesVisibleIf", {
        /**
         * A Boolean expression that is evaluated against each choice item. If the expression evaluates to `false`, the choice item becomes hidden.
         *
         * A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
         *
         * Use the `{item}` placeholder to reference the current choice item in the expression.
         *
         * Refer to the following help topic for more information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see visibleIf
         * @see choicesEnableIf
         */
        get: function () {
            return this.getPropertyValue("choicesVisibleIf", "");
        },
        set: function (val) {
            this.setPropertyValue("choicesVisibleIf", val);
            this.filterItems();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "choicesEnableIf", {
        /**
         * A Boolean expression that is evaluated against each choice item. If the expression evaluates to `false`, the choice item becomes read-only.
         *
         * A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
         *
         * Use the `{item}` placeholder to reference the current choice item in the expression.
         *
         * Refer to the following help topic for more information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey-conditional-logic#conditional-visibility).
         * @see enableIf
         * @see choicesVisibleIf
         */
        get: function () {
            return this.getPropertyValue("choicesEnableIf", "");
        },
        set: function (val) {
            this.setPropertyValue("choicesEnableIf", val);
            this.filterItems();
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.surveyChoiceItemVisibilityChange = function () {
        this.filterItems();
    };
    QuestionSelectBase.prototype.runCondition = function (values, properties) {
        _super.prototype.runCondition.call(this, values, properties);
        this.runItemsEnableCondition(values, properties);
        this.runItemsCondition(values, properties);
        this.choices.forEach(function (item) {
            item.runConditionCore(values, properties);
        });
    };
    QuestionSelectBase.prototype.isTextValue = function () {
        return true; //for comments and others
    };
    QuestionSelectBase.prototype.setDefaultValue = function () {
        this.isSettingDefaultValue =
            !this.isValueEmpty(this.defaultValue) &&
                this.hasUnknownValue(this.defaultValue);
        this.prevOtherValue = undefined;
        var prevComment = this.comment;
        _super.prototype.setDefaultValue.call(this);
        this.isSettingDefaultValue = false;
        if (this.comment && this.getStoreOthersAsComment() && prevComment !== this.comment) {
            this.setValueCore(this.setOtherValueIntoValue(this.value));
            this.setCommentIntoData(this.comment);
        }
    };
    QuestionSelectBase.prototype.getIsMultipleValue = function () {
        return false;
    };
    QuestionSelectBase.prototype.convertDefaultValue = function (val) {
        if (val == null || val == undefined)
            return val;
        if (this.getIsMultipleValue()) {
            if (!Array.isArray(val))
                return [val];
        }
        else {
            if (Array.isArray(val) && val.length > 0)
                return val[0];
        }
        return val;
    };
    QuestionSelectBase.prototype.filterItems = function () {
        if (this.isLoadingFromJson ||
            !this.data ||
            this.areInvisibleElementsShowing)
            return false;
        var values = this.getDataFilteredValues();
        var properties = this.getDataFilteredProperties();
        this.runItemsEnableCondition(values, properties);
        return this.runItemsCondition(values, properties);
    };
    QuestionSelectBase.prototype.runItemsCondition = function (values, properties) {
        this.setConditionalChoicesRunner();
        var hasChanges = this.runConditionsForItems(values, properties);
        if (!!this.filteredChoicesValue &&
            this.filteredChoicesValue.length === this.activeChoices.length) {
            this.filteredChoicesValue = undefined;
        }
        if (hasChanges) {
            this.onVisibleChoicesChanged();
            this.clearIncorrectValues();
        }
        return hasChanges;
    };
    QuestionSelectBase.prototype.runItemsEnableCondition = function (values, properties) {
        var _this = this;
        this.setConditionalEnableChoicesRunner();
        var hasChanged = itemvalue_ItemValue.runEnabledConditionsForItems(this.activeChoices, this.conditionChoicesEnableIfRunner, values, properties, function (item, val) {
            return val && _this.onEnableItemCallBack(item);
        });
        if (hasChanged) {
            this.clearDisabledValues();
        }
        this.onAfterRunItemsEnableCondition();
    };
    QuestionSelectBase.prototype.onAfterRunItemsEnableCondition = function () { };
    QuestionSelectBase.prototype.onEnableItemCallBack = function (item) {
        return true;
    };
    QuestionSelectBase.prototype.onSelectedItemValuesChangedHandler = function (newValue) {
        var _a;
        (_a = this.survey) === null || _a === void 0 ? void 0 : _a.loadedChoicesFromServer(this);
    };
    QuestionSelectBase.prototype.getItemIfChoicesNotContainThisValue = function (value, text) {
        if (this.waitingChoicesByURL) {
            return this.createItemValue(value, text);
        }
        else {
            return null;
        }
    };
    QuestionSelectBase.prototype.getSingleSelectedItem = function () {
        var selectedItemValues = this.selectedItemValues;
        if (this.isEmpty())
            return null;
        var itemValue = itemvalue_ItemValue.getItemByValue(this.visibleChoices, this.value);
        this.onGetSingleSelectedItem(itemValue);
        if (!itemValue && (!selectedItemValues || this.value != selectedItemValues.id)) {
            this.updateSelectedItemValues();
        }
        return itemValue || selectedItemValues || (this.isOtherSelected ? this.otherItem : this.getItemIfChoicesNotContainThisValue(this.value));
    };
    QuestionSelectBase.prototype.onGetSingleSelectedItem = function (selectedItemByValue) { };
    QuestionSelectBase.prototype.getMultipleSelectedItems = function () {
        return [];
    };
    QuestionSelectBase.prototype.setConditionalChoicesRunner = function () {
        if (this.choicesVisibleIf) {
            if (!this.conditionChoicesVisibleIfRunner) {
                this.conditionChoicesVisibleIfRunner = new ConditionRunner(this.choicesVisibleIf);
            }
            this.conditionChoicesVisibleIfRunner.expression = this.choicesVisibleIf;
        }
        else {
            this.conditionChoicesVisibleIfRunner = null;
        }
    };
    QuestionSelectBase.prototype.setConditionalEnableChoicesRunner = function () {
        if (this.choicesEnableIf) {
            if (!this.conditionChoicesEnableIfRunner) {
                this.conditionChoicesEnableIfRunner = new ConditionRunner(this.choicesEnableIf);
            }
            this.conditionChoicesEnableIfRunner.expression = this.choicesEnableIf;
        }
        else {
            this.conditionChoicesEnableIfRunner = null;
        }
    };
    QuestionSelectBase.prototype.canSurveyChangeItemVisibility = function () {
        return !!this.survey && this.survey.canChangeChoiceItemsVisibility();
    };
    QuestionSelectBase.prototype.changeItemVisibility = function () {
        var _this = this;
        return this.canSurveyChangeItemVisibility() ?
            function (item, val) { return _this.survey.getChoiceItemVisibility(_this, item, val); }
            : null;
    };
    QuestionSelectBase.prototype.runConditionsForItems = function (values, properties) {
        this.filteredChoicesValue = [];
        var calcVisibility = this.changeItemVisibility();
        return itemvalue_ItemValue.runConditionsForItems(this.activeChoices, this.getFilteredChoices(), this.areInvisibleElementsShowing
            ? null
            : this.conditionChoicesVisibleIfRunner, values, properties, !this.survey || !this.survey.areInvisibleElementsShowing, function (item, val) {
            return !!calcVisibility ? calcVisibility(item, val) : val;
        });
    };
    QuestionSelectBase.prototype.getHasOther = function (val) {
        return this.getIsItemValue(val, this.otherItem);
    };
    QuestionSelectBase.prototype.getIsItemValue = function (val, item) {
        return val === item.value;
    };
    Object.defineProperty(QuestionSelectBase.prototype, "validatedValue", {
        get: function () {
            return this.rendredValueToDataCore(this.value);
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.createRestful = function () {
        return new choicesRestful_ChoicesRestful();
    };
    QuestionSelectBase.prototype.setNewRestfulProperty = function () {
        this.setPropertyValue("choicesByUrl", this.createRestful());
        this.choicesByUrl.owner = this;
        this.choicesByUrl.loadingOwner = this;
    };
    Object.defineProperty(QuestionSelectBase.prototype, "autoOtherMode", {
        get: function () {
            return this.getPropertyValue("autoOtherMode");
        },
        set: function (val) {
            this.setPropertyValue("autoOtherMode", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.getQuestionComment = function () {
        if (this.showCommentArea)
            return _super.prototype.getQuestionComment.call(this);
        if (!!this.otherValueCore)
            return this.otherValueCore;
        if (this.hasComment || this.getStoreOthersAsComment())
            return _super.prototype.getQuestionComment.call(this);
        return this.otherValueCore;
    };
    QuestionSelectBase.prototype.selectOtherValueFromComment = function (val) {
        this.value = val ? this.otherItem.value : undefined;
    };
    QuestionSelectBase.prototype.setQuestionComment = function (newValue) {
        this.updatePrevOtherErrorValue(newValue);
        if (this.showCommentArea) {
            _super.prototype.setQuestionComment.call(this, newValue);
            return;
        }
        this.onUpdateCommentOnAutoOtherMode(newValue);
        if (this.getStoreOthersAsComment())
            _super.prototype.setQuestionComment.call(this, newValue);
        else {
            this.setOtherValueInternally(newValue);
        }
        this.updateChoicesDependedQuestions();
    };
    QuestionSelectBase.prototype.onUpdateCommentOnAutoOtherMode = function (newValue) {
        if (!this.autoOtherMode)
            return;
        this.prevOtherValue = undefined;
        var isSelected = this.isOtherSelected;
        if (!isSelected && !!newValue || isSelected && !newValue) {
            this.selectOtherValueFromComment(!!newValue);
        }
    };
    QuestionSelectBase.prototype.setOtherValueInternally = function (newValue) {
        if (!this.isSettingComment && newValue != this.otherValueCore) {
            this.isSettingComment = true;
            this.otherValueCore = newValue;
            if (this.isOtherSelected && !this.isRenderedValueSetting) {
                this.value = this.rendredValueToData(this.renderedValue);
            }
            this.isSettingComment = false;
        }
    };
    QuestionSelectBase.prototype.clearValue = function (keepComment) {
        _super.prototype.clearValue.call(this, keepComment);
        this.prevOtherValue = undefined;
    };
    QuestionSelectBase.prototype.updateCommentFromSurvey = function (newValue) {
        _super.prototype.updateCommentFromSurvey.call(this, newValue);
        this.prevOtherValue = undefined;
    };
    Object.defineProperty(QuestionSelectBase.prototype, "renderedValue", {
        get: function () {
            return this.getPropertyValue("renderedValue", null);
        },
        set: function (val) {
            if (this.isReadOnlyAttr)
                return;
            this.setPropertyValue("renderedValue", val);
            var val = this.rendredValueToData(val);
            if (!this.isTwoValueEquals(val, this.value)) {
                this.value = val;
            }
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.setQuestionValue = function (newValue, updateIsAnswered, updateComment) {
        if (updateIsAnswered === void 0) { updateIsAnswered = true; }
        if (updateComment === void 0) { updateComment = true; }
        if (this.isLoadingFromJson ||
            this.isTwoValueEquals(this.value, newValue))
            return;
        _super.prototype.setQuestionValue.call(this, newValue, updateIsAnswered);
        this.setPropertyValue("renderedValue", this.rendredValueFromData(newValue));
        this.updateChoicesDependedQuestions();
        if (this.hasComment || !updateComment)
            return;
        var isOtherSel = this.isOtherSelected;
        if (isOtherSel && !!this.prevOtherValue) {
            var oldOtherValue = this.prevOtherValue;
            this.prevOtherValue = undefined;
            this.otherValue = oldOtherValue;
        }
        if (!isOtherSel && !!this.otherValue) {
            if (this.getStoreOthersAsComment() && !this.autoOtherMode) {
                this.prevOtherValue = this.otherValue;
            }
            this.makeCommentEmpty = true;
            this.otherValueCore = "";
            this.setPropertyValue("comment", "");
        }
    };
    QuestionSelectBase.prototype.setValueCore = function (newValue) {
        _super.prototype.setValueCore.call(this, newValue);
        if (this.makeCommentEmpty) {
            this.setCommentIntoData("");
            this.makeCommentEmpty = false;
        }
    };
    QuestionSelectBase.prototype.setNewValue = function (newValue) {
        newValue = this.valueFromData(newValue);
        if ((!this.choicesByUrl.isRunning &&
            !this.choicesByUrl.isWaitingForParameters) ||
            !this.isValueEmpty(newValue)) {
            this.cachedValueForUrlRequests = newValue;
        }
        _super.prototype.setNewValue.call(this, newValue);
    };
    QuestionSelectBase.prototype.valueFromData = function (val) {
        var choiceitem = itemvalue_ItemValue.getItemByValue(this.activeChoices, val);
        if (!!choiceitem) {
            return choiceitem.value;
        }
        return _super.prototype.valueFromData.call(this, val);
    };
    QuestionSelectBase.prototype.rendredValueFromData = function (val) {
        if (this.getStoreOthersAsComment())
            return val;
        return this.renderedValueFromDataCore(val);
    };
    QuestionSelectBase.prototype.rendredValueToData = function (val) {
        if (this.getStoreOthersAsComment())
            return val;
        return this.rendredValueToDataCore(val);
    };
    QuestionSelectBase.prototype.renderedValueFromDataCore = function (val) {
        if (!this.hasUnknownValue(val, true, false))
            return this.valueFromData(val);
        this.otherValue = val;
        return this.otherItem.value;
    };
    QuestionSelectBase.prototype.rendredValueToDataCore = function (val) {
        if (val == this.otherItem.value && this.needConvertRenderedOtherToDataValue()) {
            val = this.otherValue;
        }
        return val;
    };
    QuestionSelectBase.prototype.needConvertRenderedOtherToDataValue = function () {
        var val = this.otherValue;
        if (!val)
            return false;
        val = val.trim();
        if (!val)
            return false;
        return this.hasUnknownValue(val, true, false);
    };
    QuestionSelectBase.prototype.getIsQuestionReady = function () {
        return _super.prototype.getIsQuestionReady.call(this) && !this.waitingChoicesByURL && !this.waitingGetChoiceDisplayValueResponse;
    };
    QuestionSelectBase.prototype.updateSelectedItemValues = function () {
        var _this = this;
        if (this.waitingGetChoiceDisplayValueResponse || !this.survey || this.isEmpty())
            return;
        var value = this.value;
        var valueArray = Array.isArray(value) ? value : [value];
        var hasItemWithoutValues = valueArray.some(function (val) { return !itemvalue_ItemValue.getItemByValue(_this.choices, val); });
        if (hasItemWithoutValues && (this.choicesLazyLoadEnabled || this.hasChoicesUrl)) {
            this.waitingGetChoiceDisplayValueResponse = true;
            this.updateIsReady();
            this.survey.getChoiceDisplayValue({
                question: this,
                values: valueArray,
                setItems: function (displayValues) {
                    var customValues = [];
                    for (var _i = 1; _i < arguments.length; _i++) {
                        customValues[_i - 1] = arguments[_i];
                    }
                    _this.waitingGetChoiceDisplayValueResponse = false;
                    if (!displayValues || !displayValues.length) {
                        _this.updateIsReady();
                        return;
                    }
                    var items = displayValues.map(function (displayValue, index) { return _this.createItemValue(valueArray[index], displayValue); });
                    _this.setCustomValuesIntoItems(items, customValues);
                    if (Array.isArray(value)) {
                        _this.selectedItemValues = items;
                    }
                    else {
                        _this.selectedItemValues = items[0];
                    }
                    _this.updateIsReady();
                }
            });
        }
    };
    QuestionSelectBase.prototype.setCustomValuesIntoItems = function (items, customValues) {
        if (!Array.isArray(customValues) || customValues.length === 0)
            return;
        customValues.forEach(function (customValue) {
            var vals = customValue.values;
            var propName = customValue.propertyName;
            if (Array.isArray(vals)) {
                for (var i = 0; i < items.length && i < vals.length; i++) {
                    items[i][propName] = vals[i];
                }
            }
        });
    };
    QuestionSelectBase.prototype.hasUnknownValue = function (val, includeOther, isFilteredChoices, checkEmptyValue) {
        if (includeOther === void 0) { includeOther = false; }
        if (isFilteredChoices === void 0) { isFilteredChoices = true; }
        if (checkEmptyValue === void 0) { checkEmptyValue = false; }
        if (!Array.isArray(val))
            return this.hasUnknownValueItem(val, includeOther, isFilteredChoices, checkEmptyValue);
        for (var i = 0; i < val.length; i++) {
            if (this.hasUnknownValueItem(val, includeOther, isFilteredChoices, checkEmptyValue))
                return true;
        }
        return false;
    };
    QuestionSelectBase.prototype.hasUnknownValueItem = function (val, includeOther, isFilteredChoices, checkEmptyValue) {
        if (includeOther === void 0) { includeOther = false; }
        if (isFilteredChoices === void 0) { isFilteredChoices = true; }
        if (checkEmptyValue === void 0) { checkEmptyValue = false; }
        if (!checkEmptyValue && this.isValueEmpty(val))
            return false;
        if (includeOther && val == this.otherItem.value)
            return false;
        if (this.showNoneItem && val == this.noneItem.value)
            return false;
        if (this.showRefuseItem && val == this.refuseItem.value)
            return false;
        if (this.showDontKnowItem && val == this.dontKnowItem.value)
            return false;
        var choices = isFilteredChoices
            ? this.getFilteredChoices()
            : this.activeChoices;
        return itemvalue_ItemValue.getItemByValue(choices, val) == null;
    };
    QuestionSelectBase.prototype.isValueDisabled = function (val) {
        var itemValue = itemvalue_ItemValue.getItemByValue(this.getFilteredChoices(), val);
        return !!itemValue && !itemValue.isEnabled;
    };
    Object.defineProperty(QuestionSelectBase.prototype, "choicesByUrl", {
        /**
         * Configures access to a RESTful service that returns choice items. Refer to the [`ChoicesRestful`](https://surveyjs.io/form-library/documentation/choicesrestful) class description for more information. You can also specify additional application-wide settings using the [`settings.web`](https://surveyjs.io/form-library/documentation/api-reference/settings#web) object.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/dropdown-menu-load-data-from-restful-service/ (linkStyle))
         * @see choices
         * @see [settings.specialChoicesOrder](https://surveyjs.io/form-library/documentation/api-reference/settings#specialChoicesOrder)
         */
        get: function () {
            return this.getPropertyValue("choicesByUrl");
        },
        set: function (val) {
            if (!val)
                return;
            this.setNewRestfulProperty();
            this.choicesByUrl.fromJSON(val.toJSON());
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "choices", {
        /**
         * Gets or sets choice items. This property accepts an array of objects with the following structure:
         *
         * ```js
         * {
         *   "value": any, // A unique value to be saved in the survey results.
         *   "text": String, // A display text. This property supports Markdown. When `text` is undefined, `value` is used.
         *   "imageLink": String // A link to the image or video that represents this choice value. Applies only to Image Picker questions.
         *   "customProperty": any // Any property that you find useful.
         * }
         * ```
         *
         * To enable Markdown support for the `text` property, implement Markdown-to-HTML conversion in the [onTextMarkdown](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onTextMarkdown) event handler. For an example, refer to the following demo: [Convert Markdown to HTML with Showdown](https://surveyjs.io/form-library/examples/edit-survey-questions-markdown/).
         *
         * If you add custom properties, refer to the following help topic to learn how to serialize them into JSON: [Add Custom Properties to Property Grid](https://surveyjs.io/survey-creator/documentation/property-grid#add-custom-properties-to-the-property-grid).
         *
         * If you need to specify only the `value` property, you can set the `choices` property to an array of primitive values, for example, `[ "item1", "item2", "item3" ]`. These values are both saved in survey results and used as display text.
         * @see choicesByUrl
         * @see choicesFromQuestion
         * @see [settings.specialChoicesOrder](https://surveyjs.io/form-library/documentation/api-reference/settings#specialChoicesOrder)
         */
        get: function () {
            return this.getPropertyValue("choices");
        },
        set: function (newValue) {
            this.setPropertyValue("choices", newValue);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "choicesFromQuestion", {
        /**
         * Copies choice items from a specified question. Accepts a question name.
         *
         * If you specify this property, the `choices`, `choicesVisibleIf`, `choicesEnableIf`, and `choicesOrder` properties do not apply because their values are copied.
         *
         * In addition, you can specify the `choicesFromQuestionMode` property if you do not want to copy all choice items.
         * @see choicesFromQuestionMode
         * @see choices
         */
        get: function () {
            return this.getPropertyValue("choicesFromQuestion");
        },
        set: function (val) {
            var question = this.getQuestionWithChoices();
            this.isLockVisibleChoices = !!question && question.name === val;
            if (!!question && question.name !== val) {
                question.removeDependedQuestion(this);
                if (this.isDesignMode && !this.isLoadingFromJson && !!val) {
                    this.setPropertyValue("choicesFromQuestion", undefined);
                }
            }
            this.setPropertyValue("choicesFromQuestion", val);
            this.isLockVisibleChoices = false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "choicesFromQuestionMode", {
        /**
         * Specifies which choice items to copy from another question. Applies only when the `choicesFromQuestion` property is specified.
         *
         * Possible values:
         *
         * - `"all"` (default) - Copies all choice items.
         * - `"selected"` - Copies only selected choice items.
         * - `"unselected"` - Copies only unselected choice items.
         *
         * Use the `visibleChoices` property to access copied choice items.
         * @see choicesFromQuestion
         * @see visibleChoices
         */
        get: function () {
            return this.getPropertyValue("choicesFromQuestionMode");
        },
        set: function (val) {
            this.setPropertyValue("choicesFromQuestionMode", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "choiceValuesFromQuestion", {
        /**
         * Specifies which matrix column or dynamic panel question supplies choice values. Use this property to construct choice items based on cell values in Dynamic Matrix and question values in Dynamic Panel.
         *
         * Each choice item consists of a value saved in survey results and a text displayed in the UI. To construct a choice item, assign the `name` of a Dynamic Matrix or Dynamic Panel to the [`choicesFromQuestion`](#choicesFromQuestion) property and specify which dynamic panel question or matrix column supplies values and which provides texts. Use the `choiceValuesFromQuestion` and [`choiceTextsFromQuestion`](#choiceTextsFromQuestion) properties for this purpose. If a choice text is empty, a choice value is used as a display text and saved in survey results.
         */
        get: function () {
            return this.getPropertyValue("choiceValuesFromQuestion");
        },
        set: function (val) {
            this.setPropertyValue("choiceValuesFromQuestion", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "choiceTextsFromQuestion", {
        /**
         * Specifies which matrix column or dynamic panel question supplies choice texts. Use this property to construct choice items based on cell values in Dynamic Matrix and question values in Dynamic Panel.
         *
         * Each choice item consists of a value saved in survey results and a text displayed in the UI. To construct a choice item, assign the `name` of a Dynamic Matrix or Dynamic Panel to the [`choicesFromQuestion`](#choicesFromQuestion) property and specify which dynamic panel question or matrix column supplies values and which provides texts. Use the [`choiceValuesFromQuestion`](#choiceValuesFromQuestion) and `choiceTextsFromQuestion` properties for this purpose. If a choice text is empty, a choice value is used as a display text and saved in survey results.
         */
        get: function () {
            return this.getPropertyValue("choiceTextsFromQuestion");
        },
        set: function (val) {
            this.setPropertyValue("choiceTextsFromQuestion", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "hideIfChoicesEmpty", {
        /**
         * Specifies whether to hide the question if no choice items are visible.
         *
         * This property is useful if you show or hide choice items at runtime based on a [condition](https://surveyjs.io/form-library/documentation/questionselectbase#choicesVisibleIf).
         */
        get: function () {
            return this.getPropertyValue("hideIfChoicesEmpty");
        },
        set: function (val) {
            this.setPropertyValue("hideIfChoicesEmpty", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "keepIncorrectValues", {
        /**
         * Specifies whether to keep values that cannot be assigned to this question, for example, choices unlisted in the `choices` array.
         *
         * > This property cannot be specified in the survey JSON schema. Use dot notation to specify it.
         * @see clearIncorrectValues
         */
        get: function () {
            return this.getPropertyValue("keepIncorrectValues", false);
        },
        set: function (val) {
            this.setPropertyValue("keepIncorrectValues", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "storeOthersAsComment", {
        get: function () {
            return this.getPropertyValue("storeOthersAsComment");
        },
        set: function (val) {
            this.setPropertyValue("storeOthersAsComment", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.hasOtherChanged = function () {
        this.onVisibleChoicesChanged();
    };
    Object.defineProperty(QuestionSelectBase.prototype, "choicesOrder", {
        /**
         * Specifies the sort order of choice items.
         *
         * Possible values:
         *
         * - `"none"` (default) - Preserves the original order of choice items.
         * - `"asc"`- Sorts choice items in ascending order.
         * - `"desc"`- Sorts choice items in ascending order.
         * - `"random"` - Displays choice items in random order.
         * @see [settings.specialChoicesOrder](https://surveyjs.io/form-library/documentation/api-reference/settings#specialChoicesOrder)
         */
        get: function () {
            return this.getPropertyValue("choicesOrder");
        },
        set: function (val) {
            val = val.toLowerCase();
            if (val == this.choicesOrder)
                return;
            this.setPropertyValue("choicesOrder", val);
            this.onVisibleChoicesChanged();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "otherText", {
        /**
         * Gets or sets a caption for the "Other" choice item.
         * @see showOtherItem
         */
        get: function () {
            return this.getLocalizableStringText("otherText");
        },
        set: function (val) {
            this.setLocalizableStringText("otherText", val);
            this.onVisibleChoicesChanged();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "locOtherText", {
        get: function () {
            return this.getLocalizableString("otherText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "otherPlaceHolder", {
        get: function () {
            return this.otherPlaceholder;
        },
        set: function (newValue) {
            this.otherPlaceholder = newValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "otherErrorText", {
        /**
         * Gets or sets an error message displayed when users select the "Other" choice item but leave the comment area empty.
         * @see showOtherItem
         */
        get: function () {
            return this.getLocalizableStringText("otherErrorText");
        },
        set: function (val) {
            this.setLocalizableStringText("otherErrorText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "locOtherErrorText", {
        get: function () {
            return this.getLocalizableString("otherErrorText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "visibleChoices", {
        /**
         * An array of visible choice items. Includes the "Select All", "Other", and "None" choice items if they are visible. Items are sorted according to the `choicesOrder` value.
         * @see showNoneItem
         * @see showOtherItem
         * @see choicesOrder
         * @see choices
         * @see enabledChoices
         */
        get: function () {
            return this.getPropertyValue("visibleChoices");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "enabledChoices", {
        /**
         * An array of choice items with which users can interact. Includes the "Select All", "Other", and "None" choice items if they are not disabled. Items are sorted according to the `choicesOrder` value.
         * @see showNoneItem
         * @see showOtherItem
         * @see choicesOrder
         * @see choices
         * @see visibleChoices
         */
        get: function () {
            var res = [];
            var items = this.visibleChoices;
            for (var i = 0; i < items.length; i++) {
                if (items[i].isEnabled)
                    res.push(items[i]);
            }
            return res;
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.updateVisibleChoices = function () {
        if (this.isLoadingFromJson || this.isDisposed)
            return;
        var newValue = new Array();
        var calcValue = this.calcVisibleChoices();
        if (!calcValue)
            calcValue = [];
        for (var i = 0; i < calcValue.length; i++) {
            newValue.push(calcValue[i]);
        }
        var oldValue = this.visibleChoices;
        if (!this.isTwoValueEquals(oldValue, newValue) || this.choicesLazyLoadEnabled) {
            this.setArrayPropertyDirectly("visibleChoices", newValue);
        }
    };
    QuestionSelectBase.prototype.calcVisibleChoices = function () {
        if (this.canUseFilteredChoices())
            return this.getFilteredChoices();
        var res = this.sortVisibleChoices(this.getFilteredChoices().slice());
        this.addToVisibleChoices(res, this.isAddDefaultItems);
        return res;
    };
    QuestionSelectBase.prototype.canUseFilteredChoices = function () {
        return (!this.isAddDefaultItems &&
            !this.showNoneItem &&
            !this.showRefuseItem &&
            !this.showDontKnowItem &&
            !this.hasOther &&
            this.choicesOrder == "none");
    };
    QuestionSelectBase.prototype.setCanShowOptionItemCallback = function (func) {
        this.canShowOptionItemCallback = func;
        if (!!func) {
            this.onVisibleChoicesChanged();
        }
    };
    Object.defineProperty(QuestionSelectBase.prototype, "newItem", {
        get: function () { return this.newItemValue; },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.addToVisibleChoices = function (items, isAddAll) {
        this.headItemsCount = 0;
        this.footItemsCount = 0;
        if (!this.isEmptyActiveChoicesInDesign) {
            this.addNewItemToVisibleChoices(items, isAddAll);
        }
        var dict = new Array();
        this.addNonChoicesItems(dict, isAddAll);
        dict.sort(function (a, b) {
            if (a.index === b.index)
                return 0;
            return a.index < b.index ? -1 : 1;
        });
        for (var i = 0; i < dict.length; i++) {
            var rec = dict[i];
            if (rec.index < 0) {
                items.splice(i, 0, rec.item);
                this.headItemsCount++;
            }
            else {
                items.push(rec.item);
                this.footItemsCount++;
            }
        }
    };
    QuestionSelectBase.prototype.addNewItemToVisibleChoices = function (items, isAddAll) {
        var _this = this;
        if (!isAddAll)
            return;
        if (!this.newItemValue) {
            this.newItemValue = this.createItemValue("newitem"); //TODO
            this.newItemValue.isGhost = true;
            this.newItemValue.registerFunctionOnPropertyValueChanged("isVisible", function () {
                _this.updateVisibleChoices();
            });
        }
        if (this.newItemValue.isVisible && !this.isUsingCarryForward
            && this.canShowOptionItem(this.newItemValue, isAddAll, false)) {
            this.footItemsCount = 1;
            items.push(this.newItemValue);
        }
    };
    QuestionSelectBase.prototype.addNonChoicesItems = function (dict, isAddAll) {
        if (this.supportNone()) {
            this.addNonChoiceItem(dict, this.noneItem, isAddAll, this.showNoneItem, settings.specialChoicesOrder.noneItem);
        }
        if (this.supportRefuse()) {
            this.addNonChoiceItem(dict, this.refuseItem, isAddAll, this.showRefuseItem, settings.specialChoicesOrder.refuseItem);
        }
        if (this.supportDontKnow()) {
            this.addNonChoiceItem(dict, this.dontKnowItem, isAddAll, this.showDontKnowItem, settings.specialChoicesOrder.dontKnowItem);
        }
        if (this.supportOther()) {
            this.addNonChoiceItem(dict, this.otherItem, isAddAll, this.hasOther, settings.specialChoicesOrder.otherItem);
        }
    };
    QuestionSelectBase.prototype.addNonChoiceItem = function (dict, item, isAddAll, showItem, order) {
        if (this.canShowOptionItem(item, isAddAll, showItem)) {
            order.forEach(function (val) { return dict.push({ index: val, item: item }); });
        }
    };
    QuestionSelectBase.prototype.canShowOptionItem = function (item, isAddAll, hasItem) {
        var res = (isAddAll && (!!this.canShowOptionItemCallback ? this.canShowOptionItemCallback(item) : true)) || hasItem;
        if (this.canSurveyChangeItemVisibility()) {
            var calc = this.changeItemVisibility();
            return calc(item, res);
        }
        return res;
    };
    QuestionSelectBase.prototype.isItemInList = function (item) {
        if (item === this.otherItem)
            return this.hasOther;
        if (item === this.noneItem)
            return this.showNoneItem;
        if (item === this.refuseItem)
            return this.showRefuseItem;
        if (item === this.dontKnowItem)
            return this.showDontKnowItem;
        if (item === this.newItemValue)
            return false;
        return true;
    };
    Object.defineProperty(QuestionSelectBase.prototype, "isAddDefaultItems", {
        get: function () {
            return settings.showDefaultItemsInCreatorV2 && this.isDesignModeV2 &&
                !this.customWidget && !this.isContentElement;
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.getPlainData = function (options) {
        var _this = this;
        if (options === void 0) { options = {
            includeEmpty: true,
            includeQuestionTypes: false,
        }; }
        var questionPlainData = _super.prototype.getPlainData.call(this, options);
        if (!!questionPlainData) {
            var values = Array.isArray(this.value) ? this.value : [this.value];
            questionPlainData.isNode = true;
            questionPlainData.data = (questionPlainData.data || []).concat(values.map(function (dataValue, index) {
                var choice = itemvalue_ItemValue.getItemByValue(_this.visibleChoices, dataValue);
                var choiceDataItem = {
                    name: index,
                    title: "Choice",
                    value: dataValue,
                    displayValue: _this.getChoicesDisplayValue(_this.visibleChoices, dataValue),
                    getString: function (val) {
                        return typeof val === "object" ? JSON.stringify(val) : val;
                    },
                    isNode: false,
                };
                if (!!choice) {
                    (options.calculations || []).forEach(function (calculation) {
                        choiceDataItem[calculation.propertyName] =
                            choice[calculation.propertyName];
                    });
                }
                if (_this.isOtherSelected && _this.otherItemValue === choice) {
                    choiceDataItem.isOther = true;
                    choiceDataItem.displayValue = _this.otherValue;
                }
                return choiceDataItem;
            }));
        }
        return questionPlainData;
    };
    QuestionSelectBase.prototype.getDisplayValueCore = function (keysAsText, value) {
        if (!this.useDisplayValuesInDynamicTexts)
            return value;
        return this.getChoicesDisplayValue(this.visibleChoices, value);
    };
    QuestionSelectBase.prototype.getDisplayValueEmpty = function () {
        return itemvalue_ItemValue.getTextOrHtmlByValue(this.visibleChoices, undefined);
    };
    QuestionSelectBase.prototype.getChoicesDisplayValue = function (items, val) {
        if (val == this.otherItemValue.value)
            return this.otherValue ? this.otherValue : this.locOtherText.textOrHtml;
        var selItem = this.getSingleSelectedItem();
        if (!!selItem && this.isTwoValueEquals(selItem.value, val))
            return selItem.locText.textOrHtml;
        var str = itemvalue_ItemValue.getTextOrHtmlByValue(items, val);
        return str == "" && val ? val : str;
    };
    QuestionSelectBase.prototype.getDisplayArrayValue = function (keysAsText, value, onGetValueCallback) {
        var _this = this;
        var items = this.visibleChoices;
        var strs = [];
        var vals = [];
        for (var i = 0; i < value.length; i++) {
            vals.push(!onGetValueCallback ? value[i] : onGetValueCallback(i));
        }
        if (helpers_Helpers.isTwoValueEquals(this.value, vals)) {
            this.getMultipleSelectedItems().forEach(function (item, index) { return strs.push(_this.getItemDisplayValue(item, vals[index])); });
        }
        if (strs.length === 0) {
            for (var i = 0; i < vals.length; i++) {
                var valStr = this.getChoicesDisplayValue(items, vals[i]);
                if (valStr) {
                    strs.push(valStr);
                }
            }
        }
        return strs.join(settings.choicesSeparator);
    };
    QuestionSelectBase.prototype.getItemDisplayValue = function (item, val) {
        if (item === this.otherItem) {
            if (this.hasOther && this.showCommentArea && !!val) {
                return val;
            }
            if (this.comment) {
                return this.comment;
            }
        }
        return item.locText.textOrHtml;
    };
    QuestionSelectBase.prototype.getFilteredChoices = function () {
        return this.filteredChoicesValue
            ? this.filteredChoicesValue
            : this.activeChoices;
    };
    Object.defineProperty(QuestionSelectBase.prototype, "activeChoices", {
        get: function () {
            var question = this.getCarryForwardQuestion();
            if (this.carryForwardQuestionType === "select") {
                question.addDependedQuestion(this);
                return this.getChoicesFromSelectQuestion(question);
            }
            if (this.carryForwardQuestionType === "array") {
                question.addDependedQuestion(this);
                return this.getChoicesFromArrayQuestion(question);
            }
            if (this.isEmptyActiveChoicesInDesign)
                return [];
            return this.choicesFromUrl ? this.choicesFromUrl : this.getChoices();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "isMessagePanelVisible", {
        get: function () {
            return this.getPropertyValue("isMessagePanelVisible", false);
        },
        set: function (val) {
            this.setPropertyValue("isMessagePanelVisible", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "isEmptyActiveChoicesInDesign", {
        get: function () {
            return this.isDesignModeV2 && (this.hasChoicesUrl || this.isMessagePanelVisible);
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.getCarryForwardQuestion = function (data) {
        var question = this.findCarryForwardQuestion(data);
        var selBaseQuestion = this.getQuestionWithChoicesCore(question);
        var arrayQuestion = !selBaseQuestion ? this.getQuestionWithArrayValue(question) : null;
        this.setCarryForwardQuestionType(!!selBaseQuestion, !!arrayQuestion);
        return !!selBaseQuestion || !!arrayQuestion ? question : null;
    };
    QuestionSelectBase.prototype.getIsReadyDependsOn = function () {
        var res = _super.prototype.getIsReadyDependsOn.call(this);
        if (this.carryForwardQuestion) {
            res.push(this.carryForwardQuestion);
        }
        return res;
    };
    QuestionSelectBase.prototype.getQuestionWithChoices = function () {
        return this.getQuestionWithChoicesCore(this.findCarryForwardQuestion());
    };
    QuestionSelectBase.prototype.findCarryForwardQuestion = function (data) {
        if (!data)
            data = this.data;
        this.carryForwardQuestion = null;
        if (this.choicesFromQuestion && data) {
            this.carryForwardQuestion = data.findQuestionByName(this.choicesFromQuestion);
        }
        return this.carryForwardQuestion;
    };
    QuestionSelectBase.prototype.getQuestionWithChoicesCore = function (question) {
        if (!!question && !!question.visibleChoices && (Serializer.isDescendantOf(question.getType(), "selectbase")) && question !== this)
            return question;
        return null;
    };
    QuestionSelectBase.prototype.getQuestionWithArrayValue = function (question) {
        return !!question && question.isValueArray ? question : null;
    };
    QuestionSelectBase.prototype.getChoicesFromArrayQuestion = function (question) {
        if (this.isDesignMode)
            return [];
        var val = question.value;
        if (!Array.isArray(val))
            return [];
        var res = [];
        for (var i = 0; i < val.length; i++) {
            var obj = val[i];
            if (!helpers_Helpers.isValueObject(obj))
                continue;
            var key = this.getValueKeyName(obj);
            if (!!key && !this.isValueEmpty(obj[key])) {
                var text = !!this.choiceTextsFromQuestion ? obj[this.choiceTextsFromQuestion] : undefined;
                res.push(this.createItemValue(obj[key], text));
            }
        }
        return res;
    };
    QuestionSelectBase.prototype.getValueKeyName = function (obj) {
        if (this.choiceValuesFromQuestion)
            return this.choiceValuesFromQuestion;
        var keys = Object.keys(obj);
        return keys.length > 0 ? keys[0] : undefined;
    };
    QuestionSelectBase.prototype.getChoicesFromSelectQuestion = function (question) {
        if (this.isDesignMode)
            return [];
        var res = [];
        var isSelected = this.choicesFromQuestionMode == "selected"
            ? true
            : this.choicesFromQuestionMode == "unselected"
                ? false
                : undefined;
        var choices = question.visibleChoices;
        for (var i = 0; i < choices.length; i++) {
            if (question.isBuiltInChoice(choices[i]))
                continue;
            if (isSelected === undefined) {
                res.push(this.copyChoiceItem(choices[i]));
                continue;
            }
            var itemsSelected = question.isItemSelected(choices[i]);
            if ((itemsSelected && isSelected) || (!itemsSelected && !isSelected)) {
                res.push(this.copyChoiceItem(choices[i]));
            }
        }
        if (this.choicesFromQuestionMode === "selected" && !this.showOtherItem && question.isOtherSelected && !!question.comment) {
            res.push(this.createItemValue(question.otherItem.value, question.comment));
        }
        return res;
    };
    QuestionSelectBase.prototype.copyChoiceItem = function (item) {
        var res = this.createItemValue(item.value);
        res.setData(item);
        return res;
    };
    Object.defineProperty(QuestionSelectBase.prototype, "hasActiveChoices", {
        get: function () {
            var choices = this.visibleChoices;
            if (!choices || choices.length == 0) {
                this.onVisibleChoicesChanged();
                choices = this.visibleChoices;
            }
            for (var i = 0; i < choices.length; i++) {
                if (!this.isBuiltInChoice(choices[i]))
                    return true;
            }
            return false;
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.isBuiltInChoice = function (item) {
        return this.isNoneItem(item) ||
            item === this.otherItem ||
            item === this.newItemValue;
    };
    QuestionSelectBase.prototype.isNoneItem = function (item) {
        return this.getNoneItems().indexOf(item) > -1;
    };
    QuestionSelectBase.prototype.getNoneItems = function () {
        return [this.noneItem, this.refuseItem, this.dontKnowItem];
    };
    QuestionSelectBase.prototype.getChoices = function () {
        return this.choices;
    };
    QuestionSelectBase.prototype.supportOther = function () {
        return this.isSupportProperty("showOtherItem");
    };
    QuestionSelectBase.prototype.supportNone = function () {
        return this.isSupportProperty("showNoneItem");
    };
    QuestionSelectBase.prototype.supportRefuse = function () {
        return this.isSupportProperty("showRefuseItem");
    };
    QuestionSelectBase.prototype.supportDontKnow = function () {
        return this.isSupportProperty("showDontKnowItem");
    };
    QuestionSelectBase.prototype.isSupportProperty = function (propName) {
        return (!this.isDesignMode ||
            this.getPropertyByName(propName).visible);
    };
    QuestionSelectBase.prototype.onCheckForErrors = function (errors, isOnValueChanged) {
        var _this = this;
        _super.prototype.onCheckForErrors.call(this, errors, isOnValueChanged);
        if (!this.hasOther || !this.isOtherSelected || this.otherValue
            || isOnValueChanged && !this.prevOtherErrorValue)
            return;
        var otherEmptyError = new OtherEmptyError(this.otherErrorText, this);
        otherEmptyError.onUpdateErrorTextCallback = function (err) { err.text = _this.otherErrorText; };
        errors.push(otherEmptyError);
    };
    QuestionSelectBase.prototype.setSurveyImpl = function (value, isLight) {
        this.isRunningChoices = true;
        _super.prototype.setSurveyImpl.call(this, value, isLight);
        this.isRunningChoices = false;
        this.runChoicesByUrl();
        if (this.isAddDefaultItems) {
            this.updateVisibleChoices();
        }
    };
    QuestionSelectBase.prototype.setSurveyCore = function (value) {
        _super.prototype.setSurveyCore.call(this, value);
        if (!!value && !!this.choicesFromQuestion) {
            this.onVisibleChoicesChanged();
        }
    };
    QuestionSelectBase.prototype.getStoreOthersAsComment = function () {
        if (this.isSettingDefaultValue)
            return false;
        if (this.showCommentArea)
            return false;
        return (this.storeOthersAsComment === true ||
            (this.storeOthersAsComment == "default" &&
                (this.survey != null ? this.survey.storeOthersAsComment : true)) ||
            (this.hasChoicesUrl && !this.choicesFromUrl));
    };
    QuestionSelectBase.prototype.onSurveyLoad = function () {
        this.runChoicesByUrl();
        this.onVisibleChoicesChanged();
        _super.prototype.onSurveyLoad.call(this);
    };
    QuestionSelectBase.prototype.onAnyValueChanged = function (name, questionName) {
        _super.prototype.onAnyValueChanged.call(this, name, questionName);
        if (name != this.getValueName()) {
            this.runChoicesByUrl();
        }
        var chQuestion = this.choicesFromQuestion;
        if (!!name && chQuestion && (name === chQuestion || questionName === chQuestion)) {
            this.onVisibleChoicesChanged();
        }
    };
    QuestionSelectBase.prototype.updateValueFromSurvey = function (newValue, clearData) {
        var newComment = "";
        if (this.hasOther &&
            !this.isRunningChoices &&
            !this.choicesByUrl.isRunning &&
            this.getStoreOthersAsComment()) {
            if (this.hasUnknownValue(newValue) && !this.getHasOther(newValue)) {
                newComment = this.getCommentFromValue(newValue);
                newValue = this.setOtherValueIntoValue(newValue);
            }
            else {
                if (this.data) {
                    newComment = this.data.getComment(this.getValueName());
                }
            }
        }
        _super.prototype.updateValueFromSurvey.call(this, newValue, clearData);
        if ((this.isRunningChoices || this.choicesByUrl.isRunning) && !this.isEmpty()) {
            this.cachedValueForUrlRequests = this.value;
        }
        if (!!newComment) {
            this.setNewComment(newComment);
        }
    };
    QuestionSelectBase.prototype.getCommentFromValue = function (newValue) {
        return newValue;
    };
    QuestionSelectBase.prototype.setOtherValueIntoValue = function (newValue) {
        return this.otherItem.value;
    };
    QuestionSelectBase.prototype.onOtherValueInput = function (event) {
        if (this.isInputTextUpdate) {
            if (event.target) {
                this.otherValue = event.target.value;
            }
        }
        else {
            this.updateCommentElements();
        }
    };
    QuestionSelectBase.prototype.onOtherValueChange = function (event) {
        this.otherValue = event.target.value;
        if (this.otherValue !== event.target.value) {
            event.target.value = this.otherValue;
        }
    };
    QuestionSelectBase.prototype.runChoicesByUrl = function () {
        this.updateIsUsingRestful();
        if (!this.choicesByUrl || this.isLoadingFromJson || this.isRunningChoices || this.isDesignModeV2)
            return;
        var processor = this.surveyImpl
            ? this.surveyImpl.getTextProcessor()
            : this.textProcessor;
        if (!processor)
            processor = this.survey;
        if (!processor)
            return;
        this.updateIsReady();
        this.isRunningChoices = true;
        this.choicesByUrl.run(processor);
        this.isRunningChoices = false;
    };
    QuestionSelectBase.prototype.onBeforeSendRequest = function () {
        if (settings.web.disableQuestionWhileLoadingChoices === true && !this.isReadOnly) {
            this.enableOnLoadingChoices = true;
            this.readOnly = true;
        }
    };
    QuestionSelectBase.prototype.onLoadChoicesFromUrl = function (array) {
        if (this.enableOnLoadingChoices) {
            this.readOnly = false;
        }
        var errors = [];
        if (!this.isReadOnly) {
            if (this.choicesByUrl && this.choicesByUrl.error) {
                errors.push(this.choicesByUrl.error);
            }
        }
        var newChoices = null;
        var checkCachedValuesOnExisting = true;
        if (this.isFirstLoadChoicesFromUrl &&
            !this.cachedValueForUrlRequests &&
            this.defaultValue) {
            this.cachedValueForUrlRequests = this.defaultValue;
            checkCachedValuesOnExisting = false;
        }
        if (this.isValueEmpty(this.cachedValueForUrlRequests)) {
            this.cachedValueForUrlRequests = this.value;
        }
        var cachedValues = this.createCachedValueForUrlRequests(this.cachedValueForUrlRequests, checkCachedValuesOnExisting);
        if (array && (array.length > 0 || this.choicesByUrl.allowEmptyResponse)) {
            newChoices = new Array();
            itemvalue_ItemValue.setData(newChoices, array);
        }
        if (!!newChoices) {
            for (var i = 0; i < newChoices.length; i++) {
                newChoices[i].locOwner = this;
            }
        }
        this.setChoicesFromUrl(newChoices, errors, cachedValues);
    };
    QuestionSelectBase.prototype.canAvoidSettChoicesFromUrl = function (newChoices) {
        if (this.isFirstLoadChoicesFromUrl)
            return false;
        var chocesAreEmpty = !newChoices || Array.isArray(newChoices) && newChoices.length === 0;
        if (chocesAreEmpty && !this.isEmpty())
            return false;
        return helpers_Helpers.isTwoValueEquals(this.choicesFromUrl, newChoices);
    };
    QuestionSelectBase.prototype.setChoicesFromUrl = function (newChoices, errors, cachedValues) {
        if (this.canAvoidSettChoicesFromUrl(newChoices))
            return;
        this.isFirstLoadChoicesFromUrl = false;
        this.choicesFromUrl = newChoices;
        this.filterItems();
        this.onVisibleChoicesChanged();
        if (newChoices) {
            var newValue = this.updateCachedValueForUrlRequests(cachedValues, newChoices);
            if (!!newValue && !this.isReadOnly) {
                var hasChanged = !this.isTwoValueEquals(this.value, newValue.value);
                try {
                    if (!this.isValueEmpty(newValue.value)) {
                        this.allowNotifyValueChanged = false;
                        this.setQuestionValue(undefined, true, false);
                    }
                    this.allowNotifyValueChanged = hasChanged;
                    if (hasChanged) {
                        this.value = newValue.value;
                    }
                    else {
                        this.setQuestionValue(newValue.value);
                    }
                }
                finally {
                    this.allowNotifyValueChanged = true;
                }
            }
        }
        if (!this.isReadOnly && !newChoices && !this.isFirstLoadChoicesFromUrl) {
            this.value = null;
        }
        this.errors = errors;
        this.choicesLoaded();
    };
    QuestionSelectBase.prototype.createCachedValueForUrlRequests = function (val, checkOnExisting) {
        if (this.isValueEmpty(val))
            return null;
        if (Array.isArray(val)) {
            var res = [];
            for (var i = 0; i < val.length; i++) {
                res.push(this.createCachedValueForUrlRequests(val[i], true));
            }
            return res;
        }
        var isExists = checkOnExisting ? !this.hasUnknownValue(val) : true;
        return { value: val, isExists: isExists };
    };
    QuestionSelectBase.prototype.updateCachedValueForUrlRequests = function (val, newChoices) {
        if (this.isValueEmpty(val))
            return null;
        if (Array.isArray(val)) {
            var res = [];
            for (var i = 0; i < val.length; i++) {
                var updatedValue = this.updateCachedValueForUrlRequests(val[i], newChoices);
                if (updatedValue && !this.isValueEmpty(updatedValue.value)) {
                    var newValue = updatedValue.value;
                    var item = itemvalue_ItemValue.getItemByValue(newChoices, updatedValue.value);
                    if (!!item) {
                        newValue = item.value;
                    }
                    res.push(newValue);
                }
            }
            return { value: res };
        }
        var value = val.isExists && this.hasUnknownValue(val.value) ? null : val.value;
        var item = itemvalue_ItemValue.getItemByValue(newChoices, value);
        if (!!item) {
            value = item.value;
        }
        return { value: value };
    };
    QuestionSelectBase.prototype.updateChoicesDependedQuestions = function () {
        if (this.isLoadingFromJson || this.isUpdatingChoicesDependedQuestions ||
            !this.allowNotifyValueChanged || this.choicesByUrl.isRunning)
            return;
        this.isUpdatingChoicesDependedQuestions = true;
        this.updateDependedQuestions();
        this.isUpdatingChoicesDependedQuestions = false;
    };
    QuestionSelectBase.prototype.updateDependedQuestion = function () {
        this.onVisibleChoicesChanged();
        this.clearIncorrectValues();
    };
    QuestionSelectBase.prototype.onSurveyValueChanged = function (newValue) {
        _super.prototype.onSurveyValueChanged.call(this, newValue);
        this.updateChoicesDependedQuestions();
    };
    QuestionSelectBase.prototype.onVisibleChoicesChanged = function () {
        if (this.isLoadingFromJson || this.isLockVisibleChoices)
            return;
        this.updateVisibleChoices();
        this.onVisibleChanged();
        if (!!this.visibleChoicesChangedCallback) {
            this.visibleChoicesChangedCallback();
        }
        this.updateChoicesDependedQuestions();
    };
    QuestionSelectBase.prototype.isVisibleCore = function () {
        var superVal = _super.prototype.isVisibleCore.call(this);
        if (!this.hideIfChoicesEmpty || !superVal)
            return superVal;
        var choices = this.isUsingCarryForward ? this.visibleChoices : this.getFilteredChoices();
        return !choices || choices.length > 0;
    };
    QuestionSelectBase.prototype.sortVisibleChoices = function (array) {
        if (this.isDesignMode)
            return array;
        var order = this.choicesOrder.toLowerCase();
        if (order == "asc")
            return this.sortArray(array, 1);
        if (order == "desc")
            return this.sortArray(array, -1);
        if (order == "random")
            return this.randomizeArray(array);
        return array;
    };
    QuestionSelectBase.prototype.sortArray = function (array, mult) {
        return array.sort(function (a, b) {
            return helpers_Helpers.compareStrings(a.calculatedText, b.calculatedText) * mult;
        });
    };
    QuestionSelectBase.prototype.randomizeArray = function (array) {
        return helpers_Helpers.randomizeArray(array);
    };
    Object.defineProperty(QuestionSelectBase.prototype, "hasChoicesUrl", {
        get: function () {
            return this.choicesByUrl && !!this.choicesByUrl.url;
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.clearIncorrectValues = function () {
        if (!this.hasValueToClearIncorrectValues() || !this.canClearIncorrectValues())
            return;
        if (this.clearIncorrectValuesCallback) {
            this.clearIncorrectValuesCallback();
        }
        else {
            this.clearIncorrectValuesCore();
        }
    };
    QuestionSelectBase.prototype.canClearIncorrectValues = function () {
        if (this.carryForwardQuestion && !this.carryForwardQuestion.isReady)
            return false;
        if (!!this.survey && this.survey.questionsByValueName(this.getValueName()).length > 1)
            return false;
        if (this.hasChoicesUrl && (!this.choicesFromUrl || this.choicesFromUrl.length == 0))
            return false;
        return true;
    };
    QuestionSelectBase.prototype.hasValueToClearIncorrectValues = function () {
        if (!!this.survey && this.survey.keepIncorrectValues)
            return false;
        return !this.keepIncorrectValues && !this.isEmpty();
    };
    QuestionSelectBase.prototype.clearValueIfInvisibleCore = function (reason) {
        _super.prototype.clearValueIfInvisibleCore.call(this, reason);
        this.clearIncorrectValues();
    };
    /**
     * Returns `true` if a passed choice item is selected.
     *
     * To obtain a choice item to check, use the `noneItem` or `otherItem` property or the `choices` array.
     * @param item A choice item.
     * @see noneItem
     * @see otherItem
     * @see choices
     */
    QuestionSelectBase.prototype.isItemSelected = function (item) {
        if (item === this.otherItem)
            return this.isOtherSelected;
        return this.isItemSelectedCore(item);
    };
    QuestionSelectBase.prototype.isItemSelectedCore = function (item) {
        return item.value === this.value;
    };
    QuestionSelectBase.prototype.clearDisabledValues = function () {
        if (!this.survey || !this.survey.clearValueOnDisableItems)
            return;
        this.clearDisabledValuesCore();
    };
    QuestionSelectBase.prototype.clearIncorrectValuesCore = function () {
        var val = this.value;
        if (this.canClearValueAnUnknown(val)) {
            this.clearValue(true);
        }
    };
    QuestionSelectBase.prototype.canClearValueAnUnknown = function (val) {
        if (!this.getStoreOthersAsComment() && this.isOtherSelected)
            return false;
        return this.hasUnknownValue(val, true, true, true);
    };
    QuestionSelectBase.prototype.clearDisabledValuesCore = function () {
        if (this.isValueDisabled(this.value)) {
            this.clearValue(true);
        }
    };
    QuestionSelectBase.prototype.clearUnusedValues = function () {
        _super.prototype.clearUnusedValues.call(this);
        if (!this.isOtherSelected) {
            this.otherValue = "";
        }
        if (!this.showCommentArea && (!this.getStoreOthersAsComment() && !this.isOtherSelected)) {
            this.comment = "";
        }
    };
    QuestionSelectBase.prototype.getColumnClass = function () {
        return new CssClassBuilder()
            .append(this.cssClasses.column)
            .append("sv-q-column-" + this.colCount, this.hasColumns)
            .toString();
    };
    QuestionSelectBase.prototype.getItemIndex = function (item) {
        return this.visibleChoices.indexOf(item);
    };
    QuestionSelectBase.prototype.getItemClass = function (item) {
        var options = { item: item };
        var res = this.getItemClassCore(item, options);
        options.css = res;
        if (!!this.survey) {
            this.survey.updateChoiceItemCss(this, options);
        }
        return options.css;
    };
    QuestionSelectBase.prototype.getCurrentColCount = function () {
        return this.colCount;
    };
    QuestionSelectBase.prototype.getItemClassCore = function (item, options) {
        var builder = new CssClassBuilder()
            .append(this.cssClasses.item)
            .append(this.cssClasses.itemInline, !this.hasColumns && this.colCount === 0)
            .append("sv-q-col-" + this.getCurrentColCount(), !this.hasColumns && this.colCount !== 0)
            .append(this.cssClasses.itemOnError, this.hasCssError());
        var readOnlyStyles = this.getIsDisableAndReadOnlyStyles(!item.isEnabled);
        var isReadOnly = readOnlyStyles[0];
        var isDisabled = readOnlyStyles[1];
        var isChecked = this.isItemSelected(item) ||
            (this.isOtherSelected && this.otherItem.value === item.value);
        var allowHover = !isDisabled && !isChecked && !(!!this.survey && this.survey.isDesignMode);
        var isNone = item === this.noneItem;
        options.isDisabled = isDisabled || isReadOnly;
        options.isChecked = isChecked;
        options.isNone = isNone;
        return builder
            .append(this.cssClasses.itemDisabled, isDisabled)
            .append(this.cssClasses.itemReadOnly, isReadOnly)
            .append(this.cssClasses.itemPreview, this.isPreviewStyle)
            .append(this.cssClasses.itemChecked, isChecked)
            .append(this.cssClasses.itemHover, allowHover)
            .append(this.cssClasses.itemNone, isNone)
            .toString();
    };
    QuestionSelectBase.prototype.getLabelClass = function (item) {
        return new CssClassBuilder()
            .append(this.cssClasses.label)
            .append(this.cssClasses.labelChecked, this.isItemSelected(item))
            .toString();
    };
    QuestionSelectBase.prototype.getControlLabelClass = function (item) {
        return new CssClassBuilder()
            .append(this.cssClasses.controlLabel)
            .append(this.cssClasses.controlLabelChecked, this.isItemSelected(item))
            .toString() || undefined;
    };
    Object.defineProperty(QuestionSelectBase.prototype, "headItems", {
        get: function () {
            var count = (this.separateSpecialChoices || this.isDesignMode) ? this.headItemsCount : 0;
            var res = [];
            for (var i = 0; i < count; i++)
                res.push(this.visibleChoices[i]);
            return res;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "footItems", {
        get: function () {
            var count = (this.separateSpecialChoices || this.isDesignMode) ? this.footItemsCount : 0;
            var res = [];
            var items = this.visibleChoices;
            for (var i = 0; i < count; i++)
                res.push(items[items.length - count + i]);
            return res;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "dataChoices", {
        get: function () {
            var _this = this;
            return this.visibleChoices.filter(function (item) { return !_this.isBuiltInChoice(item); });
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "bodyItems", {
        get: function () {
            return (this.hasHeadItems || this.hasFootItems) ? this.dataChoices : this.visibleChoices;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "hasHeadItems", {
        get: function () {
            return this.headItems.length > 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "hasFootItems", {
        get: function () {
            return this.footItems.length > 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "columns", {
        get: function () {
            var columns = [];
            var colCount = this.getCurrentColCount();
            if (this.hasColumns && this.visibleChoices.length > 0) {
                var choicesToBuildColumns = (!this.separateSpecialChoices && !this.isDesignMode) ?
                    this.visibleChoices : this.dataChoices;
                if (settings.showItemsInOrder == "column") {
                    var prevIndex = 0;
                    var leftElementsCount = choicesToBuildColumns.length % colCount;
                    for (var i = 0; i < colCount; i++) {
                        var column = [];
                        for (var j = prevIndex; j < prevIndex + Math.floor(choicesToBuildColumns.length / colCount); j++) {
                            column.push(choicesToBuildColumns[j]);
                        }
                        if (leftElementsCount > 0) {
                            leftElementsCount--;
                            column.push(choicesToBuildColumns[j]);
                            j++;
                        }
                        prevIndex = j;
                        columns.push(column);
                    }
                }
                else {
                    for (var i = 0; i < colCount; i++) {
                        var column = [];
                        for (var j = i; j < choicesToBuildColumns.length; j += colCount) {
                            column.push(choicesToBuildColumns[j]);
                        }
                        columns.push(column);
                    }
                }
            }
            return columns;
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.getItemsColumnKey = function (itemsColumn) {
        return (itemsColumn || []).map(function (c) { return c.value || ""; }).join("");
    };
    Object.defineProperty(QuestionSelectBase.prototype, "hasColumns", {
        get: function () {
            return !this.isMobile &&
                (this.getCurrentColCount() > 1);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "rowLayout", {
        get: function () {
            return this.getCurrentColCount() == 0 && !(this.hasFootItems || this.hasHeadItems);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSelectBase.prototype, "blockedRow", {
        get: function () {
            return this.getCurrentColCount() == 0 && (this.hasFootItems || this.hasHeadItems);
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.choicesLoaded = function () {
        this.isChoicesLoaded = true;
        this.updateIsReady();
        if (this.survey) {
            this.survey.loadedChoicesFromServer(this);
        }
        if (this.loadedChoicesFromServerCallback) {
            this.loadedChoicesFromServerCallback();
        }
    };
    QuestionSelectBase.prototype.getItemValueWrapperComponentName = function (item) {
        var survey = this.survey;
        if (survey) {
            return survey.getItemValueWrapperComponentName(item, this);
        }
        return survey_SurveyModel.TemplateRendererComponentName;
    };
    QuestionSelectBase.prototype.getItemValueWrapperComponentData = function (item) {
        var survey = this.survey;
        if (survey) {
            return survey.getItemValueWrapperComponentData(item, this);
        }
        return item;
    };
    QuestionSelectBase.prototype.ariaItemChecked = function (item) {
        return this.renderedValue === item.value ? "true" : "false";
    };
    QuestionSelectBase.prototype.isOtherItem = function (item) {
        return this.hasOther && item.value == this.otherItem.value;
    };
    Object.defineProperty(QuestionSelectBase.prototype, "itemSvgIcon", {
        get: function () {
            if (this.isPreviewStyle && this.cssClasses.itemPreviewSvgIconId) {
                return this.cssClasses.itemPreviewSvgIconId;
            }
            return this.cssClasses.itemSvgIconId;
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.getSelectBaseRootCss = function () {
        return new CssClassBuilder()
            .append(this.getQuestionRootCss())
            .append(this.cssClasses.rootRow, this.rowLayout)
            .toString();
    };
    QuestionSelectBase.prototype.allowMobileInDesignMode = function () {
        return true;
    };
    QuestionSelectBase.prototype.getAriaItemLabel = function (item) {
        return item.locText.renderedHtml;
    };
    QuestionSelectBase.prototype.getItemId = function (item) {
        return this.inputId + "_" + this.getItemIndex(item);
    };
    Object.defineProperty(QuestionSelectBase.prototype, "questionName", {
        get: function () {
            return this.name + "_" + this.id;
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.getItemEnabled = function (item) {
        return !this.isDisabledAttr && item.isEnabled;
    };
    QuestionSelectBase.prototype.afterRender = function (el) {
        _super.prototype.afterRender.call(this, el);
        this.rootElement = el;
    };
    QuestionSelectBase.prototype.beforeDestroyQuestionElement = function (el) {
        _super.prototype.beforeDestroyQuestionElement.call(this, el);
        this.rootElement = undefined;
    };
    QuestionSelectBase.prototype.focusOtherComment = function () {
        var _this = this;
        if (!!this.rootElement) {
            setTimeout(function () {
                var commentEl = _this.rootElement.querySelector("textarea");
                if (!!commentEl) {
                    commentEl.focus();
                }
            }, 10);
        }
    };
    QuestionSelectBase.prototype.onValueChanged = function () {
        _super.prototype.onValueChanged.call(this);
        if (!this.isDesignMode && !this.prevIsOtherSelected && this.isOtherSelected) {
            this.focusOtherComment();
        }
        this.prevIsOtherSelected = this.isOtherSelected;
    };
    QuestionSelectBase.prototype.getDefaultItemComponent = function () {
        return "";
    };
    Object.defineProperty(QuestionSelectBase.prototype, "itemComponent", {
        /**
         * The name of a component used to render items.
         *
         * [View Dropdown Demo](https://surveyjs.io/form-library/examples/dropdown-box-with-custom-items/ (linkStyle))
         *
         * [View Ranking Demo](https://surveyjs.io/form-library/examples/dropdown-box-with-custom-items/ (linkStyle))
         */
        get: function () {
            return this.getPropertyValue("itemComponent", this.getDefaultItemComponent());
        },
        set: function (value) {
            this.setPropertyValue("itemComponent", value);
        },
        enumerable: false,
        configurable: true
    });
    QuestionSelectBase.prototype.updateCssClasses = function (res, css) {
        _super.prototype.updateCssClasses.call(this, res, css);
        if (!!this.dropdownListModel) {
            var listCssClasses = {};
            mergeValues(css.list, listCssClasses);
            mergeValues(res.list, listCssClasses);
            res["list"] = listCssClasses;
        }
    };
    QuestionSelectBase.prototype.calcCssClasses = function (css) {
        var classes = _super.prototype.calcCssClasses.call(this, css);
        if (this.dropdownListModel) {
            this.dropdownListModel.updateCssClasses(classes.popup, classes.list);
        }
        return classes;
    };
    question_baseselect_decorate([
        jsonobject_property({ onSet: function (newVal, target) {
                target.onSelectedItemValuesChangedHandler(newVal);
            } })
    ], QuestionSelectBase.prototype, "selectedItemValues", void 0);
    question_baseselect_decorate([
        jsonobject_property()
    ], QuestionSelectBase.prototype, "separateSpecialChoices", void 0);
    question_baseselect_decorate([
        jsonobject_property({ localizable: true })
    ], QuestionSelectBase.prototype, "otherPlaceholder", void 0);
    return QuestionSelectBase;
}(question_Question));

/**
 * A base class for multiple-selection question types that can display choice items in multiple columns ([Checkbox](https://surveyjs.io/form-library/documentation/questioncheckboxmodel), [Radiogroup](https://surveyjs.io/form-library/documentation/questionradiogroupmodel), [Image Picker](https://surveyjs.io/form-library/documentation/questionimagepickermodel)).
 */
var QuestionCheckboxBase = /** @class */ (function (_super) {
    question_baseselect_extends(QuestionCheckboxBase, _super);
    function QuestionCheckboxBase(name) {
        return _super.call(this, name) || this;
    }
    Object.defineProperty(QuestionCheckboxBase.prototype, "colCount", {
        /**
         * Gets or sets the number of columns used to arrange choice items.
         *
         * Set this property to 0 if you want to display all items in one line. The default value depends on the available width.
         * @see separateSpecialChoices
         */
        get: function () {
            return this.getPropertyValue("colCount", this.isFlowLayout ? 0 : undefined);
        },
        set: function (value) {
            if (value < 0 || value > 5 || this.isFlowLayout)
                return;
            this.setPropertyValue("colCount", value);
            this.fireCallback(this.colCountChangedCallback);
        },
        enumerable: false,
        configurable: true
    });
    QuestionCheckboxBase.prototype.onParentChanged = function () {
        _super.prototype.onParentChanged.call(this);
        if (this.isFlowLayout) {
            this.setPropertyValue("colCount", null);
        }
    };
    QuestionCheckboxBase.prototype.onParentQuestionChanged = function () {
        this.onVisibleChoicesChanged();
    };
    QuestionCheckboxBase.prototype.getSearchableItemValueKeys = function (keys) {
        keys.push("choices");
    };
    return QuestionCheckboxBase;
}(question_baseselect_QuestionSelectBase));

function checkCopyPropVisibility(obj, mode) {
    var _a;
    if (!obj)
        return false;
    if (!!obj.templateQuestion) {
        var data = (_a = obj.colOwner) === null || _a === void 0 ? void 0 : _a.data;
        obj = obj.templateQuestion;
        if (!obj.getCarryForwardQuestion(data))
            return false;
    }
    return obj.carryForwardQuestionType === mode;
}
Serializer.addClass("selectbase", [
    { name: "showCommentArea:switch", layout: "row", visible: true, category: "general" },
    "choicesFromQuestion:question_carryforward",
    {
        name: "choices:itemvalue[]", uniqueProperty: "value",
        baseValue: function () {
            return surveyLocalization.getString("choices_Item");
        },
        dependsOn: "choicesFromQuestion",
        visibleIf: function (obj) {
            return !obj.choicesFromQuestion;
        },
    },
    {
        name: "choicesFromQuestionMode",
        default: "all",
        choices: ["all", "selected", "unselected"],
        dependsOn: "choicesFromQuestion",
        visibleIf: function (obj) {
            return checkCopyPropVisibility(obj, "select");
        },
    },
    {
        name: "choiceValuesFromQuestion",
        dependsOn: "choicesFromQuestion",
        visibleIf: function (obj) {
            return checkCopyPropVisibility(obj, "array");
        },
    },
    {
        name: "choiceTextsFromQuestion",
        dependsOn: "choicesFromQuestion",
        visibleIf: function (obj) {
            return checkCopyPropVisibility(obj, "array");
        },
    },
    {
        name: "choicesOrder",
        default: "none",
        choices: ["none", "asc", "desc", "random"],
        dependsOn: "choicesFromQuestion",
        visibleIf: function (obj) {
            return !obj.choicesFromQuestion;
        },
    },
    {
        name: "choicesByUrl:restfull",
        className: "choicesByUrl",
        onGetValue: function (obj) {
            return obj.choicesByUrl.getData();
        },
        onSetValue: function (obj, value) {
            obj.choicesByUrl.setData(value);
        },
    },
    "hideIfChoicesEmpty:boolean",
    "choicesVisibleIf:condition",
    {
        name: "choicesEnableIf:condition",
        dependsOn: "choicesFromQuestion",
        visibleIf: function (obj) {
            return !obj.choicesFromQuestion;
        },
    },
    { name: "defaultValue:value", visibleIf: function (obj) { return !obj.choicesFromQuestion; }, dependsOn: "choicesFromQuestion" },
    { name: "correctAnswer:value", visibleIf: function (obj) { return !obj.choicesFromQuestion; }, dependsOn: "choicesFromQuestion" },
    { name: "separateSpecialChoices:boolean", visible: false },
    { name: "showOtherItem:boolean", alternativeName: "hasOther" },
    { name: "showNoneItem:boolean", alternativeName: "hasNone" },
    { name: "showRefuseItem:boolean", visible: false, version: "1.9.128" },
    { name: "showDontKnowItem:boolean", visible: false, version: "1.9.128" },
    {
        name: "otherPlaceholder",
        alternativeName: "otherPlaceHolder",
        serializationProperty: "locOtherPlaceholder",
        dependsOn: "showOtherItem",
        visibleIf: function (obj) {
            return obj.hasOther;
        },
    },
    {
        name: "noneText",
        serializationProperty: "locNoneText",
        dependsOn: "showNoneItem",
        visibleIf: function (obj) {
            return obj.showNoneItem;
        },
    },
    {
        name: "refuseText",
        serializationProperty: "locRefuseText",
        dependsOn: "showRefuseItem",
        visibleIf: function (obj) {
            return obj.showRefuseItem;
        },
    },
    {
        name: "dontKnowText",
        serializationProperty: "locDontKnowText",
        dependsOn: "showDontKnowItem",
        visibleIf: function (obj) {
            return obj.showDontKnowItem;
        },
    },
    {
        name: "otherText",
        serializationProperty: "locOtherText",
        dependsOn: "showOtherItem",
        visibleIf: function (obj) {
            return obj.hasOther;
        },
    },
    {
        name: "otherErrorText",
        serializationProperty: "locOtherErrorText",
        dependsOn: "showOtherItem",
        visibleIf: function (obj) {
            return obj.hasOther;
        },
    },
    {
        name: "storeOthersAsComment",
        default: "default",
        choices: ["default", true, false],
        visible: false,
    }
], null, "question");
Serializer.addClass("checkboxbase", [
    {
        name: "colCount:number",
        default: 1,
        choices: [0, 1, 2, 3, 4, 5],
        layout: "row",
    }
], null, "selectbase");

// CONCATENATED MODULE: ./packages/survey-core/src/utils/popup.ts
var Rect = /** @class */ (function () {
    function Rect(x, y, width, height) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }
    Object.defineProperty(Rect.prototype, "left", {
        get: function () {
            return this.x;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Rect.prototype, "top", {
        get: function () {
            return this.y;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Rect.prototype, "right", {
        get: function () {
            return this.x + this.width;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Rect.prototype, "bottom", {
        get: function () {
            return this.y + this.height;
        },
        enumerable: false,
        configurable: true
    });
    return Rect;
}());

var PopupUtils = /** @class */ (function () {
    function PopupUtils() {
    }
    PopupUtils.calculatePosition = function (targetRect, height, width, verticalPosition, horizontalPosition, positionMode) {
        if (positionMode === void 0) { positionMode = "flex"; }
        var currentLeft = targetRect.left;
        var currentTop = targetRect.top;
        if (positionMode === "flex") {
            if (horizontalPosition == "center")
                currentLeft = (targetRect.left + targetRect.right - width) / 2;
            else if (horizontalPosition == "left")
                currentLeft = targetRect.left - width;
            else
                currentLeft = targetRect.right;
        }
        if (verticalPosition == "middle")
            currentTop = (targetRect.top + targetRect.bottom - height) / 2;
        else if (verticalPosition == "top")
            currentTop = targetRect.top - height;
        else
            currentTop = targetRect.bottom;
        if (horizontalPosition != "center" && verticalPosition != "middle") {
            if (verticalPosition == "top") {
                currentTop = currentTop + targetRect.height;
            }
            else {
                currentTop = currentTop - targetRect.height;
            }
        }
        return { left: Math.round(currentLeft), top: Math.round(currentTop) };
    };
    PopupUtils.getCorrectedVerticalDimensions = function (top, height, windowHeight, verticalPosition, canShrink) {
        if (canShrink === void 0) { canShrink = true; }
        var result;
        var maxHeight = windowHeight - PopupUtils.bottomIndent;
        if (verticalPosition === "top") {
            result = { height: height, top: top };
        }
        if (top < 0) {
            result = { height: canShrink ? height + top : height, top: 0 };
        }
        else if (height + top > windowHeight) {
            var newHeight = Math.min(height, maxHeight - top);
            result = { height: canShrink ? newHeight : height, top: canShrink ? top : top - (height - newHeight) };
        }
        if (result) {
            result.height = Math.min(result.height, maxHeight);
            result.top = Math.max(result.top, 0);
        }
        return result;
    };
    PopupUtils.updateHorizontalDimensions = function (left, width, windowWidth, horizontalPosition, positionMode, margins) {
        if (positionMode === void 0) { positionMode = "flex"; }
        if (margins === void 0) { margins = { left: 0, right: 0 }; }
        width += (margins.left + margins.right);
        var newWidth = undefined, newLeft = left;
        if (horizontalPosition === "center") {
            if (positionMode === "fixed") {
                if (left + width > windowWidth) {
                    newWidth = windowWidth - left;
                }
                newLeft -= margins.left;
            }
            else {
                if (left < 0) {
                    newLeft = margins.left;
                    newWidth = Math.min(width, windowWidth);
                }
                else if (width + left > windowWidth) {
                    newLeft = windowWidth - width;
                    newLeft = Math.max(newLeft, margins.left);
                    newWidth = Math.min(width, windowWidth);
                }
            }
        }
        if (horizontalPosition === "left") {
            if (left < 0) {
                newLeft = margins.left;
                newWidth = Math.min(width, windowWidth);
            }
        }
        if (horizontalPosition === "right") {
            if (width + left > windowWidth) {
                newWidth = windowWidth - left;
            }
        }
        return { width: newWidth - margins.left - margins.right, left: newLeft };
    };
    PopupUtils.updateVerticalPosition = function (targetRect, height, horizontalPosition, verticalPosition, windowHeight) {
        if (verticalPosition === "middle")
            return verticalPosition;
        var deltaTop = height - (targetRect.top + (horizontalPosition !== "center" ? targetRect.height : 0));
        var deltaBottom = height + targetRect.bottom - (horizontalPosition !== "center" ? targetRect.height : 0) - windowHeight;
        if (deltaTop > 0 && deltaBottom <= 0 && verticalPosition == "top") {
            verticalPosition = "bottom";
        }
        else if (deltaBottom > 0 && deltaTop <= 0 && verticalPosition == "bottom") {
            verticalPosition = "top";
        }
        else if (deltaBottom > 0 && deltaTop > 0) {
            verticalPosition = deltaTop < deltaBottom ? "top" : "bottom";
        }
        return verticalPosition;
    };
    PopupUtils.updateHorizontalPosition = function (targetRect, width, horizontalPosition, windowWidth) {
        if (horizontalPosition === "center")
            return horizontalPosition;
        var deltaLeft = width - targetRect.left;
        var deltaRight = width + targetRect.right - windowWidth;
        if (deltaLeft > 0 && deltaRight <= 0 && horizontalPosition == "left") {
            horizontalPosition = "right";
        }
        else if (deltaRight > 0 && deltaLeft <= 0 && horizontalPosition == "right") {
            horizontalPosition = "left";
        }
        else if (deltaRight > 0 && deltaLeft > 0) {
            horizontalPosition = deltaLeft < deltaRight ? "left" : "right";
        }
        return horizontalPosition;
    };
    PopupUtils.calculatePopupDirection = function (verticalPosition, horizontalPosition) {
        var popupDirection;
        if (horizontalPosition == "center" && verticalPosition != "middle") {
            popupDirection = verticalPosition;
        }
        else if (horizontalPosition != "center") {
            popupDirection = horizontalPosition;
        }
        return popupDirection;
    };
    //called when showPointer  is true
    PopupUtils.calculatePointerTarget = function (targetRect, top, left, verticalPosition, horizontalPosition, marginLeft, marginRight) {
        if (marginLeft === void 0) { marginLeft = 0; }
        if (marginRight === void 0) { marginRight = 0; }
        var targetPos = {};
        if (horizontalPosition != "center") {
            targetPos.top = targetRect.top + targetRect.height / 2;
            targetPos.left = targetRect[horizontalPosition];
        }
        else if (verticalPosition != "middle") {
            targetPos.top = targetRect[verticalPosition];
            targetPos.left = targetRect.left + targetRect.width / 2;
        }
        targetPos.left = Math.round(targetPos.left - left);
        targetPos.top = Math.round(targetPos.top - top);
        if (horizontalPosition == "left") {
            targetPos.left -= marginLeft + marginRight;
        }
        if (horizontalPosition === "center") {
            targetPos.left -= marginLeft;
        }
        return targetPos;
    };
    PopupUtils.bottomIndent = 16;
    return PopupUtils;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/popup-view-model.ts
var popup_view_model_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var popup_view_model_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};








var FOCUS_INPUT_SELECTOR = "input:not(:disabled):not([readonly]):not([type=hidden]),select:not(:disabled):not([readonly]),textarea:not(:disabled):not([readonly]), button:not(:disabled):not([readonly]), [tabindex]:not([tabindex^=\"-\"])";
var popup_view_model_PopupBaseViewModel = /** @class */ (function (_super) {
    popup_view_model_extends(PopupBaseViewModel, _super);
    function PopupBaseViewModel(model) {
        var _this = _super.call(this) || this;
        _this.popupSelector = ".sv-popup";
        _this.fixedPopupContainer = ".sv-popup";
        _this.containerSelector = ".sv-popup__container";
        _this.scrollingContentSelector = ".sv-popup__scrolling-content";
        _this.visibilityAnimation = new AnimationBoolean(_this, function (val) {
            if (_this._isVisible !== val) {
                if (!val) {
                    _this.updateOnHiding();
                    _this.updateIsVisible(val);
                    _this.updateAfterHiding();
                    _this._isPositionSetValue = false;
                }
                else {
                    _this.updateBeforeShowing();
                    _this.updateIsVisible(val);
                }
            }
        }, function () { return _this._isVisible; });
        _this.onVisibilityChanged = new EventBase();
        _this.onModelIsVisibleChangedCallback = function () {
            _this.isVisible = _this.model.isVisible;
        };
        _this._isPositionSetValue = false;
        _this.model = model;
        _this.locale = _this.model.locale;
        return _this;
    }
    PopupBaseViewModel.prototype.updateIsVisible = function (val) {
        this._isVisible = val;
        this.onVisibilityChanged.fire(this, { isVisible: val });
    };
    PopupBaseViewModel.prototype.updateBeforeShowing = function () {
        this.model.onShow();
    };
    PopupBaseViewModel.prototype.updateAfterHiding = function () {
        this.model.onHiding();
    };
    PopupBaseViewModel.prototype.getLeaveOptions = function () {
        return { cssClass: "sv-popup--animate-leave", onBeforeRunAnimation: function (el) {
                el.setAttribute("inert", "");
            },
            onAfterRunAnimation: function (el) { return el.removeAttribute("inert"); }
        };
    };
    PopupBaseViewModel.prototype.getEnterOptions = function () {
        return { cssClass: "sv-popup--animate-enter" };
    };
    PopupBaseViewModel.prototype.getAnimatedElement = function () {
        return this.getAnimationContainer();
    };
    PopupBaseViewModel.prototype.isAnimationEnabled = function () {
        return this.model.displayMode !== "overlay" && settings.animationEnabled;
    };
    PopupBaseViewModel.prototype.getRerenderEvent = function () { return this.onElementRerendered; };
    PopupBaseViewModel.prototype.getAnimationContainer = function () {
        var _a;
        return (_a = this.container) === null || _a === void 0 ? void 0 : _a.querySelector(this.fixedPopupContainer);
    };
    Object.defineProperty(PopupBaseViewModel.prototype, "isVisible", {
        get: function () {
            return this._isVisible;
        },
        set: function (val) {
            this.visibilityAnimation.sync(val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupBaseViewModel.prototype, "container", {
        get: function () {
            return this.containerElement || this.createdContainer;
        },
        enumerable: false,
        configurable: true
    });
    PopupBaseViewModel.prototype.getLocale = function () {
        if (!!this.locale)
            return this.locale;
        return _super.prototype.getLocale.call(this);
    };
    PopupBaseViewModel.prototype.hidePopup = function () {
        this.model.isVisible = false;
    };
    PopupBaseViewModel.prototype.getStyleClass = function () {
        return new CssClassBuilder()
            .append(this.model.cssClass)
            .append("sv-popup--" + this.model.displayMode, this.isOverlay);
    };
    PopupBaseViewModel.prototype.getShowFooter = function () {
        return this.isOverlay;
    };
    PopupBaseViewModel.prototype.getShowHeader = function () {
        return false;
    };
    PopupBaseViewModel.prototype.getPopupHeaderTemplate = function () {
        return undefined;
    };
    PopupBaseViewModel.prototype.createFooterActionBar = function () {
        var _this = this;
        this.footerToolbarValue = new container_ActionContainer();
        this.footerToolbar.updateCallback = function (isResetInitialized) {
            _this.footerToolbarValue.actions.forEach(function (action) { return action.cssClasses = {
                item: "sv-popup__body-footer-item sv-popup__button sd-btn"
            }; });
        };
        var footerActions = [{
                id: "cancel",
                visibleIndex: 10,
                title: this.cancelButtonText,
                innerCss: "sv-popup__button--cancel sd-btn",
                action: function () { _this.cancel(); }
            }];
        footerActions = this.model.updateFooterActions(footerActions);
        this.footerToolbarValue.setItems(footerActions);
    };
    PopupBaseViewModel.prototype.resetDimensionsAndPositionStyleProperties = function () {
        var nullableValue = "inherit";
        this.top = nullableValue;
        this.left = nullableValue;
        this.height = nullableValue;
        this.width = nullableValue;
        this.minWidth = nullableValue;
    };
    PopupBaseViewModel.prototype.onModelChanging = function (newModel) {
    };
    PopupBaseViewModel.prototype.setupModel = function (model) {
        if (!!this.model) {
            this.model.onVisibilityChanged.remove(this.onModelIsVisibleChangedCallback);
        }
        this.onModelChanging(model);
        this._model = model;
        model.onVisibilityChanged.add(this.onModelIsVisibleChangedCallback);
        this.onModelIsVisibleChangedCallback();
    };
    Object.defineProperty(PopupBaseViewModel.prototype, "model", {
        get: function () {
            return this._model;
        },
        set: function (model) {
            this.setupModel(model);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupBaseViewModel.prototype, "title", {
        get: function () {
            return this.model.title;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupBaseViewModel.prototype, "contentComponentName", {
        get: function () {
            return this.model.contentComponentName;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupBaseViewModel.prototype, "contentComponentData", {
        get: function () {
            return this.model.contentComponentData;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupBaseViewModel.prototype, "isModal", {
        get: function () {
            return this.model.isModal;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupBaseViewModel.prototype, "isFocusedContent", {
        get: function () {
            return this.model.isFocusedContent;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupBaseViewModel.prototype, "isFocusedContainer", {
        get: function () {
            return this.model.isFocusedContainer;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupBaseViewModel.prototype, "showFooter", {
        get: function () {
            return this.getShowFooter();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupBaseViewModel.prototype, "showHeader", {
        get: function () {
            return this.getShowHeader();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupBaseViewModel.prototype, "popupHeaderTemplate", {
        get: function () {
            return this.getPopupHeaderTemplate();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupBaseViewModel.prototype, "isOverlay", {
        get: function () {
            return this.model.displayMode === "overlay";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupBaseViewModel.prototype, "styleClass", {
        get: function () {
            return this.getStyleClass().toString();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupBaseViewModel.prototype, "cancelButtonText", {
        get: function () {
            return this.getLocalizationString("modalCancelButtonText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupBaseViewModel.prototype, "footerToolbar", {
        get: function () {
            if (!this.footerToolbarValue) {
                this.createFooterActionBar();
            }
            return this.footerToolbarValue;
        },
        enumerable: false,
        configurable: true
    });
    PopupBaseViewModel.prototype.onKeyDown = function (event) {
        if (event.key === "Tab" || event.keyCode === 9) {
            this.trapFocus(event);
        }
        else if (event.key === "Escape" || event.keyCode === 27) {
            this.hidePopup();
        }
    };
    PopupBaseViewModel.prototype.trapFocus = function (event) {
        var focusableElements = this.container.querySelectorAll(FOCUS_INPUT_SELECTOR);
        var firstFocusableElement = focusableElements[0];
        var lastFocusableElement = focusableElements[focusableElements.length - 1];
        if (event.shiftKey) {
            if (settings.environment.root.activeElement === firstFocusableElement) {
                lastFocusableElement.focus();
                event.preventDefault();
            }
        }
        else {
            if (settings.environment.root.activeElement === lastFocusableElement) {
                firstFocusableElement.focus();
                event.preventDefault();
            }
        }
    };
    PopupBaseViewModel.prototype.switchFocus = function () {
        if (this.isFocusedContent) {
            this.focusFirstInput();
        }
        else if (this.isFocusedContainer) {
            this.focusContainer();
        }
    };
    Object.defineProperty(PopupBaseViewModel.prototype, "isPositionSet", {
        get: function () {
            return this._isPositionSetValue;
        },
        enumerable: false,
        configurable: true
    });
    PopupBaseViewModel.prototype.updateOnShowing = function () {
        this.prevActiveElement = settings.environment.root.activeElement;
        if (this.isOverlay) {
            this.resetDimensionsAndPositionStyleProperties();
        }
        this.switchFocus();
        this._isPositionSetValue = true;
    };
    PopupBaseViewModel.prototype.updateOnHiding = function () {
        if (this.isFocusedContent && this.prevActiveElement) {
            this.prevActiveElement.focus();
        }
    };
    PopupBaseViewModel.prototype.focusContainer = function () {
        if (!this.container)
            return;
        var popup = this.container.querySelector(this.popupSelector);
        popup === null || popup === void 0 ? void 0 : popup.focus();
    };
    PopupBaseViewModel.prototype.focusFirstInput = function () {
        var _this = this;
        setTimeout(function () {
            if (!_this.container)
                return;
            var el = _this.container.querySelector(_this.model.focusFirstInputSelector || FOCUS_INPUT_SELECTOR);
            if (!!el)
                el.focus();
            else
                _this.focusContainer();
        }, 100);
    };
    PopupBaseViewModel.prototype.clickOutside = function (event) {
        this.hidePopup();
        event === null || event === void 0 ? void 0 : event.stopPropagation();
    };
    PopupBaseViewModel.prototype.cancel = function () {
        this.model.onCancel();
        this.hidePopup();
    };
    PopupBaseViewModel.prototype.dispose = function () {
        _super.prototype.dispose.call(this);
        if (this.model) {
            this.model.onVisibilityChanged.remove(this.onModelIsVisibleChangedCallback);
        }
        if (!!this.createdContainer) {
            this.createdContainer.remove();
            this.createdContainer = undefined;
        }
        if (!!this.footerToolbarValue) {
            this.footerToolbarValue.dispose();
        }
        this.resetComponentElement();
    };
    PopupBaseViewModel.prototype.initializePopupContainer = function () {
        if (!this.container) {
            var container = DomDocumentHelper.createElement("div");
            this.createdContainer = container;
            getElement(settings.environment.popupMountContainer).appendChild(container);
        }
    };
    PopupBaseViewModel.prototype.setComponentElement = function (componentRoot, targetElement, areaElement) {
        if (!!componentRoot) {
            this.containerElement = componentRoot;
        }
    };
    PopupBaseViewModel.prototype.resetComponentElement = function () {
        this.containerElement = undefined;
        this.prevActiveElement = undefined;
    };
    PopupBaseViewModel.prototype.preventScrollOuside = function (event, deltaY) {
        var currentElement = event.target;
        while (currentElement !== this.container) {
            if (DomDocumentHelper.getComputedStyle(currentElement).overflowY === "auto" && currentElement.scrollHeight !== currentElement.offsetHeight) {
                var scrollHeight = currentElement.scrollHeight, scrollTop = currentElement.scrollTop, clientHeight = currentElement.clientHeight;
                if (!(deltaY > 0 && Math.abs(scrollHeight - clientHeight - scrollTop) < 1) && !(deltaY < 0 && scrollTop <= 0)) {
                    return;
                }
            }
            currentElement = currentElement.parentElement;
        }
        if (event.cancelable) {
            event.preventDefault();
        }
    };
    popup_view_model_decorate([
        jsonobject_property({ defaultValue: "0px" })
    ], PopupBaseViewModel.prototype, "top", void 0);
    popup_view_model_decorate([
        jsonobject_property({ defaultValue: "0px" })
    ], PopupBaseViewModel.prototype, "left", void 0);
    popup_view_model_decorate([
        jsonobject_property({ defaultValue: "auto" })
    ], PopupBaseViewModel.prototype, "height", void 0);
    popup_view_model_decorate([
        jsonobject_property({ defaultValue: "auto" })
    ], PopupBaseViewModel.prototype, "width", void 0);
    popup_view_model_decorate([
        jsonobject_property({ defaultValue: "auto" })
    ], PopupBaseViewModel.prototype, "minWidth", void 0);
    popup_view_model_decorate([
        jsonobject_property({ defaultValue: false })
    ], PopupBaseViewModel.prototype, "_isVisible", void 0);
    popup_view_model_decorate([
        jsonobject_property()
    ], PopupBaseViewModel.prototype, "locale", void 0);
    return PopupBaseViewModel;
}(base_Base));


// CONCATENATED MODULE: ./packages/survey-core/src/popup-dropdown-view-model.ts
var popup_dropdown_view_model_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var popup_dropdown_view_model_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};







function calculateIsTablet(windowWidth, windowHeight) {
    var _windowWidth = windowWidth || DomWindowHelper.getInnerWidth();
    var _windowHeight = windowHeight || DomWindowHelper.getInnerHeight();
    var width = Math.min(_windowWidth, _windowHeight);
    var isTablet = width >= popup_dropdown_view_model_PopupDropdownViewModel.tabletSizeBreakpoint;
    return isTablet;
}
var popup_dropdown_view_model_PopupDropdownViewModel = /** @class */ (function (_super) {
    popup_dropdown_view_model_extends(PopupDropdownViewModel, _super);
    function PopupDropdownViewModel(model, targetElement, areaElement) {
        var _this = _super.call(this, model) || this;
        _this.targetElement = targetElement;
        _this.areaElement = areaElement;
        _this.scrollEventCallBack = function (event) {
            if (_this.isOverlay && IsTouch) {
                event.stopPropagation();
                event.preventDefault();
                return;
            }
            _this.hidePopup();
        };
        _this.resizeEventCallback = function () {
            if (!DomWindowHelper.isAvailable())
                return;
            var visualViewport = DomWindowHelper.getVisualViewport();
            var documentElement = DomDocumentHelper.getDocumentElement();
            if (!!documentElement && !!visualViewport) {
                documentElement.style.setProperty("--sv-popup-overlay-height", visualViewport.height * visualViewport.scale + "px");
            }
        };
        _this.resizeWindowCallback = function () {
            if (!_this.isOverlay) {
                _this.updatePosition(true, survey_SurveyModel.platform === "vue" || survey_SurveyModel.platform === "vue3" || survey_SurveyModel.platform == "react");
            }
        };
        _this.clientY = 0;
        _this.isTablet = false;
        _this.touchStartEventCallback = function (event) {
            _this.clientY = event.touches[0].clientY;
        };
        _this.touchMoveEventCallback = function (event) {
            _this.preventScrollOuside(event, _this.clientY - event.changedTouches[0].clientY);
        };
        _this.model.onRecalculatePosition.add(_this.recalculatePositionHandler);
        return _this;
    }
    PopupDropdownViewModel.prototype.calculateIsTablet = function (windowWidth, windowHeight) {
        this.isTablet = calculateIsTablet(windowWidth, windowHeight);
    };
    PopupDropdownViewModel.prototype.getAvailableAreaRect = function () {
        if (this.areaElement) {
            var areaRect = this.areaElement.getBoundingClientRect();
            return new Rect(areaRect.x, areaRect.y, areaRect.width, areaRect.height);
        }
        return new Rect(0, 0, DomWindowHelper.getInnerWidth(), DomWindowHelper.getInnerHeight());
    };
    PopupDropdownViewModel.prototype.getTargetElementRect = function () {
        var rect = this.targetElement.getBoundingClientRect();
        var areaRect = this.getAvailableAreaRect();
        return new Rect(rect.left - areaRect.left, rect.top - areaRect.top, rect.width, rect.height);
    };
    PopupDropdownViewModel.prototype._updatePosition = function () {
        var _a, _b, _c;
        if (!this.targetElement)
            return;
        var targetElementRect = this.getTargetElementRect();
        var area = this.getAvailableAreaRect();
        var popupContainer = (_a = this.container) === null || _a === void 0 ? void 0 : _a.querySelector(this.containerSelector);
        if (!popupContainer)
            return;
        var fixedPopupContainer = (_b = this.container) === null || _b === void 0 ? void 0 : _b.querySelector(this.fixedPopupContainer);
        var scrollContent = popupContainer.querySelector(this.scrollingContentSelector);
        var popupComputedStyle = DomDocumentHelper.getComputedStyle(popupContainer);
        var marginLeft = (parseFloat(popupComputedStyle.marginLeft) || 0);
        var marginRight = (parseFloat(popupComputedStyle.marginRight) || 0);
        var height = popupContainer.offsetHeight - scrollContent.offsetHeight + scrollContent.scrollHeight;
        var width = popupContainer.getBoundingClientRect().width;
        this.model.setWidthByTarget && (this.minWidth = targetElementRect.width + "px");
        var verticalPosition = this.model.verticalPosition;
        var actualHorizontalPosition = this.getActualHorizontalPosition();
        if (DomWindowHelper.isAvailable()) {
            var heightValues = [height, DomWindowHelper.getInnerHeight() * 0.9, (_c = DomWindowHelper.getVisualViewport()) === null || _c === void 0 ? void 0 : _c.height];
            height = Math.ceil(Math.min.apply(Math, heightValues.filter(function (each) { return typeof each === "number"; })));
            verticalPosition = PopupUtils.updateVerticalPosition(targetElementRect, height, this.model.horizontalPosition, this.model.verticalPosition, area.height);
            actualHorizontalPosition = PopupUtils.updateHorizontalPosition(targetElementRect, width, this.model.horizontalPosition, area.width);
        }
        this.popupDirection = PopupUtils.calculatePopupDirection(verticalPosition, actualHorizontalPosition);
        var pos = PopupUtils.calculatePosition(targetElementRect, height, width + marginLeft + marginRight, verticalPosition, actualHorizontalPosition, this.model.positionMode);
        if (DomWindowHelper.isAvailable()) {
            var newVerticalDimensions = PopupUtils.getCorrectedVerticalDimensions(pos.top, height, area.height, verticalPosition, this.model.canShrink);
            if (!!newVerticalDimensions) {
                this.height = newVerticalDimensions.height + "px";
                pos.top = newVerticalDimensions.top;
            }
            if (this.model.setWidthByTarget) {
                this.width = targetElementRect.width + "px";
                pos.left = targetElementRect.left;
            }
            else {
                var newHorizontalDimensions = PopupUtils.updateHorizontalDimensions(pos.left, width, DomWindowHelper.getInnerWidth(), actualHorizontalPosition, this.model.positionMode, { left: marginLeft, right: marginRight });
                if (!!newHorizontalDimensions) {
                    this.width = newHorizontalDimensions.width ? newHorizontalDimensions.width + "px" : undefined;
                    pos.left = newHorizontalDimensions.left;
                }
            }
        }
        if (!!fixedPopupContainer) {
            var rect = fixedPopupContainer.getBoundingClientRect();
            pos.top -= rect.top;
            pos.left -= rect.left;
        }
        pos.left += area.left;
        pos.top += area.top;
        this.left = pos.left + "px";
        this.top = pos.top + "px";
        if (this.showHeader) {
            this.pointerTarget = PopupUtils.calculatePointerTarget(targetElementRect, pos.top, pos.left, verticalPosition, actualHorizontalPosition, marginLeft, marginRight);
            this.pointerTarget.top += "px";
            this.pointerTarget.left += "px";
        }
    };
    PopupDropdownViewModel.prototype.getActualHorizontalPosition = function () {
        var actualHorizontalPosition = this.model.horizontalPosition;
        if (DomDocumentHelper.isAvailable()) {
            var isRtl = DomDocumentHelper.getComputedStyle(DomDocumentHelper.getBody()).direction == "rtl";
            if (isRtl) {
                if (this.model.horizontalPosition === "left") {
                    actualHorizontalPosition = "right";
                }
                else if (this.model.horizontalPosition === "right") {
                    actualHorizontalPosition = "left";
                }
            }
        }
        return actualHorizontalPosition;
    };
    PopupDropdownViewModel.prototype.getStyleClass = function () {
        var overlayMode = this.model.overlayDisplayMode;
        return _super.prototype.getStyleClass.call(this)
            .append("sv-popup--dropdown", !this.isOverlay)
            .append("sv-popup--dropdown-overlay", this.isOverlay && overlayMode !== "plain")
            .append("sv-popup--tablet", this.isOverlay && (overlayMode == "tablet-dropdown-overlay" || (overlayMode == "auto" && this.isTablet)))
            .append("sv-popup--show-pointer", !this.isOverlay && this.showHeader)
            .append("sv-popup--" + this.popupDirection, !this.isOverlay && (this.showHeader || this.popupDirection == "top" || this.popupDirection == "bottom"));
    };
    PopupDropdownViewModel.prototype.getShowHeader = function () {
        return this.model.showPointer && !this.isOverlay;
    };
    PopupDropdownViewModel.prototype.getPopupHeaderTemplate = function () {
        return "popup-pointer";
    };
    PopupDropdownViewModel.prototype.setComponentElement = function (componentRoot, targetElement, areaElement) {
        _super.prototype.setComponentElement.call(this, componentRoot);
        if (!!componentRoot && !!componentRoot.parentElement && !this.isModal) {
            this.targetElement = targetElement || componentRoot.parentElement;
            this.areaElement = areaElement;
        }
    };
    PopupDropdownViewModel.prototype.resetComponentElement = function () {
        _super.prototype.resetComponentElement.call(this);
        this.targetElement = undefined;
    };
    PopupDropdownViewModel.prototype.updateOnShowing = function () {
        var root = settings.environment.root;
        this.prevActiveElement = root.activeElement;
        if (this.isOverlay) {
            this.resetDimensionsAndPositionStyleProperties();
        }
        else {
            this.updatePosition(true, false);
        }
        this.switchFocus();
        DomWindowHelper.addEventListener("resize", this.resizeWindowCallback);
        if (this.shouldCreateResizeCallback) {
            DomWindowHelper.getVisualViewport().addEventListener("resize", this.resizeEventCallback);
            if (this.container) {
                this.container.addEventListener("touchstart", this.touchStartEventCallback);
                this.container.addEventListener("touchmove", this.touchMoveEventCallback);
            }
            this.calculateIsTablet();
            this.resizeEventCallback();
        }
        DomWindowHelper.addEventListener("scroll", this.scrollEventCallBack);
        this._isPositionSetValue = true;
    };
    Object.defineProperty(PopupDropdownViewModel.prototype, "shouldCreateResizeCallback", {
        get: function () {
            return !!DomWindowHelper.getVisualViewport() && this.isOverlay && IsTouch;
        },
        enumerable: false,
        configurable: true
    });
    PopupDropdownViewModel.prototype.updatePosition = function (isResetHeight, isDelayUpdating) {
        var _this = this;
        if (isDelayUpdating === void 0) { isDelayUpdating = true; }
        if (isResetHeight) {
            this.height = "auto";
        }
        if (isDelayUpdating) {
            setTimeout(function () {
                _this._updatePosition();
            }, 1);
        }
        else {
            this._updatePosition();
        }
    };
    PopupDropdownViewModel.prototype.updateOnHiding = function () {
        _super.prototype.updateOnHiding.call(this);
        DomWindowHelper.removeEventListener("resize", this.resizeWindowCallback);
        if (this.shouldCreateResizeCallback) {
            DomWindowHelper.getVisualViewport().removeEventListener("resize", this.resizeEventCallback);
            if (this.container) {
                this.container.removeEventListener("touchstart", this.touchStartEventCallback);
                this.container.removeEventListener("touchmove", this.touchMoveEventCallback);
            }
        }
        DomWindowHelper.removeEventListener("scroll", this.scrollEventCallBack);
        if (!this.isDisposed) {
            this.top = undefined;
            this.left = undefined;
            this.height = undefined;
            this.width = undefined;
            this.minWidth = undefined;
        }
    };
    PopupDropdownViewModel.prototype.onModelChanging = function (newModel) {
        var _this = this;
        if (!!this.model) {
            this.model.onRecalculatePosition.remove(this.recalculatePositionHandler);
        }
        if (!this.recalculatePositionHandler) {
            this.recalculatePositionHandler = function (_, options) {
                if (!_this.isOverlay) {
                    _this.updatePosition(options.isResetHeight);
                }
            };
        }
        _super.prototype.onModelChanging.call(this, newModel);
        newModel.onRecalculatePosition.add(this.recalculatePositionHandler);
    };
    PopupDropdownViewModel.prototype.dispose = function () {
        _super.prototype.dispose.call(this);
        this.updateOnHiding();
        if (!!this.model) {
            this.model.onRecalculatePosition.remove(this.recalculatePositionHandler);
            this.recalculatePositionHandler = undefined;
        }
        this.resetComponentElement();
    };
    PopupDropdownViewModel.tabletSizeBreakpoint = 600;
    popup_dropdown_view_model_decorate([
        jsonobject_property()
    ], PopupDropdownViewModel.prototype, "isTablet", void 0);
    popup_dropdown_view_model_decorate([
        jsonobject_property({ defaultValue: "left" })
    ], PopupDropdownViewModel.prototype, "popupDirection", void 0);
    popup_dropdown_view_model_decorate([
        jsonobject_property({ defaultValue: { left: "0px", top: "0px" } })
    ], PopupDropdownViewModel.prototype, "pointerTarget", void 0);
    return PopupDropdownViewModel;
}(popup_view_model_PopupBaseViewModel));


// CONCATENATED MODULE: ./packages/survey-core/src/dropdownListModel.ts
var dropdownListModel_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var dropdownListModel_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};












var dropdownListModel_DropdownListModel = /** @class */ (function (_super) {
    dropdownListModel_extends(DropdownListModel, _super);
    function DropdownListModel(question, onSelectionChanged) {
        var _this = _super.call(this) || this;
        _this.question = question;
        _this.onSelectionChanged = onSelectionChanged;
        _this.minPageSize = 25;
        _this.loadingItemHeight = 40;
        _this.timer = undefined;
        _this._markdownMode = false;
        _this.filteredItems = undefined;
        _this.selectedItemSelector = ".sv-list__item--selected";
        _this.itemSelector = ".sv-list__item";
        _this.itemsSettings = { skip: 0, take: 0, totalCount: 0, items: [] };
        _this.popupCssClasses = "sv-single-select-list";
        _this.listModelFilterStringChanged = function (newValue) {
            if (_this.filterString !== newValue) {
                _this.filterString = newValue;
            }
        };
        _this.questionPropertyChangedHandler = function (sender, options) {
            _this.onPropertyChangedHandler(sender, options);
        };
        _this.htmlCleanerElement = DomDocumentHelper.createElement("div");
        _this.question.ariaExpanded = "false";
        question.onPropertyChanged.add(_this.questionPropertyChangedHandler);
        _this.showInputFieldComponent = _this.question.showInputFieldComponent;
        _this.listModel = _this.createListModel();
        _this.updateAfterListModelCreated(_this.listModel);
        _this.setChoicesLazyLoadEnabled(_this.question.choicesLazyLoadEnabled);
        _this.setSearchEnabled(_this.question.searchEnabled);
        _this.setTextWrapEnabled(_this.question.textWrapEnabled);
        _this.createPopup();
        _this.resetItemsSettings();
        return _this;
    }
    Object.defineProperty(DropdownListModel.prototype, "focusFirstInputSelector", {
        get: function () {
            return this.getFocusFirstInputSelector();
        },
        enumerable: false,
        configurable: true
    });
    DropdownListModel.prototype.getFocusFirstInputSelector = function () {
        if (IsTouch) {
            return this.isValueEmpty(this.question.value) ? this.itemSelector : this.selectedItemSelector;
        }
        else {
            return (!this.listModel.showFilter && !!this.question.value) ? this.selectedItemSelector : "";
        }
    };
    DropdownListModel.prototype.resetItemsSettings = function () {
        this.itemsSettings.skip = 0;
        this.itemsSettings.take = Math.max(this.minPageSize, this.question.choicesLazyLoadPageSize);
        this.itemsSettings.totalCount = 0;
        this.itemsSettings.items = [];
    };
    DropdownListModel.prototype.setItems = function (items, totalCount) {
        this.itemsSettings.items = [].concat(this.itemsSettings.items, items);
        this.itemsSettings.totalCount = totalCount;
        this.listModel.isAllDataLoaded = this.question.choicesLazyLoadEnabled && this.itemsSettings.items.length == this.itemsSettings.totalCount;
        this.question.choices = this.itemsSettings.items;
    };
    DropdownListModel.prototype.loadQuestionChoices = function (callbackAfterItemsLoaded) {
        var _this = this;
        this.question.survey.loadQuestionChoices({
            question: this.question,
            filter: this.filterString,
            skip: this.itemsSettings.skip,
            take: this.itemsSettings.take,
            setItems: function (items, totalCount) {
                _this.setItems(items || [], totalCount || 0);
                _this.popupRecalculatePosition(_this.itemsSettings.skip === _this.itemsSettings.take);
                if (!!callbackAfterItemsLoaded) {
                    callbackAfterItemsLoaded();
                }
            }
        });
        this.itemsSettings.skip += this.itemsSettings.take;
    };
    DropdownListModel.prototype.updateQuestionChoices = function (callbackAfterItemsLoaded) {
        var _this = this;
        var isUpdate = (this.itemsSettings.skip + 1) < this.itemsSettings.totalCount;
        if (!this.itemsSettings.skip || isUpdate) {
            if (!!this.filterString && settings.dropdownSearchDelay > 0) {
                if (!!this.timer) {
                    clearTimeout(this.timer);
                    this.timer = undefined;
                }
                this.timer = setTimeout(function () {
                    _this.loadQuestionChoices(callbackAfterItemsLoaded);
                }, settings.dropdownSearchDelay);
            }
            else {
                this.loadQuestionChoices(callbackAfterItemsLoaded);
            }
        }
    };
    DropdownListModel.prototype.updatePopupFocusFirstInputSelector = function () {
        this._popupModel.focusFirstInputSelector = this.focusFirstInputSelector;
    };
    DropdownListModel.prototype.getDropdownMenuOptions = function () {
        var windowWidth = DomWindowHelper.getInnerWidth();
        var windowHeight = DomWindowHelper.getInnerHeight();
        var isTablet = calculateIsTablet(windowWidth, windowHeight);
        var menuType = "dropdown";
        var deviceType = "desktop";
        if (IsTouch) {
            menuType = isTablet ? "popup" : "overlay";
            deviceType = isTablet ? "tablet" : "mobile";
        }
        return {
            menuType: menuType,
            deviceType: deviceType,
            hasTouchScreen: IsTouch,
            screenHeight: windowHeight,
            screenWidth: windowWidth
        };
    };
    DropdownListModel.prototype.createPopup = function () {
        var _this = this;
        var popupOptions = { verticalPosition: "bottom", horizontalPosition: "center", showPointer: false };
        this._popupModel = new popup_PopupModel("sv-list", { model: this.listModel }, popupOptions);
        this._popupModel.displayMode = IsTouch ? "overlay" : "popup";
        this._popupModel.positionMode = "fixed";
        this._popupModel.isFocusedContainer = false;
        this._popupModel.isFocusedContent = IsTouch;
        this._popupModel.setWidthByTarget = !IsTouch;
        this._popupModel.locale = this.question.getLocale();
        this.updatePopupFocusFirstInputSelector();
        this.listModel.registerPropertyChangedHandlers(["showFilter"], function () {
            _this.updatePopupFocusFirstInputSelector();
        });
        this._popupModel.cssClass = this.popupCssClasses;
        this._popupModel.onVisibilityChanged.add(function (_, option) {
            if (option.isVisible) {
                _this.listModel.renderElements = true;
            }
            if (option.isVisible && _this.question.choicesLazyLoadEnabled) {
                _this.listModel.actions = [];
                _this.resetItemsSettings();
                _this.updateQuestionChoices();
            }
            if (option.isVisible) {
                _this.updatePopupFocusFirstInputSelector();
                var dropdownMenuOptions = _this.getDropdownMenuOptions();
                _this.question.processOpenDropdownMenu(dropdownMenuOptions);
                _this._popupModel.updateDisplayMode(dropdownMenuOptions.menuType);
                if (!!_this.question.onOpenedCallBack) {
                    _this.question.onOpenedCallBack();
                }
            }
            if (!option.isVisible) {
                _this.onHidePopup();
                if (_this.question.choicesLazyLoadEnabled) {
                    _this.resetItemsSettings();
                }
            }
            _this.question.ariaExpanded = option.isVisible ? "true" : "false";
            _this.question.processPopupVisiblilityChanged(_this.popupModel, option.isVisible);
        });
    };
    DropdownListModel.prototype.setFilterStringToListModel = function (newValue) {
        var _this = this;
        this.listModel.filterString = newValue;
        this.listModel.resetFocusedItem();
        if (this.question.selectedItem && this.question.selectedItem.text.indexOf(newValue) >= 0) {
            this.listModel.focusedItem = this.getAvailableItems().filter(function (item) { return item.id == _this.question.selectedItem.value; })[0];
            if (this.listModel.filterString) {
                this.listModel.actions.map(function (a) { return a.selectedValue = false; });
            }
            return;
        }
        if (!this.listModel.focusedItem || !this.listModel.isItemVisible(this.listModel.focusedItem)) {
            this.listModel.focusFirstVisibleItem();
        }
    };
    DropdownListModel.prototype.setTextWrapEnabled = function (newValue) {
        this.listModel.textWrapEnabled = newValue;
    };
    DropdownListModel.prototype.popupRecalculatePosition = function (isResetHeight) {
        var _this = this;
        setTimeout(function () {
            _this.popupModel.recalculatePosition(isResetHeight);
        }, 1);
    };
    DropdownListModel.prototype.onHidePopup = function () {
        this.resetFilterString();
        this.question.suggestedItem = null;
    };
    DropdownListModel.prototype.getAvailableItems = function () {
        return this.question.visibleChoices;
    };
    DropdownListModel.prototype.setOnTextSearchCallbackForListModel = function (listModel) {
        var _this = this;
        listModel.setOnTextSearchCallback(function (item, textToSearch) {
            if (_this.filteredItems)
                return _this.filteredItems.indexOf(item) >= 0;
            var textInLow = item.text.toLocaleLowerCase();
            textInLow = settings.comparator.normalizeTextCallback(textInLow, "filter");
            var index = textInLow.indexOf(textToSearch.toLocaleLowerCase());
            return _this.question.searchMode == "startsWith" ? index == 0 : index > -1;
        });
    };
    DropdownListModel.prototype.createListModel = function () {
        var _this = this;
        var visibleItems = this.getAvailableItems();
        var _onSelectionChanged = this.onSelectionChanged;
        if (!_onSelectionChanged) {
            _onSelectionChanged = function (item) {
                _this.question.value = item.id;
                if (_this.question.searchEnabled)
                    _this.applyInputString(item);
                _this.popupModel.hide();
            };
        }
        var listOptions = {
            items: visibleItems,
            onSelectionChanged: _onSelectionChanged,
            allowSelection: false,
            locOwner: this.question,
            elementId: this.listElementId
        };
        var res = new list_ListModel(listOptions);
        this.setOnTextSearchCallbackForListModel(res);
        res.renderElements = false;
        res.forceShowFilter = true;
        res.areSameItemsCallback = function (item1, item2) {
            return item1 === item2;
        };
        return res;
    };
    DropdownListModel.prototype.updateAfterListModelCreated = function (model) {
        var _this = this;
        model.isItemSelected = function (action) { return !!action.selected; };
        model.onPropertyChanged.add(function (sender, options) {
            if (options.name == "hasVerticalScroller") {
                _this.hasScroll = options.newValue;
            }
        });
        model.isAllDataLoaded = !this.question.choicesLazyLoadEnabled;
        model.actions.forEach(function (a) { return a.disableTabStop = true; });
    };
    DropdownListModel.prototype.updateCssClasses = function (popupCssClass, listCssClasses) {
        this.popupModel.cssClass = new CssClassBuilder().append(popupCssClass).append(this.popupCssClasses).toString();
        this.listModel.cssClasses = listCssClasses;
    };
    DropdownListModel.prototype.resetFilterString = function () {
        if (!!this.filterString) {
            this.filterString = undefined;
        }
    };
    DropdownListModel.prototype.clear = function () {
        this.inputString = null;
        this.hintString = "";
        this.resetFilterString();
    };
    DropdownListModel.prototype.onSetFilterString = function () {
        var _this = this;
        this.filteredItems = undefined;
        if (!this.filterString && !this.popupModel.isVisible)
            return;
        var options = { question: this.question, choices: this.getAvailableItems(), filter: this.filterString, filteredChoices: undefined };
        this.question.survey.onChoicesSearch.fire(this.question.survey, options);
        this.filteredItems = options.filteredChoices;
        if (!!this.filterString && !this.popupModel.isVisible) {
            this.popupModel.show();
        }
        var updateAfterFilterStringChanged = function () {
            _this.setFilterStringToListModel(_this.filterString);
            _this.popupRecalculatePosition(true);
        };
        if (this.question.choicesLazyLoadEnabled) {
            this.resetItemsSettings();
            this.updateQuestionChoices(updateAfterFilterStringChanged);
        }
        else {
            updateAfterFilterStringChanged();
        }
    };
    Object.defineProperty(DropdownListModel.prototype, "isAllDataLoaded", {
        get: function () {
            return !!this.itemsSettings.totalCount && this.itemsSettings.items.length == this.itemsSettings.totalCount;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DropdownListModel.prototype, "canShowSelectedItem", {
        get: function () {
            return !this.focused || this._markdownMode || !this.searchEnabled;
        },
        enumerable: false,
        configurable: true
    });
    DropdownListModel.prototype.applyInputString = function (item) {
        var hasHtml = item === null || item === void 0 ? void 0 : item.locText.hasHtml;
        if (hasHtml || this.question.inputFieldComponentName) {
            this._markdownMode = true;
            this.inputString = this.cleanHtml(item === null || item === void 0 ? void 0 : item.locText.getHtmlValue());
            this.hintString = "";
        }
        else {
            this.inputString = item === null || item === void 0 ? void 0 : item.title;
            this.hintString = item === null || item === void 0 ? void 0 : item.title;
        }
    };
    DropdownListModel.prototype.cleanHtml = function (html) {
        if (!this.htmlCleanerElement)
            return "";
        this.htmlCleanerElement.innerHTML = html;
        return this.htmlCleanerElement.textContent;
    };
    DropdownListModel.prototype.fixInputCase = function () {
        var hintStringMiddle = this.hintStringMiddle;
        if (hintStringMiddle && this.inputString != hintStringMiddle)
            this.inputString = hintStringMiddle;
    };
    DropdownListModel.prototype.applyHintString = function (item) {
        var hasHtml = item === null || item === void 0 ? void 0 : item.locText.hasHtml;
        if (hasHtml || this.question.inputFieldComponentName) {
            this._markdownMode = true;
            this.hintString = "";
        }
        else {
            this.hintString = item === null || item === void 0 ? void 0 : item.title;
        }
    };
    Object.defineProperty(DropdownListModel.prototype, "inputStringRendered", {
        get: function () {
            return this.inputString || "";
        },
        set: function (val) {
            this.inputString = val;
            this.filterString = val;
            if (!val) {
                this.hintString = "";
            }
            else {
                this.applyHintString(this.listModel.focusedItem || this.question.selectedItem);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DropdownListModel.prototype, "placeholderRendered", {
        get: function () {
            return this.hintString ? "" : this.question.readOnlyText;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DropdownListModel.prototype, "listElementId", {
        get: function () {
            return this.question.inputId + "_list";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DropdownListModel.prototype, "hintStringLC", {
        get: function () {
            var _a;
            return ((_a = this.hintString) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || "";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DropdownListModel.prototype, "inputStringLC", {
        get: function () {
            var _a;
            return ((_a = this.inputString) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || "";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DropdownListModel.prototype, "showHintPrefix", {
        get: function () {
            return !!this.inputString && this.hintStringLC.indexOf(this.inputStringLC) > 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DropdownListModel.prototype, "hintStringPrefix", {
        get: function () {
            if (!this.inputString)
                return null;
            return this.hintString.substring(0, this.hintStringLC.indexOf(this.inputStringLC));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DropdownListModel.prototype, "showHintString", {
        get: function () {
            return !!this.question.searchEnabled && this.hintStringLC && this.hintStringLC.indexOf(this.inputStringLC) >= 0 ||
                !this.question.searchEnabled && this.hintStringLC && this.question.isEmpty();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DropdownListModel.prototype, "hintStringSuffix", {
        get: function () {
            return this.hintString.substring(this.hintStringLC.indexOf(this.inputStringLC) + this.inputStringLC.length);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DropdownListModel.prototype, "hintStringMiddle", {
        get: function () {
            var start = this.hintStringLC.indexOf(this.inputStringLC);
            if (start == -1)
                return null;
            return this.hintString.substring(start, start + this.inputStringLC.length);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DropdownListModel.prototype, "popupModel", {
        get: function () {
            return this._popupModel;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DropdownListModel.prototype, "noTabIndex", {
        get: function () {
            return this.question.isInputReadOnly || this.searchEnabled;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DropdownListModel.prototype, "filterReadOnly", {
        get: function () {
            return this.question.isInputReadOnly || !this.searchEnabled || !this.focused;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DropdownListModel.prototype, "filterStringEnabled", {
        get: function () {
            return !this.question.isInputReadOnly && this.searchEnabled;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DropdownListModel.prototype, "inputMode", {
        get: function () {
            return IsTouch ? "none" : "text";
        },
        enumerable: false,
        configurable: true
    });
    DropdownListModel.prototype.setSearchEnabled = function (newValue) {
        this.listModel.searchEnabled = IsTouch;
        this.listModel.showSearchClearButton = IsTouch;
        this.searchEnabled = newValue;
    };
    DropdownListModel.prototype.setChoicesLazyLoadEnabled = function (newValue) {
        this.listModel.setOnFilterStringChangedCallback(newValue ? this.listModelFilterStringChanged : undefined);
    };
    DropdownListModel.prototype.updateItems = function () {
        this.listModel.setItems(this.getAvailableItems());
    };
    DropdownListModel.prototype.onClick = function (event) {
        if (this.question.readOnly || this.question.isDesignMode || this.question.isPreviewStyle || this.question.isReadOnlyAttr)
            return;
        this._popupModel.toggleVisibility();
        this.focusItemOnClickAndPopup();
        this.question.focusInputElement(false);
    };
    DropdownListModel.prototype.chevronPointerDown = function (event) {
        if (this._popupModel.isVisible) {
            event.preventDefault();
        }
    };
    DropdownListModel.prototype.onPropertyChangedHandler = function (sender, options) {
        if (options.name == "value") {
            this.showInputFieldComponent = this.question.showInputFieldComponent;
        }
        if (options.name == "textWrapEnabled") {
            this.setTextWrapEnabled(options.newValue);
        }
    };
    DropdownListModel.prototype.focusItemOnClickAndPopup = function () {
        if (this._popupModel.isVisible && this.question.value)
            this.changeSelectionWithKeyboard(false);
    };
    DropdownListModel.prototype.onClear = function (event) {
        this.question.clearValue(true);
        this._popupModel.hide();
        if (event) {
            event.preventDefault();
            event.stopPropagation();
        }
    };
    DropdownListModel.prototype.getSelectedAction = function () {
        return this.question.selectedItem || null;
    };
    DropdownListModel.prototype.changeSelectionWithKeyboard = function (reverse) {
        var _a;
        var focusedItem = this.listModel.focusedItem;
        if (!focusedItem && this.question.selectedItem) {
            if (itemvalue_ItemValue.getItemByValue(this.question.visibleChoices, this.question.value)) {
                this.listModel.focusedItem = this.question.selectedItem;
            }
        }
        else {
            if (reverse) {
                this.listModel.focusPrevVisibleItem();
            }
            else {
                this.listModel.focusNextVisibleItem();
            }
        }
        this.beforeScrollToFocusedItem(focusedItem);
        this.scrollToFocusedItem();
        this.afterScrollToFocusedItem();
        this.ariaActivedescendant = (_a = this.listModel.focusedItem) === null || _a === void 0 ? void 0 : _a.elementId;
    };
    DropdownListModel.prototype.beforeScrollToFocusedItem = function (focusedItem) {
        if (this.question.value && focusedItem) {
            focusedItem.selectedValue = false;
            this.listModel.focusedItem.selectedValue = !this.listModel.filterString;
            this.question.suggestedItem = this.listModel.focusedItem;
        }
    };
    DropdownListModel.prototype.afterScrollToFocusedItem = function () {
        var _a;
        if (this.question.value && !this.listModel.filterString && this.question.searchEnabled) {
            this.applyInputString(this.listModel.focusedItem || this.question.selectedItem);
        }
        else {
            this.applyHintString(this.listModel.focusedItem || this.question.selectedItem);
        }
        this.fixInputCase();
        this.ariaActivedescendant = (_a = this.listModel.focusedItem) === null || _a === void 0 ? void 0 : _a.elementId;
    };
    DropdownListModel.prototype.keyHandler = function (event) {
        var char = event.which || event.keyCode;
        if (this.popupModel.isVisible && event.keyCode === 38) {
            this.changeSelectionWithKeyboard(true);
            event.preventDefault();
            event.stopPropagation();
        }
        else if (event.keyCode === 40) {
            this.popupModel.show();
            this.changeSelectionWithKeyboard(false);
            event.preventDefault();
            event.stopPropagation();
        }
        if (event.keyCode === 9) {
            this.popupModel.hide();
        }
        else if (!this.popupModel.isVisible && (event.keyCode === 13 || event.keyCode === 32)) {
            if (event.keyCode === 32) {
                this.popupModel.show();
                this.changeSelectionWithKeyboard(false);
            }
            if (event.keyCode === 13) {
                this.question.survey.questionEditFinishCallback(this.question, event);
            }
            event.preventDefault();
            event.stopPropagation();
        }
        else if (this.popupModel.isVisible && (event.keyCode === 13 || event.keyCode === 32 && (!this.question.searchEnabled || !this.inputString))) {
            if (event.keyCode === 13 && this.question.searchEnabled && !this.inputString && this.question instanceof question_dropdown_QuestionDropdownModel && !this._markdownMode && this.question.value) {
                this._popupModel.hide();
                this.onClear(event);
            }
            else {
                this.listModel.selectFocusedItem();
                this.onFocus(event);
            }
            event.preventDefault();
            event.stopPropagation();
        }
        else if (char === 46 || char === 8) {
            if (!this.searchEnabled) {
                this.onClear(event);
            }
        }
        else if (event.keyCode === 27) {
            this._popupModel.hide();
            this.hintString = "";
            this.onEscape();
        }
        else {
            if (event.keyCode === 38 || event.keyCode === 40 || event.keyCode === 32 && !this.question.searchEnabled) {
                event.preventDefault();
                event.stopPropagation();
            }
            if (event.keyCode === 32 && this.question.searchEnabled) {
                return;
            }
            doKey2ClickUp(event, { processEsc: false, disableTabStop: this.question.isInputReadOnly });
        }
    };
    DropdownListModel.prototype.onEscape = function () {
        if (this.question.searchEnabled)
            this.applyInputString(this.question.selectedItem);
    };
    DropdownListModel.prototype.onScroll = function (event) {
        var target = event.target;
        if ((target.scrollHeight - (target.scrollTop + target.offsetHeight)) <= this.loadingItemHeight) {
            this.updateQuestionChoices();
        }
    };
    DropdownListModel.prototype.onBlur = function (event) {
        this.focused = false;
        if (this.popupModel.isVisible && IsTouch) {
            this._popupModel.show();
            return;
        }
        doKey2ClickBlur(event);
        this._popupModel.hide();
        this.resetFilterString();
        this.inputString = null;
        this.hintString = "";
        event.stopPropagation();
    };
    DropdownListModel.prototype.onFocus = function (event) {
        this.focused = true;
        this.setInputStringFromSelectedItem(this.question.selectedItem);
    };
    DropdownListModel.prototype.setInputStringFromSelectedItem = function (newValue) {
        if (!this.focused)
            return;
        if (this.question.searchEnabled && !!newValue) {
            this.applyInputString(newValue);
        }
        else {
            this.inputString = null;
        }
    };
    DropdownListModel.prototype.dispose = function () {
        _super.prototype.dispose.call(this);
        this.question && this.question.onPropertyChanged.remove(this.questionPropertyChangedHandler);
        this.questionPropertyChangedHandler = undefined;
        if (!!this.listModel) {
            this.listModel.dispose();
        }
        if (!!this.popupModel) {
            this.popupModel.dispose();
        }
    };
    DropdownListModel.prototype.scrollToFocusedItem = function () {
        this.listModel.scrollToFocusedItem();
    };
    dropdownListModel_decorate([
        jsonobject_property({ defaultValue: false })
    ], DropdownListModel.prototype, "focused", void 0);
    dropdownListModel_decorate([
        jsonobject_property({ defaultValue: true })
    ], DropdownListModel.prototype, "searchEnabled", void 0);
    dropdownListModel_decorate([
        jsonobject_property({
            defaultValue: "",
            onSet: function (_, target) {
                target.onSetFilterString();
            }
        })
    ], DropdownListModel.prototype, "filterString", void 0);
    dropdownListModel_decorate([
        jsonobject_property({
            defaultValue: "",
            onSet: function (newValue, target) {
                target.question.inputHasValue = !!newValue;
            }
        })
    ], DropdownListModel.prototype, "inputString", void 0);
    dropdownListModel_decorate([
        jsonobject_property({})
    ], DropdownListModel.prototype, "showInputFieldComponent", void 0);
    dropdownListModel_decorate([
        jsonobject_property()
    ], DropdownListModel.prototype, "ariaActivedescendant", void 0);
    dropdownListModel_decorate([
        jsonobject_property({
            defaultValue: false,
            onSet: function (newVal, target) {
                if (newVal) {
                    target.listModel.addScrollEventListener(function (e) { target.onScroll(e); });
                }
                else {
                    target.listModel.removeScrollEventListener();
                }
            }
        })
    ], DropdownListModel.prototype, "hasScroll", void 0);
    dropdownListModel_decorate([
        jsonobject_property({ defaultValue: "" })
    ], DropdownListModel.prototype, "hintString", void 0);
    return DropdownListModel;
}(base_Base));


// CONCATENATED MODULE: ./packages/survey-core/src/question_dropdown.ts
var question_dropdown_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var question_dropdown_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};






/**
 * A class that describes the Dropdown question type.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/questiontype-dropdown/ (linkStyle))
 */
var question_dropdown_QuestionDropdownModel = /** @class */ (function (_super) {
    question_dropdown_extends(QuestionDropdownModel, _super);
    function QuestionDropdownModel(name) {
        var _this = _super.call(this, name) || this;
        _this.lastSelectedItemValue = null;
        _this.minMaxChoices = [];
        _this.onOpened = _this.addEvent();
        _this.createLocalizableString("placeholder", _this, false, true);
        _this.createLocalizableString("clearCaption", _this, false, true);
        _this.registerPropertyChangedHandlers(["choicesMin", "choicesMax", "choicesStep"], function () {
            _this.onVisibleChoicesChanged();
        });
        _this.registerPropertyChangedHandlers(["value", "renderAs", "showOtherItem", "otherText", "placeholder", "choices", "visibleChoices"], function () {
            _this.updateReadOnlyText();
        });
        _this.updateReadOnlyText();
        return _this;
    }
    QuestionDropdownModel.prototype.updateReadOnlyText = function () {
        var result = !!this.selectedItem ? "" : this.placeholder;
        if (this.renderAs == "select") {
            if (this.isOtherSelected) {
                result = this.otherText;
            }
            else if (this.isNoneSelected) {
                result = this.noneText;
            }
            else if (!!this.selectedItem) {
                result = this.selectedItemText;
            }
        }
        this.readOnlyText = result;
    };
    QuestionDropdownModel.prototype.locStrsChanged = function () {
        _super.prototype.locStrsChanged.call(this);
        this.updateReadOnlyText();
    };
    Object.defineProperty(QuestionDropdownModel.prototype, "showOptionsCaption", {
        get: function () {
            return this.allowClear;
        },
        set: function (val) {
            this.allowClear = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionDropdownModel.prototype, "showClearButton", {
        get: function () {
            return this.allowClear && !this.isEmpty() && (!this.isDesignMode || settings.supportCreatorV2);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionDropdownModel.prototype, "optionsCaption", {
        get: function () {
            return this.placeholder;
        },
        set: function (val) {
            this.placeholder = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionDropdownModel.prototype, "placeholder", {
        /**
         * A placeholder for the input field.
         */
        get: function () {
            return this.getLocalizableStringText("placeholder");
        },
        set: function (val) {
            this.setLocalizableStringText("placeholder", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionDropdownModel.prototype, "locPlaceholder", {
        get: function () {
            return this.getLocalizableString("placeholder");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionDropdownModel.prototype, "clearCaption", {
        get: function () {
            return this.getLocalizableStringText("clearCaption");
        },
        set: function (value) {
            this.setLocalizableStringText("clearCaption", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionDropdownModel.prototype, "locClearCaption", {
        get: function () {
            return this.getLocalizableString("clearCaption");
        },
        enumerable: false,
        configurable: true
    });
    QuestionDropdownModel.prototype.getType = function () {
        return "dropdown";
    };
    Object.defineProperty(QuestionDropdownModel.prototype, "ariaRole", {
        get: function () {
            return "combobox";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionDropdownModel.prototype, "selectedItem", {
        get: function () { return this.getSingleSelectedItem(); },
        enumerable: false,
        configurable: true
    });
    QuestionDropdownModel.prototype.onGetSingleSelectedItem = function (selectedItemByValue) {
        if (!!selectedItemByValue) {
            this.lastSelectedItemValue = selectedItemByValue;
        }
    };
    QuestionDropdownModel.prototype.supportGoNextPageAutomatic = function () {
        return !this.isOtherSelected;
    };
    QuestionDropdownModel.prototype.getChoices = function () {
        var items = _super.prototype.getChoices.call(this);
        if (this.choicesMax <= this.choicesMin)
            return items;
        var res = [];
        for (var i = 0; i < items.length; i++) {
            res.push(items[i]);
        }
        if (this.minMaxChoices.length === 0 ||
            this.minMaxChoices.length !==
                (this.choicesMax - this.choicesMin) / this.choicesStep + 1) {
            this.minMaxChoices = [];
            for (var i = this.choicesMin; i <= this.choicesMax; i += this.choicesStep) {
                this.minMaxChoices.push(this.createItemValue(i));
            }
        }
        res = res.concat(this.minMaxChoices);
        return res;
    };
    Object.defineProperty(QuestionDropdownModel.prototype, "choicesMin", {
        /**
         * Use the `choicesMin`, `choicesMax`, and `choicesStep` properties to generate choice items automatically. For example, the configuration below generates three choice items: [10, 20, 30].
         *
         * ```js
         * "choicesMin": 10,
         * "choicesMax": 30
         * "choicesStep": 10
         * ```
         * @see choicesMax
         * @see choicesStep
         */
        get: function () {
            return this.getPropertyValue("choicesMin");
        },
        set: function (val) {
            this.setPropertyValue("choicesMin", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionDropdownModel.prototype, "choicesMax", {
        /**
         * Use the `choicesMin`, `choicesMax`, and `choicesStep` properties to generate choice items automatically. For example, the configuration below generates three choice items: [10, 20, 30].
         *
         * ```js
         * "choicesMin": 10,
         * "choicesMax": 30
         * "choicesStep": 10
         * ```
         * @see choicesMin
         * @see choicesStep
         */
        get: function () {
            return this.getPropertyValue("choicesMax");
        },
        set: function (val) {
            this.setPropertyValue("choicesMax", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionDropdownModel.prototype, "choicesStep", {
        /**
         * Use the `choicesMin`, `choicesMax`, and `choicesStep` properties to generate choice items automatically. For example, the configuration below generates three choice items: [10, 20, 30].
         *
         * ```js
         * "choicesMin": 10,
         * "choicesMax": 30
         * "choicesStep": 10
         * ```
         *
         * The default value of the `choicesStep` property is 1.
         * @see choicesMin
         * @see choicesMax
         */
        get: function () {
            return this.getPropertyValue("choicesStep");
        },
        set: function (val) {
            if (val < 1)
                val = 1;
            this.setPropertyValue("choicesStep", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionDropdownModel.prototype, "autocomplete", {
        get: function () {
            return this.getPropertyValue("autocomplete", "");
        },
        set: function (val) {
            this.setPropertyValue("autocomplete", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionDropdownModel.prototype.getControlClass = function () {
        return new CssClassBuilder()
            .append(this.cssClasses.control)
            .append(this.cssClasses.controlEmpty, this.isEmpty())
            .append(this.cssClasses.onError, this.hasCssError())
            .append(this.cssClasses.controlDisabled, this.isDisabledStyle)
            .append(this.cssClasses.controlReadOnly, this.isReadOnlyStyle)
            .append(this.cssClasses.controlPreview, this.isPreviewStyle)
            .append(this.cssClasses.controlInputFieldComponent, !!this.inputFieldComponentName)
            .toString();
    };
    Object.defineProperty(QuestionDropdownModel.prototype, "selectedItemLocText", {
        get: function () {
            var item = this.suggestedItem || this.selectedItem;
            return item === null || item === void 0 ? void 0 : item.locText;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionDropdownModel.prototype, "inputFieldComponentName", {
        get: function () {
            return this.inputFieldComponent || this.itemComponent;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionDropdownModel.prototype, "showSelectedItemLocText", {
        get: function () {
            return !this.inputHasValue && !this.inputFieldComponentName && !!this.selectedItemLocText && this.dropdownListModel.canShowSelectedItem;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionDropdownModel.prototype, "showInputFieldComponent", {
        get: function () {
            return !this.inputHasValue && !!this.inputFieldComponentName && !this.isEmpty();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionDropdownModel.prototype, "selectedItemText", {
        get: function () {
            var item = this.selectedItem;
            return !!item ? item.text : "";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionDropdownModel.prototype, "dropdownListModel", {
        get: function () {
            if (this.renderAs !== "select" && !this.dropdownListModelValue) {
                this.dropdownListModelValue = new dropdownListModel_DropdownListModel(this);
            }
            return this.dropdownListModelValue;
        },
        set: function (val) {
            this.dropdownListModelValue = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionDropdownModel.prototype, "popupModel", {
        get: function () {
            var _a;
            return (_a = this.dropdownListModel) === null || _a === void 0 ? void 0 : _a.popupModel;
        },
        enumerable: false,
        configurable: true
    });
    QuestionDropdownModel.prototype.onOpenedCallBack = function () {
        this.onOpened.fire(this, { question: this, choices: this.choices });
    };
    QuestionDropdownModel.prototype.onSelectedItemValuesChangedHandler = function (newValue) {
        var _a;
        (_a = this.dropdownListModel) === null || _a === void 0 ? void 0 : _a.setInputStringFromSelectedItem(newValue);
        _super.prototype.onSelectedItemValuesChangedHandler.call(this, newValue);
    };
    QuestionDropdownModel.prototype.hasUnknownValue = function (val, includeOther, isFilteredChoices, checkEmptyValue) {
        if (this.choicesLazyLoadEnabled) {
            return false;
        }
        return _super.prototype.hasUnknownValue.call(this, val, includeOther, isFilteredChoices, checkEmptyValue);
    };
    QuestionDropdownModel.prototype.needConvertRenderedOtherToDataValue = function () {
        var _a;
        var val = (_a = this.otherValue) === null || _a === void 0 ? void 0 : _a.trim();
        if (!val)
            return false;
        return _super.prototype.hasUnknownValue.call(this, val, true, false);
    };
    QuestionDropdownModel.prototype.getItemIfChoicesNotContainThisValue = function (value, text) {
        if (this.choicesLazyLoadEnabled) {
            return this.createItemValue(value, text);
        }
        else {
            return _super.prototype.getItemIfChoicesNotContainThisValue.call(this, value, text);
        }
    };
    QuestionDropdownModel.prototype.onVisibleChoicesChanged = function () {
        _super.prototype.onVisibleChoicesChanged.call(this);
        if (!this.isLoadingFromJson && this.popupModel) {
            this.dropdownListModel.updateItems();
        }
    };
    QuestionDropdownModel.prototype.getFirstInputElementId = function () {
        return this.inputId + (this.searchEnabled ? "_0" : "");
    };
    QuestionDropdownModel.prototype.getInputId = function () {
        return this.inputId + "_0";
    };
    QuestionDropdownModel.prototype.clearValue = function (keepComment) {
        var _a;
        _super.prototype.clearValue.call(this, keepComment);
        this.lastSelectedItemValue = null;
        (_a = this.dropdownListModel) === null || _a === void 0 ? void 0 : _a.clear();
    };
    QuestionDropdownModel.prototype.afterRenderCore = function (el) {
        _super.prototype.afterRenderCore.call(this, el);
        if (!!this.dropdownListModelValue) {
            this.dropdownListModelValue.clear();
        }
    };
    QuestionDropdownModel.prototype.onClick = function (e) {
        !!this.onOpenedCallBack && this.onOpenedCallBack();
    };
    QuestionDropdownModel.prototype.onKeyUp = function (event) {
        var char = event.which || event.keyCode;
        if (char === 46) {
            this.clearValue(true);
            event.preventDefault();
            event.stopPropagation();
        }
    };
    QuestionDropdownModel.prototype.supportEmptyValidation = function () { return true; };
    QuestionDropdownModel.prototype.onBlurCore = function (event) {
        var _a;
        (_a = this.dropdownListModel) === null || _a === void 0 ? void 0 : _a.onBlur(event);
        _super.prototype.onBlurCore.call(this, event);
    };
    QuestionDropdownModel.prototype.onFocusCore = function (event) {
        var _a;
        (_a = this.dropdownListModel) === null || _a === void 0 ? void 0 : _a.onFocus(event);
        _super.prototype.onFocusCore.call(this, event);
    };
    QuestionDropdownModel.prototype.dispose = function () {
        _super.prototype.dispose.call(this);
        if (!!this.dropdownListModelValue) {
            this.dropdownListModelValue.dispose();
        }
    };
    question_dropdown_decorate([
        jsonobject_property()
    ], QuestionDropdownModel.prototype, "allowClear", void 0);
    question_dropdown_decorate([
        jsonobject_property({
            onSet: function (newValue, target) {
                if (!!target.dropdownListModel) {
                    target.dropdownListModel.setSearchEnabled(newValue);
                }
            }
        })
    ], QuestionDropdownModel.prototype, "searchEnabled", void 0);
    question_dropdown_decorate([
        jsonobject_property()
    ], QuestionDropdownModel.prototype, "searchMode", void 0);
    question_dropdown_decorate([
        jsonobject_property()
    ], QuestionDropdownModel.prototype, "textWrapEnabled", void 0);
    question_dropdown_decorate([
        jsonobject_property({ defaultValue: false })
    ], QuestionDropdownModel.prototype, "inputHasValue", void 0);
    question_dropdown_decorate([
        jsonobject_property({ defaultValue: "" })
    ], QuestionDropdownModel.prototype, "readOnlyText", void 0);
    question_dropdown_decorate([
        jsonobject_property({
            onSet: function (newValue, target) {
                if (!!target.dropdownListModel) {
                    target.dropdownListModel.setChoicesLazyLoadEnabled(newValue);
                }
            }
        })
    ], QuestionDropdownModel.prototype, "choicesLazyLoadEnabled", void 0);
    question_dropdown_decorate([
        jsonobject_property()
    ], QuestionDropdownModel.prototype, "choicesLazyLoadPageSize", void 0);
    question_dropdown_decorate([
        jsonobject_property()
    ], QuestionDropdownModel.prototype, "suggestedItem", void 0);
    return QuestionDropdownModel;
}(question_baseselect_QuestionSelectBase));

Serializer.addClass("dropdown", [
    { name: "placeholder", alternativeName: "optionsCaption", serializationProperty: "locPlaceholder" },
    { name: "allowClear:boolean", alternativeName: "showOptionsCaption", default: true },
    { name: "choicesMin:number", default: 0 },
    { name: "choicesMax:number", default: 0 },
    { name: "choicesStep:number", default: 1, minValue: 1 },
    { name: "autocomplete", alternativeName: "autoComplete", choices: settings.questions.dataList, },
    { name: "textWrapEnabled:boolean", default: true },
    { name: "renderAs", default: "default", visible: false },
    { name: "searchEnabled:boolean", default: true, visible: false },
    { name: "searchMode", default: "contains", choices: ["contains", "startsWith"], },
    { name: "choicesLazyLoadEnabled:boolean", default: false, visible: false },
    { name: "choicesLazyLoadPageSize:number", default: 25, visible: false },
    { name: "inputFieldComponent", visible: false },
    { name: "itemComponent", visible: false, default: "" }
], function () {
    return new question_dropdown_QuestionDropdownModel("");
}, "selectbase");
questionfactory_QuestionFactory.Instance.registerQuestion("dropdown", function (name) {
    var q = new question_dropdown_QuestionDropdownModel(name);
    q.choices = questionfactory_QuestionFactory.DefaultChoices;
    return q;
});

// CONCATENATED MODULE: ./packages/survey-core/src/question_matrix.ts
var question_matrix_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();












var question_matrix_MatrixRowModel = /** @class */ (function (_super) {
    question_matrix_extends(MatrixRowModel, _super);
    function MatrixRowModel(item, fullName, data, value) {
        var _this = _super.call(this) || this;
        _this.item = item;
        _this.fullName = fullName;
        _this.data = data;
        _this.setValueDirectly(value);
        _this.cellClick = function (column) {
            _this.value = column.value;
        };
        _this.registerPropertyChangedHandlers(["value"], function () {
            if (_this.data)
                _this.data.onMatrixRowChanged(_this);
        });
        if (_this.data && _this.data.hasErrorInRow(_this)) {
            _this.hasError = true;
        }
        return _this;
    }
    Object.defineProperty(MatrixRowModel.prototype, "name", {
        get: function () {
            return this.item.value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixRowModel.prototype, "text", {
        get: function () {
            return this.item.text;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixRowModel.prototype, "locText", {
        get: function () {
            return this.item.locText;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixRowModel.prototype, "value", {
        get: function () {
            return this.getPropertyValue("value");
        },
        set: function (val) {
            if (!this.isReadOnly) {
                this.setValueDirectly(this.data.getCorrectedRowValue(val));
            }
        },
        enumerable: false,
        configurable: true
    });
    MatrixRowModel.prototype.setValueDirectly = function (val) {
        this.setPropertyValue("value", val);
    };
    Object.defineProperty(MatrixRowModel.prototype, "isReadOnly", {
        get: function () { return !this.item.enabled || this.data.isInputReadOnly; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixRowModel.prototype, "isReadOnlyAttr", {
        get: function () { return this.data.isReadOnlyAttr; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixRowModel.prototype, "isDisabledAttr", {
        get: function () { return !this.item.enabled || this.data.isDisabledAttr; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixRowModel.prototype, "rowTextClasses", {
        get: function () {
            return new CssClassBuilder().append(this.data.cssClasses.rowTextCell).toString();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixRowModel.prototype, "hasError", {
        get: function () {
            return this.getPropertyValue("hasError", false);
        },
        set: function (val) {
            this.setPropertyValue("hasError", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixRowModel.prototype, "rowClasses", {
        get: function () {
            var cssClasses = this.data.cssClasses;
            return new CssClassBuilder().append(cssClasses.row)
                .append(cssClasses.rowError, this.hasError)
                .append(cssClasses.rowReadOnly, this.isReadOnly)
                .append(cssClasses.rowDisabled, this.data.isDisabledStyle)
                .toString();
        },
        enumerable: false,
        configurable: true
    });
    return MatrixRowModel;
}(base_Base));

var question_matrix_MatrixCells = /** @class */ (function () {
    function MatrixCells(cellsOwner) {
        this.cellsOwner = cellsOwner;
        this.values = {};
    }
    Object.defineProperty(MatrixCells.prototype, "isEmpty", {
        get: function () {
            return Object.keys(this.values).length == 0;
        },
        enumerable: false,
        configurable: true
    });
    MatrixCells.prototype.valuesChanged = function () {
        if (!!this.onValuesChanged) {
            this.onValuesChanged();
        }
    };
    MatrixCells.prototype.setCellText = function (row, column, val) {
        row = this.getCellRowColumnValue(row, this.rows);
        column = this.getCellRowColumnValue(column, this.columns);
        if (!row || !column)
            return;
        if (val) {
            if (!this.values[row])
                this.values[row] = {};
            if (!this.values[row][column])
                this.values[row][column] = this.createString();
            this.values[row][column].text = val;
        }
        else {
            if (this.values[row] && this.values[row][column]) {
                var loc = this.values[row][column];
                loc.text = "";
                if (loc.isEmpty) {
                    delete this.values[row][column];
                    if (Object.keys(this.values[row]).length == 0) {
                        delete this.values[row];
                    }
                }
            }
        }
        this.valuesChanged();
    };
    MatrixCells.prototype.setDefaultCellText = function (column, val) {
        this.setCellText(settings.matrix.defaultRowName, column, val);
    };
    MatrixCells.prototype.getCellLocText = function (row, column) {
        row = this.getCellRowColumnValue(row, this.rows);
        column = this.getCellRowColumnValue(column, this.columns);
        if (!row || !column)
            return null;
        if (!this.values[row])
            return null;
        if (!this.values[row][column])
            return null;
        return this.values[row][column];
    };
    MatrixCells.prototype.getDefaultCellLocText = function (column, val) {
        return this.getCellLocText(settings.matrix.defaultRowName, column);
    };
    MatrixCells.prototype.getCellDisplayLocText = function (row, column) {
        var cellText = this.getCellLocText(row, column);
        if (cellText && !cellText.isEmpty)
            return cellText;
        cellText = this.getCellLocText(settings.matrix.defaultRowName, column);
        if (cellText && !cellText.isEmpty)
            return cellText;
        if (typeof column == "number") {
            column =
                column >= 0 && column < this.columns.length
                    ? this.columns[column]
                    : null;
        }
        if (column && column.locText)
            return column.locText;
        return null;
    };
    MatrixCells.prototype.getCellText = function (row, column) {
        var loc = this.getCellLocText(row, column);
        return loc ? loc.calculatedText : null;
    };
    MatrixCells.prototype.getDefaultCellText = function (column) {
        var loc = this.getCellLocText(settings.matrix.defaultRowName, column);
        return loc ? loc.calculatedText : null;
    };
    MatrixCells.prototype.getCellDisplayText = function (row, column) {
        var loc = this.getCellDisplayLocText(row, column);
        return loc ? loc.calculatedText : null;
    };
    Object.defineProperty(MatrixCells.prototype, "rows", {
        get: function () {
            return this.cellsOwner ? this.cellsOwner.getRows() : [];
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MatrixCells.prototype, "columns", {
        get: function () {
            return this.cellsOwner ? this.cellsOwner.getColumns() : [];
        },
        enumerable: false,
        configurable: true
    });
    MatrixCells.prototype.getCellRowColumnValue = function (val, values) {
        if (val === null || val === undefined)
            return null;
        if (typeof val == "number") {
            if (val < 0 || val >= values.length)
                return null;
            val = values[val].value;
        }
        if (val.value)
            return val.value;
        return val;
    };
    MatrixCells.prototype.getJson = function () {
        if (this.isEmpty)
            return null;
        var res = {};
        for (var row in this.values) {
            var resRow = {};
            var rowValues = this.values[row];
            for (var col in rowValues) {
                resRow[col] = rowValues[col].getJson();
            }
            res[row] = resRow;
        }
        return res;
    };
    MatrixCells.prototype.setJson = function (value) {
        this.values = {};
        if (!!value) {
            for (var row in value) {
                if (row == "pos")
                    continue;
                var rowValues = value[row];
                this.values[row] = {};
                for (var col in rowValues) {
                    if (col == "pos")
                        continue;
                    var loc = this.createString();
                    loc.setJson(rowValues[col]);
                    this.values[row][col] = loc;
                }
            }
        }
        this.valuesChanged();
    };
    MatrixCells.prototype.locStrsChanged = function () {
        if (this.isEmpty)
            return;
        for (var row in this.values) {
            var rowValues = this.values[row];
            for (var col in rowValues) {
                rowValues[col].strChanged();
            }
        }
    };
    MatrixCells.prototype.createString = function () {
        return new localizablestring_LocalizableString(this.cellsOwner, true);
    };
    return MatrixCells;
}());

/**
  * A class that describes the Single-Select Matrix question type.
  *
  * [View Demo](https://surveyjs.io/form-library/examples/single-selection-matrix-table-question/ (linkStyle))
  */
var question_matrix_QuestionMatrixModel = /** @class */ (function (_super) {
    question_matrix_extends(QuestionMatrixModel, _super);
    function QuestionMatrixModel(name) {
        var _this = _super.call(this, name) || this;
        _this.isRowChanging = false;
        _this.emptyLocalizableString = new localizablestring_LocalizableString(_this);
        _this.cellsValue = new question_matrix_MatrixCells(_this);
        _this.cellsValue.onValuesChanged = function () {
            _this.updateHasCellText();
            _this.propertyValueChanged("cells", _this.cells, _this.cells);
        };
        _this.registerPropertyChangedHandlers(["columns"], function () {
            _this.onColumnsChanged();
        });
        _this.registerPropertyChangedHandlers(["rows"], function () {
            if (!_this.filterItems()) {
                _this.onRowsChanged();
            }
        });
        _this.registerPropertyChangedHandlers(["hideIfRowsEmpty"], function () {
            _this.updateVisibilityBasedOnRows();
        });
        return _this;
    }
    QuestionMatrixModel.prototype.getType = function () {
        return "matrix";
    };
    Object.defineProperty(QuestionMatrixModel.prototype, "cellComponent", {
        /**
         * The name of a component used to render cells.
         */
        get: function () {
            return this.getPropertyValue("cellComponent");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixModel.prototype, "itemComponent", {
        set: function (value) {
            this.setPropertyValue("cellComponent", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixModel.prototype, "hasSingleInput", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixModel.prototype, "isAllRowRequired", {
        /**
         * Specifies whether each row requires an answer. If a respondent skips a row, the question displays a validation error.
         * @see isRequired
         * @see eachRowUnique
         * @see validators
         */
        get: function () {
            return this.getPropertyValue("isAllRowRequired");
        },
        set: function (val) {
            this.setPropertyValue("isAllRowRequired", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixModel.prototype, "eachRowUnique", {
        /**
         * Specifies whether answers in all rows should be unique. If any answers duplicate, the question displays a validation error.
         * @see isAllRowRequired
         * @see validators
         */
        get: function () {
            return this.getPropertyValue("eachRowUnique");
        },
        set: function (val) {
            this.setPropertyValue("eachRowUnique", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixModel.prototype, "hasRows", {
        get: function () {
            return this.rows.length > 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixModel.prototype, "rowsOrder", {
        /**
         * Specifies a sort order for matrix rows.
         *
         * Possible values:
         *
         * - `"initial"` (default) - Preserves the original order of the `rows` array.
         * - `"random"` - Arranges matrix rows in random order each time the question is displayed.
         * @see rows
         */
        get: function () {
            return this.getPropertyValue("rowsOrder");
        },
        set: function (val) {
            val = val.toLowerCase();
            if (val == this.rowsOrder)
                return;
            this.setPropertyValue("rowsOrder", val);
            this.onRowsChanged();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixModel.prototype, "hideIfRowsEmpty", {
        /**
         * Specifies whether to hide the question when the matrix has no visible rows.
         * @see rowsVisibleIf
         */
        get: function () {
            return this.getPropertyValue("hideIfRowsEmpty");
        },
        set: function (val) {
            this.setPropertyValue("hideIfRowsEmpty", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixModel.prototype.getRows = function () {
        return this.rows;
    };
    QuestionMatrixModel.prototype.getColumns = function () {
        return this.visibleColumns;
    };
    QuestionMatrixModel.prototype.addColumn = function (value, text) {
        var col = new itemvalue_ItemValue(value, text);
        this.columns.push(col);
        return col;
    };
    QuestionMatrixModel.prototype.getItemClass = function (row, column) {
        var isChecked = row.value == column.value;
        var isDisabled = this.isReadOnly;
        var allowHover = !isChecked && !isDisabled;
        var hasCellText = this.hasCellText;
        var css = this.cssClasses;
        return new CssClassBuilder()
            .append(css.cell, hasCellText)
            .append(hasCellText ? css.cellText : css.label)
            .append(css.itemOnError, !hasCellText && (this.isAllRowRequired || this.eachRowUnique ? row.hasError : this.hasCssError()))
            .append(hasCellText ? css.cellTextSelected : css.itemChecked, isChecked)
            .append(hasCellText ? css.cellTextDisabled : css.itemDisabled, this.isDisabledStyle)
            .append(hasCellText ? css.cellTextReadOnly : css.itemReadOnly, this.isReadOnlyStyle)
            .append(hasCellText ? css.cellTextPreview : css.itemPreview, this.isPreviewStyle)
            .append(css.itemHover, allowHover && !hasCellText)
            .toString();
    };
    Object.defineProperty(QuestionMatrixModel.prototype, "itemSvgIcon", {
        get: function () {
            if (this.isPreviewStyle && this.cssClasses.itemPreviewSvgIconId) {
                return this.cssClasses.itemPreviewSvgIconId;
            }
            return this.cssClasses.itemSvgIconId;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixModel.prototype.locStrsChanged = function () {
        _super.prototype.locStrsChanged.call(this);
        this.cells.locStrsChanged();
    };
    QuestionMatrixModel.prototype.getQuizQuestionCount = function () {
        var res = 0;
        for (var i = 0; i < this.rows.length; i++) {
            if (!this.isValueEmpty(this.correctAnswer[this.rows[i].value]))
                res++;
        }
        return res;
    };
    QuestionMatrixModel.prototype.getCorrectAnswerCount = function () {
        var res = 0;
        var value = this.value;
        for (var i = 0; i < this.rows.length; i++) {
            var row = this.rows[i].value;
            if (!this.isValueEmpty(value[row]) &&
                this.isTwoValueEquals(this.correctAnswer[row], value[row]))
                res++;
        }
        return res;
    };
    QuestionMatrixModel.prototype.runItemsCondition = function (values, properties) {
        itemvalue_ItemValue.runEnabledConditionsForItems(this.rows, undefined, values, properties);
        return _super.prototype.runItemsCondition.call(this, values, properties);
    };
    QuestionMatrixModel.prototype.getVisibleRows = function () {
        var result = new Array();
        var val = this.value;
        if (!val)
            val = {};
        var rows = !!this.filteredRows ? this.filteredRows : this.rows;
        for (var i = 0; i < rows.length; i++) {
            var row = rows[i];
            if (this.isValueEmpty(row.value))
                continue;
            result.push(this.createMatrixRow(row, this.id + "_" + row.value.toString().replace(/\s/g, "_"), val[row.value]));
        }
        this.generatedVisibleRows = result;
        return result;
    };
    QuestionMatrixModel.prototype.sortVisibleRows = function (array) {
        if (!!this.survey && this.survey.isDesignMode)
            return array;
        var order = this.rowsOrder.toLowerCase();
        if (order === "random")
            return helpers_Helpers.randomizeArray(array);
        return array;
    };
    QuestionMatrixModel.prototype.endLoadingFromJson = function () {
        _super.prototype.endLoadingFromJson.call(this);
        this.rows = this.sortVisibleRows(this.rows);
    };
    QuestionMatrixModel.prototype.isNewValueCorrect = function (val) {
        return helpers_Helpers.isValueObject(val, true);
    };
    QuestionMatrixModel.prototype.processRowsOnSet = function (newRows) {
        return this.sortVisibleRows(newRows);
    };
    Object.defineProperty(QuestionMatrixModel.prototype, "visibleRows", {
        get: function () {
            return this.getVisibleRows();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixModel.prototype, "cells", {
        /**
         * An array of matrix cells. Use this array to get or set cell values.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/questiontype-matrix-rubric/ (linkStyle))
         */
        get: function () {
            return this.cellsValue;
        },
        set: function (value) {
            this.cells.setJson(value && value.getJson ? value.getJson() : null);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMatrixModel.prototype, "hasCellText", {
        get: function () {
            return this.getPropertyValue("hasCellText", false);
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixModel.prototype.updateHasCellText = function () {
        this.setPropertyValue("hasCellText", !this.cells.isEmpty);
    };
    QuestionMatrixModel.prototype.setCellText = function (row, column, val) {
        this.cells.setCellText(row, column, val);
    };
    QuestionMatrixModel.prototype.getCellText = function (row, column) {
        return this.cells.getCellText(row, column);
    };
    QuestionMatrixModel.prototype.setDefaultCellText = function (column, val) {
        this.cells.setDefaultCellText(column, val);
    };
    QuestionMatrixModel.prototype.getDefaultCellText = function (column) {
        return this.cells.getDefaultCellText(column);
    };
    QuestionMatrixModel.prototype.getCellDisplayText = function (row, column) {
        return this.cells.getCellDisplayText(row, column);
    };
    QuestionMatrixModel.prototype.getCellDisplayLocText = function (row, column) {
        var loc = this.cells.getCellDisplayLocText(row, column);
        return loc ? loc : this.emptyLocalizableString;
    };
    QuestionMatrixModel.prototype.supportGoNextPageAutomatic = function () {
        return this.isMouseDown === true && this.hasValuesInAllRows();
    };
    QuestionMatrixModel.prototype.onCheckForErrors = function (errors, isOnValueChanged) {
        _super.prototype.onCheckForErrors.call(this, errors, isOnValueChanged);
        if (!isOnValueChanged || this.hasCssError()) {
            var rowsErrors = { noValue: false, isNotUnique: false };
            this.checkErrorsAllRows(true, rowsErrors);
            if (rowsErrors.noValue) {
                errors.push(new RequiredInAllRowsError(null, this));
            }
            if (rowsErrors.isNotUnique) {
                errors.push(new EachRowUniqueError(null, this));
            }
        }
    };
    QuestionMatrixModel.prototype.hasValuesInAllRows = function () {
        var rowsErrors = { noValue: false, isNotUnique: false };
        this.checkErrorsAllRows(false, rowsErrors, true);
        return !rowsErrors.noValue;
    };
    QuestionMatrixModel.prototype.checkErrorsAllRows = function (modifyErrors, res, allRowsRequired) {
        var _this = this;
        var rows = this.generatedVisibleRows;
        if (!rows)
            rows = this.visibleRows;
        if (!rows)
            return;
        var rowsRequired = this.isAllRowRequired || allRowsRequired;
        var rowsUnique = this.eachRowUnique;
        res.noValue = false;
        res.isNotUnique = false;
        if (modifyErrors) {
            this.errorsInRow = undefined;
        }
        if (!rowsRequired && !rowsUnique)
            return;
        var hash = {};
        for (var i = 0; i < rows.length; i++) {
            var val = rows[i].value;
            var isEmpty = this.isValueEmpty(val);
            var isNotUnique = rowsUnique && (!isEmpty && hash[val] === true);
            isEmpty = isEmpty && rowsRequired;
            if (modifyErrors && (isEmpty || isNotUnique)) {
                this.addErrorIntoRow(rows[i]);
            }
            if (!isEmpty) {
                hash[val] = true;
            }
            res.noValue = res.noValue || isEmpty;
            res.isNotUnique = res.isNotUnique || isNotUnique;
        }
        if (modifyErrors) {
            rows.forEach(function (row) {
                row.hasError = _this.hasErrorInRow(row);
            });
        }
    };
    QuestionMatrixModel.prototype.addErrorIntoRow = function (row) {
        if (!this.errorsInRow)
            this.errorsInRow = {};
        this.errorsInRow[row.name] = true;
        row.hasError = true;
    };
    QuestionMatrixModel.prototype.refreshRowsErrors = function () {
        if (!this.errorsInRow)
            return;
        this.checkErrorsAllRows(true, { noValue: false, isNotUnique: false });
    };
    QuestionMatrixModel.prototype.getIsAnswered = function () {
        return _super.prototype.getIsAnswered.call(this) && this.hasValuesInAllRows();
    };
    QuestionMatrixModel.prototype.createMatrixRow = function (item, fullName, value) {
        var row = new question_matrix_MatrixRowModel(item, fullName, this, value);
        this.onMatrixRowCreated(row);
        return row;
    };
    QuestionMatrixModel.prototype.onMatrixRowCreated = function (row) { };
    QuestionMatrixModel.prototype.setQuestionValue = function (newValue, updateIsAnswered) {
        if (updateIsAnswered === void 0) { updateIsAnswered = true; }
        _super.prototype.setQuestionValue.call(this, newValue, this.isRowChanging || updateIsAnswered);
        if (!this.generatedVisibleRows || this.generatedVisibleRows.length == 0)
            return;
        this.isRowChanging = true;
        var val = this.value;
        if (!val)
            val = {};
        if (this.rows.length == 0) {
            this.generatedVisibleRows[0].setValueDirectly(val);
        }
        else {
            for (var i = 0; i < this.generatedVisibleRows.length; i++) {
                var row = this.generatedVisibleRows[i];
                var rowVal = val[row.name];
                if (this.isValueEmpty(rowVal))
                    rowVal = null;
                this.generatedVisibleRows[i].setValueDirectly(rowVal);
            }
        }
        this.refreshRowsErrors();
        this.updateIsAnswered();
        this.isRowChanging = false;
    };
    QuestionMatrixModel.prototype.getDisplayValueCore = function (keysAsText, value) {
        var res = {};
        for (var key in value) {
            var newKey = keysAsText
                ? itemvalue_ItemValue.getTextOrHtmlByValue(this.rows, key)
                : key;
            if (!newKey)
                newKey = key;
            var newValue = itemvalue_ItemValue.getTextOrHtmlByValue(this.columns, value[key]);
            if (!newValue)
                newValue = value[key];
            res[newKey] = newValue;
        }
        return res;
    };
    QuestionMatrixModel.prototype.getPlainData = function (options) {
        var _this = this;
        if (options === void 0) { options = {
            includeEmpty: true,
        }; }
        var questionPlainData = _super.prototype.getPlainData.call(this, options);
        if (!!questionPlainData) {
            var values = this.createValueCopy();
            questionPlainData.isNode = true;
            questionPlainData.data = Object.keys(values || {}).map(function (rowName) {
                var row = _this.rows.filter(function (r) { return r.value === rowName; })[0];
                var rowDataItem = {
                    name: rowName,
                    title: !!row ? row.text : "row",
                    value: values[rowName],
                    displayValue: itemvalue_ItemValue.getTextOrHtmlByValue(_this.visibleColumns, values[rowName]),
                    getString: function (val) {
                        return typeof val === "object" ? JSON.stringify(val) : val;
                    },
                    isNode: false,
                };
                var item = itemvalue_ItemValue.getItemByValue(_this.visibleColumns, values[rowName]);
                if (!!item) {
                    (options.calculations || []).forEach(function (calculation) {
                        rowDataItem[calculation.propertyName] =
                            item[calculation.propertyName];
                    });
                }
                return rowDataItem;
            });
        }
        return questionPlainData;
    };
    QuestionMatrixModel.prototype.addConditionObjectsByContext = function (objects, context) {
        for (var i = 0; i < this.rows.length; i++) {
            var row = this.rows[i];
            if (!!row.value) {
                objects.push({
                    name: this.getValueName() + "." + row.value,
                    text: this.processedTitle + "." + row.calculatedText,
                    question: this,
                });
            }
        }
    };
    QuestionMatrixModel.prototype.getConditionJson = function (operator, path) {
        if (operator === void 0) { operator = null; }
        if (path === void 0) { path = null; }
        if (!path)
            return _super.prototype.getConditionJson.call(this, operator);
        var question = new question_dropdown_QuestionDropdownModel(path);
        question.choices = this.columns;
        var json = new jsonobject_JsonObject().toJsonObject(question);
        json["type"] = question.getType();
        return json;
    };
    QuestionMatrixModel.prototype.clearValueIfInvisibleCore = function (reason) {
        _super.prototype.clearValueIfInvisibleCore.call(this, reason);
        if (this.hasRows) {
            this.clearInvisibleValuesInRows();
        }
    };
    QuestionMatrixModel.prototype.getFirstInputElementId = function () {
        var rows = this.generatedVisibleRows;
        if (!rows)
            rows = this.visibleRows;
        if (rows.length > 0 && this.visibleColumns.length > 0) {
            return this.inputId + "_" + rows[0].name + "_" + 0;
        }
        return _super.prototype.getFirstInputElementId.call(this);
    };
    //IMatrixData
    QuestionMatrixModel.prototype.onMatrixRowChanged = function (row) {
        if (this.isRowChanging)
            return;
        this.isRowChanging = true;
        if (!this.hasRows) {
            this.setNewValue(row.value);
        }
        else {
            var newValue = this.value;
            if (!newValue) {
                newValue = {};
            }
            newValue[row.name] = row.value;
            this.setNewValue(newValue);
        }
        this.isRowChanging = false;
    };
    QuestionMatrixModel.prototype.getCorrectedRowValue = function (value) {
        for (var i = 0; i < this.columns.length; i++) {
            if (value === this.columns[i].value)
                return value;
        }
        for (var i = 0; i < this.columns.length; i++) {
            if (this.isTwoValueEquals(value, this.columns[i].value))
                return this.columns[i].value;
        }
        return value;
    };
    QuestionMatrixModel.prototype.hasErrorInRow = function (row) {
        return !!this.errorsInRow && !!this.errorsInRow[row.name];
    };
    QuestionMatrixModel.prototype.getSearchableItemValueKeys = function (keys) {
        keys.push("columns");
        keys.push("rows");
    };
    Object.defineProperty(QuestionMatrixModel.prototype, "SurveyModel", {
        get: function () {
            return this.survey;
        },
        enumerable: false,
        configurable: true
    });
    QuestionMatrixModel.prototype.getColumnHeaderWrapperComponentName = function (cell) {
        return this.SurveyModel.getElementWrapperComponentName({ column: cell }, "column-header");
    };
    QuestionMatrixModel.prototype.getColumnHeaderWrapperComponentData = function (cell) {
        return this.SurveyModel.getElementWrapperComponentData({ column: cell }, "column-header");
    };
    QuestionMatrixModel.prototype.getRowHeaderWrapperComponentName = function (cell) {
        return this.SurveyModel.getElementWrapperComponentName({ row: cell }, "row-header");
    };
    QuestionMatrixModel.prototype.getRowHeaderWrapperComponentData = function (cell) {
        return this.SurveyModel.getElementWrapperComponentData({ row: cell }, "row-header");
    };
    return QuestionMatrixModel;
}(martixBase_QuestionMatrixBaseModel));

Serializer.addClass("matrix", [
    "rowTitleWidth",
    {
        name: "columns:itemvalue[]", uniqueProperty: "value",
        baseValue: function () {
            return surveyLocalization.getString("matrix_column");
        },
    },
    {
        name: "rows:itemvalue[]", uniqueProperty: "value",
        baseValue: function () {
            return surveyLocalization.getString("matrix_row");
        },
    },
    { name: "cells:cells", serializationProperty: "cells" },
    {
        name: "rowsOrder",
        default: "initial",
        choices: ["initial", "random"],
    },
    "isAllRowRequired:boolean",
    { name: "eachRowUnique:boolean", category: "validation" },
    "hideIfRowsEmpty:boolean",
    { name: "cellComponent", visible: false, default: "survey-matrix-cell" }
], function () {
    return new question_matrix_QuestionMatrixModel("");
}, "matrixbase");
questionfactory_QuestionFactory.Instance.registerQuestion("matrix", function (name) {
    var q = new question_matrix_QuestionMatrixModel(name);
    q.rows = questionfactory_QuestionFactory.DefaultRows;
    q.columns = questionfactory_QuestionFactory.DefaultColums;
    return q;
});

// CONCATENATED MODULE: ./packages/survey-core/src/question_textbase.ts
var question_textbase_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var question_textbase_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};





var question_textbase_CharacterCounter = /** @class */ (function (_super) {
    question_textbase_extends(CharacterCounter, _super);
    function CharacterCounter() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    CharacterCounter.prototype.updateRemainingCharacterCounter = function (newValue, maxLength) {
        this.remainingCharacterCounter = helpers_Helpers.getRemainingCharacterCounterText(newValue, maxLength);
    };
    question_textbase_decorate([
        jsonobject_property()
    ], CharacterCounter.prototype, "remainingCharacterCounter", void 0);
    return CharacterCounter;
}(base_Base));

/**
 * A base class for the [Single-Line Input](https://surveyjs.io/form-library/documentation/questiontextmodel) and [Long Text](https://surveyjs.io/form-library/documentation/questioncommentmodel) question types.
 */
var question_textbase_QuestionTextBase = /** @class */ (function (_super) {
    question_textbase_extends(QuestionTextBase, _super);
    function QuestionTextBase(name) {
        var _this = _super.call(this, name) || this;
        _this.characterCounter = new question_textbase_CharacterCounter();
        return _this;
    }
    QuestionTextBase.prototype.isTextValue = function () {
        return true;
    };
    Object.defineProperty(QuestionTextBase.prototype, "maxLength", {
        /**
         * The maximum text length measured in characters. Assign 0 if the length should be unlimited.
         *
         * Default value: -1 (inherits the actual value from the `SurveyModel`'s [`maxTextLength`](https://surveyjs.io/form-library/documentation/surveymodel#maxTextLength) property).
         */
        get: function () {
            return this.getPropertyValue("maxLength");
        },
        set: function (val) {
            this.setPropertyValue("maxLength", val);
            this.updateRemainingCharacterCounter(this.value);
        },
        enumerable: false,
        configurable: true
    });
    QuestionTextBase.prototype.getMaxLength = function () {
        return helpers_Helpers.getMaxLength(this.maxLength, this.survey ? this.survey.maxTextLength : -1);
    };
    QuestionTextBase.prototype.updateRemainingCharacterCounter = function (newValue) {
        this.characterCounter.updateRemainingCharacterCounter(newValue, this.getMaxLength());
    };
    Object.defineProperty(QuestionTextBase.prototype, "placeHolder", {
        get: function () { return this.placeholder; },
        set: function (val) { this.placeholder = val; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextBase.prototype, "locPlaceHolder", {
        get: function () { return this.locPlaceholder; },
        enumerable: false,
        configurable: true
    });
    QuestionTextBase.prototype.getType = function () {
        return "textbase";
    };
    QuestionTextBase.prototype.isEmpty = function () {
        return _super.prototype.isEmpty.call(this) || this.value === "";
    };
    Object.defineProperty(QuestionTextBase.prototype, "textUpdateMode", {
        /**
         * Specifies when to update the question value.
         *
         * Possible values:
         *
         * - `"onBlur"` - Updates the value after the input field loses focus.
         * - `"onTyping"` - Updates the value on every key press.
         * - `"default"` (default) - Inherits the value from the `SurveyModel`'s [`textUpdateMode`](https://surveyjs.io/form-library/documentation/surveymodel#textUpdateMode) property.
         *
         * > Do not use the `"onTyping"` mode if your survey contains many expressions. Expressions are reevaluated each time a question value is changed. In `"onTyping"` mode, the question value changes frequently. This may cause performance degradation.
         */
        get: function () {
            return this.getPropertyValue("textUpdateMode");
        },
        set: function (val) {
            this.setPropertyValue("textUpdateMode", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionTextBase.prototype.getIsInputTextUpdate = function () {
        if (this.textUpdateMode == "default")
            return _super.prototype.getIsInputTextUpdate.call(this);
        return this.textUpdateMode == "onTyping";
    };
    Object.defineProperty(QuestionTextBase.prototype, "renderedPlaceholder", {
        get: function () {
            return this.getPropertyValue("renderedPlaceholder");
        },
        enumerable: false,
        configurable: true
    });
    QuestionTextBase.prototype.setRenderedPlaceholder = function (val) {
        this.setPropertyValue("renderedPlaceholder", val);
    };
    QuestionTextBase.prototype.onReadOnlyChanged = function () {
        _super.prototype.onReadOnlyChanged.call(this);
        this.calcRenderedPlaceholder();
    };
    QuestionTextBase.prototype.onSurveyLoad = function () {
        this.calcRenderedPlaceholder();
        _super.prototype.onSurveyLoad.call(this);
    };
    QuestionTextBase.prototype.localeChanged = function () {
        _super.prototype.localeChanged.call(this);
        this.calcRenderedPlaceholder();
    };
    QuestionTextBase.prototype.setSurveyImpl = function (value, isLight) {
        _super.prototype.setSurveyImpl.call(this, value, isLight);
        this.calcRenderedPlaceholder();
    };
    QuestionTextBase.prototype.supportEmptyValidation = function () { return true; };
    QuestionTextBase.prototype.calcRenderedPlaceholder = function () {
        var res = this.placeHolder;
        if (!!res && !this.hasPlaceholder()) {
            res = undefined;
        }
        this.setRenderedPlaceholder(res);
    };
    QuestionTextBase.prototype.hasPlaceholder = function () {
        return !this.isReadOnly;
    };
    QuestionTextBase.prototype.setNewValue = function (newValue) {
        _super.prototype.setNewValue.call(this, newValue);
        this.updateRemainingCharacterCounter(newValue);
    };
    QuestionTextBase.prototype.setQuestionValue = function (newValue, updateIsAnswered) {
        if (updateIsAnswered === void 0) { updateIsAnswered = true; }
        _super.prototype.setQuestionValue.call(this, newValue, updateIsAnswered);
        this.updateRemainingCharacterCounter(newValue);
    };
    QuestionTextBase.prototype.convertToCorrectValue = function (val) {
        if (Array.isArray(val))
            return val.join(this.getValueSeparator());
        return val;
    };
    QuestionTextBase.prototype.getValueSeparator = function () { return ", "; };
    QuestionTextBase.prototype.getControlCssClassBuilder = function () {
        return new CssClassBuilder()
            .append(this.cssClasses.root)
            .append(this.cssClasses.onError, this.hasCssError())
            .append(this.cssClasses.controlDisabled, this.isDisabledStyle)
            .append(this.cssClasses.controlReadOnly, this.isReadOnlyStyle)
            .append(this.cssClasses.controlPreview, this.isPreviewStyle);
    };
    QuestionTextBase.prototype.getControlClass = function () {
        return this.getControlCssClassBuilder().toString();
    };
    Object.defineProperty(QuestionTextBase.prototype, "isNewA11yStructure", {
        //a11y
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    question_textbase_decorate([
        jsonobject_property({ localizable: true, onSet: function (val, target) { return target.calcRenderedPlaceholder(); } })
    ], QuestionTextBase.prototype, "placeholder", void 0);
    return QuestionTextBase;
}(question_Question));

Serializer.addClass("textbase", [], function () {
    return new question_textbase_QuestionTextBase("");
}, "question");

// CONCATENATED MODULE: ./packages/survey-core/src/mask/input_element_adapter.ts
var InputElementAdapter = /** @class */ (function () {
    function InputElementAdapter(inputMaskInstance, inputElement, value) {
        var _this = this;
        this.inputMaskInstance = inputMaskInstance;
        this.inputElement = inputElement;
        this.prevUnmaskedValue = undefined;
        this.inputMaskInstancePropertyChangedHandler = function (sender, options) {
            if (options.name !== "saveMaskedValue") {
                var maskedValue = _this.inputMaskInstance.getMaskedValue(_this.prevUnmaskedValue);
                _this.inputElement.value = maskedValue;
            }
        };
        this.clickHandler = function (event) {
            if (_this.inputElement.value == _this.inputMaskInstance.getMaskedValue("")) {
                _this.inputElement.setSelectionRange(0, 0);
            }
        };
        this.beforeInputHandler = function (event) {
            var args = _this.createArgs(event);
            var result = _this.inputMaskInstance.processInput(args);
            _this.inputElement.value = result.value;
            _this.inputElement.setSelectionRange(result.caretPosition, result.caretPosition);
            if (!result.cancelPreventDefault) {
                event.preventDefault();
            }
        };
        this.changeHandler = function (event) {
            var result = _this.inputMaskInstance.processInput({ prevValue: "", insertedChars: event.target.value, selectionStart: 0, selectionEnd: 0 });
            _this.inputElement.value = result.value;
        };
        var _value = value;
        if (_value === null || _value === undefined) {
            _value = "";
        }
        this.inputElement.value = inputMaskInstance.getMaskedValue(_value);
        this.prevUnmaskedValue = _value;
        inputMaskInstance.onPropertyChanged.add(this.inputMaskInstancePropertyChangedHandler);
        this.addInputEventListener();
    }
    InputElementAdapter.prototype.createArgs = function (event) {
        var args = {
            insertedChars: event.data,
            selectionStart: event.target.selectionStart,
            selectionEnd: event.target.selectionEnd,
            prevValue: event.target.value,
            inputDirection: "forward"
        };
        if (event.inputType === "deleteContentBackward") {
            args.inputDirection = "backward";
            if (args.selectionStart === args.selectionEnd) {
                args.selectionStart = Math.max(args.selectionStart - 1, 0);
            }
        }
        if (event.inputType === "deleteContentForward" && args.selectionStart === args.selectionEnd) {
            args.selectionEnd += 1;
        }
        return args;
    };
    InputElementAdapter.prototype.addInputEventListener = function () {
        if (!!this.inputElement) {
            this.inputElement.addEventListener("beforeinput", this.beforeInputHandler);
            this.inputElement.addEventListener("click", this.clickHandler);
            this.inputElement.addEventListener("focus", this.clickHandler);
            this.inputElement.addEventListener("change", this.changeHandler);
        }
    };
    InputElementAdapter.prototype.removeInputEventListener = function () {
        if (!!this.inputElement) {
            this.inputElement.removeEventListener("beforeinput", this.beforeInputHandler);
            this.inputElement.removeEventListener("click", this.clickHandler);
            this.inputElement.removeEventListener("focus", this.clickHandler);
            this.inputElement.removeEventListener("change", this.changeHandler);
        }
    };
    InputElementAdapter.prototype.dispose = function () {
        this.removeInputEventListener();
        this.inputMaskInstance.onPropertyChanged.remove(this.inputMaskInstancePropertyChangedHandler);
    };
    return InputElementAdapter;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/mask/mask_utils.ts

var numberDefinition = /[0-9]/;
function getAvailableMaskTypeChoices() {
    var classes = Serializer.getChildrenClasses("masksettings") || [];
    var choices = classes.map(function (cl) {
        var value = cl.name;
        if (cl.name.indexOf("mask") !== -1) {
            value = value.slice(0, value.indexOf("mask"));
        }
        return value;
    });
    choices.unshift("none");
    return choices;
}

// CONCATENATED MODULE: ./packages/survey-core/src/question_text.ts
var question_text_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var question_text_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};










/**
 * A class that describes the Single-Line Input question type.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/questiontype-text/ (linkStyle))
 */
var question_text_QuestionTextModel = /** @class */ (function (_super) {
    question_text_extends(QuestionTextModel, _super);
    function QuestionTextModel(name) {
        var _this = _super.call(this, name) || this;
        //web-based methods
        _this._isWaitingForEnter = false;
        _this.onCompositionUpdate = function (event) {
            if (_this.isInputTextUpdate) {
                setTimeout(function () {
                    _this.updateValueOnEvent(event);
                }, 1);
            }
            _this.updateRemainingCharacterCounter(event.target.value);
        };
        _this.onKeyUp = function (event) {
            if (_this.isInputTextUpdate) {
                if (!_this._isWaitingForEnter || event.keyCode === 13) {
                    _this.updateValueOnEvent(event);
                    _this._isWaitingForEnter = false;
                }
            }
            else {
                if (event.keyCode === 13) {
                    _this.updateValueOnEvent(event);
                }
            }
            _this.updateRemainingCharacterCounter(event.target.value);
        };
        _this.onKeyDown = function (event) {
            _this.updateDateValidationMessage(event);
            _this.onKeyDownPreprocess && _this.onKeyDownPreprocess(event);
            if (_this.isInputTextUpdate) {
                _this._isWaitingForEnter = event.keyCode === 229;
            }
            _this.onTextKeyDownHandler(event);
        };
        _this.onChange = function (event) {
            _this.updateDateValidationMessage(event);
            var elementIsFocused = event.target === settings.environment.root.activeElement;
            if (elementIsFocused) {
                if (_this.isInputTextUpdate) {
                    _this.updateValueOnEvent(event);
                }
            }
            else {
                _this.updateValueOnEvent(event);
            }
            _this.updateRemainingCharacterCounter(event.target.value);
        };
        _this.createLocalizableString("minErrorText", _this, true, "minError");
        _this.createLocalizableString("maxErrorText", _this, true, "maxError");
        _this.setNewMaskSettingsProperty();
        _this.locDataListValue = new localizablestring_LocalizableStrings(_this);
        _this.locDataListValue.onValueChanged = function (oldValue, newValue) {
            _this.propertyValueChanged("dataList", oldValue, newValue);
        };
        _this.registerPropertyChangedHandlers(["min", "max", "inputType", "minValueExpression", "maxValueExpression"], function () {
            _this.setRenderedMinMax();
        });
        _this.registerPropertyChangedHandlers(["inputType", "size"], function () {
            _this.updateInputSize();
            _this.calcRenderedPlaceholder();
        });
        return _this;
    }
    QuestionTextModel.prototype.createMaskAdapter = function () {
        if (!!this.input && !this.maskTypeIsEmpty) {
            this.maskInputAdapter = new InputElementAdapter(this.maskInstance, this.input, this.value);
        }
    };
    QuestionTextModel.prototype.deleteMaskAdapter = function () {
        if (this.maskInputAdapter) {
            this.maskInputAdapter.dispose();
            this.maskInputAdapter = undefined;
        }
    };
    QuestionTextModel.prototype.updateMaskAdapter = function () {
        this.deleteMaskAdapter();
        this.createMaskAdapter();
    };
    QuestionTextModel.prototype.onSetMaskType = function (newValue) {
        this.setNewMaskSettingsProperty();
        this.updateMaskAdapter();
    };
    Object.defineProperty(QuestionTextModel.prototype, "maskTypeIsEmpty", {
        get: function () {
            switch (this.inputType) {
                case "tel":
                case "text": return this.maskType === "none";
                default: return true;
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "maskSettings", {
        /**
         * An object with properties that configure the mask applied to the input.
         *
         * Available properties depend on the specified [`maskType`](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model#maskType) and belong to corresponding classes. Refer to the class APIs for a full list of properties:
         *
         * | `maskType` | Class |
         * | ---------- | ----- |
         * | `"numeric"` | [`InputMaskNumeric`](https://surveyjs.io/form-library/documentation/api-reference/inputmasknumeric) |
         * | `"currency"` | [`InputMaskCurrency`](https://surveyjs.io/form-library/documentation/api-reference/inputmaskcurrency) |
         * | `"datetime"` | [`InputMaskDateTime`](https://surveyjs.io/form-library/documentation/api-reference/inputmaskdatetime) |
         * | `"pattern"` | [`InputMaskPattern`](https://surveyjs.io/form-library/documentation/api-reference/inputmaskpattern) |
         *
         * [View Demo](https://surveyjs.io/form-library/examples/masked-input-fields/ (linkStyle))
         */
        get: function () {
            return this.getPropertyValue("maskSettings");
        },
        set: function (val) {
            if (!val)
                return;
            this.setNewMaskSettingsProperty();
            this.maskSettings.fromJSON(val.toJSON());
            this.updateMaskAdapter();
        },
        enumerable: false,
        configurable: true
    });
    QuestionTextModel.prototype.setNewMaskSettingsProperty = function () {
        this.setPropertyValue("maskSettings", this.createMaskSettings());
    };
    QuestionTextModel.prototype.createMaskSettings = function () {
        var maskClassName = (!this.maskType || this.maskType === "none") ? "masksettings" : (this.maskType + "mask");
        if (!Serializer.findClass(maskClassName)) {
            maskClassName = "masksettings";
        }
        var inputMask = Serializer.createClass(maskClassName);
        inputMask.owner = this.survey;
        return inputMask;
    };
    QuestionTextModel.prototype.isTextValue = function () {
        return ["text", "number", "password"].indexOf(this.inputType) > -1;
    };
    QuestionTextModel.prototype.getType = function () {
        return "text";
    };
    QuestionTextModel.prototype.onSurveyLoad = function () {
        _super.prototype.onSurveyLoad.call(this);
        this.setRenderedMinMax();
        this.updateInputSize();
    };
    Object.defineProperty(QuestionTextModel.prototype, "inputType", {
        /**
         * A value passed on to the [`type`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types) attribute of the underlying `<input>` element.
         *
         * Default value: `"text"`
         */
        get: function () {
            return this.getPropertyValue("inputType");
        },
        set: function (val) {
            val = val.toLowerCase();
            if (val === "datetime_local" || val === "datetime")
                val = "datetime-local";
            this.setPropertyValue("inputType", val.toLowerCase());
            if (!this.isLoadingFromJson) {
                this.min = undefined;
                this.max = undefined;
                this.step = undefined;
            }
            this.updateMaskAdapter();
        },
        enumerable: false,
        configurable: true
    });
    QuestionTextModel.prototype.getMaxLength = function () {
        if (!this.isTextInput)
            return null;
        return _super.prototype.getMaxLength.call(this);
    };
    QuestionTextModel.prototype.runCondition = function (values, properties) {
        _super.prototype.runCondition.call(this, values, properties);
        if (!!this.minValueExpression || !!this.maxValueExpression) {
            this.setRenderedMinMax(values, properties);
        }
    };
    QuestionTextModel.prototype.isLayoutTypeSupported = function (layoutType) {
        return true;
    };
    Object.defineProperty(QuestionTextModel.prototype, "size", {
        /**
         * A value passed on to the [`size`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/size) attribute of the underlying `<input>` element.
         */
        get: function () {
            return this.getPropertyValue("size");
        },
        set: function (val) {
            this.setPropertyValue("size", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "isTextInput", {
        get: function () {
            return (["text", "search", "tel", "url", "email", "password"].indexOf(this.inputType) > -1);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "inputSize", {
        get: function () {
            return this.getPropertyValue("inputSize", 0);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "renderedInputSize", {
        get: function () {
            return this.getPropertyValue("inputSize") || null;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "inputWidth", {
        get: function () {
            return this.getPropertyValue("inputWidth");
        },
        enumerable: false,
        configurable: true
    });
    QuestionTextModel.prototype.updateInputSize = function () {
        var size = this.isTextInput && this.size > 0 ? this.size : 0;
        if (this.isTextInput &&
            size < 1 &&
            this.parent &&
            !!this.parent["itemSize"]) {
            size = this.parent["itemSize"];
        }
        this.setPropertyValue("inputSize", size);
        this.setPropertyValue("inputWidth", size > 0 ? "auto" : "");
    };
    Object.defineProperty(QuestionTextModel.prototype, "autocomplete", {
        /**
         * A value passed on to the [`autocomplete`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) attribute of the underlying `<input>` element.
         */
        get: function () {
            return this.getPropertyValue("autocomplete", null);
        },
        set: function (val) {
            this.setPropertyValue("autocomplete", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "min", {
        /**
         * A value passed on to the [`min`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/min) attribute of the underlying `<input>` element.
         * @see minValueExpression
         */
        get: function () {
            return this.getPropertyValue("min");
        },
        set: function (val) {
            if (this.isValueExpression(val)) {
                this.minValueExpression = val.substring(1);
                return;
            }
            this.setPropertyValue("min", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "max", {
        /**
         * A value passed on to the [`max`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/max) attribute of the underlying `<input>` element.
         * @see maxValueExpression
         */
        get: function () {
            return this.getPropertyValue("max");
        },
        set: function (val) {
            if (this.isValueExpression(val)) {
                this.maxValueExpression = val.substring(1);
                return;
            }
            this.setPropertyValue("max", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "minValueExpression", {
        /**
         * The minimum value specified as an expression. For example, `"minValueExpression": "today(-1)"` sets the minimum value to yesterday.
         * @see min
         */
        get: function () {
            return this.getPropertyValue("minValueExpression", "");
        },
        set: function (val) {
            this.setPropertyValue("minValueExpression", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "maxValueExpression", {
        /**
         * The maximum value specified as an expression. For example, `"maxValueExpression": "today(1)"` sets the maximum value to tomorrow.
         * @see max
         */
        get: function () {
            return this.getPropertyValue("maxValueExpression", "");
        },
        set: function (val) {
            this.setPropertyValue("maxValueExpression", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "renderedMin", {
        get: function () {
            return this.getPropertyValue("renderedMin");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "renderedMax", {
        get: function () {
            return this.getPropertyValue("renderedMax");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "minErrorText", {
        /**
         * An error message to display when the question value is less than the minimum accepted value.
         * @see min
         * @see minValueExpression
         */
        get: function () {
            return this.getLocalizableStringText("minErrorText");
        },
        set: function (val) {
            this.setLocalizableStringText("minErrorText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "locMinErrorText", {
        get: function () {
            return this.getLocalizableString("minErrorText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "maxErrorText", {
        /**
         * An error message to display when the question value exceeds the maximum accepted value.
         * @see max
         * @see maxValueExpression
         */
        get: function () {
            return this.getLocalizableStringText("maxErrorText");
        },
        set: function (val) {
            this.setLocalizableStringText("maxErrorText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "locMaxErrorText", {
        get: function () {
            return this.getLocalizableString("maxErrorText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "isMinMaxType", {
        /**
         * Returns `true` if the specified `inputType` supports the `min` and `max` properties.
         * @see inputType
         * @see min
         * @see max
         */
        get: function () {
            return isMinMaxType(this);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "maskInstance", {
        get: function () {
            return this.maskSettings;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "inputValue", {
        get: function () {
            return this._inputValue;
        },
        set: function (val) {
            var value = val;
            this._inputValue = val;
            if (!this.maskTypeIsEmpty) {
                value = this.maskInstance.getUnmaskedValue(val);
                this._inputValue = this.maskInstance.getMaskedValue(value);
                if (!!value && this.maskSettings.saveMaskedValue) {
                    value = this.maskInstance.getMaskedValue(value);
                }
            }
            this.value = value;
        },
        enumerable: false,
        configurable: true
    });
    QuestionTextModel.prototype.onChangeQuestionValue = function (newValue) {
        _super.prototype.onChangeQuestionValue.call(this, newValue);
        this.updateInputValue();
    };
    QuestionTextModel.prototype.updateInputValue = function () {
        if (this.maskTypeIsEmpty) {
            this._inputValue = this.value;
        }
        else if (this.maskSettings.saveMaskedValue) {
            this._inputValue = !!this.value ? this.value : this.maskInstance.getMaskedValue("");
        }
        else {
            this._inputValue = this.maskInstance.getMaskedValue(this.value);
        }
    };
    QuestionTextModel.prototype.hasToConvertToUTC = function (val) {
        return settings.storeUtcDates && this.isDateTimeLocaleType() && !!val;
    };
    QuestionTextModel.prototype.valueForSurveyCore = function (val) {
        if (this.hasToConvertToUTC(val)) {
            val = new Date(val).toISOString();
        }
        return _super.prototype.valueForSurveyCore.call(this, val);
    };
    QuestionTextModel.prototype.valueFromDataCore = function (val) {
        if (this.hasToConvertToUTC(val)) {
            var d = new Date(val);
            var locale_d = new Date(d.getTime() - d.getTimezoneOffset() * 60 * 1000);
            var res = locale_d.toISOString();
            val = res.substring(0, res.length - 2);
        }
        return _super.prototype.valueFromDataCore.call(this, val);
    };
    QuestionTextModel.prototype.onCheckForErrors = function (errors, isOnValueChanged) {
        var _this = this;
        _super.prototype.onCheckForErrors.call(this, errors, isOnValueChanged);
        if (isOnValueChanged)
            return;
        if (this.isValueLessMin) {
            var minError = new CustomError(this.getMinMaxErrorText(this.minErrorText, this.getCalculatedMinMax(this.renderedMin)), this);
            minError.onUpdateErrorTextCallback = function (err) {
                err.text = _this.getMinMaxErrorText(_this.minErrorText, _this.getCalculatedMinMax(_this.renderedMin));
            };
            errors.push(minError);
        }
        if (this.isValueGreaterMax) {
            var maxError = new CustomError(this.getMinMaxErrorText(this.maxErrorText, this.getCalculatedMinMax(this.renderedMax)), this);
            maxError.onUpdateErrorTextCallback = function (err) {
                err.text = _this.getMinMaxErrorText(_this.maxErrorText, _this.getCalculatedMinMax(_this.renderedMax));
            };
            errors.push(maxError);
        }
        if (!!this.dateValidationMessage) {
            errors.push(new CustomError(this.dateValidationMessage, this));
        }
        var valName = this.getValidatorTitle();
        var emailValidator = new EmailValidator();
        if (this.inputType === "email" &&
            !this.validators.some(function (v) { return v.getType() === "emailvalidator"; })) {
            var validateResult = emailValidator.validate(this.value, valName);
            if (!!validateResult && !!validateResult.error) {
                errors.push(validateResult.error);
            }
        }
    };
    QuestionTextModel.prototype.canSetValueToSurvey = function () {
        if (!this.isMinMaxType)
            return true;
        var isValid = !this.isValueLessMin && !this.isValueGreaterMax;
        if (this.inputType === "number" && !!this.survey &&
            (this.survey.isValidateOnValueChanging || this.survey.isValidateOnValueChanged)) {
            this.hasErrors();
        }
        return isValid;
    };
    QuestionTextModel.prototype.convertFuncValuetoQuestionValue = function (val) {
        return helpers_Helpers.convertValToQuestionVal(val, this.inputType);
    };
    QuestionTextModel.prototype.getMinMaxErrorText = function (errorText, value) {
        if (helpers_Helpers.isValueEmpty(value))
            return errorText;
        var errorValue = value.toString();
        if (this.inputType === "date" && !!value.toDateString) {
            errorValue = value.toDateString();
        }
        return errorText.replace("{0}", errorValue);
    };
    Object.defineProperty(QuestionTextModel.prototype, "isValueLessMin", {
        get: function () {
            return (!this.isValueEmpty(this.renderedMin) && !this.isEmpty() &&
                this.getCalculatedMinMax(this.value) <
                    this.getCalculatedMinMax(this.renderedMin));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "isValueGreaterMax", {
        get: function () {
            return (!this.isValueEmpty(this.renderedMax) && !this.isEmpty() &&
                this.getCalculatedMinMax(this.value) >
                    this.getCalculatedMinMax(this.renderedMax));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "isDateInputType", {
        get: function () {
            return this.inputType === "date" || this.isDateTimeLocaleType();
        },
        enumerable: false,
        configurable: true
    });
    QuestionTextModel.prototype.isDateTimeLocaleType = function () {
        return this.inputType === "datetime-local";
    };
    QuestionTextModel.prototype.getCalculatedMinMax = function (minMax) {
        if (this.isValueEmpty(minMax))
            return minMax;
        return this.isDateInputType ? new Date(minMax) : minMax;
    };
    QuestionTextModel.prototype.setRenderedMinMax = function (values, properties) {
        var _this = this;
        if (values === void 0) { values = null; }
        if (properties === void 0) { properties = null; }
        this.minValueRunner = this.getDefaultRunner(this.minValueRunner, this.minValueExpression);
        this.setValueAndRunExpression(this.minValueRunner, this.min, function (val) {
            if (!val && _this.isDateInputType && !!settings.minDate) {
                val = settings.minDate;
            }
            _this.setPropertyValue("renderedMin", val);
        }, values, properties);
        this.maxValueRunner = this.getDefaultRunner(this.maxValueRunner, this.maxValueExpression);
        this.setValueAndRunExpression(this.maxValueRunner, this.max, function (val) {
            if (!val && _this.isDateInputType) {
                val = !!settings.maxDate ? settings.maxDate : "2999-12-31";
            }
            _this.setPropertyValue("renderedMax", val);
        }, values, properties);
    };
    Object.defineProperty(QuestionTextModel.prototype, "step", {
        /**
         * A value passed on to the [`step`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/step) attribute of the underlying `<input>` element.
         */
        get: function () {
            return this.getPropertyValue("step");
        },
        set: function (val) {
            this.setPropertyValue("step", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "renderedStep", {
        get: function () {
            if (this.isValueEmpty(this.step)) {
                return this.inputType !== "number" ? undefined : "any";
            }
            return this.step;
        },
        enumerable: false,
        configurable: true
    });
    QuestionTextModel.prototype.getIsInputTextUpdate = function () {
        return this.maskTypeIsEmpty ? _super.prototype.getIsInputTextUpdate.call(this) : false;
    };
    QuestionTextModel.prototype.supportGoNextPageAutomatic = function () {
        return !this.getIsInputTextUpdate() && !this.isDateInputType;
    };
    QuestionTextModel.prototype.supportGoNextPageError = function () {
        return !this.isDateInputType;
    };
    Object.defineProperty(QuestionTextModel.prototype, "dataList", {
        /**
         * An array of predefined options from which users can select. This property configures an HTML [`<datalist>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist) element and associates it with the underlying `input` element.
         */
        get: function () {
            return this.locDataList.value;
        },
        set: function (val) {
            this.locDataList.value = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "locDataList", {
        get: function () {
            return this.locDataListValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTextModel.prototype, "dataListId", {
        get: function () {
            return this.locDataList.hasValue() ? this.id + "_datalist" : undefined;
        },
        enumerable: false,
        configurable: true
    });
    QuestionTextModel.prototype.canRunValidators = function (isOnValueChanged) {
        return (this.errors.length > 0 ||
            !isOnValueChanged ||
            this.supportGoNextPageError());
    };
    QuestionTextModel.prototype.setNewValue = function (newValue) {
        newValue = this.correctValueType(newValue);
        if (!!newValue) {
            this.dateValidationMessage = undefined;
        }
        _super.prototype.setNewValue.call(this, newValue);
    };
    QuestionTextModel.prototype.correctValueType = function (newValue) {
        if (!newValue)
            return newValue;
        if (this.inputType === "number" || this.inputType === "range") {
            return helpers_Helpers.isNumber(newValue) ? helpers_Helpers.getNumber(newValue) : "";
        }
        if (this.inputType === "month") {
            var d = new Date(newValue);
            var m = d.getMonth() + 1;
            return d.getFullYear() + "-" + (m < 10 ? "0" : "") + m;
        }
        return newValue;
    };
    QuestionTextModel.prototype.hasPlaceholder = function () {
        return !this.isReadOnly && this.inputType !== "range";
    };
    QuestionTextModel.prototype.getControlCssClassBuilder = function () {
        var maxLength = this.getMaxLength();
        return _super.prototype.getControlCssClassBuilder.call(this)
            .append(this.cssClasses.constrolWithCharacterCounter, !!maxLength)
            .append(this.cssClasses.characterCounterBig, maxLength > 99);
    };
    QuestionTextModel.prototype.isReadOnlyRenderDiv = function () {
        return this.isReadOnly && settings.readOnly.textRenderMode === "div";
    };
    Object.defineProperty(QuestionTextModel.prototype, "inputStyle", {
        get: function () {
            var style = {};
            style.width = this.inputWidth;
            this.updateTextAlign(style);
            return style;
        },
        enumerable: false,
        configurable: true
    });
    QuestionTextModel.prototype.updateTextAlign = function (style) {
        if (this.inputTextAlignment !== "auto") {
            style.textAlign = this.inputTextAlignment;
        }
        else if (!this.maskTypeIsEmpty && this.maskSettings.getTextAlignment() !== "auto") {
            style.textAlign = this.maskSettings.getTextAlignment();
        }
    };
    QuestionTextModel.prototype.updateValueOnEvent = function (event) {
        var newValue = event.target.value;
        if (!this.isTwoValueEquals(this.value, newValue)) {
            this.inputValue = newValue;
        }
    };
    QuestionTextModel.prototype.updateDateValidationMessage = function (event) {
        this.dateValidationMessage = this.isDateInputType && !!event.target ? event.target.validationMessage : undefined;
    };
    QuestionTextModel.prototype.onBlurCore = function (event) {
        this.updateValueOnEvent(event);
        this.updateRemainingCharacterCounter(event.target.value);
        _super.prototype.onBlurCore.call(this, event);
    };
    QuestionTextModel.prototype.onFocusCore = function (event) {
        this.updateRemainingCharacterCounter(event.target.value);
        _super.prototype.onFocusCore.call(this, event);
    };
    QuestionTextModel.prototype.afterRenderQuestionElement = function (el) {
        if (!!el) {
            this.input = el instanceof HTMLInputElement ? el : el.querySelector("input");
            this.createMaskAdapter();
        }
        _super.prototype.afterRenderQuestionElement.call(this, el);
    };
    QuestionTextModel.prototype.beforeDestroyQuestionElement = function (el) {
        this.deleteMaskAdapter();
    };
    question_text_decorate([
        jsonobject_property({
            onSet: function (newValue, target) { target.onSetMaskType(newValue); }
        })
    ], QuestionTextModel.prototype, "maskType", void 0);
    question_text_decorate([
        jsonobject_property()
    ], QuestionTextModel.prototype, "inputTextAlignment", void 0);
    question_text_decorate([
        jsonobject_property()
    ], QuestionTextModel.prototype, "_inputValue", void 0);
    return QuestionTextModel;
}(question_textbase_QuestionTextBase));

var minMaxTypes = [
    "number",
    "range",
    "date",
    "datetime-local",
    "month",
    "time",
    "week",
];
function isMinMaxType(obj) {
    var t = !!obj ? obj.inputType : "";
    if (!t)
        return false;
    return minMaxTypes.indexOf(t) > -1;
}
function getWeekTimeNumber(str, delimiter) {
    var strs = str.split(delimiter);
    if (strs.length !== 2)
        return -1;
    if (!helpers_Helpers.isNumber(strs[0]) || !helpers_Helpers.isNumber(strs[1]))
        return -1;
    return parseFloat(strs[0]) * 60 + parseFloat(strs[1]);
}
function isMinBiggerWeekTime(minStr, maxStr, delimiter) {
    var min = getWeekTimeNumber(minStr, delimiter);
    var max = getWeekTimeNumber(maxStr, delimiter);
    if (min < 0 || max < 0)
        return false;
    return min > max;
}
function getCorrectMinMax(obj, min, max, isMax) {
    var val = isMax ? max : min;
    if (!isMinMaxType(obj))
        return val;
    if (helpers_Helpers.isValueEmpty(min) || helpers_Helpers.isValueEmpty(max))
        return val;
    if (obj.inputType.indexOf("date") === 0 || obj.inputType === "month") {
        var isMonth = obj.inputType === "month";
        var dMin = new Date(isMonth ? min + "-01" : min);
        var dMax = new Date(isMonth ? max + "-01" : max);
        if (!dMin || !dMax)
            return val;
        if (dMin > dMax)
            return isMax ? min : max;
    }
    if (obj.inputType === "week" || obj.inputType === "time") {
        var delimiter = obj.inputType === "week" ? "-W" : ":";
        if (isMinBiggerWeekTime(min, max, delimiter))
            return isMax ? min : max;
        return val;
    }
    if (obj.inputType === "number") {
        if (!helpers_Helpers.isNumber(min) || !helpers_Helpers.isNumber(max))
            return val;
        if (helpers_Helpers.getNumber(min) > helpers_Helpers.getNumber(max))
            return isMax ? min : max;
    }
    if (typeof min === "string" || typeof max === "string")
        return val;
    if (min > max)
        return isMax ? min : max;
    return val;
}
function propertyEditorMinMaxUpdate(obj, propertyEditor) {
    if (!!obj && !!obj.inputType) {
        propertyEditor.inputType = obj.inputType !== "range" ? obj.inputType : "number";
        propertyEditor.textUpdateMode = "onBlur";
    }
}
Serializer.addClass("text", [
    {
        name: "inputType",
        default: "text",
        choices: settings.questions.inputTypes,
    },
    {
        name: "size:number",
        minValue: 0,
        dependsOn: "inputType",
        visibleIf: function (obj) {
            if (!obj)
                return false;
            return obj.isTextInput;
        },
    },
    {
        name: "textUpdateMode",
        default: "default",
        choices: ["default", "onBlur", "onTyping"],
        dependsOn: "inputType",
        visibleIf: function (obj) {
            if (!obj)
                return false;
            return obj.isTextInput;
        },
    },
    {
        name: "autocomplete",
        alternativeName: "autoComplete",
        choices: settings.questions.dataList,
    },
    {
        name: "min",
        dependsOn: "inputType",
        visibleIf: function (obj) {
            return isMinMaxType(obj);
        },
        onPropertyEditorUpdate: function (obj, propertyEditor) {
            propertyEditorMinMaxUpdate(obj, propertyEditor);
        },
        onSettingValue: function (obj, val) {
            return getCorrectMinMax(obj, val, obj.max, false);
        },
    },
    {
        name: "max",
        dependsOn: "inputType",
        nextToProperty: "*min",
        visibleIf: function (obj) {
            return isMinMaxType(obj);
        },
        onSettingValue: function (obj, val) {
            return getCorrectMinMax(obj, obj.min, val, true);
        },
        onPropertyEditorUpdate: function (obj, propertyEditor) {
            propertyEditorMinMaxUpdate(obj, propertyEditor);
        },
    },
    {
        name: "minValueExpression:expression",
        category: "logic",
        dependsOn: "inputType",
        visibleIf: function (obj) {
            return isMinMaxType(obj);
        },
    },
    {
        name: "maxValueExpression:expression",
        category: "logic",
        dependsOn: "inputType",
        visibleIf: function (obj) {
            return isMinMaxType(obj);
        },
    },
    {
        name: "minErrorText",
        serializationProperty: "locMinErrorText",
        dependsOn: "inputType",
        visibleIf: function (obj) {
            return isMinMaxType(obj);
        },
    },
    {
        name: "maxErrorText",
        serializationProperty: "locMaxErrorText",
        dependsOn: "inputType",
        visibleIf: function (obj) {
            return isMinMaxType(obj);
        },
    },
    { name: "inputTextAlignment", default: "auto", choices: ["left", "right", "auto"] },
    {
        name: "maskType",
        default: "none",
        visibleIndex: 0,
        dependsOn: "inputType",
        visibleIf: function (obj) {
            return obj.inputType === "text" || obj.inputType === "tel";
        },
        choices: function (obj) {
            var choices = getAvailableMaskTypeChoices();
            return choices;
        }
    },
    {
        name: "maskSettings:masksettings",
        className: "masksettings",
        visibleIndex: 1,
        dependsOn: ["inputType", "maskType"],
        visibleIf: function (obj) {
            return obj.inputType === "text" || obj.inputType === "tel";
        },
        onGetValue: function (obj) {
            return obj.maskSettings.getData();
        },
        onSetValue: function (obj, value) {
            obj.maskSettings.setData(value);
        },
    },
    {
        name: "step:number",
        dependsOn: "inputType",
        visibleIf: function (obj) {
            if (!obj)
                return false;
            return obj.inputType === "number" || obj.inputType === "range";
        },
    },
    {
        name: "maxLength:number",
        default: -1,
        dependsOn: "inputType",
        visibleIf: function (obj) {
            if (!obj)
                return false;
            return obj.isTextInput;
        },
    },
    {
        name: "placeholder",
        alternativeName: "placeHolder",
        serializationProperty: "locPlaceholder",
        dependsOn: "inputType",
        visibleIf: function (obj) {
            if (!obj)
                return false;
            return obj.isTextInput;
        },
    },
    {
        name: "dataList:string[]",
        serializationProperty: "locDataList",
        dependsOn: "inputType",
        visibleIf: function (obj) {
            if (!obj)
                return false;
            return obj.inputType === "text";
        },
    },
], function () {
    return new question_text_QuestionTextModel("");
}, "textbase");
questionfactory_QuestionFactory.Instance.registerQuestion("text", function (name) {
    return new question_text_QuestionTextModel(name);
});

// CONCATENATED MODULE: ./packages/survey-core/src/question_multipletext.ts
var question_multipletext_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var question_multipletext_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};










var MultipleTextEditorModel = /** @class */ (function (_super) {
    question_multipletext_extends(MultipleTextEditorModel, _super);
    function MultipleTextEditorModel() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(MultipleTextEditorModel.prototype, "a11y_input_ariaLabel", {
        get: function () {
            return this.locTitle.renderedHtml;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextEditorModel.prototype, "a11y_input_ariaLabelledBy", {
        get: function () {
            return null;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextEditorModel.prototype, "a11y_input_ariaDescribedBy", {
        get: function () {
            return null;
        },
        enumerable: false,
        configurable: true
    });
    return MultipleTextEditorModel;
}(question_text_QuestionTextModel));

/**
 * A class that describes an [item](https://surveyjs.io/form-library/documentation/api-reference/multiple-text-entry-question-model#items) in a Multiple Textboxes question.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/multiple-text-box-question/ (linkStyle))
 */
var question_multipletext_MultipleTextItemModel = /** @class */ (function (_super) {
    question_multipletext_extends(MultipleTextItemModel, _super);
    function MultipleTextItemModel(name, title) {
        if (name === void 0) { name = null; }
        if (title === void 0) { title = null; }
        var _this = _super.call(this) || this;
        _this.focusIn = function () {
            _this.editor.focusIn();
        };
        _this.editorValue = _this.createEditor(name);
        _this.maskSettings = _this.editorValue.maskSettings;
        _this.editor.questionTitleTemplateCallback = function () {
            return "";
        };
        _this.editor.titleLocation = "left";
        if (title) {
            _this.title = title;
        }
        return _this;
    }
    MultipleTextItemModel.prototype.getType = function () {
        return "multipletextitem";
    };
    Object.defineProperty(MultipleTextItemModel.prototype, "id", {
        get: function () {
            return this.editor.id;
        },
        enumerable: false,
        configurable: true
    });
    MultipleTextItemModel.prototype.getOriginalObj = function () {
        return this.editor;
    };
    Object.defineProperty(MultipleTextItemModel.prototype, "name", {
        /**
         * An item ID that is not visible to respondents.
         *
         * > Item IDs must be unique.
         * @see title
         */
        get: function () {
            return this.editor.name;
        },
        set: function (val) {
            this.editor.name = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "question", {
        get: function () {
            return this.data;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "editor", {
        get: function () {
            return this.editorValue;
        },
        enumerable: false,
        configurable: true
    });
    MultipleTextItemModel.prototype.createEditor = function (name) {
        return new MultipleTextEditorModel(name);
    };
    MultipleTextItemModel.prototype.addUsedLocales = function (locales) {
        _super.prototype.addUsedLocales.call(this, locales);
        this.editor.addUsedLocales(locales);
    };
    MultipleTextItemModel.prototype.localeChanged = function () {
        _super.prototype.localeChanged.call(this);
        this.editor.localeChanged();
    };
    MultipleTextItemModel.prototype.locStrsChanged = function () {
        _super.prototype.locStrsChanged.call(this);
        this.editor.locStrsChanged();
    };
    MultipleTextItemModel.prototype.setData = function (data) {
        this.data = data;
        if (!!data) {
            this.editor.defaultValue = data.getItemDefaultValue(this.name);
            this.editor.setSurveyImpl(this);
            this.editor.parent = data;
            this.editor.setParentQuestion(data);
        }
    };
    Object.defineProperty(MultipleTextItemModel.prototype, "isRequired", {
        /**
         * Marks the item as required. If a respondent leaves this item empty, the question displays a [validation error](#requiredErrorText).
         */
        get: function () {
            return this.editor.isRequired;
        },
        set: function (val) {
            this.editor.isRequired = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "inputType", {
        /**
         * A value passed on to the [`type`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types) attribute of the underlying `<input>` element.
         *
         * Default value: `"text"`
         */
        get: function () {
            return this.editor.inputType;
        },
        set: function (val) {
            this.editor.inputType = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "title", {
        /**
         * A user-friendly item label to display. If `title` is undefined, [`name`](https://surveyjs.io/form-library/documentation/api-reference/multipletextitemmodel#name) is displayed instead.
         */
        get: function () {
            return this.editor.title;
        },
        set: function (val) {
            this.editor.title = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "locTitle", {
        get: function () {
            return this.editor.locTitle;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "fullTitle", {
        get: function () {
            return this.editor.fullTitle;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "maxLength", {
        /**
         * The maximum text length measured in characters. Assign 0 if the length should be unlimited.
         *
         * Default value: -1 (inherits the actual value from the `SurveyModel`'s [`maxTextLength`](https://surveyjs.io/form-library/documentation/surveymodel#maxTextLength) property).
         */
        get: function () {
            return this.editor.maxLength;
        },
        set: function (val) {
            this.editor.maxLength = val;
        },
        enumerable: false,
        configurable: true
    });
    MultipleTextItemModel.prototype.getMaxLength = function () {
        var survey = this.getSurvey();
        return helpers_Helpers.getMaxLength(this.maxLength, survey ? survey.maxTextLength : -1);
    };
    Object.defineProperty(MultipleTextItemModel.prototype, "placeholder", {
        /**
         * A placeholder for the input field.
         */
        get: function () {
            return this.editor.placeholder;
        },
        set: function (val) {
            this.editor.placeholder = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "locPlaceholder", {
        get: function () {
            return this.editor.locPlaceholder;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "placeHolder", {
        get: function () {
            return this.placeholder;
        },
        set: function (val) {
            this.placeholder = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "locPlaceHolder", {
        get: function () {
            return this.locPlaceholder;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "requiredErrorText", {
        /**
         * Specifies a custom error message for a [required item](#isRequired).
         */
        get: function () {
            return this.editor.requiredErrorText;
        },
        set: function (val) {
            this.editor.requiredErrorText = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "locRequiredErrorText", {
        get: function () {
            return this.editor.locRequiredErrorText;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "size", {
        /**
         * A value passed on to the [`size`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/size) attribute of the underlying `<input>` element.
         *
         * If you want to set a uniform `size` for all text box items, use the [`itemSize`](https://surveyjs.io/form-library/documentation/api-reference/multiple-text-entry-question-model#itemSize) within the Multiple Textboxes configuration.
         */
        get: function () {
            return this.editor.size;
        },
        set: function (val) {
            this.editor.size = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "defaultValueExpression", {
        /**
         * An [expression](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#expressions) used to calculate the default item value.
         * @see minValueExpression
         * @see maxValueExpression
         */
        get: function () {
            return this.editor.defaultValueExpression;
        },
        set: function (val) {
            this.editor.defaultValueExpression = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "minValueExpression", {
        /**
         * An [expression](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#expressions) used to calculate the minimum item value.
         * @see maxValueExpression
         * @see defaultValueExpression
         */
        get: function () {
            return this.editor.minValueExpression;
        },
        set: function (val) {
            this.editor.minValueExpression = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "maxValueExpression", {
        /**
         * An [expression](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#expressions) used to calculate the maximum item value.
         * @see minValueExpression
         * @see defaultValueExpression
         */
        get: function () {
            return this.editor.maxValueExpression;
        },
        set: function (val) {
            this.editor.maxValueExpression = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "validators", {
        /**
         * Item validators.
         *
         * [Data Validation](https://surveyjs.io/form-library/documentation/data-validation (linkStyle))
         */
        get: function () {
            return this.editor.validators;
        },
        set: function (val) {
            this.editor.validators = val;
        },
        enumerable: false,
        configurable: true
    });
    MultipleTextItemModel.prototype.getValidators = function () {
        return this.validators;
    };
    Object.defineProperty(MultipleTextItemModel.prototype, "maskType", {
        /**
         * Specifies the type of a mask applied to the input.
         *
         * Possible values:
         *
         * - `"none"` (default)
         * - `"numeric"`
         * - `"currency"`
         * - `"datetime"`
         * - `"pattern"`
         *
         * [View Demo](https://surveyjs.io/form-library/examples/masked-input-fields/ (linkStyle))
         * @see maskSettings
         */
        get: function () {
            return this.editor.maskType;
        },
        set: function (val) {
            this.editor.maskType = val;
            this.maskSettings = this.editor.maskSettings;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "maskSettings", {
        /**
         * An object with properties that configure the mask applied to the input.
         *
         * Available properties depend on the specified [`maskType`](#maskType) and belong to corresponding classes. Refer to the class APIs for a full list of properties:
         *
         * | `maskType` | Class |
         * | ---------- | ----- |
         * | `"numeric"` | [`InputMaskNumeric`](https://surveyjs.io/form-library/documentation/api-reference/inputmasknumeric) |
         * | `"currency"` | [`InputMaskCurrency`](https://surveyjs.io/form-library/documentation/api-reference/inputmaskcurrency) |
         * | `"datetime"` | [`InputMaskDateTime`](https://surveyjs.io/form-library/documentation/api-reference/inputmaskdatetime) |
         * | `"pattern"` | [`InputMaskPattern`](https://surveyjs.io/form-library/documentation/api-reference/inputmaskpattern) |
         *
         * [View Demo](https://surveyjs.io/form-library/examples/masked-input-fields/ (linkStyle))
         */
        get: function () {
            return this.getPropertyValue("maskSettings");
        },
        set: function (val) {
            this.setPropertyValue("maskSettings", val);
            if (this.editor.maskSettings !== val) {
                this.editor.maskSettings = val;
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "inputTextAlignment", {
        /**
         * Specifies text alignment within the input field.
         *
         * Possible values:
         *
         * - `"left"` - Aligns input text to the left side.
         * - `"right"` - Aligns input text to the right side.
         * - `"auto"` (default) - Applies right alignment if a [numeric or currency input mask](https://surveyjs.io/form-library/documentation/api-reference/multipletextitemmodel#maskType) is specified. Otherwise, applies left alignment.
         */
        get: function () {
            return this.editor.inputTextAlignment;
        },
        set: function (val) {
            this.editor.inputTextAlignment = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleTextItemModel.prototype, "value", {
        /**
         * An item value.
         */
        get: function () {
            return this.data ? this.data.getMultipleTextValue(this.name) : null;
        },
        set: function (value) {
            if (this.data != null) {
                this.data.setMultipleTextValue(this.name, value);
            }
        },
        enumerable: false,
        configurable: true
    });
    MultipleTextItemModel.prototype.isEmpty = function () {
        return this.editor.isEmpty();
    };
    MultipleTextItemModel.prototype.onValueChanged = function (newValue) {
        if (this.valueChangedCallback)
            this.valueChangedCallback(newValue);
    };
    //ISurveyImpl
    MultipleTextItemModel.prototype.getSurveyData = function () {
        return this;
    };
    MultipleTextItemModel.prototype.getSurvey = function () {
        return this.data ? this.data.getSurvey() : null;
    };
    MultipleTextItemModel.prototype.getTextProcessor = function () {
        return this.data ? this.data.getTextProcessor() : null;
    };
    //ISurveyData
    MultipleTextItemModel.prototype.getValue = function (name) {
        if (!this.data)
            return null;
        return this.data.getMultipleTextValue(name);
    };
    MultipleTextItemModel.prototype.setValue = function (name, value) {
        if (this.data) {
            this.data.setMultipleTextValue(name, value);
        }
    };
    MultipleTextItemModel.prototype.getVariable = function (name) {
        return undefined;
    };
    MultipleTextItemModel.prototype.setVariable = function (name, newValue) { };
    MultipleTextItemModel.prototype.getComment = function (name) {
        return null;
    };
    MultipleTextItemModel.prototype.setComment = function (name, newValue) { };
    MultipleTextItemModel.prototype.getAllValues = function () {
        if (this.data)
            return this.data.getAllValues();
        return this.value;
    };
    MultipleTextItemModel.prototype.getFilteredValues = function () {
        return this.getAllValues();
    };
    MultipleTextItemModel.prototype.getFilteredProperties = function () {
        return { survey: this.getSurvey() };
    };
    MultipleTextItemModel.prototype.findQuestionByName = function (name) {
        var survey = this.getSurvey();
        return !!survey ? survey.getQuestionByName(name) : null;
    };
    MultipleTextItemModel.prototype.getEditingSurveyElement = function () { return undefined; };
    //IValidatorOwner
    MultipleTextItemModel.prototype.getValidatorTitle = function () {
        return this.title;
    };
    Object.defineProperty(MultipleTextItemModel.prototype, "validatedValue", {
        get: function () {
            return this.value;
        },
        set: function (val) {
            this.value = val;
        },
        enumerable: false,
        configurable: true
    });
    MultipleTextItemModel.prototype.getDataFilteredValues = function () {
        return this.getFilteredValues();
    };
    MultipleTextItemModel.prototype.getDataFilteredProperties = function () {
        return this.getFilteredProperties();
    };
    return MultipleTextItemModel;
}(base_Base));

/**
 * A class that describes the Multiple Text question type.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/questiontype-multipletext/ (linkStyle))
 */
var question_multipletext_QuestionMultipleTextModel = /** @class */ (function (_super) {
    question_multipletext_extends(QuestionMultipleTextModel, _super);
    function QuestionMultipleTextModel(name) {
        var _this = _super.call(this, name) || this;
        _this.isMultipleItemValueChanging = false;
        _this.createNewArray("items", function (item) {
            item.setData(_this);
            if (_this.survey) {
                _this.survey.multipleTextItemAdded(_this, item);
            }
        });
        _this.registerPropertyChangedHandlers(["items", "colCount", "itemErrorLocation"], function () {
            _this.calcVisibleRows();
        });
        _this.registerPropertyChangedHandlers(["itemSize"], function () { _this.updateItemsSize(); });
        return _this;
    }
    QuestionMultipleTextModel.addDefaultItems = function (question) {
        var names = questionfactory_QuestionFactory.DefaultMutlipleTextItems;
        for (var i = 0; i < names.length; i++)
            question.addItem(names[i]);
    };
    QuestionMultipleTextModel.prototype.getType = function () {
        return "multipletext";
    };
    QuestionMultipleTextModel.prototype.setSurveyImpl = function (value, isLight) {
        _super.prototype.setSurveyImpl.call(this, value, isLight);
        for (var i = 0; i < this.items.length; i++) {
            this.items[i].setData(this);
        }
    };
    Object.defineProperty(QuestionMultipleTextModel.prototype, "isAllowTitleLeft", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMultipleTextModel.prototype, "hasSingleInput", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMultipleTextModel.prototype, "isContainer", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMultipleTextModel.prototype, "id", {
        get: function () {
            return this.getPropertyValue("id");
        },
        set: function (val) {
            var _a;
            (_a = this.items) === null || _a === void 0 ? void 0 : _a.map(function (item, index) { return item.editor.id = val + "_" + index; });
            this.setPropertyValue("id", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionMultipleTextModel.prototype.onSurveyLoad = function () {
        this.editorsOnSurveyLoad();
        _super.prototype.onSurveyLoad.call(this);
    };
    QuestionMultipleTextModel.prototype.setQuestionValue = function (newValue, updateIsAnswered) {
        if (updateIsAnswered === void 0) { updateIsAnswered = true; }
        _super.prototype.setQuestionValue.call(this, newValue, updateIsAnswered);
        this.performForEveryEditor(function (item) {
            item.editor.updateValueFromSurvey(item.value);
        });
        this.updateIsAnswered();
    };
    QuestionMultipleTextModel.prototype.onSurveyValueChanged = function (newValue) {
        _super.prototype.onSurveyValueChanged.call(this, newValue);
        this.performForEveryEditor(function (item) {
            item.editor.onSurveyValueChanged(item.value);
        });
    };
    QuestionMultipleTextModel.prototype.updateItemsSize = function () {
        this.performForEveryEditor(function (item) {
            item.editor.updateInputSize();
        });
    };
    QuestionMultipleTextModel.prototype.editorsOnSurveyLoad = function () {
        this.performForEveryEditor(function (item) {
            item.editor.onSurveyLoad();
        });
    };
    QuestionMultipleTextModel.prototype.performForEveryEditor = function (func) {
        for (var i = 0; i < this.items.length; i++) {
            var item = this.items[i];
            if (item.editor) {
                func(item);
            }
        }
    };
    Object.defineProperty(QuestionMultipleTextModel.prototype, "items", {
        /**
         * Gets or sets an array of [`MultipleTextItemModel`](https://surveyjs.io/form-library/documentation/api-reference/multipletextitemmodel) objects that represent input items.
         *
         * Each object in this array should have at least the following properties:
         *
         * ```js
         * {
         *   "name": any, // A unique value used to identify an input item and save an item value to survey results.
         *   "title": String // An item caption. When `title` is undefined, `name` is used. This property supports Markdown.
         * }
         * ```
         *
         * To enable Markdown support for the `title` property, implement Markdown-to-HTML conversion in the [`onTextMarkdown`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onTextMarkdown) event handler. For an example, refer to the following demo: [Convert Markdown to HTML with Showdown](https://surveyjs.io/form-library/examples/edit-survey-questions-markdown/).
         * @see itemTitleWidth
         * @see addItem
         */
        get: function () {
            return this.getPropertyValue("items");
        },
        set: function (val) {
            this.setPropertyValue("items", val);
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Adds a new input item.
     * @param name An item name.
     * @param title *(Optional)* An item title.
     * @see items
     */
    QuestionMultipleTextModel.prototype.addItem = function (name, title) {
        if (title === void 0) { title = null; }
        var item = this.createTextItem(name, title);
        this.items.push(item);
        return item;
    };
    QuestionMultipleTextModel.prototype.getItemByName = function (name) {
        for (var i = 0; i < this.items.length; i++) {
            if (this.items[i].name == name)
                return this.items[i];
        }
        return null;
    };
    QuestionMultipleTextModel.prototype.getElementsInDesign = function (includeHidden) {
        if (includeHidden === void 0) { includeHidden = false; }
        var elements;
        elements = _super.prototype.getElementsInDesign.call(this, includeHidden);
        return elements.concat(this.items);
    };
    QuestionMultipleTextModel.prototype.addConditionObjectsByContext = function (objects, context) {
        for (var i = 0; i < this.items.length; i++) {
            var item = this.items[i];
            objects.push({
                name: this.getValueName() + "." + item.name,
                text: this.processedTitle + "." + item.fullTitle,
                question: this,
            });
        }
    };
    QuestionMultipleTextModel.prototype.collectNestedQuestionsCore = function (questions, visibleOnly) {
        this.items.forEach(function (item) { return item.editor.collectNestedQuestions(questions, visibleOnly); });
    };
    QuestionMultipleTextModel.prototype.getConditionJson = function (operator, path) {
        if (operator === void 0) { operator = null; }
        if (path === void 0) { path = null; }
        if (!path)
            return _super.prototype.getConditionJson.call(this, operator);
        var item = this.getItemByName(path);
        if (!item)
            return null;
        var json = new jsonobject_JsonObject().toJsonObject(item);
        json["type"] = "text";
        return json;
    };
    QuestionMultipleTextModel.prototype.locStrsChanged = function () {
        _super.prototype.locStrsChanged.call(this);
        for (var i = 0; i < this.items.length; i++) {
            this.items[i].locStrsChanged();
        }
    };
    QuestionMultipleTextModel.prototype.localeChanged = function () {
        _super.prototype.localeChanged.call(this);
        for (var i = 0; i < this.items.length; i++) {
            this.items[i].localeChanged();
        }
    };
    Object.defineProperty(QuestionMultipleTextModel.prototype, "itemErrorLocation", {
        /**
         * Specifies the error message position relative to individual input fields.
         *
         * Possible values:
         *
         * - `"default"` (default) - Inherits the setting from the [`errorLocation`](#errorLocation) property.
         * - `"top"` - Displays error messages above input fields.
         * - `"bottom"` - Displays error messages below input fields.
         */
        get: function () {
            return this.getPropertyValue("itemErrorLocation");
        },
        set: function (val) {
            this.setPropertyValue("itemErrorLocation", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionMultipleTextModel.prototype.getQuestionErrorLocation = function () {
        if (this.itemErrorLocation !== "default")
            return this.itemErrorLocation;
        return this.getErrorLocation();
    };
    Object.defineProperty(QuestionMultipleTextModel.prototype, "showItemErrorOnTop", {
        get: function () {
            return this.getQuestionErrorLocation() == "top";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMultipleTextModel.prototype, "showItemErrorOnBottom", {
        get: function () {
            return this.getQuestionErrorLocation() == "bottom";
        },
        enumerable: false,
        configurable: true
    });
    QuestionMultipleTextModel.prototype.getChildErrorLocation = function (child) {
        return this.getQuestionErrorLocation();
    };
    QuestionMultipleTextModel.prototype.isNewValueCorrect = function (val) {
        return helpers_Helpers.isValueObject(val, true);
    };
    QuestionMultipleTextModel.prototype.supportGoNextPageAutomatic = function () {
        for (var i = 0; i < this.items.length; i++) {
            if (this.items[i].isEmpty())
                return false;
        }
        return true;
    };
    Object.defineProperty(QuestionMultipleTextModel.prototype, "colCount", {
        /**
         * The number of columns used to arrange input items. Accepts the following values: 1, 2, 3, 4, 5.
         *
         * Default value: 1
         */
        get: function () {
            return this.getPropertyValue("colCount");
        },
        set: function (val) {
            if (val < 1 || val > 5)
                return;
            this.setPropertyValue("colCount", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMultipleTextModel.prototype, "itemSize", {
        /**
         * A value passed on to the [`size`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/size) attribute of the underlying `<input>` elements.
         */
        get: function () {
            return this.getPropertyValue("itemSize");
        },
        set: function (val) {
            this.setPropertyValue("itemSize", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionMultipleTextModel.prototype, "itemTitleWidth", {
        /**
         * Specifies a uniform width for all text box titles. Accepts CSS values.
         *
         * Default value: `""` (the width of each title depends on the title length)
         * @see items
         * @see itemErrorLocation
         */
        get: function () {
            return this.getPropertyValue("itemTitleWidth") || "";
        },
        set: function (val) {
            this.setPropertyValue("itemTitleWidth", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionMultipleTextModel.prototype.onRowCreated = function (row) {
        return row;
    };
    QuestionMultipleTextModel.prototype.calcVisibleRows = function () {
        var colCount = this.colCount;
        var items = this.items;
        var index = 0;
        var row;
        var errorRow;
        var rows = [];
        for (var i = 0; i < items.length; i++) {
            if (index == 0) {
                row = this.onRowCreated(new question_multipletext_MutlipleTextRow());
                errorRow = this.onRowCreated(new MutlipleTextErrorRow());
                if (this.showItemErrorOnTop) {
                    rows.push(errorRow);
                    rows.push(row);
                }
                else {
                    rows.push(row);
                    rows.push(errorRow);
                }
            }
            row.cells.push(new question_multipletext_MultipleTextCell(items[i], this));
            errorRow.cells.push(new question_multipletext_MultipleTextErrorCell(items[i], this));
            index++;
            if (index >= colCount || i == items.length - 1) {
                index = 0;
                errorRow.onAfterCreated();
            }
        }
        this.rows = rows;
    };
    QuestionMultipleTextModel.prototype.getRows = function () {
        if (helpers_Helpers.isValueEmpty(this.rows)) {
            this.calcVisibleRows();
        }
        return this.rows;
    };
    QuestionMultipleTextModel.prototype.onValueChanged = function () {
        _super.prototype.onValueChanged.call(this);
        this.onItemValueChanged();
    };
    QuestionMultipleTextModel.prototype.createTextItem = function (name, title) {
        return new question_multipletext_MultipleTextItemModel(name, title);
    };
    QuestionMultipleTextModel.prototype.onItemValueChanged = function () {
        if (this.isMultipleItemValueChanging)
            return;
        for (var i = 0; i < this.items.length; i++) {
            var itemValue = null;
            if (this.value && this.items[i].name in this.value) {
                itemValue = this.value[this.items[i].name];
            }
            this.items[i].onValueChanged(itemValue);
        }
    };
    QuestionMultipleTextModel.prototype.runCondition = function (values, properties) {
        _super.prototype.runCondition.call(this, values, properties);
        this.items.forEach(function (item) { return item.editor.runCondition(values, properties); });
    };
    QuestionMultipleTextModel.prototype.getIsRunningValidators = function () {
        if (_super.prototype.getIsRunningValidators.call(this))
            return true;
        for (var i = 0; i < this.items.length; i++) {
            if (this.items[i].editor.isRunningValidators)
                return true;
        }
        return false;
    };
    QuestionMultipleTextModel.prototype.hasErrors = function (fireCallback, rec) {
        var _this = this;
        if (fireCallback === void 0) { fireCallback = true; }
        if (rec === void 0) { rec = null; }
        var res = false;
        for (var i = 0; i < this.items.length; i++) {
            this.items[i].editor.onCompletedAsyncValidators = function (hasErrors) {
                _this.raiseOnCompletedAsyncValidators();
            };
            if (!!rec &&
                rec.isOnValueChanged === true &&
                this.items[i].editor.isEmpty())
                continue;
            res = this.items[i].editor.hasErrors(fireCallback, rec) || res;
        }
        return _super.prototype.hasErrors.call(this, fireCallback) || res;
    };
    QuestionMultipleTextModel.prototype.getAllErrors = function () {
        var result = _super.prototype.getAllErrors.call(this);
        for (var i = 0; i < this.items.length; i++) {
            var errors = this.items[i].editor.getAllErrors();
            if (errors && errors.length > 0) {
                result = result.concat(errors);
            }
        }
        return result;
    };
    QuestionMultipleTextModel.prototype.clearErrors = function () {
        _super.prototype.clearErrors.call(this);
        for (var i = 0; i < this.items.length; i++) {
            this.items[i].editor.clearErrors();
        }
    };
    QuestionMultipleTextModel.prototype.getContainsErrors = function () {
        var res = _super.prototype.getContainsErrors.call(this);
        if (res)
            return res;
        var items = this.items;
        for (var i = 0; i < items.length; i++) {
            if (items[i].editor.containsErrors)
                return true;
        }
        return false;
    };
    QuestionMultipleTextModel.prototype.getIsAnswered = function () {
        if (!_super.prototype.getIsAnswered.call(this))
            return false;
        for (var i = 0; i < this.items.length; i++) {
            var editor = this.items[i].editor;
            if (editor.isVisible && !editor.isAnswered)
                return false;
        }
        return true;
    };
    QuestionMultipleTextModel.prototype.getProgressInfo = function () {
        var elements = [];
        for (var i = 0; i < this.items.length; i++) {
            elements.push(this.items[i].editor);
        }
        return survey_element_SurveyElement.getProgressInfoByElements(elements, this.isRequired);
    };
    QuestionMultipleTextModel.prototype.getDisplayValueCore = function (keysAsText, value) {
        if (!value)
            return value;
        var res = {};
        for (var i = 0; i < this.items.length; i++) {
            var item = this.items[i];
            var val = value[item.name];
            if (helpers_Helpers.isValueEmpty(val))
                continue;
            var itemName = item.name;
            if (keysAsText && !!item.title) {
                itemName = item.title;
            }
            res[itemName] = item.editor.getDisplayValue(keysAsText, val);
        }
        return res;
    };
    QuestionMultipleTextModel.prototype.allowMobileInDesignMode = function () {
        return true;
    };
    //IMultipleTextData
    QuestionMultipleTextModel.prototype.getMultipleTextValue = function (name) {
        if (!this.value)
            return null;
        return this.value[name];
    };
    QuestionMultipleTextModel.prototype.setMultipleTextValue = function (name, value) {
        this.isMultipleItemValueChanging = true;
        if (this.isValueEmpty(value)) {
            value = undefined;
        }
        var newValue = this.value;
        if (!newValue) {
            newValue = {};
        }
        newValue[name] = value;
        this.setNewValue(newValue);
        this.isMultipleItemValueChanging = false;
    };
    QuestionMultipleTextModel.prototype.getItemDefaultValue = function (name) {
        return !!this.defaultValue ? this.defaultValue[name] : null;
    };
    QuestionMultipleTextModel.prototype.getTextProcessor = function () {
        return this.textProcessor;
    };
    QuestionMultipleTextModel.prototype.getAllValues = function () {
        return this.data ? this.data.getAllValues() : null;
    };
    QuestionMultipleTextModel.prototype.getIsRequiredText = function () {
        return this.survey ? this.survey.requiredText : "";
    };
    //IPanel
    QuestionMultipleTextModel.prototype.addElement = function (element, index) { };
    QuestionMultipleTextModel.prototype.removeElement = function (element) {
        return false;
    };
    QuestionMultipleTextModel.prototype.getQuestionTitleLocation = function () {
        return "left";
    };
    QuestionMultipleTextModel.prototype.getQuestionTitleWidth = function () {
        return undefined;
    };
    QuestionMultipleTextModel.prototype.getColumsForElement = function (el) {
        return [];
    };
    QuestionMultipleTextModel.prototype.updateColumns = function () { };
    QuestionMultipleTextModel.prototype.getQuestionStartIndex = function () {
        return this.getStartIndex();
    };
    QuestionMultipleTextModel.prototype.getChildrenLayoutType = function () {
        return "row";
    };
    QuestionMultipleTextModel.prototype.elementWidthChanged = function (el) { };
    Object.defineProperty(QuestionMultipleTextModel.prototype, "elements", {
        get: function () {
            return [];
        },
        enumerable: false,
        configurable: true
    });
    QuestionMultipleTextModel.prototype.indexOf = function (el) {
        return -1;
    };
    QuestionMultipleTextModel.prototype.ensureRowsVisibility = function () {
        // do nothing
    };
    QuestionMultipleTextModel.prototype.validateContainerOnly = function () {
        // do nothing
    };
    QuestionMultipleTextModel.prototype.onQuestionValueChanged = function (el) {
        // do nothing
    };
    QuestionMultipleTextModel.prototype.getItemLabelCss = function (item) {
        return new CssClassBuilder()
            .append(this.cssClasses.itemLabel)
            .append(this.cssClasses.itemLabelDisabled, this.isDisabledStyle)
            .append(this.cssClasses.itemLabelReadOnly, this.isReadOnlyStyle)
            .append(this.cssClasses.itemLabelPreview, this.isPreviewStyle)
            .append(this.cssClasses.itemLabelAnswered, item.editor.isAnswered)
            .append(this.cssClasses.itemLabelAllowFocus, !this.isDesignMode)
            .append(this.cssClasses.itemLabelOnError, item.editor.errors.length > 0)
            .append(this.cssClasses.itemWithCharacterCounter, !!item.getMaxLength())
            .toString();
    };
    QuestionMultipleTextModel.prototype.getItemCss = function () {
        return new CssClassBuilder().append(this.cssClasses.item).toString();
    };
    QuestionMultipleTextModel.prototype.getItemTitleCss = function () {
        return new CssClassBuilder().append(this.cssClasses.itemTitle).toString();
    };
    question_multipletext_decorate([
        propertyArray()
    ], QuestionMultipleTextModel.prototype, "rows", void 0);
    return QuestionMultipleTextModel;
}(question_Question));

var question_multipletext_MutlipleTextRow = /** @class */ (function (_super) {
    question_multipletext_extends(MutlipleTextRow, _super);
    function MutlipleTextRow() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.isVisible = true;
        _this.cells = [];
        return _this;
    }
    question_multipletext_decorate([
        jsonobject_property()
    ], MutlipleTextRow.prototype, "isVisible", void 0);
    question_multipletext_decorate([
        propertyArray()
    ], MutlipleTextRow.prototype, "cells", void 0);
    return MutlipleTextRow;
}(base_Base));

var MutlipleTextErrorRow = /** @class */ (function (_super) {
    question_multipletext_extends(MutlipleTextErrorRow, _super);
    function MutlipleTextErrorRow() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MutlipleTextErrorRow.prototype.onAfterCreated = function () {
        var _this = this;
        var callback = function () {
            _this.isVisible = _this.cells.some(function (cell) { var _a, _b; return ((_a = cell.item) === null || _a === void 0 ? void 0 : _a.editor) && ((_b = cell.item) === null || _b === void 0 ? void 0 : _b.editor.hasVisibleErrors); });
        };
        this.cells.forEach(function (cell) {
            var _a, _b;
            if ((_a = cell.item) === null || _a === void 0 ? void 0 : _a.editor) {
                (_b = cell.item) === null || _b === void 0 ? void 0 : _b.editor.registerFunctionOnPropertyValueChanged("hasVisibleErrors", callback);
            }
        });
        callback();
    };
    return MutlipleTextErrorRow;
}(question_multipletext_MutlipleTextRow));

var question_multipletext_MultipleTextCell = /** @class */ (function () {
    function MultipleTextCell(item, question) {
        this.item = item;
        this.question = question;
        this.isErrorsCell = false;
    }
    MultipleTextCell.prototype.getClassName = function () {
        return new CssClassBuilder().append(this.question.cssClasses.cell).toString();
    };
    Object.defineProperty(MultipleTextCell.prototype, "className", {
        get: function () {
            return this.getClassName();
        },
        enumerable: false,
        configurable: true
    });
    return MultipleTextCell;
}());

var question_multipletext_MultipleTextErrorCell = /** @class */ (function (_super) {
    question_multipletext_extends(MultipleTextErrorCell, _super);
    function MultipleTextErrorCell() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.isErrorsCell = true;
        return _this;
    }
    MultipleTextErrorCell.prototype.getClassName = function () {
        return new CssClassBuilder()
            .append(_super.prototype.getClassName.call(this))
            .append(this.question.cssClasses.cellError)
            .append(this.question.cssClasses.cellErrorTop, this.question.showItemErrorOnTop)
            .append(this.question.cssClasses.cellErrorBottom, this.question.showItemErrorOnBottom)
            .toString();
    };
    return MultipleTextErrorCell;
}(question_multipletext_MultipleTextCell));

Serializer.addClass("multipletextitem", [
    { name: "!name", isUnique: true },
    "isRequired:boolean",
    { name: "placeholder", alternativeName: "placeHolder", serializationProperty: "locPlaceholder" },
    {
        name: "inputType",
        default: "text",
        choices: settings.questions.inputTypes,
    },
    {
        name: "maskType",
        default: "none",
        visibleIndex: 0,
        dependsOn: "inputType",
        visibleIf: function (obj) {
            return obj.inputType === "text";
        },
        choices: function (obj) {
            var choices = getAvailableMaskTypeChoices();
            return choices;
        }
    },
    {
        name: "maskSettings:masksettings",
        className: "masksettings",
        visibleIndex: 1,
        dependsOn: "inputType",
        visibleIf: function (obj) {
            return obj.inputType === "text";
        },
        onGetValue: function (obj) {
            return obj.maskSettings.getData();
        },
        onSetValue: function (obj, value) {
            obj.maskSettings.setData(value);
        },
    },
    { name: "inputTextAlignment", default: "auto", choices: ["left", "right", "auto"] },
    { name: "title", serializationProperty: "locTitle" },
    { name: "maxLength:number", default: -1 },
    { name: "size:number", minValue: 0 },
    {
        name: "requiredErrorText:text",
        serializationProperty: "locRequiredErrorText",
    },
    { name: "defaultValueExpression:expression", visible: false },
    {
        name: "minValueExpression:expression",
        category: "logic",
        dependsOn: "inputType",
        visibleIf: function (obj) {
            return isMinMaxType(obj);
        },
    },
    {
        name: "maxValueExpression:expression",
        category: "logic",
        dependsOn: "inputType",
        visibleIf: function (obj) {
            return isMinMaxType(obj);
        },
    },
    {
        name: "validators:validators",
        baseClassName: "surveyvalidator",
        classNamePart: "validator",
    },
], function () {
    return new question_multipletext_MultipleTextItemModel("");
});
Serializer.addClass("multipletext", [
    { name: "!items:textitems", className: "multipletextitem", isArray: true },
    { name: "itemSize:number", minValue: 0, visible: false },
    { name: "colCount:number", default: 1, choices: [1, 2, 3, 4, 5] },
    { name: "itemErrorLocation", default: "default", choices: ["default", "top", "bottom"], visible: false },
    { name: "itemTitleWidth", category: "layout" }
], function () {
    return new question_multipletext_QuestionMultipleTextModel("");
}, "question");
questionfactory_QuestionFactory.Instance.registerQuestion("multipletext", function (name) {
    var q = new question_multipletext_QuestionMultipleTextModel(name);
    question_multipletext_QuestionMultipleTextModel.addDefaultItems(q);
    return q;
});

// CONCATENATED MODULE: ./packages/survey-core/src/flowpanel.ts
var flowpanel_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();



/**
 * The flow panel object. It is a container with flow layout where you can mix questions with markdown text.
 *
 */
var flowpanel_FlowPanelModel = /** @class */ (function (_super) {
    flowpanel_extends(FlowPanelModel, _super);
    function FlowPanelModel(name) {
        if (name === void 0) { name = ""; }
        var _this = _super.call(this, name) || this;
        _this.createLocalizableString("content", _this, true);
        _this.registerPropertyChangedHandlers(["content"], function () {
            _this.onContentChanged();
        });
        return _this;
    }
    FlowPanelModel.prototype.getType = function () {
        return "flowpanel";
    };
    FlowPanelModel.prototype.getChildrenLayoutType = function () {
        return "flow";
    };
    FlowPanelModel.prototype.onSurveyLoad = function () {
        _super.prototype.onSurveyLoad.call(this);
        this.onContentChanged();
    };
    Object.defineProperty(FlowPanelModel.prototype, "content", {
        get: function () {
            return this.getLocalizableStringText("content");
        },
        set: function (val) {
            this.setLocalizableStringText("content", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FlowPanelModel.prototype, "locContent", {
        get: function () {
            return this.getLocalizableString("content");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FlowPanelModel.prototype, "html", {
        get: function () {
            return this.getPropertyValue("html", "");
        },
        set: function (val) {
            this.setPropertyValue("html", val);
        },
        enumerable: false,
        configurable: true
    });
    FlowPanelModel.prototype.onContentChanged = function () {
        var html = "";
        if (!!this.onCustomHtmlProducing) {
            html = this.onCustomHtmlProducing();
        }
        else {
            html = this.produceHtml();
        }
        this.html = html;
        if (!!this.contentChangedCallback)
            this.contentChangedCallback();
    };
    FlowPanelModel.prototype.produceHtml = function () {
        var html = [];
        //contentElementNamePrefix
        var regEx = /{(.*?(element:)[^$].*?)}/g;
        var str = this.content;
        var startIndex = 0;
        var res = null;
        while ((res = regEx.exec(str)) !== null) {
            if (res.index > startIndex) {
                html.push(str.substring(startIndex, res.index));
                startIndex = res.index;
            }
            var question = this.getQuestionFromText(res[0]);
            if (!!question) {
                html.push(this.getHtmlForQuestion(question));
            }
            else {
                html.push(str.substring(startIndex, res.index + res[0].length));
            }
            startIndex = res.index + res[0].length;
        }
        if (startIndex < str.length) {
            html.push(str.substring(startIndex, str.length));
        }
        return html.join("").replace(new RegExp("<br>", "g"), "<br/>");
    };
    FlowPanelModel.prototype.getQuestionFromText = function (str) {
        str = str.substring(1, str.length - 1);
        str = str.replace(FlowPanelModel.contentElementNamePrefix, "").trim();
        return this.getQuestionByName(str);
    };
    FlowPanelModel.prototype.getHtmlForQuestion = function (question) {
        if (!!this.onGetHtmlForQuestion)
            return this.onGetHtmlForQuestion(question);
        return "";
    };
    FlowPanelModel.prototype.getQuestionHtmlId = function (question) {
        return this.name + "_" + question.id;
    };
    FlowPanelModel.prototype.onAddElement = function (element, index) {
        _super.prototype.onAddElement.call(this, element, index);
        this.addElementToContent(element);
        element.renderWidth = "";
    };
    FlowPanelModel.prototype.onRemoveElement = function (element) {
        var searchStr = this.getElementContentText(element);
        this.content = this.content.replace(searchStr, "");
        _super.prototype.onRemoveElement.call(this, element);
    };
    FlowPanelModel.prototype.dragDropMoveElement = function (src, target, targetIndex) { };
    FlowPanelModel.prototype.addElementToContent = function (element) {
        if (this.isLoadingFromJson)
            return;
        var text = this.getElementContentText(element);
        if (!this.insertTextAtCursor(text)) {
            this.content = this.content + text;
        }
    };
    FlowPanelModel.prototype.insertTextAtCursor = function (text, prevName) {
        if (prevName === void 0) { prevName = null; }
        if (!this.isDesignMode || !DomWindowHelper.isAvailable())
            return false;
        var sel = DomWindowHelper.getSelection();
        if (sel.getRangeAt && sel.rangeCount) {
            var range = sel.getRangeAt(0);
            range.deleteContents();
            var textElement = new Text(text);
            range.insertNode(textElement);
            var self = this;
            if (self.getContent) {
                var str = self.getContent(prevName);
                this.content = str;
            }
            return true;
        }
        return false;
    };
    FlowPanelModel.prototype.getElementContentText = function (element) {
        return "{" + FlowPanelModel.contentElementNamePrefix + element.name + "}";
    };
    FlowPanelModel.contentElementNamePrefix = "element:";
    return FlowPanelModel;
}(panel_PanelModel));

Serializer.addClass("flowpanel", [{ name: "content:html", serializationProperty: "locContent" }], function () {
    return new flowpanel_FlowPanelModel();
}, "panel");

// CONCATENATED MODULE: ./packages/survey-core/src/template-renderer.ts


// CONCATENATED MODULE: ./packages/survey-core/src/defaultTitle.ts

var defaultTitle_DefaultTitleModel = /** @class */ (function () {
    function DefaultTitleModel() {
    }
    DefaultTitleModel.getIconCss = function (cssClasses, isCollapsed) {
        return new CssClassBuilder()
            .append(cssClasses.icon)
            .append(cssClasses.iconExpanded, !isCollapsed)
            .toString();
    };
    return DefaultTitleModel;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/questionnonvalue.ts
var questionnonvalue_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();


/**
 * A base class for question types that cannot have a value ([Html](https://surveyjs.io/form-library/documentation/questionhtmlmodel), [Image](https://surveyjs.io/form-library/documentation/questionimagemodel)).
 *
 * This class does not implement new functionality&mdash;it only redefines default values of certain properties inherited from the [`Question`](https://surveyjs.io/form-library/documentation/question) class.
 */
var QuestionNonValue = /** @class */ (function (_super) {
    questionnonvalue_extends(QuestionNonValue, _super);
    function QuestionNonValue(name) {
        return _super.call(this, name) || this;
    }
    QuestionNonValue.prototype.getType = function () {
        return "nonvalue";
    };
    Object.defineProperty(QuestionNonValue.prototype, "hasInput", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionNonValue.prototype, "hasTitle", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    QuestionNonValue.prototype.getTitleLocation = function () {
        return "";
    };
    Object.defineProperty(QuestionNonValue.prototype, "hasComment", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    QuestionNonValue.prototype.hasErrors = function (fireCallback, rec) {
        if (fireCallback === void 0) { fireCallback = true; }
        if (rec === void 0) { rec = null; }
        return false;
    };
    QuestionNonValue.prototype.getAllErrors = function () {
        return [];
    };
    QuestionNonValue.prototype.supportGoNextPageAutomatic = function () {
        return false;
    };
    QuestionNonValue.prototype.addConditionObjectsByContext = function (objects, context) { };
    QuestionNonValue.prototype.getConditionJson = function (operator, path) {
        if (operator === void 0) { operator = null; }
        if (path === void 0) { path = null; }
        return null;
    };
    Object.defineProperty(QuestionNonValue.prototype, "ariaRole", {
        get: function () {
            return null;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionNonValue.prototype, "ariaRequired", {
        get: function () {
            return null;
        },
        enumerable: false,
        configurable: true
    });
    return QuestionNonValue;
}(question_Question));

Serializer.addClass("nonvalue", [
    { name: "title", visible: false },
    { name: "description", visible: false },
    { name: "valueName", visible: false },
    { name: "enableIf", visible: false },
    { name: "defaultValue", visible: false },
    { name: "correctAnswer", visible: false },
    { name: "clearIfInvisible", visible: false },
    { name: "isRequired", visible: false, isSerializable: false },
    { name: "requiredErrorText", visible: false },
    { name: "readOnly", visible: false },
    { name: "requiredIf", visible: false },
    { name: "validators", visible: false },
    { name: "titleLocation", visible: false },
    { name: "showCommentArea", visible: false },
    { name: "useDisplayValuesInDynamicTexts", alternativeName: "useDisplayValuesInTitle", visible: false },
], function () {
    return new QuestionNonValue("");
}, "question");

// CONCATENATED MODULE: ./packages/survey-core/src/question_empty.ts
var question_empty_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();


/**
 * A Model for an question that renders empty "div" tag. It used as a base class for some custom widgets
 */
var QuestionEmptyModel = /** @class */ (function (_super) {
    question_empty_extends(QuestionEmptyModel, _super);
    function QuestionEmptyModel(name) {
        return _super.call(this, name) || this;
    }
    QuestionEmptyModel.prototype.getType = function () {
        return "empty";
    };
    return QuestionEmptyModel;
}(question_Question));

Serializer.addClass("empty", [], function () {
    return new QuestionEmptyModel("");
}, "question");

// CONCATENATED MODULE: ./packages/survey-core/src/question_checkbox.ts
var question_checkbox_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();








/**
 * A class that describes the Checkboxes question type.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/questiontype-checkbox/ (linkStyle))
 */
var question_checkbox_QuestionCheckboxModel = /** @class */ (function (_super) {
    question_checkbox_extends(QuestionCheckboxModel, _super);
    function QuestionCheckboxModel(name) {
        var _this = _super.call(this, name) || this;
        _this.invisibleOldValues = {};
        _this.isChangingValueOnClearIncorrect = false;
        _this.selectAllItemValue = new itemvalue_ItemValue("");
        _this.selectAllItemValue.id = "selectall";
        var selectAllItemText = _this.createLocalizableString("selectAllText", _this.selectAllItem, true, "selectAllItemText");
        _this.selectAllItem.locOwner = _this;
        _this.selectAllItem.setLocText(selectAllItemText);
        _this.registerPropertyChangedHandlers(["showSelectAllItem", "selectAllText"], function () {
            _this.onVisibleChoicesChanged();
        });
        return _this;
    }
    QuestionCheckboxModel.prototype.getDefaultItemComponent = function () {
        return "survey-checkbox-item";
    };
    QuestionCheckboxModel.prototype.getType = function () {
        return "checkbox";
    };
    QuestionCheckboxModel.prototype.onCreating = function () {
        _super.prototype.onCreating.call(this);
        this.createNewArray("renderedValue");
        this.createNewArray("value");
    };
    QuestionCheckboxModel.prototype.getFirstInputElementId = function () {
        return this.inputId + "_0";
    };
    Object.defineProperty(QuestionCheckboxModel.prototype, "valuePropertyName", {
        /**
         * Specifies a property name used to store selected values.
         *
         * Set this property if you want to store selected values in an array of objects instead of an array of primitive values. For example, if you set `valuePropertyName` to `"car"`, the `value` property will contain an array of objects `[{ car: "Ford" }, { car: "Tesla" }]`, not an array of string values `[ "Ford", "Tesla" ]`.
         */
        get: function () {
            return this.getPropertyValue("valuePropertyName");
        },
        set: function (val) {
            this.setPropertyValue("valuePropertyName", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionCheckboxModel.prototype.getQuestionFromArray = function (name, index) {
        if (!!name && name === this.valuePropertyName) {
            var v = this.value;
            if (Array.isArray(v) && index < v.length)
                return this;
        }
        return null;
    };
    Object.defineProperty(QuestionCheckboxModel.prototype, "selectAllItem", {
        /**
         * Returns the "Select All" choice item. Use this property to change the item's `value` or `text`.
         * @see showSelectAllItem
         */
        get: function () {
            return this.selectAllItemValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCheckboxModel.prototype, "selectAllText", {
        /**
         * Gets or sets a caption for the "Select All" choice item.
         * @see showSelectAllItem
         */
        get: function () {
            return this.getLocalizableStringText("selectAllText");
        },
        set: function (val) {
            this.setLocalizableStringText("selectAllText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCheckboxModel.prototype, "locSelectAllText", {
        get: function () {
            return this.getLocalizableString("selectAllText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCheckboxModel.prototype, "showSelectAllItem", {
        /**
         * Enable this property to display a "Select All" item. When users select it, all other choice items, except "Other" and "None", also become selected.
         * @see selectAll
         * @see isAllSelected
         * @see separateSpecialChoices
         */
        get: function () {
            return this.getPropertyValue("showSelectAllItem");
        },
        set: function (val) {
            this.setPropertyValue("showSelectAllItem", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCheckboxModel.prototype, "hasSelectAll", {
        get: function () {
            return this.showSelectAllItem;
        },
        set: function (val) {
            this.showSelectAllItem = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCheckboxModel.prototype, "isAllSelected", {
        /**
         * Returns `true` if all choice items, except "Other" and "None", are selected.
         * @see showSelectAllItem
         */
        get: function () {
            var noneItems = this.getNoneItems();
            for (var i = 0; i < noneItems.length; i++) {
                if (this.isItemSelected(noneItems[i]))
                    return false;
            }
            var items = this.getVisibleEnableItems();
            if (items.length === 0)
                return false;
            var val = this.value;
            if (!val || !Array.isArray(val) || val.length === 0)
                return false;
            if (val.length < items.length)
                return false;
            var rVal = [];
            for (var i = 0; i < val.length; i++) {
                rVal.push(this.getRealValue(val[i]));
            }
            for (var i = 0; i < items.length; i++) {
                if (rVal.indexOf(items[i].value) < 0)
                    return false;
            }
            return true;
        },
        set: function (val) {
            if (val) {
                this.selectAll();
            }
            else {
                this.clearValue(true);
            }
        },
        enumerable: false,
        configurable: true
    });
    QuestionCheckboxModel.prototype.toggleSelectAll = function () {
        this.isAllSelected = !this.isAllSelected;
    };
    /**
     * Selects all choice items, except "Other" and "None".
     *
     * To clear selection, call the `clearValue()` method.
     * @see clearValue
     */
    QuestionCheckboxModel.prototype.selectAll = function () {
        var val = [];
        var items = this.getVisibleEnableItems();
        for (var i = 0; i < items.length; i++) {
            val.push(items[i].value);
        }
        this.renderedValue = val;
    };
    QuestionCheckboxModel.prototype.clickItemHandler = function (item, checked) {
        if (this.isReadOnlyAttr)
            return;
        if (item === this.selectAllItem) {
            if (checked === true || checked === false) {
                this.isAllSelected = checked;
            }
            else {
                this.toggleSelectAll();
            }
        }
        else {
            if (this.isNoneItem(item)) {
                this.renderedValue = checked ? [item.value] : [];
            }
            else {
                var newValue = [].concat(this.renderedValue || []);
                var index = newValue.indexOf(item.value);
                if (checked) {
                    if (index < 0) {
                        newValue.push(item.value);
                    }
                }
                else {
                    if (index > -1) {
                        newValue.splice(index, 1);
                    }
                }
                this.renderedValue = newValue;
            }
        }
    };
    QuestionCheckboxModel.prototype.isItemSelectedCore = function (item) {
        if (item === this.selectAllItem)
            return this.isAllSelected;
        var val = this.renderedValue;
        if (!val || !Array.isArray(val))
            return false;
        for (var i = 0; i < val.length; i++) {
            if (this.isTwoValueEquals(val[i], item.value))
                return true;
        }
        return false;
    };
    QuestionCheckboxModel.prototype.getRealValue = function (val) {
        if (!val)
            return val;
        return !this.valuePropertyName ? val : val[this.valuePropertyName];
    };
    Object.defineProperty(QuestionCheckboxModel.prototype, "isValueArray", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCheckboxModel.prototype, "maxSelectedChoices", {
        /**
         * Specifies the maximum number of selected choices.
         *
         * Default value: 0 (unlimited)
         *
         * > This property only limits the number of choice items that can be selected by users. You can select any number of choice items in code, regardless of the `maxSelectedChoices` value.
         * @see minSelectedChoices
         */
        get: function () {
            return this.getPropertyValue("maxSelectedChoices");
        },
        set: function (val) {
            if (val < 0)
                val = 0;
            this.setPropertyValue("maxSelectedChoices", val);
            this.filterItems();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCheckboxModel.prototype, "minSelectedChoices", {
        /**
         * Specifies the minimum number of selected choices.
         *
         * Default value: 0 (unlimited)
         *
         * > This property only limits the number of choice items that can be selected by users. You can select any number of choice items in code, regardless of the `minSelectedChoices` value.
         * @see maxSelectedChoices
         */
        get: function () {
            return this.getPropertyValue("minSelectedChoices");
        },
        set: function (val) {
            if (val < 0)
                val = 0;
            this.setPropertyValue("minSelectedChoices", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCheckboxModel.prototype, "selectedChoices", {
        /**
         * An array of selected choice items. Includes the "Other" and "None" choice items if they are selected, but not "Select All". Items are sorted in the order they were selected.
         * @see visibleChoices
         * @see enabledChoices
         */
        get: function () {
            var val = this.renderedValue;
            var visChoices = this.visibleChoices;
            var selectedItemValues = this.selectedItemValues;
            if (this.isEmpty())
                return [];
            var allChoices = !!this.defaultSelectedItemValues ? [].concat(this.defaultSelectedItemValues, visChoices) : visChoices;
            var itemValues = val.map(function (item) { return itemvalue_ItemValue.getItemByValue(allChoices, item); }).filter(function (item) { return !!item; });
            if (!itemValues.length && !selectedItemValues) {
                this.updateSelectedItemValues();
            }
            var validValues = this.validateItemValues(itemValues);
            return validValues;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCheckboxModel.prototype, "selectedItems", {
        get: function () { return this.selectedChoices; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCheckboxModel.prototype, "hasFilteredValue", {
        get: function () { return !!this.valuePropertyName; },
        enumerable: false,
        configurable: true
    });
    QuestionCheckboxModel.prototype.getFilteredName = function () {
        var res = _super.prototype.getFilteredName.call(this);
        if (this.hasFilteredValue) {
            res += "-unwrapped";
        }
        return res;
    };
    QuestionCheckboxModel.prototype.getFilteredValue = function () {
        if (this.hasFilteredValue)
            return this.renderedValue;
        return _super.prototype.getFilteredValue.call(this);
    };
    QuestionCheckboxModel.prototype.getMultipleSelectedItems = function () {
        return this.selectedChoices;
    };
    QuestionCheckboxModel.prototype.validateItemValues = function (itemValues) {
        var _this = this;
        if (!!itemValues.length)
            return itemValues;
        var selectedItemValues = this.selectedItemValues;
        if (!!selectedItemValues && !!selectedItemValues.length) {
            this.defaultSelectedItemValues = [].concat(selectedItemValues);
            return selectedItemValues;
        }
        var val = this.renderedValue;
        return val.map(function (item) { return _this.createItemValue(item); });
    };
    QuestionCheckboxModel.prototype.getAnswerCorrectIgnoreOrder = function () { return true; };
    QuestionCheckboxModel.prototype.onCheckForErrors = function (errors, isOnValueChanged) {
        _super.prototype.onCheckForErrors.call(this, errors, isOnValueChanged);
        if (isOnValueChanged)
            return;
        if (this.minSelectedChoices > 0 && this.checkMinSelectedChoicesUnreached()) {
            var minError = new CustomError(this.getLocalizationFormatString("minSelectError", this.minSelectedChoices), this);
            errors.push(minError);
        }
    };
    QuestionCheckboxModel.prototype.onVisibleChoicesChanged = function () {
        _super.prototype.onVisibleChoicesChanged.call(this);
        this.updateSelectAllItemProps();
    };
    QuestionCheckboxModel.prototype.onEnableItemCallBack = function (item) {
        if (!this.shouldCheckMaxSelectedChoices())
            return true;
        return this.isItemSelected(item);
    };
    QuestionCheckboxModel.prototype.onAfterRunItemsEnableCondition = function () {
        this.updateSelectAllItemProps();
        if (this.maxSelectedChoices < 1) {
            this.otherItem.setIsEnabled(true);
            return;
        }
        if (this.hasOther) {
            this.otherItem.setIsEnabled(!this.shouldCheckMaxSelectedChoices() || this.isOtherSelected);
        }
    };
    QuestionCheckboxModel.prototype.updateSelectAllItemProps = function () {
        if (!this.hasSelectAll)
            return;
        this.selectAllItem.setIsEnabled(this.getSelectAllEnabled());
    };
    QuestionCheckboxModel.prototype.getSelectAllEnabled = function () {
        if (!this.hasSelectAll)
            return true;
        var items = this.activeChoices;
        var visCount = this.getVisibleEnableItems().length;
        var max = this.maxSelectedChoices;
        if (max > 0 && max < visCount)
            return false;
        return visCount > 0;
    };
    QuestionCheckboxModel.prototype.getVisibleEnableItems = function () {
        var res = new Array();
        var items = this.activeChoices;
        for (var i = 0; i < items.length; i++) {
            var item = items[i];
            if (item.isEnabled && item.isVisible) {
                res.push(item);
            }
        }
        return res;
    };
    QuestionCheckboxModel.prototype.shouldCheckMaxSelectedChoices = function () {
        if (this.maxSelectedChoices < 1)
            return false;
        var val = this.value;
        var len = !Array.isArray(val) ? 0 : val.length;
        return len >= this.maxSelectedChoices;
    };
    QuestionCheckboxModel.prototype.checkMinSelectedChoicesUnreached = function () {
        if (this.minSelectedChoices < 1)
            return false;
        var val = this.value;
        var len = !Array.isArray(val) ? 0 : val.length;
        return len < this.minSelectedChoices;
    };
    QuestionCheckboxModel.prototype.getItemClassCore = function (item, options) {
        var __dummy_value = this.value; //trigger dependencies from koValue for knockout
        options.isSelectAllItem = item === this.selectAllItem;
        return new CssClassBuilder()
            .append(_super.prototype.getItemClassCore.call(this, item, options))
            .append(this.cssClasses.itemSelectAll, options.isSelectAllItem)
            .toString();
    };
    QuestionCheckboxModel.prototype.updateValueFromSurvey = function (newValue, clearData) {
        _super.prototype.updateValueFromSurvey.call(this, newValue, clearData);
        this.invisibleOldValues = {};
    };
    QuestionCheckboxModel.prototype.setDefaultValue = function () {
        _super.prototype.setDefaultValue.call(this);
        var val = this.defaultValue;
        if (Array.isArray(val)) {
            for (var i = 0; i < val.length; i++) {
                var rVal = this.getRealValue(val[i]);
                if (this.canClearValueAnUnknown(rVal)) {
                    this.addIntoInvisibleOldValues(rVal);
                }
            }
        }
    };
    QuestionCheckboxModel.prototype.addIntoInvisibleOldValues = function (val) {
        this.invisibleOldValues[val] = val;
    };
    QuestionCheckboxModel.prototype.hasValueToClearIncorrectValues = function () {
        return _super.prototype.hasValueToClearIncorrectValues.call(this) || !helpers_Helpers.isValueEmpty(this.invisibleOldValues);
    };
    QuestionCheckboxModel.prototype.setNewValue = function (newValue) {
        if (!this.isChangingValueOnClearIncorrect) {
            this.invisibleOldValues = {};
        }
        newValue = this.valueFromData(newValue);
        var value = this.value;
        if (!newValue)
            newValue = [];
        if (!value)
            value = [];
        if (this.isTwoValueEquals(value, newValue))
            return;
        this.removeNoneItemsValues(value, newValue);
        _super.prototype.setNewValue.call(this, newValue);
    };
    QuestionCheckboxModel.prototype.getIsMultipleValue = function () {
        return true;
    };
    QuestionCheckboxModel.prototype.getCommentFromValue = function (newValue) {
        var ind = this.getFirstUnknownIndex(newValue);
        if (ind < 0)
            return "";
        return newValue[ind];
    };
    QuestionCheckboxModel.prototype.setOtherValueIntoValue = function (newValue) {
        var ind = this.getFirstUnknownIndex(newValue);
        if (ind < 0)
            return newValue;
        newValue.splice(ind, 1, this.otherItem.value);
        return newValue;
    };
    QuestionCheckboxModel.prototype.getFirstUnknownIndex = function (newValue) {
        if (!Array.isArray(newValue))
            return -1;
        for (var i = 0; i < newValue.length; i++) {
            if (this.hasUnknownValueItem(newValue[i], false, false))
                return i;
        }
        return -1;
    };
    QuestionCheckboxModel.prototype.removeNoneItemsValues = function (value, newValue) {
        var noneValues = [];
        if (this.showNoneItem)
            noneValues.push(this.noneItem.value);
        if (this.showRefuseItem)
            noneValues.push(this.refuseItem.value);
        if (this.showDontKnowItem)
            noneValues.push(this.dontKnowItem.value);
        if (noneValues.length > 0) {
            var prevNone = this.noneIndexInArray(value, noneValues);
            var newNone = this.noneIndexInArray(newValue, noneValues);
            if (prevNone.index > -1) {
                if (prevNone.val === newNone.val) {
                    if (newValue.length > 0) {
                        newValue.splice(newNone.index, 1);
                    }
                }
                else {
                    var prevNewNone = this.noneIndexInArray(newValue, [prevNone.val]);
                    if (prevNewNone.index > -1 && prevNewNone.index < newValue.length - 1) {
                        newValue.splice(prevNewNone.index, 1);
                    }
                }
            }
            else {
                if (newNone.index > -1 && newValue.length > 1) {
                    var itemVal = this.convertValueToObject([newNone.val])[0];
                    newValue.splice(0, newValue.length, itemVal);
                }
            }
        }
    };
    QuestionCheckboxModel.prototype.noneIndexInArray = function (val, noneValues) {
        if (!Array.isArray(val))
            return { index: -1, val: undefined };
        for (var i = val.length - 1; i >= 0; i--) {
            var index = noneValues.indexOf(this.getRealValue(val[i]));
            if (index > -1)
                return { index: i, val: noneValues[index] };
        }
        return { index: -1, val: undefined };
    };
    QuestionCheckboxModel.prototype.canUseFilteredChoices = function () {
        return !this.hasSelectAll && _super.prototype.canUseFilteredChoices.call(this);
    };
    QuestionCheckboxModel.prototype.supportSelectAll = function () {
        return this.isSupportProperty("showSelectAllItem");
    };
    QuestionCheckboxModel.prototype.addNonChoicesItems = function (dict, isAddAll) {
        _super.prototype.addNonChoicesItems.call(this, dict, isAddAll);
        if (this.supportSelectAll()) {
            this.addNonChoiceItem(dict, this.selectAllItem, isAddAll, this.hasSelectAll, settings.specialChoicesOrder.selectAllItem);
        }
    };
    QuestionCheckboxModel.prototype.isBuiltInChoice = function (item) {
        return item === this.selectAllItem || _super.prototype.isBuiltInChoice.call(this, item);
    };
    QuestionCheckboxModel.prototype.isItemInList = function (item) {
        if (item == this.selectAllItem)
            return this.hasSelectAll;
        return _super.prototype.isItemInList.call(this, item);
    };
    QuestionCheckboxModel.prototype.getDisplayValueEmpty = function () {
        var _this = this;
        return itemvalue_ItemValue.getTextOrHtmlByValue(this.visibleChoices.filter(function (choice) { return choice != _this.selectAllItemValue; }), undefined);
    };
    QuestionCheckboxModel.prototype.getDisplayValueCore = function (keysAsText, value) {
        if (!Array.isArray(value))
            return _super.prototype.getDisplayValueCore.call(this, keysAsText, value);
        var valuePropName = this.valuePropertyName;
        var onGetValueCallback = function (index) {
            var val = value[index];
            if (!!valuePropName && !!val[valuePropName]) {
                val = val[valuePropName];
            }
            return val;
        };
        return this.getDisplayArrayValue(keysAsText, value, onGetValueCallback);
    };
    QuestionCheckboxModel.prototype.clearIncorrectValuesCore = function () {
        this.clearIncorrectAndDisabledValues(false);
    };
    QuestionCheckboxModel.prototype.clearDisabledValuesCore = function () {
        this.clearIncorrectAndDisabledValues(true);
    };
    QuestionCheckboxModel.prototype.clearIncorrectAndDisabledValues = function (clearDisabled) {
        var val = this.value;
        var hasChanged = false;
        var restoredValues = this.restoreValuesFromInvisible();
        if (!val && restoredValues.length == 0)
            return;
        if (!Array.isArray(val) || val.length == 0) {
            this.isChangingValueOnClearIncorrect = true;
            if (!clearDisabled) {
                if (this.hasComment) {
                    this.value = null;
                }
                else {
                    this.clearValue(true);
                }
            }
            this.isChangingValueOnClearIncorrect = false;
            if (restoredValues.length == 0)
                return;
            val = [];
        }
        var newValue = [];
        for (var i = 0; i < val.length; i++) {
            var rItemVal = this.getRealValue(val[i]);
            var isUnkown = this.canClearValueAnUnknown(rItemVal);
            if ((!clearDisabled && !isUnkown) ||
                (clearDisabled && !this.isValueDisabled(rItemVal))) {
                newValue.push(val[i]);
            }
            else {
                hasChanged = true;
                if (isUnkown) {
                    this.addIntoInvisibleOldValues(val[i]);
                }
            }
        }
        for (var i = 0; i < restoredValues.length; i++) {
            newValue.push(restoredValues[i]);
            hasChanged = true;
        }
        if (!hasChanged)
            return;
        this.isChangingValueOnClearIncorrect = true;
        if (newValue.length == 0) {
            this.clearValue(true);
        }
        else {
            this.value = newValue;
        }
        this.isChangingValueOnClearIncorrect = false;
    };
    QuestionCheckboxModel.prototype.restoreValuesFromInvisible = function () {
        var res = [];
        var visItems = this.visibleChoices;
        for (var i = 0; i < visItems.length; i++) {
            var item = visItems[i];
            if (item === this.selectAllItem)
                continue;
            var val = visItems[i].value;
            if (helpers_Helpers.isTwoValueEquals(val, this.invisibleOldValues[val])) {
                if (!this.isItemSelected(item)) {
                    res.push(val);
                }
                delete this.invisibleOldValues[val];
            }
        }
        return res;
    };
    QuestionCheckboxModel.prototype.getConditionJson = function (operator, path) {
        if (operator === void 0) { operator = null; }
        if (path === void 0) { path = null; }
        var json = _super.prototype.getConditionJson.call(this, operator, path);
        if (operator == "contains" || operator == "notcontains") {
            json["type"] = "radiogroup";
        }
        json["maxSelectedChoices"] = 0;
        json["minSelectedChoices"] = 0;
        return json;
    };
    QuestionCheckboxModel.prototype.isAnswerCorrect = function () {
        return helpers_Helpers.isArrayContainsEqual(this.value, this.correctAnswer);
    };
    QuestionCheckboxModel.prototype.setDefaultValueWithOthers = function () {
        this.value = this.renderedValueFromDataCore(this.defaultValue);
    };
    QuestionCheckboxModel.prototype.getIsItemValue = function (val, item) {
        if (!val || !Array.isArray(val))
            return false;
        return val.indexOf(item.value) >= 0;
    };
    QuestionCheckboxModel.prototype.valueFromData = function (val) {
        if (!val)
            return val;
        if (!Array.isArray(val))
            return [_super.prototype.valueFromData.call(this, val)];
        var value = [];
        for (var i = 0; i < val.length; i++) {
            var choiceitem = itemvalue_ItemValue.getItemByValue(this.activeChoices, val[i]);
            if (!!choiceitem) {
                value.push(choiceitem.value);
            }
            else {
                value.push(val[i]);
            }
        }
        return value;
    };
    QuestionCheckboxModel.prototype.rendredValueFromData = function (val) {
        val = this.convertValueFromObject(val);
        return _super.prototype.rendredValueFromData.call(this, val);
    };
    QuestionCheckboxModel.prototype.rendredValueToData = function (val) {
        val = _super.prototype.rendredValueToData.call(this, val);
        return this.convertValueToObject(val);
    };
    QuestionCheckboxModel.prototype.convertValueFromObject = function (val) {
        if (!this.valuePropertyName)
            return val;
        return helpers_Helpers.convertArrayObjectToValue(val, this.valuePropertyName);
    };
    QuestionCheckboxModel.prototype.convertValueToObject = function (val) {
        if (!this.valuePropertyName)
            return val;
        var dest = undefined;
        if (!!this.survey && this.survey.questionsByValueName(this.getValueName()).length > 1) {
            dest = this.data.getValue(this.getValueName());
        }
        return helpers_Helpers.convertArrayValueToObject(val, this.valuePropertyName, dest);
    };
    QuestionCheckboxModel.prototype.renderedValueFromDataCore = function (val) {
        if (!val || !Array.isArray(val))
            val = [];
        if (!this.hasActiveChoices)
            return val;
        for (var i = 0; i < val.length; i++) {
            if (val[i] == this.otherItem.value)
                return val;
            if (this.hasUnknownValueItem(val[i], true, false)) {
                this.otherValue = val[i];
                var newVal = val.slice();
                newVal[i] = this.otherItem.value;
                return newVal;
            }
        }
        return val;
    };
    QuestionCheckboxModel.prototype.rendredValueToDataCore = function (val) {
        if (!val || !val.length)
            return val;
        for (var i = 0; i < val.length; i++) {
            if (val[i] == this.otherItem.value) {
                if (this.needConvertRenderedOtherToDataValue()) {
                    var newVal = val.slice();
                    newVal[i] = this.otherValue;
                    return newVal;
                }
            }
        }
        return val;
    };
    QuestionCheckboxModel.prototype.selectOtherValueFromComment = function (val) {
        var newVal = [];
        var rendVal = this.renderedValue;
        if (Array.isArray(rendVal)) {
            for (var i = 0; i < rendVal.length; i++) {
                if (rendVal[i] !== this.otherItem.value) {
                    newVal.push(rendVal[i]);
                }
            }
        }
        if (val) {
            newVal.push(this.otherItem.value);
        }
        this.value = newVal;
    };
    Object.defineProperty(QuestionCheckboxModel.prototype, "checkBoxSvgPath", {
        get: function () {
            return "M5,13l2-2l3,3l7-7l2,2l-9,9L5,13z";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCheckboxModel.prototype, "isNewA11yStructure", {
        //a11y
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCheckboxModel.prototype, "a11y_input_ariaRole", {
        get: function () {
            return "group";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCheckboxModel.prototype, "a11y_input_ariaRequired", {
        get: function () {
            return null;
        },
        enumerable: false,
        configurable: true
    });
    return QuestionCheckboxModel;
}(QuestionCheckboxBase));

Serializer.addClass("checkbox", [
    { name: "showSelectAllItem:boolean", alternativeName: "hasSelectAll" },
    { name: "separateSpecialChoices", visible: true },
    { name: "maxSelectedChoices:number", default: 0, onSettingValue: function (obj, val) {
            if (val <= 0)
                return 0;
            var min = obj.minSelectedChoices;
            return min > 0 && val < min ? min : val;
        }
    },
    { name: "minSelectedChoices:number", default: 0, onSettingValue: function (obj, val) {
            if (val <= 0)
                return 0;
            var max = obj.maxSelectedChoices;
            return max > 0 && val > max ? max : val;
        }
    },
    {
        name: "selectAllText",
        serializationProperty: "locSelectAllText",
        dependsOn: "showSelectAllItem",
        visibleIf: function (obj) {
            return obj.hasSelectAll;
        }
    },
    {
        name: "valuePropertyName",
        category: "data"
    },
    { name: "itemComponent", visible: false, default: "survey-checkbox-item" }
], function () {
    return new question_checkbox_QuestionCheckboxModel("");
}, "checkboxbase");
questionfactory_QuestionFactory.Instance.registerQuestion("checkbox", function (name) {
    var q = new question_checkbox_QuestionCheckboxModel(name);
    q.choices = questionfactory_QuestionFactory.DefaultChoices;
    return q;
});

// CONCATENATED MODULE: ./packages/survey-core/src/multiSelectListModel.ts
var multiSelectListModel_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var multiSelectListModel_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};


var multiSelectListModel_MultiSelectListModel = /** @class */ (function (_super) {
    multiSelectListModel_extends(MultiSelectListModel, _super);
    function MultiSelectListModel(options) {
        var _this = _super.call(this, options) || this;
        _this.onItemClick = function (item) {
            if (_this.isItemDisabled(item))
                return;
            _this.isExpanded = false;
            if (_this.isItemSelected(item)) {
                _this.selectedItems.splice(_this.selectedItems.indexOf(item), 1)[0];
                !!_this.onSelectionChanged && (_this.onSelectionChanged(item, "removed"));
            }
            else {
                _this.selectedItems.push(item);
                !!_this.onSelectionChanged && (_this.onSelectionChanged(item, "added"));
            }
        };
        _this.isItemDisabled = function (itemValue) {
            return itemValue.enabled !== undefined && !itemValue.enabled;
        };
        _this.isItemSelected = function (itemValue) {
            return !!_this.allowSelection && _this.selectedItems.filter(function (item) { return _this.areSameItems(item, itemValue); }).length > 0;
        };
        _this.setSelectedItems(options.selectedItems || []);
        return _this;
    }
    MultiSelectListModel.prototype.updateItemState = function () {
        var _this = this;
        this.actions.forEach(function (action) {
            var isSelected = _this.isItemSelected(action);
            action.visible = _this.hideSelectedItems ? !isSelected : true;
        });
    };
    MultiSelectListModel.prototype.updateState = function () {
        var _this = this;
        this.updateItemState();
        this.isEmpty = this.renderedActions.filter(function (action) { return _this.isItemVisible(action); }).length === 0;
    };
    MultiSelectListModel.prototype.setSelectedItems = function (newItems) {
        this.selectedItems = newItems;
        this.updateState();
    };
    MultiSelectListModel.prototype.selectFocusedItem = function () {
        _super.prototype.selectFocusedItem.call(this);
        if (this.hideSelectedItems) {
            this.focusNextVisibleItem();
        }
    };
    multiSelectListModel_decorate([
        jsonobject_property()
    ], MultiSelectListModel.prototype, "hideSelectedItems", void 0);
    return MultiSelectListModel;
}(list_ListModel));


// CONCATENATED MODULE: ./packages/survey-core/src/dropdownMultiSelectListModel.ts
var dropdownMultiSelectListModel_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var dropdownMultiSelectListModel_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};






var dropdownMultiSelectListModel_DropdownMultiSelectListModel = /** @class */ (function (_super) {
    dropdownMultiSelectListModel_extends(DropdownMultiSelectListModel, _super);
    function DropdownMultiSelectListModel(question, onSelectionChanged) {
        var _this = _super.call(this, question, onSelectionChanged) || this;
        _this.popupCssClasses = "sv-multi-select-list";
        _this.setHideSelectedItems(question.hideSelectedItems);
        _this.syncFilterStringPlaceholder();
        _this.closeOnSelect = question.closeOnSelect;
        return _this;
    }
    DropdownMultiSelectListModel.prototype.locStrsChanged = function () {
        _super.prototype.locStrsChanged.call(this);
        this.syncFilterStringPlaceholder();
    };
    DropdownMultiSelectListModel.prototype.updateListState = function () {
        this.listModel.updateState();
        this.syncFilterStringPlaceholder();
    };
    DropdownMultiSelectListModel.prototype.syncFilterStringPlaceholder = function () {
        var selectedActions = this.getSelectedActions();
        if (selectedActions.length || this.question.selectedItems.length || this.listModel.focusedItem) {
            this.filterStringPlaceholder = undefined;
        }
        else {
            this.filterStringPlaceholder = this.question.placeholder;
        }
    };
    DropdownMultiSelectListModel.prototype.getSelectedActions = function () {
        return this.listModel.actions.filter(function (item) { return item.selected; });
    };
    DropdownMultiSelectListModel.prototype.getFocusFirstInputSelector = function () {
        if (this.listModel.hideSelectedItems && IsTouch && !this.isValueEmpty(this.question.value)) {
            return this.itemSelector;
        }
        else {
            return _super.prototype.getFocusFirstInputSelector.call(this);
        }
    };
    DropdownMultiSelectListModel.prototype.createListModel = function () {
        var _this = this;
        var visibleItems = this.getAvailableItems();
        var _onSelectionChanged = this.onSelectionChanged;
        if (!_onSelectionChanged) {
            _onSelectionChanged = function (item, status) {
                _this.resetFilterString();
                if (item.id === "selectall") {
                    _this.selectAllItems();
                }
                else if (status === "added" && item.value === settings.noneItemValue) {
                    _this.selectNoneItem();
                }
                else if (status === "added") {
                    _this.selectItem(item.value);
                }
                else if (status === "removed") {
                    _this.deselectItem(item.value);
                }
                _this.popupRecalculatePosition(false);
                if (_this.closeOnSelect) {
                    _this.popupModel.isVisible = false;
                }
            };
        }
        var listOptions = {
            items: visibleItems,
            onSelectionChanged: _onSelectionChanged,
            allowSelection: false,
            locOwner: this.question,
            elementId: this.listElementId
        };
        var res = new multiSelectListModel_MultiSelectListModel(listOptions);
        res.actions.forEach(function (a) { return a.disableTabStop = true; });
        this.setOnTextSearchCallbackForListModel(res);
        res.forceShowFilter = true;
        return res;
    };
    DropdownMultiSelectListModel.prototype.resetFilterString = function () {
        _super.prototype.resetFilterString.call(this);
        this.inputString = null;
        this.hintString = "";
    };
    Object.defineProperty(DropdownMultiSelectListModel.prototype, "shouldResetAfterCancel", {
        get: function () {
            return IsTouch && !this.closeOnSelect;
        },
        enumerable: false,
        configurable: true
    });
    DropdownMultiSelectListModel.prototype.createPopup = function () {
        var _this = this;
        _super.prototype.createPopup.call(this);
        this.popupModel.onFooterActionsCreated.add(function (_, opt) {
            if (_this.shouldResetAfterCancel) {
                opt.actions.push({
                    id: "sv-dropdown-done-button",
                    title: _this.doneButtonCaption,
                    innerCss: "sv-popup__button--done",
                    needSpace: true,
                    action: function () { _this.popupModel.isVisible = false; },
                    enabled: new ComputedUpdater(function () { return !_this.isTwoValueEquals(_this.question.renderedValue, _this.previousValue); })
                });
            }
        });
        this.popupModel.onVisibilityChanged.add(function (_, opt) {
            if (_this.shouldResetAfterCancel && opt.isVisible) {
                _this.previousValue = [].concat(_this.question.renderedValue || []);
            }
        });
        this.popupModel.onCancel = function () {
            if (_this.shouldResetAfterCancel) {
                _this.question.renderedValue = _this.previousValue;
                _this.updateListState();
            }
        };
    };
    DropdownMultiSelectListModel.prototype.selectAllItems = function () {
        this.question.toggleSelectAll();
        this.updateListState();
    };
    DropdownMultiSelectListModel.prototype.selectNoneItem = function () {
        this.question.renderedValue = [settings.noneItemValue];
        this.updateListState();
    };
    DropdownMultiSelectListModel.prototype.selectItem = function (id) {
        var newValue = [].concat(this.question.renderedValue || []);
        newValue.push(id);
        this.question.renderedValue = newValue;
        this.updateListState();
    };
    DropdownMultiSelectListModel.prototype.deselectItem = function (id) {
        var newValue = [].concat(this.question.renderedValue || []);
        newValue.splice(newValue.indexOf(id), 1);
        this.question.renderedValue = newValue;
        this.applyHintString(this.listModel.focusedItem);
        this.updateListState();
    };
    DropdownMultiSelectListModel.prototype.clear = function () {
        _super.prototype.clear.call(this);
        this.syncFilterStringPlaceholder();
    };
    DropdownMultiSelectListModel.prototype.onClear = function (event) {
        _super.prototype.onClear.call(this, event);
        this.updateListState();
    };
    DropdownMultiSelectListModel.prototype.setHideSelectedItems = function (newValue) {
        this.listModel.hideSelectedItems = newValue;
        this.updateListState();
    };
    DropdownMultiSelectListModel.prototype.removeLastSelectedItem = function () {
        this.deselectItem(this.question.renderedValue[this.question.renderedValue.length - 1]);
        this.popupRecalculatePosition(false);
    };
    DropdownMultiSelectListModel.prototype.inputKeyHandler = function (event) {
        if (event.keyCode === 8 && !this.filterString) {
            this.removeLastSelectedItem();
            event.preventDefault();
            event.stopPropagation();
        }
    };
    DropdownMultiSelectListModel.prototype.setInputStringFromSelectedItem = function (newValue) {
        if (this.question.searchEnabled) {
            this.inputString = null;
        }
    };
    DropdownMultiSelectListModel.prototype.focusItemOnClickAndPopup = function () {
        return;
    };
    DropdownMultiSelectListModel.prototype.onEscape = function () {
        return;
    };
    DropdownMultiSelectListModel.prototype.beforeScrollToFocusedItem = function (focusedItem) {
        return;
    };
    DropdownMultiSelectListModel.prototype.afterScrollToFocusedItem = function () {
        var _a;
        if (!((_a = this.listModel.focusedItem) === null || _a === void 0 ? void 0 : _a.selected)) {
            this.applyHintString(this.listModel.focusedItem || this.question.selectedItem);
        }
        else {
            this.hintString = "";
        }
        this.syncFilterStringPlaceholder();
    };
    DropdownMultiSelectListModel.prototype.onPropertyChangedHandler = function (sender, options) {
        _super.prototype.onPropertyChangedHandler.call(this, sender, options);
        if (options.name === "value" || options.name === "renderedValue" || options.name === "placeholder") {
            this.syncFilterStringPlaceholder();
        }
    };
    dropdownMultiSelectListModel_decorate([
        jsonobject_property({ defaultValue: "" })
    ], DropdownMultiSelectListModel.prototype, "filterStringPlaceholder", void 0);
    dropdownMultiSelectListModel_decorate([
        jsonobject_property({ defaultValue: true })
    ], DropdownMultiSelectListModel.prototype, "closeOnSelect", void 0);
    dropdownMultiSelectListModel_decorate([
        jsonobject_property()
    ], DropdownMultiSelectListModel.prototype, "previousValue", void 0);
    dropdownMultiSelectListModel_decorate([
        jsonobject_property({ localizable: { defaultStr: "tagboxDoneButtonCaption" } })
    ], DropdownMultiSelectListModel.prototype, "doneButtonCaption", void 0);
    return DropdownMultiSelectListModel;
}(dropdownListModel_DropdownListModel));


// CONCATENATED MODULE: ./packages/survey-core/src/question_tagbox.ts
var question_tagbox_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var question_tagbox_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};






/**
 * A class that describes the Multi-Select Dropdown (Tag Box) question type.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/how-to-create-multiselect-tag-box/ (linkStyle))
 */
var question_tagbox_QuestionTagboxModel = /** @class */ (function (_super) {
    question_tagbox_extends(QuestionTagboxModel, _super);
    function QuestionTagboxModel(name) {
        var _this = _super.call(this, name) || this;
        _this.itemDisplayNameMap = {};
        _this.onOpened = _this.addEvent();
        _this.createLocalizableString("placeholder", _this, false, true);
        _this.createLocalizableString("clearCaption", _this, false, true);
        _this.createLocalizableString("readOnlyText", _this, true);
        _this.registerPropertyChangedHandlers(["value", "renderAs", "showOtherItem", "otherText", "placeholder", "choices", "visibleChoices"], function () {
            _this.updateReadOnlyText();
        });
        _this.updateReadOnlyText();
        return _this;
    }
    QuestionTagboxModel.prototype.locStrsChanged = function () {
        var _a;
        _super.prototype.locStrsChanged.call(this);
        this.updateReadOnlyText();
        (_a = this.dropdownListModel) === null || _a === void 0 ? void 0 : _a.locStrsChanged();
    };
    QuestionTagboxModel.prototype.updateReadOnlyText = function () {
        this.readOnlyText = this.displayValue || this.placeholder;
    };
    QuestionTagboxModel.prototype.getDefaultItemComponent = function () {
        return "";
    };
    QuestionTagboxModel.prototype.onSurveyLoad = function () {
        _super.prototype.onSurveyLoad.call(this);
        this.createDropdownListModel();
    };
    QuestionTagboxModel.prototype.onSetData = function () {
        _super.prototype.onSetData.call(this);
        this.createDropdownListModel();
    };
    QuestionTagboxModel.prototype.createDropdownListModel = function () {
        if (!this.dropdownListModel && !this.isLoadingFromJson) {
            this.dropdownListModel = new dropdownMultiSelectListModel_DropdownMultiSelectListModel(this);
        }
    };
    Object.defineProperty(QuestionTagboxModel.prototype, "placeholder", {
        /**
         * A text displayed in the input field when it doesn't have a value.
         */
        get: function () {
            return this.getLocalizableStringText("placeholder");
        },
        set: function (val) {
            this.setLocalizableStringText("placeholder", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTagboxModel.prototype, "locPlaceholder", {
        get: function () {
            return this.getLocalizableString("placeholder");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTagboxModel.prototype, "clearCaption", {
        get: function () {
            return this.getLocalizableStringText("clearCaption");
        },
        set: function (value) {
            this.setLocalizableStringText("clearCaption", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTagboxModel.prototype, "locClearCaption", {
        get: function () {
            return this.getLocalizableString("clearCaption");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTagboxModel.prototype, "readOnlyText", {
        get: function () {
            return this.getLocalizableStringText("readOnlyText");
        },
        set: function (val) {
            this.setLocalizableStringText("readOnlyText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTagboxModel.prototype, "locReadOnlyText", {
        get: function () {
            return this.getLocalizableString("readOnlyText");
        },
        enumerable: false,
        configurable: true
    });
    QuestionTagboxModel.prototype.getType = function () {
        return "tagbox";
    };
    Object.defineProperty(QuestionTagboxModel.prototype, "ariaRole", {
        get: function () {
            return "combobox";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTagboxModel.prototype, "popupModel", {
        get: function () {
            var _a;
            return (_a = this.dropdownListModel) === null || _a === void 0 ? void 0 : _a.popupModel;
        },
        enumerable: false,
        configurable: true
    });
    QuestionTagboxModel.prototype.getControlClass = function () {
        return new CssClassBuilder()
            .append(this.cssClasses.control)
            .append(this.cssClasses.controlEmpty, this.isEmpty())
            .append(this.cssClasses.onError, this.hasCssError())
            .append(this.cssClasses.controlEditable, !this.isDisabledStyle && !this.isReadOnlyStyle && !this.isPreviewStyle)
            .append(this.cssClasses.controlDisabled, this.isDisabledStyle)
            .append(this.cssClasses.controlReadOnly, this.isReadOnlyStyle)
            .append(this.cssClasses.controlPreview, this.isPreviewStyle)
            .toString();
    };
    QuestionTagboxModel.prototype.onOpenedCallBack = function () {
        this.onOpened.fire(this, { question: this, choices: this.choices });
    };
    QuestionTagboxModel.prototype.hasUnknownValue = function (val, includeOther, isFilteredChoices, checkEmptyValue) {
        if (this.choicesLazyLoadEnabled) {
            return false;
        }
        return _super.prototype.hasUnknownValue.call(this, val, includeOther, isFilteredChoices, checkEmptyValue);
    };
    QuestionTagboxModel.prototype.needConvertRenderedOtherToDataValue = function () {
        var _a;
        var val = (_a = this.otherValue) === null || _a === void 0 ? void 0 : _a.trim();
        if (!val)
            return false;
        return _super.prototype.hasUnknownValue.call(this, val, true, false);
    };
    QuestionTagboxModel.prototype.onVisibleChoicesChanged = function () {
        _super.prototype.onVisibleChoicesChanged.call(this);
        if (this.popupModel) {
            this.dropdownListModel.updateItems();
        }
    };
    QuestionTagboxModel.prototype.getItemIfChoicesNotContainThisValue = function (value, text) {
        if (this.choicesLazyLoadEnabled) {
            return this.createItemValue(value, text);
        }
        else {
            return _super.prototype.getItemIfChoicesNotContainThisValue.call(this, value, text);
        }
    };
    QuestionTagboxModel.prototype.validateItemValues = function (itemValues) {
        var _this = this;
        this.updateItemDisplayNameMap();
        var val = this.renderedValue;
        if (!!itemValues.length && itemValues.length === val.length)
            return itemValues;
        var selectedItemValues = this.selectedItemValues;
        if (!itemValues.length && !!selectedItemValues && !!selectedItemValues.length) {
            this.defaultSelectedItemValues = [].concat(selectedItemValues);
            return selectedItemValues;
        }
        var itemValueValues = itemValues.map(function (iV) { return iV.value; });
        val.filter(function (item) { return itemValueValues.indexOf(item) === -1; }).forEach(function (item) {
            var newItem = _this.getItemIfChoicesNotContainThisValue(item, _this.itemDisplayNameMap[item]);
            if (newItem) {
                itemValues.push(newItem);
            }
        });
        itemValues.sort(function (a, b) { return val.indexOf(a.value) - val.indexOf(b.value); });
        return itemValues;
    };
    QuestionTagboxModel.prototype.updateItemDisplayNameMap = function () {
        var _this = this;
        var func = function (item) { _this.itemDisplayNameMap[item.value] = item.text; };
        (this.defaultSelectedItemValues || []).forEach(func);
        (this.selectedItemValues || []).forEach(func);
        this.visibleChoices.forEach(func);
    };
    QuestionTagboxModel.prototype.getFirstInputElementId = function () {
        return this.inputId + (this.searchEnabled ? "_0" : "");
    };
    QuestionTagboxModel.prototype.getInputId = function () {
        return this.inputId + "_0";
    };
    QuestionTagboxModel.prototype.supportEmptyValidation = function () { return true; };
    QuestionTagboxModel.prototype.onBlurCore = function (event) {
        var _a;
        (_a = this.dropdownListModel) === null || _a === void 0 ? void 0 : _a.onBlur(event);
        _super.prototype.onBlurCore.call(this, event);
    };
    QuestionTagboxModel.prototype.onFocusCore = function (event) {
        var _a;
        (_a = this.dropdownListModel) === null || _a === void 0 ? void 0 : _a.onFocus(event);
        _super.prototype.onFocusCore.call(this, event);
    };
    QuestionTagboxModel.prototype.dispose = function () {
        _super.prototype.dispose.call(this);
        if (!!this.dropdownListModel) {
            this.dropdownListModel.dispose();
        }
    };
    QuestionTagboxModel.prototype.clearValue = function (keepComment) {
        var _a;
        _super.prototype.clearValue.call(this, keepComment);
        (_a = this.dropdownListModel) === null || _a === void 0 ? void 0 : _a.clear();
    };
    Object.defineProperty(QuestionTagboxModel.prototype, "showClearButton", {
        get: function () {
            return this.allowClear && !this.isEmpty() && (!this.isDesignMode || settings.supportCreatorV2);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionTagboxModel.prototype, "isNewA11yStructure", {
        //a11y
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    question_tagbox_decorate([
        jsonobject_property()
    ], QuestionTagboxModel.prototype, "searchMode", void 0);
    question_tagbox_decorate([
        jsonobject_property()
    ], QuestionTagboxModel.prototype, "allowClear", void 0);
    question_tagbox_decorate([
        jsonobject_property({
            onSet: function (newValue, target) {
                if (!!target.dropdownListModel) {
                    target.dropdownListModel.setSearchEnabled(newValue);
                }
            }
        })
    ], QuestionTagboxModel.prototype, "searchEnabled", void 0);
    question_tagbox_decorate([
        jsonobject_property({
            onSet: function (newValue, target) {
                if (!!target.dropdownListModel) {
                    target.dropdownListModel.setHideSelectedItems(newValue);
                }
            }
        })
    ], QuestionTagboxModel.prototype, "hideSelectedItems", void 0);
    question_tagbox_decorate([
        jsonobject_property({
            onSet: function (newValue, target) {
                if (!!target.dropdownListModel) {
                    target.dropdownListModel.setChoicesLazyLoadEnabled(newValue);
                }
            }
        })
    ], QuestionTagboxModel.prototype, "choicesLazyLoadEnabled", void 0);
    question_tagbox_decorate([
        jsonobject_property()
    ], QuestionTagboxModel.prototype, "choicesLazyLoadPageSize", void 0);
    question_tagbox_decorate([
        jsonobject_property({ getDefaultValue: function () { return settings.tagboxCloseOnSelect; } })
    ], QuestionTagboxModel.prototype, "closeOnSelect", void 0);
    question_tagbox_decorate([
        jsonobject_property()
    ], QuestionTagboxModel.prototype, "textWrapEnabled", void 0);
    return QuestionTagboxModel;
}(question_checkbox_QuestionCheckboxModel));

Serializer.addClass("tagbox", [
    { name: "placeholder", serializationProperty: "locPlaceholder" },
    { name: "allowClear:boolean", default: true },
    { name: "searchEnabled:boolean", default: true },
    { name: "textWrapEnabled:boolean", default: true },
    { name: "choicesLazyLoadEnabled:boolean", default: false, visible: false },
    { name: "choicesLazyLoadPageSize:number", default: 25, visible: false },
    { name: "hideSelectedItems:boolean", default: false },
    { name: "closeOnSelect:boolean" },
    { name: "itemComponent", visible: false, default: "" },
    { name: "searchMode", default: "contains", choices: ["contains", "startsWith"] }
], function () {
    return new question_tagbox_QuestionTagboxModel("");
}, "checkbox");
questionfactory_QuestionFactory.Instance.registerQuestion("tagbox", function (name) {
    var q = new question_tagbox_QuestionTagboxModel(name);
    q.choices = questionfactory_QuestionFactory.DefaultChoices;
    return q;
});

// CONCATENATED MODULE: ./packages/survey-core/src/dragdrop/choices.ts
var choices_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();


var choices_DragDropChoices = /** @class */ (function (_super) {
    choices_extends(DragDropChoices, _super);
    function DragDropChoices() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.doDragOver = function () {
            if (_this.parentElement.getType() === "imagepicker")
                return;
            var node = _this.domAdapter.draggedElementShortcut.querySelector(".svc-item-value-controls__button");
            node.style.cursor = "grabbing";
        };
        _this.doBanDropHere = function () {
            if (_this.parentElement.getType() === "imagepicker")
                return;
            var node = _this.domAdapter.draggedElementShortcut.querySelector(".svc-item-value-controls__button");
            node.style.cursor = "not-allowed";
        };
        return _this;
    }
    Object.defineProperty(DragDropChoices.prototype, "draggedElementType", {
        get: function () {
            return "item-value";
        },
        enumerable: false,
        configurable: true
    });
    DragDropChoices.prototype.createDraggedElementShortcut = function (text, draggedElementNode, event) {
        if (this.parentElement.getType() === "imagepicker") {
            return this.createImagePickerShortcut(this.draggedElement, text, draggedElementNode, event);
        }
        var draggedElementShortcut = DomDocumentHelper.createElement("div");
        if (!draggedElementShortcut)
            return;
        // draggedElementShortcut.innerText = text;
        draggedElementShortcut.className = "sv-drag-drop-choices-shortcut";
        var isDeepClone = true;
        var clone = (draggedElementNode
            .closest("[data-sv-drop-target-item-value]")
            .cloneNode(isDeepClone));
        clone.classList.add("sv-drag-drop-choices-shortcut__content");
        var dragIcon = clone.querySelector(".svc-item-value-controls__drag-icon");
        dragIcon.style.visibility = "visible";
        var removeIcon = clone.querySelector(".svc-item-value-controls__remove");
        removeIcon.style.backgroundColor = "transparent";
        clone.classList.remove("svc-item-value--moveup");
        clone.classList.remove("svc-item-value--movedown");
        this.draggedElement.isDragDropMoveDown = false;
        this.draggedElement.isDragDropMoveUp = false;
        draggedElementShortcut.appendChild(clone);
        var rect = draggedElementNode.getBoundingClientRect();
        draggedElementShortcut.shortcutXOffset = event.clientX - rect.x;
        draggedElementShortcut.shortcutYOffset = event.clientY - rect.y;
        this.isBottom = null;
        if (typeof this.onShortcutCreated === "function") {
            this.onShortcutCreated(draggedElementShortcut);
        }
        return draggedElementShortcut;
    };
    DragDropChoices.prototype.createImagePickerShortcut = function (item, text, draggedElementNode, event) {
        var draggedElementShortcut = DomDocumentHelper.createElement("div");
        if (!draggedElementShortcut)
            return;
        draggedElementShortcut.style.cssText = " \n      cursor: grabbing;\n      position: absolute;\n      z-index: 10000;\n      box-shadow: var(--sjs-shadow-large, 0px 8px 16px 0px rgba(0, 0, 0, 0.1)), var(--sjs-shadow-medium, 0px 2px 6px 0px rgba(0, 0, 0, 0.1));\n      background-color: var(--sjs-general-backcolor, var(--background, #fff));\n      padding: calc(0.5 * var(--sjs-base-unit, var(--base-unit, 8px)));\n      border-radius: calc(0.5 * var(--sjs-base-unit, var(--base-unit, 8px)));\n    ";
        var itemValueNode = draggedElementNode.closest("[data-sv-drop-target-item-value]");
        this.imagepickerControlsNode = itemValueNode.querySelector(".svc-image-item-value-controls");
        var imageContainerNode = itemValueNode.querySelector(".sd-imagepicker__image-container");
        var imageNode = itemValueNode.querySelector(item.imageLink ? "img" : ".sd-imagepicker__no-image").cloneNode(true);
        if (!!this.imagepickerControlsNode) {
            this.imagepickerControlsNode.style.display = "none";
        }
        imageContainerNode.style.width = imageNode.width + "px";
        imageContainerNode.style.height = imageNode.height + "px";
        imageNode.style.objectFit = "cover";
        imageNode.style.borderRadius = "4px";
        draggedElementShortcut.appendChild(imageNode);
        return draggedElementShortcut;
    };
    DragDropChoices.prototype.getDropTargetByDataAttributeValue = function (dataAttributeValue) {
        var dragOverChoice;
        dragOverChoice = this.parentElement.choices.filter(function (choice) { return "" + choice.value == dataAttributeValue; })[0];
        return dragOverChoice;
    };
    DragDropChoices.prototype.getVisibleChoices = function () {
        var parent = this.parentElement;
        if (parent.getType() === "ranking") {
            if (parent.selectToRankEnabled) {
                return parent.visibleChoices;
            }
            else {
                return parent.rankingChoices;
            }
        }
        return parent.visibleChoices;
    };
    DragDropChoices.prototype.isDropTargetValid = function (dropTarget, dropTargetNode) {
        var choices = this.getVisibleChoices();
        if (this.parentElement.getType() !== "imagepicker") {
            var dropTargetIndex = choices.indexOf(this.dropTarget);
            var draggedElementIndex = choices.indexOf(this.draggedElement);
            if (draggedElementIndex > dropTargetIndex && this.dropTarget.isDragDropMoveUp) {
                this.dropTarget.isDragDropMoveUp = false;
                return false;
            }
            if (draggedElementIndex < dropTargetIndex && this.dropTarget.isDragDropMoveDown) {
                this.dropTarget.isDragDropMoveDown = false;
                return false;
            }
        }
        // shouldn't allow to drop on "adorners" (selectall, none, other)
        if (choices.indexOf(dropTarget) === -1)
            return false;
        return true;
    };
    DragDropChoices.prototype.calculateIsBottom = function (clientY) {
        var choices = this.getVisibleChoices();
        return (choices.indexOf(this.dropTarget) - choices.indexOf(this.draggedElement) >
            0);
    };
    DragDropChoices.prototype.afterDragOver = function (dropTargetNode) {
        if (this.isDropTargetDoesntChanged(this.isBottom))
            return;
        var choices = this.getVisibleChoices();
        var dropTargetIndex = choices.indexOf(this.dropTarget);
        var draggedElementIndex = choices.indexOf(this.draggedElement);
        choices.splice(draggedElementIndex, 1);
        choices.splice(dropTargetIndex, 0, this.draggedElement);
        if (this.parentElement.getType() === "imagepicker")
            return;
        if (draggedElementIndex !== dropTargetIndex) {
            dropTargetNode.classList.remove("svc-item-value--moveup");
            dropTargetNode.classList.remove("svc-item-value--movedown");
            this.dropTarget.isDragDropMoveDown = false;
            this.dropTarget.isDragDropMoveUp = false;
        }
        if (draggedElementIndex > dropTargetIndex) {
            this.dropTarget.isDragDropMoveDown = true;
        }
        if (draggedElementIndex < dropTargetIndex) {
            this.dropTarget.isDragDropMoveUp = true;
        }
        _super.prototype.ghostPositionChanged.call(this);
    };
    DragDropChoices.prototype.doDrop = function () {
        var choices = this.parentElement.choices;
        var filteredChoices = this.getVisibleChoices().filter(function (item) {
            return choices.indexOf(item) !== -1;
        });
        var oldIndex = choices.indexOf(this.draggedElement);
        var newIndex = filteredChoices.indexOf(this.draggedElement);
        choices.splice(oldIndex, 1);
        choices.splice(newIndex, 0, this.draggedElement);
        return this.parentElement;
    };
    DragDropChoices.prototype.clear = function () {
        if (!!this.parentElement) {
            this.updateVisibleChoices(this.parentElement);
        }
        if (!!this.imagepickerControlsNode) {
            this.imagepickerControlsNode.style.display = "flex";
            this.imagepickerControlsNode = null;
        }
        _super.prototype.clear.call(this);
    };
    DragDropChoices.prototype.updateVisibleChoices = function (parent) {
        parent.getType() === "ranking" ?
            parent.updateRankingChoices() :
            parent["updateVisibleChoices"]();
    };
    return DragDropChoices;
}(core_DragDropCore));


// CONCATENATED MODULE: ./packages/survey-core/src/dragdrop/ranking-choices.ts
var ranking_choices_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();





var ranking_choices_DragDropRankingChoices = /** @class */ (function (_super) {
    ranking_choices_extends(DragDropRankingChoices, _super);
    function DragDropRankingChoices() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.isDragOverRootNode = false;
        _this.doDragOver = function () {
            var node = _this.domAdapter.draggedElementShortcut.querySelector(".sv-ranking-item");
            node.style.cursor = "grabbing";
        };
        _this.reorderRankedItem = function (questionModel, fromIndex, toIndex) {
            if (fromIndex == toIndex)
                return;
            var rankingChoices = questionModel.rankingChoices;
            var item = rankingChoices[fromIndex];
            questionModel.isValueSetByUser = true;
            rankingChoices.splice(fromIndex, 1);
            rankingChoices.splice(toIndex, 0, item);
            _this.updateDraggedElementShortcut(toIndex + 1);
        };
        _this.doBanDropHere = function () {
            if (_this.isDragOverRootNode) {
                _this.allowDropHere = true;
                return;
            }
            var node = _this.domAdapter.draggedElementShortcut.querySelector(".sv-ranking-item");
            node.style.cursor = "not-allowed";
        };
        return _this;
    }
    Object.defineProperty(DragDropRankingChoices.prototype, "draggedElementType", {
        get: function () {
            return "ranking-item";
        },
        enumerable: false,
        configurable: true
    });
    DragDropRankingChoices.prototype.createDraggedElementShortcut = function (text, draggedElementNode, event) {
        var draggedElementShortcut = DomDocumentHelper.createElement("div");
        if (!draggedElementShortcut)
            return;
        draggedElementShortcut.className = this.shortcutClass + " sv-ranking-shortcut";
        var isDeepClone = true;
        var clone = draggedElementNode.cloneNode(isDeepClone);
        draggedElementShortcut.appendChild(clone);
        var rect = draggedElementNode.getBoundingClientRect();
        draggedElementShortcut.style.left = rect.x;
        draggedElementShortcut.style.top = rect.y;
        this.domAdapter.rootElement.append(draggedElementShortcut);
        var shortcutHeight = draggedElementShortcut.offsetHeight;
        var clientY = event.clientY;
        if (clientY > rect.y + shortcutHeight) {
            clientY = rect.y + shortcutHeight - 10; //TODO
        }
        draggedElementShortcut.shortcutXOffset = event.clientX - rect.x;
        draggedElementShortcut.shortcutYOffset = clientY - rect.y;
        if (this.parentElement && this.parentElement.useFullItemSizeForShortcut) {
            draggedElementShortcut.style.width = draggedElementNode.offsetWidth + "px";
            draggedElementShortcut.style.height = draggedElementNode.offsetHeight + "px";
        }
        return draggedElementShortcut;
    };
    Object.defineProperty(DragDropRankingChoices.prototype, "shortcutClass", {
        get: function () {
            return new CssClassBuilder()
                .append(this.parentElement.cssClasses.root)
                .append(this.parentElement.cssClasses.rootMobileMod, IsMobile)
                .toString();
        },
        enumerable: false,
        configurable: true
    });
    DragDropRankingChoices.prototype.getDropTargetByDataAttributeValue = function (dataAttributeValue) {
        return this.parentElement.rankingChoices[dataAttributeValue];
    };
    DragDropRankingChoices.prototype.findDropTargetNodeByDragOverNode = function (dragOverNode) {
        this.isDragOverRootNode = this.getIsDragOverRootNode(dragOverNode);
        return _super.prototype.findDropTargetNodeByDragOverNode.call(this, dragOverNode);
    };
    DragDropRankingChoices.prototype.getIsDragOverRootNode = function (dragOverNode) {
        // dragOverNode might be <path></path> for example and the className prop is obj
        return typeof dragOverNode.className === "string" &&
            dragOverNode.className.indexOf("sv-ranking") !== -1;
    };
    DragDropRankingChoices.prototype.isDropTargetValid = function (dropTarget, dropTargetNode) {
        var choices = this.parentElement.rankingChoices;
        if (choices.indexOf(dropTarget) === -1)
            // shouldn't allow to drop on "adorners" (selectall, none, other)
            return false;
        return true;
    };
    DragDropRankingChoices.prototype.calculateIsBottom = function (clientY, dropTargetNode) {
        if (this.dropTarget instanceof itemvalue_ItemValue && this.draggedElement !== this.dropTarget) {
            var rect = dropTargetNode.getBoundingClientRect();
            return clientY >= rect.y + rect.height / 2;
        }
        return _super.prototype.calculateIsBottom.call(this, clientY);
    };
    DragDropRankingChoices.prototype.getIndices = function (model, fromChoicesArray, toChoicesArray) {
        var fromIndex = fromChoicesArray.indexOf(this.draggedElement);
        var toIndex = toChoicesArray.indexOf(this.dropTarget);
        if (fromIndex < 0 && !!this.draggedElement) {
            this.draggedElement = itemvalue_ItemValue.getItemByValue(fromChoicesArray, this.draggedElement.value) || this.draggedElement;
            fromIndex = fromChoicesArray.indexOf(this.draggedElement);
        }
        if (toIndex === -1) {
            var length_1 = model.value.length;
            toIndex = length_1;
        }
        else if (fromChoicesArray == toChoicesArray) {
            if (!this.isBottom && fromIndex < toIndex)
                toIndex--;
            if (this.isBottom && fromIndex > toIndex)
                toIndex++;
        }
        else if (fromChoicesArray != toChoicesArray) {
            if (this.isBottom)
                toIndex++;
        }
        return { fromIndex: fromIndex, toIndex: toIndex };
    };
    DragDropRankingChoices.prototype.afterDragOver = function (dropTargetNode) {
        var _a = this.getIndices(this.parentElement, this.parentElement.rankingChoices, this.parentElement.rankingChoices), fromIndex = _a.fromIndex, toIndex = _a.toIndex;
        this.reorderRankedItem(this.parentElement, fromIndex, toIndex);
    };
    DragDropRankingChoices.prototype.updateDraggedElementShortcut = function (newIndex) {
        var _a;
        if ((_a = this.domAdapter) === null || _a === void 0 ? void 0 : _a.draggedElementShortcut) {
            var newIndexText = newIndex !== null ? newIndex + "" : "";
            // TODO should avoid direct DOM manipulation, do through the frameworks instead
            var indexNode = this.domAdapter.draggedElementShortcut.querySelector(".sv-ranking-item__index");
            indexNode.innerText = newIndexText;
        }
    };
    DragDropRankingChoices.prototype.ghostPositionChanged = function () {
        this.parentElement.currentDropTarget = this.draggedElement;
        _super.prototype.ghostPositionChanged.call(this);
    };
    DragDropRankingChoices.prototype.doDrop = function () {
        this.parentElement.setValue();
        return this.parentElement;
    };
    DragDropRankingChoices.prototype.clear = function () {
        if (!!this.parentElement) {
            this.parentElement.dropTargetNodeMove = null;
            this.parentElement.updateRankingChoices(true);
        }
        _super.prototype.clear.call(this);
    };
    return DragDropRankingChoices;
}(choices_DragDropChoices));


// CONCATENATED MODULE: ./packages/survey-core/src/dragdrop/ranking-select-to-rank.ts
var ranking_select_to_rank_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();

var DragDropRankingSelectToRank = /** @class */ (function (_super) {
    ranking_select_to_rank_extends(DragDropRankingSelectToRank, _super);
    function DragDropRankingSelectToRank() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.selectToRank = function (questionModel, fromIndex, toIndex) {
            var rankingChoices = [].concat(questionModel.rankingChoices);
            var unRankingChoices = questionModel.unRankingChoices;
            var item = unRankingChoices[fromIndex];
            rankingChoices.splice(toIndex, 0, item);
            _this.updateChoices(questionModel, rankingChoices);
        };
        _this.unselectFromRank = function (questionModel, fromIndex, toIndex) {
            var rankingChoices = [].concat(questionModel.rankingChoices);
            rankingChoices.splice(fromIndex, 1);
            _this.updateChoices(questionModel, rankingChoices);
        };
        return _this;
    }
    DragDropRankingSelectToRank.prototype.findDropTargetNodeByDragOverNode = function (dragOverNode) {
        if (dragOverNode.dataset.ranking === "from-container" || dragOverNode.dataset.ranking === "to-container") {
            return dragOverNode;
        }
        var toContainer = dragOverNode.closest("[data-ranking='to-container']");
        var fromContainer = dragOverNode.closest("[data-ranking='from-container']");
        if (this.parentElement.unRankingChoices.length === 0 && fromContainer)
            return fromContainer;
        if (this.parentElement.rankingChoices.length === 0 && toContainer)
            return toContainer;
        return _super.prototype.findDropTargetNodeByDragOverNode.call(this, dragOverNode);
    };
    DragDropRankingSelectToRank.prototype.getDropTargetByDataAttributeValue = function (dataAttributeValue) {
        return this.parentElement.rankingChoices[dataAttributeValue] || this.parentElement.unRankingChoices[dataAttributeValue];
    };
    DragDropRankingSelectToRank.prototype.getDropTargetByNode = function (dropTargetNode, event) {
        if (dropTargetNode.dataset.ranking === "to-container") {
            return "to-container";
        }
        if (dropTargetNode.dataset.ranking === "from-container" || dropTargetNode.closest("[data-ranking='from-container']")) {
            return "from-container";
        }
        return _super.prototype.getDropTargetByNode.call(this, dropTargetNode, event);
    };
    DragDropRankingSelectToRank.prototype.isDropTargetValid = function (dropTarget, dropTargetNode) {
        if (dropTarget === "to-container" || dropTarget === "from-container") {
            return true;
        }
        else {
            return _super.prototype.isDropTargetValid.call(this, dropTarget, dropTargetNode);
        }
    };
    DragDropRankingSelectToRank.prototype.afterDragOver = function (dropTargetNode) {
        var questionModel = this.parentElement;
        var rankingChoices = questionModel.rankingChoices;
        var unRankingChoices = questionModel.unRankingChoices;
        if (this.isDraggedElementUnranked && this.isDropTargetRanked) {
            this.doRankBetween(dropTargetNode, unRankingChoices, rankingChoices, this.selectToRank);
            return;
        }
        if (this.isDraggedElementRanked && this.isDropTargetRanked) {
            this.doRankBetween(dropTargetNode, rankingChoices, rankingChoices, this.reorderRankedItem);
            return;
        }
        if (this.isDraggedElementRanked && !this.isDropTargetRanked) {
            this.doRankBetween(dropTargetNode, rankingChoices, unRankingChoices, this.unselectFromRank);
            return;
        }
    };
    DragDropRankingSelectToRank.prototype.doRankBetween = function (dropTargetNode, fromChoicesArray, toChoicesArray, rankFunction) {
        var questionModel = this.parentElement;
        var _a = this.getIndices(questionModel, fromChoicesArray, toChoicesArray), fromIndex = _a.fromIndex, toIndex = _a.toIndex;
        rankFunction(questionModel, fromIndex, toIndex, dropTargetNode);
    };
    Object.defineProperty(DragDropRankingSelectToRank.prototype, "isDraggedElementRanked", {
        get: function () {
            return this.parentElement.rankingChoices.indexOf(this.draggedElement) !== -1;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DragDropRankingSelectToRank.prototype, "isDropTargetRanked", {
        get: function () {
            if (this.dropTarget === "to-container")
                return true;
            return this.parentElement.rankingChoices.indexOf(this.dropTarget) !== -1;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DragDropRankingSelectToRank.prototype, "isDraggedElementUnranked", {
        get: function () {
            return !this.isDraggedElementRanked;
        },
        enumerable: false,
        configurable: true
    });
    DragDropRankingSelectToRank.prototype.updateChoices = function (questionModel, rankingChoices) {
        questionModel.isValueSetByUser = true;
        questionModel.rankingChoices = rankingChoices;
        questionModel.updateUnRankingChoices(rankingChoices);
    };
    return DragDropRankingSelectToRank;
}(ranking_choices_DragDropRankingChoices));


// CONCATENATED MODULE: ./packages/survey-core/src/question_ranking.ts
var question_ranking_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var question_ranking_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};













/**
 * A class that describes the Ranking question type.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/questiontype-ranking/ (linkStyle))
 */
var question_ranking_QuestionRankingModel = /** @class */ (function (_super) {
    question_ranking_extends(QuestionRankingModel, _super);
    function QuestionRankingModel(name) {
        var _this = _super.call(this, name) || this;
        _this.domNode = null;
        _this.onVisibleChoicesChanged = function () {
            _super.prototype.onVisibleChoicesChanged.call(_this);
            if (_this.carryForwardStartUnranked && !_this.isValueSetByUser && !_this.selectToRankEnabled && !_this.defaultValue) {
                _this.value = [];
            }
            // ranking question with only one choice doesn't make sense
            if (_this.visibleChoices.length === 1 && !_this.selectToRankEnabled) {
                _this.value = [];
                _this.value.push(_this.visibleChoices[0].value);
                _this.updateRankingChoices();
                return;
            }
            if (_this.isEmpty()) {
                _this.updateRankingChoices();
                return;
            }
            if (_this.selectToRankEnabled) {
                _this.updateRankingChoices();
                return;
            }
            if (_this.visibleChoices.length > _this.value.length)
                _this.addToValueByVisibleChoices();
            if (_this.visibleChoices.length < _this.value.length)
                _this.removeFromValueByVisibleChoices();
            _this.updateRankingChoices();
        };
        _this.localeChanged = function () {
            _super.prototype.localeChanged.call(_this);
            _this.updateRankingChoicesSync();
        };
        _this._rankingChoicesAnimation = new animation_AnimationGroup(_this.getChoicesAnimationOptions(true), function (val) {
            _this._renderedRankingChoices = val;
        }, function () { return _this.renderedRankingChoices; });
        _this._unRankingChoicesAnimation = new animation_AnimationGroup(_this.getChoicesAnimationOptions(false), function (val) {
            _this._renderedUnRankingChoices = val;
        }, function () { return _this.renderedUnRankingChoices; });
        _this.rankingChoices = [];
        _this.unRankingChoices = [];
        _this._renderedRankingChoices = [];
        _this._renderedUnRankingChoices = [];
        _this.handlePointerDown = function (event, choice, node) {
            var target = event.target;
            if (!_this.isDragStartNodeValid(target))
                return;
            if (_this.isAllowStartDrag(target, choice)) {
                _this.draggedChoiceValue = choice.value;
                _this.draggedTargetNode = node;
                _this.dragOrClickHelper.onPointerDown(event);
            }
        };
        _this.startDrag = function (event) {
            var choice = itemvalue_ItemValue.getItemByValue(_this.activeChoices, _this.draggedChoiceValue);
            _this.dragDropRankingChoices.startDrag(event, choice, _this, _this.draggedTargetNode);
        };
        _this.handlePointerUp = function (event, choice, node) {
            if (!_this.selectToRankEnabled)
                return;
            var target = event.target;
            if (_this.isAllowStartDrag(target, choice)) {
                _this.handleKeydownSelectToRank(event, choice, " ", false);
            }
        };
        _this.handleKeydown = function (event, choice) {
            if (_this.isReadOnlyAttr)
                return;
            if (!_this.isDesignMode) {
                var key = event.key;
                var index = _this.rankingChoices.indexOf(choice);
                if (_this.selectToRankEnabled) {
                    _this.handleKeydownSelectToRank(event, choice);
                    return;
                }
                if ((key === "ArrowUp" && index) || (key === "ArrowDown" && index !== _this.rankingChoices.length - 1)) {
                    var toIndex = key == "ArrowUp" ? index - 1 : index + 1;
                    _this.dragDropRankingChoices.reorderRankedItem(_this, index, toIndex);
                    _this.setValueAfterKeydown(toIndex, "", true, event);
                }
            }
        };
        _this.focusItem = function (index, container) {
            if (!_this.domNode)
                return;
            if (_this.selectToRankEnabled && container) {
                var containerSelector = "[data-ranking='" + container + "']";
                var itemsNodes = _this.domNode.querySelectorAll(containerSelector + " " + "." + _this.cssClasses.item);
                itemsNodes[index].focus();
            }
            else {
                var itemsNodes = _this.domNode.querySelectorAll("." + _this.cssClasses.item);
                itemsNodes[index].focus();
            }
        };
        _this.isValueSetByUser = false;
        _this.setValue = function () {
            var value = [];
            _this.rankingChoices.forEach(function (choice) {
                value.push(choice.value);
            });
            _this.value = value;
            _this.isValueSetByUser = true;
        };
        _this.registerFunctionOnPropertyValueChanged("selectToRankEnabled", function () {
            _this.clearValue(true);
            _this.setDragDropRankingChoices();
            _this.updateRankingChoicesSync();
        });
        _this.dragOrClickHelper = new dragOrClickHelper_DragOrClickHelper(_this.startDrag);
        return _this;
    }
    QuestionRankingModel.prototype.getType = function () {
        return "ranking";
    };
    QuestionRankingModel.prototype.getItemTabIndex = function (item) {
        if (this.isDesignMode || item.disabled)
            return undefined;
        return 0;
    };
    QuestionRankingModel.prototype.supportContainerQueries = function () {
        return this.selectToRankEnabled;
    };
    Object.defineProperty(QuestionRankingModel.prototype, "rootClass", {
        get: function () {
            return new CssClassBuilder()
                .append(this.cssClasses.root)
                .append(this.cssClasses.rootMobileMod, this.isMobileMode())
                .append(this.cssClasses.rootDisabled, this.isDisabledStyle)
                .append(this.cssClasses.rootReadOnly, this.isReadOnlyStyle)
                .append(this.cssClasses.rootPreview, this.isPreviewStyle)
                .append(this.cssClasses.rootDesignMode, !!this.isDesignMode)
                .append(this.cssClasses.itemOnError, this.hasCssError())
                .append(this.cssClasses.rootDragHandleAreaIcon, settings.rankingDragHandleArea === "icon")
                .append(this.cssClasses.rootSelectToRankMod, this.selectToRankEnabled)
                .append(this.cssClasses.rootSelectToRankEmptyValueMod, this.isEmpty())
                .append(this.cssClasses.rootSelectToRankAlignHorizontal, this.selectToRankEnabled && this.renderedSelectToRankAreasLayout === "horizontal")
                .append(this.cssClasses.rootSelectToRankAlignVertical, this.selectToRankEnabled && this.renderedSelectToRankAreasLayout === "vertical")
                .toString();
        },
        enumerable: false,
        configurable: true
    });
    QuestionRankingModel.prototype.isItemSelectedCore = function (item) {
        if (this.selectToRankEnabled) {
            return _super.prototype.isItemSelectedCore.call(this, item);
        }
        return true;
    };
    QuestionRankingModel.prototype.getItemClassCore = function (item, options) {
        return new CssClassBuilder()
            .append(_super.prototype.getItemClassCore.call(this, item, options))
            .append(this.cssClasses.itemGhostMod, this.currentDropTarget === item)
            .toString();
    };
    QuestionRankingModel.prototype.getContainerClasses = function (containerType) {
        var isEmpty = false;
        var isToContainer = containerType === "to";
        var isFromContainer = containerType === "from";
        if (isToContainer) {
            isEmpty = this.renderedRankingChoices.length === 0;
        }
        else if (isFromContainer) {
            isEmpty = this.renderedUnRankingChoices.length === 0;
        }
        return new CssClassBuilder()
            .append(this.cssClasses.container)
            .append(this.cssClasses.containerToMode, isToContainer)
            .append(this.cssClasses.containerFromMode, isFromContainer)
            .append(this.cssClasses.containerEmptyMode, isEmpty)
            .toString();
    };
    QuestionRankingModel.prototype.isItemCurrentDropTarget = function (item) {
        return this.dragDropRankingChoices.dropTarget === item;
    };
    Object.defineProperty(QuestionRankingModel.prototype, "ghostPositionCssClass", {
        get: function () {
            if (this.ghostPosition === "top")
                return this.cssClasses.dragDropGhostPositionTop;
            if (this.ghostPosition === "bottom")
                return this.cssClasses.dragDropGhostPositionBottom;
            return "";
        },
        enumerable: false,
        configurable: true
    });
    QuestionRankingModel.prototype.getItemIndexClasses = function (item) {
        var noNumber;
        if (this.selectToRankEnabled) {
            noNumber = this.unRankingChoices.indexOf(item) !== -1;
        }
        else {
            noNumber = this.isEmpty();
        }
        return new CssClassBuilder()
            .append(this.cssClasses.itemIndex)
            .append(this.cssClasses.itemIndexEmptyMode, noNumber)
            .toString();
    };
    QuestionRankingModel.prototype.getNumberByIndex = function (index) {
        return this.isEmpty() ? "" : index + 1 + "";
    };
    QuestionRankingModel.prototype.updateRankingChoicesSync = function () {
        this.blockAnimations();
        this.updateRankingChoices();
        this.releaseAnimations();
    };
    QuestionRankingModel.prototype.setSurveyImpl = function (value, isLight) {
        _super.prototype.setSurveyImpl.call(this, value, isLight);
        this.setDragDropRankingChoices();
        this.updateRankingChoicesSync();
    };
    QuestionRankingModel.prototype.isAnswerCorrect = function () {
        return helpers_Helpers.isArraysEqual(this.value, this.correctAnswer, false);
    };
    Object.defineProperty(QuestionRankingModel.prototype, "requireStrictCompare", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    QuestionRankingModel.prototype.onSurveyValueChanged = function (newValue) {
        _super.prototype.onSurveyValueChanged.call(this, newValue);
        if (this.isLoadingFromJson)
            return;
        this.updateRankingChoices();
    };
    QuestionRankingModel.prototype.onSurveyLoad = function () {
        this.blockAnimations();
        _super.prototype.onSurveyLoad.call(this);
        this.updateRankingChoices();
        this.releaseAnimations();
    };
    QuestionRankingModel.prototype.addToValueByVisibleChoices = function () {
        var newValue = this.value.slice();
        this.visibleChoices.forEach(function (choice) {
            if (newValue.indexOf(choice.value) === -1) {
                newValue.push(choice.value);
            }
        });
        this.value = newValue;
    };
    QuestionRankingModel.prototype.removeFromValueByVisibleChoices = function () {
        var newValue = this.value.slice();
        var choices = this.visibleChoices;
        for (var i = this.value.length - 1; i >= 0; i--) {
            if (!itemvalue_ItemValue.getItemByValue(choices, this.value[i])) {
                newValue.splice(i, 1);
            }
        }
        this.value = newValue;
    };
    QuestionRankingModel.prototype.getChoicesAnimationOptions = function (isRankingChoices) {
        var _this = this;
        return {
            getKey: function (item) {
                return item.value;
            },
            getRerenderEvent: function () {
                return _this.onElementRerendered;
            },
            isAnimationEnabled: function () { return _this.animationAllowed && !_this.isDesignMode && _this.isVisible && !!_this.domNode; },
            getReorderOptions: function (item, movedForward) {
                var cssClass = "";
                if (item !== _this.currentDropTarget) {
                    cssClass = movedForward ? "sv-dragdrop-movedown" : "sv-dragdrop-moveup";
                }
                return { cssClass: cssClass };
            },
            getLeaveOptions: function (item) {
                var choices = isRankingChoices ? _this.renderedRankingChoices : _this.renderedUnRankingChoices;
                if (_this.renderedSelectToRankAreasLayout == "vertical" && choices.length == 1 && choices.indexOf(item) >= 0) {
                    return { cssClass: "sv-ranking-item--animate-item-removing-empty" };
                }
                return { cssClass: "sv-ranking-item--animate-item-removing", onBeforeRunAnimation: function (el) {
                        el.style.setProperty("--animation-height", el.offsetHeight + "px");
                    } };
            },
            getEnterOptions: function (item) {
                var choices = isRankingChoices ? _this.renderedRankingChoices : _this.renderedUnRankingChoices;
                if (_this.renderedSelectToRankAreasLayout == "vertical" && choices.length == 1 && choices.indexOf(item) >= 0) {
                    return { cssClass: "sv-ranking-item--animate-item-adding-empty" };
                }
                return { cssClass: "sv-ranking-item--animate-item-adding", onBeforeRunAnimation: function (el) {
                        el.style.setProperty("--animation-height", el.offsetHeight + "px");
                    } };
            },
            getAnimatedElement: function (item) {
                var _a;
                var cssClasses = _this.cssClasses;
                var containerSelector = "";
                if (_this.selectToRankEnabled) {
                    if (!isRankingChoices && cssClasses.containerFromMode) {
                        containerSelector = classesToSelector(cssClasses.containerFromMode);
                    }
                    else if (isRankingChoices && cssClasses.containerToMode) {
                        containerSelector = classesToSelector(cssClasses.containerToMode);
                    }
                }
                var index = isRankingChoices ? _this.renderedRankingChoices.indexOf(item) : _this.renderedUnRankingChoices.indexOf(item);
                return (_a = _this.domNode) === null || _a === void 0 ? void 0 : _a.querySelector(containerSelector + " [data-sv-drop-target-ranking-item='" + index + "']");
            },
            allowSyncRemovalAddition: true
        };
    };
    Object.defineProperty(QuestionRankingModel.prototype, "rankingChoicesAnimation", {
        get: function () {
            return this._rankingChoicesAnimation;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRankingModel.prototype, "unRankingChoicesAnimation", {
        get: function () {
            return this._unRankingChoicesAnimation;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRankingModel.prototype, "renderedRankingChoices", {
        get: function () {
            return this._renderedRankingChoices;
        },
        set: function (val) {
            this.rankingChoicesAnimation.sync(val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRankingModel.prototype, "renderedUnRankingChoices", {
        get: function () {
            return this._renderedUnRankingChoices;
        },
        set: function (val) {
            this.unRankingChoicesAnimation.sync(val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionRankingModel.prototype.updateRenderedRankingChoices = function () {
        this.renderedRankingChoices = this.rankingChoices;
    };
    QuestionRankingModel.prototype.updateRenderedUnRankingChoices = function () {
        this.renderedUnRankingChoices = this.unRankingChoices;
    };
    QuestionRankingModel.prototype.updateRankingChoices = function (forceUpdate) {
        var _this = this;
        if (forceUpdate === void 0) { forceUpdate = false; }
        if (this.selectToRankEnabled) {
            this.updateRankingChoicesSelectToRankMode(forceUpdate);
            return;
        }
        var newRankingChoices = [];
        // ranking question with only one choice doesn't make sense
        // if (this.visibleChoices.length === 1) {
        //   this.setPropertyValue("rankingChoices", newRankingChoices);
        //   return;
        // }
        if (forceUpdate)
            this.rankingChoices = [];
        if (this.isEmpty()) {
            this.rankingChoices = this.visibleChoices;
            return;
        }
        this.value.forEach(function (valueItem) {
            _this.visibleChoices.forEach(function (choice) {
                if (choice.value === valueItem)
                    newRankingChoices.push(choice);
            });
        });
        this.rankingChoices = newRankingChoices;
    };
    QuestionRankingModel.prototype.updateUnRankingChoices = function (newRankingChoices) {
        var unRankingChoices = [];
        this.visibleChoices.forEach(function (choice) {
            unRankingChoices.push(choice);
        });
        newRankingChoices.forEach(function (rankingChoice) {
            unRankingChoices.forEach(function (choice, index) {
                if (choice.value === rankingChoice.value)
                    unRankingChoices.splice(index, 1);
            });
        });
        this.unRankingChoices = unRankingChoices;
    };
    QuestionRankingModel.prototype.updateRankingChoicesSelectToRankMode = function (forceUpdate) {
        var _this = this;
        var newRankingChoices = [];
        if (!this.isEmpty()) {
            this.value.forEach(function (valueItem) {
                _this.visibleChoices.forEach(function (choice) {
                    if (choice.value === valueItem)
                        newRankingChoices.push(choice);
                });
            });
        }
        this.updateUnRankingChoices(newRankingChoices);
        this.rankingChoices = newRankingChoices;
    };
    QuestionRankingModel.prototype.endLoadingFromJson = function () {
        _super.prototype.endLoadingFromJson.call(this);
        this.setDragDropRankingChoices();
    };
    QuestionRankingModel.prototype.setDragDropRankingChoices = function () {
        this.dragDropRankingChoices = this.createDragDropRankingChoices();
    };
    QuestionRankingModel.prototype.createDragDropRankingChoices = function () {
        if (this.selectToRankEnabled)
            return new DragDropRankingSelectToRank(this.survey, null, this.longTap);
        return new ranking_choices_DragDropRankingChoices(this.survey, null, this.longTap);
    };
    QuestionRankingModel.prototype.isDragStartNodeValid = function (target) {
        if (settings.rankingDragHandleArea === "icon") {
            return target.classList.contains(this.cssClasses.itemIconHoverMod);
        }
        return true;
    };
    QuestionRankingModel.prototype.isAllowStartDrag = function (target, choice) {
        return !this.isReadOnly &&
            !this.isDesignMode &&
            this.canStartDragDueMaxSelectedChoices(target) &&
            this.canStartDragDueItemEnabled(choice);
    };
    QuestionRankingModel.prototype.canStartDragDueMaxSelectedChoices = function (target) {
        if (!this.selectToRankEnabled)
            return true;
        var fromContainer = target.closest("[data-ranking='from-container']");
        if (fromContainer) {
            return this.checkMaxSelectedChoicesUnreached();
        }
        return true;
    };
    QuestionRankingModel.prototype.canStartDragDueItemEnabled = function (item) {
        return item.enabled;
    };
    QuestionRankingModel.prototype.checkMaxSelectedChoicesUnreached = function () {
        if (this.maxSelectedChoices < 1)
            return true;
        var val = this.value;
        var len = !Array.isArray(val) ? 0 : val.length;
        return len < this.maxSelectedChoices;
    };
    //cross framework initialization
    QuestionRankingModel.prototype.afterRenderQuestionElement = function (el) {
        this.domNode = el;
        _super.prototype.afterRenderQuestionElement.call(this, el);
    };
    //cross framework destroy
    QuestionRankingModel.prototype.beforeDestroyQuestionElement = function (el) {
        this.domNode = undefined;
        _super.prototype.beforeDestroyQuestionElement.call(this, el);
    };
    QuestionRankingModel.prototype.supportSelectAll = function () { return false; };
    QuestionRankingModel.prototype.supportOther = function () { return false; };
    QuestionRankingModel.prototype.supportNone = function () { return false; };
    QuestionRankingModel.prototype.supportRefuse = function () { return false; };
    QuestionRankingModel.prototype.supportDontKnow = function () { return false; };
    QuestionRankingModel.prototype.handleKeydownSelectToRank = function (event, movedElement, hardKey, isNeedFocus) {
        if (isNeedFocus === void 0) { isNeedFocus = true; }
        if (this.isDesignMode)
            return;
        var key = event.key;
        if (hardKey)
            key = hardKey;
        if (key !== " " && key !== "ArrowUp" && key !== "ArrowDown")
            return;
        var dnd = this.dragDropRankingChoices; //????
        var rankingChoices = this.rankingChoices;
        var isMovedElementRanked = rankingChoices.indexOf(movedElement) !== -1;
        var choices = isMovedElementRanked ? rankingChoices : this.unRankingChoices;
        var fromIndex = choices.indexOf(movedElement);
        if (fromIndex < 0)
            return;
        var toIndex;
        if (key === " " && !isMovedElementRanked) {
            if (!this.checkMaxSelectedChoicesUnreached() || !this.canStartDragDueItemEnabled(movedElement))
                return;
            toIndex = this.value.length;
            dnd.selectToRank(this, fromIndex, toIndex);
            this.setValueAfterKeydown(toIndex, "to-container", isNeedFocus, event);
            return;
        }
        if (!isMovedElementRanked)
            return;
        if (key === " ") {
            dnd.unselectFromRank(this, fromIndex);
            toIndex = this.unRankingChoices.indexOf(movedElement); //'this.' leads to actual array after the 'unselectFromRank' method
            this.setValueAfterKeydown(toIndex, "from-container", isNeedFocus, event);
            return;
        }
        var delta = key === "ArrowUp" ? -1 : (key === "ArrowDown" ? 1 : 0);
        if (delta === 0)
            return;
        toIndex = fromIndex + delta;
        if (toIndex < 0 || toIndex >= rankingChoices.length)
            return;
        dnd.reorderRankedItem(this, fromIndex, toIndex);
        this.setValueAfterKeydown(toIndex, "to-container", isNeedFocus, event);
    };
    QuestionRankingModel.prototype.setValueAfterKeydown = function (index, container, isNeedFocus, event) {
        var _this = this;
        if (isNeedFocus === void 0) { isNeedFocus = true; }
        this.setValue();
        if (isNeedFocus) {
            setTimeout(function () {
                _this.focusItem(index, container);
            }, 1);
        }
        event && event.preventDefault();
    };
    QuestionRankingModel.prototype.getIconHoverCss = function () {
        return new CssClassBuilder()
            .append(this.cssClasses.itemIcon)
            .append(this.cssClasses.itemIconHoverMod)
            .toString();
    };
    QuestionRankingModel.prototype.getIconFocusCss = function () {
        return new CssClassBuilder()
            .append(this.cssClasses.itemIcon)
            .append(this.cssClasses.itemIconFocusMod)
            .toString();
    };
    Object.defineProperty(QuestionRankingModel.prototype, "longTap", {
        /**
         * Specifies whether to use a long tap (press and hold) gesture to start dragging.
         *
         * Default value: `true`
         *
         * Disable this property if you want to start dragging when users perform a scroll gesture.
        */
        get: function () {
            return this.getPropertyValue("longTap");
        },
        set: function (val) {
            this.setPropertyValue("longTap", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionRankingModel.prototype.getDefaultItemComponent = function () {
        return "sv-ranking-item";
    };
    Object.defineProperty(QuestionRankingModel.prototype, "selectToRankEnabled", {
        /**
         * Specifies whether users can select choices they want to rank.
         *
         * When you enable this property, the Ranking question displays two areas for ranked and unranked choices. To order choices, users should first drag them from the unranked to the ranked area. Use this mode if you want to let users order only the choices they select.
         *
         * Default value: `false`
         * @see selectToRankAreasLayout
        */
        get: function () {
            return this.getPropertyValue("selectToRankEnabled", false);
        },
        set: function (val) {
            this.setPropertyValue("selectToRankEnabled", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRankingModel.prototype, "selectToRankAreasLayout", {
        /**
         * Specifies the layout of the ranked and unranked areas. Applies when [`selectToRankEnabled`](https://surveyjs.io/form-library/documentation/api-reference/ranking-question-model#selectToRankEnabled) is `true`.
         *
         * Possible values:
         *
         * - `"horizontal"` (default) - The ranked and unranked areas are positioned next to each other. Users drag and drop choices between them in the horizontal direction.
         * - `"vertical"`- The ranked area is positioned above the unranked area. Users drag and drop choices between them in the vertical direction.
         * @see selectToRankAreasLayout
        */
        get: function () {
            return this.getPropertyValue("selectToRankAreasLayout");
        },
        set: function (val) {
            this.setPropertyValue("selectToRankAreasLayout", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRankingModel.prototype, "renderedSelectToRankAreasLayout", {
        get: function () {
            if (this.isMobileMode())
                return "vertical";
            return this.selectToRankAreasLayout;
        },
        enumerable: false,
        configurable: true
    });
    QuestionRankingModel.prototype.isMobileMode = function () {
        return IsMobile;
    };
    Object.defineProperty(QuestionRankingModel.prototype, "useFullItemSizeForShortcut", {
        get: function () {
            return this.getPropertyValue("useFullItemSizeForShortcut");
        },
        set: function (val) {
            this.setPropertyValue("useFullItemSizeForShortcut", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRankingModel.prototype, "dragDropSvgIcon", {
        get: function () {
            return this.cssClasses.dragDropSvgIconId || "#icon-drag-n-drop";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRankingModel.prototype, "arrowsSvgIcon", {
        get: function () {
            return this.cssClasses.arrowsSvgIconId || "#icon-ranking-arrows";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRankingModel.prototype, "dashSvgIcon", {
        get: function () {
            return this.cssClasses.dashSvgIconId || "#icon-ranking-dash";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRankingModel.prototype, "isNewA11yStructure", {
        //a11y
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    question_ranking_decorate([
        propertyArray({
            onSet: function (val, target) { return target.updateRenderedRankingChoices(); },
            onRemove: function (_, _i, target) { return target.updateRenderedRankingChoices(); },
            onPush: function (_, _i, target) { return target.updateRenderedRankingChoices(); },
        })
    ], QuestionRankingModel.prototype, "rankingChoices", void 0);
    question_ranking_decorate([
        propertyArray({ onSet: function (val, target) { return target.updateRenderedUnRankingChoices(); },
            onRemove: function (_, _i, target) { return target.updateRenderedUnRankingChoices(); },
            onPush: function (_, _i, target) { return target.updateRenderedUnRankingChoices(); },
        })
    ], QuestionRankingModel.prototype, "unRankingChoices", void 0);
    question_ranking_decorate([
        propertyArray()
    ], QuestionRankingModel.prototype, "_renderedRankingChoices", void 0);
    question_ranking_decorate([
        propertyArray()
    ], QuestionRankingModel.prototype, "_renderedUnRankingChoices", void 0);
    question_ranking_decorate([
        jsonobject_property({ defaultValue: null })
    ], QuestionRankingModel.prototype, "currentDropTarget", void 0);
    question_ranking_decorate([
        jsonobject_property({ defaultValue: true })
    ], QuestionRankingModel.prototype, "carryForwardStartUnranked", void 0);
    question_ranking_decorate([
        jsonobject_property({ localizable: { defaultStr: "selectToRankEmptyRankedAreaText" } })
    ], QuestionRankingModel.prototype, "selectToRankEmptyRankedAreaText", void 0);
    question_ranking_decorate([
        jsonobject_property({ localizable: { defaultStr: "selectToRankEmptyUnrankedAreaText" } })
    ], QuestionRankingModel.prototype, "selectToRankEmptyUnrankedAreaText", void 0);
    return QuestionRankingModel;
}(question_checkbox_QuestionCheckboxModel));

Serializer.addClass("ranking", [
    { name: "showOtherItem", visible: false, isSerializable: false },
    { name: "otherText", visible: false, isSerializable: false },
    { name: "otherErrorText", visible: false, isSerializable: false },
    { name: "storeOthersAsComment", visible: false, isSerializable: false },
    { name: "showNoneItem", visible: false, isSerializable: false },
    { name: "showRefuseItem", visible: false, isSerializable: false },
    { name: "showDontKnowItem", visible: false, isSerializable: false },
    { name: "noneText", visible: false, isSerializable: false },
    { name: "showSelectAllItem", visible: false, isSerializable: false },
    { name: "selectAllText", visible: false, isSerializable: false },
    { name: "colCount:number", visible: false, isSerializable: false },
    { name: "separateSpecialChoices", visible: false, isSerializable: false },
    {
        name: "longTap",
        default: true,
        visible: false,
        isSerializable: false,
    },
    {
        name: "selectToRankEnabled:switch",
        default: false,
        visible: true,
        isSerializable: true,
    },
    {
        name: "selectToRankAreasLayout",
        default: "horizontal",
        choices: ["horizontal", "vertical"],
        dependsOn: "selectToRankEnabled",
        visibleIf: function (obj) {
            return !!obj.selectToRankEnabled;
        },
        visible: true,
        isSerializable: true,
    },
    {
        name: "selectToRankEmptyRankedAreaText:text",
        serializationProperty: "locSelectToRankEmptyRankedAreaText",
        category: "general",
        dependsOn: "selectToRankEnabled",
        visibleIf: function (obj) {
            return !!obj.selectToRankEnabled;
        },
    },
    {
        name: "selectToRankEmptyUnrankedAreaText:text",
        serializationProperty: "locSelectToRankEmptyUnrankedAreaText",
        category: "general",
        dependsOn: "selectToRankEnabled",
        visibleIf: function (obj) {
            return !!obj.selectToRankEnabled;
        },
    },
    {
        name: "maxSelectedChoices:number",
        visible: true,
        default: 0,
        dependsOn: "selectToRankEnabled",
        visibleIf: function (obj) {
            return !!obj.selectToRankEnabled;
        },
        isSerializable: true
    },
    { name: "minSelectedChoices:number",
        visible: true,
        default: 0,
        dependsOn: "selectToRankEnabled", visibleIf: function (obj) {
            return !!obj.selectToRankEnabled;
        }, isSerializable: true },
    { name: "itemComponent", visible: false, default: "sv-ranking-item" },
], function () {
    return new question_ranking_QuestionRankingModel("");
}, "checkbox");
questionfactory_QuestionFactory.Instance.registerQuestion("ranking", function (name) {
    var q = new question_ranking_QuestionRankingModel(name);
    q.choices = questionfactory_QuestionFactory.DefaultChoices;
    return q;
});

// CONCATENATED MODULE: ./packages/survey-core/src/question_comment.ts
var question_comment_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();





/**
 * A class that describes the Long Text question type.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/questiontype-comment/ (linkStyle))
 */
var question_comment_QuestionCommentModel = /** @class */ (function (_super) {
    question_comment_extends(QuestionCommentModel, _super);
    function QuestionCommentModel() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(QuestionCommentModel.prototype, "rows", {
        /**
         * Specifies the visible height of the comment area, measured in lines.
         *
         * The value of this property is passed on to the `rows` attribute of the underlying `<textarea>` element.
         */
        get: function () {
            return this.getPropertyValue("rows");
        },
        set: function (val) {
            this.setPropertyValue("rows", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCommentModel.prototype, "cols", {
        get: function () {
            return this.getPropertyValue("cols");
        },
        set: function (val) {
            this.setPropertyValue("cols", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCommentModel.prototype, "acceptCarriageReturn", {
        /**
         * Specifies whether the question allows line breaks.
         *
         * When this property is enabled, a user can press Enter to insert line breaks. They are saved as `\n` in survey results. The Comment question also recognizes and interprets the `\n` sequence as a line break when you set the question `value` in code.
         */
        get: function () {
            return this.getPropertyValue("acceptCarriageReturn");
        },
        set: function (val) {
            this.setPropertyValue("acceptCarriageReturn", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCommentModel.prototype, "autoGrow", {
        /**
         * Specifies whether the comment area automatically increases its height to accomodate multi-line content.
         *
         * Default value: `false` (inherited from `SurveyModel`'s [`autoGrowComment`](https://surveyjs.io/form-library/documentation/surveymodel#autoGrowComment) property)
         * @see allowResize
         */
        get: function () {
            return this.getPropertyValue("autoGrow");
        },
        set: function (val) {
            this.setPropertyValue("autoGrow", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCommentModel.prototype, "renderedAutoGrow", {
        get: function () {
            var autoGrow = this.autoGrow;
            return autoGrow === undefined && this.survey ? this.survey.autoGrowComment : !!autoGrow;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCommentModel.prototype, "allowResize", {
        /**
         *
         * Default value: `true` (inherited from `SurveyModel`'s [`allowResizeComment`](https://surveyjs.io/form-library/documentation/surveymodel#allowResizeComment) property)
         * @see autoGrow
         */
        get: function () {
            return this.getPropertyValue("allowResize");
        },
        set: function (val) {
            this.setPropertyValue("allowResize", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCommentModel.prototype, "renderedAllowResize", {
        get: function () {
            var res = this.allowResize;
            var allowResize = res === undefined && this.survey ? this.survey.allowResizeComment : !!res;
            return allowResize && !this.isPreviewStyle && !this.isReadOnlyStyle;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionCommentModel.prototype, "resizeStyle", {
        get: function () {
            return this.renderedAllowResize ? "both" : "none";
        },
        enumerable: false,
        configurable: true
    });
    QuestionCommentModel.prototype.getType = function () {
        return "comment";
    };
    QuestionCommentModel.prototype.afterRenderQuestionElement = function (el) {
        var root = settings.environment.root;
        this.element = root.getElementById(this.inputId) || el;
        this.updateElement();
        _super.prototype.afterRenderQuestionElement.call(this, el);
    };
    QuestionCommentModel.prototype.updateElement = function () {
        var _this = this;
        if (this.element && this.renderedAutoGrow) {
            setTimeout(function () { return increaseHeightByContent(_this.element); }, 1);
        }
    };
    QuestionCommentModel.prototype.beforeDestroyQuestionElement = function (el) {
        _super.prototype.beforeDestroyQuestionElement.call(this, el);
        this.element = undefined;
    };
    QuestionCommentModel.prototype.onInput = function (event) {
        if (this.isInputTextUpdate)
            this.value = event.target.value;
        else
            this.updateElement();
        this.updateRemainingCharacterCounter(event.target.value);
    };
    QuestionCommentModel.prototype.onBlurCore = function (event) {
        _super.prototype.onBlurCore.call(this, event);
    };
    QuestionCommentModel.prototype.onKeyDown = function (event) {
        this.onKeyDownPreprocess && this.onKeyDownPreprocess(event);
        if (!this.acceptCarriageReturn && (event.key === "Enter" || event.keyCode === 13)) {
            event.preventDefault();
            event.stopPropagation();
        }
    };
    QuestionCommentModel.prototype.setQuestionValue = function (newValue, updateIsAnswered) {
        if (updateIsAnswered === void 0) { updateIsAnswered = true; }
        _super.prototype.setQuestionValue.call(this, newValue, updateIsAnswered);
        this.updateElement();
    };
    QuestionCommentModel.prototype.onValueChanged = function () {
        _super.prototype.onValueChanged.call(this);
        this.updateElement();
    };
    QuestionCommentModel.prototype.setNewValue = function (newValue) {
        if (!this.acceptCarriageReturn && !!newValue) {
            // eslint-disable-next-line no-control-regex
            newValue = newValue.replace(new RegExp("(\r\n|\n|\r)", "gm"), "");
        }
        _super.prototype.setNewValue.call(this, newValue);
    };
    QuestionCommentModel.prototype.getValueSeparator = function () { return "\n"; };
    Object.defineProperty(QuestionCommentModel.prototype, "className", {
        get: function () {
            return (this.cssClasses ? this.getControlClass() : "panel-comment-root") || undefined;
        },
        enumerable: false,
        configurable: true
    });
    return QuestionCommentModel;
}(question_textbase_QuestionTextBase));

Serializer.addClass("comment", [
    { name: "maxLength:number", default: -1 },
    { name: "cols:number", default: 50, visible: false, isSerializable: false },
    { name: "rows:number", default: 4 },
    { name: "placeholder",
        alternativeName: "placeHolder",
        serializationProperty: "locPlaceholder" },
    {
        name: "textUpdateMode",
        default: "default",
        choices: ["default", "onBlur", "onTyping"],
    },
    { name: "autoGrow:boolean", defaultFunc: function () { return undefined; } },
    { name: "allowResize:boolean", defaultFunc: function () { return undefined; } },
    { name: "acceptCarriageReturn:boolean", default: true, visible: false }
], function () {
    return new question_comment_QuestionCommentModel("");
}, "textbase");
questionfactory_QuestionFactory.Instance.registerQuestion("comment", function (name) {
    return new question_comment_QuestionCommentModel(name);
});

// CONCATENATED MODULE: ./packages/survey-core/src/utils/camera.ts

var camera_Camera = /** @class */ (function () {
    function Camera() {
        this.canFlipValue = undefined;
    }
    Camera.clear = function () {
        Camera.cameraList = undefined;
        Camera.cameraIndex = -1;
    };
    Camera.setCameraList = function (list) {
        var getDeviceType = function (device) {
            var lbl = device.label.toLocaleLowerCase();
            if (lbl.indexOf("user") > -1)
                return "user";
            if (lbl.indexOf("enviroment") > -1)
                return "enviroment";
            return "";
        };
        Camera.clear();
        if (Array.isArray(list) && list.length > 0) {
            Camera.cameraIndex = -1;
            list.sort(function (a, b) {
                if (a === b)
                    return 0;
                if (a.label !== b.label) {
                    var lblA = getDeviceType(a);
                    var lblB = getDeviceType(b);
                    if (lblA !== lblB) {
                        if (lblA === "user")
                            return -1;
                        if (lblB === "user")
                            return 1;
                        if (lblA === "enviroment")
                            return -1;
                        if (lblB === "enviroment")
                            return 1;
                    }
                }
                var iA = list.indexOf(a);
                var iB = list.indexOf(b);
                return iA < iB ? -1 : 1;
            });
        }
        Camera.cameraList = list;
    };
    Camera.prototype.hasCamera = function (callback) {
        var _this = this;
        if (Camera.cameraList !== undefined) {
            this.hasCameraCallback(callback);
            return;
        }
        if (Camera.mediaDevicesCallback) {
            var devicesCallback = function (devices) {
                _this.setVideoInputs(devices);
                _this.hasCameraCallback(callback);
            };
            Camera.mediaDevicesCallback(devicesCallback);
            return;
        }
        if (typeof navigator !== "undefined" && navigator.mediaDevices) {
            navigator.mediaDevices.enumerateDevices()
                .then(function (devices) {
                _this.setVideoInputs(devices);
                _this.hasCameraCallback(callback);
                _this.updateCanFlipValue();
            })
                .catch(function (error) {
                Camera.cameraList = null;
                _this.hasCameraCallback(callback);
            });
        }
        else {
            Camera.cameraList = null;
            this.hasCameraCallback(callback);
        }
    };
    Camera.prototype.getMediaConstraints = function (videoSize) {
        var devices = Camera.cameraList;
        if (!Array.isArray(devices) || devices.length < 1)
            return undefined;
        if (Camera.cameraIndex < 0)
            Camera.cameraIndex = 0;
        var selDevice = devices[Camera.cameraIndex];
        var videoConstraints = {};
        if (selDevice && selDevice.deviceId) {
            videoConstraints.deviceId = { exact: selDevice.deviceId };
        }
        else {
            videoConstraints.facingMode = Camera.cameraFacingMode;
        }
        if (videoSize) {
            if (videoSize === null || videoSize === void 0 ? void 0 : videoSize.height) {
                videoConstraints.height = { ideal: videoSize.height };
            }
            if (videoSize === null || videoSize === void 0 ? void 0 : videoSize.width) {
                videoConstraints.width = { ideal: videoSize.width };
            }
        }
        return {
            video: videoConstraints,
            audio: false
        };
    };
    Camera.prototype.startVideo = function (videoElement, callback, imageWidth, imageHeight) {
        var _this = this;
        if (!videoElement) {
            callback(undefined);
            return;
        }
        videoElement.style.width = "100%";
        videoElement.style.height = "auto";
        videoElement.style.height = "100%";
        videoElement.style.objectFit = "contain";
        var mediaConstraints = this.getMediaConstraints({ width: imageWidth, height: imageHeight });
        navigator.mediaDevices.getUserMedia(mediaConstraints).then(function (stream) {
            var _a;
            videoElement.srcObject = stream;
            if (!((_a = Camera.cameraList[Camera.cameraIndex]) === null || _a === void 0 ? void 0 : _a.deviceId) && !!stream.getTracks()[0].getCapabilities().facingMode) {
                Camera.canSwitchFacingMode = true;
                _this.updateCanFlipValue();
            }
            videoElement.play();
            callback(stream);
        })
            .catch(function (error) {
            callback(undefined);
        });
    };
    Camera.prototype.getImageSize = function (videoEl) {
        return { width: videoEl.videoWidth, height: videoEl.videoHeight };
    };
    Camera.prototype.snap = function (videoElement, callback) {
        if (!videoElement)
            return false;
        if (!DomDocumentHelper.isAvailable())
            return false;
        var root = DomDocumentHelper.getDocument();
        var canvasEl = root.createElement("canvas");
        var imageSize = this.getImageSize(videoElement);
        canvasEl.height = imageSize.height;
        canvasEl.width = imageSize.width;
        var context = canvasEl.getContext("2d");
        /*
        if(this._facingMode == 'user'){
          context.translate(canvasEl.width, 0);
          context.scale(-1, 1);
        }
        */
        context.clearRect(0, 0, canvasEl.width, canvasEl.height);
        context.drawImage(videoElement, 0, 0, canvasEl.width, canvasEl.height);
        canvasEl.toBlob(callback, "image/png");
        return true;
    };
    Camera.prototype.updateCanFlipValue = function () {
        var list = Camera.cameraList;
        this.canFlipValue = Array.isArray(list) && list.length > 1 || Camera.canSwitchFacingMode;
        if (this.onCanFlipChangedCallback)
            this.onCanFlipChangedCallback(this.canFlipValue);
    };
    Camera.prototype.canFlip = function (onCanFlipChangedCallback) {
        if (this.canFlipValue === undefined) {
            this.updateCanFlipValue();
        }
        if (onCanFlipChangedCallback) {
            this.onCanFlipChangedCallback = onCanFlipChangedCallback;
        }
        return this.canFlipValue;
    };
    Camera.prototype.flip = function () {
        if (!this.canFlip())
            return;
        if (Camera.canSwitchFacingMode) {
            Camera.cameraFacingMode = Camera.cameraFacingMode === "user" ? "environment" : "user";
        }
        else if (Camera.cameraIndex >= Camera.cameraList.length - 1) {
            Camera.cameraIndex = 0;
        }
        else {
            Camera.cameraIndex++;
        }
    };
    Camera.prototype.hasCameraCallback = function (callback) {
        callback(Array.isArray(Camera.cameraList));
    };
    Camera.prototype.setVideoInputs = function (devices) {
        var list = [];
        devices.forEach(function (device) {
            if (device.kind === "videoinput") {
                list.push(device);
            }
        });
        Camera.setCameraList(list.length > 0 ? list : null);
    };
    Camera.cameraIndex = -1;
    Camera.cameraFacingMode = "user";
    Camera.canSwitchFacingMode = false;
    return Camera;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/question_file.ts
var question_file_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var question_file_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};














function dataUrl2File(dataUrl, fileName, type) {
    var str = atob(dataUrl.split(",")[1]);
    var buffer = new Uint8Array(str.split("").map(function (c) { return c.charCodeAt(0); })).buffer;
    return new File([buffer], fileName, { type: type });
}
/**
 * A base class for question types that support file upload: `QuestionFileModel` and `QuestionSignaturePadModel`.
 */
var question_file_QuestionFileModelBase = /** @class */ (function (_super) {
    question_file_extends(QuestionFileModelBase, _super);
    function QuestionFileModelBase() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.isUploading = false;
        /**
         * An event that is raised after the upload state has changed.
         *
         * Parameters:
         *
         * - `sender`: `SurveyModel`\
         * A survey instance that raised the event.
         * - `options.state`: `string`\
         * The current upload state: `"empty"`, `"loading"`, `"loaded"`, or `"error"`.
         */
        _this.onUploadStateChanged = _this.addEvent();
        _this.onStateChanged = _this.addEvent();
        return _this;
    }
    QuestionFileModelBase.prototype.stateChanged = function (state) {
        if (this.currentState == state) {
            return;
        }
        if (state === "loading") {
            this.isUploading = true;
        }
        if (state === "loaded") {
            this.isUploading = false;
        }
        if (state === "error") {
            this.isUploading = false;
        }
        this.currentState = state;
        this.onStateChanged.fire(this, { state: state });
        this.onUploadStateChanged.fire(this, { state: state });
    };
    Object.defineProperty(QuestionFileModelBase.prototype, "showLoadingIndicator", {
        get: function () {
            return this.isUploading && this.isDefaultV2Theme;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModelBase.prototype, "storeDataAsText", {
        /**
         * Specifies whether to store file or signature content as text in `SurveyModel`'s [`data`](https://surveyjs.io/form-library/documentation/surveymodel#data) property.
         *
         * If you disable this property, implement `SurveyModel`'s [`onUploadFiles`](https://surveyjs.io/form-library/documentation/surveymodel#onUploadFiles) event handler to specify how to store file content.
         */
        get: function () {
            return this.getPropertyValue("storeDataAsText");
        },
        set: function (val) {
            this.setPropertyValue("storeDataAsText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModelBase.prototype, "waitForUpload", {
        /**
           * Enable this property if you want to wait until files are uploaded to complete the survey.
           *
           * Default value: `false`
           */
        get: function () {
            return this.getPropertyValue("waitForUpload");
        },
        set: function (val) {
            this.setPropertyValue("waitForUpload", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionFileModelBase.prototype.clearValue = function (keepComment) {
        this.clearOnDeletingContainer();
        _super.prototype.clearValue.call(this, keepComment);
    };
    QuestionFileModelBase.prototype.clearOnDeletingContainer = function () {
        if (!this.survey)
            return;
        this.survey.clearFiles(this, this.name, this.value, null, function () { });
    };
    QuestionFileModelBase.prototype.onCheckForErrors = function (errors, isOnValueChanged) {
        _super.prototype.onCheckForErrors.call(this, errors, isOnValueChanged);
        if (this.isUploading && this.waitForUpload) {
            errors.push(new UploadingFileError(this.getLocalizationString("uploadingFile"), this));
        }
    };
    QuestionFileModelBase.prototype.uploadFiles = function (files) {
        var _this = this;
        if (this.survey) {
            this.stateChanged("loading");
            this.survey.uploadFiles(this, this.name, files, function (arg1, arg2) {
                if (Array.isArray(arg1)) {
                    _this.setValueFromResult(arg1);
                    if (Array.isArray(arg2)) {
                        arg2.forEach(function (error) { return _this.errors.push(new UploadingFileError(error, _this)); });
                        _this.stateChanged("error");
                    }
                }
                if (arg1 === "success" && Array.isArray(arg2)) {
                    _this.setValueFromResult(arg2);
                }
                if (arg1 === "error") {
                    if (typeof (arg2) === "string") {
                        _this.errors.push(new UploadingFileError(arg2, _this));
                    }
                    if (Array.isArray(arg2) && arg2.length > 0) {
                        arg2.forEach(function (error) { return _this.errors.push(new UploadingFileError(error, _this)); });
                    }
                    _this.stateChanged("error");
                }
                _this.stateChanged("loaded");
            });
        }
    };
    QuestionFileModelBase.prototype.loadPreview = function (newValue) { };
    QuestionFileModelBase.prototype.onChangeQuestionValue = function (newValue) {
        _super.prototype.onChangeQuestionValue.call(this, newValue);
        this.stateChanged(this.isEmpty() ? "empty" : "loaded");
        if (!this.isLoadingFromJson) {
            this.loadPreview(newValue);
        }
    };
    question_file_decorate([
        jsonobject_property()
    ], QuestionFileModelBase.prototype, "isUploading", void 0);
    question_file_decorate([
        jsonobject_property({ defaultValue: "empty" })
    ], QuestionFileModelBase.prototype, "currentState", void 0);
    return QuestionFileModelBase;
}(question_Question));

/**
 * A class that describes the File Upload question type.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/file-upload/ (linkStyle))
 */
var question_file_QuestionFileModel = /** @class */ (function (_super) {
    question_file_extends(QuestionFileModel, _super);
    function QuestionFileModel(name) {
        var _this = _super.call(this, name) || this;
        _this.isDragging = false;
        _this.fileNavigator = new container_ActionContainer();
        _this.canFlipCameraValue = undefined;
        _this.prevPreviewLength = 0;
        _this.calcAvailableItemsCount = function (availableWidth, itemWidth, gap) {
            var itemsCount = Math.floor(availableWidth / (itemWidth + gap));
            if ((itemsCount + 1) * (itemWidth + gap) - gap <= availableWidth)
                itemsCount++;
            return itemsCount;
        };
        _this.dragCounter = 0;
        _this.onDragEnter = function (event) {
            if (_this.canDragDrop()) {
                event.preventDefault();
                _this.isDragging = true;
                _this.dragCounter++;
            }
        };
        _this.onDragOver = function (event) {
            if (!_this.canDragDrop()) {
                event.returnValue = false;
                return false;
            }
            event.dataTransfer.dropEffect = "copy";
            event.preventDefault();
        };
        _this.onDrop = function (event) {
            if (_this.canDragDrop()) {
                _this.isDragging = false;
                _this.dragCounter = 0;
                event.preventDefault();
                var src = event.dataTransfer;
                _this.onChange(src);
            }
        };
        _this.onDragLeave = function (event) {
            if (_this.canDragDrop()) {
                _this.dragCounter--;
                if (_this.dragCounter === 0) {
                    _this.isDragging = false;
                }
            }
        };
        _this.doChange = function (event) {
            var src = event.target || event.srcElement;
            _this.onChange(src);
        };
        _this.doClean = function () {
            if (_this.needConfirmRemoveFile) {
                confirmActionAsync(_this.confirmRemoveAllMessage, function () { _this.clearFilesCore(); }, undefined, _this.getLocale(), _this.survey.rootElement);
                return;
            }
            _this.clearFilesCore();
        };
        _this.doDownloadFileFromContainer = function (event) {
            event.stopPropagation();
            var currentTarget = event.currentTarget;
            if (currentTarget && currentTarget.getElementsByTagName) {
                var link = currentTarget.getElementsByTagName("a")[0];
                link === null || link === void 0 ? void 0 : link.click();
            }
        };
        _this.doDownloadFile = function (event, data) {
            event.stopPropagation();
            if (detectIEOrEdge()) {
                event.preventDefault();
                loadFileFromBase64(data.content, data.name);
            }
        };
        _this.createLocalizableString("takePhotoCaption", _this, false, true);
        _this.createLocalizableString("clearCaption", _this, false, true);
        _this.actionsContainer = new container_ActionContainer();
        _this.actionsContainer.locOwner = _this;
        _this.fileIndexAction = new action_Action({
            id: "fileIndex",
            title: _this.getFileIndexCaption(),
            enabled: false
        });
        _this.prevFileAction = new action_Action({
            id: "prevPage",
            iconSize: 16,
            action: function () {
                _this.indexToShow = _this.previewValue.length && ((_this.indexToShow - 1 + _this.pagesCount) % _this.pagesCount) || 0;
                _this.fileIndexAction.title = _this.getFileIndexCaption();
            }
        });
        _this.nextFileAction = new action_Action({
            id: "nextPage",
            iconSize: 16,
            action: function () {
                _this.indexToShow = _this.previewValue.length && ((_this.indexToShow + 1) % _this.pagesCount) || 0;
                _this.fileIndexAction.title = _this.getFileIndexCaption();
            }
        });
        _this.takePictureAction = new action_Action({
            iconName: "icon-takepicture",
            id: "sv-file-take-picture",
            iconSize: "auto",
            innerCss: new ComputedUpdater(function () { return new CssClassBuilder().append(_this.cssClasses.contextButton).append(_this.cssClasses.takePictureButton).toString(); }),
            locTitle: _this.locTakePhotoCaption,
            showTitle: false,
            action: function () {
                _this.snapPicture();
            }
        });
        _this.closeCameraAction = new action_Action({
            iconName: "icon-closecamera",
            id: "sv-file-close-camera",
            iconSize: "auto",
            innerCss: new ComputedUpdater(function () { return new CssClassBuilder().append(_this.cssClasses.contextButton).append(_this.cssClasses.closeCameraButton).toString(); }),
            action: function () {
                _this.stopVideo();
            }
        });
        _this.changeCameraAction = new action_Action({
            iconName: "icon-changecamera",
            id: "sv-file-change-camera",
            iconSize: "auto",
            innerCss: new ComputedUpdater(function () { return new CssClassBuilder().append(_this.cssClasses.contextButton).append(_this.cssClasses.changeCameraButton).toString(); }),
            visible: new ComputedUpdater(function () { return _this.canFlipCamera(); }),
            action: function () {
                _this.flipCamera();
            }
        });
        _this.chooseFileAction = new action_Action({
            iconName: "icon-choosefile",
            id: "sv-file-choose-file",
            iconSize: "auto",
            data: { question: _this },
            enabledIf: function () { return !_this.isInputReadOnly; },
            component: "sv-file-choose-btn"
        });
        _this.startCameraAction = new action_Action({
            iconName: "icon-takepicture_24x24",
            id: "sv-file-start-camera",
            iconSize: "auto",
            locTitle: _this.locTakePhotoCaption,
            showTitle: new ComputedUpdater(function () { return !_this.isAnswered; }),
            enabledIf: function () { return !_this.isInputReadOnly; },
            action: function () {
                _this.startVideo();
            }
        });
        _this.cleanAction = new action_Action({
            iconName: "icon-clear",
            id: "sv-file-clean",
            iconSize: "auto",
            locTitle: _this.locClearButtonCaption,
            showTitle: false,
            enabledIf: function () { return !_this.isInputReadOnly; },
            innerCss: new ComputedUpdater(function () { return _this.cssClasses.removeButton; }),
            action: function () {
                _this.doClean();
            }
        });
        [_this.closeCameraAction, _this.changeCameraAction, _this.takePictureAction].forEach(function (action) {
            action.cssClasses = {};
        });
        _this.registerFunctionOnPropertiesValueChanged(["sourceType", "currentMode", "isAnswered"], function () {
            _this.updateActionsVisibility();
        });
        _this.actionsContainer.actions = [_this.chooseFileAction, _this.startCameraAction, _this.cleanAction];
        _this.fileNavigator.actions = [_this.prevFileAction, _this.fileIndexAction, _this.nextFileAction];
        return _this;
    }
    Object.defineProperty(QuestionFileModel.prototype, "isFileLoading", {
        get: function () { return this.isFileLoadingValue; },
        set: function (val) {
            this.isFileLoadingValue = val;
            this.updateIsReady();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "fileNavigatorVisible", {
        get: function () {
            var isUploading = this.isUploading;
            var isPlayingVideo = this.isPlayingVideo;
            var containsMultipleFiles = this.containsMultiplyFiles;
            var needToShowFileNavigator = this.pageSize < this.previewValue.length;
            return !isUploading && !isPlayingVideo && containsMultipleFiles && needToShowFileNavigator && this.isDefaultV2Theme;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "pagesCount", {
        get: function () {
            return Math.ceil(this.previewValue.length / this.pageSize);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "actionsContainerVisible", {
        get: function () {
            var isUploading = this.isUploading;
            var isPlayingVideo = this.isPlayingVideo;
            var isDefaultV2Theme = this.isDefaultV2Theme;
            return !isUploading && !isPlayingVideo && isDefaultV2Theme;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "videoId", {
        get: function () { return this.id + "_video"; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "hasVideoUI", {
        get: function () { return this.currentMode !== "file"; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "hasFileUI", {
        get: function () { return this.currentMode !== "camera"; },
        enumerable: false,
        configurable: true
    });
    QuestionFileModel.prototype.startVideo = function () {
        var _this = this;
        if (this.currentMode === "file" || this.isDesignMode || this.isPlayingVideo)
            return;
        this.setIsPlayingVideo(true);
        setTimeout(function () {
            _this.startVideoInCamera();
        }, 0);
    };
    Object.defineProperty(QuestionFileModel.prototype, "videoHtmlElement", {
        get: function () {
            var _a;
            return (_a = this.rootElement) === null || _a === void 0 ? void 0 : _a.querySelector("#" + this.videoId);
        },
        enumerable: false,
        configurable: true
    });
    QuestionFileModel.prototype.startVideoInCamera = function () {
        var _this = this;
        this.camera.startVideo(this.videoHtmlElement, function (stream) {
            _this.videoStream = stream;
            if (!stream) {
                _this.stopVideo();
            }
        }, getRenderedSize(this.imageWidth), getRenderedSize(this.imageHeight));
    };
    QuestionFileModel.prototype.stopVideo = function () {
        this.setIsPlayingVideo(false);
        this.closeVideoStream();
    };
    QuestionFileModel.prototype.snapPicture = function () {
        var _this = this;
        if (!this.isPlayingVideo)
            return;
        var blobCallback = function (blob) {
            if (blob) {
                var file = new File([blob], "snap_picture.png", { type: "image/png" });
                _this.loadFiles([file]);
            }
        };
        this.camera.snap(this.videoHtmlElement, blobCallback);
        this.stopVideo();
    };
    QuestionFileModel.prototype.canFlipCamera = function () {
        var _this = this;
        if (this.canFlipCameraValue === undefined) {
            this.canFlipCameraValue = this.camera.canFlip(function (res) {
                _this.canFlipCameraValue = res;
            });
        }
        return this.canFlipCameraValue;
    };
    QuestionFileModel.prototype.flipCamera = function () {
        if (!this.canFlipCamera())
            return;
        this.closeVideoStream();
        this.camera.flip();
        this.startVideoInCamera();
    };
    QuestionFileModel.prototype.closeVideoStream = function () {
        if (!!this.videoStream) {
            this.videoStream.getTracks().forEach(function (track) {
                track.stop();
            });
            this.videoStream = undefined;
        }
    };
    QuestionFileModel.prototype.onHidingContent = function () {
        _super.prototype.onHidingContent.call(this);
        this.stopVideo();
    };
    QuestionFileModel.prototype.updateElementCssCore = function (cssClasses) {
        _super.prototype.updateElementCssCore.call(this, cssClasses);
        this.prevFileAction.iconName = this.cssClasses.leftIconId;
        this.nextFileAction.iconName = this.cssClasses.rightIconId;
        this.updateCurrentMode();
    };
    QuestionFileModel.prototype.getFileIndexCaption = function () {
        return this.getLocalizationFormatString("indexText", this.indexToShow + 1, this.pagesCount);
    };
    QuestionFileModel.prototype.updateFileNavigator = function () {
        this.indexToShow = this.previewValue.length && ((this.indexToShow + this.pagesCount) % this.pagesCount) || 0;
        this.fileIndexAction.title = this.getFileIndexCaption();
    };
    QuestionFileModel.prototype.previewValueChanged = function () {
        var _this = this;
        if (this.previewValue.length !== this.prevPreviewLength) {
            if (this.previewValue.length > 0) {
                if (this.prevPreviewLength > this.previewValue.length) {
                    this.indexToShow = this.indexToShow >= this.pagesCount && this.indexToShow > 0 ? this.pagesCount - 1 : this.indexToShow;
                }
                else {
                    this.indexToShow = Math.floor(this.prevPreviewLength / this.pageSize);
                }
            }
            else {
                this.indexToShow = 0;
            }
        }
        this.fileIndexAction.title = this.getFileIndexCaption();
        this.containsMultiplyFiles = this.previewValue.length > 1;
        if (this.previewValue.length > 0 && !this.calculatedGapBetweenItems && !this.calculatedItemWidth) {
            setTimeout(function () {
                _this.processResponsiveness(0, _this._width);
            });
        }
        this.prevPreviewLength = this.previewValue.length;
    };
    QuestionFileModel.prototype.isPreviewVisible = function (index) {
        var isFileNavigatorVisible = this.fileNavigatorVisible;
        var isPreviewVisible = (this.indexToShow * this.pageSize <= index && index < (this.indexToShow + 1) * this.pageSize);
        return !isFileNavigatorVisible || isPreviewVisible;
    };
    QuestionFileModel.prototype.getType = function () {
        return "file";
    };
    Object.defineProperty(QuestionFileModel.prototype, "showPreview", {
        /**
         * Disable this property only to implement a custom preview.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/file-custom-preview/ (linkStyle))
         * @see allowImagesPreview
         */
        get: function () {
            return this.getPropertyValue("showPreview");
        },
        set: function (val) {
            this.setPropertyValue("showPreview", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "allowMultiple", {
        /**
         * Specifies whether users can upload multiple files.
         *
         * Default value: `false`
         */
        get: function () {
            return this.getPropertyValue("allowMultiple");
        },
        set: function (val) {
            this.setPropertyValue("allowMultiple", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "imageHeight", {
        /**
         * The image height.
         */
        get: function () {
            return this.getPropertyValue("imageHeight");
        },
        set: function (val) {
            this.setPropertyValue("imageHeight", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "imageWidth", {
        /**
         * The image width.
         */
        get: function () {
            return this.getPropertyValue("imageWidth");
        },
        set: function (val) {
            this.setPropertyValue("imageWidth", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "acceptedTypes", {
        /**
         * An [accept](https://www.w3schools.com/tags/att_input_accept.asp) attribute value for the underlying `<input>` element.
         */
        get: function () {
            return this.getPropertyValue("acceptedTypes");
        },
        set: function (val) {
            this.setPropertyValue("acceptedTypes", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "allowImagesPreview", {
        /**
         * Specifies whether to show a preview of image files.
         */
        get: function () {
            return this.getPropertyValue("allowImagesPreview");
        },
        set: function (val) {
            this.setPropertyValue("allowImagesPreview", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "maxSize", {
        /**
         * Maximum allowed file size, measured in bytes.
         *
         * Default value: 0 (unlimited)
         */
        get: function () {
            return this.getPropertyValue("maxSize");
        },
        set: function (val) {
            this.setPropertyValue("maxSize", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionFileModel.prototype.chooseFile = function (event) {
        var _this = this;
        if (!this.rootElement)
            return;
        var inputElement = this.rootElement.querySelector("#" + this.inputId);
        if (!inputElement)
            return;
        event.preventDefault();
        event.stopImmediatePropagation();
        if (inputElement) {
            if (this.survey) {
                this.survey.chooseFiles(inputElement, function (files) { return _this.loadFiles(files); }, { element: this, elementType: this.getType(), propertyName: this.name });
            }
            else {
                inputElement.click();
            }
        }
    };
    Object.defineProperty(QuestionFileModel.prototype, "needConfirmRemoveFile", {
        /**
         * Specifies whether users should confirm file deletion.
         *
         * Default value: `false`
         */
        get: function () {
            return this.getPropertyValue("needConfirmRemoveFile");
        },
        set: function (val) {
            this.setPropertyValue("needConfirmRemoveFile", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionFileModel.prototype.getConfirmRemoveMessage = function (fileName) {
        return this.confirmRemoveMessage.format(fileName);
    };
    Object.defineProperty(QuestionFileModel.prototype, "takePhotoCaption", {
        get: function () { return this.getLocalizableStringText("takePhotoCaption"); },
        set: function (val) { this.setLocalizableStringText("takePhotoCaption", val); },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "locTakePhotoCaption", {
        get: function () { return this.getLocalizableString("takePhotoCaption"); },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "clearButtonCaption", {
        get: function () {
            return this.getLocalizableStringText("clearCaption");
        },
        set: function (value) {
            this.setLocalizableStringText("clearCaption", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "locClearButtonCaption", {
        get: function () {
            return this.getLocalizableString("clearCaption");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "locRenderedPlaceholder", {
        get: function () {
            var _this = this;
            if (this.locRenderedPlaceholderValue === undefined) {
                this.locRenderedPlaceholderValue = (new ComputedUpdater(function () {
                    var isReadOnly = _this.isReadOnly;
                    var hasFileUI = (!_this.isDesignMode && _this.hasFileUI) || (_this.isDesignMode && _this.sourceType != "camera");
                    var hasVideoUI = (!_this.isDesignMode && _this.hasVideoUI) || (_this.isDesignMode && _this.sourceType != "file");
                    var renderedPlaceholder;
                    if (isReadOnly) {
                        renderedPlaceholder = _this.locNoFileChosenCaption;
                    }
                    else if (hasFileUI && hasVideoUI) {
                        renderedPlaceholder = _this.locFileOrPhotoPlaceholder;
                    }
                    else if (hasFileUI) {
                        renderedPlaceholder = _this.locFilePlaceholder;
                    }
                    else {
                        renderedPlaceholder = _this.locPhotoPlaceholder;
                    }
                    return renderedPlaceholder;
                }));
            }
            return this.locRenderedPlaceholderValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "currentMode", {
        get: function () {
            return this.getPropertyValue("currentMode", this.sourceType);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "isPlayingVideo", {
        get: function () {
            return this.getPropertyValue("isPlayingVideo", false);
        },
        enumerable: false,
        configurable: true
    });
    QuestionFileModel.prototype.setIsPlayingVideo = function (show) {
        this.setPropertyValue("isPlayingVideo", show);
    };
    QuestionFileModel.prototype.updateCurrentMode = function () {
        var _this = this;
        if (!this.isDesignMode) {
            if (this.sourceType !== "file") {
                this.camera.hasCamera(function (res) {
                    _this.setPropertyValue("currentMode", res && _this.isDefaultV2Theme ? _this.sourceType : "file");
                });
            }
            else {
                this.setPropertyValue("currentMode", this.sourceType);
            }
        }
    };
    QuestionFileModel.prototype.updateActionsVisibility = function () {
        var isDesignMode = this.isDesignMode;
        this.chooseFileAction.visible = (!isDesignMode && this.hasFileUI) || (isDesignMode && this.sourceType !== "camera");
        this.startCameraAction.visible = (!isDesignMode && this.hasVideoUI) || (isDesignMode && this.sourceType !== "file");
        this.cleanAction.visible = !!this.isAnswered;
    };
    Object.defineProperty(QuestionFileModel.prototype, "inputTitle", {
        get: function () {
            if (this.isUploading)
                return this.loadingFileTitle;
            if (this.isEmpty())
                return this.chooseFileTitle;
            return " ";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "chooseButtonText", {
        get: function () {
            return this.isEmpty() || this.allowMultiple ? this.chooseButtonCaption : this.replaceButtonCaption;
        },
        enumerable: false,
        configurable: true
    });
    QuestionFileModel.prototype.clear = function (doneCallback) {
        var _this = this;
        if (!this.survey)
            return;
        this.containsMultiplyFiles = false;
        this.survey.clearFiles(this, this.name, this.value, null, function (status, data) {
            if (status === "success") {
                _this.value = undefined;
                _this.errors = [];
                !!doneCallback && doneCallback();
                _this.indexToShow = 0;
                _this.fileIndexAction.title = _this.getFileIndexCaption();
            }
        });
    };
    Object.defineProperty(QuestionFileModel.prototype, "renderCapture", {
        get: function () {
            return this.allowCameraAccess ? "user" : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "multipleRendered", {
        get: function () {
            return this.allowMultiple ? "multiple" : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "showChooseButton", {
        //todo: remove it in V2
        get: function () {
            return !this.isReadOnly && !this.isDefaultV2Theme;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "showFileDecorator", {
        //
        get: function () {
            var isPlayingVideo = this.isPlayingVideo;
            var showLoadingIndicator = this.showLoadingIndicator;
            return !isPlayingVideo && !showLoadingIndicator;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "allowShowPreview", {
        get: function () {
            var isShowLoadingIndicator = this.showLoadingIndicator;
            var isPlayingVideo = this.isPlayingVideo;
            return !isShowLoadingIndicator && !isPlayingVideo;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "showPreviewContainer", {
        get: function () {
            return this.previewValue && this.previewValue.length > 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "showRemoveButtonCore", {
        //todo: remove in V2
        get: function () {
            var showLoadingIndicator = this.showLoadingIndicator;
            var isReadOnly = this.isReadOnly;
            var isEmpty = this.isEmpty();
            return !isReadOnly && !isEmpty && !showLoadingIndicator && !this.isDefaultV2Theme;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "showRemoveButton", {
        get: function () {
            return this.showRemoveButtonCore && this.cssClasses.removeButton;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionFileModel.prototype, "showRemoveButtonBottom", {
        get: function () {
            var cssClasses = new CssClassBuilder().append(this.cssClasses.removeButtonBottom).append(this.cssClasses.contextButton).toString();
            return this.showRemoveButtonCore && cssClasses;
        },
        enumerable: false,
        configurable: true
    });
    //
    QuestionFileModel.prototype.defaultImage = function (data) {
        return !this.canPreviewImage(data) && !!this.cssClasses.defaultImage;
    };
    /**
     * Removes a file with a specified name.
     */
    QuestionFileModel.prototype.removeFile = function (name) {
        this.removeFileByContent(this.value.filter(function (f) { return f.name === name; })[0]);
    };
    QuestionFileModel.prototype.removeFileByContent = function (content) {
        var _this = this;
        if (!this.survey)
            return;
        this.survey.clearFiles(this, this.name, this.value, content.name, function (status, data) {
            if (status === "success") {
                var oldValue = _this.value;
                if (Array.isArray(oldValue)) {
                    _this.value = oldValue.filter(function (f) { return !helpers_Helpers.isTwoValueEquals(f, content, true, false, false); });
                }
                else {
                    _this.value = undefined;
                }
            }
        });
    };
    QuestionFileModel.prototype.setValueFromResult = function (arg) {
        this.value = (this.value || []).concat(arg.map(function (r) {
            return {
                name: r.file.name,
                type: r.file.type,
                content: r.content,
            };
        }));
    };
    /**
     * Loads multiple files into the question.
     * @param files An array of [File](https://developer.mozilla.org/en-US/docs/Web/API/File) objects.
     */
    QuestionFileModel.prototype.loadFiles = function (files) {
        var _this = this;
        if (!this.survey) {
            return;
        }
        this.errors = [];
        if (!this.allFilesOk(files)) {
            return;
        }
        var loadFilesProc = function () {
            _this.stateChanged("loading");
            var content = [];
            if (_this.storeDataAsText) {
                files.forEach(function (file) {
                    var fileReader = new FileReader();
                    fileReader.onload = function (e) {
                        content = content.concat([
                            { name: file.name, type: file.type, content: fileReader.result },
                        ]);
                        if (content.length === files.length) {
                            _this.value = (_this.value || []).concat(content);
                        }
                    };
                    fileReader.readAsDataURL(file);
                });
            }
            else {
                _this.uploadFiles(files);
            }
        };
        if (this.allowMultiple) {
            loadFilesProc();
        }
        else {
            this.clear(loadFilesProc);
        }
    };
    Object.defineProperty(QuestionFileModel.prototype, "camera", {
        get: function () {
            if (!this.cameraValue) {
                this.cameraValue = new camera_Camera();
            }
            return this.cameraValue;
        },
        enumerable: false,
        configurable: true
    });
    QuestionFileModel.prototype.canPreviewImage = function (fileItem) {
        return this.allowImagesPreview && !!fileItem && this.isFileImage(fileItem);
    };
    QuestionFileModel.prototype.loadPreview = function (newValue) {
        var _this = this;
        this.previewValue.splice(0, this.previewValue.length);
        if (!this.showPreview || !newValue)
            return;
        var newValues = Array.isArray(newValue)
            ? newValue
            : !!newValue
                ? [newValue]
                : [];
        if (this.storeDataAsText) {
            newValues.forEach(function (value) {
                var content = value.content || value;
                _this.previewValue.push({
                    name: value.name,
                    type: value.type,
                    content: content,
                });
            });
        }
        else {
            if (!!this._previewLoader) {
                this._previewLoader.dispose();
            }
            this.isFileLoading = true;
            this._previewLoader = new FileLoader(this, function (status, loaded) {
                if (status !== "error") {
                    loaded.forEach(function (val) {
                        _this.previewValue.push(val);
                    });
                    _this.previewValueChanged();
                }
                _this.isFileLoading = false;
                _this._previewLoader.dispose();
                _this._previewLoader = undefined;
            });
            this._previewLoader.load(newValues);
        }
        this.previewValueChanged();
    };
    QuestionFileModel.prototype.getIsQuestionReady = function () {
        return _super.prototype.getIsQuestionReady.call(this) && !this.isFileLoading;
    };
    QuestionFileModel.prototype.allFilesOk = function (files) {
        var _this = this;
        var errorLength = this.errors ? this.errors.length : 0;
        (files || []).forEach(function (file) {
            if (_this.maxSize > 0 && file.size > _this.maxSize) {
                _this.errors.push(new error_ExceedSizeError(_this.maxSize, _this));
            }
        });
        return errorLength === this.errors.length;
    };
    QuestionFileModel.prototype.isFileImage = function (file) {
        if (!file || !file.content || !file.content.substring)
            return false;
        var imagePrefix = "data:image";
        var subStr = file.content && file.content.substring(0, imagePrefix.length);
        subStr = subStr && subStr.toLowerCase();
        var result = subStr === imagePrefix ||
            (!!file.type && file.type.toLowerCase().indexOf("image/") === 0);
        return result;
    };
    QuestionFileModel.prototype.getPlainData = function (options) {
        if (options === void 0) { options = {
            includeEmpty: true,
        }; }
        var questionPlainData = _super.prototype.getPlainData.call(this, options);
        if (!!questionPlainData && !this.isEmpty()) {
            questionPlainData.isNode = false;
            var values = Array.isArray(this.value) ? this.value : [this.value];
            questionPlainData.data = values.map(function (dataValue, index) {
                return {
                    name: index,
                    title: "File",
                    value: (dataValue.content && dataValue.content) || dataValue,
                    displayValue: (dataValue.name && dataValue.name) || dataValue,
                    getString: function (val) {
                        return typeof val === "object" ? JSON.stringify(val) : val;
                    },
                    isNode: false,
                };
            });
        }
        return questionPlainData;
    };
    QuestionFileModel.prototype.getImageWrapperCss = function (data) {
        return new CssClassBuilder().append(this.cssClasses.imageWrapper).append(this.cssClasses.imageWrapperDefaultImage, this.defaultImage(data)).toString();
    };
    QuestionFileModel.prototype.getActionsContainerCss = function (css) {
        return new CssClassBuilder()
            .append(css.actionsContainer)
            .append(css.actionsContainerAnswered, this.isAnswered)
            .toString();
    };
    QuestionFileModel.prototype.getRemoveButtonCss = function () {
        return new CssClassBuilder()
            .append(this.cssClasses.removeFileButton)
            .append(this.cssClasses.contextButton)
            .toString();
    };
    QuestionFileModel.prototype.getChooseFileCss = function () {
        var isAnswered = this.isAnswered;
        return new CssClassBuilder()
            .append(this.cssClasses.chooseFile)
            .append(this.cssClasses.controlDisabled, this.isReadOnly)
            .append(this.cssClasses.chooseFileAsText, !isAnswered)
            .append(this.cssClasses.chooseFileAsTextDisabled, !isAnswered && this.isInputReadOnly)
            .append(this.cssClasses.contextButton, isAnswered)
            .append(this.cssClasses.chooseFileAsIcon, isAnswered)
            .toString();
    };
    QuestionFileModel.prototype.getReadOnlyFileCss = function () {
        return new CssClassBuilder()
            .append("form-control")
            .append(this.cssClasses.placeholderInput)
            .toString();
    };
    Object.defineProperty(QuestionFileModel.prototype, "fileRootCss", {
        get: function () {
            return new CssClassBuilder()
                .append(this.cssClasses.root)
                .append(this.cssClasses.rootDisabled, this.isDisabledStyle)
                .append(this.cssClasses.rootReadOnly, this.isReadOnlyStyle)
                .append(this.cssClasses.rootPreview, this.isPreviewStyle)
                .append(this.cssClasses.rootDragging, this.isDragging)
                .append(this.cssClasses.rootAnswered, this.isAnswered)
                .append(this.cssClasses.single, !this.allowMultiple)
                .append(this.cssClasses.singleImage, !this.allowMultiple && this.isAnswered && this.canPreviewImage(this.value[0]))
                .append(this.cssClasses.mobile, this.isMobile)
                .toString();
        },
        enumerable: false,
        configurable: true
    });
    QuestionFileModel.prototype.getFileDecoratorCss = function () {
        return new CssClassBuilder()
            .append(this.cssClasses.fileDecorator)
            .append(this.cssClasses.onError, this.hasCssError())
            .append(this.cssClasses.fileDecoratorDrag, this.isDragging)
            .toString();
    };
    QuestionFileModel.prototype.onChange = function (src) {
        if (!DomWindowHelper.isFileReaderAvailable())
            return;
        if (!src || !src.files || src.files.length < 1)
            return;
        var files = [];
        var allowCount = this.allowMultiple ? src.files.length : 1;
        for (var i = 0; i < allowCount; i++) {
            files.push(src.files[i]);
        }
        src.value = "";
        this.loadFiles(files);
    };
    QuestionFileModel.prototype.calcCssClasses = function (css) {
        var classes = _super.prototype.calcCssClasses.call(this, css);
        this.actionsContainer.cssClasses = css.actionBar;
        this.actionsContainer.cssClasses.itemWithTitle = this.actionsContainer.cssClasses.item;
        this.actionsContainer.cssClasses.item = "";
        this.actionsContainer.cssClasses.itemAsIcon = classes.contextButton;
        this.actionsContainer.containerCss = classes.actionsContainer;
        return classes;
    };
    QuestionFileModel.prototype.onSurveyLoad = function () {
        _super.prototype.onSurveyLoad.call(this);
        this.updateCurrentMode();
        this.updateActionsVisibility();
        this.loadPreview(this.value);
    };
    QuestionFileModel.prototype.needResponsiveness = function () {
        return this.supportResponsiveness() && this.isDefaultV2Theme;
    };
    QuestionFileModel.prototype.supportResponsiveness = function () {
        return true;
    };
    QuestionFileModel.prototype.getObservedElementSelector = function () {
        return classesToSelector(this.cssClasses.dragArea);
    };
    QuestionFileModel.prototype.getFileListSelector = function () {
        return classesToSelector(this.cssClasses.fileList);
    };
    QuestionFileModel.prototype.triggerResponsiveness = function (hard) {
        if (hard) {
            this.calculatedGapBetweenItems = undefined;
            this.calculatedItemWidth = undefined;
        }
        _super.prototype.triggerResponsiveness.call(this);
    };
    QuestionFileModel.prototype.processResponsiveness = function (_, availableWidth) {
        var _this = this;
        this._width = availableWidth;
        if (this.rootElement) {
            if ((!this.calculatedGapBetweenItems || !this.calculatedItemWidth) && this.allowMultiple) {
                var fileListSelector = this.getFileListSelector();
                var fileListElement = fileListSelector ? this.rootElement.querySelector(this.getFileListSelector()) : undefined;
                if (fileListElement) {
                    this.calculatedGapBetweenItems = Math.ceil(Number.parseFloat(DomDocumentHelper.getComputedStyle(fileListElement).gap));
                    var firstVisibleItem = Array.from(fileListElement.children).filter(function (_, index) { return _this.isPreviewVisible(index); })[0];
                    if (firstVisibleItem) {
                        this.calculatedItemWidth = Math.ceil(Number.parseFloat(DomDocumentHelper.getComputedStyle(firstVisibleItem).width));
                    }
                }
            }
        }
        if (this.calculatedGapBetweenItems && this.calculatedItemWidth) {
            this.pageSize = this.calcAvailableItemsCount(availableWidth, this.calculatedItemWidth, this.calculatedGapBetweenItems);
            return true;
        }
        return false;
    };
    QuestionFileModel.prototype.canDragDrop = function () { return !this.isInputReadOnly && this.currentMode !== "camera" && !this.isPlayingVideo; };
    QuestionFileModel.prototype.afterRenderQuestionElement = function (el) {
        this.rootElement = el;
    };
    QuestionFileModel.prototype.beforeDestroyQuestionElement = function (el) {
        this.rootElement = undefined;
    };
    QuestionFileModel.prototype.clearFilesCore = function () {
        if (this.rootElement) {
            var input = this.rootElement.querySelectorAll("input")[0];
            if (input) {
                input.value = "";
            }
        }
        this.clear();
    };
    QuestionFileModel.prototype.doRemoveFile = function (data, event) {
        var _this = this;
        event.stopPropagation();
        if (this.needConfirmRemoveFile) {
            confirmActionAsync(this.getConfirmRemoveMessage(data.name), function () { _this.removeFileCore(data); }, undefined, this.getLocale(), this.survey.rootElement);
            return;
        }
        this.removeFileCore(data);
    };
    QuestionFileModel.prototype.removeFileCore = function (data) {
        var previewIndex = this.previewValue.indexOf(data);
        this.removeFileByContent(previewIndex === -1 ? data : this.value[previewIndex]);
    };
    //#endregion
    QuestionFileModel.prototype.dispose = function () {
        this.cameraValue = undefined;
        this.closeVideoStream();
        _super.prototype.dispose.call(this);
    };
    question_file_decorate([
        jsonobject_property()
    ], QuestionFileModel.prototype, "isDragging", void 0);
    question_file_decorate([
        propertyArray({})
    ], QuestionFileModel.prototype, "previewValue", void 0);
    question_file_decorate([
        jsonobject_property({ defaultValue: 0 })
    ], QuestionFileModel.prototype, "indexToShow", void 0);
    question_file_decorate([
        jsonobject_property({
            defaultValue: 1,
            onSet: function (_, target) {
                target.updateFileNavigator();
            }
        })
    ], QuestionFileModel.prototype, "pageSize", void 0);
    question_file_decorate([
        jsonobject_property({ defaultValue: false })
    ], QuestionFileModel.prototype, "containsMultiplyFiles", void 0);
    question_file_decorate([
        jsonobject_property()
    ], QuestionFileModel.prototype, "allowCameraAccess", void 0);
    question_file_decorate([
        jsonobject_property({
            onSet: function (val, obj) {
                if (!obj.isLoadingFromJson) {
                    obj.updateCurrentMode();
                }
            }
        })
    ], QuestionFileModel.prototype, "sourceType", void 0);
    question_file_decorate([
        jsonobject_property()
    ], QuestionFileModel.prototype, "canFlipCameraValue", void 0);
    question_file_decorate([
        jsonobject_property({ localizable: { defaultStr: "confirmRemoveFile" } })
    ], QuestionFileModel.prototype, "confirmRemoveMessage", void 0);
    question_file_decorate([
        jsonobject_property({ localizable: { defaultStr: "confirmRemoveAllFiles" } })
    ], QuestionFileModel.prototype, "confirmRemoveAllMessage", void 0);
    question_file_decorate([
        jsonobject_property({ localizable: { defaultStr: "noFileChosen" } })
    ], QuestionFileModel.prototype, "noFileChosenCaption", void 0);
    question_file_decorate([
        jsonobject_property({ localizable: { defaultStr: "chooseFileCaption" } })
    ], QuestionFileModel.prototype, "chooseButtonCaption", void 0);
    question_file_decorate([
        jsonobject_property({ localizable: { defaultStr: "replaceFileCaption" } })
    ], QuestionFileModel.prototype, "replaceButtonCaption", void 0);
    question_file_decorate([
        jsonobject_property({ localizable: { defaultStr: "removeFileCaption" } })
    ], QuestionFileModel.prototype, "removeFileCaption", void 0);
    question_file_decorate([
        jsonobject_property({ localizable: { defaultStr: "loadingFile" } })
    ], QuestionFileModel.prototype, "loadingFileTitle", void 0);
    question_file_decorate([
        jsonobject_property({ localizable: { defaultStr: "chooseFile" } })
    ], QuestionFileModel.prototype, "chooseFileTitle", void 0);
    question_file_decorate([
        jsonobject_property({ localizable: { defaultStr: "fileOrPhotoPlaceholder" } })
    ], QuestionFileModel.prototype, "fileOrPhotoPlaceholder", void 0);
    question_file_decorate([
        jsonobject_property({ localizable: { defaultStr: "photoPlaceholder" } })
    ], QuestionFileModel.prototype, "photoPlaceholder", void 0);
    question_file_decorate([
        jsonobject_property({ localizable: { defaultStr: "filePlaceholder" } })
    ], QuestionFileModel.prototype, "filePlaceholder", void 0);
    question_file_decorate([
        jsonobject_property()
    ], QuestionFileModel.prototype, "locRenderedPlaceholderValue", void 0);
    return QuestionFileModel;
}(question_file_QuestionFileModelBase));

Serializer.addClass("file", [
    { name: "showCommentArea:switch", layout: "row", visible: true, category: "general" },
    { name: "showPreview:boolean", default: true, visible: false },
    "allowMultiple:boolean",
    {
        name: "allowImagesPreview:boolean",
        default: true,
        dependsOn: "showPreview",
        visibleIf: function (obj) {
            return !!obj.showPreview;
        },
    },
    "imageHeight",
    "imageWidth",
    "acceptedTypes",
    { name: "storeDataAsText:boolean", default: true },
    { name: "waitForUpload:boolean", default: false },
    { name: "maxSize:number", default: 0 },
    { name: "defaultValue", visible: false },
    { name: "correctAnswer", visible: false },
    { name: "validators", visible: false },
    { name: "needConfirmRemoveFile:boolean" },
    { name: "sourceType", choices: ["file", "camera", "file-camera"], default: "file", category: "general", visible: true, visibleIf: function () { return settings.supportCreatorV2; } },
    { name: "fileOrPhotoPlaceholder:text", serializationProperty: "locFileOrPhotoPlaceholder", category: "general", visibleIf: function () { return settings.supportCreatorV2; } },
    { name: "photoPlaceholder:text", serializationProperty: "locPhotoPlaceholder", category: "general", visibleIf: function () { return settings.supportCreatorV2; } },
    { name: "filePlaceholder:text", serializationProperty: "locFilePlaceholder", category: "general", visibleIf: function () { return settings.supportCreatorV2; } },
    { name: "allowCameraAccess:switch", category: "general", visible: false },
], function () {
    return new question_file_QuestionFileModel("");
}, "question");
questionfactory_QuestionFactory.Instance.registerQuestion("file", function (name) {
    return new question_file_QuestionFileModel(name);
});
var FileLoader = /** @class */ (function () {
    function FileLoader(fileQuestion, callback) {
        this.fileQuestion = fileQuestion;
        this.callback = callback;
        this.loaded = [];
    }
    FileLoader.prototype.load = function (files) {
        var _this = this;
        var downloadedCount = 0;
        this.loaded = new Array(files.length);
        files.forEach(function (value, index) {
            if (_this.fileQuestion.survey) {
                _this.fileQuestion.survey.downloadFile(_this.fileQuestion, _this.fileQuestion.name, value, function (status, data) {
                    if (!_this.fileQuestion || !_this.callback) {
                        return;
                    }
                    if (status !== "error") {
                        _this.loaded[index] = {
                            content: data,
                            name: value.name,
                            type: value.type,
                        };
                        downloadedCount++;
                        if (downloadedCount === files.length) {
                            _this.callback(status, _this.loaded);
                        }
                    }
                    else {
                        _this.callback("error", _this.loaded);
                    }
                });
            }
        });
    };
    FileLoader.prototype.dispose = function () {
        this.fileQuestion = undefined;
        this.callback = undefined;
    };
    return FileLoader;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/question_html.ts
var question_html_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();




/**
  * A class that describes the HTML question type. Unlike other question types, HTML cannot have a title or value.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/questiontype-html/ (linkStyle))
 */
var question_html_QuestionHtmlModel = /** @class */ (function (_super) {
    question_html_extends(QuestionHtmlModel, _super);
    function QuestionHtmlModel(name) {
        var _this = _super.call(this, name) || this;
        var locHtml = _this.createLocalizableString("html", _this);
        locHtml.onGetTextCallback = function (str) {
            return !!_this.survey && !_this.ignoreHtmlProgressing
                ? _this.processHtml(str)
                : str;
        };
        return _this;
    }
    QuestionHtmlModel.prototype.getType = function () {
        return "html";
    };
    Object.defineProperty(QuestionHtmlModel.prototype, "isCompositeQuestion", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    QuestionHtmlModel.prototype.getProcessedText = function (text) {
        if (this.ignoreHtmlProgressing)
            return text;
        return _super.prototype.getProcessedText.call(this, text);
    };
    Object.defineProperty(QuestionHtmlModel.prototype, "html", {
        /**
         * HTML markup to display.
         *
         * > IMPORTANT: If you get the markup from a third party, ensure that it does not contain malicious code.
         */
        get: function () {
            return this.getLocalizableStringText("html", "");
        },
        set: function (val) {
            this.setLocalizableStringText("html", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionHtmlModel.prototype, "locHtml", {
        get: function () {
            return this.getLocalizableString("html");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionHtmlModel.prototype, "processedHtml", {
        get: function () {
            return this.processHtml(this.html);
        },
        enumerable: false,
        configurable: true
    });
    QuestionHtmlModel.prototype.processHtml = function (html) {
        return this.survey ? this.survey.processHtml(html, "html-question") : this.html;
    };
    Object.defineProperty(QuestionHtmlModel.prototype, "isNewA11yStructure", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionHtmlModel.prototype, "renderCssRoot", {
        get: function () {
            return new CssClassBuilder().append(this.cssClasses.root).append(this.cssClasses.nested, this.getIsNested()).toString() || undefined;
        },
        enumerable: false,
        configurable: true
    });
    return QuestionHtmlModel;
}(QuestionNonValue));

Serializer.addClass("html", [
    { name: "html:html", serializationProperty: "locHtml" },
    { name: "hideNumber", visible: false },
    { name: "state", visible: false },
    { name: "titleLocation", visible: false },
    { name: "descriptionLocation", visible: false },
    { name: "errorLocation", visible: false },
    { name: "indent", visible: false },
    { name: "width", visible: false },
], function () {
    return new question_html_QuestionHtmlModel("");
}, "nonvalue");
questionfactory_QuestionFactory.Instance.registerQuestion("html", function (name) {
    return new question_html_QuestionHtmlModel(name);
});

// CONCATENATED MODULE: ./packages/survey-core/src/question_radiogroup.ts
var question_radiogroup_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();





/**
 * A class that describes the Radio Button Group question type.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/questiontype-radiogroup/ (linkStyle))
 */
var question_radiogroup_QuestionRadiogroupModel = /** @class */ (function (_super) {
    question_radiogroup_extends(QuestionRadiogroupModel, _super);
    function QuestionRadiogroupModel(name) {
        return _super.call(this, name) || this;
    }
    QuestionRadiogroupModel.prototype.getDefaultItemComponent = function () {
        return "survey-radiogroup-item";
    };
    QuestionRadiogroupModel.prototype.getType = function () {
        return "radiogroup";
    };
    QuestionRadiogroupModel.prototype.getFirstInputElementId = function () {
        return this.inputId + "_0";
    };
    Object.defineProperty(QuestionRadiogroupModel.prototype, "selectedItem", {
        /**
         * Returns the selected choice item. If no item is selected, returns `null`.
         */
        get: function () { return this.getSingleSelectedItem(); },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRadiogroupModel.prototype, "showClearButton", {
        /**
         * Specifies whether to display a button that clears the question value.
         *
         * Default value: `false`
         */
        get: function () {
            return this.getPropertyValue("showClearButton");
        },
        set: function (val) {
            this.setPropertyValue("showClearButton", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRadiogroupModel.prototype, "canShowClearButton", {
        get: function () {
            return this.showClearButton && !this.isReadOnly;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRadiogroupModel.prototype, "clearButtonCaption", {
        get: function () {
            return this.getLocalizationString("clearCaption");
        },
        enumerable: false,
        configurable: true
    });
    QuestionRadiogroupModel.prototype.supportGoNextPageAutomatic = function () {
        return this.isMouseDown === true && !this.isOtherSelected;
    };
    QuestionRadiogroupModel.prototype.getConditionJson = function (operator, path) {
        if (operator === void 0) { operator = null; }
        if (path === void 0) { path = null; }
        var json = _super.prototype.getConditionJson.call(this, operator, path);
        delete json["showClearButton"];
        return json;
    };
    QuestionRadiogroupModel.prototype.setNewComment = function (newValue) {
        this.isMouseDown = true;
        _super.prototype.setNewComment.call(this, newValue);
        this.isMouseDown = false;
    };
    Object.defineProperty(QuestionRadiogroupModel.prototype, "showClearButtonInContent", {
        get: function () {
            return !this.isDefaultV2Theme && this.canShowClearButton;
        },
        enumerable: false,
        configurable: true
    });
    QuestionRadiogroupModel.prototype.clickItemHandler = function (item) {
        if (this.isReadOnlyAttr)
            return;
        this.renderedValue = item.value;
    };
    QuestionRadiogroupModel.prototype.getDefaultTitleActions = function () {
        var _this = this;
        var actions = [];
        if (this.isDefaultV2Theme && !this.isDesignMode) {
            var clearAction = new action_Action({
                title: this.clearButtonCaption,
                id: "sv-clr-btn-" + this.id,
                action: function () { _this.clearValue(true); },
                innerCss: this.cssClasses.clearButton,
                visible: new ComputedUpdater(function () { return _this.canShowClearButton; })
            });
            actions.push(clearAction);
        }
        return actions;
    };
    Object.defineProperty(QuestionRadiogroupModel.prototype, "isNewA11yStructure", {
        //a11y
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRadiogroupModel.prototype, "a11y_input_ariaRole", {
        get: function () {
            return "radiogroup";
        },
        enumerable: false,
        configurable: true
    });
    return QuestionRadiogroupModel;
}(QuestionCheckboxBase));

Serializer.addClass("radiogroup", [{ name: "showClearButton:boolean", default: false },
    { name: "separateSpecialChoices", visible: true },
    { name: "itemComponent", visible: false, default: "survey-radiogroup-item" }
], function () {
    return new question_radiogroup_QuestionRadiogroupModel("");
}, "checkboxbase");
questionfactory_QuestionFactory.Instance.registerQuestion("radiogroup", function (name) {
    var q = new question_radiogroup_QuestionRadiogroupModel(name);
    q.choices = questionfactory_QuestionFactory.DefaultChoices;
    return q;
});

// CONCATENATED MODULE: ./packages/survey-core/src/question_rating.ts
var question_rating_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var question_rating_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};












var question_rating_RenderedRatingItem = /** @class */ (function (_super) {
    question_rating_extends(RenderedRatingItem, _super);
    function RenderedRatingItem(itemValue, locString) {
        if (locString === void 0) { locString = null; }
        var _this = _super.call(this) || this;
        _this.itemValue = itemValue;
        _this.locString = locString;
        _this.locText.onStringChanged.add(_this.onStringChangedCallback.bind(_this));
        _this.onStringChangedCallback();
        return _this;
    }
    RenderedRatingItem.prototype.onStringChangedCallback = function () {
        this.text = this.itemValue.text;
    };
    Object.defineProperty(RenderedRatingItem.prototype, "value", {
        get: function () {
            return this.itemValue.getPropertyValue("value");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(RenderedRatingItem.prototype, "locText", {
        get: function () {
            return this.locString || this.itemValue.locText;
        },
        enumerable: false,
        configurable: true
    });
    question_rating_decorate([
        jsonobject_property({ defaultValue: "" })
    ], RenderedRatingItem.prototype, "highlight", void 0);
    question_rating_decorate([
        jsonobject_property({ defaultValue: "" })
    ], RenderedRatingItem.prototype, "text", void 0);
    question_rating_decorate([
        jsonobject_property()
    ], RenderedRatingItem.prototype, "style", void 0);
    return RenderedRatingItem;
}(base_Base));

var RatingItemValue = /** @class */ (function (_super) {
    question_rating_extends(RatingItemValue, _super);
    function RatingItemValue(value, description) {
        var _this = _super.call(this, value) || this;
        _this.description = description;
        return _this;
    }
    return RatingItemValue;
}(itemvalue_ItemValue));
/**
 * A class that describes the Rating Scale question type.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/rating-scale/ (linkStyle))
 */
var question_rating_QuestionRatingModel = /** @class */ (function (_super) {
    question_rating_extends(QuestionRatingModel, _super);
    function QuestionRatingModel(name) {
        var _this = _super.call(this, name) || this;
        _this._syncPropertiesChanging = false;
        _this.createItemValues("rateValues");
        _this.createRenderedRateItems();
        _this.createLocalizableString("ratingOptionsCaption", _this, false, true);
        _this.registerFunctionOnPropertiesValueChanged(["rateMin", "rateMax",
            "minRateDescription", "maxRateDescription", "rateStep", "displayRateDescriptionsAsExtremeItems"], function () { return _this.createRenderedRateItems(); });
        _this.registerFunctionOnPropertiesValueChanged(["rateType"], function () {
            _this.setIconsToRateValues();
            _this.createRenderedRateItems();
            _this.updateRateCount();
        });
        _this.registerFunctionOnPropertiesValueChanged(["rateValues"], function () {
            _this.setIconsToRateValues();
            _this.createRenderedRateItems();
        });
        _this.registerSychProperties(["rateValues"], function () {
            _this.autoGenerate = _this.rateValues.length == 0;
            _this.setIconsToRateValues();
            _this.createRenderedRateItems();
        });
        _this.registerFunctionOnPropertiesValueChanged(["rateColorMode", "scaleColorMode"], function () {
            _this.updateColors(_this.survey.themeVariables);
        });
        _this.registerFunctionOnPropertiesValueChanged(["displayMode"], function () {
            _this.updateRenderAsBasedOnDisplayMode(true);
        });
        _this.registerSychProperties(["autoGenerate"], function () {
            if (!_this.autoGenerate && _this.rateValues.length === 0) {
                _this.setPropertyValue("rateValues", _this.visibleRateValues);
            }
            if (_this.autoGenerate) {
                _this.rateValues.splice(0, _this.rateValues.length);
                _this.updateRateMax();
            }
            _this.createRenderedRateItems();
        });
        _this.createLocalizableString("minRateDescription", _this, true);
        _this.createLocalizableString("maxRateDescription", _this, true);
        _this.initPropertyDependencies();
        return _this;
    }
    QuestionRatingModel.prototype.setIconsToRateValues = function () {
        var _this = this;
        if (this.rateType == "smileys") {
            this.rateValues.map(function (item) { return item.icon = _this.getItemSmiley(item); });
        }
    };
    QuestionRatingModel.prototype.endLoadingFromJson = function () {
        _super.prototype.endLoadingFromJson.call(this);
        this.hasMinRateDescription = !!this.minRateDescription;
        this.hasMaxRateDescription = !!this.maxRateDescription;
        if (this.jsonObj.rateMin !== undefined && this.jsonObj.rateCount !== undefined && this.jsonObj.rateMax === undefined) {
            this.updateRateMax();
        }
        if (this.jsonObj.rateMax !== undefined && this.jsonObj.rateCount !== undefined && this.jsonObj.rateMin === undefined) {
            this.updateRateMin();
        }
        if (this.jsonObj.autoGenerate === undefined && this.jsonObj.rateValues !== undefined)
            this.autoGenerate = !this.jsonObj.rateValues.length;
        this.updateRateCount();
        this.setIconsToRateValues();
        this.createRenderedRateItems();
    };
    QuestionRatingModel.prototype.registerSychProperties = function (names, func) {
        var _this = this;
        this.registerFunctionOnPropertiesValueChanged(names, function () {
            if (!_this._syncPropertiesChanging) {
                _this._syncPropertiesChanging = true;
                func();
                _this._syncPropertiesChanging = false;
            }
        });
    };
    QuestionRatingModel.prototype.useRateValues = function () {
        return !!this.rateValues.length && !this.autoGenerate;
    };
    QuestionRatingModel.prototype.updateRateMax = function () {
        this.rateMax = this.rateMin + this.rateStep * (this.rateCount - 1);
    };
    QuestionRatingModel.prototype.updateRateMin = function () {
        this.rateMin = this.rateMax - this.rateStep * (this.rateCount - 1);
    };
    QuestionRatingModel.prototype.updateRateCount = function () {
        var newCount = 0;
        if (this.useRateValues()) {
            newCount = this.rateValues.length;
        }
        else {
            newCount = Math.trunc((this.rateMax - this.rateMin) / (this.rateStep || 1)) + 1;
        }
        if (newCount > 10 && this.rateDisplayMode == "smileys") {
            newCount = 10;
        }
        this.rateCount = newCount;
        if (this.rateValues.length > newCount)
            this.rateValues.splice(newCount, this.rateValues.length - newCount);
    };
    QuestionRatingModel.prototype.initPropertyDependencies = function () {
        var _this = this;
        this.registerSychProperties(["rateCount"], function () {
            if (!_this.useRateValues()) {
                _this.rateMax = _this.rateMin + _this.rateStep * (_this.rateCount - 1);
            }
            else {
                if (_this.rateCount < _this.rateValues.length) {
                    if (_this.rateCount >= 10 && _this.rateDisplayMode == "smileys")
                        return;
                    _this.rateValues.splice(_this.rateCount, _this.rateValues.length - _this.rateCount);
                }
                else {
                    for (var i = _this.rateValues.length; i < _this.rateCount; i++) {
                        _this.rateValues.push(new itemvalue_ItemValue(surveyLocalization.getString("choices_Item") + (i + 1)));
                    }
                }
            }
        });
        this.registerSychProperties(["rateMin", "rateMax", "rateStep", "rateValues"], function () {
            _this.updateRateCount();
        });
    };
    Object.defineProperty(QuestionRatingModel.prototype, "showSelectedItemLocText", {
        get: function () {
            return !this.readOnly && !this.inputHasValue && !!this.selectedItemLocText;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "selectedItemLocText", {
        get: function () {
            var _this = this;
            var _a;
            return !this.readOnly && ((_a = this.visibleRateValues.filter(function (v) { return v.value == _this.value; })[0]) === null || _a === void 0 ? void 0 : _a.locText);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "rateValues", {
        /**
         * A list of rate values.
         *
         * This property accepts an array of objects with the following structure:
         *
         * ```js
         * {
         *   "value": any, // A value to be saved in survey results
         *   "text": String, // A display text. This property supports Markdown. When `text` is undefined, `value` is used.
         *   "customProperty": any // Any property that you find useful.
         * }
         * ```
         *
         * If you add custom properties, refer to the following help topic to learn how to serialize them into JSON: [Add Custom Properties to Property Grid](https://surveyjs.io/survey-creator/documentation/property-grid#add-custom-properties-to-the-property-grid).
         *
         * To enable Markdown support for the `text` property, implement Markdown-to-HTML conversion in the [onTextMarkdown](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onTextMarkdown) event handler. For an example, refer to the following demo: [Convert Markdown to HTML with Showdown](https://surveyjs.io/form-library/examples/edit-survey-questions-markdown/).
         *
         * If you need to specify only the `value` property, you can set the `rateValues` property to an array of numbers, for example, `[ 3, 6, 10 ]`. These values are both saved in survey results and used as display text.
         *
         * If you do not specify the `rateValues` property, rate values are generated automatically based upon the [`rateMin`](https://surveyjs.io/form-library/documentation/api-reference/rating-scale-question-model#rateMin), [`rateMax`](https://surveyjs.io/form-library/documentation/api-reference/rating-scale-question-model#rateMax), [`rateStep`](https://surveyjs.io/form-library/documentation/api-reference/rating-scale-question-model#rateStep), and [`rateCount`](https://surveyjs.io/form-library/documentation/api-reference/rating-scale-question-model#rateCount) property values.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/rating-scale/ (linkStyle))
         */
        get: function () {
            return this.getPropertyValue("rateValues");
        },
        set: function (val) {
            this.setPropertyValue("rateValues", val);
            this.createRenderedRateItems();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "rateMin", {
        /**
         * Specifies the first rate value in the generated sequence of rate values. Applies if the [`rateValues`](https://surveyjs.io/form-library/documentation/api-reference/rating-scale-question-model#rateValues) array is empty.
         *
         * Default value: 1
         *
         * [View Demo](https://surveyjs.io/form-library/examples/rating-scale/ (linkStyle))
         * @see rateMax
         * @see rateStep
         * @see rateCount
         */
        get: function () {
            return this.getPropertyValue("rateMin");
        },
        set: function (val) {
            this.setPropertyValue("rateMin", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "rateMax", {
        /**
         * Specifies the last rate value in the generated sequence of rate values. Applies if the [`rateValues`](https://surveyjs.io/form-library/documentation/api-reference/rating-scale-question-model#rateValues) array is empty.
         *
         * Default value: 5
         *
         * [View Demo](https://surveyjs.io/form-library/examples/rating-scale/ (linkStyle))
         * @see rateMin
         * @see rateStep
         * @see rateCount
         */
        get: function () {
            return this.getPropertyValue("rateMax");
        },
        set: function (val) {
            this.setPropertyValue("rateMax", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "rateStep", {
        /**
         * Specifies a step with which to generate rate values. Applies if the [`rateValues`](https://surveyjs.io/form-library/documentation/api-reference/rating-scale-question-model#rateValues) array is empty.
         *
         * Default value: 1
         *
         * [View Demo](https://surveyjs.io/form-library/examples/rating-scale/ (linkStyle))
         * @see rateMin
         * @see rateMax
         * @see rateCount
         */
        get: function () {
            return this.getPropertyValue("rateStep");
        },
        set: function (val) {
            this.setPropertyValue("rateStep", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionRatingModel.prototype.updateColors = function (themeVariables) {
        if (this.colorMode === "monochrome")
            return;
        if (!DomDocumentHelper.isAvailable())
            return;
        if (QuestionRatingModel.colorsCalculated)
            return;
        function getRGBColor(colorName, varName) {
            var str = !!themeVariables && themeVariables[colorName];
            if (!str) {
                var style = getComputedStyle(DomDocumentHelper.getDocumentElement());
                str = style.getPropertyValue && style.getPropertyValue(varName);
            }
            if (!str)
                return null;
            var canvasElement = DomDocumentHelper.createElement("canvas");
            if (!canvasElement)
                return null;
            var ctx = canvasElement.getContext("2d");
            ctx.fillStyle = str;
            var newStr = ctx.fillStyle;
            if (newStr.startsWith("rgba")) {
                return newStr.substring(5, newStr.length - 1).split(",").map(function (c) { return +(c.trim()); });
            }
            var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(newStr);
            return result ? [
                parseInt(result[1], 16),
                parseInt(result[2], 16),
                parseInt(result[3], 16),
                1
            ] : null;
        }
        QuestionRatingModel.badColor = getRGBColor("--sjs-special-red", "--sd-rating-bad-color");
        QuestionRatingModel.normalColor = getRGBColor("--sjs-special-yellow", "--sd-rating-normal-color");
        QuestionRatingModel.goodColor = getRGBColor("--sjs-special-green", "--sd-rating-good-color");
        QuestionRatingModel.badColorLight = getRGBColor("--sjs-special-red-light", "--sd-rating-bad-color-light");
        QuestionRatingModel.normalColorLight = getRGBColor("--sjs-special-yellow-light", "--sd-rating-normal-color-light");
        QuestionRatingModel.goodColorLight = getRGBColor("--sjs-special-green-light", "--sd-rating-good-color-light");
        this.colorsCalculated = true;
    };
    QuestionRatingModel.prototype.getDisplayValueCore = function (keysAsText, value) {
        if (!this.useRateValues)
            return _super.prototype.getDisplayValueCore.call(this, keysAsText, value);
        var res = itemvalue_ItemValue.getTextOrHtmlByValue(this.visibleRateValues, value);
        return !!res ? res : value;
    };
    Object.defineProperty(QuestionRatingModel.prototype, "visibleRateValues", {
        get: function () {
            return this.renderedRateItems.map(function (i) { return i.itemValue; });
        },
        enumerable: false,
        configurable: true
    });
    QuestionRatingModel.prototype.supportEmptyValidation = function () { return this.renderAs === "dropdown"; };
    QuestionRatingModel.prototype.itemValuePropertyChanged = function (item, name, oldValue, newValue) {
        if (!this.useRateValues() && newValue !== undefined)
            this.autoGenerate = false;
        _super.prototype.itemValuePropertyChanged.call(this, item, name, oldValue, newValue);
    };
    QuestionRatingModel.prototype.createRenderedRateItems = function () {
        var _this = this;
        var rateValues = [];
        if (this.useRateValues()) {
            rateValues = this.rateValues;
        }
        else {
            rateValues = this.createRateValues();
        }
        if (this.autoGenerate) {
            this.rateMax = rateValues[rateValues.length - 1].value;
        }
        if (this.rateType == "smileys" && rateValues.length > 10)
            rateValues = rateValues.slice(0, 10);
        this.renderedRateItems = rateValues.map(function (v, i) {
            var renderedItem = null;
            if (_this.displayRateDescriptionsAsExtremeItems) {
                if (i == 0)
                    renderedItem = new question_rating_RenderedRatingItem(v, _this.minRateDescription && _this.locMinRateDescription || v.locText);
                if (i == rateValues.length - 1)
                    renderedItem = new question_rating_RenderedRatingItem(v, _this.maxRateDescription && _this.locMaxRateDescription || v.locText);
            }
            if (!renderedItem)
                renderedItem = new question_rating_RenderedRatingItem(v);
            return renderedItem;
        });
    };
    QuestionRatingModel.prototype.createRateValues = function () {
        var res = [];
        var value = this.rateMin;
        var step = this.rateStep;
        while (value <= this.rateMax &&
            res.length < settings.ratingMaximumRateValueCount) {
            var description = void 0;
            if (value === this.rateMin) {
                description = this.minRateDescription && this.locMinRateDescription;
            }
            if (value === this.rateMax || res.length === settings.ratingMaximumRateValueCount) {
                description = this.maxRateDescription && this.locMaxRateDescription;
            }
            var item = new RatingItemValue(value, description);
            item.locOwner = this;
            item.ownerPropertyName = "rateValues";
            res.push(item);
            value = this.correctValue(value + step, step);
        }
        return res;
    };
    QuestionRatingModel.prototype.correctValue = function (value, step) {
        if (!value)
            return value;
        if (Math.round(value) == value)
            return value;
        var fr = 0;
        while (Math.round(step) != step) {
            step *= 10;
            fr++;
        }
        return parseFloat(value.toFixed(fr));
    };
    QuestionRatingModel.prototype.getType = function () {
        return "rating";
    };
    QuestionRatingModel.prototype.getFirstInputElementId = function () {
        return this.inputId + "_0";
    };
    QuestionRatingModel.prototype.getInputId = function (index) {
        return this.inputId + "_" + index;
    };
    Object.defineProperty(QuestionRatingModel.prototype, "questionName", {
        get: function () {
            return this.name + "_" + this.id;
        },
        enumerable: false,
        configurable: true
    });
    QuestionRatingModel.prototype.supportGoNextPageAutomatic = function () {
        return this.isMouseDown === true || this.renderAs === "dropdown";
    };
    QuestionRatingModel.prototype.supportOther = function () {
        return false;
    };
    QuestionRatingModel.prototype.getPlainDataCalculatedValue = function (propName) {
        var res = _super.prototype.getPlainDataCalculatedValue.call(this, propName);
        if (res !== undefined || !this.useRateValues || this.isEmpty())
            return res;
        var item = itemvalue_ItemValue.getItemByValue(this.visibleRateValues, this.value);
        return item ? item[propName] : undefined;
    };
    Object.defineProperty(QuestionRatingModel.prototype, "minRateDescription", {
        /**
         * Specifies a description for the minimum (first) rate value.
         * @see rateDescriptionLocation
         * @see displayRateDescriptionsAsExtremeItems
         * @see rateValues
         * @see rateMin
         */
        get: function () {
            return this.getLocalizableStringText("minRateDescription");
        },
        set: function (val) {
            this.setLocalizableStringText("minRateDescription", val);
            this.hasMinRateDescription = !!this.minRateDescription;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "locMinRateDescription", {
        get: function () {
            return this.getLocalizableString("minRateDescription");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "maxRateDescription", {
        /**
         * Specifies a description for the maximum (last) rate value.
         * @see rateDescriptionLocation
         * @see displayRateDescriptionsAsExtremeItems
         * @see rateValues
         * @see rateMax
         */
        get: function () {
            return this.getLocalizableStringText("maxRateDescription");
        },
        set: function (val) {
            this.setLocalizableStringText("maxRateDescription", val);
            this.hasMaxRateDescription = !!this.maxRateDescription;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "locMaxRateDescription", {
        get: function () {
            return this.getLocalizableString("maxRateDescription");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "hasMinLabel", {
        get: function () {
            return !this.displayRateDescriptionsAsExtremeItems && !!this.hasMinRateDescription;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "hasMaxLabel", {
        get: function () {
            return !this.displayRateDescriptionsAsExtremeItems && !!this.hasMaxRateDescription;
        },
        enumerable: false,
        configurable: true
    });
    QuestionRatingModel.prototype.updateRenderAsBasedOnDisplayMode = function (isOnChange) {
        if (this.isDesignMode) {
            if (isOnChange || this.renderAs === "dropdown") {
                this.renderAs = "default";
            }
        }
        else {
            if (isOnChange || this.displayMode !== "auto") {
                this.renderAs = this.displayMode === "dropdown" ? "dropdown" : "default";
            }
        }
    };
    QuestionRatingModel.prototype.onSurveyLoad = function () {
        _super.prototype.onSurveyLoad.call(this);
        if (this.renderAs === "dropdown" && this.displayMode === "auto") {
            this.displayMode = this.renderAs;
        }
        else {
            this.updateRenderAsBasedOnDisplayMode();
        }
    };
    Object.defineProperty(QuestionRatingModel.prototype, "rateDisplayMode", {
        get: function () {
            return this.rateType;
        },
        set: function (val) {
            this.rateType = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "isStar", {
        get: function () {
            return this.rateType == "stars";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "isSmiley", {
        get: function () {
            return this.rateType == "smileys";
        },
        enumerable: false,
        configurable: true
    });
    QuestionRatingModel.prototype.getDefaultItemComponent = function () {
        if (this.renderAs == "dropdown")
            return "sv-rating-dropdown-item";
        if (this.isStar)
            return "sv-rating-item-star";
        if (this.isSmiley)
            return "sv-rating-item-smiley";
        return "sv-rating-item";
    };
    Object.defineProperty(QuestionRatingModel.prototype, "itemComponent", {
        /**
         * The name of a component used to render items.
         */
        get: function () {
            return this.getPropertyValue("itemComponent", this.getDefaultItemComponent());
        },
        set: function (value) {
            this.setPropertyValue("itemComponent", value);
        },
        enumerable: false,
        configurable: true
    });
    QuestionRatingModel.prototype.valueToData = function (val) {
        if (this.useRateValues()) {
            var item = itemvalue_ItemValue.getItemByValue(this.rateValues, val);
            return !!item ? item.value : val;
        }
        return !isNaN(val) ? parseFloat(val) : val;
    };
    QuestionRatingModel.prototype.setValueFromClick = function (value) {
        if (this.isReadOnlyAttr)
            return;
        if (this.value === ((typeof (this.value) === "string") ? value : parseFloat(value))) {
            this.clearValue(true);
        }
        else {
            this.value = value;
        }
        for (var i = 0; i < this.renderedRateItems.length; i++) {
            this.renderedRateItems[i].highlight = "none";
        }
    };
    QuestionRatingModel.prototype.onItemMouseIn = function (item) {
        if (IsTouch)
            return;
        if (this.isReadOnly || !item.itemValue.isEnabled || this.isDesignMode)
            return;
        var high = true;
        var selected = this.value != null;
        if (this.rateType !== "stars") {
            item.highlight = "highlighted";
            return;
        }
        for (var i = 0; i < this.renderedRateItems.length; i++) {
            this.renderedRateItems[i].highlight = high && !selected && "highlighted" || !high && selected && "unhighlighted" || "none";
            if (this.renderedRateItems[i] == item)
                high = false;
            if (this.renderedRateItems[i].itemValue.value == this.value)
                selected = false;
        }
    };
    QuestionRatingModel.prototype.onItemMouseOut = function (item) {
        if (IsTouch)
            return;
        this.renderedRateItems.forEach(function (item) { return item.highlight = "none"; });
    };
    Object.defineProperty(QuestionRatingModel.prototype, "itemSmallMode", {
        get: function () {
            return this.inMatrixMode && settings.matrix.rateSize == "small";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "ratingRootCss", {
        get: function () {
            var baseClassModifier = ((this.displayMode == "buttons" || (!!this.survey && this.survey.isDesignMode)) && this.cssClasses.rootWrappable) ?
                this.cssClasses.rootWrappable : "";
            var rootClassModifier = "";
            if (this.hasMaxLabel || this.hasMinLabel) {
                if (this.rateDescriptionLocation == "top")
                    rootClassModifier = this.cssClasses.rootLabelsTop;
                if (this.rateDescriptionLocation == "bottom")
                    rootClassModifier = this.cssClasses.rootLabelsBottom;
                if (this.rateDescriptionLocation == "topBottom")
                    rootClassModifier = this.cssClasses.rootLabelsDiagonal;
            }
            return new CssClassBuilder()
                .append(this.cssClasses.root)
                .append(baseClassModifier)
                .append(rootClassModifier)
                .append(this.cssClasses.itemSmall, this.itemSmallMode && this.rateType != "labels")
                .toString();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "itemStarIcon", {
        get: function () {
            return this.itemSmallMode ? "icon-rating-star-small" : "icon-rating-star";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "itemStarIconAlt", {
        get: function () {
            return this.itemStarIcon + "-2";
        },
        enumerable: false,
        configurable: true
    });
    QuestionRatingModel.prototype.getItemSmiley = function (item) {
        var icons = ["terrible", "very-poor", "poor", "not-good", "average", "normal", "good", "very-good", "excellent", "perfect"];
        var priority = ["very-good", "not-good", "normal", "good", "average", "excellent", "poor", "perfect", "very-poor", "terrible"];
        var count = this.useRateValues() ? this.rateValues.length : this.rateMax - this.rateMin + 1;
        var selectedPriority = priority.slice(0, count);
        var selectedIcons = icons.filter(function (i) { return selectedPriority.indexOf(i) != -1; });
        if (!this.useRateValues()) {
            return selectedIcons[item.value - this.rateMin];
        }
        else {
            return selectedIcons[this.rateValues.indexOf(item)];
        }
    };
    QuestionRatingModel.prototype.getItemSmileyIconName = function (item) {
        return "icon-" + this.getItemSmiley(item);
    };
    QuestionRatingModel.prototype.getItemClassByText = function (item, text) {
        return this.getItemClass(item);
    };
    QuestionRatingModel.prototype.getRenderedItemColor = function (index, light) {
        var startColor = light ? QuestionRatingModel.badColorLight : QuestionRatingModel.badColor;
        var endColor = light ? QuestionRatingModel.goodColorLight : QuestionRatingModel.goodColor;
        var normalIndex = (this.rateCount - 1) / 2.0;
        var middleColor = light ? QuestionRatingModel.normalColorLight : QuestionRatingModel.normalColor;
        if (index < normalIndex) {
            endColor = middleColor;
        }
        else {
            startColor = middleColor;
            index -= normalIndex;
        }
        if (!startColor || !endColor)
            return null;
        var curColor = [0, 0, 0, 0];
        for (var i = 0; i < 4; i++) {
            curColor[i] = startColor[i] + (endColor[i] - startColor[i]) * index / normalIndex;
            if (i < 3)
                curColor[i] = Math.trunc(curColor[i]);
        }
        return "rgba(" + curColor[0] + ", " + curColor[1] + ", " + curColor[2] + ", " + curColor[3] + ")";
    };
    QuestionRatingModel.prototype.getItemStyle = function (item, highlight) {
        if (highlight === void 0) { highlight = "none"; }
        if (this.scaleColorMode === "monochrome" && this.rateColorMode == "default" ||
            this.isPreviewStyle ||
            this.isReadOnlyStyle)
            return {};
        var index = this.visibleRateValues.indexOf(item);
        var color = this.getRenderedItemColor(index, false);
        var colorLight = highlight == "highlighted" && this.scaleColorMode === "colored" && this.getRenderedItemColor(index, true);
        return colorLight ? { "--sd-rating-item-color": color, "--sd-rating-item-color-light": colorLight } : { "--sd-rating-item-color": color };
    };
    QuestionRatingModel.prototype.getItemClass = function (item, highlight) {
        var _this = this;
        if (highlight === void 0) { highlight = "none"; }
        var isSelected = this.value == item.value;
        if (this.isStar) {
            if (!this.useRateValues()) {
                isSelected = this.value >= item.value;
            }
            else {
                isSelected = this.rateValues.indexOf(this.rateValues.filter(function (i) { return i.value == _this.value; })[0]) >= this.rateValues.indexOf(item);
            }
        }
        var isDisabled = this.isReadOnly || !item.isEnabled;
        var allowHover = !isDisabled && (this.value != item.value) && !(!!this.survey && this.survey.isDesignMode);
        var renderedItem = this.renderedRateItems.filter(function (i) { return i.itemValue == item; })[0];
        var isHighlighted = this.isStar && (renderedItem === null || renderedItem === void 0 ? void 0 : renderedItem.highlight) == "highlighted";
        var isUnhighlighted = this.isStar && (renderedItem === null || renderedItem === void 0 ? void 0 : renderedItem.highlight) == "unhighlighted";
        var itemClass = this.cssClasses.item;
        var itemSelectedClass = this.cssClasses.selected;
        var itemDisabledClass = this.cssClasses.itemDisabled;
        var itemReadOnlyClass = this.cssClasses.itemReadOnly;
        var itemPreviewClass = this.cssClasses.itemPreview;
        var itemHoverClass = this.cssClasses.itemHover;
        var itemitemOnErrorClass = this.cssClasses.itemOnError;
        var itemHighlightedClass = null;
        var itemUnhighlightedClass = null;
        var itemScaleColoredClass = null;
        var itemRateColoredClass = null;
        var itemSmallClass = null;
        if (this.isStar) {
            itemClass = this.cssClasses.itemStar;
            itemSelectedClass = this.cssClasses.itemStarSelected;
            itemDisabledClass = this.cssClasses.itemStarDisabled;
            itemReadOnlyClass = this.cssClasses.itemStarReadOnly;
            itemPreviewClass = this.cssClasses.itemStarPreview;
            itemHoverClass = this.cssClasses.itemStarHover;
            itemitemOnErrorClass = this.cssClasses.itemStarOnError;
            itemHighlightedClass = this.cssClasses.itemStarHighlighted;
            itemUnhighlightedClass = this.cssClasses.itemStarUnhighlighted;
            itemSmallClass = this.cssClasses.itemStarSmall;
        }
        if (this.isSmiley) {
            itemClass = this.cssClasses.itemSmiley;
            itemSelectedClass = this.cssClasses.itemSmileySelected;
            itemDisabledClass = this.cssClasses.itemSmileyDisabled;
            itemReadOnlyClass = this.cssClasses.itemSmileyReadOnly;
            itemPreviewClass = this.cssClasses.itemSmileyPreview;
            itemHoverClass = this.cssClasses.itemSmileyHover;
            itemitemOnErrorClass = this.cssClasses.itemSmileyOnError;
            itemHighlightedClass = this.cssClasses.itemSmileyHighlighted;
            itemScaleColoredClass = this.cssClasses.itemSmileyScaleColored;
            itemRateColoredClass = this.cssClasses.itemSmileyRateColored;
            itemSmallClass = this.cssClasses.itemSmileySmall;
        }
        var hasFixedSize = !this.isStar &&
            !this.isSmiley &&
            (!this.displayRateDescriptionsAsExtremeItems ||
                this.useRateValues() && item != this.rateValues[0] && item != this.rateValues[this.rateValues.length - 1] ||
                !this.useRateValues() && item.value != this.rateMin && item.value != this.rateMax) &&
            item.locText.calculatedText.length <= 2 &&
            Number.isInteger(Number(item.locText.calculatedText));
        return new CssClassBuilder()
            .append(itemClass)
            .append(itemSelectedClass, isSelected)
            .append(itemDisabledClass, this.isDisabledStyle)
            .append(itemReadOnlyClass, this.isReadOnlyStyle)
            .append(itemPreviewClass, this.isPreviewStyle)
            .append(itemHoverClass, allowHover)
            .append(itemHighlightedClass, isHighlighted)
            .append(itemScaleColoredClass, this.scaleColorMode == "colored")
            .append(itemRateColoredClass, this.rateColorMode == "scale" && isSelected)
            .append(itemUnhighlightedClass, isUnhighlighted)
            .append(itemitemOnErrorClass, this.hasCssError())
            .append(itemSmallClass, this.itemSmallMode)
            .append(this.cssClasses.itemFixedSize, hasFixedSize)
            .toString();
    };
    //methods for mobile view
    QuestionRatingModel.prototype.getControlClass = function () {
        this.isEmpty();
        return new CssClassBuilder()
            .append(this.cssClasses.control)
            .append(this.cssClasses.controlEmpty, this.isEmpty())
            .append(this.cssClasses.onError, this.hasCssError())
            .append(this.cssClasses.controlDisabled, this.isDisabledStyle)
            .append(this.cssClasses.controlReadOnly, this.isReadOnlyStyle)
            .append(this.cssClasses.controlPreview, this.isPreviewStyle)
            .toString();
    };
    Object.defineProperty(QuestionRatingModel.prototype, "placeholder", {
        get: function () {
            return this.getLocalizableStringText("ratingOptionsCaption");
        },
        set: function (val) {
            this.setLocalizableStringText("ratingOptionsCaption", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "locPlaceholder", {
        get: function () {
            return this.getLocalizableString("ratingOptionsCaption");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "allowClear", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "searchEnabled", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "renderedValue", {
        get: function () {
            return this.value;
        },
        set: function (val) {
            this.value = val;
        },
        enumerable: false,
        configurable: true
    });
    QuestionRatingModel.prototype.isItemSelected = function (item) {
        return item.value == this.value;
    };
    Object.defineProperty(QuestionRatingModel.prototype, "visibleChoices", {
        get: function () {
            return this.visibleRateValues;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionRatingModel.prototype, "readOnlyText", {
        get: function () {
            if (this.readOnly)
                return (this.displayValue || this.placeholder);
            return this.isEmpty() ? this.placeholder : "";
        },
        enumerable: false,
        configurable: true
    });
    QuestionRatingModel.prototype.needResponsiveWidth = function () {
        var rateValues = this.getPropertyValue("rateValues");
        var rateStep = this.getPropertyValue("rateStep");
        var rateMax = this.getPropertyValue("rateMax");
        var rateMin = this.getPropertyValue("rateMin");
        return this.displayMode != "dropdown" && !!(this.hasMinRateDescription ||
            this.hasMaxRateDescription ||
            (rateStep && (rateMax - rateMin) / rateStep > 9));
    };
    // TODO: return responsiveness after design improvement
    QuestionRatingModel.prototype.supportResponsiveness = function () {
        return true;
    };
    QuestionRatingModel.prototype.onBeforeSetCompactRenderer = function () {
        if (!this.dropdownListModelValue) {
            this.dropdownListModel = new dropdownListModel_DropdownListModel(this);
        }
    };
    QuestionRatingModel.prototype.getCompactRenderAs = function () {
        return (this.displayMode == "buttons") ? "default" : "dropdown";
    };
    QuestionRatingModel.prototype.getDesktopRenderAs = function () {
        return (this.displayMode == "dropdown") ? "dropdown" : "default";
    };
    Object.defineProperty(QuestionRatingModel.prototype, "dropdownListModel", {
        get: function () {
            if (this.renderAs === "dropdown") {
                this.onBeforeSetCompactRenderer();
            }
            return this.dropdownListModelValue;
        },
        set: function (val) {
            this.dropdownListModelValue = val;
            this.updateElementCss();
        },
        enumerable: false,
        configurable: true
    });
    QuestionRatingModel.prototype.updateCssClasses = function (res, css) {
        _super.prototype.updateCssClasses.call(this, res, css);
        if (!!this.dropdownListModel) {
            var listCssClasses = {};
            mergeValues(css.list, listCssClasses);
            mergeValues(res.list, listCssClasses);
            res["list"] = listCssClasses;
        }
    };
    QuestionRatingModel.prototype.calcCssClasses = function (css) {
        var classes = _super.prototype.calcCssClasses.call(this, css);
        if (this.dropdownListModel) {
            this.dropdownListModel.updateCssClasses(classes.popup, classes.list);
        }
        return classes;
    };
    QuestionRatingModel.prototype.themeChanged = function (theme) {
        this.colorsCalculated = false;
        this.updateColors(theme.cssVariables);
        this.createRenderedRateItems();
    };
    QuestionRatingModel.prototype.setSurveyImpl = function (value, isLight) {
        _super.prototype.setSurveyImpl.call(this, value, isLight);
        if (!this.survey)
            return;
        this.updateColors(this.survey.themeVariables);
        this.updateRenderAsBasedOnDisplayMode();
    };
    QuestionRatingModel.prototype.dispose = function () {
        _super.prototype.dispose.call(this);
        if (!!this.dropdownListModelValue) {
            this.dropdownListModelValue.dispose();
        }
    };
    QuestionRatingModel.colorsCalculated = false;
    question_rating_decorate([
        jsonobject_property({ defaultValue: false })
    ], QuestionRatingModel.prototype, "inputHasValue", void 0);
    question_rating_decorate([
        jsonobject_property()
    ], QuestionRatingModel.prototype, "autoGenerate", void 0);
    question_rating_decorate([
        jsonobject_property()
    ], QuestionRatingModel.prototype, "rateCount", void 0);
    question_rating_decorate([
        propertyArray()
    ], QuestionRatingModel.prototype, "renderedRateItems", void 0);
    question_rating_decorate([
        jsonobject_property({ defaultValue: false })
    ], QuestionRatingModel.prototype, "hasMinRateDescription", void 0);
    question_rating_decorate([
        jsonobject_property({ defaultValue: false })
    ], QuestionRatingModel.prototype, "hasMaxRateDescription", void 0);
    question_rating_decorate([
        jsonobject_property()
    ], QuestionRatingModel.prototype, "displayRateDescriptionsAsExtremeItems", void 0);
    question_rating_decorate([
        jsonobject_property()
    ], QuestionRatingModel.prototype, "displayMode", void 0);
    question_rating_decorate([
        jsonobject_property()
    ], QuestionRatingModel.prototype, "rateDescriptionLocation", void 0);
    question_rating_decorate([
        jsonobject_property()
    ], QuestionRatingModel.prototype, "rateType", void 0);
    question_rating_decorate([
        jsonobject_property()
    ], QuestionRatingModel.prototype, "scaleColorMode", void 0);
    question_rating_decorate([
        jsonobject_property()
    ], QuestionRatingModel.prototype, "rateColorMode", void 0);
    return QuestionRatingModel;
}(question_Question));

Serializer.addClass("rating", [
    { name: "showCommentArea:switch", layout: "row", visible: true, category: "general" },
    {
        name: "rateType",
        alternativeName: "rateDisplayMode",
        default: "labels",
        category: "rateValues",
        choices: ["labels", "stars", "smileys"],
        visibleIndex: 1
    },
    {
        name: "scaleColorMode",
        category: "rateValues",
        default: "monochrome",
        choices: ["monochrome", "colored"],
        visibleIf: function (obj) {
            return obj.rateDisplayMode == "smileys";
        },
        visibleIndex: 2
    },
    {
        name: "rateColorMode",
        category: "rateValues",
        default: "scale",
        choices: ["default", "scale"],
        visibleIf: function (obj) {
            return obj.rateDisplayMode == "smileys" && obj.scaleColorMode == "monochrome";
        },
        visibleIndex: 3
    },
    {
        name: "autoGenerate",
        category: "rateValues",
        default: true,
        choices: [true, false],
        visibleIndex: 5
    },
    {
        name: "rateCount:number",
        default: 5,
        category: "rateValues",
        visibleIndex: 4,
        onSettingValue: function (obj, val) {
            if (val < 2)
                return 2;
            if (val > settings.ratingMaximumRateValueCount && val > obj.rateValues.length)
                return settings.ratingMaximumRateValueCount;
            if (val > 10 && obj.rateDisplayMode == "smileys")
                return 10;
            return val;
        },
    },
    {
        name: "rateValues:itemvalue[]",
        baseValue: function () {
            return surveyLocalization.getString("choices_Item");
        },
        category: "rateValues",
        visibleIf: function (obj) {
            return !obj.autoGenerate;
        },
        visibleIndex: 6
    },
    {
        name: "rateMin:number", default: 1,
        onSettingValue: function (obj, val) {
            return val > obj.rateMax - obj.rateStep ? obj.rateMax - obj.rateStep : val;
        },
        visibleIf: function (obj) {
            return !!obj.autoGenerate;
        },
        visibleIndex: 7
    },
    {
        name: "rateMax:number", default: 5,
        onSettingValue: function (obj, val) {
            return val < obj.rateMin + obj.rateStep ? obj.rateMin + obj.rateStep : val;
        },
        visibleIf: function (obj) {
            return !!obj.autoGenerate;
        },
        visibleIndex: 8
    },
    {
        name: "rateStep:number", default: 1, minValue: 0.1,
        onSettingValue: function (obj, val) {
            if (val <= 0)
                val = 1;
            if (val > obj.rateMax - obj.rateMin)
                val = obj.rateMax - obj.rateMin;
            return val;
        },
        visibleIf: function (obj) {
            return !!obj.autoGenerate;
        },
        visibleIndex: 9
    },
    {
        name: "minRateDescription",
        alternativeName: "mininumRateDescription",
        serializationProperty: "locMinRateDescription",
        visibleIndex: 18
    },
    {
        name: "maxRateDescription",
        alternativeName: "maximumRateDescription",
        serializationProperty: "locMaxRateDescription",
        visibleIndex: 19
    },
    {
        name: "displayRateDescriptionsAsExtremeItems:boolean",
        default: false,
        visibleIndex: 21,
        visibleIf: function (obj) {
            return obj.rateType == "labels";
        }
    },
    {
        name: "rateDescriptionLocation",
        default: "leftRight",
        choices: ["leftRight", "top", "bottom", "topBottom"],
        visibleIndex: 20
    },
    {
        name: "displayMode",
        default: "auto",
        choices: ["auto", "buttons", "dropdown"],
        visibleIndex: 0
    },
    { name: "itemComponent", visible: false, defaultFunc: function (obj) {
            if (!obj)
                return "sv-rating-item";
            if (!!obj.getOriginalObj)
                obj = obj.getOriginalObj();
            return obj.getDefaultItemComponent();
        } }
], function () {
    return new question_rating_QuestionRatingModel("");
}, "question");
questionfactory_QuestionFactory.Instance.registerQuestion("rating", function (name) {
    return new question_rating_QuestionRatingModel(name);
});

// CONCATENATED MODULE: ./packages/survey-core/src/question_boolean.ts
var question_boolean_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var question_boolean_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};






/**
 * A class that describes the Yes/No (Boolean) question type.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/questiontype-boolean/ (linkStyle))
 */
var question_boolean_QuestionBooleanModel = /** @class */ (function (_super) {
    question_boolean_extends(QuestionBooleanModel, _super);
    function QuestionBooleanModel(name) {
        var _this = _super.call(this, name) || this;
        _this.createLocalizableString("labelFalse", _this, true, "booleanUncheckedLabel");
        _this.createLocalizableString("labelTrue", _this, true, "booleanCheckedLabel");
        return _this;
    }
    QuestionBooleanModel.prototype.getType = function () {
        return "boolean";
    };
    QuestionBooleanModel.prototype.isLayoutTypeSupported = function (layoutType) {
        return true;
    };
    QuestionBooleanModel.prototype.supportGoNextPageAutomatic = function () {
        return this.renderAs !== "checkbox";
    };
    Object.defineProperty(QuestionBooleanModel.prototype, "isIndeterminate", {
        get: function () {
            return this.isEmpty();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionBooleanModel.prototype, "hasTitle", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionBooleanModel.prototype, "booleanValue", {
        /**
         * Gets or sets the question value as a Boolean value.
         *
         * If you set the `valueTrue` and `valueFalse` properties, the `value` property contains their values instead of Boolean values. This may be inconvenient when you operate the question value in code. To access the standard Boolean values, use the `booleanValue` property.
         * @see valueTrue
         * @see valueFalse
         */
        get: function () {
            if (this.isEmpty())
                return null;
            return this.value == this.getValueTrue();
        },
        set: function (val) {
            if (this.isReadOnly || this.isDesignMode) {
                return;
            }
            this.setBooleanValue(val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionBooleanModel.prototype, "checkedValue", {
        get: function () { return this.booleanValue; },
        set: function (val) { this.booleanValue = val; },
        enumerable: false,
        configurable: true
    });
    QuestionBooleanModel.prototype.setBooleanValue = function (val) {
        if (this.isValueEmpty(val)) {
            this.value = undefined;
            this.booleanValueRendered = undefined;
        }
        else {
            this.value = val == true ? this.getValueTrue() : this.getValueFalse();
            this.booleanValueRendered = val;
        }
    };
    Object.defineProperty(QuestionBooleanModel.prototype, "defaultValue", {
        get: function () {
            return this.getPropertyValue("defaultValue");
        },
        set: function (val) {
            if (val === true)
                val = "true";
            if (val === false)
                val = "false";
            this.setPropertyValue("defaultValue", val);
            this.updateValueWithDefaults();
        },
        enumerable: false,
        configurable: true
    });
    QuestionBooleanModel.prototype.getDefaultValue = function () {
        var val = this.defaultValue;
        if (val === "indeterminate" || val === undefined || val === null)
            return undefined;
        return val == "true" ? this.getValueTrue() : this.getValueFalse();
    };
    Object.defineProperty(QuestionBooleanModel.prototype, "locTitle", {
        get: function () {
            var original = this.getLocalizableString("title");
            if (!this.isValueEmpty(this.locLabel.text) && (this.isValueEmpty(original.text) || this.isLabelRendered && !this.showTitle))
                return this.locLabel;
            return original;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionBooleanModel.prototype, "labelRenderedAriaID", {
        get: function () {
            return this.isLabelRendered ? this.ariaTitleId : null;
        },
        enumerable: false,
        configurable: true
    });
    QuestionBooleanModel.prototype.beforeDestroyQuestionElement = function (el) {
        _super.prototype.beforeDestroyQuestionElement.call(this, el);
        this.leftAnswerElement = undefined;
    };
    Object.defineProperty(QuestionBooleanModel.prototype, "isLabelRendered", {
        get: function () {
            return this.titleLocation === "hidden";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionBooleanModel.prototype, "canRenderLabelDescription", {
        get: function () {
            return this.isLabelRendered && this.hasDescription && (this.hasDescriptionUnderTitle || this.hasDescriptionUnderInput);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionBooleanModel.prototype, "labelTrue", {
        /**
         * Gets or sets a text label that corresponds to a positive answer.
         *
         * Default value: "Yes"
         * @see valueTrue
         * @see valueFalse
         */
        get: function () {
            return this.getLocalizableStringText("labelTrue");
        },
        set: function (val) {
            this.setLocalizableStringText("labelTrue", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionBooleanModel.prototype, "locLabelTrue", {
        get: function () {
            return this.getLocalizableString("labelTrue");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionBooleanModel.prototype, "isDeterminated", {
        get: function () {
            return this.booleanValue !== null && this.booleanValue !== undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionBooleanModel.prototype, "locLabelLeft", {
        get: function () {
            return this.swapOrder ? this.getLocalizableString("labelTrue") : this.getLocalizableString("labelFalse");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionBooleanModel.prototype, "locLabelRight", {
        get: function () {
            return this.swapOrder ? this.getLocalizableString("labelFalse") : this.getLocalizableString("labelTrue");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionBooleanModel.prototype, "labelFalse", {
        /**
         * Gets or sets a text label that corresponds to a negative answer.
         *
         * Default value: "No"
         * @see valueTrue
         * @see valueFalse
         */
        get: function () {
            return this.getLocalizableStringText("labelFalse");
        },
        set: function (val) {
            this.setLocalizableStringText("labelFalse", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionBooleanModel.prototype, "locLabelFalse", {
        get: function () {
            return this.getLocalizableString("labelFalse");
        },
        enumerable: false,
        configurable: true
    });
    QuestionBooleanModel.prototype.getValueTrue = function () {
        return this.valueTrue !== undefined ? this.valueTrue : true;
    };
    QuestionBooleanModel.prototype.getValueFalse = function () {
        return this.valueFalse !== undefined ? this.valueFalse : false;
    };
    QuestionBooleanModel.prototype.setDefaultValue = function () {
        if (this.isDefaultValueSet("true", this.valueTrue))
            this.setBooleanValue(true);
        if (this.isDefaultValueSet("false", this.valueFalse))
            this.setBooleanValue(false);
        var val = this.defaultValue;
        if (val === "indeterminate" || val === null || val === undefined)
            this.setBooleanValue(undefined);
    };
    QuestionBooleanModel.prototype.isDefaultValueSet = function (defaultValueCheck, valueTrueOrFalse) {
        return this.defaultValue == defaultValueCheck || (valueTrueOrFalse !== undefined && this.defaultValue === valueTrueOrFalse);
    };
    QuestionBooleanModel.prototype.getDisplayValueCore = function (keysAsText, value) {
        if (value == this.getValueTrue())
            return this.locLabelTrue.textOrHtml;
        return this.locLabelFalse.textOrHtml;
    };
    QuestionBooleanModel.prototype.getItemCssValue = function (css) {
        return new CssClassBuilder()
            .append(css.item)
            .append(css.itemOnError, this.hasCssError())
            .append(css.itemDisabled, this.isDisabledStyle)
            .append(css.itemReadOnly, this.isReadOnlyStyle)
            .append(css.itemPreview, this.isPreviewStyle)
            .append(css.itemHover, !this.isDesignMode)
            .append(css.itemChecked, !!this.booleanValue)
            .append(css.itemExchanged, !!this.swapOrder)
            .append(css.itemIndeterminate, !this.isDeterminated)
            .toString();
    };
    QuestionBooleanModel.prototype.getItemCss = function () {
        return this.getItemCssValue(this.cssClasses);
    };
    QuestionBooleanModel.prototype.getCheckboxItemCss = function () {
        return this.getItemCssValue({
            item: this.cssClasses.checkboxItem,
            itemOnError: this.cssClasses.checkboxItemOnError,
            itemDisabled: this.cssClasses.checkboxItemDisabled,
            itemDisable: this.cssClasses.checkboxItemDisabled,
            itemReadOnly: this.cssClasses.checkboxItemReadOnly,
            itemPreview: this.cssClasses.checkboxItemPreview,
            itemChecked: this.cssClasses.checkboxItemChecked,
            itemIndeterminate: this.cssClasses.checkboxItemIndeterminate
        });
    };
    QuestionBooleanModel.prototype.getLabelCss = function (checked) {
        return new CssClassBuilder()
            .append(this.cssClasses.label)
            .append(this.cssClasses.disabledLabel, this.booleanValue === !checked || this.isDisabledStyle)
            .append(this.cssClasses.labelReadOnly, this.isReadOnlyStyle)
            .append(this.cssClasses.labelPreview, this.isPreviewStyle)
            .append(this.cssClasses.labelTrue, !this.isIndeterminate && checked === !this.swapOrder)
            .append(this.cssClasses.labelFalse, !this.isIndeterminate && checked === this.swapOrder)
            .toString();
    };
    QuestionBooleanModel.prototype.updateValueFromSurvey = function (newValue, clearData) {
        if (clearData === void 0) { clearData = false; }
        _super.prototype.updateValueFromSurvey.call(this, newValue, clearData);
    };
    QuestionBooleanModel.prototype.onValueChanged = function () {
        _super.prototype.onValueChanged.call(this);
    };
    Object.defineProperty(QuestionBooleanModel.prototype, "svgIcon", {
        get: function () {
            if (this.booleanValue && this.cssClasses.svgIconCheckedId)
                return this.cssClasses.svgIconCheckedId;
            if (!this.isDeterminated && this.cssClasses.svgIconIndId)
                return this.cssClasses.svgIconIndId;
            if (!this.booleanValue && this.cssClasses.svgIconUncheckedId)
                return this.cssClasses.svgIconUncheckedId;
            return this.cssClasses.svgIconId;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionBooleanModel.prototype, "itemSvgIcon", {
        get: function () {
            if (this.isPreviewStyle && this.cssClasses.itemPreviewSvgIconId) {
                return this.cssClasses.itemPreviewSvgIconId;
            }
            return this.cssClasses.itemSvgIconId;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionBooleanModel.prototype, "allowClick", {
        get: function () {
            return this.isIndeterminate && !this.isInputReadOnly;
        },
        enumerable: false,
        configurable: true
    });
    QuestionBooleanModel.prototype.getCheckedLabel = function () {
        if (this.booleanValue === true) {
            return this.locLabelTrue;
        }
        else if (this.booleanValue === false) {
            return this.locLabelFalse;
        }
    };
    QuestionBooleanModel.prototype.setQuestionValue = function (newValue, updateIsAnswered) {
        if (updateIsAnswered === void 0) { updateIsAnswered = true; }
        if (newValue === "true" && this.valueTrue !== "true")
            newValue = true;
        if (newValue === "false" && this.valueFalse !== "false")
            newValue = false;
        if (newValue === "indeterminate" || newValue === null)
            newValue = undefined;
        _super.prototype.setQuestionValue.call(this, newValue, updateIsAnswered);
    };
    /* #region web-based methods */
    QuestionBooleanModel.prototype.onLabelClick = function (event, value) {
        if (this.allowClick) {
            preventDefaults(event);
            this.booleanValue = value;
        }
        return true;
    };
    QuestionBooleanModel.prototype.calculateBooleanValueByEvent = function (event, isRightClick) {
        var isRtl = false;
        if (DomDocumentHelper.isAvailable()) {
            isRtl = DomDocumentHelper.getComputedStyle(event.target).direction == "rtl";
        }
        this.booleanValue = isRtl ? !isRightClick : isRightClick;
    };
    QuestionBooleanModel.prototype.onSwitchClickModel = function (event) {
        if (this.allowClick) {
            preventDefaults(event);
            var isRightClick = event.offsetX / event.target.offsetWidth > 0.5;
            this.calculateBooleanValueByEvent(event, isRightClick);
            return;
        }
        return true;
    };
    QuestionBooleanModel.prototype.onKeyDownCore = function (event) {
        if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
            event.stopPropagation();
            this.calculateBooleanValueByEvent(event, event.key === "ArrowRight");
        }
        return true;
    };
    /* #endregion */
    QuestionBooleanModel.prototype.getRadioItemClass = function (css, value) {
        var className = undefined;
        if (css.radioItem) {
            className = css.radioItem;
        }
        if (css.radioItemChecked && value === this.booleanValue) {
            className = (className ? className + " " : "") + css.radioItemChecked;
        }
        if (this.isDisabledStyle) {
            className += " " + css.radioItemDisabled;
        }
        if (this.isReadOnlyStyle) {
            className += " " + css.radioItemReadOnly;
        }
        if (this.isPreviewStyle) {
            className += " " + css.radioItemPreview;
        }
        return className;
    };
    QuestionBooleanModel.prototype.supportResponsiveness = function () {
        return true;
    };
    QuestionBooleanModel.prototype.getCompactRenderAs = function () {
        return "radio";
    };
    QuestionBooleanModel.prototype.createActionContainer = function (allowAdaptiveActions) {
        return _super.prototype.createActionContainer.call(this, this.renderAs !== "checkbox");
    };
    Object.defineProperty(QuestionBooleanModel.prototype, "isNewA11yStructure", {
        //a11y
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionBooleanModel.prototype, "a11y_input_ariaRole", {
        get: function () {
            return "switch";
        },
        enumerable: false,
        configurable: true
    });
    question_boolean_decorate([
        jsonobject_property()
    ], QuestionBooleanModel.prototype, "booleanValueRendered", void 0);
    question_boolean_decorate([
        jsonobject_property()
    ], QuestionBooleanModel.prototype, "showTitle", void 0);
    question_boolean_decorate([
        jsonobject_property({ localizable: true })
    ], QuestionBooleanModel.prototype, "label", void 0);
    question_boolean_decorate([
        jsonobject_property({ defaultValue: false })
    ], QuestionBooleanModel.prototype, "swapOrder", void 0);
    question_boolean_decorate([
        jsonobject_property()
    ], QuestionBooleanModel.prototype, "valueTrue", void 0);
    question_boolean_decorate([
        jsonobject_property()
    ], QuestionBooleanModel.prototype, "valueFalse", void 0);
    return QuestionBooleanModel;
}(question_Question));

Serializer.addClass("boolean", [
    { name: "showCommentArea:switch", layout: "row", visible: true, category: "general" },
    { name: "label:text", serializationProperty: "locLabel", isSerializable: false, visible: false },
    {
        name: "labelTrue:text",
        serializationProperty: "locLabelTrue",
    },
    {
        name: "labelFalse:text",
        serializationProperty: "locLabelFalse",
    },
    "valueTrue",
    "valueFalse",
    { name: "swapOrder:boolean", category: "general" },
    { name: "renderAs", default: "default", visible: false },
], function () {
    return new question_boolean_QuestionBooleanModel("");
}, "question");
questionfactory_QuestionFactory.Instance.registerQuestion("boolean", function (name) {
    return new question_boolean_QuestionBooleanModel(name);
});

// CONCATENATED MODULE: ./packages/survey-core/src/question_imagepicker.ts
var question_imagepicker_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var question_imagepicker_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};









var question_imagepicker_ImageItemValue = /** @class */ (function (_super) {
    question_imagepicker_extends(ImageItemValue, _super);
    function ImageItemValue(value, text, typeName) {
        if (text === void 0) { text = null; }
        if (typeName === void 0) { typeName = "imageitemvalue"; }
        var _this = _super.call(this, value, text, typeName) || this;
        _this.typeName = typeName;
        _this.createLocalizableString("imageLink", _this, false);
        return _this;
    }
    ImageItemValue.prototype.getType = function () {
        return !!this.typeName ? this.typeName : "itemvalue";
    };
    Object.defineProperty(ImageItemValue.prototype, "imageLink", {
        /**
         * The image or video link property.
         */
        get: function () {
            return this.getLocalizableStringText("imageLink");
        },
        set: function (val) {
            this.setLocalizableStringText("imageLink", val);
            this.imageNotLoaded = false;
            this.videoNotLoaded = false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ImageItemValue.prototype, "locImageLink", {
        get: function () {
            return this.getLocalizableString("imageLink");
        },
        enumerable: false,
        configurable: true
    });
    ImageItemValue.prototype.getLocale = function () {
        return !!this.locOwner ? this.locOwner.getLocale() : "";
    };
    ImageItemValue.prototype.getMarkdownHtml = function (text, name) {
        return !!this.locOwner ? this.locOwner.getMarkdownHtml(text, name) : undefined;
    };
    ImageItemValue.prototype.getRenderer = function (name) {
        return !!this.locOwner ? this.locOwner.getRenderer(name) : null;
    };
    ImageItemValue.prototype.getRendererContext = function (locStr) {
        return !!this.locOwner ? this.locOwner.getRendererContext(locStr) : locStr;
    };
    ImageItemValue.prototype.getProcessedText = function (text) {
        return !!this.locOwner ? this.locOwner.getProcessedText(text) : text;
    };
    ImageItemValue.prototype.onErrorHandler = function () {
        this.contentNotLoaded = true;
    };
    Object.defineProperty(ImageItemValue.prototype, "contentNotLoaded", {
        get: function () {
            return this.locOwner instanceof question_imagepicker_QuestionImagePickerModel && this.locOwner.contentMode == "video" ? this.videoNotLoaded : this.imageNotLoaded;
        },
        set: function (val) {
            if (this.locOwner instanceof question_imagepicker_QuestionImagePickerModel && this.locOwner.contentMode == "video") {
                this.videoNotLoaded = val;
            }
            else {
                this.imageNotLoaded = val;
            }
        },
        enumerable: false,
        configurable: true
    });
    question_imagepicker_decorate([
        jsonobject_property({ defaultValue: false })
    ], ImageItemValue.prototype, "videoNotLoaded", void 0);
    question_imagepicker_decorate([
        jsonobject_property({ defaultValue: false })
    ], ImageItemValue.prototype, "imageNotLoaded", void 0);
    return ImageItemValue;
}(itemvalue_ItemValue));

/**
  * A class that describes the Image Picker question type.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/image-picker-question/ (linkStyle))
 */
var question_imagepicker_QuestionImagePickerModel = /** @class */ (function (_super) {
    question_imagepicker_extends(QuestionImagePickerModel, _super);
    function QuestionImagePickerModel(name) {
        var _this = _super.call(this, name) || this;
        //responsive mode
        _this.isResponsiveValue = false;
        _this.onContentLoaded = function (item, event) {
            item.contentNotLoaded = false;
            var content = event.target;
            if (_this.contentMode == "video") {
                item["aspectRatio"] = content.videoWidth / content.videoHeight;
            }
            else {
                item["aspectRatio"] = content.naturalWidth / content.naturalHeight;
            }
            _this._width && _this.processResponsiveness(0, _this._width);
        };
        _this.colCount = 0;
        _this.registerPropertyChangedHandlers(["minImageWidth", "maxImageWidth", "minImageHeight", "maxImageHeight", "visibleChoices", "colCount", "isResponsiveValue"], function () {
            if (!!_this._width) {
                _this.processResponsiveness(0, _this._width);
            }
        });
        _this.registerPropertyChangedHandlers(["imageWidth", "imageHeight"], function () {
            _this.calcIsResponsive();
        });
        _this.calcIsResponsive();
        return _this;
    }
    QuestionImagePickerModel.prototype.getType = function () {
        return "imagepicker";
    };
    QuestionImagePickerModel.prototype.supportGoNextPageAutomatic = function () {
        return !this.multiSelect;
    };
    Object.defineProperty(QuestionImagePickerModel.prototype, "hasSingleInput", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    QuestionImagePickerModel.prototype.getItemValueType = function () {
        return "imageitemvalue";
    };
    Object.defineProperty(QuestionImagePickerModel.prototype, "isCompositeQuestion", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    QuestionImagePickerModel.prototype.supportOther = function () { return false; };
    QuestionImagePickerModel.prototype.supportNone = function () { return false; };
    QuestionImagePickerModel.prototype.supportRefuse = function () { return false; };
    QuestionImagePickerModel.prototype.supportDontKnow = function () { return false; };
    QuestionImagePickerModel.prototype.isAnswerCorrect = function () {
        if (!this.multiSelect)
            return _super.prototype.isAnswerCorrect.call(this);
        return helpers_Helpers.isArrayContainsEqual(this.value, this.correctAnswer);
    };
    Object.defineProperty(QuestionImagePickerModel.prototype, "multiSelect", {
        /**
         * Specifies whether users can select multiple images or videos.
         *
         * Default value: `false`
         */
        get: function () {
            return this.getPropertyValue("multiSelect");
        },
        set: function (newValue) {
            this.setPropertyValue("multiSelect", newValue);
        },
        enumerable: false,
        configurable: true
    });
    QuestionImagePickerModel.prototype.isItemSelected = function (item) {
        var val = this.value;
        var imageItemValue = item;
        if (this.isValueEmpty(val))
            return false;
        if (!imageItemValue.imageLink || imageItemValue.contentNotLoaded)
            return false;
        if (!this.multiSelect)
            return this.isTwoValueEquals(val, item.value);
        if (!Array.isArray(val))
            return false;
        for (var i = 0; i < val.length; i++) {
            if (this.isTwoValueEquals(val[i], item.value))
                return true;
        }
        return false;
    };
    QuestionImagePickerModel.prototype.getItemEnabled = function (item) {
        var imageItemValue = item;
        if (!imageItemValue.imageLink || imageItemValue.contentNotLoaded)
            return false;
        return _super.prototype.getItemEnabled.call(this, item);
    };
    QuestionImagePickerModel.prototype.clearIncorrectValues = function () {
        if (this.multiSelect) {
            var val = this.value;
            if (!val)
                return;
            if (!Array.isArray(val) || val.length == 0) {
                this.clearValue(true);
                return;
            }
            var newValue = [];
            for (var i = 0; i < val.length; i++) {
                if (!this.hasUnknownValue(val[i], true)) {
                    newValue.push(val[i]);
                }
            }
            if (newValue.length == val.length)
                return;
            if (newValue.length == 0) {
                this.clearValue(true);
            }
            else {
                this.value = newValue;
            }
        }
        else {
            _super.prototype.clearIncorrectValues.call(this);
        }
    };
    QuestionImagePickerModel.prototype.getDisplayValueCore = function (keysAsText, value) {
        if (!this.multiSelect && !Array.isArray(value))
            return _super.prototype.getDisplayValueCore.call(this, keysAsText, value);
        return this.getDisplayArrayValue(keysAsText, value);
    };
    Object.defineProperty(QuestionImagePickerModel.prototype, "showLabel", {
        /**
         * Specifies whether to display labels under images or videos. Labels text are taken from the `text` property of each object in the `choices` array.
         * @see choices
         */
        get: function () {
            return this.getPropertyValue("showLabel");
        },
        set: function (newValue) {
            this.setPropertyValue("showLabel", newValue);
        },
        enumerable: false,
        configurable: true
    });
    QuestionImagePickerModel.prototype.endLoadingFromJson = function () {
        _super.prototype.endLoadingFromJson.call(this);
        if (!this.isDesignMode && this.multiSelect) {
            this.createNewArray("renderedValue");
            this.createNewArray("value");
        }
        this.calcIsResponsive();
    };
    QuestionImagePickerModel.prototype.getValueCore = function () {
        var value = _super.prototype.getValueCore.call(this);
        if (value !== undefined) {
            return value;
        }
        if (this.multiSelect) {
            return [];
        }
        return value;
    };
    QuestionImagePickerModel.prototype.convertValToArrayForMultSelect = function (val) {
        if (!this.multiSelect)
            return val;
        if (this.isValueEmpty(val) || Array.isArray(val))
            return val;
        return [val];
    };
    QuestionImagePickerModel.prototype.renderedValueFromDataCore = function (val) {
        return this.convertValToArrayForMultSelect(val);
    };
    QuestionImagePickerModel.prototype.rendredValueToDataCore = function (val) {
        return this.convertValToArrayForMultSelect(val);
    };
    Object.defineProperty(QuestionImagePickerModel.prototype, "imageHeight", {
        /**
         * Specifies the height of containers for images or videos. Accepts positive numbers and CSS values.
         *
         * Default value: `auto`
         *
         * This property allows you to specify the exact image height. If you do not set it, the height will be calculated automatically based on the [`minImageHeight`](#minImageHeight) and [`maxImageHeight`](#maxImageHeight) values and available screen height.
         *
         * Use the [`imageFit`](#imageFit) property to specify how to fit the images or videos into their containers.
         * @see imageWidth
         */
        get: function () {
            return this.getPropertyValue("imageHeight");
        },
        set: function (val) {
            this.setPropertyValue("imageHeight", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImagePickerModel.prototype, "renderedImageHeight", {
        get: function () {
            var height = this.isResponsive ? Math.floor(this.responsiveImageHeight) : this.imageHeight;
            return (height ? height : 150);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImagePickerModel.prototype, "imageWidth", {
        /**
         * Specifies the width of containers for images or videos. Accepts positive numbers and CSS values.
         *
         * Default value: `auto`
         *
         * This property allows you to specify the exact image width. If you do not set it, the width will be calculated automatically based on the [`minImageWidth`](#minImageWidth) and [`maxImageWidth`](#maxImageWidth) values and available screen width.
         *
         * Use the [`imageFit`](#imageFit) property to specify how to fit the images or videos into their containers.
         * @see imageHeight
         */
        get: function () {
            return this.getPropertyValue("imageWidth");
        },
        set: function (val) {
            this.setPropertyValue("imageWidth", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImagePickerModel.prototype, "renderedImageWidth", {
        get: function () {
            var width = this.isResponsive ? Math.floor(this.responsiveImageWidth) : this.imageWidth;
            return (width ? width : 200);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImagePickerModel.prototype, "imageFit", {
        /**
         * Specifies how to resize images or videos to fit them into their containers.
         *
         * Refer to the [`object-fit`](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) CSS property description for information on accepted values.
         * @see imageHeight
         * @see imageWidth
         */
        get: function () {
            return this.getPropertyValue("imageFit");
        },
        set: function (val) {
            this.setPropertyValue("imageFit", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImagePickerModel.prototype, "contentMode", {
        /**
         * Specifies the type of content that choice items display.
         *
         * Possible values:
         *
         * - `"image"` (default) - Images in one of the following formats: JPEG, GIF, PNG, APNG, SVG, BMP, ICO.
         * - `"video"` - Videos in one of the following formats: MP4, MOV, WMV, FLV, AVI, MKV.
         */
        get: function () {
            return this.getPropertyValue("contentMode");
        },
        set: function (val) {
            this.setPropertyValue("contentMode", val);
            if (val === "video") {
                this.showLabel = true;
            }
        },
        enumerable: false,
        configurable: true
    });
    QuestionImagePickerModel.prototype.convertDefaultValue = function (val) {
        return val;
    };
    Object.defineProperty(QuestionImagePickerModel.prototype, "inputType", {
        get: function () {
            return this.multiSelect ? "checkbox" : "radio";
        },
        enumerable: false,
        configurable: true
    });
    QuestionImagePickerModel.prototype.isBuiltInChoice = function (item) {
        return false;
    };
    QuestionImagePickerModel.prototype.addToVisibleChoices = function (items, isAddAll) {
        this.addNewItemToVisibleChoices(items, isAddAll);
    };
    QuestionImagePickerModel.prototype.getSelectBaseRootCss = function () {
        return new CssClassBuilder().append(_super.prototype.getSelectBaseRootCss.call(this)).append(this.cssClasses.rootColumn, this.getCurrentColCount() == 1).toString();
    };
    Object.defineProperty(QuestionImagePickerModel.prototype, "isResponsive", {
        get: function () {
            return this.isResponsiveValue && this.isDefaultV2Theme;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImagePickerModel.prototype, "exactSizesAreEmpty", {
        get: function () {
            var _this = this;
            return !(["imageHeight", "imageWidth"].some(function (propName) { return _this[propName] !== undefined && _this[propName] !== null; }));
        },
        enumerable: false,
        configurable: true
    });
    QuestionImagePickerModel.prototype.calcIsResponsive = function () {
        this.isResponsiveValue = this.exactSizesAreEmpty;
    };
    QuestionImagePickerModel.prototype.getObservedElementSelector = function () {
        return classesToSelector(this.cssClasses.root);
    };
    QuestionImagePickerModel.prototype.supportResponsiveness = function () {
        return true;
    };
    QuestionImagePickerModel.prototype.needResponsiveness = function () {
        return this.supportResponsiveness() && this.isDefaultV2Theme;
    };
    QuestionImagePickerModel.prototype.needResponsiveWidth = function () {
        return this.colCount > 2;
    };
    QuestionImagePickerModel.prototype.getCurrentColCount = function () {
        if (this.responsiveColCount === undefined || this.colCount === 0) {
            return this.colCount;
        }
        return this.responsiveColCount;
    };
    QuestionImagePickerModel.prototype.processResponsiveness = function (_, availableWidth) {
        this._width = availableWidth = Math.floor(availableWidth);
        var calcAvailableColumnsCount = function (availableWidth, minWidth, gap) {
            var itemsInRow = Math.floor(availableWidth / (minWidth + gap));
            if ((itemsInRow + 1) * (minWidth + gap) - gap <= availableWidth)
                itemsInRow++;
            return itemsInRow;
        };
        if (this.isResponsive) {
            var itemsCount = this.choices.length + (this.isDesignMode ? 1 : 0);
            var gap = this.gapBetweenItems || 0;
            var minWidth = this.minImageWidth;
            var maxWidth = this.maxImageWidth;
            var maxHeight = this.maxImageHeight;
            var minHeight = this.minImageHeight;
            var colCount = this.colCount;
            var width_1;
            if (colCount === 0) {
                if ((gap + minWidth) * itemsCount - gap > availableWidth) {
                    var itemsInRow = calcAvailableColumnsCount(availableWidth, minWidth, gap);
                    width_1 = Math.floor((availableWidth - gap * (itemsInRow - 1)) / itemsInRow);
                }
                else {
                    width_1 = Math.floor(((availableWidth - gap * (itemsCount - 1)) / itemsCount));
                }
            }
            else {
                var availableColumnsCount = calcAvailableColumnsCount(availableWidth, minWidth, gap);
                if (availableColumnsCount < colCount) {
                    this.responsiveColCount = availableColumnsCount >= 1 ? availableColumnsCount : 1;
                    colCount = this.responsiveColCount;
                }
                else {
                    this.responsiveColCount = colCount;
                }
                width_1 = Math.floor((availableWidth - gap * (colCount - 1)) / colCount);
            }
            width_1 = Math.max(minWidth, Math.min(width_1, maxWidth));
            var height_1 = Number.MIN_VALUE;
            this.choices.forEach(function (item) {
                var tempHeight = width_1 / item["aspectRatio"];
                height_1 = tempHeight > height_1 ? tempHeight : height_1;
            });
            if (height_1 > maxHeight) {
                height_1 = maxHeight;
            }
            else if (height_1 < minHeight) {
                height_1 = minHeight;
            }
            var oldResponsiveImageWidth = this.responsiveImageWidth;
            var oldResponsiveImageHeight = this.responsiveImageHeight;
            this.responsiveImageWidth = width_1;
            this.responsiveImageHeight = height_1;
            return oldResponsiveImageWidth !== this.responsiveImageWidth || oldResponsiveImageHeight !== this.responsiveImageHeight;
        }
        return false;
    };
    QuestionImagePickerModel.prototype.triggerResponsiveness = function (hard) {
        if (hard === void 0) { hard = true; }
        if (hard && this.reCalcGapBetweenItemsCallback) {
            this.reCalcGapBetweenItemsCallback();
        }
        _super.prototype.triggerResponsiveness.call(this, hard);
    };
    QuestionImagePickerModel.prototype.afterRender = function (el) {
        var _this = this;
        _super.prototype.afterRender.call(this, el);
        var selector = this.getObservedElementSelector();
        var observedElement = el && selector ? el.querySelector(selector) : undefined;
        if (!!observedElement) {
            this.reCalcGapBetweenItemsCallback = function () {
                _this.gapBetweenItems = Math.ceil(Number.parseFloat(DomDocumentHelper.getComputedStyle(observedElement).gap)) || 16;
            };
            this.reCalcGapBetweenItemsCallback();
        }
    };
    question_imagepicker_decorate([
        jsonobject_property({})
    ], QuestionImagePickerModel.prototype, "responsiveImageHeight", void 0);
    question_imagepicker_decorate([
        jsonobject_property({})
    ], QuestionImagePickerModel.prototype, "responsiveImageWidth", void 0);
    question_imagepicker_decorate([
        jsonobject_property({})
    ], QuestionImagePickerModel.prototype, "isResponsiveValue", void 0);
    question_imagepicker_decorate([
        jsonobject_property({})
    ], QuestionImagePickerModel.prototype, "maxImageWidth", void 0);
    question_imagepicker_decorate([
        jsonobject_property({})
    ], QuestionImagePickerModel.prototype, "minImageWidth", void 0);
    question_imagepicker_decorate([
        jsonobject_property({})
    ], QuestionImagePickerModel.prototype, "maxImageHeight", void 0);
    question_imagepicker_decorate([
        jsonobject_property({})
    ], QuestionImagePickerModel.prototype, "minImageHeight", void 0);
    question_imagepicker_decorate([
        jsonobject_property({})
    ], QuestionImagePickerModel.prototype, "responsiveColCount", void 0);
    return QuestionImagePickerModel;
}(QuestionCheckboxBase));

Serializer.addClass("imageitemvalue", [{ name: "imageLink:file", serializationProperty: "locImageLink" }], function (value) { return new question_imagepicker_ImageItemValue(value); }, "itemvalue");
Serializer.addClass("responsiveImageSize", [], undefined, "number");
Serializer.addClass("imagepicker", [
    { name: "showOtherItem", visible: false },
    { name: "otherText", visible: false },
    { name: "showNoneItem", visible: false },
    { name: "showRefuseItem", visible: false },
    { name: "showDontKnowItem", visible: false },
    { name: "noneText", visible: false },
    { name: "optionsCaption", visible: false },
    { name: "otherErrorText", visible: false },
    { name: "storeOthersAsComment", visible: false },
    {
        name: "contentMode",
        default: "image",
        choices: ["image", "video"],
    },
    {
        name: "imageFit",
        default: "contain",
        choices: ["none", "contain", "cover", "fill"],
    },
    { name: "imageHeight:number", minValue: 0 },
    { name: "imageWidth:number", minValue: 0 },
    { name: "minImageWidth:responsiveImageSize", default: 200, minValue: 0, visibleIf: function () { return settings.supportCreatorV2; } },
    { name: "minImageHeight:responsiveImageSize", default: 133, minValue: 0, visibleIf: function () { return settings.supportCreatorV2; } },
    { name: "maxImageWidth:responsiveImageSize", default: 400, minValue: 0, visibleIf: function () { return settings.supportCreatorV2; } },
    { name: "maxImageHeight:responsiveImageSize", default: 266, minValue: 0, visibleIf: function () { return settings.supportCreatorV2; } },
], function () {
    return new question_imagepicker_QuestionImagePickerModel("");
}, "checkboxbase");
Serializer.addProperty("imagepicker", {
    name: "showLabel:boolean",
    default: false,
});
Serializer.addProperty("imagepicker", {
    name: "colCount:number",
    default: 0,
    choices: [0, 1, 2, 3, 4, 5],
});
Serializer.addProperty("imagepicker", {
    name: "multiSelect:boolean",
    default: false,
});
Serializer.addProperty("imagepicker", {
    name: "choices:imageitemvalue[]",
});
questionfactory_QuestionFactory.Instance.registerQuestion("imagepicker", function (name) {
    var q = new question_imagepicker_QuestionImagePickerModel(name);
    //q.choices = QuestionFactory.DefaultChoices;
    return q;
});

// CONCATENATED MODULE: ./packages/survey-core/src/question_image.ts
var question_image_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var question_image_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};





var youtubeDomains = ["www.youtube.com", "m.youtube.com", "youtube.com", "youtu.be"];
var videoSuffics = [".mp4", ".mov", ".wmv", ".flv", ".avi", ".mkv"];
var youtubeUrl = "https://www.youtube.com/";
var youtubeEmbed = "embed";
function isUrlYoutubeVideo(url) {
    if (!url)
        return false;
    url = url.toLowerCase();
    url = url.replace(/^https?:\/\//, "");
    for (var i = 0; i < youtubeDomains.length; i++) {
        if (url.indexOf(youtubeDomains[i] + "/") === 0)
            return true;
    }
    return false;
}
/**
  * A class that describes the Image question type. Unlike other question types, Image cannot have a title or value.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/questiontype-image/ (linkStyle))
 */
var question_image_QuestionImageModel = /** @class */ (function (_super) {
    question_image_extends(QuestionImageModel, _super);
    function QuestionImageModel(name) {
        var _this = _super.call(this, name) || this;
        var locImageLink = _this.createLocalizableString("imageLink", _this, false);
        locImageLink.onGetTextCallback = function (text) {
            return getCorrectImageLink(text, _this.contentMode == "youtube");
        };
        _this.createLocalizableString("altText", _this, false);
        _this.registerPropertyChangedHandlers(["contentMode", "imageLink"], function () { return _this.calculateRenderedMode(); });
        return _this;
    }
    QuestionImageModel.prototype.getType = function () {
        return "image";
    };
    Object.defineProperty(QuestionImageModel.prototype, "isCompositeQuestion", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    QuestionImageModel.prototype.onSurveyLoad = function () {
        _super.prototype.onSurveyLoad.call(this);
        this.calculateRenderedMode();
    };
    Object.defineProperty(QuestionImageModel.prototype, "imageLink", {
        /**
         * Specifies an image or video URL.
         * @see contentMode
         */
        get: function () {
            return this.getLocalizableStringText("imageLink");
        },
        set: function (val) {
            this.setLocalizableStringText("imageLink", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImageModel.prototype, "locImageLink", {
        get: function () {
            return this.getLocalizableString("imageLink");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImageModel.prototype, "altText", {
        /**
         * Specifies a value for the `alt` attribute of the underlying `<img>` element.
         */
        get: function () {
            return this.getLocalizableStringText("altText");
        },
        set: function (val) {
            this.setLocalizableStringText("altText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImageModel.prototype, "locAltText", {
        get: function () {
            return this.getLocalizableString("altText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImageModel.prototype, "imageHeight", {
        /**
         * Specifies the height of a container for the image or video. Accepts positive numbers and CSS values.
         *
         * Default value: 150
         *
         * Use the `imageFit` property to specify how to fit the image or video into the container.
         * @see imageWidth
         * @see imageFit
         */
        get: function () {
            return this.getPropertyValue("imageHeight");
        },
        set: function (val) {
            this.setPropertyValue("imageHeight", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImageModel.prototype, "renderedStyleHeight", {
        get: function () {
            return this.imageHeight ? getRenderedStyleSize(this.imageHeight) : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImageModel.prototype, "renderedHeight", {
        get: function () {
            return this.imageHeight ? getRenderedSize(this.imageHeight) : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImageModel.prototype, "imageWidth", {
        /**
         * Specifies the width of a container for the image or video. Accepts positive numbers and CSS values.
         *
         * Default value: 200
         *
         * Use the `imageFit` property to specify how to fit the image or video into the container.
         * @see imageHeight
         * @see imageFit
         */
        get: function () {
            return this.getPropertyValue("imageWidth");
        },
        set: function (val) {
            this.setPropertyValue("imageWidth", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImageModel.prototype, "renderedStyleWidth", {
        get: function () {
            return this.imageWidth ? getRenderedStyleSize(this.imageWidth) : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImageModel.prototype, "renderedWidth", {
        get: function () {
            return this.imageWidth ? getRenderedSize(this.imageWidth) : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImageModel.prototype, "imageFit", {
        /**
         * Specifies how to resize the image or video to fit it into its container.
         *
         * Refer to the [`object-fit`](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) CSS property description for information on accepted values.
         * @see imageHeight
         * @see imageWidth
         */
        get: function () {
            return this.getPropertyValue("imageFit");
        },
        set: function (val) {
            this.setPropertyValue("imageFit", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImageModel.prototype, "contentMode", {
        /**
         * Specifies the type of content that the Image question displays.
         *
         * Possible values:
         *
         * - `"image"` - An image in one of the following formats: JPEG, GIF, PNG, APNG, SVG, BMP, ICO.
         * - `"video"` - A video in one of the following formats: MP4, MOV, WMV, FLV, AVI, MKV.
         * - `"youtube"` - A link to a YouTube video.
         * - `"auto"` (default) - Selects one of the above based on the [`imageLink`](https://surveyjs.io/form-library/documentation/questionimagemodel#imageLink) property.
         */
        get: function () {
            return this.getPropertyValue("contentMode");
        },
        set: function (val) {
            this.setPropertyValue("contentMode", val);
            if (val === "video") {
                this.showLabel = true;
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionImageModel.prototype, "renderedMode", {
        /**
         * Returns the type of content that the Image question displays: `"image"`, `"video"`, or `"youtube"`.
         * @see contentMode
         */
        get: function () {
            return this.getPropertyValue("renderedMode", "image");
        },
        enumerable: false,
        configurable: true
    });
    QuestionImageModel.prototype.getImageCss = function () {
        var imageHeightProperty = this.getPropertyByName("imageHeight");
        var imageWidthProperty = this.getPropertyByName("imageWidth");
        var isDefaultSize = imageHeightProperty.isDefaultValue(this.imageHeight) && imageWidthProperty.isDefaultValue(this.imageWidth);
        return new CssClassBuilder()
            .append(this.cssClasses.image)
            .append(this.cssClasses.adaptive, isDefaultSize)
            .toString();
    };
    QuestionImageModel.prototype.onLoadHandler = function () {
        this.contentNotLoaded = false;
    };
    QuestionImageModel.prototype.onErrorHandler = function () {
        this.contentNotLoaded = true;
    };
    QuestionImageModel.prototype.setRenderedMode = function (val) {
        this.setPropertyValue("renderedMode", val);
    };
    QuestionImageModel.prototype.calculateRenderedMode = function () {
        if (this.contentMode !== "auto") {
            this.setRenderedMode(this.contentMode);
        }
        else {
            if (this.isYoutubeVideo()) {
                this.setRenderedMode("youtube");
            }
            else if (this.isVideo()) {
                this.setRenderedMode("video");
            }
            else {
                this.setRenderedMode("image");
            }
        }
    };
    QuestionImageModel.prototype.isYoutubeVideo = function () {
        return isUrlYoutubeVideo(this.imageLink);
    };
    QuestionImageModel.prototype.isVideo = function () {
        var link = this.imageLink;
        if (!link)
            return false;
        link = link.toLowerCase();
        for (var i = 0; i < videoSuffics.length; i++) {
            if (link.endsWith(videoSuffics[i]))
                return true;
        }
        return false;
    };
    question_image_decorate([
        jsonobject_property({ defaultValue: false })
    ], QuestionImageModel.prototype, "contentNotLoaded", void 0);
    return QuestionImageModel;
}(QuestionNonValue));

function getCorrectImageLink(val, isYouTube) {
    if (!val || !isUrlYoutubeVideo(val))
        return isYouTube ? "" : val;
    //if(!val || !isUrlYoutubeVideo(val)) return val;
    var res = val.toLocaleLowerCase();
    if (res.indexOf(youtubeEmbed) > -1)
        return val;
    var id = "";
    for (var i = val.length - 1; i >= 0; i--) {
        if (val[i] === "=" || val[i] === "/")
            break;
        id = val[i] + id;
    }
    return youtubeUrl + youtubeEmbed + "/" + id;
}
Serializer.addClass("image", [
    { name: "imageLink:file", serializationProperty: "locImageLink" },
    { name: "altText", serializationProperty: "locAltText", alternativeName: "text", category: "general" },
    {
        name: "contentMode",
        default: "auto",
        choices: ["auto", "image", "video", "youtube"],
    },
    {
        name: "imageFit",
        default: "contain",
        choices: ["none", "contain", "cover", "fill"],
    },
    { name: "imageHeight", default: "150" },
    { name: "imageWidth", default: "200" },
], function () {
    return new question_image_QuestionImageModel("");
}, "nonvalue");
questionfactory_QuestionFactory.Instance.registerQuestion("image", function (name) {
    return new question_image_QuestionImageModel(name);
});

// CONCATENATED MODULE: ./node_modules/signature_pad/dist/signature_pad.js
/*!
 * Signature Pad v4.2.0 | https://github.com/szimek/signature_pad
 * (c) 2024 Szymon Nowak | Released under the MIT license
 */

class Point {
    constructor(x, y, pressure, time) {
        if (isNaN(x) || isNaN(y)) {
            throw new Error(`Point is invalid: (${x}, ${y})`);
        }
        this.x = +x;
        this.y = +y;
        this.pressure = pressure || 0;
        this.time = time || Date.now();
    }
    distanceTo(start) {
        return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
    }
    equals(other) {
        return (this.x === other.x &&
            this.y === other.y &&
            this.pressure === other.pressure &&
            this.time === other.time);
    }
    velocityFrom(start) {
        return this.time !== start.time
            ? this.distanceTo(start) / (this.time - start.time)
            : 0;
    }
}

class Bezier {
    static fromPoints(points, widths) {
        const c2 = this.calculateControlPoints(points[0], points[1], points[2]).c2;
        const c3 = this.calculateControlPoints(points[1], points[2], points[3]).c1;
        return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
    }
    static calculateControlPoints(s1, s2, s3) {
        const dx1 = s1.x - s2.x;
        const dy1 = s1.y - s2.y;
        const dx2 = s2.x - s3.x;
        const dy2 = s2.y - s3.y;
        const m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
        const m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
        const l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
        const l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
        const dxm = m1.x - m2.x;
        const dym = m1.y - m2.y;
        const k = l2 / (l1 + l2);
        const cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
        const tx = s2.x - cm.x;
        const ty = s2.y - cm.y;
        return {
            c1: new Point(m1.x + tx, m1.y + ty),
            c2: new Point(m2.x + tx, m2.y + ty),
        };
    }
    constructor(startPoint, control2, control1, endPoint, startWidth, endWidth) {
        this.startPoint = startPoint;
        this.control2 = control2;
        this.control1 = control1;
        this.endPoint = endPoint;
        this.startWidth = startWidth;
        this.endWidth = endWidth;
    }
    length() {
        const steps = 10;
        let length = 0;
        let px;
        let py;
        for (let i = 0; i <= steps; i += 1) {
            const t = i / steps;
            const cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
            const cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
            if (i > 0) {
                const xdiff = cx - px;
                const ydiff = cy - py;
                length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
            }
            px = cx;
            py = cy;
        }
        return length;
    }
    point(t, start, c1, c2, end) {
        return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
            + (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
            + (3.0 * c2 * (1.0 - t) * t * t)
            + (end * t * t * t);
    }
}

class SignatureEventTarget {
    constructor() {
        try {
            this._et = new EventTarget();
        }
        catch (error) {
            this._et = document;
        }
    }
    addEventListener(type, listener, options) {
        this._et.addEventListener(type, listener, options);
    }
    dispatchEvent(event) {
        return this._et.dispatchEvent(event);
    }
    removeEventListener(type, callback, options) {
        this._et.removeEventListener(type, callback, options);
    }
}

function throttle(fn, wait = 250) {
    let previous = 0;
    let timeout = null;
    let result;
    let storedContext;
    let storedArgs;
    const later = () => {
        previous = Date.now();
        timeout = null;
        result = fn.apply(storedContext, storedArgs);
        if (!timeout) {
            storedContext = null;
            storedArgs = [];
        }
    };
    return function wrapper(...args) {
        const now = Date.now();
        const remaining = wait - (now - previous);
        storedContext = this;
        storedArgs = args;
        if (remaining <= 0 || remaining > wait) {
            if (timeout) {
                clearTimeout(timeout);
                timeout = null;
            }
            previous = now;
            result = fn.apply(storedContext, storedArgs);
            if (!timeout) {
                storedContext = null;
                storedArgs = [];
            }
        }
        else if (!timeout) {
            timeout = window.setTimeout(later, remaining);
        }
        return result;
    };
}

class SignaturePad extends SignatureEventTarget {
    constructor(canvas, options = {}) {
        super();
        this.canvas = canvas;
        this._drawingStroke = false;
        this._isEmpty = true;
        this._lastPoints = [];
        this._data = [];
        this._lastVelocity = 0;
        this._lastWidth = 0;
        this._handleMouseDown = (event) => {
            if (event.buttons === 1) {
                this._strokeBegin(event);
            }
        };
        this._handleMouseMove = (event) => {
            this._strokeMoveUpdate(event);
        };
        this._handleMouseUp = (event) => {
            if (event.buttons === 1) {
                this._strokeEnd(event);
            }
        };
        this._handleTouchStart = (event) => {
            if (event.cancelable) {
                event.preventDefault();
            }
            if (event.targetTouches.length === 1) {
                const touch = event.changedTouches[0];
                this._strokeBegin(touch);
            }
        };
        this._handleTouchMove = (event) => {
            if (event.cancelable) {
                event.preventDefault();
            }
            const touch = event.targetTouches[0];
            this._strokeMoveUpdate(touch);
        };
        this._handleTouchEnd = (event) => {
            const wasCanvasTouched = event.target === this.canvas;
            if (wasCanvasTouched) {
                if (event.cancelable) {
                    event.preventDefault();
                }
                const touch = event.changedTouches[0];
                this._strokeEnd(touch);
            }
        };
        this._handlePointerStart = (event) => {
            event.preventDefault();
            this._strokeBegin(event);
        };
        this._handlePointerMove = (event) => {
            this._strokeMoveUpdate(event);
        };
        this._handlePointerEnd = (event) => {
            if (this._drawingStroke) {
                event.preventDefault();
                this._strokeEnd(event);
            }
        };
        this.velocityFilterWeight = options.velocityFilterWeight || 0.7;
        this.minWidth = options.minWidth || 0.5;
        this.maxWidth = options.maxWidth || 2.5;
        this.throttle = ('throttle' in options ? options.throttle : 16);
        this.minDistance = ('minDistance' in options ? options.minDistance : 5);
        this.dotSize = options.dotSize || 0;
        this.penColor = options.penColor || 'black';
        this.backgroundColor = options.backgroundColor || 'rgba(0,0,0,0)';
        this.compositeOperation = options.compositeOperation || 'source-over';
        this.canvasContextOptions = ('canvasContextOptions' in options ? options.canvasContextOptions : {});
        this._strokeMoveUpdate = this.throttle
            ? throttle(SignaturePad.prototype._strokeUpdate, this.throttle)
            : SignaturePad.prototype._strokeUpdate;
        this._ctx = canvas.getContext('2d', this.canvasContextOptions);
        this.clear();
        this.on();
    }
    clear() {
        const { _ctx: ctx, canvas } = this;
        ctx.fillStyle = this.backgroundColor;
        ctx.clearRect(0, 0, canvas.width, canvas.height);
        ctx.fillRect(0, 0, canvas.width, canvas.height);
        this._data = [];
        this._reset(this._getPointGroupOptions());
        this._isEmpty = true;
    }
    fromDataURL(dataUrl, options = {}) {
        return new Promise((resolve, reject) => {
            const image = new Image();
            const ratio = options.ratio || window.devicePixelRatio || 1;
            const width = options.width || this.canvas.width / ratio;
            const height = options.height || this.canvas.height / ratio;
            const xOffset = options.xOffset || 0;
            const yOffset = options.yOffset || 0;
            this._reset(this._getPointGroupOptions());
            image.onload = () => {
                this._ctx.drawImage(image, xOffset, yOffset, width, height);
                resolve();
            };
            image.onerror = (error) => {
                reject(error);
            };
            image.crossOrigin = 'anonymous';
            image.src = dataUrl;
            this._isEmpty = false;
        });
    }
    toDataURL(type = 'image/png', encoderOptions) {
        switch (type) {
            case 'image/svg+xml':
                if (typeof encoderOptions !== 'object') {
                    encoderOptions = undefined;
                }
                return `data:image/svg+xml;base64,${btoa(this.toSVG(encoderOptions))}`;
            default:
                if (typeof encoderOptions !== 'number') {
                    encoderOptions = undefined;
                }
                return this.canvas.toDataURL(type, encoderOptions);
        }
    }
    on() {
        this.canvas.style.touchAction = 'none';
        this.canvas.style.msTouchAction = 'none';
        this.canvas.style.userSelect = 'none';
        const isIOS = /Macintosh/.test(navigator.userAgent) && 'ontouchstart' in document;
        if (window.PointerEvent && !isIOS) {
            this._handlePointerEvents();
        }
        else {
            this._handleMouseEvents();
            if ('ontouchstart' in window) {
                this._handleTouchEvents();
            }
        }
    }
    off() {
        this.canvas.style.touchAction = 'auto';
        this.canvas.style.msTouchAction = 'auto';
        this.canvas.style.userSelect = 'auto';
        this.canvas.removeEventListener('pointerdown', this._handlePointerStart);
        this.canvas.removeEventListener('pointermove', this._handlePointerMove);
        this.canvas.ownerDocument.removeEventListener('pointerup', this._handlePointerEnd);
        this.canvas.removeEventListener('mousedown', this._handleMouseDown);
        this.canvas.removeEventListener('mousemove', this._handleMouseMove);
        this.canvas.ownerDocument.removeEventListener('mouseup', this._handleMouseUp);
        this.canvas.removeEventListener('touchstart', this._handleTouchStart);
        this.canvas.removeEventListener('touchmove', this._handleTouchMove);
        this.canvas.removeEventListener('touchend', this._handleTouchEnd);
    }
    isEmpty() {
        return this._isEmpty;
    }
    fromData(pointGroups, { clear = true } = {}) {
        if (clear) {
            this.clear();
        }
        this._fromData(pointGroups, this._drawCurve.bind(this), this._drawDot.bind(this));
        this._data = this._data.concat(pointGroups);
    }
    toData() {
        return this._data;
    }
    _getPointGroupOptions(group) {
        return {
            penColor: group && 'penColor' in group ? group.penColor : this.penColor,
            dotSize: group && 'dotSize' in group ? group.dotSize : this.dotSize,
            minWidth: group && 'minWidth' in group ? group.minWidth : this.minWidth,
            maxWidth: group && 'maxWidth' in group ? group.maxWidth : this.maxWidth,
            velocityFilterWeight: group && 'velocityFilterWeight' in group
                ? group.velocityFilterWeight
                : this.velocityFilterWeight,
            compositeOperation: group && 'compositeOperation' in group
                ? group.compositeOperation
                : this.compositeOperation,
        };
    }
    _strokeBegin(event) {
        const cancelled = !this.dispatchEvent(new CustomEvent('beginStroke', { detail: event, cancelable: true }));
        if (cancelled) {
            return;
        }
        this._drawingStroke = true;
        const pointGroupOptions = this._getPointGroupOptions();
        const newPointGroup = Object.assign(Object.assign({}, pointGroupOptions), { points: [] });
        this._data.push(newPointGroup);
        this._reset(pointGroupOptions);
        this._strokeUpdate(event);
    }
    _strokeUpdate(event) {
        if (!this._drawingStroke) {
            return;
        }
        if (this._data.length === 0) {
            this._strokeBegin(event);
            return;
        }
        this.dispatchEvent(new CustomEvent('beforeUpdateStroke', { detail: event }));
        const x = event.clientX;
        const y = event.clientY;
        const pressure = event.pressure !== undefined
            ? event.pressure
            : event.force !== undefined
                ? event.force
                : 0;
        const point = this._createPoint(x, y, pressure);
        const lastPointGroup = this._data[this._data.length - 1];
        const lastPoints = lastPointGroup.points;
        const lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
        const isLastPointTooClose = lastPoint
            ? point.distanceTo(lastPoint) <= this.minDistance
            : false;
        const pointGroupOptions = this._getPointGroupOptions(lastPointGroup);
        if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
            const curve = this._addPoint(point, pointGroupOptions);
            if (!lastPoint) {
                this._drawDot(point, pointGroupOptions);
            }
            else if (curve) {
                this._drawCurve(curve, pointGroupOptions);
            }
            lastPoints.push({
                time: point.time,
                x: point.x,
                y: point.y,
                pressure: point.pressure,
            });
        }
        this.dispatchEvent(new CustomEvent('afterUpdateStroke', { detail: event }));
    }
    _strokeEnd(event) {
        if (!this._drawingStroke) {
            return;
        }
        this._strokeUpdate(event);
        this._drawingStroke = false;
        this.dispatchEvent(new CustomEvent('endStroke', { detail: event }));
    }
    _handlePointerEvents() {
        this._drawingStroke = false;
        this.canvas.addEventListener('pointerdown', this._handlePointerStart);
        this.canvas.addEventListener('pointermove', this._handlePointerMove);
        this.canvas.ownerDocument.addEventListener('pointerup', this._handlePointerEnd);
    }
    _handleMouseEvents() {
        this._drawingStroke = false;
        this.canvas.addEventListener('mousedown', this._handleMouseDown);
        this.canvas.addEventListener('mousemove', this._handleMouseMove);
        this.canvas.ownerDocument.addEventListener('mouseup', this._handleMouseUp);
    }
    _handleTouchEvents() {
        this.canvas.addEventListener('touchstart', this._handleTouchStart);
        this.canvas.addEventListener('touchmove', this._handleTouchMove);
        this.canvas.addEventListener('touchend', this._handleTouchEnd);
    }
    _reset(options) {
        this._lastPoints = [];
        this._lastVelocity = 0;
        this._lastWidth = (options.minWidth + options.maxWidth) / 2;
        this._ctx.fillStyle = options.penColor;
        this._ctx.globalCompositeOperation = options.compositeOperation;
    }
    _createPoint(x, y, pressure) {
        const rect = this.canvas.getBoundingClientRect();
        return new Point(x - rect.left, y - rect.top, pressure, new Date().getTime());
    }
    _addPoint(point, options) {
        const { _lastPoints } = this;
        _lastPoints.push(point);
        if (_lastPoints.length > 2) {
            if (_lastPoints.length === 3) {
                _lastPoints.unshift(_lastPoints[0]);
            }
            const widths = this._calculateCurveWidths(_lastPoints[1], _lastPoints[2], options);
            const curve = Bezier.fromPoints(_lastPoints, widths);
            _lastPoints.shift();
            return curve;
        }
        return null;
    }
    _calculateCurveWidths(startPoint, endPoint, options) {
        const velocity = options.velocityFilterWeight * endPoint.velocityFrom(startPoint) +
            (1 - options.velocityFilterWeight) * this._lastVelocity;
        const newWidth = this._strokeWidth(velocity, options);
        const widths = {
            end: newWidth,
            start: this._lastWidth,
        };
        this._lastVelocity = velocity;
        this._lastWidth = newWidth;
        return widths;
    }
    _strokeWidth(velocity, options) {
        return Math.max(options.maxWidth / (velocity + 1), options.minWidth);
    }
    _drawCurveSegment(x, y, width) {
        const ctx = this._ctx;
        ctx.moveTo(x, y);
        ctx.arc(x, y, width, 0, 2 * Math.PI, false);
        this._isEmpty = false;
    }
    _drawCurve(curve, options) {
        const ctx = this._ctx;
        const widthDelta = curve.endWidth - curve.startWidth;
        const drawSteps = Math.ceil(curve.length()) * 2;
        ctx.beginPath();
        ctx.fillStyle = options.penColor;
        for (let i = 0; i < drawSteps; i += 1) {
            const t = i / drawSteps;
            const tt = t * t;
            const ttt = tt * t;
            const u = 1 - t;
            const uu = u * u;
            const uuu = uu * u;
            let x = uuu * curve.startPoint.x;
            x += 3 * uu * t * curve.control1.x;
            x += 3 * u * tt * curve.control2.x;
            x += ttt * curve.endPoint.x;
            let y = uuu * curve.startPoint.y;
            y += 3 * uu * t * curve.control1.y;
            y += 3 * u * tt * curve.control2.y;
            y += ttt * curve.endPoint.y;
            const width = Math.min(curve.startWidth + ttt * widthDelta, options.maxWidth);
            this._drawCurveSegment(x, y, width);
        }
        ctx.closePath();
        ctx.fill();
    }
    _drawDot(point, options) {
        const ctx = this._ctx;
        const width = options.dotSize > 0
            ? options.dotSize
            : (options.minWidth + options.maxWidth) / 2;
        ctx.beginPath();
        this._drawCurveSegment(point.x, point.y, width);
        ctx.closePath();
        ctx.fillStyle = options.penColor;
        ctx.fill();
    }
    _fromData(pointGroups, drawCurve, drawDot) {
        for (const group of pointGroups) {
            const { points } = group;
            const pointGroupOptions = this._getPointGroupOptions(group);
            if (points.length > 1) {
                for (let j = 0; j < points.length; j += 1) {
                    const basicPoint = points[j];
                    const point = new Point(basicPoint.x, basicPoint.y, basicPoint.pressure, basicPoint.time);
                    if (j === 0) {
                        this._reset(pointGroupOptions);
                    }
                    const curve = this._addPoint(point, pointGroupOptions);
                    if (curve) {
                        drawCurve(curve, pointGroupOptions);
                    }
                }
            }
            else {
                this._reset(pointGroupOptions);
                drawDot(points[0], pointGroupOptions);
            }
        }
    }
    toSVG({ includeBackgroundColor = false } = {}) {
        const pointGroups = this._data;
        const ratio = Math.max(window.devicePixelRatio || 1, 1);
        const minX = 0;
        const minY = 0;
        const maxX = this.canvas.width / ratio;
        const maxY = this.canvas.height / ratio;
        const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
        svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
        svg.setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
        svg.setAttribute('viewBox', `${minX} ${minY} ${maxX} ${maxY}`);
        svg.setAttribute('width', maxX.toString());
        svg.setAttribute('height', maxY.toString());
        if (includeBackgroundColor && this.backgroundColor) {
            const rect = document.createElement('rect');
            rect.setAttribute('width', '100%');
            rect.setAttribute('height', '100%');
            rect.setAttribute('fill', this.backgroundColor);
            svg.appendChild(rect);
        }
        this._fromData(pointGroups, (curve, { penColor }) => {
            const path = document.createElement('path');
            if (!isNaN(curve.control1.x) &&
                !isNaN(curve.control1.y) &&
                !isNaN(curve.control2.x) &&
                !isNaN(curve.control2.y)) {
                const attr = `M ${curve.startPoint.x.toFixed(3)},${curve.startPoint.y.toFixed(3)} ` +
                    `C ${curve.control1.x.toFixed(3)},${curve.control1.y.toFixed(3)} ` +
                    `${curve.control2.x.toFixed(3)},${curve.control2.y.toFixed(3)} ` +
                    `${curve.endPoint.x.toFixed(3)},${curve.endPoint.y.toFixed(3)}`;
                path.setAttribute('d', attr);
                path.setAttribute('stroke-width', (curve.endWidth * 2.25).toFixed(3));
                path.setAttribute('stroke', penColor);
                path.setAttribute('fill', 'none');
                path.setAttribute('stroke-linecap', 'round');
                svg.appendChild(path);
            }
        }, (point, { penColor, dotSize, minWidth, maxWidth }) => {
            const circle = document.createElement('circle');
            const size = dotSize > 0 ? dotSize : (minWidth + maxWidth) / 2;
            circle.setAttribute('r', size.toString());
            circle.setAttribute('cx', point.x.toString());
            circle.setAttribute('cy', point.y.toString());
            circle.setAttribute('fill', penColor);
            svg.appendChild(circle);
        });
        return svg.outerHTML;
    }
}


//# sourceMappingURL=signature_pad.js.map

// CONCATENATED MODULE: ./packages/survey-core/src/question_signaturepad.ts
var question_signaturepad_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var question_signaturepad_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};






var defaultWidth = 300;
var defaultHeight = 200;
/**
 * A class that describes the Signature question type.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/signature-pad-widget-javascript/ (linkStyle))
 */
var question_signaturepad_QuestionSignaturePadModel = /** @class */ (function (_super) {
    question_signaturepad_extends(QuestionSignaturePadModel, _super);
    function QuestionSignaturePadModel(name) {
        var _this = _super.call(this, name) || this;
        _this.valueIsUpdatingInternally = false;
        _this.updateValueHandler = function () {
            _this.scaleCanvas(false, true);
            _this.refreshCanvas();
        };
        return _this;
    }
    QuestionSignaturePadModel.prototype.getPenColorFromTheme = function () {
        var _survey = this.survey;
        return !!_survey && !!_survey.themeVariables && _survey.themeVariables["--sjs-primary-backcolor"];
    };
    QuestionSignaturePadModel.prototype.updateColors = function (signaturePad) {
        var penColorFromTheme = this.getPenColorFromTheme();
        var penColorProperty = this.getPropertyByName("penColor");
        signaturePad.penColor = this.penColor || penColorFromTheme || penColorProperty.defaultValue || "#1ab394";
        var backgroundColorProperty = this.getPropertyByName("backgroundColor");
        var backgroundColorFromTheme = penColorFromTheme ? "transparent" : undefined;
        var background = !!this.backgroundImage ? "transparent" : this.backgroundColor;
        signaturePad.backgroundColor = background || backgroundColorFromTheme || backgroundColorProperty.defaultValue || "#ffffff";
    };
    QuestionSignaturePadModel.prototype.getCssRoot = function (cssClasses) {
        return new CssClassBuilder()
            .append(_super.prototype.getCssRoot.call(this, cssClasses))
            .append(cssClasses.small, this.signatureWidth.toString() === "300")
            .toString();
    };
    QuestionSignaturePadModel.prototype.getFormat = function () {
        return this.dataFormat === "jpeg" ? "image/jpeg" :
            (this.dataFormat === "svg" ? "image/svg+xml" : "");
    };
    QuestionSignaturePadModel.prototype.updateValue = function () {
        if (this.signaturePad) {
            var data = this.signaturePad.toDataURL(this.getFormat());
            this.valueIsUpdatingInternally = true;
            this.value = data;
            this.valueIsUpdatingInternally = false;
        }
    };
    QuestionSignaturePadModel.prototype.getType = function () {
        return "signaturepad";
    };
    QuestionSignaturePadModel.prototype.afterRenderQuestionElement = function (el) {
        if (!!el) {
            this.initSignaturePad(el);
            this.element = el;
        }
        _super.prototype.afterRenderQuestionElement.call(this, el);
    };
    QuestionSignaturePadModel.prototype.beforeDestroyQuestionElement = function (el) {
        if (!!el) {
            this.destroySignaturePad(el);
        }
    };
    QuestionSignaturePadModel.prototype.themeChanged = function (theme) {
        if (!!this.signaturePad) {
            this.updateColors(this.signaturePad);
        }
    };
    QuestionSignaturePadModel.prototype.resizeCanvas = function () {
        this.canvas.width = this.containerWidth;
        this.canvas.height = this.containerHeight;
    };
    QuestionSignaturePadModel.prototype.scaleCanvas = function (refresh, resize) {
        if (refresh === void 0) { refresh = true; }
        if (resize === void 0) { resize = false; }
        var canvas = this.canvas;
        var scale = canvas.offsetWidth / this.containerWidth;
        if (this.scale != scale || resize) {
            this.scale = scale;
            canvas.style.width = this.renderedCanvasWidth;
            this.resizeCanvas();
            this.signaturePad.minWidth = this.penMinWidth * scale;
            this.signaturePad.maxWidth = this.penMaxWidth * scale;
            canvas.getContext("2d").scale(1 / scale, 1 / scale);
            if (refresh)
                this.refreshCanvas();
        }
    };
    QuestionSignaturePadModel.prototype.fromDataUrl = function (data) {
        this.signaturePad.fromDataURL(data, { width: this.canvas.width * this.scale, height: this.canvas.height * this.scale });
    };
    QuestionSignaturePadModel.prototype.fromUrl = function (url) {
        var _this = this;
        var img = new Image();
        img.crossOrigin = "anonymous";
        img.src = url;
        img.onload = function () {
            var ctx = _this.canvas.getContext("2d");
            ctx.drawImage(img, 0, 0);
            var dataURL = _this.canvas.toDataURL(_this.getFormat());
            _this.fromDataUrl(dataURL);
        };
    };
    QuestionSignaturePadModel.prototype.refreshCanvas = function () {
        if (!this.canvas)
            return;
        if (!this.value) {
            this.canvas.getContext("2d").clearRect(0, 0, this.canvas.width * this.scale, this.canvas.height * this.scale);
            this.signaturePad.clear();
            this.valueWasChangedFromLastUpload = false;
        }
        else {
            if (this.storeDataAsText) {
                this.fromDataUrl(this.value);
            }
            else {
                this.fromUrl(this.value);
            }
        }
    };
    QuestionSignaturePadModel.prototype.loadPreview = function (newValue) {
        var _this = this;
        if (!this.storeDataAsText) {
            var newValues = !!newValue ? [newValue] : [];
            if (!!this._previewLoader) {
                this._previewLoader.dispose();
            }
            this.isFileLoading = true;
            this._previewLoader = new FileLoader(this, function (status, loaded) {
                _this.isFileLoading = false;
                if (loaded && loaded.length > 0 && loaded[0].content && status === "success")
                    _this.fromDataUrl(loaded[0].content);
                _this._previewLoader.dispose();
                _this._previewLoader = undefined;
            });
            this._previewLoader.load(newValues);
        }
    };
    QuestionSignaturePadModel.prototype.onSurveyLoad = function () {
        _super.prototype.onSurveyLoad.call(this);
        this.loadPreview(this.value);
    };
    QuestionSignaturePadModel.prototype.initSignaturePad = function (el) {
        var _this = this;
        var canvas = el.getElementsByTagName("canvas")[0];
        this.canvas = canvas;
        this.resizeCanvas();
        var signaturePad = new SignaturePad(canvas, { backgroundColor: "#ffffff" });
        this.signaturePad = signaturePad;
        if (this.isInputReadOnly) {
            signaturePad.off();
        }
        this.readOnlyChangedCallback = function () {
            if (_this.isInputReadOnly) {
                signaturePad.off();
            }
            else {
                signaturePad.on();
            }
        };
        this.updateColors(signaturePad);
        signaturePad.addEventListener("beginStroke", function () {
            _this.scaleCanvas();
            _this.isDrawingValue = true;
            canvas.focus();
        }, { once: false });
        signaturePad.addEventListener("endStroke", function () {
            _this.isDrawingValue = false;
            if (_this.storeDataAsText) {
                _this.updateValue();
            }
            else {
                _this.valueWasChangedFromLastUpload = true;
            }
        }, { once: false });
        this.updateValueHandler();
        this.readOnlyChangedCallback();
        var propertyChangedHandler = function (sender, options) {
            if (options.name === "signatureWidth" || options.name === "signatureHeight" || options.name === "value") {
                if (!_this.valueIsUpdatingInternally)
                    _this.updateValueHandler();
            }
        };
        this.onPropertyChanged.add(propertyChangedHandler);
        this.signaturePad.propertyChangedHandler = propertyChangedHandler;
    };
    QuestionSignaturePadModel.prototype.destroySignaturePad = function (el) {
        if (this.signaturePad) {
            this.onPropertyChanged.remove(this.signaturePad.propertyChangedHandler);
            this.signaturePad.off();
        }
        this.readOnlyChangedCallback = null;
        this.signaturePad = null;
    };
    Object.defineProperty(QuestionSignaturePadModel.prototype, "dataFormat", {
        /**
         * Specifies the format in which to store the signature image.
         *
         * Possible values:
         *
         * - `"png"` (default)
         * - `"jpeg"`
         * - `"svg"`
         */
        get: function () {
            return this.getPropertyValue("dataFormat");
        },
        set: function (val) {
            this.setPropertyValue("dataFormat", correctFormatData(val));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSignaturePadModel.prototype, "signatureWidth", {
        /**
         * Specifies the width of the signature area. Accepts positive integer numbers.
         */
        get: function () {
            return this.getPropertyValue("signatureWidth");
        },
        set: function (val) {
            this.setPropertyValue("signatureWidth", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSignaturePadModel.prototype, "signatureHeight", {
        /**
         * Specifies the height of the signature area. Accepts positive integer numbers.
         */
        get: function () {
            return this.getPropertyValue("signatureHeight");
        },
        set: function (val) {
            this.setPropertyValue("signatureHeight", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSignaturePadModel.prototype, "containerHeight", {
        get: function () {
            return this.signatureHeight || defaultHeight;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSignaturePadModel.prototype, "containerWidth", {
        get: function () {
            return this.signatureWidth || defaultWidth;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSignaturePadModel.prototype, "renderedCanvasWidth", {
        get: function () {
            return this.signatureAutoScaleEnabled ? "100%" : this.containerWidth + "px";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSignaturePadModel.prototype, "height", {
        //todo: need to remove this property
        get: function () {
            return this.getPropertyValue("height");
        },
        set: function (val) {
            this.setPropertyValue("height", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSignaturePadModel.prototype, "allowClear", {
        /**
         * Specifies whether to display a button that clears the signature area.
         *
         * Default value: `true`
         */
        get: function () {
            return this.getPropertyValue("allowClear");
        },
        set: function (val) {
            this.setPropertyValue("allowClear", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSignaturePadModel.prototype, "canShowClearButton", {
        get: function () {
            var hasSignature = !this.nothingIsDrawn();
            var isUploading = this.isUploading;
            return !this.isInputReadOnly && this.allowClear && hasSignature && !isUploading;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSignaturePadModel.prototype, "penColor", {
        /**
         * Specifies a color for the pen.
         *
         * This property accepts color values in the following formats:
         *
         * - Hexadecimal colors (`"#FF0000"`)
         * - RGB colors (`"rgb(255,0,0)"`)
         * - Color names (`"red"`)
         * @see backgroundColor
         */
        get: function () {
            return this.getPropertyValue("penColor");
        },
        set: function (val) {
            this.setPropertyValue("penColor", val);
            !!this.signaturePad && this.updateColors(this.signaturePad);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSignaturePadModel.prototype, "backgroundColor", {
        /**
         * Specifies a color for the signature area background. Ignored if [`backgroundImage`](#backgroundImage) is set.
         *
         * This property accepts color values in the following formats:
         *
         * - Hexadecimal colors (`"#FF0000"`)
         * - RGB colors (`"rgb(255,0,0)"`)
         * - Color names (`"red"`)
         * @see penColor
         */
        get: function () {
            return this.getPropertyValue("backgroundColor");
        },
        set: function (val) {
            this.setPropertyValue("backgroundColor", val);
            !!this.signaturePad && this.updateColors(this.signaturePad);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSignaturePadModel.prototype, "backgroundImage", {
        /**
         * An image to display in the background of the signature area. Accepts a base64 or URL string value.
         * @see backgroundColor
         */
        get: function () {
            return this.getPropertyValue("backgroundImage");
        },
        set: function (val) {
            this.setPropertyValue("backgroundImage", val);
            !!this.signaturePad && this.updateColors(this.signaturePad);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSignaturePadModel.prototype, "clearButtonCaption", {
        get: function () {
            return this.getLocalizationString("clearCaption");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionSignaturePadModel.prototype, "locRenderedPlaceholder", {
        get: function () {
            return this.isReadOnly ? this.locPlaceholderReadOnly : this.locPlaceholder;
        },
        enumerable: false,
        configurable: true
    });
    QuestionSignaturePadModel.prototype.nothingIsDrawn = function () {
        var isDrawing = this.isDrawingValue;
        var isEmpty = this.isEmpty();
        var isUploading = this.isUploading;
        var valueWasChangedFromLastUpload = this.valueWasChangedFromLastUpload;
        return !isDrawing && isEmpty && !isUploading && !valueWasChangedFromLastUpload;
    };
    QuestionSignaturePadModel.prototype.needShowPlaceholder = function () {
        return this.showPlaceholder && this.nothingIsDrawn();
    };
    QuestionSignaturePadModel.prototype.onBlurCore = function (event) {
        _super.prototype.onBlurCore.call(this, event);
        if (!this.storeDataAsText) {
            if (!this.element.contains(event.relatedTarget)) {
                if (!this.valueWasChangedFromLastUpload)
                    return;
                this.uploadFiles([dataUrl2File(this.signaturePad.toDataURL(this.getFormat()), this.name + "." + correctFormatData(this.dataFormat), this.getFormat())]);
                this.valueWasChangedFromLastUpload = false;
            }
        }
    };
    QuestionSignaturePadModel.prototype.uploadResultItemToValue = function (r) {
        return r.content;
    };
    QuestionSignaturePadModel.prototype.setValueFromResult = function (arg) {
        this.valueIsUpdatingInternally = true;
        this.value = (arg === null || arg === void 0 ? void 0 : arg.length) ? arg.map(function (r) { return r.content; })[0] : undefined;
        this.valueIsUpdatingInternally = false;
    };
    QuestionSignaturePadModel.prototype.clearValue = function (keepComment) {
        this.valueWasChangedFromLastUpload = false;
        _super.prototype.clearValue.call(this, keepComment);
        this.refreshCanvas();
    };
    QuestionSignaturePadModel.prototype.endLoadingFromJson = function () {
        _super.prototype.endLoadingFromJson.call(this);
        //todo: need to remove this code
        if (this.signatureWidth === 300 && !!this.width && typeof this.width === "number" && this.width) {
            ConsoleWarnings.warn("Use signatureWidth property to set width for the signature pad");
            this.signatureWidth = this.width;
            this.width = undefined;
        }
        if (this.signatureHeight === 200 && !!this.height) {
            ConsoleWarnings.warn("Use signatureHeight property to set width for the signature pad");
            this.signatureHeight = this.height;
            this.height = undefined;
        }
    };
    question_signaturepad_decorate([
        jsonobject_property({ defaultValue: false })
    ], QuestionSignaturePadModel.prototype, "isDrawingValue", void 0);
    question_signaturepad_decorate([
        jsonobject_property({ defaultValue: false })
    ], QuestionSignaturePadModel.prototype, "isReadyForUpload", void 0);
    question_signaturepad_decorate([
        jsonobject_property({ defaultValue: false })
    ], QuestionSignaturePadModel.prototype, "valueWasChangedFromLastUpload", void 0);
    question_signaturepad_decorate([
        jsonobject_property()
    ], QuestionSignaturePadModel.prototype, "signatureAutoScaleEnabled", void 0);
    question_signaturepad_decorate([
        jsonobject_property()
    ], QuestionSignaturePadModel.prototype, "penMinWidth", void 0);
    question_signaturepad_decorate([
        jsonobject_property()
    ], QuestionSignaturePadModel.prototype, "penMaxWidth", void 0);
    question_signaturepad_decorate([
        jsonobject_property({})
    ], QuestionSignaturePadModel.prototype, "showPlaceholder", void 0);
    question_signaturepad_decorate([
        jsonobject_property({ localizable: { defaultStr: "signaturePlaceHolder" } })
    ], QuestionSignaturePadModel.prototype, "placeholder", void 0);
    question_signaturepad_decorate([
        jsonobject_property({ localizable: { defaultStr: "signaturePlaceHolderReadOnly" } })
    ], QuestionSignaturePadModel.prototype, "placeholderReadOnly", void 0);
    return QuestionSignaturePadModel;
}(question_file_QuestionFileModelBase));

function correctFormatData(val) {
    if (!val)
        val = "png";
    val = val.replace("image/", "").replace("+xml", "");
    if (val !== "jpeg" && val !== "svg")
        val = "png";
    return val;
}
Serializer.addClass("signaturepad", [
    {
        name: "signatureWidth:number",
        category: "general",
        default: 300,
    },
    {
        name: "signatureHeight:number",
        category: "general",
        default: 200,
    },
    {
        name: "signatureAutoScaleEnabled:boolean",
        category: "general",
        default: false,
    },
    {
        name: "penMinWidth:number",
        category: "general",
        default: 0.5,
    },
    {
        name: "penMaxWidth:number",
        category: "general",
        default: 2.5,
    },
    //need to remove this property
    {
        name: "height:number",
        category: "general",
        visible: false
    },
    {
        name: "allowClear:boolean",
        category: "general",
        default: true,
    },
    { name: "showPlaceholder:boolean", category: "general", default: true },
    {
        name: "placeholder:text",
        serializationProperty: "locPlaceholder",
        category: "general",
        dependsOn: "showPlaceholder",
        visibleIf: function (obj) { return obj.showPlaceholder; }
    },
    {
        name: "placeholderReadOnly:text",
        serializationProperty: "locPlaceholderReadOnly",
        category: "general",
        dependsOn: "showPlaceholder",
        visibleIf: function (obj) { return obj.showPlaceholder; }
    },
    {
        name: "backgroundImage:file",
        category: "general",
    },
    {
        name: "penColor:color",
        category: "general",
    },
    {
        name: "backgroundColor:color",
        category: "general",
    },
    {
        name: "dataFormat",
        category: "general",
        default: "png",
        choices: [
            { value: "png", text: "PNG" },
            { value: "image/jpeg", text: "JPEG" },
            { value: "image/svg+xml", text: "SVG" },
        ],
        onSettingValue: function (obj, val) {
            return correctFormatData(val);
        }
    },
    { name: "defaultValue", visible: false },
    { name: "correctAnswer", visible: false },
    { name: "storeDataAsText:boolean", default: true },
    { name: "waitForUpload:boolean", default: false },
], function () {
    return new question_signaturepad_QuestionSignaturePadModel("");
}, "question");
questionfactory_QuestionFactory.Instance.registerQuestion("signaturepad", function (name) {
    return new question_signaturepad_QuestionSignaturePadModel(name);
});

// CONCATENATED MODULE: ./packages/survey-core/src/question_paneldynamic.ts
var question_paneldynamic_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var question_paneldynamic_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var question_paneldynamic_spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
    for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
        to[j] = from[i];
    return to;
};















var QuestionPanelDynamicItemTextProcessor = /** @class */ (function (_super) {
    question_paneldynamic_extends(QuestionPanelDynamicItemTextProcessor, _super);
    function QuestionPanelDynamicItemTextProcessor(data, panelItem, variableName) {
        var _this = _super.call(this, variableName) || this;
        _this.data = data;
        _this.panelItem = panelItem;
        _this.variableName = variableName;
        _this.sharedQuestions = {};
        return _this;
    }
    Object.defineProperty(QuestionPanelDynamicItemTextProcessor.prototype, "survey", {
        get: function () {
            return this.panelItem.getSurvey();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicItemTextProcessor.prototype, "panel", {
        get: function () {
            return this.panelItem.panel;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicItemTextProcessor.prototype, "panelIndex", {
        get: function () {
            return !!this.data ? this.data.getItemIndex(this.panelItem) : -1;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicItemTextProcessor.prototype, "visiblePanelIndex", {
        get: function () {
            return !!this.data ? this.data.getVisibleItemIndex(this.panelItem) : -1;
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicItemTextProcessor.prototype.getValues = function () {
        return this.panelItem.getAllValues();
    };
    QuestionPanelDynamicItemTextProcessor.prototype.getQuestionByName = function (name) {
        var res = _super.prototype.getQuestionByName.call(this, name);
        if (!!res)
            return res;
        var index = this.panelIndex;
        res = index > -1 ? this.data.getSharedQuestionFromArray(name, index) : undefined;
        var qName = !!res ? res.name : name;
        this.sharedQuestions[qName] = name;
        return res;
    };
    QuestionPanelDynamicItemTextProcessor.prototype.getQuestionDisplayText = function (question) {
        var name = this.sharedQuestions[question.name];
        if (!name)
            return _super.prototype.getQuestionDisplayText.call(this, question);
        var val = this.panelItem.getValue(name);
        return question.getDisplayValue(true, val);
    };
    QuestionPanelDynamicItemTextProcessor.prototype.onCustomProcessText = function (textValue) {
        if (textValue.name == question_paneldynamic_QuestionPanelDynamicItem.IndexVariableName) {
            var index = this.panelIndex;
            if (index > -1) {
                textValue.isExists = true;
                textValue.value = index + 1;
                return true;
            }
        }
        if (textValue.name == question_paneldynamic_QuestionPanelDynamicItem.VisibleIndexVariableName) {
            var index = this.visiblePanelIndex;
            if (index > -1) {
                textValue.isExists = true;
                textValue.value = index + 1;
                return true;
            }
        }
        if (textValue.name.toLowerCase().indexOf(question_paneldynamic_QuestionPanelDynamicItem.ParentItemVariableName + ".") == 0) {
            var q = this.data;
            if (!!q && !!q.parentQuestion && !!q.parent && !!q.parent.data) {
                var processor = new QuestionPanelDynamicItemTextProcessor(q.parentQuestion, q.parent.data, question_paneldynamic_QuestionPanelDynamicItem.ItemVariableName);
                var text = question_paneldynamic_QuestionPanelDynamicItem.ItemVariableName +
                    textValue.name.substring(question_paneldynamic_QuestionPanelDynamicItem.ParentItemVariableName.length);
                var res = processor.processValue(text, textValue.returnDisplayValue);
                textValue.isExists = res.isExists;
                textValue.value = res.value;
            }
            return true;
        }
        return false;
    };
    return QuestionPanelDynamicItemTextProcessor;
}(textPreProcessor_QuestionTextProcessor));
var question_paneldynamic_QuestionPanelDynamicItem = /** @class */ (function () {
    function QuestionPanelDynamicItem(data, panel) {
        this.data = data;
        this.panelValue = panel;
        this.textPreProcessor = new QuestionPanelDynamicItemTextProcessor(data, this, QuestionPanelDynamicItem.ItemVariableName);
        this.setSurveyImpl();
    }
    Object.defineProperty(QuestionPanelDynamicItem.prototype, "panel", {
        get: function () {
            return this.panelValue;
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicItem.prototype.setSurveyImpl = function () {
        this.panel.setSurveyImpl(this);
    };
    QuestionPanelDynamicItem.prototype.getValue = function (name) {
        var values = this.getAllValues();
        return values[name];
    };
    QuestionPanelDynamicItem.prototype.setValue = function (name, newValue) {
        var oldItemData = this.data.getPanelItemData(this);
        var oldValue = !!oldItemData ? oldItemData[name] : undefined;
        if (helpers_Helpers.isTwoValueEquals(newValue, oldValue, false, true, false))
            return;
        this.data.setPanelItemData(this, name, helpers_Helpers.getUnbindValue(newValue));
        var questions = this.panel.questions;
        var triggerName = QuestionPanelDynamicItem.ItemVariableName + "." + name;
        for (var i = 0; i < questions.length; i++) {
            var q = questions[i];
            if (q.getValueName() !== name) {
                q.checkBindings(name, newValue);
            }
            q.runTriggers(triggerName, newValue);
        }
    };
    QuestionPanelDynamicItem.prototype.getVariable = function (name) {
        return undefined;
    };
    QuestionPanelDynamicItem.prototype.setVariable = function (name, newValue) { };
    QuestionPanelDynamicItem.prototype.getComment = function (name) {
        var result = this.getValue(name + settings.commentSuffix);
        return result ? result : "";
    };
    QuestionPanelDynamicItem.prototype.setComment = function (name, newValue, locNotification) {
        this.setValue(name + settings.commentSuffix, newValue);
    };
    QuestionPanelDynamicItem.prototype.findQuestionByName = function (name) {
        if (!name)
            return undefined;
        var prefix = QuestionPanelDynamicItem.ItemVariableName + ".";
        if (name.indexOf(prefix) === 0) {
            return this.panel.getQuestionByName(name.substring(prefix.length));
        }
        var survey = this.getSurvey();
        return !!survey ? survey.getQuestionByName(name) : null;
    };
    QuestionPanelDynamicItem.prototype.getEditingSurveyElement = function () { return undefined; };
    QuestionPanelDynamicItem.prototype.getAllValues = function () {
        return this.data.getPanelItemData(this);
    };
    QuestionPanelDynamicItem.prototype.getFilteredValues = function () {
        var values = {};
        var surveyValues = !!this.data && !!this.data.getRootData()
            ? this.data.getRootData().getFilteredValues()
            : {};
        for (var key in surveyValues) {
            values[key] = surveyValues[key];
        }
        values[QuestionPanelDynamicItem.ItemVariableName] = this.getAllValues();
        if (!!this.data) {
            var indexStr = QuestionPanelDynamicItem.IndexVariableName;
            var visibleIndexStr = QuestionPanelDynamicItem.VisibleIndexVariableName;
            delete values[indexStr];
            delete values[visibleIndexStr];
            values[indexStr.toLowerCase()] = this.data.getItemIndex(this);
            values[visibleIndexStr.toLowerCase()] = this.data.getVisibleItemIndex(this);
            var q = this.data;
            if (!!q && !!q.parentQuestion && !!q.parent) {
                values[QuestionPanelDynamicItem.ParentItemVariableName] = q.parent.getValue();
            }
        }
        return values;
    };
    QuestionPanelDynamicItem.prototype.getFilteredProperties = function () {
        if (!!this.data && !!this.data.getRootData())
            return this.data.getRootData().getFilteredProperties();
        return { survey: this.getSurvey() };
    };
    QuestionPanelDynamicItem.prototype.getSurveyData = function () {
        return this;
    };
    QuestionPanelDynamicItem.prototype.getSurvey = function () {
        return this.data ? this.data.getSurvey() : null;
    };
    QuestionPanelDynamicItem.prototype.getTextProcessor = function () {
        return this.textPreProcessor;
    };
    QuestionPanelDynamicItem.ItemVariableName = "panel";
    QuestionPanelDynamicItem.ParentItemVariableName = "parentpanel";
    QuestionPanelDynamicItem.IndexVariableName = "panelIndex";
    QuestionPanelDynamicItem.VisibleIndexVariableName = "visiblePanelIndex";
    return QuestionPanelDynamicItem;
}());

var QuestionPanelDynamicTemplateSurveyImpl = /** @class */ (function () {
    function QuestionPanelDynamicTemplateSurveyImpl(data) {
        this.data = data;
    }
    QuestionPanelDynamicTemplateSurveyImpl.prototype.getSurveyData = function () {
        return null;
    };
    QuestionPanelDynamicTemplateSurveyImpl.prototype.getSurvey = function () {
        return this.data.getSurvey();
    };
    QuestionPanelDynamicTemplateSurveyImpl.prototype.getTextProcessor = function () {
        return null;
    };
    return QuestionPanelDynamicTemplateSurveyImpl;
}());

/**
  * A class that describes the Dynamic Panel question type.
  *
  * Dynamic Panel allows respondents to add panels based on a panel template and delete them. Specify the [`templateElements`](https://surveyjs.io/form-library/documentation/questionpaneldynamicmodel#templateElements) property to configure panel template elements.
  *
  * [View Demo](https://surveyjs.io/form-library/examples/questiontype-paneldynamic/ (linkStyle))
  */
var question_paneldynamic_QuestionPanelDynamicModel = /** @class */ (function (_super) {
    question_paneldynamic_extends(QuestionPanelDynamicModel, _super);
    function QuestionPanelDynamicModel(name) {
        var _this = _super.call(this, name) || this;
        _this._renderedPanels = [];
        _this.isPanelsAnimationRunning = false;
        _this.isAddingNewPanels = false;
        _this.isSetPanelItemData = {};
        _this.createNewArray("panels", function (panel) { _this.onPanelAdded(panel); }, function (panel) { _this.onPanelRemoved(panel); });
        _this.createNewArray("visiblePanels");
        _this.templateValue = _this.createAndSetupNewPanelObject();
        _this.template.renderWidth = "100%";
        _this.template.selectedElementInDesign = _this;
        _this.template.addElementCallback = function (element) {
            _this.addOnPropertyChangedCallback(element);
            _this.rebuildPanels();
        };
        _this.template.removeElementCallback = function () {
            _this.rebuildPanels();
        };
        _this.createLocalizableString("confirmDeleteText", _this, false, "confirmDelete");
        _this.createLocalizableString("keyDuplicationError", _this, false, true);
        _this.createLocalizableString("panelAddText", _this, false, "addPanel");
        _this.createLocalizableString("panelRemoveText", _this, false, "removePanel");
        _this.createLocalizableString("panelPrevText", _this, false, "pagePrevText");
        _this.createLocalizableString("panelNextText", _this, false, "pageNextText");
        _this.createLocalizableString("noEntriesText", _this, false, "noEntriesText");
        _this.createLocalizableString("templateTabTitle", _this, true, "panelDynamicTabTextFormat");
        _this.createLocalizableString("tabTitlePlaceholder", _this, true, "tabTitlePlaceholder");
        _this.registerPropertyChangedHandlers(["panelsState"], function () {
            _this.setPanelsState();
        });
        _this.registerPropertyChangedHandlers(["isMobile", "newPanelPosition", "displayMode", "showProgressBar"], function () {
            _this.updateFooterActions();
        });
        _this.registerPropertyChangedHandlers(["allowAddPanel"], function () { _this.updateNoEntriesTextDefaultLoc(); });
        return _this;
    }
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "isCompositeQuestion", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "hasSingleInput", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "isContainer", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.getFirstQuestionToFocus = function (withError) {
        for (var i = 0; i < this.visiblePanelsCore.length; i++) {
            var res = this.visiblePanelsCore[i].getFirstQuestionToFocus(withError);
            if (!!res)
                return res;
        }
        return null;
    };
    QuestionPanelDynamicModel.prototype.setSurveyImpl = function (value, isLight) {
        _super.prototype.setSurveyImpl.call(this, value, isLight);
        this.setTemplatePanelSurveyImpl();
        this.setPanelsSurveyImpl();
    };
    QuestionPanelDynamicModel.prototype.assignOnPropertyChangedToTemplate = function () {
        var elements = this.template.elements;
        for (var i = 0; i < elements.length; i++) {
            this.addOnPropertyChangedCallback(elements[i]);
        }
    };
    QuestionPanelDynamicModel.prototype.addOnPropertyChangedCallback = function (element) {
        var _this = this;
        if (element.isQuestion) {
            element.setParentQuestion(this);
        }
        element.onPropertyChanged.add(function (element, options) {
            _this.onTemplateElementPropertyChanged(element, options);
        });
        if (element.isPanel) {
            element.addElementCallback = function (element) {
                _this.addOnPropertyChangedCallback(element);
            };
        }
    };
    QuestionPanelDynamicModel.prototype.onTemplateElementPropertyChanged = function (element, options) {
        if (this.isLoadingFromJson || this.useTemplatePanel || this.panelsCore.length == 0)
            return;
        var property = Serializer.findProperty(element.getType(), options.name);
        if (!property)
            return;
        var panels = this.panelsCore;
        for (var i = 0; i < panels.length; i++) {
            var question = panels[i].getQuestionByName(element.name);
            if (!!question && question[options.name] !== options.newValue) {
                question[options.name] = options.newValue;
            }
        }
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "useTemplatePanel", {
        get: function () {
            return this.isDesignMode && !this.isContentElement;
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.getType = function () {
        return "paneldynamic";
    };
    QuestionPanelDynamicModel.prototype.clearOnDeletingContainer = function () {
        this.panelsCore.forEach(function (panel) {
            panel.clearOnDeletingContainer();
        });
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "isAllowTitleLeft", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.removeElement = function (element) {
        return this.template.removeElement(element);
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "template", {
        /**
         * A `PanelModel` object used as a template to create dynamic panels.
         * @see PanelModel
         * @see templateElements
         * @see templateTitle
         * @see panels
         * @see panelCount
         */
        get: function () {
            return this.templateValue;
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.getPanel = function () {
        return this.template;
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "templateElements", {
        /**
         * An array of questions and panels included in a panel template.
         * @see template
         * @see panels
         * @see panelCount
         */
        get: function () {
            return this.template.elements;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "templateTitle", {
        /**
         * A template for panel titles.
         *
         * The template can contain the following placeholders:
         *
         * - `{panelIndex}` - A panel index within the collection of all panels. Starts with 1.
         * - `{visiblePanelIndex}` - A panel index within the collection of visible panels. Starts with 1.
         * @see template
         * @see templateDescription
         * @see templateElements
         * @see panels
         * @see panelCount
         */
        get: function () {
            return this.template.title;
        },
        set: function (newValue) {
            this.template.title = newValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "locTemplateTitle", {
        get: function () {
            return this.template.locTitle;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "templateTabTitle", {
        /**
         * A template for tab titles. Applies when [`displayMode`](https://surveyjs.io/form-library/documentation/api-reference/dynamic-panel-model#displayMode) is `"tab"`.
         *
         * The template can contain the following placeholders:
         *
         * - `{panelIndex}` - A panel index within the collection of all panels. Starts with 1.
         * - `{visiblePanelIndex}` - A panel index within the collection of visible panels. Starts with 1.
         *
         * If you want to customize individual tab titles, handle `SurveyModel`'s [`onGetDynamicPanelTabTitle`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onGetDynamicPanelTabTitle) event.
         *
         * [View Demo](https://surveyjs.io/form-library/examples/tabbed-interface-for-duplicate-group-option/ (linkStyle))
         * @see templateTitle
         * @see tabTitlePlaceholder
         * @see displayMode
         */
        get: function () {
            return this.locTemplateTabTitle.text;
        },
        set: function (newValue) {
            this.locTemplateTabTitle.text = newValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "locTemplateTabTitle", {
        get: function () {
            return this.getLocalizableString("templateTabTitle");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "tabTitlePlaceholder", {
        /**
         * A placeholder for tab titles that applies when the [`templateTabTitle`](https://surveyjs.io/form-library/documentation/api-reference/dynamic-panel-model#templateTabTitle) expression doesn't produce a meaningful value.
         *
         * Default value: `"New Panel"` (taken from a [localization dictionary](https://github.com/surveyjs/survey-library/tree/master/src/localization))
         */
        get: function () {
            return this.locTabTitlePlaceholder.text;
        },
        set: function (newValue) {
            this.locTabTitlePlaceholder.text = newValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "locTabTitlePlaceholder", {
        get: function () {
            return this.getLocalizableString("tabTitlePlaceholder");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "templateDescription", {
        /**
         * A template for panel descriptions.
         * @see template
         * @see templateTitle
         * @see templateElements
         * @see panels
         * @see panelCount
         */
        get: function () {
            return this.template.description;
        },
        set: function (newValue) {
            this.template.description = newValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "locTemplateDescription", {
        get: function () {
            return this.template.locDescription;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "templateVisibleIf", {
        /**
         * A Boolean expression that is evaluated against each panel. If the expression evaluates to `false`, the panel becomes hidden.
         *
         * A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
         *
         * Use the `{panel}` placeholder to reference the current panel in the expression.
         *
         * Refer to the following help topic for more information: [Conditional Visibility](https://surveyjs.io/form-library/documentation/design-survey/conditional-logic#conditional-visibility).
         * @see visibleIf
         * @see visiblePanels
         */
        get: function () {
            return this.getPropertyValue("templateVisibleIf");
        },
        set: function (val) {
            this.setPropertyValue("templateVisibleIf", val);
            this.template.visibleIf = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "items", {
        get: function () {
            var res = [];
            for (var i = 0; i < this.panelsCore.length; i++) {
                res.push(this.panelsCore[i].data);
            }
            return res;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "panels", {
        /**
         * An array of `PanelModel` objects created based on a panel template.
         * @see PanelModel
         * @see template
         * @see panelCount
         */
        get: function () {
            this.buildPanelsFirstTime(this.canBuildPanels);
            return this.panelsCore;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "visiblePanels", {
        /**
         * An array of currently visible panels ([`PanelModel`](https://surveyjs.io/form-library/documentation/api-reference/panel-model) objects).
         * @see templateVisibleIf
         */
        get: function () {
            this.buildPanelsFirstTime(this.canBuildPanels);
            return this.visiblePanelsCore;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "panelsCore", {
        get: function () {
            return this.getPropertyValue("panels");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "visiblePanelsCore", {
        get: function () {
            return this.getPropertyValue("visiblePanels");
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.onPanelAdded = function (panel) {
        this.onPanelRemovedCore(panel);
        if (!panel.visible)
            return;
        var index = 0;
        var panels = this.panelsCore;
        for (var i = 0; i < panels.length; i++) {
            if (panels[i] === panel)
                break;
            if (panels[i].visible)
                index++;
        }
        this.visiblePanelsCore.splice(index, 0, panel);
        this.addTabFromToolbar(panel, index);
        if (!this.currentPanel) {
            this.currentPanel = panel;
        }
        this.updateRenderedPanels();
    };
    QuestionPanelDynamicModel.prototype.onPanelRemoved = function (panel) {
        var index = this.onPanelRemovedCore(panel);
        if (this.currentPanel === panel) {
            var visPanels = this.visiblePanelsCore;
            if (index >= visPanels.length)
                index = visPanels.length - 1;
            this.currentPanel = index >= 0 ? visPanels[index] : null;
        }
        this.updateRenderedPanels();
    };
    QuestionPanelDynamicModel.prototype.onPanelRemovedCore = function (panel) {
        var visPanels = this.visiblePanelsCore;
        var index = visPanels.indexOf(panel);
        if (index > -1) {
            visPanels.splice(index, 1);
            this.removeTabFromToolbar(panel);
        }
        return index;
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "currentIndex", {
        /**
         * A zero-based index of the currently displayed panel.
         *
         * When `displayMode` is `"list"` or Dynamic Panel is empty (`panelCount` is 0), this property contains -1.
         * @see currentPanel
         * @see panels
         * @see panelCount
         * @see displayMode
         */
        get: function () {
            if (this.isRenderModeList)
                return -1;
            if (this.useTemplatePanel)
                return 0;
            return this.visiblePanelsCore.indexOf(this.currentPanel);
        },
        set: function (val) {
            if (val < 0 || this.visiblePanelCount < 1)
                return;
            if (val >= this.visiblePanelCount)
                val = this.visiblePanelCount - 1;
            this.currentPanel = this.visiblePanelsCore[val];
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "currentPanel", {
        /**
         * A `PanelModel` object that is the currently displayed panel.
         *
         * When `displayMode` is `"list"` or Dynamic Panel is empty (`panelCount` is 0), this property contains `null`.
         * @see currentIndex
         * @see panels
         * @see panelCount
         * @see displayMode
         */
        get: function () {
            if (this.isDesignMode)
                return this.template;
            if (this.isRenderModeList || this.useTemplatePanel)
                return null;
            var res = this.getPropertyValue("currentPanel", null);
            if (!res && this.visiblePanelCount > 0) {
                res = this.visiblePanelsCore[0];
                this.currentPanel = res;
            }
            return res;
        },
        set: function (val) {
            if (this.isRenderModeList || this.useTemplatePanel)
                return;
            var curPanel = this.getPropertyValue("currentPanel");
            var index = !!val ? this.visiblePanelsCore.indexOf(val) : -1;
            if (!!val && index < 0 || val === curPanel)
                return;
            if (curPanel) {
                curPanel.onHidingContent();
            }
            this.setPropertyValue("currentPanel", val);
            this.updateRenderedPanels();
            this.updateFooterActions();
            this.updateTabToolbarItemsPressedState();
            this.fireCallback(this.currentIndexChangedCallback);
            if (index > -1 && this.survey) {
                var options = {
                    panel: val,
                    visiblePanelIndex: index
                };
                this.survey.dynamicPanelCurrentIndexChanged(this, options);
            }
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.updateRenderedPanels = function () {
        if (this.isRenderModeList) {
            this.renderedPanels = [].concat(this.visiblePanels);
        }
        else if (this.currentPanel) {
            this.renderedPanels = [this.currentPanel];
        }
        else {
            this.renderedPanels = [];
        }
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "renderedPanels", {
        get: function () {
            return this._renderedPanels;
        },
        set: function (val) {
            if (this.renderedPanels.length == 0 || val.length == 0) {
                this.blockAnimations();
                this.panelsAnimation.sync(val);
                this.releaseAnimations();
            }
            else {
                this.isPanelsAnimationRunning = true;
                this.panelsAnimation.sync(val);
            }
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.getPanelsAnimationOptions = function () {
        var _this = this;
        var getDirectionCssClass = function () {
            if (_this.isRenderModeList)
                return "";
            var cssClass = new CssClassBuilder();
            var isRemoving = false;
            var leavingPanel = _this.renderedPanels.filter(function (el) { return el !== _this.currentPanel; })[0];
            var leavingPanelIndex = _this.visiblePanels.indexOf(leavingPanel);
            if (leavingPanelIndex < 0) {
                isRemoving = true;
                leavingPanelIndex = _this.removedPanelIndex;
            }
            return cssClass
                .append("sv-pd-animation-adding", !!_this.focusNewPanelCallback)
                .append("sv-pd-animation-removing", isRemoving)
                .append("sv-pd-animation-left", leavingPanelIndex <= _this.currentIndex)
                .append("sv-pd-animation-right", leavingPanelIndex > _this.currentIndex)
                .toString();
        };
        return {
            getRerenderEvent: function () { return _this.onElementRerendered; },
            getAnimatedElement: function (panel) {
                var _a, _b;
                if (panel && _this.cssContent) {
                    var contentSelector = classesToSelector(_this.cssContent);
                    return (_b = (_a = _this.getWrapperElement()) === null || _a === void 0 ? void 0 : _a.querySelector(":scope " + contentSelector + " #" + panel.id)) === null || _b === void 0 ? void 0 : _b.parentElement;
                }
            },
            getEnterOptions: function () {
                var cssClass = new CssClassBuilder().append(_this.cssClasses.panelWrapperFadeIn).append(getDirectionCssClass()).toString();
                return {
                    onBeforeRunAnimation: function (el) {
                        var _a;
                        if (_this.focusNewPanelCallback) {
                            var scolledElement = _this.isRenderModeList ? el : el.parentElement;
                            survey_element_SurveyElement.ScrollElementToViewCore(scolledElement, false, false, { behavior: "smooth" });
                        }
                        if (!_this.isRenderModeList) {
                            (_a = el.parentElement) === null || _a === void 0 ? void 0 : _a.style.setProperty("--animation-height-to", el.offsetHeight + "px");
                        }
                        else {
                            el.style.setProperty("--animation-height", el.offsetHeight + "px");
                        }
                    },
                    cssClass: cssClass
                };
            },
            getLeaveOptions: function () {
                var cssClass = new CssClassBuilder().append(_this.cssClasses.panelWrapperFadeOut).append(getDirectionCssClass()).toString();
                return {
                    onBeforeRunAnimation: function (el) {
                        var _a;
                        if (!_this.isRenderModeList) {
                            (_a = el.parentElement) === null || _a === void 0 ? void 0 : _a.style.setProperty("--animation-height-from", el.offsetHeight + "px");
                        }
                        else {
                            el.style.setProperty("--animation-height", el.offsetHeight + "px");
                        }
                    },
                    cssClass: cssClass
                };
            },
            isAnimationEnabled: function () {
                return _this.animationAllowed && !!_this.getWrapperElement();
            },
        };
    };
    QuestionPanelDynamicModel.prototype.disablePanelsAnimations = function () {
        this.panelsCore.forEach(function (panel) {
            panel.blockAnimations();
        });
    };
    QuestionPanelDynamicModel.prototype.enablePanelsAnimations = function () {
        this.panelsCore.forEach(function (panel) {
            panel.releaseAnimations();
        });
    };
    QuestionPanelDynamicModel.prototype.updatePanelsAnimation = function () {
        var _this = this;
        this._panelsAnimations = new (this.isRenderModeList ? animation_AnimationGroup : AnimationTab)(this.getPanelsAnimationOptions(), function (val, isTempUpdate) {
            _this._renderedPanels = val;
            if (!isTempUpdate) {
                _this.isPanelsAnimationRunning = false;
                _this.focusNewPanel();
            }
        }, function () { return _this._renderedPanels; });
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "panelsAnimation", {
        get: function () {
            if (!this._panelsAnimations) {
                this.updatePanelsAnimation();
            }
            return this._panelsAnimations;
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.onHidingContent = function () {
        _super.prototype.onHidingContent.call(this);
        if (this.currentPanel) {
            this.currentPanel.onHidingContent();
        }
        else {
            this.visiblePanelsCore.forEach(function (panel) { return panel.onHidingContent(); });
        }
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "confirmDelete", {
        /**
         * Specifies whether to display a confirmation dialog when a respondent wants to delete a panel.
         * @see confirmDeleteText
         */
        get: function () {
            return this.getPropertyValue("confirmDelete");
        },
        set: function (val) {
            this.setPropertyValue("confirmDelete", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "keyName", {
        /**
         * Specifies a key question. Set this property to the name of a question used in the template, and Dynamic Panel will display `keyDuplicationError` if a user tries to enter a duplicate value in this question.
         * @see keyDuplicationError
         */
        get: function () {
            return this.getPropertyValue("keyName", "");
        },
        set: function (val) {
            this.setPropertyValue("keyName", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "confirmDeleteText", {
        /**
         * A message displayed in a confirmation dialog that appears when a respondent wants to delete a panel.
         * @see confirmDelete
         */
        get: function () {
            return this.getLocalizableStringText("confirmDeleteText");
        },
        set: function (val) {
            this.setLocalizableStringText("confirmDeleteText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "locConfirmDeleteText", {
        get: function () {
            return this.getLocalizableString("confirmDeleteText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "keyDuplicationError", {
        /**
         * An error message displayed when users enter a duplicate value into a question that accepts only unique values (`isUnique` is set to `true` or `keyName` is specified).
         *
         * A default value for this property is taken from a [localization dictionary](https://github.com/surveyjs/survey-library/tree/master/src/localization). Refer to the following help topic for more information: [Localization & Globalization](https://surveyjs.io/form-library/documentation/localization).
         * @see keyName
         */
        get: function () {
            return this.getLocalizableStringText("keyDuplicationError");
        },
        set: function (val) {
            this.setLocalizableStringText("keyDuplicationError", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "locKeyDuplicationError", {
        get: function () {
            return this.getLocalizableString("keyDuplicationError");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "panelPrevText", {
        /**
         * A caption for the Previous button. Applies only if `displayMode` is different from `"list"`.
         * @see displayMode
         * @see isPrevButtonVisible
         */
        get: function () {
            return this.getLocalizableStringText("panelPrevText");
        },
        set: function (val) {
            this.setLocalizableStringText("panelPrevText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "locPanelPrevText", {
        get: function () {
            return this.getLocalizableString("panelPrevText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "panelNextText", {
        /**
         * A caption for the Next button. Applies only if `displayMode` is different from `"list"`.
         * @see displayMode
         * @see isNextButtonVisible
         */
        get: function () {
            return this.getLocalizableStringText("panelNextText");
        },
        set: function (val) {
            this.setLocalizableStringText("panelNextText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "locPanelNextText", {
        get: function () {
            return this.getLocalizableString("panelNextText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "panelAddText", {
        /**
         * A caption for the Add Panel button.
         */
        get: function () {
            return this.getLocalizableStringText("panelAddText");
        },
        set: function (value) {
            this.setLocalizableStringText("panelAddText", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "locPanelAddText", {
        get: function () {
            return this.getLocalizableString("panelAddText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "panelRemoveText", {
        /**
         * A caption for the Delete Panel button.
         * @see panelRemoveButtonLocation
         */
        get: function () {
            return this.getLocalizableStringText("panelRemoveText");
        },
        set: function (val) {
            this.setLocalizableStringText("panelRemoveText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "locPanelRemoveText", {
        get: function () {
            return this.getLocalizableString("panelRemoveText");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "isProgressTopShowing", {
        get: function () {
            return this.displayMode == "carousel" && (this.progressBarLocation === "top" || this.progressBarLocation === "topBottom");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "isProgressBottomShowing", {
        get: function () {
            return this.displayMode == "carousel" && (this.progressBarLocation === "bottom" || this.progressBarLocation === "topBottom");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "isPrevButtonVisible", {
        /**
         * Indicates whether the Previous button is visible.
         * @see currentIndex
         * @see currentPanel
         * @see panelPrevText
         */
        get: function () { return this.currentIndex > 0; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "isPrevButtonShowing", {
        get: function () { return this.isPrevButtonVisible; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "isNextButtonVisible", {
        /**
         * Indicates whether the Next button is visible.
         * @see currentIndex
         * @see currentPanel
         * @see panelNextText
         */
        get: function () {
            return this.currentIndex >= 0 && this.currentIndex < this.visiblePanelCount - 1;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "isNextButtonShowing", {
        get: function () { return this.isNextButtonVisible; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "isRangeShowing", {
        get: function () {
            return (this.showRangeInProgress && this.currentIndex >= 0 && this.visiblePanelCount > 1);
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.getElementsInDesign = function (includeHidden) {
        if (includeHidden === void 0) { includeHidden = false; }
        return includeHidden ? [this.template] : this.templateElements;
    };
    QuestionPanelDynamicModel.prototype.prepareValueForPanelCreating = function () {
        this.addingNewPanelsValue = this.value;
        this.isAddingNewPanels = true;
        this.isNewPanelsValueChanged = false;
    };
    QuestionPanelDynamicModel.prototype.setValueAfterPanelsCreating = function () {
        this.isAddingNewPanels = false;
        if (this.isNewPanelsValueChanged) {
            this.isValueChangingInternally = true;
            this.value = this.addingNewPanelsValue;
            this.isValueChangingInternally = false;
        }
    };
    QuestionPanelDynamicModel.prototype.getValueCore = function () {
        return this.isAddingNewPanels
            ? this.addingNewPanelsValue
            : _super.prototype.getValueCore.call(this);
    };
    QuestionPanelDynamicModel.prototype.setValueCore = function (newValue) {
        if (this.isAddingNewPanels) {
            this.isNewPanelsValueChanged = true;
            this.addingNewPanelsValue = newValue;
        }
        else {
            _super.prototype.setValueCore.call(this, newValue);
        }
    };
    QuestionPanelDynamicModel.prototype.setIsMobile = function (val) {
        _super.prototype.setIsMobile.call(this, val);
        (this.panelsCore || []).forEach(function (panel) { return panel.getQuestions(true).forEach(function (question) {
            question.setIsMobile(val);
        }); });
    };
    QuestionPanelDynamicModel.prototype.themeChanged = function (theme) {
        _super.prototype.themeChanged.call(this, theme);
        (this.panelsCore || []).forEach(function (panel) {
            return panel.getQuestions(true).forEach(function (question) {
                question.themeChanged(theme);
            });
        });
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "panelCount", {
        /**
         * The number of panels in Dynamic Panel.
         * @see minPanelCount
         * @see maxPanelCount
         */
        get: function () {
            return !this.canBuildPanels || this.wasNotRenderedInSurvey
                ? this.getPropertyValue("panelCount")
                : this.panelsCore.length;
        },
        set: function (val) {
            if (val < 0)
                return;
            if (!this.canBuildPanels || this.wasNotRenderedInSurvey) {
                this.setPropertyValue("panelCount", val);
                return;
            }
            if (val == this.panelsCore.length || this.useTemplatePanel)
                return;
            this.updateBindings("panelCount", val);
            this.prepareValueForPanelCreating();
            for (var i = this.panelCount; i < val; i++) {
                var panel = this.createNewPanel();
                this.panelsCore.push(panel);
                if (this.displayMode == "list" && this.panelsState != "default") {
                    if (this.panelsState === "expanded") {
                        panel.expand();
                    }
                    else {
                        if (!!panel.title) {
                            panel.collapse();
                        }
                    }
                }
            }
            if (val < this.panelCount) {
                this.panelsCore.splice(val, this.panelCount - val);
            }
            this.disablePanelsAnimations();
            this.setValueAfterPanelsCreating();
            this.setValueBasedOnPanelCount();
            this.reRunCondition();
            this.updateFooterActions();
            this.fireCallback(this.panelCountChangedCallback);
            this.enablePanelsAnimations();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "visiblePanelCount", {
        /**
         * Returns the number of visible panels in Dynamic Panel.
         * @see templateVisibleIf
         */
        get: function () { return this.visiblePanels.length; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "panelsState", {
        /**
         * Specifies whether users can expand and collapse panels. Applies if `displayMode` is `"list"` and the `templateTitle` property is specified.
         *
         * Possible values:
         *
         * - `"default"` (default) - All panels are displayed in full and cannot be collapsed.
         * - `"expanded"` - All panels are displayed in full and can be collapsed in the UI.
         * - `"collapsed"` - All panels display only their titles and descriptions and can be expanded in the UI.
         * - `"firstExpanded"` - Only the first panel is displayed in full; other panels are collapsed and can be expanded in the UI.
         * @see displayMode
         * @see templateTitle
         */
        get: function () {
            return this.getPropertyValue("panelsState");
        },
        set: function (val) {
            this.setPropertyValue("panelsState", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.setTemplatePanelSurveyImpl = function () {
        this.template.setSurveyImpl(this.useTemplatePanel
            ? this.surveyImpl
            : new QuestionPanelDynamicTemplateSurveyImpl(this));
    };
    QuestionPanelDynamicModel.prototype.setPanelsSurveyImpl = function () {
        for (var i = 0; i < this.panelsCore.length; i++) {
            var panel = this.panelsCore[i];
            if (panel == this.template)
                continue;
            panel.setSurveyImpl(panel.data);
        }
    };
    QuestionPanelDynamicModel.prototype.setPanelsState = function () {
        if (this.useTemplatePanel || this.displayMode != "list" || !this.templateTitle)
            return;
        for (var i = 0; i < this.panelsCore.length; i++) {
            var state = this.panelsState;
            if (state === "firstExpanded") {
                state = i === 0 ? "expanded" : "collapsed";
            }
            this.panelsCore[i].state = state;
        }
    };
    QuestionPanelDynamicModel.prototype.setValueBasedOnPanelCount = function () {
        var value = this.value;
        if (!value || !Array.isArray(value))
            value = [];
        if (value.length == this.panelCount)
            return;
        for (var i = value.length; i < this.panelCount; i++)
            value.push({});
        if (value.length > this.panelCount) {
            value.splice(this.panelCount, value.length - this.panelCount);
        }
        this.isValueChangingInternally = true;
        this.value = value;
        this.isValueChangingInternally = false;
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "minPanelCount", {
        /**
         * A minimum number of panels in Dynamic Panel. Users cannot delete panels if `panelCount` equals `minPanelCount`.
         *
         * Default value: 0
         * @see panelCount
         * @see maxPanelCount
         * @see allowRemovePanel
         */
        get: function () {
            return this.getPropertyValue("minPanelCount");
        },
        set: function (val) {
            if (val < 0)
                val = 0;
            if (val == this.minPanelCount)
                return;
            this.setPropertyValue("minPanelCount", val);
            if (val > this.maxPanelCount)
                this.maxPanelCount = val;
            if (this.panelCount < val)
                this.panelCount = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "maxPanelCount", {
        /**
         * A maximum number of panels in Dynamic Panel. Users cannot add new panels if `panelCount` equals `maxPanelCount`.
         *
         * Default value: 100 (inherited from [`settings.panel.maxPanelCount`](https://surveyjs.io/form-library/documentation/settings#panelMaximumPanelCount))
         * @see panelCount
         * @see minPanelCount
         * @see allowAddPanel
         */
        get: function () {
            return this.getPropertyValue("maxPanelCount");
        },
        set: function (val) {
            if (val <= 0)
                return;
            if (val > settings.panel.maxPanelCount)
                val = settings.panel.maxPanelCount;
            if (val == this.maxPanelCount)
                return;
            this.setPropertyValue("maxPanelCount", val);
            if (val < this.minPanelCount)
                this.minPanelCount = val;
            if (this.panelCount > val)
                this.panelCount = val;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "allowAddPanel", {
        /**
         * Specifies whether users are allowed to add new panels.
         *
         * Default value: `true`
         *
         * By default, users add new panels to the end. If you want to let users insert a new panel after the current panel, set the [`newPanelPosition`](https://surveyjs.io/form-library/documentation/api-reference/dynamic-panel-model#newPanelPosition) property to `"next"`.
         * @see canAddPanel
         * @see allowRemovePanel
         */
        get: function () {
            return this.getPropertyValue("allowAddPanel");
        },
        set: function (val) {
            this.setPropertyValue("allowAddPanel", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "newPanelPosition", {
        /**
         * Specifies the position of newly added panels.
         *
         * Possible values:
         *
         * - `"last"` (default) - New panels are added to the end.
         * - `"next"` - New panels are inserted after the current panel.
         * @see allowAddPanel
         * @see addPanel
         */
        get: function () {
            return this.getPropertyValue("newPanelPosition");
        },
        set: function (val) {
            this.setPropertyValue("newPanelPosition", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "allowRemovePanel", {
        /**
         * Specifies whether users are allowed to delete panels.
         *
         * Default value: `true`
         * @see canRemovePanel
         * @see allowAddPanel
         */
        get: function () {
            return this.getPropertyValue("allowRemovePanel");
        },
        set: function (val) {
            this.setPropertyValue("allowRemovePanel", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "templateTitleLocation", {
        /**
         * Gets or sets the location of question titles relative to their input fields.
         *
         * - `"default"` (default) - Inherits the setting from the Dynamic Panel's `titleLocation` property, which in turn inherits the [`questionTitleLocation`](https://surveyjs.io/form-library/documentation/surveymodel#questionTitleLocation) property value specified for the Dynamic Panel's container (page or survey).
         * - `"top"` - Displays question titles above input fields.
         * - `"bottom"` - Displays question titles below input fields.
         * - `"left"` - Displays question titles to the left of input fields.
         * - `"hidden"` - Hides question titles.
         * @see titleLocation
         */
        get: function () {
            return this.getPropertyValue("templateTitleLocation");
        },
        set: function (value) {
            this.setPropertyValue("templateTitleLocation", value.toLowerCase());
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "templateErrorLocation", {
        /**
         * Specifies the error message position.
         *
         * Possible values:
         *
         * - `"default"` (default) - Inherits the setting from the [`errorLocation`](#errorLocation) property.
         * - `"top"` - Displays error messages above questions.
         * - `"bottom"` - Displays error messages below questions.
         */
        get: function () {
            return this.getPropertyValue("templateErrorLocation");
        },
        set: function (value) {
            this.setPropertyValue("templateErrorLocation", value.toLowerCase());
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "showQuestionNumbers", {
        /**
         * Use this property to show/hide the numbers in titles in questions inside a dynamic panel.
         * By default the value is "off". You may set it to "onPanel" and the first question inside a dynamic panel will start with 1 or "onSurvey" to include nested questions in dymamic panels into global survey question numbering.
         */
        get: function () {
            return this.getPropertyValue("showQuestionNumbers");
        },
        set: function (val) {
            this.setPropertyValue("showQuestionNumbers", val);
            if (!this.isLoadingFromJson && this.survey) {
                this.survey.questionVisibilityChanged(this, this.visible, true);
            }
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.notifySurveyOnChildrenVisibilityChanged = function () { return this.showQuestionNumbers === "onSurvey"; };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "panelRemoveButtonLocation", {
        /**
         * Specifies the location of the Delete Panel button relative to panel content.
         *
         * Possible values:
         *
         * - `"bottom"` (default) - Displays the Delete Panel button below panel content.
         * - `"right"` - Displays the Delete Panel button to the right of panel content.
         * @see panelRemoveText
         */
        get: function () {
            return this.getPropertyValue("panelRemoveButtonLocation");
        },
        set: function (val) {
            this.setPropertyValue("panelRemoveButtonLocation", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "showRangeInProgress", {
        /**
         * Obsolete. Use the [`showProgressBar`](https://surveyjs.io/form-library/documentation/api-reference/dynamic-panel-model#showProgressBar) property instead.
         * @deprecated
         */
        get: function () {
            return this.showProgressBar;
            // return this.getPropertyValue("showRangeInProgress");
        },
        set: function (val) {
            this.showProgressBar = val;
            // this.setPropertyValue("showRangeInProgress", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "renderMode", {
        /**
         * Obsolete. Use the [`displayMode`](https://surveyjs.io/form-library/documentation/api-reference/dynamic-panel-model#displayMode) property instead.
         * @deprecated
         */
        get: function () {
            var displayMode = this.displayMode;
            if (displayMode == "carousel") {
                var progressBarLocation = this.progressBarLocation;
                if (progressBarLocation == "top") {
                    return "progressTop";
                }
                else if (progressBarLocation == "bottom") {
                    return "progressBottom";
                }
                else if (progressBarLocation == "topBottom") {
                    return "progressTopBottom";
                }
            }
            return displayMode;
        },
        set: function (val) {
            if ((val || "").startsWith("progress")) {
                if (val == "progressTop") {
                    this.progressBarLocation = "top";
                }
                else if (val == "progressBottom") {
                    this.progressBarLocation = "bottom";
                }
                else if (val == "progressTopBottom") {
                    this.progressBarLocation = "topBottom";
                }
                this.displayMode = "carousel";
            }
            else {
                this.displayMode = val;
            }
            // this.updatePanelView();
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.updatePanelView = function () {
        this.blockAnimations();
        this.updateRenderedPanels();
        this.releaseAnimations();
        this.updatePanelsAnimation();
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "tabAlign", {
        get: function () {
            return this.getPropertyValue("tabAlign");
        },
        set: function (val) {
            this.setPropertyValue("tabAlign", val);
            if (this.isRenderModeTab) {
                this.additionalTitleToolbar.containerCss = this.getAdditionalTitleToolbarCss();
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "isRenderModeList", {
        get: function () {
            return this.displayMode === "list";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "isRenderModeTab", {
        get: function () {
            return this.displayMode === "tab";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "hasTitleOnLeftTop", {
        get: function () {
            if (this.isRenderModeTab && this.visiblePanelCount > 0)
                return true;
            if (!this.hasTitle)
                return false;
            var location = this.getTitleLocation();
            return location === "left" || location === "top";
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.setVisibleIndex = function (value) {
        if (!this.isVisible)
            return 0;
        var onSurveyNumbering = this.showQuestionNumbers === "onSurvey";
        var startIndex = onSurveyNumbering ? value : 0;
        for (var i = 0; i < this.visiblePanelsCore.length; i++) {
            var counter = this.setPanelVisibleIndex(this.visiblePanelsCore[i], startIndex, this.showQuestionNumbers != "off");
            if (onSurveyNumbering) {
                startIndex += counter;
            }
        }
        _super.prototype.setVisibleIndex.call(this, !onSurveyNumbering ? value : -1);
        return !onSurveyNumbering ? 1 : startIndex - value;
    };
    QuestionPanelDynamicModel.prototype.setPanelVisibleIndex = function (panel, index, showIndex) {
        if (!showIndex) {
            panel.setVisibleIndex(-1);
            return 0;
        }
        return panel.setVisibleIndex(index);
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "canAddPanel", {
        /**
         * Indicates whether it is possible to add a new panel.
         *
         * This property returns `true` when all of the following conditions apply:
         *
         * - Users are allowed to add new panels (`allowAddPanel` is `true`).
         * - Dynamic Panel or its parent survey is not in read-only state.
         * - `panelCount` is less than `maxPanelCount`.
         * @see allowAddPanel
         * @see isReadOnly
         * @see panelCount
         * @see maxPanelCount
         * @see canRemovePanel
         */
        get: function () {
            if (this.isDesignMode)
                return false;
            if (this.isDefaultV2Theme && !this.legacyNavigation && !this.isRenderModeList &&
                (this.currentIndex < this.visiblePanelCount - 1 && this.newPanelPosition !== "next")) {
                return false;
            }
            return (this.allowAddPanel &&
                !this.isReadOnly &&
                this.panelCount < this.maxPanelCount);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "canRemovePanel", {
        /**
         * Indicates whether it is possible to delete panels.
         *
         * This property returns `true` when all of the following conditions apply:
         *
         * - Users are allowed to delete panels (`allowRemovePanel` is `true`).
         * - Dynamic Panel or its parent survey is not in read-only state.
         * - `panelCount` exceeds `minPanelCount`.
         * @see allowRemovePanel
         * @see isReadOnly
         * @see panelCount
         * @see minPanelCount
         * @see canAddPanel
         */
        get: function () {
            if (this.isDesignMode)
                return false;
            return (this.allowRemovePanel &&
                !this.isReadOnly &&
                this.panelCount > this.minPanelCount);
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.rebuildPanels = function () {
        var _a;
        if (this.isLoadingFromJson)
            return;
        this.prepareValueForPanelCreating();
        var panels = [];
        var panel;
        if (this.useTemplatePanel) {
            panel = new question_paneldynamic_QuestionPanelDynamicItem(this, this.template);
            panels.push(this.template);
        }
        else {
            for (var i = 0; i < this.panelCount; i++) {
                panel = this.createNewPanel();
                panels.push(this.createNewPanel());
            }
        }
        (_a = this.panelsCore).splice.apply(_a, question_paneldynamic_spreadArray([0, this.panelsCore.length], panels));
        this.setValueAfterPanelsCreating();
        this.setPanelsState();
        this.reRunCondition();
        this.updateFooterActions();
        this.fireCallback(this.panelCountChangedCallback);
        this.updateTabToolbar();
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "defaultPanelValue", {
        /**
         * If it is not empty, then this value is set to every new panel, including panels created initially, unless the defaultValue is not empty
         * @see defaultValue
         * @see defaultValueFromLastPanel
         */
        get: function () {
            return this.getPropertyValue("defaultPanelValue");
        },
        set: function (val) {
            this.setPropertyValue("defaultPanelValue", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "defaultValueFromLastPanel", {
        /**
         * Specifies whether default values for a new panel should be copied from the last panel.
         *
         * If you also specify `defaultValue`, it will be merged with the copied values.
         * @see defaultValue
         */
        get: function () {
            return this.getPropertyValue("defaultValueFromLastPanel");
        },
        set: function (val) {
            this.setPropertyValue("defaultValueFromLastPanel", val);
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.isDefaultValueEmpty = function () {
        return (_super.prototype.isDefaultValueEmpty.call(this) && this.isValueEmpty(this.defaultPanelValue));
    };
    QuestionPanelDynamicModel.prototype.setDefaultValue = function () {
        if (this.isValueEmpty(this.defaultPanelValue) ||
            !this.isValueEmpty(this.defaultValue)) {
            _super.prototype.setDefaultValue.call(this);
            return;
        }
        if (!this.isEmpty() || this.panelCount == 0)
            return;
        var newValue = [];
        for (var i = 0; i < this.panelCount; i++) {
            newValue.push(this.defaultPanelValue);
        }
        this.value = newValue;
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "isValueArray", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.isEmpty = function () {
        var val = this.value;
        if (!val || !Array.isArray(val))
            return true;
        for (var i = 0; i < val.length; i++) {
            if (!this.isRowEmpty(val[i]))
                return false;
        }
        return true;
    };
    QuestionPanelDynamicModel.prototype.getProgressInfo = function () {
        return survey_element_SurveyElement.getProgressInfoByElements(this.visiblePanelsCore, this.isRequired);
    };
    QuestionPanelDynamicModel.prototype.isRowEmpty = function (val) {
        for (var prop in val) {
            if (val.hasOwnProperty(prop))
                return false;
        }
        return true;
    };
    /**
     * Add a new dynamic panel based on the template Panel. It checks if canAddPanel returns true and then calls addPanel method.
     * If a displayMode is different from "list" and the current panel has erros, then
     * @see template
     * @see panelCount
     * @see panels
     * @see canAddPanel
     */
    QuestionPanelDynamicModel.prototype.addPanelUI = function () {
        if (!this.canAddPanel)
            return null;
        if (!this.canLeaveCurrentPanel())
            return null;
        var newPanel = this.addPanel();
        if (this.displayMode === "list" && this.panelsState !== "default") {
            newPanel.expand();
        }
        this.focusNewPanelCallback = function () {
            newPanel.focusFirstQuestion();
        };
        if (!this.isPanelsAnimationRunning) {
            this.focusNewPanel();
        }
        return newPanel;
    };
    QuestionPanelDynamicModel.prototype.focusNewPanel = function () {
        if (this.focusNewPanelCallback) {
            this.focusNewPanelCallback();
            this.focusNewPanelCallback = undefined;
        }
    };
    /**
     * Adds a new panel based on the [template](https://surveyjs.io/form-library/documentation/api-reference/dynamic-panel-model#template).
     * @param index *(Optional)* An index at which to insert the new panel. `undefined` adds the panel to the end or inserts it after the current panel if [`displayMode`](https://surveyjs.io/form-library/documentation/api-reference/dynamic-panel-model#renderMode) is `"tab"`. A negative index (for instance, -1) adds the panel to the end in all cases, regardless of the `displayMode` value.
     * @see panelCount
     * @see panels
     * @see allowAddPanel
     * @see newPanelPosition
     */
    QuestionPanelDynamicModel.prototype.addPanel = function (index) {
        var curIndex = this.currentIndex;
        if (index === undefined) {
            index = curIndex < 0 ? this.panelCount : curIndex + 1;
        }
        if (index < 0 || index > this.panelCount) {
            index = this.panelCount;
        }
        this.updateValueOnAddingPanel(curIndex < 0 ? this.panelCount - 1 : curIndex, index);
        if (!this.isRenderModeList) {
            this.currentIndex = index;
        }
        if (this.survey)
            this.survey.dynamicPanelAdded(this);
        return this.panelsCore[index];
    };
    QuestionPanelDynamicModel.prototype.updateValueOnAddingPanel = function (prevIndex, index) {
        this.panelCount++;
        var newValue = this.value;
        if (!Array.isArray(newValue) || newValue.length !== this.panelCount)
            return;
        var hasModified = false;
        var lastIndex = this.panelCount - 1;
        if (index < lastIndex) {
            hasModified = true;
            var rec = newValue[lastIndex];
            newValue.splice(lastIndex, 1);
            newValue.splice(index, 0, rec);
        }
        if (!this.isValueEmpty(this.defaultPanelValue)) {
            hasModified = true;
            this.copyValue(newValue[index], this.defaultPanelValue);
        }
        if (this.defaultValueFromLastPanel && newValue.length > 1) {
            var fromIndex = prevIndex > -1 && prevIndex <= lastIndex ? prevIndex : lastIndex;
            hasModified = true;
            this.copyValue(newValue[index], newValue[fromIndex]);
        }
        if (hasModified) {
            this.value = newValue;
        }
    };
    QuestionPanelDynamicModel.prototype.canLeaveCurrentPanel = function () {
        return !(this.displayMode !== "list" && this.currentPanel && this.currentPanel.hasErrors(true, true));
    };
    QuestionPanelDynamicModel.prototype.copyValue = function (dest, src) {
        for (var key in src) {
            dest[key] = src[key];
        }
    };
    /**
     * Call removePanel function. Do nothing is canRemovePanel returns false. If confirmDelete set to true, it shows the confirmation dialog first.
     * @param value a panel or panel index
     * @see removePanel
     * @see confirmDelete
     * @see confirmDeleteText
     * @see canRemovePanel
     *
     */
    QuestionPanelDynamicModel.prototype.removePanelUI = function (value) {
        var _this = this;
        if (!this.canRemovePanel)
            return;
        if (this.isRequireConfirmOnDelete(value)) {
            confirmActionAsync(this.confirmDeleteText, function () { _this.removePanel(value); }, undefined, this.getLocale(), this.survey.rootElement);
        }
        else {
            this.removePanel(value);
        }
    };
    QuestionPanelDynamicModel.prototype.isRequireConfirmOnDelete = function (val) {
        if (!this.confirmDelete)
            return false;
        var index = this.getVisualPanelIndex(val);
        if (index < 0 || index >= this.visiblePanelCount)
            return false;
        var panelValue = this.visiblePanelsCore[index].getValue();
        return !this.isValueEmpty(panelValue) &&
            (this.isValueEmpty(this.defaultPanelValue) || !this.isTwoValueEquals(panelValue, this.defaultPanelValue));
    };
    /**
     * Switches Dynamic Panel to the next panel. Returns `true` in case of success, or `false` if `displayMode` is `"list"` or the current panel contains validation errors.
     * @see displayMode
     */
    QuestionPanelDynamicModel.prototype.goToNextPanel = function () {
        if (this.currentIndex < 0)
            return false;
        if (!this.canLeaveCurrentPanel())
            return false;
        this.currentIndex++;
        return true;
    };
    /**
     * Switches Dynamic Panel to the previous panel.
     */
    QuestionPanelDynamicModel.prototype.goToPrevPanel = function () {
        if (this.currentIndex < 0)
            return;
        this.currentIndex--;
    };
    QuestionPanelDynamicModel.prototype.removePanel = function (value) {
        var visIndex = this.getVisualPanelIndex(value);
        if (visIndex < 0 || visIndex >= this.visiblePanelCount)
            return;
        this.removedPanelIndex = visIndex;
        var panel = this.visiblePanelsCore[visIndex];
        var index = this.panelsCore.indexOf(panel);
        if (index < 0)
            return;
        if (this.survey && !this.survey.dynamicPanelRemoving(this, index, panel))
            return;
        this.panelsCore.splice(index, 1);
        this.updateBindings("panelCount", this.panelCount);
        var value = this.value;
        if (!value || !Array.isArray(value) || index >= value.length)
            return;
        this.isValueChangingInternally = true;
        value.splice(index, 1);
        this.value = value;
        this.updateFooterActions();
        this.fireCallback(this.panelCountChangedCallback);
        if (this.survey)
            this.survey.dynamicPanelRemoved(this, index, panel);
        this.isValueChangingInternally = false;
    };
    QuestionPanelDynamicModel.prototype.getVisualPanelIndex = function (val) {
        if (helpers_Helpers.isNumber(val))
            return val;
        var visPanels = this.visiblePanelsCore;
        for (var i = 0; i < visPanels.length; i++) {
            if (visPanels[i] === val || visPanels[i].data === val)
                return i;
        }
        return -1;
    };
    QuestionPanelDynamicModel.prototype.getPanelVisibleIndexById = function (id) {
        var visPanels = this.visiblePanelsCore;
        for (var i = 0; i < visPanels.length; i++) {
            if (visPanels[i].id === id)
                return i;
        }
        return -1;
    };
    QuestionPanelDynamicModel.prototype.locStrsChanged = function () {
        _super.prototype.locStrsChanged.call(this);
        var panels = this.panelsCore;
        for (var i = 0; i < panels.length; i++) {
            panels[i].locStrsChanged();
        }
        if (this.additionalTitleToolbar) {
            this.additionalTitleToolbar.locStrsChanged();
        }
    };
    QuestionPanelDynamicModel.prototype.clearIncorrectValues = function () {
        for (var i = 0; i < this.panelsCore.length; i++) {
            this.clearIncorrectValuesInPanel(i);
        }
    };
    QuestionPanelDynamicModel.prototype.clearErrors = function () {
        _super.prototype.clearErrors.call(this);
        for (var i = 0; i < this.panelsCore.length; i++) {
            this.panelsCore[i].clearErrors();
        }
    };
    QuestionPanelDynamicModel.prototype.getQuestionFromArray = function (name, index) {
        if (index < 0 || index >= this.panelsCore.length)
            return null;
        return this.panelsCore[index].getQuestionByName(name);
    };
    QuestionPanelDynamicModel.prototype.clearIncorrectValuesInPanel = function (index) {
        var panel = this.panelsCore[index];
        panel.clearIncorrectValues();
        var val = this.value;
        var values = !!val && index < val.length ? val[index] : null;
        if (!values)
            return;
        var isChanged = false;
        for (var key in values) {
            if (this.getSharedQuestionFromArray(key, index))
                continue;
            var q = panel.getQuestionByName(key);
            if (!!q)
                continue;
            if (this.iscorrectValueWithPostPrefix(panel, key, settings.commentSuffix) ||
                this.iscorrectValueWithPostPrefix(panel, key, settings.matrix.totalsSuffix))
                continue;
            delete values[key];
            isChanged = true;
        }
        if (isChanged) {
            val[index] = values;
            this.value = val;
        }
    };
    QuestionPanelDynamicModel.prototype.iscorrectValueWithPostPrefix = function (panel, key, postPrefix) {
        if (key.indexOf(postPrefix) !== key.length - postPrefix.length)
            return false;
        return !!panel.getQuestionByName(key.substring(0, key.indexOf(postPrefix)));
    };
    QuestionPanelDynamicModel.prototype.getSharedQuestionFromArray = function (name, panelIndex) {
        return !!this.survey && !!this.valueName
            ? (this.survey.getQuestionByValueNameFromArray(this.valueName, name, panelIndex))
            : null;
    };
    QuestionPanelDynamicModel.prototype.addConditionObjectsByContext = function (objects, context) {
        var hasContext = !!context
            ? context === true || this.template.questions.indexOf(context) > -1
            : false;
        var panelObjs = new Array();
        var questions = this.template.questions;
        for (var i = 0; i < questions.length; i++) {
            questions[i].addConditionObjectsByContext(panelObjs, context);
        }
        for (var index = 0; index < settings.panel.maxPanelCountInCondition; index++) {
            var indexStr = "[" + index + "].";
            var prefixName = this.getValueName() + indexStr;
            var prefixText = this.processedTitle + indexStr;
            for (var i = 0; i < panelObjs.length; i++) {
                if (!!panelObjs[i].context) {
                    objects.push(panelObjs[i]);
                }
                else {
                    objects.push({
                        name: prefixName + panelObjs[i].name,
                        text: prefixText + panelObjs[i].text,
                        question: panelObjs[i].question,
                    });
                }
            }
        }
        if (hasContext) {
            var prefixName = context === true ? this.getValueName() + "." : "";
            var prefixText = context === true ? this.processedTitle + "." : "";
            for (var i = 0; i < panelObjs.length; i++) {
                if (panelObjs[i].question == context)
                    continue;
                var obj = {
                    name: prefixName + question_paneldynamic_QuestionPanelDynamicItem.ItemVariableName + "." + panelObjs[i].name,
                    text: prefixText + question_paneldynamic_QuestionPanelDynamicItem.ItemVariableName + "." + panelObjs[i].text,
                    question: panelObjs[i].question
                };
                obj.context = this;
                objects.push(obj);
            }
        }
    };
    QuestionPanelDynamicModel.prototype.collectNestedQuestionsCore = function (questions, visibleOnly) {
        var panels = visibleOnly ? this.visiblePanelsCore : this.panelsCore;
        if (!Array.isArray(panels))
            return;
        panels.forEach(function (panel) {
            panel.questions.forEach(function (q) { return q.collectNestedQuestions(questions, visibleOnly); });
        });
    };
    QuestionPanelDynamicModel.prototype.getConditionJson = function (operator, path) {
        if (operator === void 0) { operator = null; }
        if (path === void 0) { path = null; }
        if (!path)
            return _super.prototype.getConditionJson.call(this, operator);
        var questionName = path;
        var pos = path.indexOf(".");
        if (pos > -1) {
            questionName = path.substring(0, pos);
            path = path.substring(pos + 1);
        }
        var question = this.template.getQuestionByName(questionName);
        if (!question)
            return null;
        return question.getConditionJson(operator, path);
    };
    QuestionPanelDynamicModel.prototype.onReadOnlyChanged = function () {
        var readOnly = this.isReadOnly;
        this.template.readOnly = readOnly;
        for (var i = 0; i < this.panelsCore.length; i++) {
            this.panelsCore[i].readOnly = readOnly;
        }
        this.updateNoEntriesTextDefaultLoc();
        this.updateFooterActions();
        _super.prototype.onReadOnlyChanged.call(this);
    };
    QuestionPanelDynamicModel.prototype.updateNoEntriesTextDefaultLoc = function () {
        var loc = this.getLocalizableString("noEntriesText");
        if (!loc)
            return;
        loc.localizationName = (this.isReadOnly || !this.allowAddPanel) ? "noEntriesReadonlyText" : "noEntriesText";
        loc.strChanged();
    };
    QuestionPanelDynamicModel.prototype.onSurveyLoad = function () {
        this.template.readOnly = this.isReadOnly;
        this.template.onSurveyLoad();
        this.buildPanelsFirstTime();
        _super.prototype.onSurveyLoad.call(this);
    };
    QuestionPanelDynamicModel.prototype.buildPanelsFirstTime = function (force) {
        if (force === void 0) { force = false; }
        if (this.hasPanelBuildFirstTime)
            return;
        if (!force && this.wasNotRenderedInSurvey)
            return;
        this.blockAnimations();
        this.hasPanelBuildFirstTime = true;
        this.isBuildingPanelsFirstTime = true;
        if (this.getPropertyValue("panelCount") > 0) {
            this.panelCount = this.getPropertyValue("panelCount");
        }
        if (this.useTemplatePanel) {
            this.rebuildPanels();
        }
        this.setPanelsSurveyImpl();
        this.setPanelsState();
        this.assignOnPropertyChangedToTemplate();
        if (!!this.survey) {
            for (var i = 0; i < this.panelCount; i++) {
                this.survey.dynamicPanelAdded(this);
            }
        }
        this.updateIsReady();
        if (this.isReadOnly || !this.allowAddPanel) {
            this.updateNoEntriesTextDefaultLoc();
        }
        this.updateFooterActions();
        this.isBuildingPanelsFirstTime = false;
        this.releaseAnimations();
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "wasNotRenderedInSurvey", {
        get: function () {
            return !this.hasPanelBuildFirstTime && !this.wasRendered && !!this.survey;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "canBuildPanels", {
        get: function () {
            return !this.isLoadingFromJson && !this.useTemplatePanel;
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.onFirstRendering = function () {
        _super.prototype.onFirstRendering.call(this);
        this.buildPanelsFirstTime();
        this.template.onFirstRendering();
        for (var i = 0; i < this.panelsCore.length; i++) {
            this.panelsCore[i].onFirstRendering();
        }
    };
    QuestionPanelDynamicModel.prototype.localeChanged = function () {
        _super.prototype.localeChanged.call(this);
        for (var i = 0; i < this.panelsCore.length; i++) {
            this.panelsCore[i].localeChanged();
        }
    };
    QuestionPanelDynamicModel.prototype.runCondition = function (values, properties) {
        _super.prototype.runCondition.call(this, values, properties);
        this.runPanelsCondition(this.panelsCore, values, properties);
    };
    QuestionPanelDynamicModel.prototype.runTriggers = function (name, value) {
        _super.prototype.runTriggers.call(this, name, value);
        this.visiblePanelsCore.forEach(function (p) {
            p.questions.forEach(function (q) { return q.runTriggers(name, value); });
        });
    };
    QuestionPanelDynamicModel.prototype.reRunCondition = function () {
        if (!this.data)
            return;
        this.runCondition(this.getDataFilteredValues(), this.getDataFilteredProperties());
    };
    QuestionPanelDynamicModel.prototype.runPanelsCondition = function (panels, values, properties) {
        var cachedValues = {};
        if (values && values instanceof Object) {
            cachedValues = JSON.parse(JSON.stringify(values));
        }
        if (!!this.parentQuestion && !!this.parent) {
            cachedValues[question_paneldynamic_QuestionPanelDynamicItem.ParentItemVariableName] = this.parent.getValue();
        }
        this.isValueChangingInternally = true;
        for (var i = 0; i < panels.length; i++) {
            var panel = panels[i];
            var panelValues = this.getPanelItemData(panel.data);
            //Should be unique for every panel due async expression support
            var newValues = helpers_Helpers.createCopy(cachedValues);
            var panelName = question_paneldynamic_QuestionPanelDynamicItem.ItemVariableName;
            newValues[panelName] = panelValues;
            newValues[question_paneldynamic_QuestionPanelDynamicItem.IndexVariableName.toLowerCase()] = i;
            var newProps = helpers_Helpers.createCopy(properties);
            newProps[panelName] = panel;
            panel.runCondition(newValues, newProps);
        }
        this.isValueChangingInternally = false;
    };
    QuestionPanelDynamicModel.prototype.onAnyValueChanged = function (name, questionName) {
        _super.prototype.onAnyValueChanged.call(this, name, questionName);
        for (var i = 0; i < this.panelsCore.length; i++) {
            this.panelsCore[i].onAnyValueChanged(name, questionName);
            this.panelsCore[i].onAnyValueChanged(question_paneldynamic_QuestionPanelDynamicItem.ItemVariableName, "");
        }
    };
    QuestionPanelDynamicModel.prototype.hasKeysDuplicated = function (fireCallback, rec) {
        if (rec === void 0) { rec = null; }
        var keyValues = [];
        var res;
        for (var i = 0; i < this.panelsCore.length; i++) {
            res =
                this.isValueDuplicated(this.panelsCore[i], keyValues, rec, fireCallback) ||
                    res;
        }
        return res;
    };
    QuestionPanelDynamicModel.prototype.updatePanelsContainsErrors = function () {
        var question = this.changingValueQuestion;
        var parent = question.parent;
        while (!!parent) {
            parent.updateContainsErrors();
            parent = parent.parent;
        }
        this.updateContainsErrors();
    };
    QuestionPanelDynamicModel.prototype.hasErrors = function (fireCallback, rec) {
        if (fireCallback === void 0) { fireCallback = true; }
        if (rec === void 0) { rec = null; }
        if (this.isValueChangingInternally || this.isBuildingPanelsFirstTime)
            return false;
        var res = false;
        if (!!this.changingValueQuestion) {
            var res = this.changingValueQuestion.hasErrors(fireCallback, rec);
            res = this.hasKeysDuplicated(fireCallback, rec) || res;
            this.updatePanelsContainsErrors();
        }
        else {
            res = this.hasErrorInPanels(fireCallback, rec);
        }
        return _super.prototype.hasErrors.call(this, fireCallback, rec) || res;
    };
    QuestionPanelDynamicModel.prototype.getContainsErrors = function () {
        var res = _super.prototype.getContainsErrors.call(this);
        if (res)
            return res;
        var panels = this.panelsCore;
        for (var i = 0; i < panels.length; i++) {
            if (panels[i].containsErrors)
                return true;
        }
        return false;
    };
    QuestionPanelDynamicModel.prototype.getIsAnswered = function () {
        if (!_super.prototype.getIsAnswered.call(this))
            return false;
        var panels = this.visiblePanelsCore;
        for (var i = 0; i < panels.length; i++) {
            var visibleQuestions = [];
            panels[i].addQuestionsToList(visibleQuestions, true);
            for (var j = 0; j < visibleQuestions.length; j++) {
                if (!visibleQuestions[j].isAnswered)
                    return false;
            }
        }
        return true;
    };
    QuestionPanelDynamicModel.prototype.clearValueOnHidding = function (isClearOnHidden) {
        if (!isClearOnHidden) {
            if (!!this.survey && this.survey.getQuestionClearIfInvisible("onHidden") === "none")
                return;
            this.clearValueInPanelsIfInvisible("onHiddenContainer");
        }
        _super.prototype.clearValueOnHidding.call(this, isClearOnHidden);
    };
    QuestionPanelDynamicModel.prototype.clearValueIfInvisible = function (reason) {
        if (reason === void 0) { reason = "onHidden"; }
        var panelReason = reason === "onHidden" ? "onHiddenContainer" : reason;
        this.clearValueInPanelsIfInvisible(panelReason);
        _super.prototype.clearValueIfInvisible.call(this, reason);
    };
    QuestionPanelDynamicModel.prototype.clearValueInPanelsIfInvisible = function (reason) {
        for (var i = 0; i < this.panelsCore.length; i++) {
            var panel = this.panelsCore[i];
            var questions = panel.questions;
            this.isSetPanelItemData = {};
            for (var j = 0; j < questions.length; j++) {
                var q = questions[j];
                if (q.visible && !panel.isVisible)
                    continue;
                q.clearValueIfInvisible(reason);
                this.isSetPanelItemData[q.getValueName()] = this.maxCheckCount + 1;
            }
        }
        this.isSetPanelItemData = {};
    };
    QuestionPanelDynamicModel.prototype.getIsRunningValidators = function () {
        if (_super.prototype.getIsRunningValidators.call(this))
            return true;
        for (var i = 0; i < this.panelsCore.length; i++) {
            var questions = this.panelsCore[i].questions;
            for (var j = 0; j < questions.length; j++) {
                if (questions[j].isRunningValidators)
                    return true;
            }
        }
        return false;
    };
    QuestionPanelDynamicModel.prototype.getAllErrors = function () {
        var result = _super.prototype.getAllErrors.call(this);
        var panels = this.visiblePanelsCore;
        for (var i = 0; i < panels.length; i++) {
            var questions = panels[i].questions;
            for (var j = 0; j < questions.length; j++) {
                var errors = questions[j].getAllErrors();
                if (errors && errors.length > 0) {
                    result = result.concat(errors);
                }
            }
        }
        return result;
    };
    QuestionPanelDynamicModel.prototype.getDisplayValueCore = function (keysAsText, value) {
        var values = this.getUnbindValue(value);
        if (!values || !Array.isArray(values))
            return values;
        for (var i = 0; i < this.panelsCore.length && i < values.length; i++) {
            var val = values[i];
            if (!val)
                continue;
            values[i] = this.getPanelDisplayValue(i, val, keysAsText);
        }
        return values;
    };
    QuestionPanelDynamicModel.prototype.getPanelDisplayValue = function (panelIndex, val, keysAsText) {
        if (!val)
            return val;
        var panel = this.panelsCore[panelIndex];
        var keys = Object.keys(val);
        for (var i = 0; i < keys.length; i++) {
            var key = keys[i];
            var question = panel.getQuestionByValueName(key);
            if (!question) {
                question = this.getSharedQuestionFromArray(key, panelIndex);
            }
            if (!!question) {
                var qValue = question.getDisplayValue(keysAsText, val[key]);
                val[key] = qValue;
                if (keysAsText && !!question.title && question.title !== key) {
                    val[question.title] = qValue;
                    delete val[key];
                }
            }
        }
        return val;
    };
    QuestionPanelDynamicModel.prototype.hasErrorInPanels = function (fireCallback, rec) {
        var res = false;
        var panels = this.visiblePanelsCore;
        var keyValues = [];
        for (var i = 0; i < panels.length; i++) {
            this.setOnCompleteAsyncInPanel(panels[i]);
        }
        for (var i = 0; i < panels.length; i++) {
            var pnlError = panels[i].hasErrors(fireCallback, !!rec && rec.focusOnFirstError, rec);
            pnlError = this.isValueDuplicated(panels[i], keyValues, rec, fireCallback) || pnlError;
            if (!this.isRenderModeList && pnlError && !res) {
                this.currentIndex = i;
            }
            res = pnlError || res;
        }
        return res;
    };
    QuestionPanelDynamicModel.prototype.setOnCompleteAsyncInPanel = function (panel) {
        var _this = this;
        var questions = panel.questions;
        for (var i = 0; i < questions.length; i++) {
            questions[i].onCompletedAsyncValidators = function (hasErrors) {
                _this.raiseOnCompletedAsyncValidators();
            };
        }
    };
    QuestionPanelDynamicModel.prototype.isValueDuplicated = function (panel, keyValues, rec, fireCallback) {
        if (!this.keyName)
            return false;
        var question = panel.getQuestionByValueName(this.keyName);
        if (!question || question.isEmpty())
            return false;
        var value = question.value;
        if (!!this.changingValueQuestion &&
            question != this.changingValueQuestion) {
            question.hasErrors(fireCallback, rec);
        }
        for (var i = 0; i < keyValues.length; i++) {
            if (value == keyValues[i]) {
                if (fireCallback) {
                    question.addError(new KeyDuplicationError(this.keyDuplicationError, this));
                }
                if (!!rec && !rec.firstErrorQuestion) {
                    rec.firstErrorQuestion = question;
                }
                return true;
            }
        }
        keyValues.push(value);
        return false;
    };
    QuestionPanelDynamicModel.prototype.getPanelActions = function (panel) {
        var _this = this;
        var actions = panel.footerActions;
        if (this.panelRemoveButtonLocation !== "right") {
            actions.push(new action_Action({
                id: "remove-panel-" + panel.id,
                component: "sv-paneldynamic-remove-btn",
                visible: new ComputedUpdater(function () { return [_this.canRemovePanel, panel.state !== "collapsed", _this.panelRemoveButtonLocation !== "right"].every(function (val) { return val === true; }); }),
                data: { question: this, panel: panel }
            }));
        }
        if (!!this.survey) {
            actions = this.survey.getUpdatedPanelFooterActions(panel, actions, this);
        }
        return actions;
    };
    QuestionPanelDynamicModel.prototype.createNewPanel = function () {
        var _this = this;
        var panel = this.createAndSetupNewPanelObject();
        var json = this.template.toJSON();
        new jsonobject_JsonObject().toObject(json, panel);
        panel.renderWidth = "100%";
        panel.updateCustomWidgets();
        new question_paneldynamic_QuestionPanelDynamicItem(this, panel);
        if (!this.isDesignMode && !this.isReadOnly && !this.isValueEmpty(panel.getValue())) {
            this.runPanelsCondition([panel], this.getDataFilteredValues(), this.getDataFilteredProperties());
        }
        panel.onFirstRendering();
        var questions = panel.questions;
        for (var i = 0; i < questions.length; i++) {
            questions[i].setParentQuestion(this);
        }
        panel.locStrsChanged();
        panel.onGetFooterActionsCallback = function () {
            return _this.getPanelActions(panel);
        };
        panel.onGetFooterToolbarCssCallback = function () { return _this.cssClasses.panelFooter; };
        panel.registerPropertyChangedHandlers(["visible"], function () {
            if (panel.visible)
                _this.onPanelAdded(panel);
            else
                _this.onPanelRemoved(panel);
            _this.updateFooterActions();
        });
        return panel;
    };
    QuestionPanelDynamicModel.prototype.createAndSetupNewPanelObject = function () {
        var _this = this;
        var panel = this.createNewPanelObject();
        panel.isInteractiveDesignElement = false;
        panel.setParentQuestion(this);
        panel.onGetQuestionTitleLocation = function () { return _this.getTemplateQuestionTitleLocation(); };
        return panel;
    };
    QuestionPanelDynamicModel.prototype.getTemplateQuestionTitleLocation = function () {
        return this.templateTitleLocation != "default"
            ? this.templateTitleLocation
            : this.getTitleLocationCore();
    };
    QuestionPanelDynamicModel.prototype.getChildErrorLocation = function (child) {
        if (this.templateErrorLocation !== "default")
            return this.templateErrorLocation;
        return _super.prototype.getChildErrorLocation.call(this, child);
    };
    QuestionPanelDynamicModel.prototype.createNewPanelObject = function () {
        return Serializer.createClass("panel");
    };
    QuestionPanelDynamicModel.prototype.setPanelCountBasedOnValue = function () {
        if (this.isValueChangingInternally || this.useTemplatePanel)
            return;
        var val = this.value;
        var newPanelCount = val && Array.isArray(val) ? val.length : 0;
        if (newPanelCount == 0 && this.getPropertyValue("panelCount") > 0) {
            newPanelCount = this.getPropertyValue("panelCount");
        }
        this.settingPanelCountBasedOnValue = true;
        this.panelCount = newPanelCount;
        this.settingPanelCountBasedOnValue = false;
    };
    QuestionPanelDynamicModel.prototype.setQuestionValue = function (newValue) {
        if (this.settingPanelCountBasedOnValue)
            return;
        _super.prototype.setQuestionValue.call(this, newValue, false);
        this.setPanelCountBasedOnValue();
        for (var i = 0; i < this.panelsCore.length; i++) {
            this.panelUpdateValueFromSurvey(this.panelsCore[i]);
        }
        this.updateIsAnswered();
    };
    QuestionPanelDynamicModel.prototype.onSurveyValueChanged = function (newValue) {
        if (newValue === undefined && this.isAllPanelsEmpty())
            return;
        _super.prototype.onSurveyValueChanged.call(this, newValue);
        for (var i = 0; i < this.panelsCore.length; i++) {
            this.panelSurveyValueChanged(this.panelsCore[i]);
        }
        if (newValue === undefined) {
            this.setValueBasedOnPanelCount();
        }
        this.updateIsReady();
    };
    QuestionPanelDynamicModel.prototype.isAllPanelsEmpty = function () {
        for (var i = 0; i < this.panelsCore.length; i++) {
            if (!helpers_Helpers.isValueEmpty(this.panelsCore[i].getValue()))
                return false;
        }
        return true;
    };
    QuestionPanelDynamicModel.prototype.panelUpdateValueFromSurvey = function (panel) {
        var questions = panel.questions;
        var values = this.getPanelItemData(panel.data);
        for (var i = 0; i < questions.length; i++) {
            var q = questions[i];
            q.updateValueFromSurvey(values[q.getValueName()]);
            q.updateCommentFromSurvey(values[q.getValueName() + settings.commentSuffix]);
            q.initDataUI();
        }
    };
    QuestionPanelDynamicModel.prototype.panelSurveyValueChanged = function (panel) {
        var questions = panel.questions;
        var values = this.getPanelItemData(panel.data);
        for (var i = 0; i < questions.length; i++) {
            var q = questions[i];
            q.onSurveyValueChanged(values[q.getValueName()]);
        }
    };
    QuestionPanelDynamicModel.prototype.onSetData = function () {
        _super.prototype.onSetData.call(this);
        if (this.useTemplatePanel) {
            this.setTemplatePanelSurveyImpl();
            this.rebuildPanels();
        }
    };
    QuestionPanelDynamicModel.prototype.isNewValueCorrect = function (val) {
        return Array.isArray(val);
    };
    //IQuestionPanelDynamicData
    QuestionPanelDynamicModel.prototype.getItemIndex = function (item) {
        var res = this.items.indexOf(item);
        return res > -1 ? res : this.items.length;
    };
    QuestionPanelDynamicModel.prototype.getVisibleItemIndex = function (item) {
        var visPanels = this.visiblePanelsCore;
        for (var i = 0; i < visPanels.length; i++) {
            if (visPanels[i].data === item)
                return i;
        }
        return visPanels.length;
    };
    QuestionPanelDynamicModel.prototype.getPanelItemData = function (item) {
        var items = this.items;
        var index = items.indexOf(item);
        var qValue = this.value;
        if (index < 0 && Array.isArray(qValue) && qValue.length > items.length) {
            index = items.length;
        }
        if (index < 0)
            return {};
        if (!qValue || !Array.isArray(qValue) || qValue.length <= index)
            return {};
        return qValue[index];
    };
    QuestionPanelDynamicModel.prototype.setPanelItemData = function (item, name, val) {
        if (this.isSetPanelItemData[name] > this.maxCheckCount)
            return;
        if (!this.isSetPanelItemData[name]) {
            this.isSetPanelItemData[name] = 0;
        }
        this.isSetPanelItemData[name]++;
        var items = this.items;
        var index = items.indexOf(item);
        if (index < 0)
            index = items.length;
        var qValue = this.getUnbindValue(this.value);
        if (!qValue || !Array.isArray(qValue)) {
            qValue = [];
        }
        if (qValue.length <= index) {
            for (var i = qValue.length; i <= index; i++) {
                qValue.push({});
            }
        }
        if (!qValue[index])
            qValue[index] = {};
        if (!this.isValueEmpty(val)) {
            qValue[index][name] = val;
        }
        else {
            delete qValue[index][name];
        }
        if (index >= 0 && index < this.panelsCore.length) {
            this.changingValueQuestion = this.panelsCore[index].getQuestionByValueName(name);
        }
        this.value = qValue;
        this.changingValueQuestion = null;
        if (this.survey) {
            var options = {
                question: this,
                panel: item.panel,
                name: name,
                itemIndex: index,
                itemValue: qValue[index],
                value: val,
            };
            this.survey.dynamicPanelItemValueChanged(this, options);
        }
        this.isSetPanelItemData[name]--;
        if (this.isSetPanelItemData[name] - 1) {
            delete this.isSetPanelItemData[name];
        }
    };
    QuestionPanelDynamicModel.prototype.getRootData = function () {
        return this.data;
    };
    QuestionPanelDynamicModel.prototype.getPlainData = function (options) {
        if (options === void 0) { options = { includeEmpty: true }; }
        var questionPlainData = _super.prototype.getPlainData.call(this, options);
        if (!!questionPlainData) {
            questionPlainData.isNode = true;
            var prevData = Array.isArray(questionPlainData.data) ? [].concat(questionPlainData.data) : [];
            questionPlainData.data = this.panels.map(function (panel, index) {
                var panelDataItem = {
                    name: panel.name || index,
                    title: panel.title || "Panel",
                    value: panel.getValue(),
                    displayValue: panel.getValue(),
                    getString: function (val) {
                        return typeof val === "object" ? JSON.stringify(val) : val;
                    },
                    isNode: true,
                    data: panel.questions
                        .map(function (question) { return question.getPlainData(options); })
                        .filter(function (d) { return !!d; }),
                };
                (options.calculations || []).forEach(function (calculation) {
                    panelDataItem[calculation.propertyName] = panel[calculation.propertyName];
                });
                return panelDataItem;
            });
            questionPlainData.data = questionPlainData.data.concat(prevData);
        }
        return questionPlainData;
    };
    QuestionPanelDynamicModel.prototype.updateElementCss = function (reNew) {
        _super.prototype.updateElementCss.call(this, reNew);
        for (var i = 0; i < this.panelsCore.length; i++) {
            var el = this.panelsCore[i];
            el.updateElementCss(reNew);
        }
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "progressText", {
        get: function () {
            var rangeMax = this.visiblePanelCount;
            return this.getLocalizationFormatString("panelDynamicProgressText", this.currentIndex + 1, rangeMax);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "progress", {
        get: function () {
            return ((this.currentIndex + 1) / this.visiblePanelCount) * 100 + "%";
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.getRootCss = function () {
        return new CssClassBuilder().append(_super.prototype.getRootCss.call(this)).append(this.cssClasses.empty, this.getShowNoEntriesPlaceholder()).toString();
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "cssHeader", {
        get: function () {
            var showTab = this.isRenderModeTab && !!this.visiblePanelCount;
            return new CssClassBuilder()
                .append(this.cssClasses.header)
                .append(this.cssClasses.headerTop, this.hasTitleOnTop || showTab)
                .append(this.cssClasses.headerTab, showTab)
                .toString();
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.getPanelWrapperCss = function (panel) {
        return new CssClassBuilder()
            .append(this.cssClasses.panelWrapper, !panel || panel.visible)
            .append(this.cssClasses.panelWrapperList, this.isRenderModeList)
            .append(this.cssClasses.panelWrapperInRow, this.panelRemoveButtonLocation === "right")
            .toString();
    };
    QuestionPanelDynamicModel.prototype.getPanelRemoveButtonCss = function () {
        return new CssClassBuilder()
            .append(this.cssClasses.button)
            .append(this.cssClasses.buttonRemove)
            .append(this.cssClasses.buttonRemoveRight, this.panelRemoveButtonLocation === "right")
            .toString();
    };
    QuestionPanelDynamicModel.prototype.getAddButtonCss = function () {
        return new CssClassBuilder()
            .append(this.cssClasses.button)
            .append(this.cssClasses.buttonAdd)
            .append(this.cssClasses.buttonAdd + "--list-mode", this.displayMode === "list")
            .toString();
    };
    QuestionPanelDynamicModel.prototype.getPrevButtonCss = function () {
        return new CssClassBuilder()
            .append(this.cssClasses.buttonPrev)
            .append(this.cssClasses.buttonPrevDisabled, !this.isPrevButtonVisible)
            .toString();
    };
    QuestionPanelDynamicModel.prototype.getNextButtonCss = function () {
        return new CssClassBuilder()
            .append(this.cssClasses.buttonNext)
            .append(this.cssClasses.buttonNextDisabled, !this.isNextButtonVisible)
            .toString();
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "noEntriesText", {
        /**
         * A text displayed when Dynamic Panel contains no entries.
         */
        get: function () {
            return this.getLocalizableStringText("noEntriesText");
        },
        set: function (val) {
            this.setLocalizableStringText("noEntriesText", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "locNoEntriesText", {
        get: function () {
            return this.getLocalizableString("noEntriesText");
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.getShowNoEntriesPlaceholder = function () {
        return !!this.cssClasses.noEntriesPlaceholder && !this.isDesignMode && this.visiblePanelCount === 0;
    };
    QuestionPanelDynamicModel.prototype.needResponsiveWidth = function () {
        var panel = this.getPanel();
        if (!!panel && panel.needResponsiveWidth())
            return true;
        return false;
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "hasAdditionalTitleToolbar", {
        get: function () {
            return this.isRenderModeTab && this.visiblePanels.length > 0;
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.getAdditionalTitleToolbar = function () {
        if (!this.isRenderModeTab)
            return null;
        if (!this.additionalTitleToolbarValue) {
            this.additionalTitleToolbarValue = new adaptive_container_AdaptiveActionContainer();
            this.additionalTitleToolbarValue.dotsItem.popupModel.showPointer = false;
            this.additionalTitleToolbarValue.dotsItem.popupModel.verticalPosition = "bottom";
            this.additionalTitleToolbarValue.dotsItem.popupModel.horizontalPosition = "center";
            this.updateElementCss(false);
        }
        return this.additionalTitleToolbarValue;
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "footerToolbar", {
        get: function () {
            if (!this.footerToolbarValue) {
                this.initFooterToolbar();
            }
            return this.footerToolbarValue;
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.updateFooterActions = function () {
        if (!!this.updateFooterActionsCallback) {
            this.updateFooterActionsCallback();
        }
    };
    QuestionPanelDynamicModel.prototype.initFooterToolbar = function () {
        var _this = this;
        this.footerToolbarValue = this.createActionContainer();
        var items = [];
        var prevTextBtn = new action_Action({
            id: "sv-pd-prev-btn",
            title: this.panelPrevText,
            action: function () {
                _this.goToPrevPanel();
            }
        });
        var nextTextBtn = new action_Action({
            id: "sv-pd-next-btn",
            title: this.panelNextText,
            action: function () {
                _this.goToNextPanel();
            }
        });
        var addBtn = new action_Action({
            id: "sv-pd-add-btn",
            component: "sv-paneldynamic-add-btn",
            data: { question: this }
        });
        var prevBtnIcon = new action_Action({
            id: "sv-prev-btn-icon",
            component: "sv-paneldynamic-prev-btn",
            data: { question: this }
        });
        var progressText = new action_Action({
            id: "sv-pd-progress-text",
            component: "sv-paneldynamic-progress-text",
            data: { question: this }
        });
        var nextBtnIcon = new action_Action({
            id: "sv-pd-next-btn-icon",
            component: "sv-paneldynamic-next-btn",
            data: { question: this }
        });
        items.push(prevTextBtn, nextTextBtn, addBtn, prevBtnIcon, progressText, nextBtnIcon);
        this.updateFooterActionsCallback = function () {
            var isLegacyNavigation = _this.legacyNavigation;
            var isRenderModeList = _this.isRenderModeList;
            var isMobile = _this.isMobile;
            var showNavigation = !isLegacyNavigation && !isRenderModeList;
            prevTextBtn.visible = showNavigation && _this.currentIndex > 0;
            nextTextBtn.visible = showNavigation && _this.currentIndex < _this.visiblePanelCount - 1;
            nextTextBtn.needSpace = isMobile && nextTextBtn.visible && prevTextBtn.visible;
            addBtn.visible = _this.canAddPanel;
            addBtn.needSpace = _this.isMobile && !nextTextBtn.visible && prevTextBtn.visible;
            progressText.visible = !_this.isRenderModeList && !isMobile;
            progressText.needSpace = !isLegacyNavigation && !_this.isMobile;
            var showLegacyNavigation = isLegacyNavigation && !isRenderModeList;
            prevBtnIcon.visible = showLegacyNavigation;
            nextBtnIcon.visible = showLegacyNavigation;
            prevBtnIcon.needSpace = showLegacyNavigation;
        };
        this.updateFooterActionsCallback();
        this.footerToolbarValue.setItems(items);
    };
    QuestionPanelDynamicModel.prototype.createTabByPanel = function (panel, visPanelIndex) {
        var _this = this;
        if (!this.isRenderModeTab)
            return;
        var locTitle = new localizablestring_LocalizableString(panel, true);
        locTitle.onGetTextCallback = function (str) {
            if (!str) {
                str = _this.locTabTitlePlaceholder.renderedHtml;
            }
            if (!_this.survey)
                return str;
            var options = {
                title: str,
                panel: panel,
                visiblePanelIndex: visPanelIndex
            };
            _this.survey.dynamicPanelGetTabTitle(_this, options);
            return options.title;
        };
        locTitle.sharedData = this.locTemplateTabTitle;
        var isActive = this.getPanelVisibleIndexById(panel.id) === this.currentIndex;
        var newItem = new action_Action({
            id: panel.id,
            pressed: isActive,
            locTitle: locTitle,
            disableHide: isActive,
            action: function () {
                _this.currentIndex = _this.getPanelVisibleIndexById(newItem.id);
            }
        });
        return newItem;
    };
    QuestionPanelDynamicModel.prototype.getAdditionalTitleToolbarCss = function (cssClasses) {
        var css = cssClasses !== null && cssClasses !== void 0 ? cssClasses : this.cssClasses;
        return new CssClassBuilder()
            .append(css.tabsRoot)
            .append(css.tabsLeft, this.tabAlign === "left")
            .append(css.tabsRight, this.tabAlign === "right")
            .append(css.tabsCenter, this.tabAlign === "center")
            .toString();
    };
    QuestionPanelDynamicModel.prototype.updateTabToolbarItemsPressedState = function () {
        if (!this.isRenderModeTab)
            return;
        if (this.currentIndex < 0 || this.currentIndex >= this.visiblePanelCount)
            return;
        var panel = this.visiblePanelsCore[this.currentIndex];
        this.additionalTitleToolbar.renderedActions.forEach(function (action) {
            var isActive = action.id === panel.id;
            action.pressed = isActive;
            action.disableHide = isActive;
            //should raise update if dimensions are not changed but action is active now
            if (action.mode === "popup" && action.disableHide) {
                action["raiseUpdate"]();
            }
        });
    };
    QuestionPanelDynamicModel.prototype.updateTabToolbar = function () {
        var _this = this;
        if (!this.isRenderModeTab)
            return;
        var items = [];
        var visPanels = this.visiblePanelsCore;
        var _loop_1 = function (i) {
            this_1.visiblePanelsCore.forEach(function (panel) { return items.push(_this.createTabByPanel(visPanels[i], i)); });
        };
        var this_1 = this;
        for (var i = 0; i < visPanels.length; i++) {
            _loop_1(i);
        }
        this.additionalTitleToolbar.setItems(items);
    };
    QuestionPanelDynamicModel.prototype.addTabFromToolbar = function (panel, index) {
        if (!this.isRenderModeTab)
            return;
        var newItem = this.createTabByPanel(panel, index);
        this.additionalTitleToolbar.actions.splice(index, 0, newItem);
        this.updateTabToolbarItemsPressedState();
    };
    QuestionPanelDynamicModel.prototype.removeTabFromToolbar = function (panel) {
        if (!this.isRenderModeTab)
            return;
        var removedItem = this.additionalTitleToolbar.getActionById(panel.id);
        if (!removedItem)
            return;
        this.additionalTitleToolbar.actions.splice(this.additionalTitleToolbar.actions.indexOf(removedItem), 1);
        this.updateTabToolbarItemsPressedState();
    };
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "showLegacyNavigation", {
        get: function () {
            return !this.isDefaultV2Theme;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(QuestionPanelDynamicModel.prototype, "showNavigation", {
        get: function () {
            if (this.isReadOnly && this.visiblePanelCount == 1)
                return false;
            return this.visiblePanelCount > 0 && !this.showLegacyNavigation && !!this.cssClasses.footer;
        },
        enumerable: false,
        configurable: true
    });
    QuestionPanelDynamicModel.prototype.showSeparator = function (index) {
        return this.isRenderModeList && index < this.renderedPanels.length - 1;
    };
    QuestionPanelDynamicModel.prototype.calcCssClasses = function (css) {
        var classes = _super.prototype.calcCssClasses.call(this, css);
        var additionalTitleToolbar = this.additionalTitleToolbar;
        if (!!additionalTitleToolbar) {
            additionalTitleToolbar.containerCss = this.getAdditionalTitleToolbarCss(classes);
            additionalTitleToolbar.cssClasses = classes.tabs;
            additionalTitleToolbar.dotsItem.cssClasses = classes.tabs;
            additionalTitleToolbar.dotsItem.popupModel.contentComponentData.model.cssClasses = css.list;
        }
        return classes;
    };
    QuestionPanelDynamicModel.maxCheckCount = 3;
    question_paneldynamic_decorate([
        propertyArray({})
    ], QuestionPanelDynamicModel.prototype, "_renderedPanels", void 0);
    question_paneldynamic_decorate([
        jsonobject_property({
            onSet: function (val, target) {
                target.fireCallback(target.renderModeChangedCallback);
                target.updatePanelView();
            }
        })
    ], QuestionPanelDynamicModel.prototype, "displayMode", void 0);
    question_paneldynamic_decorate([
        jsonobject_property({
            onSet: function (val, target) {
                target.fireCallback(target.currentIndexChangedCallback);
            }
        })
    ], QuestionPanelDynamicModel.prototype, "showProgressBar", void 0);
    question_paneldynamic_decorate([
        jsonobject_property({
            onSet: function (val, target) {
                // target.updatePanelView();
            }
        })
    ], QuestionPanelDynamicModel.prototype, "progressBarLocation", void 0);
    question_paneldynamic_decorate([
        jsonobject_property({ defaultValue: false, onSet: function (_, target) { target.updateFooterActions(); } })
    ], QuestionPanelDynamicModel.prototype, "legacyNavigation", void 0);
    return QuestionPanelDynamicModel;
}(question_Question));

Serializer.addClass("paneldynamic", [
    { name: "showCommentArea:switch", layout: "row", visible: true, category: "general" },
    {
        name: "templateElements",
        alternativeName: "questions",
        baseClassName: "question",
        visible: false,
        isLightSerializable: false
    },
    { name: "templateTitle:text", serializationProperty: "locTemplateTitle" },
    {
        name: "templateTabTitle", serializationProperty: "locTemplateTabTitle",
        visibleIf: function (obj) { return obj.displayMode === "tab"; }
    },
    {
        name: "tabTitlePlaceholder", serializationProperty: "locTabTitlePlaceholder",
        visibleIf: function (obj) { return obj.displayMode === "tab"; }
    },
    {
        name: "templateDescription:text",
        serializationProperty: "locTemplateDescription",
    },
    { name: "minWidth", defaultFunc: function () { return "auto"; } },
    { name: "noEntriesText:text", serializationProperty: "locNoEntriesText" },
    { name: "allowAddPanel:boolean", default: true },
    { name: "allowRemovePanel:boolean", default: true },
    { name: "newPanelPosition", choices: ["next", "last"], default: "last", category: "layout" },
    {
        name: "panelCount:number",
        isBindable: true,
        default: 0,
        choices: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    },
    { name: "minPanelCount:number", default: 0, minValue: 0 },
    {
        name: "maxPanelCount:number",
        default: settings.panel.maxPanelCount,
    },
    "defaultPanelValue:panelvalue",
    "defaultValueFromLastPanel:boolean",
    {
        name: "panelsState",
        default: "default",
        choices: ["default", "collapsed", "expanded", "firstExpanded"],
        visibleIf: function (obj) { return obj.displayMode === "list"; }
    },
    { name: "keyName" },
    {
        name: "keyDuplicationError",
        serializationProperty: "locKeyDuplicationError",
    },
    { name: "confirmDelete:boolean" },
    {
        name: "confirmDeleteText",
        serializationProperty: "locConfirmDeleteText",
        visibleIf: function (obj) { return obj.confirmDelete; }
    },
    {
        name: "panelAddText",
        serializationProperty: "locPanelAddText",
        visibleIf: function (obj) { return obj.allowAddPanel; }
    },
    {
        name: "panelRemoveText",
        serializationProperty: "locPanelRemoveText",
        visibleIf: function (obj) { return obj.allowRemovePanel; }
    },
    {
        name: "panelPrevText",
        serializationProperty: "locPanelPrevText",
        visibleIf: function (obj) { return obj.displayMode !== "list"; }
    },
    {
        name: "panelNextText",
        serializationProperty: "locPanelNextText",
        visibleIf: function (obj) { return obj.displayMode !== "list"; }
    },
    {
        name: "showQuestionNumbers",
        default: "off",
        choices: ["off", "onPanel", "onSurvey"],
    },
    {
        name: "showRangeInProgress:boolean",
        default: true,
        visible: false
        // visibleIf: (obj: any) => { return obj.displayMode !== "list"; }
    },
    {
        name: "renderMode",
        default: "list",
        choices: ["list", "progressTop", "progressBottom", "progressTopBottom", "tab"],
        visible: false,
    },
    { name: "displayMode", default: "list", choices: ["list", "carousel", "tab"] },
    {
        name: "showProgressBar:boolean",
        default: true,
        visibleIf: function (obj) { return obj.displayMode === "carousel"; }
    },
    {
        name: "progressBarLocation",
        default: "top",
        choices: ["top", "bottom", "topBottom"],
        visibleIf: function (obj) { return obj.showProgressBar; }
    },
    {
        name: "tabAlign", default: "center", choices: ["left", "center", "right"],
        visibleIf: function (obj) { return obj.displayMode === "tab"; }
    },
    {
        name: "templateTitleLocation",
        default: "default",
        choices: ["default", "top", "bottom", "left"],
    },
    { name: "templateErrorLocation", default: "default", choices: ["default", "top", "bottom"] },
    {
        name: "templateVisibleIf:expression",
        category: "logic"
    },
    {
        name: "panelRemoveButtonLocation",
        default: "bottom",
        choices: ["bottom", "right"],
        visibleIf: function (obj) { return obj.allowRemovePanel; }
    },
], function () {
    return new question_paneldynamic_QuestionPanelDynamicModel("");
}, "question");
questionfactory_QuestionFactory.Instance.registerQuestion("paneldynamic", function (name) {
    return new question_paneldynamic_QuestionPanelDynamicModel(name);
});

// CONCATENATED MODULE: ./packages/survey-core/src/surveyProgress.ts

var surveyProgress_SurveyProgressModel = /** @class */ (function () {
    function SurveyProgressModel() {
    }
    SurveyProgressModel.getProgressTextInBarCss = function (css) {
        return new CssClassBuilder()
            .append(css.progressText)
            .append(css.progressTextInBar)
            .toString();
    };
    SurveyProgressModel.getProgressTextUnderBarCss = function (css) {
        return new CssClassBuilder()
            .append(css.progressText)
            .append(css.progressTextUnderBar)
            .toString();
    };
    return SurveyProgressModel;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/themes.ts


// CONCATENATED MODULE: ./packages/survey-core/src/survey-events-api.ts


// CONCATENATED MODULE: ./packages/survey-core/src/trigger.ts
var trigger_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();







/**
 * A base class for all triggers.
 * A trigger calls a method when the expression change the result: from false to true or from true to false.
 * Please note, it runs only one changing the expression result.
 */
var trigger_Trigger = /** @class */ (function (_super) {
    trigger_extends(Trigger, _super);
    function Trigger() {
        var _this = _super.call(this) || this;
        _this.idValue = (Trigger.idCounter++);
        _this.registerPropertyChangedHandlers(["operator", "value", "name"], function () {
            _this.oldPropertiesChanged();
        });
        _this.registerPropertyChangedHandlers(["expression"], function () { _this.onExpressionChanged(); });
        return _this;
    }
    Object.defineProperty(Trigger, "operators", {
        get: function () {
            if (Trigger.operatorsValue != null)
                return Trigger.operatorsValue;
            Trigger.operatorsValue = {
                empty: function (value, expectedValue) {
                    return !value;
                },
                notempty: function (value, expectedValue) {
                    return !!value;
                },
                equal: function (value, expectedValue) {
                    return value == expectedValue;
                },
                notequal: function (value, expectedValue) {
                    return value != expectedValue;
                },
                contains: function (value, expectedValue) {
                    return value && value["indexOf"] && value.indexOf(expectedValue) > -1;
                },
                notcontains: function (value, expectedValue) {
                    return (!value || !value["indexOf"] || value.indexOf(expectedValue) == -1);
                },
                greater: function (value, expectedValue) {
                    return value > expectedValue;
                },
                less: function (value, expectedValue) {
                    return value < expectedValue;
                },
                greaterorequal: function (value, expectedValue) {
                    return value >= expectedValue;
                },
                lessorequal: function (value, expectedValue) {
                    return value <= expectedValue;
                },
            };
            return Trigger.operatorsValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Trigger.prototype, "id", {
        get: function () { return this.idValue; },
        enumerable: false,
        configurable: true
    });
    Trigger.prototype.getType = function () {
        return "triggerbase";
    };
    Trigger.prototype.toString = function () {
        var res = this.getType().replace("trigger", "");
        var exp = !!this.expression ? this.expression : this.buildExpression();
        if (exp) {
            res += ", " + exp;
        }
        return res;
    };
    Object.defineProperty(Trigger.prototype, "isInternal", {
        get: function () {
            return this.isGhost === true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Trigger.prototype, "operator", {
        get: function () {
            return this.getPropertyValue("operator", "equal");
        },
        set: function (value) {
            if (!value)
                return;
            value = value.toLowerCase();
            if (!Trigger.operators[value])
                return;
            this.setPropertyValue("operator", value);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Trigger.prototype, "value", {
        get: function () {
            return this.getPropertyValue("value", null);
        },
        set: function (val) {
            this.setPropertyValue("value", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Trigger.prototype, "name", {
        get: function () {
            return this.getPropertyValue("name", "");
        },
        set: function (val) {
            this.setPropertyValue("name", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Trigger.prototype, "expression", {
        get: function () {
            return this.getPropertyValue("expression", "");
        },
        set: function (val) {
            this.setPropertyValue("expression", val);
        },
        enumerable: false,
        configurable: true
    });
    Trigger.prototype.canBeExecuted = function (isOnNextPage) {
        return true;
    };
    Trigger.prototype.canBeExecutedOnComplete = function () {
        return false;
    };
    Trigger.prototype.checkExpression = function (isOnNextPage, isOnComplete, keys, values, properties) {
        if (properties === void 0) { properties = null; }
        this.isExecutingOnNextPage = isOnNextPage;
        if (!this.canBeExecuted(isOnNextPage))
            return;
        if (isOnComplete && !this.canBeExecutedOnComplete())
            return;
        if (!this.isCheckRequired(keys))
            return;
        if (!!this.conditionRunner) {
            this.perform(values, properties);
        }
        else {
            if (this.canSuccessOnEmptyExpression()) {
                this.triggerResult(true, values, properties);
            }
        }
    };
    Trigger.prototype.canSuccessOnEmptyExpression = function () { return false; };
    Trigger.prototype.check = function (value) {
        var triggerResult = Trigger.operators[this.operator](value, this.value);
        if (triggerResult) {
            this.onSuccess({}, null);
        }
        else {
            this.onFailure();
        }
    };
    Object.defineProperty(Trigger.prototype, "requireValidQuestion", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Trigger.prototype.perform = function (values, properties) {
        var _this = this;
        this.conditionRunner.onRunComplete = function (res) {
            _this.triggerResult(res, values, properties);
        };
        this.conditionRunner.run(values, properties);
    };
    Trigger.prototype.triggerResult = function (res, values, properties) {
        if (res) {
            this.onSuccess(values, properties);
            this.onSuccessExecuted();
        }
        else {
            this.onFailure();
        }
    };
    Trigger.prototype.onSuccess = function (values, properties) { };
    Trigger.prototype.onFailure = function () { };
    Trigger.prototype.onSuccessExecuted = function () { };
    Trigger.prototype.endLoadingFromJson = function () {
        _super.prototype.endLoadingFromJson.call(this);
        this.oldPropertiesChanged();
    };
    Trigger.prototype.oldPropertiesChanged = function () {
        this.onExpressionChanged();
    };
    Trigger.prototype.onExpressionChanged = function () {
        this.conditionRunner = null;
    };
    Trigger.prototype.buildExpression = function () {
        if (!this.name)
            return "";
        if (this.isValueEmpty(this.value) && this.isRequireValue)
            return "";
        return ("{" +
            this.name +
            "} " +
            this.operator +
            " " +
            expressions_OperandMaker.toOperandString(this.value));
    };
    Trigger.prototype.isCheckRequired = function (keys) {
        if (!keys)
            return false;
        this.createConditionRunner();
        if (this.conditionRunner && this.conditionRunner.hasFunction() === true)
            return true;
        return new conditionProcessValue_ProcessValue().isAnyKeyChanged(keys, this.getUsedVariables());
    };
    Trigger.prototype.getUsedVariables = function () {
        if (!this.conditionRunner)
            return [];
        var res = this.conditionRunner.getVariables();
        if (Array.isArray(res)) {
            var unw = "-unwrapped";
            for (var i = res.length - 1; i >= 0; i--) {
                var s = res[i];
                if (s.endsWith(unw)) {
                    res.push(s.substring(0, s.length - unw.length));
                }
            }
        }
        return res;
    };
    Trigger.prototype.createConditionRunner = function () {
        if (!!this.conditionRunner)
            return;
        var expression = this.expression;
        if (!expression) {
            expression = this.buildExpression();
        }
        if (!expression)
            return;
        this.conditionRunner = new ConditionRunner(expression);
    };
    Object.defineProperty(Trigger.prototype, "isRequireValue", {
        get: function () {
            return this.operator !== "empty" && this.operator != "notempty";
        },
        enumerable: false,
        configurable: true
    });
    Trigger.idCounter = 1;
    Trigger.operatorsValue = null;
    return Trigger;
}(base_Base));

/**
 * It extends the Trigger base class and add properties required for SurveyJS classes.
 */
var SurveyTrigger = /** @class */ (function (_super) {
    trigger_extends(SurveyTrigger, _super);
    function SurveyTrigger() {
        var _this = _super.call(this) || this;
        _this.ownerValue = null;
        return _this;
    }
    Object.defineProperty(SurveyTrigger.prototype, "owner", {
        get: function () {
            return this.ownerValue;
        },
        enumerable: false,
        configurable: true
    });
    SurveyTrigger.prototype.setOwner = function (owner) {
        this.ownerValue = owner;
    };
    SurveyTrigger.prototype.getSurvey = function (live) {
        if (live === void 0) { live = false; }
        return !!this.owner && !!this.owner["getSurvey"]
            ? this.owner.getSurvey()
            : null;
    };
    SurveyTrigger.prototype.isRealExecution = function () {
        return true;
    };
    SurveyTrigger.prototype.onSuccessExecuted = function () {
        if (!!this.owner && this.isRealExecution()) {
            this.owner.triggerExecuted(this);
        }
    };
    return SurveyTrigger;
}(trigger_Trigger));

/**
 * If expression returns true, it makes questions/pages visible.
 * Ohterwise it makes them invisible.
 */
var SurveyTriggerVisible = /** @class */ (function (_super) {
    trigger_extends(SurveyTriggerVisible, _super);
    function SurveyTriggerVisible() {
        var _this = _super.call(this) || this;
        _this.pages = [];
        _this.questions = [];
        return _this;
    }
    SurveyTriggerVisible.prototype.getType = function () {
        return "visibletrigger";
    };
    SurveyTriggerVisible.prototype.onSuccess = function (values, properties) {
        this.onTrigger(this.onItemSuccess);
    };
    SurveyTriggerVisible.prototype.onFailure = function () {
        this.onTrigger(this.onItemFailure);
    };
    SurveyTriggerVisible.prototype.onTrigger = function (func) {
        if (!this.owner)
            return;
        var objects = this.owner.getObjects(this.pages, this.questions);
        for (var i = 0; i < objects.length; i++) {
            func(objects[i]);
        }
    };
    SurveyTriggerVisible.prototype.onItemSuccess = function (item) {
        item.visible = true;
    };
    SurveyTriggerVisible.prototype.onItemFailure = function (item) {
        item.visible = false;
    };
    return SurveyTriggerVisible;
}(SurveyTrigger));

/**
 * If expression returns true, it completes the survey.
 */
var trigger_SurveyTriggerComplete = /** @class */ (function (_super) {
    trigger_extends(SurveyTriggerComplete, _super);
    function SurveyTriggerComplete() {
        return _super.call(this) || this;
    }
    SurveyTriggerComplete.prototype.getType = function () {
        return "completetrigger";
    };
    Object.defineProperty(SurveyTriggerComplete.prototype, "requireValidQuestion", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    SurveyTriggerComplete.prototype.isRealExecution = function () {
        return !settings.triggers.executeCompleteOnValueChanged === this.isExecutingOnNextPage;
    };
    SurveyTriggerComplete.prototype.onSuccess = function (values, properties) {
        if (!this.owner)
            return;
        if (this.isRealExecution()) {
            this.owner.setCompleted(this);
        }
        else {
            this.owner.canBeCompleted(this, true);
        }
    };
    SurveyTriggerComplete.prototype.onFailure = function () {
        this.owner.canBeCompleted(this, false);
    };
    return SurveyTriggerComplete;
}(SurveyTrigger));

/**
 * If expression returns true, the value from property **setValue** will be set to **setToName**
 */
var SurveyTriggerSetValue = /** @class */ (function (_super) {
    trigger_extends(SurveyTriggerSetValue, _super);
    function SurveyTriggerSetValue() {
        return _super.call(this) || this;
    }
    SurveyTriggerSetValue.prototype.getType = function () {
        return "setvaluetrigger";
    };
    SurveyTriggerSetValue.prototype.canBeExecuted = function (isOnNextPage) {
        return !isOnNextPage && !!this.setToName;
    };
    SurveyTriggerSetValue.prototype.onPropertyValueChanged = function (name, oldValue, newValue) {
        _super.prototype.onPropertyValueChanged.call(this, name, oldValue, newValue);
        if (name !== "setToName")
            return;
        var survey = this.getSurvey();
        if (survey && !survey.isLoadingFromJson && survey.isDesignMode) {
            this.setValue = undefined;
        }
    };
    Object.defineProperty(SurveyTriggerSetValue.prototype, "setToName", {
        get: function () {
            return this.getPropertyValue("setToName", "");
        },
        set: function (val) {
            this.setPropertyValue("setToName", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyTriggerSetValue.prototype, "setValue", {
        get: function () {
            return this.getPropertyValue("setValue");
        },
        set: function (val) {
            this.setPropertyValue("setValue", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyTriggerSetValue.prototype, "isVariable", {
        get: function () {
            return this.getPropertyValue("isVariable");
        },
        set: function (val) {
            this.setPropertyValue("isVariable", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyTriggerSetValue.prototype.onSuccess = function (values, properties) {
        if (!this.setToName || !this.owner)
            return;
        this.owner.setTriggerValue(this.setToName, this.setValue, this.isVariable);
    };
    return SurveyTriggerSetValue;
}(SurveyTrigger));

/**
 * If expression returns true, the survey go to question **gotoName** and focus it.
 */
var trigger_SurveyTriggerSkip = /** @class */ (function (_super) {
    trigger_extends(SurveyTriggerSkip, _super);
    function SurveyTriggerSkip() {
        return _super.call(this) || this;
    }
    SurveyTriggerSkip.prototype.getType = function () {
        return "skiptrigger";
    };
    Object.defineProperty(SurveyTriggerSkip.prototype, "requireValidQuestion", {
        get: function () { return this.canBeExecuted(false); },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyTriggerSkip.prototype, "gotoName", {
        get: function () {
            return this.getPropertyValue("gotoName", "");
        },
        set: function (val) {
            this.setPropertyValue("gotoName", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyTriggerSkip.prototype.canBeExecuted = function (isOnNextPage) {
        return isOnNextPage === !settings.triggers.executeSkipOnValueChanged;
    };
    SurveyTriggerSkip.prototype.onSuccess = function (values, properties) {
        if (!this.gotoName || !this.owner)
            return;
        this.owner.focusQuestion(this.gotoName);
    };
    return SurveyTriggerSkip;
}(SurveyTrigger));

/**
 * If expression returns true, the **runExpression** will be run. If **setToName** property is not empty then the result of **runExpression** will be set to it.
 */
var trigger_SurveyTriggerRunExpression = /** @class */ (function (_super) {
    trigger_extends(SurveyTriggerRunExpression, _super);
    function SurveyTriggerRunExpression() {
        return _super.call(this) || this;
    }
    SurveyTriggerRunExpression.prototype.getType = function () {
        return "runexpressiontrigger";
    };
    Object.defineProperty(SurveyTriggerRunExpression.prototype, "setToName", {
        get: function () {
            return this.getPropertyValue("setToName", "");
        },
        set: function (val) {
            this.setPropertyValue("setToName", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyTriggerRunExpression.prototype, "runExpression", {
        get: function () {
            return this.getPropertyValue("runExpression", "");
        },
        set: function (val) {
            this.setPropertyValue("runExpression", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyTriggerRunExpression.prototype.canBeExecuted = function (isOnNextPage) {
        return !isOnNextPage;
    };
    SurveyTriggerRunExpression.prototype.onSuccess = function (values, properties) {
        var _this = this;
        if (!this.owner || !this.runExpression)
            return;
        var expression = new ExpressionRunner(this.runExpression);
        if (expression.canRun) {
            expression.onRunComplete = function (res) {
                _this.onCompleteRunExpression(res);
            };
            expression.run(values, properties);
        }
    };
    SurveyTriggerRunExpression.prototype.onCompleteRunExpression = function (newValue) {
        if (!!this.setToName && newValue !== undefined) {
            this.owner.setTriggerValue(this.setToName, helpers_Helpers.convertValToQuestionVal(newValue), false);
        }
    };
    return SurveyTriggerRunExpression;
}(SurveyTrigger));

/**
 * If expression returns true, the value from question **fromName** will be set into **setToName**.
 */
var SurveyTriggerCopyValue = /** @class */ (function (_super) {
    trigger_extends(SurveyTriggerCopyValue, _super);
    function SurveyTriggerCopyValue() {
        return _super.call(this) || this;
    }
    SurveyTriggerCopyValue.prototype.canBeExecuted = function (isOnNextPage) {
        return !isOnNextPage && !!this.setToName && !!this.fromName;
    };
    Object.defineProperty(SurveyTriggerCopyValue.prototype, "setToName", {
        get: function () {
            return this.getPropertyValue("setToName", "");
        },
        set: function (val) {
            this.setPropertyValue("setToName", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyTriggerCopyValue.prototype, "fromName", {
        get: function () {
            return this.getPropertyValue("fromName", "");
        },
        set: function (val) {
            this.setPropertyValue("fromName", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SurveyTriggerCopyValue.prototype, "copyDisplayValue", {
        get: function () {
            return this.getPropertyValue("copyDisplayValue");
        },
        set: function (val) {
            this.setPropertyValue("copyDisplayValue", val);
        },
        enumerable: false,
        configurable: true
    });
    SurveyTriggerCopyValue.prototype.getType = function () {
        return "copyvaluetrigger";
    };
    SurveyTriggerCopyValue.prototype.onSuccess = function (values, properties) {
        if (!this.setToName || !this.owner)
            return;
        this.owner.copyTriggerValue(this.setToName, this.fromName, this.copyDisplayValue);
    };
    SurveyTriggerCopyValue.prototype.canSuccessOnEmptyExpression = function () { return true; };
    SurveyTriggerCopyValue.prototype.getUsedVariables = function () {
        var res = _super.prototype.getUsedVariables.call(this);
        if (res.length === 0 && !!this.fromName) {
            res.push(this.fromName);
        }
        return res;
    };
    return SurveyTriggerCopyValue;
}(SurveyTrigger));

Serializer.addClass("trigger", [
    { name: "operator", default: "equal", visible: false },
    { name: "value", visible: false },
    "expression:condition",
]);
Serializer.addClass("surveytrigger", [{ name: "name", visible: false }], null, "trigger");
Serializer.addClass("visibletrigger", ["pages:pages", "questions:questions"], function () {
    return new SurveyTriggerVisible();
}, "surveytrigger");
Serializer.addClass("completetrigger", [], function () {
    return new trigger_SurveyTriggerComplete();
}, "surveytrigger");
Serializer.addClass("setvaluetrigger", [
    { name: "!setToName:questionvalue" },
    {
        name: "setValue:triggervalue",
        dependsOn: "setToName",
        visibleIf: function (obj) {
            return !!obj && !!obj["setToName"];
        },
    },
    { name: "isVariable:boolean", visible: false },
], function () {
    return new SurveyTriggerSetValue();
}, "surveytrigger");
Serializer.addClass("copyvaluetrigger", [{ name: "!fromName:questionvalue" }, { name: "!setToName:questionvalue" },
    { name: "copyDisplayValue:boolean", visible: false }], function () {
    return new SurveyTriggerCopyValue();
}, "surveytrigger");
Serializer.addClass("skiptrigger", [{ name: "!gotoName:question" }], function () {
    return new trigger_SurveyTriggerSkip();
}, "surveytrigger");
Serializer.addClass("runexpressiontrigger", [{ name: "setToName:questionvalue" }, "runExpression:expression"], function () {
    return new trigger_SurveyTriggerRunExpression();
}, "surveytrigger");

// CONCATENATED MODULE: ./packages/survey-core/src/popup-survey.ts
var popup_survey_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var popup_survey_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};




/**
 * A class that renders a survey in a pop-up window.
 *
 * [View Demo](https://surveyjs.io/form-library/examples/popup-survey/ (linkStyle))
 */
var popup_survey_PopupSurveyModel = /** @class */ (function (_super) {
    popup_survey_extends(PopupSurveyModel, _super);
    function PopupSurveyModel(jsonObj, initialModel) {
        if (initialModel === void 0) { initialModel = null; }
        var _this = _super.call(this) || this;
        /**
         * Specifies how many seconds the pop-up window should remain open after users complete the survey.
         *
         * Default value: 0 (the window is closed immediately)
         *
         * Set this property to a negative value (for instance, -1) to keep the pop-up window open without a time limit.
         */
        _this.closeOnCompleteTimeout = 0;
        if (initialModel) {
            _this.surveyValue = initialModel;
        }
        else {
            _this.surveyValue = _this.createSurvey(jsonObj);
        }
        _this.surveyValue.fitToContainer = true;
        _this.windowElement = DomDocumentHelper.createElement("div");
        _this.survey.onComplete.add(function (survey, options) {
            _this.onSurveyComplete();
        });
        _this.registerPropertyChangedHandlers(["isShowing"], function () {
            if (!!_this.showingChangedCallback)
                _this.showingChangedCallback();
        });
        _this.registerPropertyChangedHandlers(["isExpanded"], function () {
            _this.onExpandedChanged();
        });
        _this.width = new ComputedUpdater(function () { return _this.survey.width; });
        _this.width = _this.survey.width;
        _this.updateCss();
        _this.onCreating();
        return _this;
    }
    PopupSurveyModel.prototype.onCreating = function () { };
    PopupSurveyModel.prototype.getType = function () {
        return "popupsurvey";
    };
    Object.defineProperty(PopupSurveyModel.prototype, "survey", {
        /**
         * A [`SurveyModel`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model) instance rendered in the pop-up window.
         */
        get: function () {
            return this.surveyValue;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "isShowing", {
        /**
         * Indicates whether the pop-up survey appears on the page, regardless of its [expand state](#isExpanded).
         *
         * You can set this property to `true` or `false` to control visibility of the pop-up survey. Alternatively, you can use the [`show()`](#show) and [`hide()`](#hide) methods.
         */
        get: function () {
            return this.getPropertyValue("isShowing", false);
        },
        set: function (val) {
            this.setPropertyValue("isShowing", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "isFullScreen", {
        get: function () {
            return this.getPropertyValue("isFullScreen", false);
        },
        set: function (val) {
            if (!this.isExpanded && !!val) {
                this.isExpanded = true;
            }
            this.setPropertyValue("isFullScreen", val);
            this.setCssRoot();
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Shows the pop-up survey. The survey may appear [expanded or collapsed](#isExpanded).
     *
     * As an alternative to this method, you can set the [`isShowing`](#isShowing) property to `true`.
     * @see hide
     */
    PopupSurveyModel.prototype.show = function () {
        this.isShowing = true;
    };
    /**
     * Hides the pop-up survey.
     *
     * As an alternative to this method, you can set the [`isShowing`](#isShowing) property to `false`.
     * @see show
     * @see expand
     * @see collapse
     */
    PopupSurveyModel.prototype.hide = function () {
        this.isShowing = false;
    };
    PopupSurveyModel.prototype.toggleFullScreen = function () {
        this.isFullScreen = !this.isFullScreen;
    };
    Object.defineProperty(PopupSurveyModel.prototype, "isExpanded", {
        /**
         * Indicates whether the pop-up window is expanded or collapsed.
         *
         * You can set this property to `true` or `false` to control the expand state of the pop-up survey. Alternatively, you can use the [`expand()`](#expand) and [`collapse()`](#collapse) methods.
         */
        get: function () {
            return this.getPropertyValue("isExpanded", false);
        },
        set: function (val) {
            if (!!this.isFullScreen && !val) {
                this.isFullScreen = false;
            }
            this.setPropertyValue("isExpanded", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "isCollapsed", {
        get: function () {
            return !this.isExpanded;
        },
        enumerable: false,
        configurable: true
    });
    PopupSurveyModel.prototype.onExpandedChanged = function () {
        if (!!this.expandedChangedCallback) {
            this.expandedChangedCallback();
        }
        this.updateCssButton();
    };
    Object.defineProperty(PopupSurveyModel.prototype, "title", {
        /**
         * A title for the pop-up window. If this property is undefined, the title is taken from [`SurveyModel`](#survey)'s [`title`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#title) property.
         */
        get: function () {
            return this.survey.title;
        },
        set: function (value) {
            this.survey.title = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "locTitle", {
        get: function () {
            if (this.survey.locTitle.isEmpty)
                return null;
            return this.survey.locTitle;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "locDescription", {
        get: function () {
            if (this.survey.locTitle.isEmpty)
                return null;
            return this.survey.locDescription;
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Expands the pop-up window.
     *
     * As an alternative to this method, you can set the [`isExpanded`](#isExpanded) property to `true`.
     * @see collapse
     */
    PopupSurveyModel.prototype.expand = function () {
        this.isExpanded = true;
    };
    /**
     * Collapses the pop-up window, leaving only the survey title visible.
     *
     * As an alternative to this method, you can set the [`isExpanded`](#isExpanded) property to `false`.
     * @see expand
     */
    PopupSurveyModel.prototype.collapse = function () {
        this.isExpanded = false;
    };
    PopupSurveyModel.prototype.changeExpandCollapse = function () {
        this.isExpanded = !this.isExpanded;
    };
    Object.defineProperty(PopupSurveyModel.prototype, "allowClose", {
        /**
         * Specifies whether to display a button that closes the pop-up window.
         *
         * Default value: `false`
         *
         * If you allow users to close the pop-up window, make sure to implement a UI element that opens it. This element should call the [`show()`](#show) method or enable the [`isShowing`](#isShowing) property.
         * @see expand
         * @see collapse
         * @see hide
         */
        get: function () {
            return this.getPropertyValue("allowClose", false);
        },
        set: function (val) {
            this.setPropertyValue("allowClose", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "allowFullScreen", {
        /**
         * Specifies whether to display a button that allows respondents to show the pop-up survey in full screen mode.
         *
         * Default value: `false`
         */
        get: function () {
            return this.getPropertyValue("allowFullScreen", false);
        },
        set: function (val) {
            this.setPropertyValue("allowFullScreen", val);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "css", {
        get: function () {
            return this.survey.css;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "cssButton", {
        get: function () {
            return this.getPropertyValue("cssButton", "");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "cssRoot", {
        get: function () {
            var result = this.getPropertyValue("cssRoot", "");
            if (this.isCollapsed)
                result += " " + this.getPropertyValue("cssRootCollapsedMod", "");
            return result;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "cssRootCollapsedMod", {
        get: function () {
            return this.getPropertyValue("cssRootCollapsedMod");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "cssRootContent", {
        get: function () {
            return this.getPropertyValue("cssRootContent");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "cssBody", {
        get: function () {
            return this.getPropertyValue("cssBody", "");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "cssHeaderRoot", {
        get: function () {
            return this.getPropertyValue("cssHeaderRoot", "");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "cssHeaderTitleCollapsed", {
        get: function () {
            return this.getPropertyValue("cssHeaderTitleCollapsed", "");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "cssHeaderButtonsContainer", {
        get: function () {
            return this.getPropertyValue("cssHeaderButtonsContainer", "");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "cssHeaderCollapseButton", {
        get: function () {
            return this.getPropertyValue("cssHeaderCollapseButton", "");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "cssHeaderCloseButton", {
        get: function () {
            return this.getPropertyValue("cssHeaderCloseButton", "");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "cssHeaderFullScreenButton", {
        get: function () {
            return this.getPropertyValue("cssHeaderFullScreenButton", "");
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupSurveyModel.prototype, "renderedWidth", {
        get: function () {
            var width = this.getPropertyValue("width", "60%");
            if (width && !isNaN(width))
                width = width + "px";
            return width;
        },
        enumerable: false,
        configurable: true
    });
    PopupSurveyModel.prototype.updateCss = function () {
        if (!this.css || !this.css.window)
            return;
        var cssWindow = this.css.window;
        this.setCssRoot();
        this.setPropertyValue("cssRootCollapsedMod", cssWindow.rootCollapsedMod);
        this.setPropertyValue("cssRootContent", cssWindow.rootContent);
        this.setPropertyValue("cssBody", cssWindow.body);
        var cssHeader = cssWindow.header;
        if (!cssHeader)
            return;
        this.setPropertyValue("cssHeaderRoot", cssHeader.root);
        this.setPropertyValue("cssHeaderTitleCollapsed", cssHeader.titleCollapsed);
        this.setPropertyValue("cssHeaderButtonsContainer", cssHeader.buttonsContainer);
        this.setPropertyValue("cssHeaderCollapseButton", cssHeader.collapseButton);
        this.setPropertyValue("cssHeaderCloseButton", cssHeader.closeButton);
        this.setPropertyValue("cssHeaderFullScreenButton", cssHeader.fullScreenButton);
        this.updateCssButton();
    };
    PopupSurveyModel.prototype.setCssRoot = function () {
        var cssWindow = this.css.window;
        if (this.isFullScreen) {
            this.setPropertyValue("cssRoot", cssWindow.root + " " + cssWindow.rootFullScreenMode);
        }
        else {
            this.setPropertyValue("cssRoot", cssWindow.root);
        }
    };
    PopupSurveyModel.prototype.updateCssButton = function () {
        var cssHeader = !!this.css.window ? this.css.window.header : null;
        if (!cssHeader)
            return;
        this.setCssButton(this.isExpanded ? cssHeader.buttonExpanded : cssHeader.buttonCollapsed);
    };
    PopupSurveyModel.prototype.setCssButton = function (val) {
        if (!val)
            return;
        this.setPropertyValue("cssButton", val);
    };
    PopupSurveyModel.prototype.createSurvey = function (jsonObj) {
        return new survey_SurveyModel(jsonObj);
    };
    PopupSurveyModel.prototype.onSurveyComplete = function () {
        if (this.closeOnCompleteTimeout < 0)
            return;
        if (this.closeOnCompleteTimeout == 0) {
            this.hide();
        }
        else {
            var self = this;
            var timerId = null;
            var func = function () {
                self.hide();
                clearInterval(timerId);
            };
            timerId = setInterval(func, this.closeOnCompleteTimeout * 1000);
        }
    };
    PopupSurveyModel.prototype.onScroll = function () {
        this.survey.onScroll();
    };
    popup_survey_decorate([
        jsonobject_property()
    ], PopupSurveyModel.prototype, "width", void 0);
    return PopupSurveyModel;
}(base_Base));

/**
 * Obsolete. Please use PopupSurvey
 */
var SurveyWindowModel = /** @class */ (function (_super) {
    popup_survey_extends(SurveyWindowModel, _super);
    function SurveyWindowModel() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return SurveyWindowModel;
}(popup_survey_PopupSurveyModel));


// CONCATENATED MODULE: ./packages/survey-core/src/popup-modal-view-model.ts
var popup_modal_view_model_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();

var PopupModalViewModel = /** @class */ (function (_super) {
    popup_modal_view_model_extends(PopupModalViewModel, _super);
    function PopupModalViewModel(model) {
        var _this = _super.call(this, model) || this;
        _this.onScrollOutsideCallback = function (event) {
            _this.preventScrollOuside(event, event.deltaY);
        };
        return _this;
    }
    PopupModalViewModel.prototype.getStyleClass = function () {
        return _super.prototype.getStyleClass.call(this)
            .append("sv-popup--modal", !this.isOverlay);
    };
    PopupModalViewModel.prototype.getShowFooter = function () {
        return true;
    };
    PopupModalViewModel.prototype.createFooterActionBar = function () {
        var _this = this;
        _super.prototype.createFooterActionBar.call(this);
        this.footerToolbar.containerCss = "sv-footer-action-bar";
        this.footerToolbarValue.addAction({
            id: "apply",
            visibleIndex: 20,
            title: this.applyButtonText,
            innerCss: "sv-popup__body-footer-item sv-popup__button sv-popup__button--apply sd-btn sd-btn--action",
            action: function () { _this.apply(); }
        });
    };
    Object.defineProperty(PopupModalViewModel.prototype, "applyButtonText", {
        get: function () {
            return this.getLocalizationString("modalApplyButtonText");
        },
        enumerable: false,
        configurable: true
    });
    PopupModalViewModel.prototype.apply = function () {
        if (!!this.model.onApply && !this.model.onApply())
            return;
        this.hidePopup();
    };
    PopupModalViewModel.prototype.clickOutside = function () {
        return;
    };
    PopupModalViewModel.prototype.onKeyDown = function (event) {
        if (event.key === "Escape" || event.keyCode === 27) {
            this.model.onCancel();
        }
        _super.prototype.onKeyDown.call(this, event);
    };
    PopupModalViewModel.prototype.updateOnShowing = function () {
        if (this.container) {
            this.container.addEventListener("wheel", this.onScrollOutsideCallback, { passive: false });
        }
        _super.prototype.updateOnShowing.call(this);
    };
    PopupModalViewModel.prototype.updateOnHiding = function () {
        if (this.container) {
            this.container.removeEventListener("wheel", this.onScrollOutsideCallback);
        }
        _super.prototype.updateOnHiding.call(this);
    };
    return PopupModalViewModel;
}(popup_view_model_PopupBaseViewModel));


// CONCATENATED MODULE: ./packages/survey-core/src/popup-utils.ts
var __assign = (undefined && undefined.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};




function createPopupModalViewModel(options, rootElement) {
    var _a;
    var popupOptions = __assign({}, options);
    popupOptions.verticalPosition = "top";
    popupOptions.horizontalPosition = "left";
    popupOptions.showPointer = false;
    popupOptions.isModal = true;
    popupOptions.displayMode = options.displayMode || "popup";
    var popupModel = new popup_PopupModel(options.componentName, options.data, popupOptions);
    popupModel.isFocusedContent = (_a = options.isFocusedContent) !== null && _a !== void 0 ? _a : true;
    var popupViewModel = new PopupModalViewModel(popupModel);
    if (!!rootElement && !!rootElement.appendChild) {
        var container = DomDocumentHelper.createElement("div");
        rootElement.appendChild(container);
        popupViewModel.setComponentElement(container);
    }
    if (!popupViewModel.container) {
        popupViewModel.initializePopupContainer();
    }
    var onVisibilityChangedCallback = function (sender, options) {
        if (!options.isVisible) {
            if (!!container) {
                popupViewModel.resetComponentElement();
            }
        }
        popupViewModel.onVisibilityChanged.remove(onVisibilityChangedCallback);
    };
    popupViewModel.onVisibilityChanged.add(onVisibilityChangedCallback);
    return popupViewModel;
}
function createPopupViewModel(model, targetElement) {
    if (model.isModal) {
        return new PopupModalViewModel(model);
    }
    else {
        return new popup_dropdown_view_model_PopupDropdownViewModel(model, targetElement);
    }
}

// CONCATENATED MODULE: ./packages/survey-core/src/question_buttongroup.ts
var question_buttongroup_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var question_buttongroup_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};




var question_buttongroup_ButtonGroupItemValue = /** @class */ (function (_super) {
    question_buttongroup_extends(ButtonGroupItemValue, _super);
    function ButtonGroupItemValue(value, text, typeName) {
        if (text === void 0) { text = null; }
        if (typeName === void 0) { typeName = "buttongroupitemvalue"; }
        var _this = _super.call(this, value, text, typeName) || this;
        _this.typeName = typeName;
        return _this;
    }
    ButtonGroupItemValue.prototype.getType = function () {
        return !!this.typeName ? this.typeName : "buttongroupitemvalue";
    };
    question_buttongroup_decorate([
        jsonobject_property()
    ], ButtonGroupItemValue.prototype, "iconName", void 0);
    question_buttongroup_decorate([
        jsonobject_property()
    ], ButtonGroupItemValue.prototype, "iconSize", void 0);
    question_buttongroup_decorate([
        jsonobject_property()
    ], ButtonGroupItemValue.prototype, "showCaption", void 0);
    return ButtonGroupItemValue;
}(itemvalue_ItemValue));

/**
 * A Model for a button group question.
 */
var QuestionButtonGroupModel = /** @class */ (function (_super) {
    question_buttongroup_extends(QuestionButtonGroupModel, _super);
    function QuestionButtonGroupModel(name) {
        return _super.call(this, name) || this;
    }
    QuestionButtonGroupModel.prototype.getType = function () {
        return "buttongroup";
    };
    QuestionButtonGroupModel.prototype.getItemValueType = function () {
        return "buttongroupitemvalue";
    };
    QuestionButtonGroupModel.prototype.supportOther = function () {
        return false;
    };
    return QuestionButtonGroupModel;
}(QuestionCheckboxBase));

Serializer.addClass("buttongroup", [
    {
        name: "choices:buttongroupitemvalue[]",
    },
], function () {
    return new QuestionButtonGroupModel("");
}, "checkboxbase");
Serializer.addClass("buttongroupitemvalue", [
    { name: "showCaption:boolean", default: true },
    { name: "iconName:text" },
    { name: "iconSize:number" },
], function (value) { return new question_buttongroup_ButtonGroupItemValue(value); }, "itemvalue");
// QuestionFactory.Instance.registerQuestion("buttongroup", name => {
//   var q = new QuestionButtonGroupModel(name);
//   q.choices = QuestionFactory.DefaultChoices;
//   return q;
// });
var question_buttongroup_ButtonGroupItemModel = /** @class */ (function () {
    function ButtonGroupItemModel(question, item, index) {
        this.question = question;
        this.item = item;
        this.index = index;
    }
    Object.defineProperty(ButtonGroupItemModel.prototype, "value", {
        get: function () {
            return this.item.value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ButtonGroupItemModel.prototype, "iconName", {
        get: function () {
            return this.item.iconName;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ButtonGroupItemModel.prototype, "iconSize", {
        get: function () {
            return this.item.iconSize || 24;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ButtonGroupItemModel.prototype, "caption", {
        get: function () {
            return this.item.locText;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ButtonGroupItemModel.prototype, "showCaption", {
        get: function () {
            return this.item.showCaption || this.item.showCaption === undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ButtonGroupItemModel.prototype, "isRequired", {
        get: function () {
            return this.question.isRequired;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ButtonGroupItemModel.prototype, "selected", {
        get: function () {
            return this.question.isItemSelected(this.item);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ButtonGroupItemModel.prototype, "readOnly", {
        get: function () {
            return this.question.isInputReadOnly || !this.item.isEnabled;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ButtonGroupItemModel.prototype, "name", {
        get: function () {
            return this.question.name + "_" + this.question.id;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ButtonGroupItemModel.prototype, "id", {
        get: function () {
            return this.question.inputId + "_" + this.index;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ButtonGroupItemModel.prototype, "hasErrors", {
        get: function () {
            return this.question.errors.length > 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ButtonGroupItemModel.prototype, "describedBy", {
        get: function () {
            return this.question.errors.length > 0
                ? this.question.id + "_errors"
                : null;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ButtonGroupItemModel.prototype, "labelClass", {
        get: function () {
            return new CssClassBuilder()
                .append(this.question.cssClasses.item)
                .append(this.question.cssClasses.itemSelected, this.selected)
                .append(this.question.cssClasses.itemHover, !this.readOnly && !this.selected)
                .append(this.question.cssClasses.itemDisabled, this.question.isReadOnly || !this.item.isEnabled)
                .toString();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ButtonGroupItemModel.prototype, "css", {
        get: function () {
            return {
                label: this.labelClass,
                icon: this.question.cssClasses.itemIcon,
                control: this.question.cssClasses.itemControl,
                caption: this.question.cssClasses.itemCaption,
                decorator: this.question.cssClasses.itemDecorator,
            };
        },
        enumerable: false,
        configurable: true
    });
    ButtonGroupItemModel.prototype.onChange = function () {
        this.question.renderedValue = this.item.value;
    };
    return ButtonGroupItemModel;
}());


// CONCATENATED MODULE: ./packages/survey-core/src/mask/mask_base.ts
var mask_base_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var mask_base_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};


/**
 * A base class for classes that implement input masks:
 *
 * - [`InputMaskNumeric`](https://surveyjs.io/form-library/documentation/inputmasknumeric)
 * - [`InputMaskCurrency`](https://surveyjs.io/form-library/documentation/inputmaskcurrency)
 * - [`InputMaskDateTime`](https://surveyjs.io/form-library/documentation/inputmaskdatetime)
 * - [`InputMaskPattern`](https://surveyjs.io/form-library/documentation/inputmaskpattern)
 */
var mask_base_InputMaskBase = /** @class */ (function (_super) {
    mask_base_extends(InputMaskBase, _super);
    function InputMaskBase() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    InputMaskBase.prototype.getSurvey = function (live) {
        if (live === void 0) { live = false; }
        return this.owner;
    };
    InputMaskBase.prototype.getType = function () {
        return "masksettings";
    };
    InputMaskBase.prototype.setData = function (json) {
        var _this = this;
        var properties = Serializer.getProperties(this.getType());
        properties.forEach(function (property) {
            var currentValue = json[property.name];
            _this[property.name] = currentValue !== undefined ? currentValue : property.defaultValue;
        });
    };
    InputMaskBase.prototype.getData = function () {
        var _this = this;
        var res = {};
        var properties = Serializer.getProperties(this.getType());
        properties.forEach(function (property) {
            var currentValue = _this[property.name];
            if (!property.isDefaultValue(currentValue)) {
                res[property.name] = currentValue;
            }
        });
        return res;
    };
    InputMaskBase.prototype.processInput = function (args) {
        return { value: args.prevValue, caretPosition: args.selectionEnd, cancelPreventDefault: false };
    };
    InputMaskBase.prototype.getUnmaskedValue = function (src) { return src; };
    InputMaskBase.prototype.getMaskedValue = function (src) { return src; };
    InputMaskBase.prototype.getTextAlignment = function () { return "auto"; };
    mask_base_decorate([
        jsonobject_property()
    ], InputMaskBase.prototype, "saveMaskedValue", void 0);
    return InputMaskBase;
}(base_Base));

Serializer.addClass("masksettings", [
    {
        name: "saveMaskedValue:boolean",
        visibleIf: function (obj) {
            if (!obj)
                return false;
            return obj.getType() !== "masksettings";
        },
    },
], function () {
    return new mask_base_InputMaskBase();
});

// CONCATENATED MODULE: ./packages/survey-core/src/mask/mask_pattern.ts
var mask_pattern_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var mask_pattern_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};



function getLiterals(pattern) {
    var result = [];
    var prevCharIsEscaped = false;
    var definitionsKeys = Object.keys(settings.maskSettings.patternDefinitions);
    for (var index = 0; index < pattern.length; index++) {
        var currentChar = pattern[index];
        if (currentChar === settings.maskSettings.patternEscapeChar) {
            prevCharIsEscaped = true;
        }
        else if (prevCharIsEscaped) {
            prevCharIsEscaped = false;
            result.push({ type: "fixed", value: currentChar });
        }
        else {
            result.push({ type: definitionsKeys.indexOf(currentChar) !== -1 ? "regex" : "const", value: currentChar });
        }
    }
    return result;
}
function getFirstMatch(str, strIndex, literal) {
    var currentDefinition = settings.maskSettings.patternDefinitions[literal.value];
    while (strIndex < str.length) {
        if (str[strIndex].match(currentDefinition)) {
            return strIndex;
        }
        strIndex++;
    }
    return strIndex;
}
function getMaskedValueByPattern(src, pattern, matchWholeMask) {
    var input = (src === undefined || src === null) ? "" : src;
    var result = "";
    var strIndex = 0;
    var literals = (typeof pattern === "string") ? getLiterals(pattern) : pattern;
    for (var maskIndex = 0; maskIndex < literals.length; maskIndex++) {
        switch (literals[maskIndex].type) {
            case "regex":
                if (strIndex < input.length) {
                    strIndex = getFirstMatch(input, strIndex, literals[maskIndex]);
                }
                if (strIndex < input.length) {
                    result += input[strIndex];
                }
                else if (matchWholeMask) {
                    result += settings.maskSettings.patternPlaceholderChar;
                }
                else {
                    return result;
                }
                strIndex++;
                break;
            case "const":
            case "fixed":
                result += literals[maskIndex].value;
                if (literals[maskIndex].value === input[strIndex]) {
                    strIndex++;
                }
                break;
        }
    }
    return result;
}
function getUnmaskedValueByPattern(str, pattern, matchWholeMask, skipFixedChar) {
    if (skipFixedChar === void 0) { skipFixedChar = false; }
    var result = "";
    if (!str)
        return result;
    var literals = (typeof pattern === "string") ? getLiterals(pattern) : pattern;
    for (var index = 0; index < literals.length; index++) {
        if (literals[index].type === "fixed" && !skipFixedChar) {
            result += literals[index].value;
        }
        if (literals[index].type === "regex") {
            var currentDefinition = settings.maskSettings.patternDefinitions[literals[index].value];
            if (!!str[index] && str[index].match(currentDefinition)) {
                result += str[index];
            }
            else if (matchWholeMask) {
                result = "";
                break;
            }
            else {
                break;
            }
        }
    }
    return result;
}
/**
 * A class that describes an input mask of the `"pattern"` [`maskType`](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model#maskType).
 *
 * The following code shows how to specify the properties of this class within a survey JSON schema:
 *
 * ```js
 * const surveyJson = {
 *   "elements": [{
 *     "name": "textquestion1"
 *     "type": "text",
 *     "maskType": "pattern",
 *     "maskSettings": {
 *       // Specify the properties of a pattern input mask here
 *     }
 *   }]
 * }
 * ```
 *
 * [View Demo](https://surveyjs.io/form-library/examples/masked-input-fields/ (linkStyle))
 */
var mask_pattern_InputMaskPattern = /** @class */ (function (_super) {
    mask_pattern_extends(InputMaskPattern, _super);
    function InputMaskPattern() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.literals = [];
        return _this;
    }
    InputMaskPattern.prototype.updateLiterals = function () {
        this.literals = getLiterals(this.pattern || "");
    };
    InputMaskPattern.prototype.onPropertyValueChanged = function (name, oldValue, newValue) {
        if (name === "pattern") {
            this.updateLiterals();
        }
    };
    InputMaskPattern.prototype.getType = function () {
        return "patternmask";
    };
    InputMaskPattern.prototype.fromJSON = function (json, options) {
        _super.prototype.fromJSON.call(this, json, options);
        this.updateLiterals();
    };
    InputMaskPattern.prototype._getMaskedValue = function (src, matchWholeMask) {
        if (matchWholeMask === void 0) { matchWholeMask = false; }
        var input = (src === undefined || src === null) ? "" : src;
        return getMaskedValueByPattern(input, this.literals, matchWholeMask);
    };
    InputMaskPattern.prototype._getUnmaskedValue = function (src, matchWholeMask) {
        if (matchWholeMask === void 0) { matchWholeMask = false; }
        var input = (src === undefined || src === null) ? "" : src;
        return getUnmaskedValueByPattern(input, this.literals, matchWholeMask);
    };
    InputMaskPattern.prototype.processInput = function (args) {
        var result = { value: args.prevValue, caretPosition: args.selectionEnd, cancelPreventDefault: false };
        if (!args.insertedChars && args.selectionStart === args.selectionEnd) {
            return result;
        }
        var leftPart = args.prevValue.slice(0, args.selectionStart) + (args.insertedChars || "");
        var leftPartUnmasked = getUnmaskedValueByPattern(args.prevValue.slice(0, args.selectionStart), this.literals.slice(0, args.selectionStart), false);
        var rightPartUnmasked = getUnmaskedValueByPattern(args.prevValue.slice(args.selectionEnd), this.literals.slice(args.selectionEnd), false, true);
        result.value = this._getMaskedValue(leftPartUnmasked + (args.insertedChars || "") + rightPartUnmasked, true);
        if (!args.insertedChars && args.inputDirection === "backward") {
            result.caretPosition = args.selectionStart;
        }
        else {
            result.caretPosition = this._getMaskedValue(leftPart).length;
        }
        return result;
    };
    InputMaskPattern.prototype.getMaskedValue = function (src) {
        return this._getMaskedValue(src, true);
    };
    InputMaskPattern.prototype.getUnmaskedValue = function (src) {
        return this._getUnmaskedValue(src, true);
    };
    mask_pattern_decorate([
        jsonobject_property()
    ], InputMaskPattern.prototype, "pattern", void 0);
    return InputMaskPattern;
}(mask_base_InputMaskBase));

Serializer.addClass("patternmask", [
    { name: "pattern" },
], function () {
    return new mask_pattern_InputMaskPattern();
}, "masksettings");

// CONCATENATED MODULE: ./packages/survey-core/src/mask/mask_numeric.ts
var mask_numeric_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var mask_numeric_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};



function splitString(str, reverse, n) {
    if (reverse === void 0) { reverse = true; }
    if (n === void 0) { n = 3; }
    var arr = [];
    if (reverse) {
        for (var i = str.length - n; i > -n; i -= n) {
            arr.push(str.substring(i, i + n));
        }
        arr = arr.reverse();
    }
    else {
        for (var i = 0; i < str.length; i += n) {
            arr.push(str.substring(i, i + n));
        }
    }
    return arr;
}
/**
 * A class that describes an input mask of the `"numeric"` [`maskType`](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model#maskType).
 *
 * The following code shows how to specify the properties of this class within a survey JSON schema:
 *
 * ```js
 * const surveyJson = {
 *   "elements": [{
 *     "name": "textquestion1"
 *     "type": "text",
 *     "maskType": "numeric",
 *     "maskSettings": {
 *       // Specify the properties of a numeric input mask here
 *     }
 *   }]
 * }
 * ```
 *
 * [View Demo](https://surveyjs.io/form-library/examples/masked-input-fields/ (linkStyle))
 */
var mask_numeric_InputMaskNumeric = /** @class */ (function (_super) {
    mask_numeric_extends(InputMaskNumeric, _super);
    function InputMaskNumeric() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    InputMaskNumeric.prototype.calccaretPosition = function (leftPart, args, maskedValue) {
        var leftPartMaskedLength = !!leftPart ? this.displayNumber(this.parseNumber(leftPart), false).length : 0;
        var validCharIndex = 0;
        var result = args.selectionStart;
        // let result = 0;
        var isDeleteKeyOperation = !args.insertedChars && args.inputDirection === "forward";
        for (var index = 0; index < maskedValue.length; index++) {
            var currentChar = maskedValue[index];
            if (currentChar !== this.thousandsSeparator) {
                validCharIndex++;
            }
            if (validCharIndex === (leftPartMaskedLength + (isDeleteKeyOperation ? 1 : 0))) {
                if (isDeleteKeyOperation) {
                    result = index;
                }
                else {
                    result = index + 1;
                }
                break;
            }
            // if (validCharIndex === leftPartMaskedLength) {
            //   result = index + 1;
            //   break;
            // }
        }
        return result;
    };
    InputMaskNumeric.prototype.numericalCompositionIsEmpty = function (number) {
        return !number.integralPart && !number.fractionalPart;
    };
    InputMaskNumeric.prototype.displayNumber = function (parsedNumber, insertThousandsSeparator, matchWholeMask) {
        if (insertThousandsSeparator === void 0) { insertThousandsSeparator = true; }
        if (matchWholeMask === void 0) { matchWholeMask = false; }
        var displayIntegralPart = parsedNumber.integralPart;
        if (insertThousandsSeparator && !!displayIntegralPart) {
            displayIntegralPart = splitString(displayIntegralPart).join(this.thousandsSeparator);
        }
        var displayFractionalPart = parsedNumber.fractionalPart;
        var minusSign = parsedNumber.isNegative ? "-" : "";
        if (displayFractionalPart === "") {
            if (matchWholeMask) {
                return (!displayIntegralPart || displayIntegralPart === "0") ? displayIntegralPart : minusSign + displayIntegralPart;
            }
            else {
                var displayDecimalSeparator = parsedNumber.hasDecimalSeparator && !matchWholeMask ? this.decimalSeparator : "";
                var src = displayIntegralPart + displayDecimalSeparator;
                return src === "0" ? src : minusSign + src;
            }
        }
        else {
            displayIntegralPart = displayIntegralPart || "0";
            displayFractionalPart = displayFractionalPart.substring(0, this.precision);
            return [minusSign + displayIntegralPart, displayFractionalPart].join(this.decimalSeparator);
        }
    };
    InputMaskNumeric.prototype.convertNumber = function (parsedNumber) {
        var value;
        var minusSign = parsedNumber.isNegative ? "-" : "";
        if (!!parsedNumber.fractionalPart) {
            value = parseFloat(minusSign + (parsedNumber.integralPart || "0") + "." + parsedNumber.fractionalPart.substring(0, this.precision));
        }
        else {
            value = parseInt(minusSign + parsedNumber.integralPart || "0");
        }
        return value;
    };
    InputMaskNumeric.prototype.validateNumber = function (number, matchWholeMask) {
        var min = this.min || Number.MIN_SAFE_INTEGER;
        var max = this.max || Number.MAX_SAFE_INTEGER;
        if (this.numericalCompositionIsEmpty(number))
            return true;
        if (this.min !== undefined || this.max !== undefined) {
            var value = this.convertNumber(number);
            if (Number.isNaN(value)) {
                return true;
            }
            if (value >= min && value <= max)
                return true;
            if (!matchWholeMask) {
                if (!number.hasDecimalSeparator && value != 0) {
                    var test_high = value;
                    var test_low = value;
                    if (value > 0) {
                        if (value + 1 > min && value <= max)
                            return true;
                        while (true) {
                            test_high = test_high * 10 + 9;
                            test_low = test_low * 10;
                            if (test_low > max) {
                                break;
                            }
                            if (test_high > min) {
                                return true;
                            }
                        }
                        return false;
                    }
                    if (value < 0) {
                        if (value >= min && value - 1 < max)
                            return true;
                        while (true) {
                            test_high = test_high * 10;
                            test_low = test_low * 10 - 9;
                            if (test_high < min) {
                                break;
                            }
                            if (test_low < max) {
                                return true;
                            }
                        }
                        return false;
                    }
                }
                else {
                    var delta = Math.pow(0.1, (number.fractionalPart || "").length);
                    if (value >= 0)
                        return value + delta > min && value <= max;
                    if (value < 0)
                        return value >= min && value - delta < max;
                }
                return value >= 0 && value <= max || value < 0 && value >= min;
            }
            return false;
        }
        return true;
    };
    InputMaskNumeric.prototype.parseNumber = function (src) {
        var result = { integralPart: "", fractionalPart: "", hasDecimalSeparator: false, isNegative: false };
        var input = (src === undefined || src === null) ? "" : src.toString();
        var minusCharCount = 0;
        for (var inputIndex = 0; inputIndex < input.length; inputIndex++) {
            var currentChar = input[inputIndex];
            switch (currentChar) {
                case "-": {
                    if (this.allowNegativeValues && (this.min === undefined || this.min < 0)) {
                        minusCharCount++;
                    }
                    break;
                }
                case this.decimalSeparator: {
                    if (this.precision > 0) {
                        result.hasDecimalSeparator = true;
                    }
                    break;
                }
                case this.thousandsSeparator: {
                    break;
                }
                default: {
                    if (currentChar.match(numberDefinition)) {
                        if (result.hasDecimalSeparator) {
                            result.fractionalPart += currentChar;
                        }
                        else {
                            result.integralPart += currentChar;
                        }
                    }
                }
            }
        }
        result.isNegative = minusCharCount % 2 !== 0;
        if (result.integralPart.length > 1 && result.integralPart[0] === "0") {
            result.integralPart = result.integralPart.slice(1);
        }
        return result;
    };
    InputMaskNumeric.prototype.getNumberMaskedValue = function (src, matchWholeMask) {
        if (matchWholeMask === void 0) { matchWholeMask = false; }
        var parsedNumber = this.parseNumber(src);
        if (!this.validateNumber(parsedNumber, matchWholeMask)) {
            return null;
        }
        var displayText = this.displayNumber(parsedNumber, true, matchWholeMask);
        return displayText;
    };
    InputMaskNumeric.prototype.getNumberUnmaskedValue = function (str) {
        var parsedNumber = this.parseNumber(str);
        if (this.numericalCompositionIsEmpty(parsedNumber))
            return undefined;
        return this.convertNumber(parsedNumber);
    };
    InputMaskNumeric.prototype.getTextAlignment = function () {
        return "right";
    };
    InputMaskNumeric.prototype.getMaskedValue = function (src) {
        var input = (src === undefined || src === null) ? "" : src.toString();
        input = input.replace(".", this.decimalSeparator);
        return this.getNumberMaskedValue(input, true);
    };
    InputMaskNumeric.prototype.getUnmaskedValue = function (src) {
        return this.getNumberUnmaskedValue(src);
    };
    InputMaskNumeric.prototype.processInput = function (args) {
        var result = { value: args.prevValue, caretPosition: args.selectionEnd, cancelPreventDefault: false };
        var leftPart = args.prevValue.slice(0, args.selectionStart) + (args.insertedChars || "");
        var rightPart = args.prevValue.slice(args.selectionEnd);
        var src = leftPart + rightPart;
        var parsedNumber = this.parseNumber(src);
        if (!this.validateNumber(parsedNumber, false)) {
            return result;
        }
        var maskedValue = this.getNumberMaskedValue(src);
        var caretPosition = this.calccaretPosition(leftPart, args, maskedValue);
        result.value = maskedValue;
        result.caretPosition = caretPosition;
        return result;
    };
    InputMaskNumeric.prototype.getType = function () {
        return "numericmask";
    };
    InputMaskNumeric.prototype.isPropertyEmpty = function (value) {
        return value === "" || value === undefined || value === null;
    };
    mask_numeric_decorate([
        jsonobject_property()
    ], InputMaskNumeric.prototype, "allowNegativeValues", void 0);
    mask_numeric_decorate([
        jsonobject_property()
    ], InputMaskNumeric.prototype, "decimalSeparator", void 0);
    mask_numeric_decorate([
        jsonobject_property()
    ], InputMaskNumeric.prototype, "precision", void 0);
    mask_numeric_decorate([
        jsonobject_property()
    ], InputMaskNumeric.prototype, "thousandsSeparator", void 0);
    mask_numeric_decorate([
        jsonobject_property()
    ], InputMaskNumeric.prototype, "min", void 0);
    mask_numeric_decorate([
        jsonobject_property()
    ], InputMaskNumeric.prototype, "max", void 0);
    return InputMaskNumeric;
}(mask_base_InputMaskBase));

Serializer.addClass("numericmask", [
    { name: "allowNegativeValues:boolean", default: true },
    { name: "decimalSeparator", default: ".", maxLength: 1 },
    { name: "thousandsSeparator", default: ",", maxLength: 1 },
    { name: "precision:number", default: 2, minValue: 0 },
    { name: "min:number" },
    { name: "max:number" },
], function () {
    return new mask_numeric_InputMaskNumeric();
}, "masksettings");

// CONCATENATED MODULE: ./packages/survey-core/src/mask/mask_datetime.ts
var mask_datetime_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var mask_datetime_assign = (undefined && undefined.__assign) || function () {
    mask_datetime_assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return mask_datetime_assign.apply(this, arguments);
};
var mask_datetime_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};



function getMaxCountLexem(currentLexemType, count) {
    switch (currentLexemType) {
        case "hour":
        case "minute":
        case "second":
        case "day":
        case "month": {
            return 2;
        }
        case "timeMarker":
        case "year": {
            return count;
        }
        default: {
            return 1;
        }
    }
}
function trimDatePart(lexem, data) {
    var result = data;
    if (lexem.count < lexem.maxCount && ((lexem.type === "day" && parseInt(data[0]) === 0) || (lexem.type === "month" && parseInt(data[0]) === 0))) {
        result = data.slice(1, data.length);
    }
    return result;
}
function getDefaultYearForValidation(minYear, maxYear) {
    var defaultVal = 2000;
    if (defaultVal > maxYear) {
        defaultVal = parseInt(maxYear.toString().slice(0, maxYear.toString().length - 2)) * 100;
    }
    if (defaultVal < minYear) {
        var middle = (maxYear - minYear) / 2 + minYear;
        defaultVal = parseInt(middle.toString().slice(0, middle.toString().length - 1)) * 10;
    }
    if (defaultVal >= minYear && defaultVal <= maxYear) {
        return defaultVal;
    }
    return minYear;
}
function getDateTimeLexems(pattern) {
    var result = [];
    var prevLexemType;
    var createOrUpdateLexem = function (currentLexemType, currentChar, upperCase) {
        if (upperCase === void 0) { upperCase = false; }
        if (!!prevLexemType && prevLexemType === currentLexemType) {
            result[result.length - 1].count++;
            var maxCount = getMaxCountLexem(currentLexemType, result[result.length - 1].count);
            result[result.length - 1].maxCount = maxCount;
        }
        else {
            var maxCount = getMaxCountLexem(currentLexemType, 1);
            // result.push({ type: currentLexemType, value: currentChar, count: 1, data: { value: "", isCompleted: false, isCorrect: false }, maxCount: maxCount });
            result.push({ type: currentLexemType, value: currentChar, count: 1, maxCount: maxCount, upperCase: upperCase });
        }
    };
    for (var index = 0; index < pattern.length; index++) {
        var currentChar = pattern[index];
        switch (currentChar) {
            case "m":
                createOrUpdateLexem("month", currentChar);
                break;
            case "d":
                createOrUpdateLexem("day", currentChar);
                break;
            case "y":
                createOrUpdateLexem("year", currentChar);
                break;
            case "h":
                createOrUpdateLexem("hour", currentChar, false);
                break;
            case "H":
                createOrUpdateLexem("hour", currentChar, true);
                break;
            case "M":
                createOrUpdateLexem("minute", currentChar);
                break;
            case "s":
                createOrUpdateLexem("second", currentChar);
                break;
            case "t":
                createOrUpdateLexem("timeMarker", currentChar);
                break;
            case "T":
                createOrUpdateLexem("timeMarker", currentChar, true);
                break;
            default:
                result.push({ type: "separator", value: currentChar, count: 1, maxCount: 1, upperCase: false });
                break;
        }
        prevLexemType = result[result.length - 1].type;
    }
    return result;
}
/**
 * A class that describes an input mask of the `"datetime"` [`maskType`](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model#maskType).
 *
 * The following code shows how to specify the properties of this class within a survey JSON schema:
 *
 * ```js
 * const surveyJson = {
 *   "elements": [{
 *     "name": "textquestion1"
 *     "type": "text",
 *     "maskType": "datetime",
 *     "maskSettings": {
 *       // Specify the properties of a date-time input mask here
 *     }
 *   }]
 * }
 * ```
 *
 * [View Demo](https://surveyjs.io/form-library/examples/masked-input-fields/ (linkStyle))
 */
var mask_datetime_InputMaskDateTime = /** @class */ (function (_super) {
    mask_datetime_extends(InputMaskDateTime, _super);
    function InputMaskDateTime() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.defaultDate = "1970-01-01T";
        _this.turnOfTheCentury = 68;
        _this.twelve = 12;
        _this.lexems = [];
        _this.inputDateTimeData = [];
        _this.validBeginningOfNumbers = {
            hour: 1,
            hourU: 2,
            minute: 5,
            second: 5,
            day: 3,
            month: 1,
        };
        return _this;
    }
    Object.defineProperty(InputMaskDateTime.prototype, "hasDatePart", {
        get: function () {
            return this.lexems.some(function (l) { return l.type === "day" || l.type === "month" || l.type === "year"; });
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(InputMaskDateTime.prototype, "hasTimePart", {
        get: function () {
            return this.lexems.some(function (l) { return l.type === "hour" || l.type === "minute" || l.type === "second"; });
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(InputMaskDateTime.prototype, "is12Hours", {
        get: function () {
            return this.lexems.filter(function (l) { return l.type === "hour" && !l.upperCase; }).length > 0;
        },
        enumerable: false,
        configurable: true
    });
    InputMaskDateTime.prototype.getType = function () {
        return "datetimemask";
    };
    InputMaskDateTime.prototype.updateLiterals = function () {
        this.lexems = getDateTimeLexems(this.pattern || "");
    };
    InputMaskDateTime.prototype.leaveOnlyNumbers = function (input) {
        var result = "";
        for (var index = 0; index < input.length; index++) {
            if (input[index].match(numberDefinition)) {
                result += input[index];
            }
        }
        return result;
    };
    InputMaskDateTime.prototype.getMaskedStrFromISO = function (str) {
        var _this = this;
        var date = new Date(str);
        this.initInputDateTimeData();
        if (!this.hasDatePart) {
            date = new Date(this.defaultDate + str);
        }
        if (!isNaN(date)) {
            this.lexems.forEach(function (lexem, index) {
                var inputData = _this.inputDateTimeData[index];
                inputData.isCompleted = true;
                switch (lexem.type) {
                    case "hour": {
                        if (!_this.is12Hours) {
                            inputData.value = date.getHours().toString();
                        }
                        else {
                            inputData.value = ((date.getHours() - 1) % _this.twelve + 1).toString();
                        }
                        break;
                    }
                    case "minute": {
                        inputData.value = date.getMinutes().toString();
                        break;
                    }
                    case "second": {
                        inputData.value = date.getSeconds().toString();
                        break;
                    }
                    case "timeMarker": {
                        var marker = (date.getHours() >= _this.twelve) ? "pm" : "am";
                        inputData.value = lexem.upperCase ? marker.toUpperCase() : marker;
                        break;
                    }
                    case "day": {
                        inputData.value = date.getDate().toString();
                        break;
                    }
                    case "month": {
                        inputData.value = (date.getMonth() + 1).toString();
                        break;
                    }
                    case "year": {
                        var year = date.getFullYear();
                        if (lexem.count == 2)
                            year = year % 100;
                        inputData.value = year.toString();
                        break;
                    }
                    default: {
                        break;
                    }
                }
            });
        }
        return this.getFormatedString(true);
    };
    InputMaskDateTime.prototype.initInputDateTimeData = function () {
        var _this = this;
        this.inputDateTimeData = [];
        this.lexems.forEach(function (lexem) {
            _this.inputDateTimeData.push({ lexem: lexem, isCompleted: false, value: undefined });
        });
    };
    InputMaskDateTime.prototype.getISO_8601Format = function (dateTime) {
        var date = [];
        var time = [];
        if (dateTime.year !== undefined) {
            var year = this.getPlaceholder(4, dateTime.year.toString(), "0") + dateTime.year;
            date.push(year);
        }
        if (dateTime.month !== undefined && dateTime.year !== undefined) {
            var month = this.getPlaceholder(2, dateTime.month.toString(), "0") + dateTime.month;
            date.push(month);
        }
        if (dateTime.day !== undefined && dateTime.month !== undefined && dateTime.year !== undefined) {
            var day = this.getPlaceholder(2, dateTime.day.toString(), "0") + dateTime.day;
            date.push(day);
        }
        if (dateTime.hour !== undefined) {
            var hour = this.getPlaceholder(2, dateTime.hour.toString(), "0") + dateTime.hour;
            time.push(hour);
        }
        if (dateTime.minute !== undefined && dateTime.hour !== undefined) {
            var minute = this.getPlaceholder(2, dateTime.minute.toString(), "0") + dateTime.minute;
            time.push(minute);
        }
        if (dateTime.second !== undefined && dateTime.minute !== undefined && dateTime.hour !== undefined) {
            var second = this.getPlaceholder(2, dateTime.second.toString(), "0") + dateTime.second;
            time.push(second);
        }
        var result = [];
        if (date.length > 0) {
            result.push(date.join("-"));
        }
        if (time.length > 1) {
            result.push(time.join(":"));
        }
        return result.join("T");
    };
    InputMaskDateTime.prototype.isYearValid = function (dateTime) {
        if (dateTime.min === undefined && dateTime.max === undefined)
            return false;
        var data = dateTime.year.toString();
        var minYearPart = dateTime.min.toISOString().slice(0, data.length);
        var maxYearPart = dateTime.max.toISOString().slice(0, data.length);
        return dateTime.year >= parseInt(minYearPart) && dateTime.year <= parseInt(maxYearPart);
    };
    InputMaskDateTime.prototype.createIDateTimeCompositionWithDefaults = function (dateTime, isUpperLimit) {
        var min = dateTime.min;
        var max = dateTime.max;
        var year = dateTime.year !== undefined ? dateTime.year : getDefaultYearForValidation(min.getFullYear(), max.getFullYear());
        var month = dateTime.month !== undefined ? dateTime.month : (isUpperLimit && this.hasDatePart ? 12 : 1);
        var day = dateTime.day !== undefined ? dateTime.day : (isUpperLimit && this.hasDatePart ? this.getMaxDateForMonth(year, month) : 1);
        var hour = dateTime.hour !== undefined ? dateTime.hour : (isUpperLimit ? 23 : 0);
        var minute = dateTime.minute !== undefined ? dateTime.minute : (isUpperLimit ? 59 : 0);
        var second = dateTime.second !== undefined ? dateTime.second : (isUpperLimit ? 59 : 0);
        return { year: year, month: month, day: day, hour: hour, minute: minute, second: second };
    };
    InputMaskDateTime.prototype.getMaxDateForMonth = function (year, month) {
        if (month == 2)
            return year % 4 == 0 && year % 100 != 0 || year % 400 ? 29 : 28;
        return [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1];
    };
    InputMaskDateTime.prototype.isDateValid = function (dateTime) {
        var min = dateTime.min;
        var max = dateTime.max;
        var year = dateTime.year !== undefined ? dateTime.year : getDefaultYearForValidation(min.getFullYear(), max.getFullYear());
        var month = dateTime.month !== undefined ? dateTime.month : 1;
        var day = dateTime.day !== undefined ? dateTime.day : 1;
        var monthIndex = month - 1;
        var date = new Date(this.getISO_8601Format(this.createIDateTimeCompositionWithDefaults(dateTime, false)));
        var dateH = new Date(this.getISO_8601Format(this.createIDateTimeCompositionWithDefaults(dateTime, true)));
        return !isNaN(date) &&
            date.getDate() === day &&
            date.getMonth() === monthIndex &&
            date.getFullYear() === year &&
            dateH >= dateTime.min && date <= dateTime.max;
    };
    InputMaskDateTime.prototype.getPlaceholder = function (lexemLength, str, char) {
        var paddingsLength = lexemLength - (str || "").length;
        var paddings = paddingsLength > 0 ? char.repeat(paddingsLength) : "";
        return paddings;
    };
    InputMaskDateTime.prototype.isDateValid12 = function (dateTime12) {
        if (!this.is12Hours)
            return this.isDateValid(dateTime12);
        if (this.is12Hours && dateTime12.hour > this.twelve) {
            return false;
        }
        if (!dateTime12.timeMarker) {
            if (this.isDateValid(dateTime12))
                return true;
            dateTime12.hour += this.twelve;
            return this.isDateValid(dateTime12);
        }
        else if (dateTime12.timeMarker[0].toLowerCase() === "p") {
            if (dateTime12.hour !== this.twelve) {
                dateTime12.hour += this.twelve;
            }
            return this.isDateValid(dateTime12);
        }
        else {
            if (dateTime12.hour === this.twelve) {
                dateTime12.hour = 0;
            }
            return this.isDateValid(dateTime12);
        }
    };
    InputMaskDateTime.prototype.updateTimeMarkerInputDateTimeData = function (newItem, dateTime) {
        var data = newItem.value;
        if (!data)
            return;
        var propertyName = "timeMarker";
        var tempDateTime = mask_datetime_assign({}, dateTime);
        tempDateTime[propertyName] = data;
        if (this.isDateValid12(tempDateTime)) {
            newItem.isCompleted = true;
        }
        else {
            data = data.slice(0, data.length - 1);
        }
        newItem.value = data || undefined;
        dateTime[propertyName] = data || undefined;
        return;
    };
    InputMaskDateTime.prototype.updateInputDateTimeData = function (newItem, dateTime) {
        var data = newItem.value;
        if (!data)
            return;
        var propertyName = newItem.lexem.type;
        var tempDateTime = mask_datetime_assign({}, dateTime);
        tempDateTime[propertyName] = parseInt(data);
        if (data.length === newItem.lexem.maxCount) {
            if (this.isDateValid12(tempDateTime)) {
                newItem.isCompleted = true;
                newItem.value = data || undefined;
                dateTime[propertyName] = parseInt(data) > 0 ? parseInt(data) : undefined;
                return;
            }
            else {
                data = data.slice(0, data.length - 1);
            }
        }
        tempDateTime[propertyName] = parseInt(data);
        var firstDigit = parseInt(data[0]);
        var validBeginningOfNumber = this.validBeginningOfNumbers[propertyName + (newItem.lexem.upperCase ? "U" : "")];
        if ((propertyName === "year" && !this.isYearValid(tempDateTime))) {
            data = data.slice(0, data.length - 1);
            newItem.isCompleted = false;
        }
        else if (validBeginningOfNumber !== undefined && firstDigit > validBeginningOfNumber) {
            if (this.isDateValid12(tempDateTime)) {
                newItem.isCompleted = true;
            }
            else {
                data = data.slice(0, data.length - 1);
            }
        }
        else if (validBeginningOfNumber !== undefined && firstDigit !== 0 && firstDigit <= validBeginningOfNumber) {
            this.checkValidationDateTimePart(tempDateTime, propertyName, newItem);
            if (newItem.isCompleted && !this.isDateValid12(tempDateTime)) {
                data = data.slice(0, data.length - 1);
            }
        }
        newItem.value = data || undefined;
        dateTime[propertyName] = parseInt(data) > 0 ? parseInt(data) : undefined;
    };
    InputMaskDateTime.prototype.checkValidationDateTimePart = function (dateTime, propertyName, newItem) {
        var prevValue = dateTime[propertyName];
        var tempValue = prevValue * 10;
        var maxValue = 10;
        if (propertyName === "month")
            maxValue = 3;
        if (propertyName === "hour")
            maxValue = this.is12Hours ? 3 : 5;
        newItem.isCompleted = true;
        for (var index = 0; index < maxValue; index++) {
            dateTime[propertyName] = tempValue + index;
            if (this.isDateValid12(dateTime)) {
                newItem.isCompleted = false;
                break;
            }
        }
        dateTime[propertyName] = prevValue;
    };
    InputMaskDateTime.prototype.getCorrectDatePartFormat = function (inputData, matchWholeMask) {
        var lexem = inputData.lexem;
        var dataStr = inputData.value || "";
        if (!!dataStr && lexem.type === "timeMarker") {
            if (matchWholeMask) {
                dataStr = dataStr + this.getPlaceholder(lexem.count, dataStr, lexem.value);
            }
            return dataStr;
        }
        if (!!dataStr && inputData.isCompleted) {
            dataStr = parseInt(dataStr).toString();
        }
        if (!!dataStr && inputData.isCompleted) {
            var zeroPaddings = this.getPlaceholder(lexem.count, dataStr, "0");
            dataStr = zeroPaddings + dataStr;
        }
        else {
            // !!!
            dataStr = trimDatePart(lexem, dataStr);
            if (matchWholeMask) {
                dataStr += this.getPlaceholder(lexem.count, dataStr, lexem.value);
            }
        }
        return dataStr;
    };
    InputMaskDateTime.prototype.createIDateTimeComposition = function () {
        var isoMin, isoMax;
        if (this.hasDatePart) {
            isoMin = this.min || "0001-01-01";
            isoMax = this.max || "9999-12-31";
        }
        else {
            isoMin = this.defaultDate + (this.min || "00:00:00");
            isoMax = this.defaultDate + (this.max || "23:59:59");
        }
        var tempDateTime = {
            hour: undefined,
            minute: undefined,
            second: undefined,
            day: undefined,
            month: undefined,
            year: undefined,
            min: new Date(isoMin),
            max: new Date(isoMax)
        };
        return tempDateTime;
    };
    InputMaskDateTime.prototype.parseTwoDigitYear = function (data) {
        var inputData = data.value;
        if (data.lexem.type !== "year" || data.lexem.count > 2)
            return inputData;
        if (!!this.max && this.max.length >= 4) {
            this.turnOfTheCentury = parseInt(this.max.slice(2, 4));
        }
        var year = parseInt(inputData);
        var result = (year > this.turnOfTheCentury ? "19" : "20") + inputData;
        return result;
    };
    InputMaskDateTime.prototype.getFormatedString = function (matchWholeMask) {
        var result = "";
        var prevSeparator = "";
        var prevIsCompleted = false;
        var lastItemWithDataIndex = this.inputDateTimeData.length - 1;
        if (!matchWholeMask) {
            var arr = this.inputDateTimeData.filter(function (item) { return !!item.value; });
            lastItemWithDataIndex = this.inputDateTimeData.indexOf(arr[arr.length - 1]);
        }
        for (var index = 0; index < this.inputDateTimeData.length; index++) {
            var inputData = this.inputDateTimeData[index];
            switch (inputData.lexem.type) {
                case "timeMarker":
                case "hour":
                case "minute":
                case "second":
                case "day":
                case "month":
                case "year":
                    if (inputData.value === undefined && !matchWholeMask) {
                        result += (prevIsCompleted ? prevSeparator : "");
                        return result;
                    }
                    else {
                        var _matchWholeMask = matchWholeMask || lastItemWithDataIndex > index;
                        var data = this.getCorrectDatePartFormat(inputData, _matchWholeMask);
                        result += (prevSeparator + data);
                        prevIsCompleted = inputData.isCompleted;
                    }
                    break;
                case "separator":
                    prevSeparator = inputData.lexem.value;
                    break;
            }
        }
        return result;
    };
    InputMaskDateTime.prototype.cleanTimeMarker = function (str, upperCase) {
        var result = "";
        str = str.toUpperCase();
        for (var i = 0; i < str.length; i++) {
            if (!result && (str[i] == "P" || str[i] == "A") || result && str[i] == "M")
                result += str[i];
        }
        if (upperCase) {
            result = result.toUpperCase();
        }
        else {
            result = result.toLowerCase();
        }
        return result;
    };
    InputMaskDateTime.prototype.setInputDateTimeData = function (numberParts) {
        var _this = this;
        var numberPartsArrayIndex = 0;
        this.initInputDateTimeData();
        this.lexems.forEach(function (lexem, index) {
            if (numberParts.length > 0 && numberPartsArrayIndex < numberParts.length) {
                if (lexem.type === "separator")
                    return;
                var inputData = _this.inputDateTimeData[index];
                var currentPart = numberParts[numberPartsArrayIndex];
                var _data = void 0;
                if (lexem.type === "timeMarker") {
                    _data = _this.cleanTimeMarker(currentPart, lexem.upperCase);
                }
                else {
                    _data = _this.leaveOnlyNumbers(currentPart);
                }
                inputData.value = _data.slice(0, lexem.maxCount);
                numberPartsArrayIndex++;
            }
        });
    };
    InputMaskDateTime.prototype._getMaskedValue = function (src, matchWholeMask) {
        var _this = this;
        if (matchWholeMask === void 0) { matchWholeMask = true; }
        var input = (src === undefined || src === null) ? "" : src.toString();
        var inputParts = this.getParts(input);
        this.setInputDateTimeData(inputParts);
        var tempDateTime = this.createIDateTimeComposition();
        this.inputDateTimeData.forEach(function (itemData) {
            if (itemData.lexem.type === "timeMarker") {
                _this.updateTimeMarkerInputDateTimeData(itemData, tempDateTime);
            }
            else {
                _this.updateInputDateTimeData(itemData, tempDateTime);
            }
        });
        var result = this.getFormatedString(matchWholeMask);
        return result;
    };
    InputMaskDateTime.prototype.getParts = function (input) {
        var inputParts = [];
        var lexemsWithValue = this.lexems.filter(function (l) { return l.type !== "separator"; });
        var separators = this.lexems.filter(function (l) { return l.type === "separator"; }).map(function (s) { return s.value; });
        var curPart = "";
        var foundSeparator = false;
        var foundPseudoSeparator = false;
        for (var i = 0; i < input.length; i++) {
            var inputChar = input[i];
            if (inputChar.match(numberDefinition) || inputChar === lexemsWithValue[inputParts.length].value) {
                foundSeparator = false;
                foundPseudoSeparator = false;
                curPart += inputChar;
            }
            else if (lexemsWithValue[inputParts.length].type === "timeMarker") {
                foundSeparator = false;
                foundPseudoSeparator = false;
                curPart += inputChar;
            }
            else {
                if (separators.indexOf(inputChar) !== -1) {
                    if (!foundPseudoSeparator) {
                        foundSeparator = true;
                        inputParts.push(curPart);
                        curPart = "";
                    }
                }
                else {
                    if (!foundSeparator) {
                        foundPseudoSeparator = true;
                        inputParts.push(curPart);
                        curPart = "";
                    }
                }
            }
            if (inputParts.length >= lexemsWithValue.length) {
                foundSeparator = false;
                break;
            }
        }
        if (curPart != "" || foundSeparator) {
            inputParts.push(curPart);
        }
        return inputParts;
    };
    InputMaskDateTime.prototype.getUnmaskedValue = function (src) {
        var _this = this;
        var _a;
        var input = (src === undefined || src === null) ? "" : src.toString();
        var inputParts = this.getParts(input);
        this.setInputDateTimeData(inputParts);
        var timeMarker = (_a = this.inputDateTimeData.filter(function (idtd) { return idtd.lexem.type === "timeMarker"; })[0]) === null || _a === void 0 ? void 0 : _a.value.toLowerCase()[0];
        var tempDateTime = this.createIDateTimeComposition();
        var uncompleted = false;
        this.inputDateTimeData.forEach(function (inputData) {
            var str = inputData.value;
            if (inputData.lexem.type == "timeMarker" || inputData.lexem.type == "separator")
                return;
            if (!str || str.length < inputData.lexem.count) {
                uncompleted = true;
                return;
            }
            var value = parseInt(_this.parseTwoDigitYear(inputData));
            if (inputData.lexem.type == "hour" && timeMarker === "p" && value != _this.twelve)
                value += _this.twelve;
            tempDateTime[inputData.lexem.type] = value;
        });
        return uncompleted ? "" : this.getISO_8601Format(tempDateTime);
    };
    InputMaskDateTime.prototype.getMaskedValue = function (src) {
        return this.getMaskedStrFromISO(src);
    };
    InputMaskDateTime.prototype.processInput = function (args) {
        var result = { value: args.prevValue, caretPosition: args.selectionEnd, cancelPreventDefault: false };
        var leftPart = args.prevValue.slice(0, args.selectionStart);
        var rightPart = args.prevValue.slice(args.selectionEnd);
        result.value = this._getMaskedValue(leftPart + (args.insertedChars || "") + rightPart);
        if (!args.insertedChars && args.inputDirection === "backward") {
            result.caretPosition = args.selectionStart;
        }
        else {
            result.caretPosition = this._getMaskedValue(leftPart + (args.insertedChars || ""), false).length;
        }
        return result;
    };
    mask_datetime_decorate([
        jsonobject_property()
    ], InputMaskDateTime.prototype, "min", void 0);
    mask_datetime_decorate([
        jsonobject_property()
    ], InputMaskDateTime.prototype, "max", void 0);
    return InputMaskDateTime;
}(mask_pattern_InputMaskPattern));

Serializer.addClass("datetimemask", [
    {
        name: "min",
        type: "datetime",
        enableIf: function (obj) {
            return !!obj.pattern;
        }
    },
    {
        name: "max",
        type: "datetime",
        enableIf: function (obj) {
            return !!obj.pattern;
        }
    }
], function () {
    return new mask_datetime_InputMaskDateTime();
}, "patternmask");

// CONCATENATED MODULE: ./packages/survey-core/src/mask/mask_currency.ts
var mask_currency_extends = (undefined && undefined.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var mask_currency_decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    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;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};


/**
 * A class that describes an input mask of the `"currency"` [`maskType`](https://surveyjs.io/form-library/documentation/api-reference/text-entry-question-model#maskType).
 *
 * The following code shows how to specify the properties of this class within a survey JSON schema:
 *
 * ```js
 * const surveyJson = {
 *   "elements": [{
 *     "name": "textquestion1"
 *     "type": "text",
 *     "maskType": "currency",
 *     "maskSettings": {
 *       // Specify the properties of a currency input mask here
 *     }
 *   }]
 * }
 * ```
 *
 * [View Demo](https://surveyjs.io/form-library/examples/masked-input-fields/ (linkStyle))
 */
var mask_currency_InputMaskCurrency = /** @class */ (function (_super) {
    mask_currency_extends(InputMaskCurrency, _super);
    function InputMaskCurrency() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    InputMaskCurrency.prototype.getType = function () {
        return "currencymask";
    };
    InputMaskCurrency.prototype.wrapText = function (str) {
        var prefixValue = this.prefix || "";
        var suffixValue = this.suffix || "";
        var result = str;
        if (!result)
            return result;
        if (result.indexOf(prefixValue) === -1) {
            result = prefixValue + result;
        }
        if (result.indexOf(suffixValue) === -1) {
            result += suffixValue;
        }
        return result;
    };
    InputMaskCurrency.prototype.unwrapInputArgs = function (args) {
        var result = args.prevValue;
        if (!result)
            return;
        if (this.prefix && result.indexOf(this.prefix) !== -1) {
            result = result.slice(result.indexOf(this.prefix) + this.prefix.length);
            var preffixPadding = (this.prefix || "").length;
            args.selectionStart = Math.max((args.selectionStart - preffixPadding), 0);
            args.selectionEnd -= preffixPadding;
        }
        if (this.suffix && result.indexOf(this.suffix) !== -1) {
            result = result.slice(0, result.indexOf(this.suffix));
        }
        args.prevValue = result;
    };
    InputMaskCurrency.prototype.processInput = function (args) {
        this.unwrapInputArgs(args);
        var result = _super.prototype.processInput.call(this, args);
        var preffixPadding = (this.prefix || "").length;
        if (!!result.value) {
            result.caretPosition += preffixPadding;
        }
        result.value = this.wrapText(result.value);
        return result;
    };
    InputMaskCurrency.prototype.getMaskedValue = function (src) {
        var result = _super.prototype.getMaskedValue.call(this, src);
        return this.wrapText(result);
    };
    mask_currency_decorate([
        jsonobject_property()
    ], InputMaskCurrency.prototype, "prefix", void 0);
    mask_currency_decorate([
        jsonobject_property()
    ], InputMaskCurrency.prototype, "suffix", void 0);
    return InputMaskCurrency;
}(mask_numeric_InputMaskNumeric));

Serializer.addClass("currencymask", [
    { name: "prefix" },
    { name: "suffix" },
], function () {
    return new mask_currency_InputMaskCurrency();
}, "numericmask");

// CONCATENATED MODULE: ./packages/survey-core/entries/chunks/model.ts
// styles
// import "../../src/main.scss";
//import "../../src/modern.scss";

var Version;
var ReleaseDate;
Version = "" + "1.11.13";
ReleaseDate = "" + "2024-08-27";
function checkLibraryVersion(ver, libraryName) {
    if (Version != ver) {
        var str = "survey-core has version '" + Version + "' and " + libraryName
            + " has version '" + ver + "'. SurveyJS libraries should have the same versions to work correctly.";
        /* eslint no-console: ["error", { allow: ["error"] }] */
        console.error(str);
    }
}
function setLicenseKey(key) {
    slk(key);
}
function slk(key) {
    _slk(key, lic, ReleaseDate);
}
function hasLicense(index) {
    return lic[index.toString()] === true;
}
var lic = {};
function _slk(k, lh, rd) {
    if (!k)
        return;
    var en = function (s) {
        var e = {}, i, b = 0, c, x, l = 0, a, r = "", w = String.fromCharCode, L = s.length;
        var A = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
        for (i = 0; i < 64; i++) {
            e[A.charAt(i)] = i;
        }
        for (x = 0; x < L; x++) {
            var c_1 = e[s.charAt(x)];
            b = (b << 6) + c_1;
            l += 6;
            while (l >= 8) {
                ((a = (b >>> (l -= 8)) & 0xff) || (x < (L - 2))) && (r += w(a));
            }
        }
        return r;
    };
    var v = en(k);
    if (!v)
        return;
    var index = v.indexOf(";");
    if (index < 0)
        return;
    if (!checkPrefix(v.substring(0, index)))
        return;
    v = v.substring(index + 1);
    v.split(",").forEach(function (s) {
        var i = s.indexOf("=");
        if (i > 0) {
            lh[s.substring(0, i)] = new Date(rd) <= new Date(s.substring(i + 1));
        }
    });
}
function checkPrefix(prefix) {
    if (!prefix)
        return true;
    var s = "domains:";
    var index = prefix.indexOf(s);
    if (index < 0)
        return true;
    var ds = prefix.substring(index + s.length).toLowerCase().split(",");
    if (!Array.isArray(ds) || ds.length === 0)
        return true;
    var location = DomWindowHelper.getLocation();
    if (!!location && !!location.hostname) {
        var hn = location.hostname.toLowerCase();
        ds.push("localhost");
        for (var i = 0; i < ds.length; i++) {
            if (hn.indexOf(ds[i]) > -1)
                return true;
        }
        return false;
    }
    return true;
}





































































// export { cultureInfo } from "../../src/cultureInfo";





















//Uncomment to include the "date" question type.
//export {default as QuestionDateModel} from "../../src/plugins/question_date";




// CONCATENATED MODULE: ./src/stylesmanager.ts





var modernThemeColors = {
    "$main-color": "#1ab394",
    "$add-button-color": "#1948b3",
    "$remove-button-color": "#ff1800",
    "$disable-color": "#dbdbdb",
    "$progress-text-color": "#9d9d9d",
    "$disabled-label-color": "rgba(64, 64, 64, 0.5)",
    "$slider-color": "white",
    "$disabled-slider-color": "#cfcfcf",
    "$error-color": "#d52901",
    "$text-color": "#404040",
    "$light-text-color": "#fff",
    "$checkmark-color": "#fff",
    "$progress-buttons-color": "#8dd9ca",
    "$inputs-background-color": "transparent",
    "$main-hover-color": "#9f9f9f",
    "$body-container-background-color": "#f4f4f4",
    "$text-border-color": "#d4d4d4",
    "$disabled-text-color": "rgba(64, 64, 64, 0.5)",
    "$border-color": "rgb(64, 64, 64, 0.5)",
    "$header-background-color": "#e7e7e7",
    "$answer-background-color": "rgba(26, 179, 148, 0.2)",
    "$error-background-color": "rgba(213, 41, 1, 0.2)",
    "$radio-checked-color": "#404040",
    "$clean-button-color": "#1948b3",
    "$body-background-color": "#ffffff",
    "$foreground-light": "#909090",
    "$font-family": "Raleway",
};
var defaultThemeColors = {
    "$header-background-color": "#e7e7e7",
    "$body-container-background-color": "#f4f4f4",
    "$main-color": "#1ab394",
    "$main-hover-color": "#0aa384",
    "$body-background-color": "white",
    "$inputs-background-color": "white",
    "$text-color": "#6d7072",
    "$text-input-color": "#6d7072",
    "$header-color": "#6d7072",
    "$border-color": "#e7e7e7",
    "$error-color": "#ed5565",
    "$error-background-color": "#fcdfe2",
    "$progress-text-color": "#9d9d9d",
    "$disable-color": "#dbdbdb",
    "$disabled-label-color": "rgba(64, 64, 64, 0.5)",
    "$slider-color": "white",
    "$disabled-switch-color": "#9f9f9f",
    "$disabled-slider-color": "#cfcfcf",
    "$foreground-light": "#909090",
    "$foreground-disabled": "#161616",
    "$background-dim": "#f3f3f3",
    "$progress-buttons-color": "#8dd9ca",
    "$progress-buttons-line-color": "#d4d4d4"
};
var orangeThemeColors = {
    "$header-background-color": "#4a4a4a",
    "$body-container-background-color": "#f8f8f8",
    "$main-color": "#f78119",
    "$main-hover-color": "#e77109",
    "$body-background-color": "white",
    "$inputs-background-color": "white",
    "$text-color": "#4a4a4a",
    "$text-input-color": "#4a4a4a",
    "$header-color": "#f78119",
    "$border-color": "#e7e7e7",
    "$error-color": "#ed5565",
    "$error-background-color": "#fcdfe2",
    "$progress-text-color": "#9d9d9d",
    "$disable-color": "#dbdbdb",
    "$disabled-label-color": "rgba(64, 64, 64, 0.5)",
    "$slider-color": "white",
    "$disabled-switch-color": "#9f9f9f",
    "$disabled-slider-color": "#cfcfcf",
    "$foreground-light": "#909090",
    "$foreground-disabled": "#161616",
    "$background-dim": "#f3f3f3",
    "$progress-buttons-color": "#f7b781",
    "$progress-buttons-line-color": "#d4d4d4"
};
var darkblueThemeColors = {
    "$header-background-color": "#d9d8dd",
    "$body-container-background-color": "#f6f7f2",
    "$main-color": "#3c4f6d",
    "$main-hover-color": "#2c3f5d",
    "$body-background-color": "white",
    "$inputs-background-color": "white",
    "$text-color": "#4a4a4a",
    "$text-input-color": "#4a4a4a",
    "$header-color": "#6d7072",
    "$border-color": "#e7e7e7",
    "$error-color": "#ed5565",
    "$error-background-color": "#fcdfe2",
    "$progress-text-color": "#9d9d9d",
    "$disable-color": "#dbdbdb",
    "$disabled-label-color": "rgba(64, 64, 64, 0.5)",
    "$slider-color": "white",
    "$disabled-switch-color": "#9f9f9f",
    "$disabled-slider-color": "#cfcfcf",
    "$foreground-light": "#909090",
    "$foreground-disabled": "#161616",
    "$background-dim": "#f3f3f3",
    "$progress-buttons-color": "#839ec9",
    "$progress-buttons-line-color": "#d4d4d4"
};
var darkroseThemeColors = {
    "$header-background-color": "#ddd2ce",
    "$body-container-background-color": "#f7efed",
    "$main-color": "#68656e",
    "$main-hover-color": "#58555e",
    "$body-background-color": "white",
    "$inputs-background-color": "white",
    "$text-color": "#4a4a4a",
    "$text-input-color": "#4a4a4a",
    "$header-color": "#6d7072",
    "$border-color": "#e7e7e7",
    "$error-color": "#ed5565",
    "$error-background-color": "#fcdfe2",
    "$progress-text-color": "#9d9d9d",
    "$disable-color": "#dbdbdb",
    "$disabled-label-color": "rgba(64, 64, 64, 0.5)",
    "$slider-color": "white",
    "$disabled-switch-color": "#9f9f9f",
    "$disabled-slider-color": "#cfcfcf",
    "$foreground-light": "#909090",
    "$foreground-disabled": "#161616",
    "$background-dim": "#f3f3f3",
    "$progress-buttons-color": "#c6bed4",
    "$progress-buttons-line-color": "#d4d4d4"
};
var stoneThemeColors = {
    "$header-background-color": "#cdccd2",
    "$body-container-background-color": "#efedf4",
    "$main-color": "#0f0f33",
    "$main-hover-color": "#191955",
    "$body-background-color": "white",
    "$inputs-background-color": "white",
    "$text-color": "#0f0f33",
    "$text-input-color": "#0f0f33",
    "$header-color": "#0f0f33",
    "$border-color": "#e7e7e7",
    "$error-color": "#ed5565",
    "$error-background-color": "#fcdfe2",
    "$progress-text-color": "#9d9d9d",
    "$disable-color": "#dbdbdb",
    "$disabled-label-color": "rgba(64, 64, 64, 0.5)",
    "$slider-color": "white",
    "$disabled-switch-color": "#9f9f9f",
    "$disabled-slider-color": "#cfcfcf",
    "$foreground-light": "#909090",
    "$foreground-disabled": "#161616",
    "$background-dim": "#f3f3f3",
    "$progress-buttons-color": "#747491",
    "$progress-buttons-line-color": "#d4d4d4"
};
var winterThemeColors = {
    "$header-background-color": "#82b8da",
    "$body-container-background-color": "#dae1e7",
    "$main-color": "#3c3b40",
    "$main-hover-color": "#1e1d20",
    "$body-background-color": "white",
    "$inputs-background-color": "white",
    "$text-color": "#000",
    "$text-input-color": "#000",
    "$header-color": "#000",
    "$border-color": "#e7e7e7",
    "$error-color": "#ed5565",
    "$error-background-color": "#fcdfe2",
    "$disable-color": "#dbdbdb",
    "$progress-text-color": "#9d9d9d",
    "$disabled-label-color": "rgba(64, 64, 64, 0.5)",
    "$slider-color": "white",
    "$disabled-switch-color": "#9f9f9f",
    "$disabled-slider-color": "#cfcfcf",
    "$foreground-light": "#909090",
    "$foreground-disabled": "#161616",
    "$background-dim": "#f3f3f3",
    "$progress-buttons-color": "#d1c9f5",
    "$progress-buttons-line-color": "#d4d4d4"
};
var winterstoneThemeColors = {
    "$header-background-color": "#323232",
    "$body-container-background-color": "#f8f8f8",
    "$main-color": "#5ac8fa",
    "$main-hover-color": "#06a1e7",
    "$body-background-color": "white",
    "$inputs-background-color": "white",
    "$text-color": "#000",
    "$text-input-color": "#000",
    "$header-color": "#000",
    "$border-color": "#e7e7e7",
    "$error-color": "#ed5565",
    "$error-background-color": "#fcdfe2",
    "$disable-color": "#dbdbdb",
    "$progress-text-color": "#9d9d9d",
    "$disabled-label-color": "rgba(64, 64, 64, 0.5)",
    "$slider-color": "white",
    "$disabled-switch-color": "#9f9f9f",
    "$disabled-slider-color": "#cfcfcf",
    "$foreground-light": "#909090",
    "$foreground-disabled": "#161616",
    "$background-dim": "#f3f3f3",
    "$progress-buttons-color": "#acdcf2",
    "$progress-buttons-line-color": "#d4d4d4"
};
function setCssVariables(vars, element) {
    Object.keys(vars || {}).forEach(function (sassVarName) {
        var name = sassVarName.substring(1);
        element.style.setProperty("--" + name, vars[sassVarName]);
    });
}
var stylesmanager_StylesManager = /** @class */ (function () {
    function StylesManager() {
        StylesManager.autoApplyTheme();
    }
    StylesManager.autoApplyTheme = function () {
        if (surveyCss.currentType === "bootstrap" || surveyCss.currentType === "bootstrapmaterial") {
            return;
        }
        var includedThemeCss = StylesManager.getIncludedThemeCss();
        if (includedThemeCss.length === 1) {
            StylesManager.applyTheme(includedThemeCss[0].name);
        }
    };
    StylesManager.getAvailableThemes = function () {
        var themeMapper = surveyCss.getAvailableThemes()
            .filter(function (themeName) { return ["defaultV2", "default", "modern"].indexOf(themeName) !== -1; })
            .map(function (themeName) { return { name: themeName, theme: surveyCss[themeName] }; });
        return themeMapper;
    };
    StylesManager.getIncludedThemeCss = function () {
        if (typeof settings.environment === "undefined")
            return [];
        var rootElement = settings.environment.rootElement;
        var themeMapper = StylesManager.getAvailableThemes();
        var element = isShadowDOM(rootElement) ? rootElement.host : rootElement;
        if (!!element) {
            var styles_1 = getComputedStyle(element);
            if (styles_1.length) {
                return themeMapper.filter(function (item) { return item.theme.variables && styles_1.getPropertyValue(item.theme.variables.themeMark); });
            }
        }
        return [];
    };
    StylesManager.findSheet = function (styleSheetId) {
        if (typeof settings.environment === "undefined")
            return null;
        var styleSheets = settings.environment.root.styleSheets;
        for (var i = 0; i < styleSheets.length; i++) {
            if (!!styleSheets[i].ownerNode && styleSheets[i].ownerNode["id"] === styleSheetId) {
                return styleSheets[i];
            }
        }
        return null;
    };
    StylesManager.createSheet = function (styleSheetId) {
        var stylesSheetsMountContainer = settings.environment.stylesSheetsMountContainer;
        var style = DomDocumentHelper.createElement("style");
        style.id = styleSheetId;
        // Add a media (and/or media query) here if you'd like!
        // style.setAttribute("media", "screen")
        // style.setAttribute("media", "only screen and (max-width : 1024px)")
        style.appendChild(new Text(""));
        getElement(stylesSheetsMountContainer).appendChild(style);
        if (!!StylesManager.Logger) {
            StylesManager.Logger.log("style sheet " + styleSheetId + " created");
        }
        return style.sheet;
    };
    StylesManager.applyTheme = function (themeName, themeSelector) {
        if (themeName === void 0) { themeName = "default"; }
        if (typeof settings.environment === "undefined")
            return;
        var rootElement = settings.environment.rootElement;
        var element = isShadowDOM(rootElement) ? rootElement.host : rootElement;
        surveyCss.currentType = themeName;
        if (StylesManager.Enabled) {
            if (themeName !== "bootstrap" && themeName !== "bootstrapmaterial") {
                setCssVariables(StylesManager.ThemeColors[themeName], element);
                if (!!StylesManager.Logger) {
                    StylesManager.Logger.log("apply theme " + themeName + " completed");
                }
                return;
            }
            var themeCss_1 = StylesManager.ThemeCss[themeName];
            if (!themeCss_1) {
                surveyCss.currentType = "defaultV2";
                return;
            }
            StylesManager.insertStylesRulesIntoDocument();
            var currentThemeSelector_1 = themeSelector || StylesManager.ThemeSelector[themeName] || StylesManager.ThemeSelector["default"];
            var styleSheetId = (themeName + currentThemeSelector_1).trim();
            var sheet_1 = StylesManager.findSheet(styleSheetId);
            if (!sheet_1) {
                sheet_1 = StylesManager.createSheet(styleSheetId);
                var themeColors_1 = StylesManager.ThemeColors[themeName] || StylesManager.ThemeColors["default"];
                Object.keys(themeCss_1).forEach(function (selector) {
                    var cssRuleText = themeCss_1[selector];
                    Object.keys(themeColors_1 || {}).forEach(function (colorVariableName) { return (cssRuleText = cssRuleText.replace(new RegExp("\\" + colorVariableName, "g"), themeColors_1[colorVariableName])); });
                    try {
                        if (selector.indexOf("body") === 0) {
                            sheet_1.insertRule(selector + " { " + cssRuleText + " }", 0);
                        }
                        else {
                            sheet_1.insertRule(currentThemeSelector_1 + selector + " { " + cssRuleText + " }", 0);
                        }
                    }
                    catch (e) { }
                });
            }
        }
        if (!!StylesManager.Logger) {
            StylesManager.Logger.log("apply theme " + themeName + " completed");
        }
    };
    StylesManager.insertStylesRulesIntoDocument = function () {
        if (StylesManager.Enabled) {
            var sheet_2 = StylesManager.findSheet(StylesManager.SurveyJSStylesSheetId);
            if (!sheet_2) {
                sheet_2 = StylesManager.createSheet(StylesManager.SurveyJSStylesSheetId);
            }
            if (Object.keys(StylesManager.Styles).length) {
                Object.keys(StylesManager.Styles).forEach(function (selector) {
                    try {
                        sheet_2.insertRule(selector + " { " + StylesManager.Styles[selector] + " }", 0);
                    }
                    catch (e) { }
                });
            }
            if (Object.keys(StylesManager.Media).length) {
                Object.keys(StylesManager.Media).forEach(function (selector) {
                    try {
                        sheet_2.insertRule(StylesManager.Media[selector].media +
                            " { " +
                            selector +
                            " { " +
                            StylesManager.Media[selector].style +
                            " } }", 0);
                    }
                    catch (e) { }
                });
            }
        }
    };
    StylesManager.SurveyJSStylesSheetId = "surveyjs-styles";
    StylesManager.Styles = {};
    StylesManager.Media = {};
    StylesManager.ThemeColors = {
        "modern": modernThemeColors,
        "default": defaultThemeColors,
        "orange": orangeThemeColors,
        "darkblue": darkblueThemeColors,
        "darkrose": darkroseThemeColors,
        "stone": stoneThemeColors,
        "winter": winterThemeColors,
        "winterstone": winterstoneThemeColors,
    };
    StylesManager.ThemeCss = {};
    StylesManager.ThemeSelector = {
        "default": ".sv_main ",
        "modern": ".sv-root-modern "
    };
    StylesManager.Enabled = true;
    return StylesManager;
}());

survey_SurveyModel.prototype["onBeforeRunConstructor"] = function () {
    if (DomWindowHelper.isAvailable()) {
        stylesmanager_StylesManager.autoApplyTheme();
    }
};

// CONCATENATED MODULE: ./src/entries/chunks/model.ts



// CONCATENATED MODULE: ./src/defaultCss/cssstandard.ts

var defaultStandardCss = {
    root: "sv_main sv_default_css",
    rootProgress: "sv_progress",
    container: "sv_container",
    header: "sv_header",
    bodyContainer: "sv-components-row",
    body: "sv_body",
    bodyEmpty: "sv_body sv_body_empty",
    footer: "sv_nav",
    title: "",
    description: "",
    logo: "sv_logo",
    logoImage: "sv_logo__image",
    headerText: "sv_header__text",
    navigationButton: "sv_nav_btn",
    completedPage: "sv_completed_page",
    navigation: {
        complete: "sv_complete_btn",
        prev: "sv_prev_btn",
        next: "sv_next_btn",
        start: "sv_start_btn",
        preview: "sv_preview_btn",
        edit: "sv_edit_btn",
    },
    progress: "sv_progress",
    progressBar: "sv_progress_bar",
    progressTextInBar: "sv-hidden",
    progressButtonsContainerCenter: "sv_progress-buttons__container-center",
    progressButtonsContainer: "sv_progress-buttons__container",
    progressButtonsImageButtonLeft: "sv_progress-buttons__image-button-left",
    progressButtonsImageButtonRight: "sv_progress-buttons__image-button-right",
    progressButtonsImageButtonHidden: "sv_progress-buttons__image-button--hidden",
    progressButtonsListContainer: "sv_progress-buttons__list-container",
    progressButtonsList: "sv_progress-buttons__list",
    progressButtonsListElementPassed: "sv_progress-buttons__list-element--passed",
    progressButtonsListElementCurrent: "sv_progress-buttons__list-element--current",
    progressButtonsListElementNonClickable: "sv_progress-buttons__list-element--nonclickable",
    progressButtonsPageTitle: "sv_progress-buttons__page-title",
    progressButtonsPageDescription: "sv_progress-buttons__page-description",
    page: {
        root: "sv_p_root",
        title: "sv_page_title",
        description: "",
    },
    // TODO: move to the page object
    pageTitle: "sv_page_title",
    pageDescription: "",
    row: "sv_row",
    question: {
        mainRoot: "sv_q sv_qstn",
        flowRoot: "sv_q_flow sv_qstn",
        header: "",
        headerLeft: "title-left",
        content: "",
        contentLeft: "content-left",
        titleLeftRoot: "sv_qstn_left",
        requiredText: "sv_q_required_text",
        title: "sv_q_title",
        titleExpandable: "sv_q_title_expandable",
        titleExpanded: "sv_q_title_expanded",
        titleCollapsed: "sv_q_title_collapsed",
        number: "sv_q_num",
        description: "sv_q_description",
        comment: "",
        required: "",
        titleRequired: "",
        hasError: "",
        indent: 20,
        footer: "sv_q_footer",
        formGroup: "form-group",
        asCell: "sv_matrix_cell",
        icon: "sv_question_icon",
        iconExpanded: "sv_expanded",
        disabled: "sv_q--disabled",
    },
    panel: {
        title: "sv_p_title",
        titleExpandable: "sv_p_title_expandable",
        titleExpanded: "sv_p_title_expanded",
        titleCollapsed: "sv_p_title_collapsed",
        titleOnError: "",
        icon: "sv_panel_icon",
        iconExpanded: "sv_expanded",
        description: "sv_p_description",
        container: "sv_p_container",
        footer: "sv_p_footer",
        number: "sv_q_num",
        requiredText: "sv_q_required_text",
    },
    error: {
        root: "sv_q_erbox",
        icon: "",
        item: "",
        locationTop: "sv_qstn_error_top",
        locationBottom: "sv_qstn_error_bottom",
    },
    boolean: {
        root: "sv_qcbc sv_qbln",
        rootRadio: "sv_qcbc sv_qbln",
        item: "sv-boolean",
        control: "sv-visuallyhidden",
        itemChecked: "sv-boolean--checked checked",
        itemIndeterminate: "sv-boolean--indeterminate",
        itemDisabled: "sv-boolean--disabled",
        switch: "sv-boolean__switch",
        slider: "sv-boolean__slider",
        label: "sv-boolean__label ",
        disabledLabel: "sv-boolean__label--disabled",
        sliderGhost: "sv-boolean__thumb-ghost",
        //checkbox
        rootCheckbox: "sv_qcbc sv_qbln",
        checkboxItem: "sv-boolean",
        checkboxItemChecked: "sv-boolean--checked",
        controlCheckbox: "sv-visuallyvisible",
        checkboxControlLabel: "sv-boolean__label",
        checkboxItemIndeterminate: "sv-boolean--indeterminate",
        checkboxItemDisabled: "sv-item--disabled sv-boolean--disabled",
        checkboxMaterialDecorator: "sv-item__decorator sv-boolean__decorator",
        checkboxItemDecorator: "sv-item__svg sv-boolean__svg",
    },
    checkbox: {
        root: "sv_qcbc sv_qcbx",
        item: "sv_q_checkbox",
        itemSelectAll: "sv_q_checkbox_selectall",
        itemNone: "sv_q_checkbox_none",
        itemChecked: "checked",
        itemInline: "sv_q_checkbox_inline",
        label: "sv_q_checkbox_label",
        labelChecked: "",
        itemControl: "sv_q_checkbox_control_item",
        itemDecorator: "sv-hidden",
        controlLabel: "sv_q_checkbox_control_label",
        other: "sv_q_other sv_q_checkbox_other",
        column: "sv_q_select_column",
    },
    ranking: {
        root: "sv-ranking",
        rootMobileMod: "sv-ranking--mobile",
        rootDragMod: "sv-ranking--drag",
        rootDisabled: "sv-ranking--disabled",
        rootDragHandleAreaIcon: "sv-ranking--drag-handle-area-icon",
        rootSelectToRankMod: "sv-ranking--select-to-rank",
        rootSelectToRankAlignVertical: "sv-ranking--select-to-rank-vertical",
        rootSelectToRankAlignHorizontal: "sv-ranking--select-to-rank-horizontal",
        item: "sv-ranking-item",
        itemContent: "sv-ranking-item__content",
        itemIndex: "sv-ranking-item__index",
        itemIndexEmptyMode: "sv-ranking-item__index--empty",
        // itemText: "sv-ranking-item__text",
        controlLabel: "sv-ranking-item__text",
        itemGhostNode: "sv-ranking-item__ghost",
        itemIconContainer: "sv-ranking-item__icon-container",
        itemIcon: "sv-ranking-item__icon",
        itemIconHoverMod: "sv-ranking-item__icon--hover",
        itemIconFocusMod: "sv-ranking-item__icon--focus",
        itemGhostMod: "sv-ranking-item--ghost",
        itemDragMod: "sv-ranking-item--drag",
        container: "sv-ranking__container",
        containerEmptyMode: "sv-ranking__container--empty",
        containerFromMode: "sv-ranking__container--from",
        containerToMode: "sv-ranking__container--to",
        containerPlaceholder: "sv-ranking__container-placeholder",
        containersDivider: "sv-ranking__containers-divider",
    },
    comment: {
        remainingCharacterCounter: "sv-remaining-character-counter",
    },
    dropdown: {
        root: "",
        popup: "sv-dropdown-popup",
        control: "sv_q_dropdown_control",
        controlInputFieldComponent: "sv_q_dropdown_control__input-field-component",
        selectWrapper: "sv_select_wrapper",
        other: "sv_q_dd_other",
        cleanButton: "sv_q_dropdown_clean-button",
        cleanButtonSvg: "sv_q_dropdown_clean-button-svg",
        cleanButtonIconId: "icon-clear_16x16",
        controlValue: "sv_q_dropdown__value",
        filterStringInput: "sv_q_dropdown__filter-string-input",
        hintPrefix: "sv_q_dropdown__hint-prefix",
        hintSuffix: "sv_q_dropdown__hint-suffix"
    },
    html: { root: "" },
    image: {
        root: "sv_q_image",
        image: "sv_image_image",
        noImage: "sv-image__no-image",
        noImageSvgIconId: "icon-no-image",
    },
    matrix: {
        root: "sv_q_matrix",
        label: "sv_q_m_label",
        itemChecked: "checked",
        itemDecorator: "sv-hidden",
        cell: "sv_q_m_cell",
        cellText: "sv_q_m_cell_text",
        cellTextSelected: "sv_q_m_cell_selected",
        cellLabel: "sv_q_m_cell_label",
        cellResponsiveTitle: "sv_q_m_cell_responsive_title"
    },
    matrixdropdown: {
        root: "sv_q_matrix_dropdown",
        cell: "sv_matrix_cell",
        cellResponsiveTitle: "sv_matrix_cell_responsive_title",
        headerCell: "sv_matrix_cell_header",
        row: "sv_matrix_row",
        rowAdditional: "sv-matrix__row--additional",
        rowTextCell: "sv-table__cell--row-text",
        detailRow: "sv_matrix_detail_row",
        detailRowText: "sv_matrix_cell_detail_rowtext",
        detailCell: "sv_matrix_cell_detail",
        choiceCell: "sv-table__cell--choice",
        detailButton: "sv_matrix_cell_detail_button",
        detailButtonExpanded: "sv_matrix_cell_detail_button_expanded",
        detailIcon: "sv_detail_panel_icon",
        detailIconExpanded: "sv_detail_expanded",
        detailPanelCell: "sv_matrix_cell_detail_panel",
        actionsCell: "sv_matrix_cell sv_matrix_cell_actions",
    },
    matrixdynamic: {
        root: "sv_q_matrix_dynamic",
        button: "sv_matrix_dynamic_button",
        buttonAdd: "",
        buttonRemove: "",
        iconAdd: "",
        iconRemove: "",
        iconDrag: "sv-matrixdynamic__drag-icon",
        cell: "sv_matrix_cell",
        cellResponsiveTitle: "sv_matrix_cell_responsive_title",
        headerCell: "sv_matrix_cell_header",
        row: "sv_matrix_row",
        detailRow: "sv_matrix_detail_row",
        detailCell: "sv_matrix_cell_detail",
        choiceCell: "sv-table__cell--choice",
        detailButton: "sv_matrix_cell_detail_button",
        detailButtonExpanded: "sv_matrix_cell_detail_button_expanded",
        detailIcon: "sv_detail_panel_icon",
        detailIconExpanded: "sv_detail_expanded",
        detailPanelCell: "sv_matrix_cell_detail_panel",
        actionsCell: "sv_matrix_cell sv_matrix_cell_actions",
        emptyRowsSection: "sv_matrix_empty_rows_section",
        emptyRowsText: "sv_matrix_empty_rows_text",
        emptyRowsButton: "",
        ghostRow: "sv-matrix-row--drag-drop-ghost-mod"
    },
    paneldynamic: {
        root: "sv_panel_dynamic",
        title: "sv_p_title",
        header: "sv-paneldynamic__header sv_header",
        headerTab: "sv-paneldynamic__header-tab",
        button: "",
        buttonAdd: "sv-paneldynamic__add-btn",
        buttonRemove: "sv_p_remove_btn",
        buttonRemoveRight: "sv_p_remove_btn_right",
        buttonPrev: "sv-paneldynamic__prev-btn",
        buttonPrevDisabled: "sv-paneldynamic__prev-btn--disabled",
        buttonNextDisabled: "sv-paneldynamic__next-btn--disabled",
        buttonNext: "sv-paneldynamic__next-btn",
        progressContainer: "sv-paneldynamic__progress-container",
        progress: "sv-progress",
        progressBar: "sv-progress__bar",
        progressText: "sv-paneldynamic__progress-text",
        panelWrapper: "sv_p_wrapper",
        panelWrapperInRow: "sv_p_wrapper_in_row",
        footer: "",
        progressBtnIcon: "icon-progressbutton"
    },
    multipletext: {
        root: "sv_q_mt",
        itemTitle: "sv_q_mt_title",
        item: "sv_q_mt_item",
        row: "sv_q_mt_row",
        itemLabel: "sv_q_mt_label",
        itemValue: "sv_q_mt_item_value sv_q_text_root",
    },
    radiogroup: {
        root: "sv_qcbc",
        item: "sv_q_radiogroup",
        itemChecked: "checked",
        itemInline: "sv_q_radiogroup_inline",
        itemDecorator: "sv-hidden",
        label: "sv_q_radiogroup_label",
        labelChecked: "",
        itemControl: "sv_q_radiogroup_control_item",
        controlLabel: "",
        other: "sv_q_other sv_q_radiogroup_other",
        clearButton: "sv_q_radiogroup_clear",
        column: "sv_q_select_column",
    },
    buttongroup: {
        root: "sv-button-group",
        item: "sv-button-group__item",
        itemIcon: "sv-button-group__item-icon",
        itemDecorator: "sv-button-group__item-decorator",
        itemCaption: "sv-button-group__item-caption",
        itemHover: "sv-button-group__item--hover",
        itemSelected: "sv-button-group__item--selected",
        itemDisabled: "sv-button-group__item--disabled",
        itemControl: "sv-visuallyhidden",
    },
    imagepicker: {
        root: "sv_imgsel",
        item: "sv_q_imgsel",
        itemChecked: "checked",
        label: "sv_q_imgsel_label",
        itemControl: "sv_q_imgsel_control_item",
        image: "sv_q_imgsel_image",
        itemInline: "sv_q_imagepicker_inline",
        itemText: "sv_q_imgsel_text",
        clearButton: "sv_q_radiogroup_clear",
        column: "sv_q_select_column",
        itemNoImage: "sv_q_imgsel__no-image",
        itemNoImageSvgIcon: "sv_q_imgsel__no-image-svg",
        itemNoImageSvgIconId: "icon-no-image",
    },
    rating: {
        root: "sv_q_rating",
        item: "sv_q_rating_item",
        itemFixedSize: "sv_q_rating_item_fixed",
        selected: "active",
        minText: "sv_q_rating_min_text",
        itemText: "sv_q_rating_item_text",
        maxText: "sv_q_rating_max_text",
        itemStar: "sv_q_rating__item-star",
        itemStarSelected: "sv_q_rating__item-star--selected",
        itemSmiley: "sv_q_rating__item-smiley",
        itemSmileySelected: "sv_q_rating__item-smiley--selected",
    },
    text: {
        root: "sv_q_text_root",
        remainingCharacterCounter: "sv-remaining-character-counter",
    },
    expression: "",
    file: {
        root: "sv_q_file",
        placeholderInput: "sv-visuallyhidden",
        previewItem: "sv_q_file_preview",
        removeButton: "sv_q_file_remove_button",
        fileInput: "sv-visuallyhidden",
        removeFile: "sv_q_file_remove",
        fileDecorator: "sv-file__decorator",
        fileSign: "sv_q_file_sign",
        chooseFile: "sv_q_file_choose_button",
        noFileChosen: "sv_q_file_placeholder",
        dragAreaPlaceholder: "sv-hidden",
        fileList: "",
    },
    signaturepad: {
        root: "sv_q_signaturepad sjs_sp_container",
        controls: "sjs_sp_controls",
        placeholder: "sjs_sp_placeholder",
        canvas: "sjs_sp_canvas",
        backgroundImage: "sjs_sp__background-image",
        clearButton: "sjs_sp_clear",
    },
    saveData: {
        root: "sv-save-data_root",
        rootWithButtons: "sv-save-data_root--with-buttons",
        info: "sv-save-data_info",
        error: "sv-save-data_error",
        success: "sv-save-data_success",
        button: "sv-save-data_button",
        shown: "sv-save-data_root--shown"
    },
    window: {
        root: "sv_window",
        rootCollapsedMod: "sv_window--collapsed",
        rootFullScreenMode: "sv_window--full-screen",
        rootContent: "sv_window_root-content",
        body: "sv_window_content",
        header: {
            root: "sv_window_header",
            titleCollapsed: "sv_window_header_title_collapsed",
            buttonsContainer: "sv_window_buttons_container",
            button: "sv_window_button",
            buttonExpanded: "",
            buttonCollapsed: "",
            collapseButton: "sv_window_button sv_window_button_collapse",
            closeButton: "sv_window_button sv_window_button_close",
            fullScreenButton: "sv_window_button sv_window_button_full_screen"
        }
    },
    variables: {
        mobileWidth: "--sv-mobile-width",
        themeMark: "--sv-default-mark"
    },
    tagbox: {
        root: "",
        popup: "sv-dropdown-popup",
        small: "sv_q_row__question--small",
        selectWrapper: "sv_select_wrapper sv_q_tagbox_wrapper",
        other: "sv_q_input sv_q_comment sv_q_selectbase__other",
        cleanButton: "sv_q_tagbox_clean-button sv_q_dropdown_clean-button",
        cleanButtonSvg: "sv_q_tagbox_clean-button-svg sv_q_dropdown_clean-button-svg",
        cleanButtonIconId: "icon-clear_16x16",
        cleanItemButton: "sv_q_tagbox-item_clean-button",
        cleanItemButtonSvg: "sv_q_tagbox-item_clean-button-svg",
        cleanItemButtonIconId: "icon-clear_16x16",
        control: "sv_q_input sv_q_tagbox sv_q_dropdown_control",
        controlValue: "sv_q_tagbox__value sv_q_dropdown__value",
        controlEmpty: "sv_q_dropdown--empty sv_q_tagbox--empty",
        placeholderInput: "sv_q_tagbox__placeholder",
        filterStringInput: "sv_q_tagbox__filter-string-input sv_q_dropdown__filter-string-input",
        hint: "sv_q_tagbox__hint",
        hintPrefix: "sv_q_dropdown__hint-prefix sv_q_tagbox__hint-prefix",
        hintSuffix: "sv_q_dropdown__hint-suffix sv_q_tagbox__hint-suffix",
        hintSuffixWrapper: "sv_q_tagbox__hint-suffix-wrapper"
    },
};
surveyCss["default"] = defaultStandardCss;
surveyCss["orange"] = defaultStandardCss;
surveyCss["darkblue"] = defaultStandardCss;
surveyCss["darkrose"] = defaultStandardCss;
surveyCss["stone"] = defaultStandardCss;
surveyCss["winter"] = defaultStandardCss;
surveyCss["winterstone"] = defaultStandardCss;

// CONCATENATED MODULE: ./src/defaultCss/cssmodern.ts

var modernCss = {
    root: "sv-root-modern",
    rootProgress: "sv-progress",
    timerRoot: "sv-body__timer",
    container: "sv-container-modern",
    header: "sv-title sv-container-modern__title",
    headerClose: "sv-container-modern__close",
    bodyContainer: "sv-components-row",
    body: "sv-body",
    bodyEmpty: "sv-body sv-body--empty",
    footer: "sv-footer sv-body__footer sv-clearfix",
    title: "",
    description: "",
    logo: "sv-logo",
    logoImage: "sv-logo__image",
    headerText: "sv-header__text",
    navigationButton: "sv-btn sv-btn--navigation",
    completedPage: "sv-completedpage",
    navigation: {
        complete: "sv-footer__complete-btn",
        prev: "sv-footer__prev-btn",
        next: "sv-footer__next-btn",
        start: "sv-footer__start-btn",
        preview: "sv-footer__preview-btn",
        edit: "sv-footer__edit-btn",
    },
    panel: {
        title: "sv-title sv-panel__title",
        titleExpandable: "sv-panel__title--expandable",
        titleExpanded: "sv-panel__title--expanded",
        titleCollapsed: "sv-panel__title--collapsed",
        titleOnError: "sv-panel__title--error",
        description: "sv-description sv-panel__description",
        container: "sv-panel sv-row__panel",
        content: "sv-panel__content",
        icon: "sv-panel__icon",
        iconExpanded: "sv-panel__icon--expanded",
        footer: "sv-panel__footer",
        requiredText: "sv-panel__required-text",
        number: "sv-question__num",
    },
    paneldynamic: {
        root: "sv-paneldynamic",
        navigation: "sv-paneldynamic__navigation",
        title: "sv-title sv-question__title",
        button: "sv-btn",
        buttonRemove: "sv-paneldynamic__remove-btn",
        buttonRemoveRight: "sv-paneldynamic__remove-btn--right",
        buttonAdd: "sv-paneldynamic__add-btn",
        progressTop: "sv-paneldynamic__progress sv-paneldynamic__progress--top",
        progressBottom: "sv-paneldynamic__progress sv-paneldynamic__progress--bottom",
        buttonPrev: "sv-paneldynamic__prev-btn",
        buttonNext: "sv-paneldynamic__next-btn",
        buttonPrevDisabled: "sv-paneldynamic__prev-btn--disabled",
        buttonNextDisabled: "sv-paneldynamic__next-btn--disabled",
        progressContainer: "sv-paneldynamic__progress-container",
        progress: "sv-progress",
        progressBar: "sv-progress__bar",
        progressText: "sv-paneldynamic__progress-text",
        separator: "sv-paneldynamic__separator",
        panelWrapper: "sv-paneldynamic__panel-wrapper",
        panelWrapperInRow: "sv-paneldynamic__panel-wrapper--in-row",
        progressBtnIcon: "icon-progressbutton",
        footer: ""
    },
    progress: "sv-progress sv-body__progress",
    progressBar: "sv-progress__bar",
    progressText: "sv-progress__text",
    progressTextInBar: "sv-hidden",
    progressButtonsContainerCenter: "sv_progress-buttons__container-center",
    progressButtonsContainer: "sv_progress-buttons__container",
    progressButtonsImageButtonLeft: "sv_progress-buttons__image-button-left",
    progressButtonsImageButtonRight: "sv_progress-buttons__image-button-right",
    progressButtonsImageButtonHidden: "sv_progress-buttons__image-button--hidden",
    progressButtonsListContainer: "sv_progress-buttons__list-container",
    progressButtonsList: "sv_progress-buttons__list",
    progressButtonsListElementPassed: "sv_progress-buttons__list-element--passed",
    progressButtonsListElementCurrent: "sv_progress-buttons__list-element--current",
    progressButtonsListElementNonClickable: "sv_progress-buttons__list-element--nonclickable",
    progressButtonsPageTitle: "sv_progress-buttons__page-title",
    progressButtonsPageDescription: "sv_progress-buttons__page-description",
    page: {
        root: "sv-page sv-body__page",
        title: "sv-title sv-page__title",
        description: "sv-description sv-page__description",
    },
    pageTitle: "sv-title sv-page__title",
    pageDescription: "sv-description sv-page__description",
    row: "sv-row sv-clearfix",
    question: {
        mainRoot: "sv-question sv-row__question",
        flowRoot: "sv-question sv-row__question sv-row__question--flow",
        asCell: "sv-table__cell",
        header: "sv-question__header",
        headerLeft: "sv-question__header--location--left",
        headerTop: "sv-question__header--location--top",
        headerBottom: "sv-question__header--location--bottom",
        content: "sv-question__content",
        contentLeft: "sv-question__content--left",
        titleLeftRoot: "",
        answered: "sv-question--answered",
        titleOnAnswer: "sv-question__title--answer",
        titleOnError: "sv-question__title--error",
        title: "sv-title sv-question__title",
        titleExpandable: "sv-question__title--expandable",
        titleExpanded: "sv-question__title--expanded",
        titleCollapsed: "sv-question__title--collapsed",
        icon: "sv-question__icon",
        iconExpanded: "sv-question__icon--expanded",
        requiredText: "sv-question__required-text",
        number: "sv-question__num",
        description: "sv-description sv-question__description",
        descriptionUnderInput: "sv-description sv-question__description",
        comment: "sv-comment",
        required: "sv-question--required",
        titleRequired: "sv-question__title--required",
        indent: 20,
        footer: "sv-question__footer",
        formGroup: "sv-question__form-group",
        hasError: "",
        disabled: "sv-question--disabled",
    },
    image: { root: "sv-image", image: "sv_image_image" },
    error: {
        root: "sv-question__erbox",
        icon: "",
        item: "",
        locationTop: "sv-question__erbox--location--top",
        locationBottom: "sv-question__erbox--location--bottom",
    },
    checkbox: {
        root: "sv-selectbase",
        item: "sv-item sv-checkbox sv-selectbase__item",
        itemSelectAll: "sv-checkbox--selectall",
        itemNone: "sv-checkbox--none",
        itemDisabled: "sv-item--disabled sv-checkbox--disabled",
        itemChecked: "sv-checkbox--checked",
        itemHover: "sv-checkbox--allowhover",
        itemInline: "sv-selectbase__item--inline",
        label: "sv-selectbase__label",
        labelChecked: "",
        itemControl: "sv-visuallyhidden sv-item__control",
        itemDecorator: "sv-item__svg sv-checkbox__svg",
        itemSvgIconId: "#icon-moderncheck",
        controlLabel: "sv-item__control-label",
        materialDecorator: "sv-item__decorator sv-selectbase__decorator sv-checkbox__decorator",
        other: "sv-comment sv-question__other",
        column: "sv-selectbase__column",
    },
    ranking: {
        root: "sv-ranking",
        rootMobileMod: "sv-ranking--mobile",
        rootDragMod: "sv-ranking--drag",
        rootDisabled: "sv-ranking--disabled",
        rootDragHandleAreaIcon: "sv-ranking--drag-handle-area-icon",
        rootSelectToRankMod: "sv-ranking--select-to-rank",
        rootSelectToRankAlignVertical: "sv-ranking--select-to-rank-vertical",
        rootSelectToRankAlignHorizontal: "sv-ranking--select-to-rank-horizontal",
        item: "sv-ranking-item",
        itemContent: "sv-ranking-item__content",
        itemIndex: "sv-ranking-item__index",
        itemIndexEmptyMode: "sv-ranking-item__index--empty",
        // itemText: "sv-ranking-item__text",
        controlLabel: "sv-ranking-item__text",
        itemGhostNode: "sv-ranking-item__ghost",
        itemIconContainer: "sv-ranking-item__icon-container",
        itemIcon: "sv-ranking-item__icon",
        itemIconHoverMod: "sv-ranking-item__icon--hover",
        itemIconFocusMod: "sv-ranking-item__icon--focus",
        itemGhostMod: "sv-ranking-item--ghost",
        itemDragMod: "sv-ranking-item--drag",
        container: "sv-ranking__container",
        containerEmptyMode: "sv-ranking__container--empty",
        containerFromMode: "sv-ranking__container--from",
        containerToMode: "sv-ranking__container--to",
        containerPlaceholder: "sv-ranking__container-placeholder",
        containersDivider: "sv-ranking__containers-divider",
    },
    radiogroup: {
        root: "sv-selectbase",
        item: "sv-item sv-radio sv-selectbase__item",
        itemInline: "sv-selectbase__item--inline",
        label: "sv-selectbase__label",
        labelChecked: "",
        itemDisabled: "sv-item--disabled sv-radio--disabled",
        itemChecked: "sv-radio--checked",
        itemHover: "sv-radio--allowhover",
        itemControl: "sv-visuallyhidden sv-item__control",
        itemDecorator: "sv-item__svg sv-radio__svg",
        itemSvgIconId: "#icon-modernradio",
        controlLabel: "sv-item__control-label",
        materialDecorator: "sv-item__decorator sv-selectbase__decorator sv-radio__decorator",
        other: "sv-comment sv-question__other",
        clearButton: "sv-btn sv-selectbase__clear-btn",
        column: "sv-selectbase__column",
    },
    buttongroup: {
        root: "sv-button-group",
        item: "sv-button-group__item",
        itemIcon: "sv-button-group__item-icon",
        itemDecorator: "sv-button-group__item-decorator",
        itemCaption: "sv-button-group__item-caption",
        itemSelected: "sv-button-group__item--selected",
        itemHover: "sv-button-group__item--hover",
        itemDisabled: "sv-button-group__item--disabled",
        itemControl: "sv-visuallyhidden",
    },
    boolean: {
        root: "sv_qbln",
        rootRadio: "sv_qbln",
        small: "sv-row__question--small",
        item: "sv-boolean sv-item",
        control: "sv-visuallyhidden",
        itemChecked: "sv-boolean--checked",
        itemIndeterminate: "sv-boolean--indeterminate",
        itemDisabled: "sv-item--disabled sv-boolean--disabled",
        switch: "sv-boolean__switch",
        slider: "sv-boolean__slider",
        label: "sv-boolean__label",
        disabledLabel: "sv-boolean__label--disabled",
        sliderGhost: "sv-boolean__thumb-ghost",
        //checkbox
        rootCheckbox: "sv_qbln",
        checkboxItem: "sv-boolean sv-item",
        checkboxItemChecked: "sv-boolean--checked",
        controlCheckbox: "sv-visuallyhidden",
        checkboxControlLabel: "sv-boolean__label",
        checkboxItemIndeterminate: "sv-boolean--indeterminate",
        checkboxItemDisabled: "sv-item--disabled sv-boolean--disabled",
        checkboxMaterialDecorator: "sv-item__decorator sv-boolean__decorator ",
        checkboxItemDecorator: "sv-item__svg  sv-boolean__svg",
        indeterminatePath: "sv-boolean__indeterminate-path",
        svgIconCheckedId: "#icon-modernbooleancheckchecked",
        svgIconUncheckedId: "#icon-modernbooleancheckunchecked",
        svgIconIndId: "#icon-modernbooleancheckind",
    },
    text: {
        root: "sv-text",
        small: "sv-row__question--small",
        remainingCharacterCounter: "sv-remaining-character-counter",
        onError: "sv-text--error",
    },
    multipletext: {
        root: "sv-multipletext",
        item: "sv-multipletext__item",
        itemLabel: "sv-multipletext__item-label",
        itemTitle: "sv-multipletext__item-title",
        row: "sv-multipletext__row",
        cell: "sv-multipletext__cell",
    },
    dropdown: {
        root: "",
        popup: "sv-dropdown-popup",
        small: "sv-row__question--small",
        control: "sv-dropdown",
        selectWrapper: "",
        other: "sv-comment sv-question__other",
        onError: "sv-dropdown--error",
        cleanButton: "sv-dropdown_clean-button",
        cleanButtonSvg: "sv-dropdown_clean-button-svg",
        cleanButtonIconId: "icon-clear_16x16",
        filterStringInput: "sv-dropdown__filter-string-input",
        controlValue: "sv-dropdown__value",
        controlInputFieldComponent: "sv_dropdown_control__input-field-component",
        hintPrefix: "sv-dropdown__hint-prefix",
        hintSuffix: "sv-dropdown__hint-suffix"
    },
    tagbox: {
        root: "",
        popup: "sv-dropdown-popup",
        small: "sv-row__question--small",
        selectWrapper: "sv_select_wrapper sv-tagbox_wrapper",
        other: "sv-input sv-comment sv-selectbase__other",
        cleanButton: "sv-tagbox_clean-button sv-dropdown_clean-button",
        cleanButtonSvg: "sv-tagbox_clean-button-svg sv-dropdown_clean-button-svg",
        cleanButtonIconId: "icon-clear_16x16",
        cleanItemButton: "sv-tagbox__item_clean-button",
        cleanItemButtonSvg: "sv-tagbox__item_clean-button-svg",
        cleanItemButtonIconId: "icon-clear_16x16",
        control: "sv-input sv-tagbox sv-dropdown",
        controlValue: "sv-tagbox__value sv-dropdown__value",
        controlEmpty: "sv-dropdown--empty sv-tagbox--empty",
        placeholderInput: "sv-tagbox__placeholder",
        filterStringInput: "sv-tagbox__filter-string-input sv-dropdown__filter-string-input"
    },
    imagepicker: {
        root: "sv-selectbase sv-imagepicker",
        column: "sv-selectbase__column",
        item: "sv-imagepicker__item",
        itemInline: "sv-imagepicker__item--inline",
        itemChecked: "sv-imagepicker__item--checked",
        itemDisabled: "sv-imagepicker__item--disabled",
        itemHover: "sv-imagepicker__item--allowhover",
        label: "sv-imagepicker__label",
        itemControl: "sv-imagepicker__control sv-visuallyhidden",
        image: "sv-imagepicker__image",
        itemText: "sv-imagepicker__text",
        clearButton: "sv-btn",
        other: "sv-comment sv-question__other",
    },
    matrix: {
        tableWrapper: "sv-matrix",
        root: "sv-table sv-matrix-root",
        rowError: "sv-matrix__row--error",
        cell: "sv-table__cell sv-matrix__cell",
        headerCell: "sv-table__cell sv-table__cell--header",
        label: "sv-item sv-radio sv-matrix__label",
        itemValue: "sv-visuallyhidden sv-item__control sv-radio__control",
        itemChecked: "sv-radio--checked",
        itemDisabled: "sv-item--disabled sv-radio--disabled",
        itemHover: "sv-radio--allowhover",
        materialDecorator: "sv-item__decorator sv-radio__decorator",
        itemDecorator: "sv-item__svg sv-radio__svg",
        cellText: "sv-matrix__text",
        cellTextSelected: "sv-matrix__text--checked",
        cellTextDisabled: "sv-matrix__text--disabled",
        cellResponsiveTitle: "sv-matrix__cell-responsive-title",
        itemSvgIconId: "#icon-modernradio",
    },
    matrixdropdown: {
        root: "sv-table sv-matrixdropdown",
        cell: "sv-table__cell",
        cellResponsiveTitle: "sv-table__responsive-title",
        headerCell: "sv-table__cell sv-table__cell--header",
        row: "sv-table__row",
        rowTextCell: "sv-table__cell--row-text",
        rowAdditional: "sv-table__row--additional",
        detailRow: "sv-table__row--detail",
        detailRowText: "sv-table__cell--detail-rowtext",
        detailCell: "sv-table__cell--detail",
        choiceCell: "sv-table__cell--choice",
        detailButton: "sv-table__cell--detail-button",
        detailButtonExpanded: "sv-table__cell--detail-button--expanded",
        detailIcon: "sv-detail-panel__icon",
        detailIconExpanded: "sv-detail-panel__icon--expanded",
        detailPanelCell: "sv-table__cell--detail-panel",
        actionsCell: "sv-table__cell sv-table__cell--actions",
    },
    matrixdynamic: {
        root: "sv-table sv-matrixdynamic",
        cell: "sv-table__cell",
        cellResponsiveTitle: "sv-table__responsive-title",
        headerCell: "sv-table__cell sv-table__cell--header",
        button: "sv-btn",
        buttonAdd: "sv-matrixdynamic__add-btn",
        buttonRemove: "sv-matrixdynamic__remove-btn",
        iconAdd: "",
        iconRemove: "",
        iconDrag: "sv-matrixdynamic__drag-icon",
        row: "sv-table__row",
        detailRow: "sv-table__row--detail",
        detailCell: "sv-table__cell--detail",
        choiceCell: "sv-table__cell--choice",
        detailButton: "sv-table__cell--detail-button",
        detailButtonExpanded: "sv-table__cell--detail-button--expanded",
        detailIcon: "sv-detail-panel__icon",
        detailIconExpanded: "sv-detail-panel__icon--expanded",
        detailPanelCell: "sv-table__cell--detail-panel",
        actionsCell: "sv-table__cell sv-table__cell--actions",
        emptyRowsSection: "sv-table__empty--rows--section",
        emptyRowsText: "sv-table__empty--rows--text",
        emptyRowsButton: "",
        ghostRow: "sv-matrix-row--drag-drop-ghost-mod"
    },
    rating: {
        root: "sv-rating",
        item: "sv-rating__item",
        selected: "sv-rating__item--selected",
        minText: "sv-rating__min-text",
        itemText: "sv-rating__item-text",
        maxText: "sv-rating__max-text",
        itemDisabled: "sv-rating--disabled",
        filterStringInput: "sv-dropdown__filter-string-input",
        control: "sv-dropdown",
        cleanButton: "sv-dropdown_clean-button",
        cleanButtonSvg: "sv-dropdown_clean-button-svg",
        cleanButtonIconId: "icon-clear_16x16",
        controlValue: "sv-dropdown__value",
        controlInputFieldComponent: "sv_dropdown_control__input-field-component",
        itemSmiley: "sv-rating__item-smiley",
        itemStar: "sv-rating__item-star",
        itemSmileySelected: "sv-rating__item-smiley--selected",
        itemStarSelected: "sv-rating__item-star--selected"
    },
    comment: {
        root: "sv-comment",
        small: "sv-row__question--small",
        remainingCharacterCounter: "sv-remaining-character-counter",
    },
    expression: "",
    file: {
        root: "sv-file",
        other: "sv-comment sv-question__other",
        placeholderInput: "sv-visuallyhidden",
        previewItem: "sd-file__preview-item",
        fileSignBottom: "sv-file__sign",
        fileDecorator: "sv-file__decorator",
        fileInput: "sv-visuallyhidden",
        noFileChosen: "sv-description sv-file__no-file-chosen",
        chooseFile: "sv-btn sv-file__choose-btn",
        controlDisabled: "sv-file__choose-btn--disabled",
        removeButton: "sv-hidden",
        removeButtonBottom: "sv-btn sv-file__clean-btn",
        removeFile: "sv-hidden",
        removeFileSvg: "sv-file__remove-svg",
        removeFileSvgIconId: "icon-removefile",
        wrapper: "sv-file__wrapper",
        dragAreaPlaceholder: "sv-hidden",
        fileList: "",
    },
    signaturepad: {
        root: "sv-signaturepad sjs_sp_container",
        small: "sv-row__question--small",
        controls: "sjs_sp_controls",
        placeholder: "sjs_sp_placeholder",
        canvas: "sjs_sp_canvas",
        backgroundImage: "sjs_sp__background-image",
        clearButton: "sjs_sp_clear",
    },
    saveData: {
        root: "sv-save-data_root",
        rootWithButtons: "sv-save-data_root--with-buttons",
        info: "sv-save-data_info",
        error: "sv-save-data_error",
        success: "sv-save-data_success",
        button: "sv-save-data_button",
        shown: "sv-save-data_root--shown"
    },
    window: {
        root: "sv_window",
        rootCollapsedMod: "sv_window--collapsed",
        rootFullScreenMode: "sv_window--full-screen",
        rootContent: "sv_window_root-content",
        body: "sv_window_content",
        header: {
            root: "sv_window_header",
            titleCollapsed: "sv_window_header_title_collapsed",
            buttonsContainer: "sv_window_buttons_container",
            button: "sv_window_button",
            buttonExpanded: "",
            buttonCollapsed: "",
            collapseButton: "sv_window_button sv_window_button_collapse",
            closeButton: "sv_window_button sv_window_button_close",
            fullScreenButton: "sv_window_button sv_window_button_full_screen"
        }
    },
    variables: {
        mobileWidth: "--sv-mobile-width",
        themeMark: "--sv-modern-mark"
    }
};
surveyCss["modern"] = modernCss;

// CONCATENATED MODULE: ./packages/survey-core/src/svgbundle.ts

var SvgIconData = /** @class */ (function () {
    function SvgIconData() {
    }
    return SvgIconData;
}());
var svgbundle_SvgIconRegistry = /** @class */ (function () {
    function SvgIconRegistry() {
        this.icons = {};
        this.iconPrefix = "icon-";
    }
    SvgIconRegistry.prototype.processId = function (iconId, iconPrefix) {
        if (iconId.indexOf(iconPrefix) == 0)
            iconId = iconId.substring(iconPrefix.length);
        return iconId;
    };
    SvgIconRegistry.prototype.registerIconFromSymbol = function (iconId, iconSymbolSvg) {
        this.icons[iconId] = iconSymbolSvg;
    };
    SvgIconRegistry.prototype.registerIconFromSvgViaElement = function (iconId, iconSvg, iconPrefix) {
        if (iconPrefix === void 0) { iconPrefix = this.iconPrefix; }
        if (!DomDocumentHelper.isAvailable())
            return;
        iconId = this.processId(iconId, iconPrefix);
        var divSvg = DomDocumentHelper.createElement("div");
        divSvg.innerHTML = iconSvg;
        var symbol = DomDocumentHelper.createElement("symbol");
        var svg = divSvg.querySelector("svg");
        symbol.innerHTML = svg.innerHTML;
        for (var i = 0; i < svg.attributes.length; i++) {
            symbol.setAttributeNS("http://www.w3.org/2000/svg", svg.attributes[i].name, svg.attributes[i].value);
        }
        symbol.id = iconPrefix + iconId;
        this.registerIconFromSymbol(iconId, symbol.outerHTML);
    };
    SvgIconRegistry.prototype.registerIconFromSvg = function (iconId, iconSvg, iconPrefix) {
        if (iconPrefix === void 0) { iconPrefix = this.iconPrefix; }
        iconId = this.processId(iconId, iconPrefix);
        var startStr = "<svg ";
        var endStr = "</svg>";
        iconSvg = iconSvg.trim();
        var str = iconSvg.toLowerCase();
        if (str.substring(0, startStr.length) === startStr &&
            str.substring(str.length - endStr.length, str.length) === endStr) {
            this.registerIconFromSymbol(iconId, "<symbol " +
                "id=\"" + iconPrefix + iconId + "\" " +
                iconSvg.substring(startStr.length, str.length - endStr.length) +
                "</symbol>");
            return true;
        }
        else {
            return false;
        }
    };
    SvgIconRegistry.prototype.registerIconsFromFolder = function (r) {
        var _this = this;
        r.keys().forEach(function (key) {
            _this.registerIconFromSvg(key.substring(2, key.length - 4).toLowerCase(), r(key));
        });
    };
    SvgIconRegistry.prototype.iconsRenderedHtml = function () {
        var _this = this;
        return Object.keys(this.icons).map(function (icon) { return _this.icons[icon]; }).join("");
    };
    return SvgIconRegistry;
}());

var SvgRegistry = new svgbundle_SvgIconRegistry();
var SvgBundleViewModel;
var svgbundle_path = __webpack_require__("./packages/survey-core/src/images sync \\.svg$");
var pathSmiley = __webpack_require__("./packages/survey-core/src/images/smiley sync \\.svg$");
SvgRegistry.registerIconsFromFolder(svgbundle_path);
SvgRegistry.registerIconsFromFolder(pathSmiley);

// CONCATENATED MODULE: ./packages/survey-core/entries/chunks/core-wo-model.ts
// model


// utils









// CONCATENATED MODULE: ./src/entries/core-wo-model.ts
// model

// css standard classes

// css modern classes



// CONCATENATED MODULE: ./src/entries/core.ts
// model




/***/ })

/******/ });
});
//# sourceMappingURL=survey.core.js.map