text: System.register(["jimu-core","jimu-for-builder","jimu-for-builder/service","jimu-ui/advanced/setting-components","jimu-arcgis","jimu-ui"],(function(e,t){var s={},i={},a={},r={},n={},o={};return{setters:[function(e){s.DataSourceManager=e.DataSourceManager,s.DataSourceTypes=e.DataSourceTypes,s.Immutable=e.Immutable,s.React=e.React,s.SessionManager=e.SessionManager,s.classNames=e.classNames,s.css=e.css,s.getAppStore=e.getAppStore,s.jsx=e.jsx,s.moduleLoader=e.moduleLoader,s.portalUrlUtils=e.portalUrlUtils},function(e){i.builderAppSync=e.builderAppSync},function(e){a.appServices=e.appServices},function(e){r.JimuLayerViewSelector=e.JimuLayerViewSelector,r.MapWidgetSelector=e.MapWidgetSelector,r.SettingRow=e.SettingRow,r.SettingSection=e.SettingSection},function(e){n.ArcGISDataSourceTypes=e.ArcGISDataSourceTypes},function(e){o.AdvancedSelect=e.AdvancedSelect,o.AlertPopup=e.AlertPopup,o.Button=e.Button,o.Icon=e.Icon,o.Label=e.Label,o.Modal=e.Modal,o.Radio=e.Radio,o.Select=e.Select,o.Switch=e.Switch,o.TagInput=e.TagInput,o.TextArea=e.TextArea,o.TextInput=e.TextInput}],execute:function(){e((()=>{var e={66319:e=>{e.exports='<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 4h2.5v1H4a3 3 0 000 6h2.5v1H4a4 4 0 110-8zM12 11H9.5v1H12a4 4 0 100-8H9.5v1H12a3 3 0 010 6z" fill="#000"></path><path d="M5.5 7.5a.5.5 0 000 1h5a.5.5 0 000-1h-5z" fill="#000"></path></svg>'},55339:e=>{e.exports='<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.745 8l6.1 6.1a.527.527 0 11-.745.746L8 8.746l-6.1 6.1a.527.527 0 11-.746-.746l6.1-6.1-6.1-6.1a.527.527 0 01.746-.746l6.1 6.1 6.1-6.1a.527.527 0 01.746.746L8.746 8z" fill="#000"></path></svg>'},54357:e=>{e.exports='<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 6.5a.5.5 0 011 0v6a.5.5 0 01-1 0v-6zM9.5 6a.5.5 0 00-.5.5v6a.5.5 0 001 0v-6a.5.5 0 00-.5-.5z" fill="#000"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M11 0H5a1 1 0 00-1 1v2H.5a.5.5 0 000 1h1.6l.81 11.1a1 1 0 00.995.9h8.19a1 1 0 00.995-.9L13.9 4h1.6a.5.5 0 000-1H12V1a1 1 0 00-1-1zm0 3V1H5v2h6zm1.895 1h-9.79l.8 11h8.19l.8-11z" fill="#000"></path></svg>'},26826:e=>{"use strict";e.exports=n},48891:e=>{"use strict";e.exports=s},23137:e=>{"use strict";e.exports=i},66325:e=>{"use strict";e.exports=a},30726:e=>{"use strict";e.exports=o},77756:e=>{"use strict";e.exports=r}},t={};function l(s){var i=t[s];if(void 0!==i)return i.exports;var a=t[s]={exports:{}};return e[s](a,a.exports,l),a.exports}l.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return l.d(t,{a:t}),t},l.d=(e,t)=>{for(var s in t)l.o(t,s)&&!l.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.p="";var u={};return l.p=window.jimuConfig.baseUrl,(()=>{"use strict";l.r(u),l.d(u,{default:()=>w});var e=l(48891),t=l(23137),s=l(66325),i=l(77756),a=l(26826),r=l(30726);const n=new class{setQueryObject(e){const t=e?e.survey123:"",s=t?decodeURIComponent(t+""):"",i=this._urlParamToJson(s);this.queryObj=i}getSurveyHostUrlFromPortal(e){if(e=e||"https://www.arcgis.com",this.surveyUrlFromPortal||null===this.surveyUrlFromPortal)return Promise.resolve(this.surveyUrlFromPortal);const t=window.esriGeowConfig;if(t&&t.surveyUrl)return this.surveyUrlFromPortal=t.surveyUrl,Promise.resolve(this.surveyUrlFromPortal);let s="";e.endsWith("/")||(e+="/"),s=e+"home/js/arcgisonline/config.js";const i=document.createElement("script");i.type="text/javascript",i.src=s;const a=document.documentElement,r=a.getAttribute("dir");return new Promise(((e,t)=>{i.onload=()=>{a.getAttribute("dir")!==r&&a.setAttribute("dir",r);const t=window.esriGeowConfig;t&&t.surveyUrl?(this.surveyUrlFromPortal=t.surveyUrl,e(t.surveyUrl)):(this.surveyUrlFromPortal=null,e(null))},i.onerror=()=>{a.getAttribute("dir")!==r&&a.setAttribute("dir",r),console.log("Failed to get survey url from portal's config.js, will fallback to use the default survey123 url."),this.surveyUrlFromPortal=null,e(null)},document.getElementsByTagName("head")[0].appendChild(i)}))}getSurvey123HostUrl(){let e="https://survey123.arcgis.com";this.surveyUrlFromPortal&&(e=this.surveyUrlFromPortal);let t=window.jimuConfig.hostEnv;if(this.queryObj&&this.queryObj.env&&(t=this.queryObj.env+"",t.startsWith("http://")||t.startsWith("https://")))return t;let s=!0;if("https://survey123.arcgis.com"!==e){const t=e.match(/https:\/\/survey123(.[^\.]*)\.arcgis\.com/);s=!(!t||!t.length)}return t&&"prd"!==t&&"prod"!==t&&s&&(e=`https://survey123${t}.arcgis.com`),e}getSurvey123HostAPIUrl(){let e=this.getSurvey123HostUrl()+"/api/jsapi/3.13";return this.queryObj&&this.queryObj.jsapi&&(e=this.getSurvey123HostUrl()+"/api/jsapi/"+this.queryObj.jsapi),e}createSurvey(e,t,s,i){return i=Object.assign({snippet:""},i||{}),Promise.resolve(!0).then((()=>{if(!(e&&t&&s&&s.token&&s.username))throw new Error("missing title, tags, username or token")})).then((()=>{const a=`${this.getSurvey123HostUrl()}/api/survey/create`,r={title:e,tags:t.join(","),snippet:i.snippet,thumbnailUrl:i.thumbnailUrl,token:s.token,username:s.username,portalUrl:s.portalUrl||"https://www.arcgis.com"};return fetch(a,{mode:"cors",method:"POST",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(r)}).then((e=>{if(e.ok)return e.json();throw e}))}))}isPortal(e){return!["www.arcgis.com","devext.arcgis.com","qaext.arcgis.com"].find(((t,s)=>e.includes(t)))}querySurvey(e,t){return t=Object.assign({isShared:!1,isPublished:!0,isSearchAll:!0,queryFromClient:!1,surveyClientAPI:null},t||{}),Promise.resolve(!0).then((()=>{if(!e||!e.token||!e.username)throw new Error("missing token or username")})).then((()=>{const s={isShared:t.isShared,isPublished:t.isPublished,isSearchAll:t.isSearchAll,token:e.token,username:e.username,portalUrl:e.portalUrl||"https://www.arcgis.com"};if(t.searchSurveyType&&(s.searchSurveyType=t.searchSurveyType),t.queryFromClient)return t.surveyClientAPI?t.surveyClientAPI.survey123.searchSurvey(s).then((e=>{if(e&&e.results)return e.results;throw e})):(console.log("Survey client api is not provided."),null);{let e=`${this.getSurvey123HostUrl()}/api/survey/search`;return e=`${e}?${Object.keys(s).map((e=>e+"="+s[e])).join("&")}`,fetch(e,{mode:"cors",method:"GET"}).then((e=>{if(e.ok)return e.json();throw e})).then((e=>{if(e&&e.results)return e.results;if(e&&Array.isArray(e))return e;throw e}))}}))}getSurvey123DesignerUrl(e,t){t=Object.assign({},t||{});let s=`${this.getSurvey123HostUrl()}/surveys/${e}/design?embed=exb`;return t.portalUrl&&"https://www.arcgis.com"!==t.portalUrl&&(s+=`&portalUrl=${t.portalUrl}`),"https://survey123dev.arcgis.com"!==this.getSurvey123HostUrl()||t.portalUrl&&"https://www.arcgis.com"!==t.portalUrl||(s+=`&portalUrl=${t.portalUrl}`),s}getSurvey123WebformUrl(e,t){t=Object.assign({queryParams:[]},t||{});let s=`${this.getSurvey123HostUrl()}/share/${e}`;return t.queryParams.length>0&&(s+=`?${t.queryParams.join("&")}`),s}flatQuestions(e){let t=[];return e.forEach((e=>{e.questions?"esriQuestionTypeRepeat"!==e.type&&(t=t.concat(this.flatQuestions(e.questions))):t.push(e)})),t}getSurveyQuestionFields(e,t){return Promise.resolve(!0).then((()=>{if(!e||!t||!t.token)throw new Error("missing surveyItemId or token")})).then((()=>{let s=`${this.getSurvey123HostUrl()}/api/survey/${e}/form`;const i={token:t.token};return s=`${s}?${Object.keys(i).map((e=>e+"="+i[e])).join("&")}`,fetch(s,{mode:"cors",method:"GET"}).then((e=>{if(e.ok)return e.json();throw e}))})).then((e=>{const t=[];return e&&e.questions&&e.questions.length>0&&this.flatQuestions(e.questions).forEach((e=>{const s=(e.type+"").replace("esriQuestionType","");(e.fieldName||["geopoint","polyline","polygon"].includes(s.toLowerCase()))&&t.push({name:e.fieldName||e.name,label:e.label})})),t}))}_urlParamToJson(e){if(!e)return null;const t=(e+="").split(";");if(t.length<2&&e.split(":").length<2)return e.split(",").length>1?e.split(","):e;{const e={};return t.forEach((t=>{const s=(t+"").split(":");if(s.length>1){const t=s[0];let i=(Array.isArray(s.slice(1))?s.slice(1):[]).join(":");i.length&&"{"===i[0]&&(i=this._stringToJson(i)),"string"==typeof i&&i.split(",").length>1&&(i=i.split(",")),e[t]=i}})),e}}_stringToJson(e){let t=e;try{t=JSON.parse(e)}catch(s){t=e}return t}},o={errLoadS123JSAPI:"Failed to load Survey123 JavaScript API from {S123JSAPIURL}. Please check if this URL is available to you.",chooseSurvey:"Select which survey to run in the widget:",createNewSurveyLabel:"Create new survey",chooseSurveyLabel:"Select existing survey",draftSurveyPostfix:" (draft)",previewDraftSurveyMsg:"This survey is not published yet. Edit and publish the survey to preview the content here.",selectSurveyTip:"Please select",noExistingSurvey:"There is no available survey to this account.",searchHint:"Search",surveyDetailLabel:"Survey Details:",currentSurveyLabel:"Current survey",resetSurveyLabel:"Reset survey",summaryLabel:"Summary",insertLabel:"Insert",surveyTitleLabel:"Name",surveyTitleRequiredMsg:"The name of the survey is required.",surveyTitleDuplicateMsg:"A survey with this name already exists, please use a different name.",surveyTagLabel:"Tags",surveyTagHint:"Separate tags with commas",surveyTagsRequiredMsg:"One or more tags are required.",surveySummaryLabel:"Summary",createSurveyBtn:"Create",createSurveyDisabled1:"You do not have permission to perform this action. Required privileges: publish hosted feature layers",editSurveyBtn:"Edit survey",appearanceTitle:"Appearance",showOptionsBarLabel:"Show options bar",showOptionsHeaderLabel:"Show survey header",showOptionsDesLabel:"Show survey description",showOptionsFooterLabel:"Show survey footer",useSurveyTheme:"Enable survey theme",resetSurveyTip:"Reset survey will remove all settings to this survey widget.",confirmResetSurveyTip:"Are you sure you want to continue?",surveyModeTitle:"Mode",surveyModeNew:"Submit a new record",surveyModeEdit:"Edit an existing record",surveyModeView:"View an existing record",chooseExistDataTitle:"Choose existing data",chooseExistDataEditDesc:"Set the survey to edit an existing record rather than create one. The submit button in this survey will update the existing record.",chooseExistDataViewDesc:"Set the survey to view an existing record in read-only mode.",selectSurveyLayer:"Select the survey layer",selectSurveyLayerTip:"Please select a layer that contains at least one existing survey record.",chooseExistDataLoadDesc:"When a feature is selected in this layer, the survey will load data from the feature.",noAvailableSurveyLyrMsg:"No available survey layer.",sendDataToSurveyTitle:"Send data to this survey",sendDataToSurveyDesc:"Attributes and geometry of a feature in the source layer can be sent to survey questions.",sendDataDisabled1:"Please add a map widget that contains at least one feature layer to use this capability.",sendDataDisabled2:"Please add a map widget that contains at least one survey layer to use this capability.",sourceLayer:"Source layer",selectSourceWidget:"Select an interactive map",selectSourceLayer:"Select the source layer",triggerEventListTitle:"Trigger event for sending data",triggerEventSelect:"When an existing feature is selected",triggerEventAdd:"When a new feature is added",triggerEventDesc1:"Data will be sent to this survey when a feature is selected in the layer.",addConnTitle:"Field/question connections",addConnSelectField:"Select a field",addConnSelectQuestion:"Select a survey question",addConnFailed1:"The survey question type is not compatible with the field type.",addConnBtn:"Add connection",geometryLabel:"*Shape",geometryTypePoint:"Point",geometryTypeMultiPoint:"MultiPoint",geometryTypePolyline:"Polyline",geometryTypePolygon:"Polygon",errmsgGeneralLoading:"An error occurred while loading.",errmsgGeneralCreatingNewSvy:"An error occurred while creating the new survey. Pleasey try again later.",msgUnsavedBeforeLeaving:"Changes you made may not be saved."};function d(t){var s;const i=null===(s=null==t?void 0:t.components)||void 0===s?void 0:s.input;return e.css`
      &.survey123{
        input:-webkit-autofill {
          -webkit-box-shadow: 0 0 0px 1000px ${i.bg} inset;
          -webkit-text-fill-color: ${i.color};
        }
        .survey123__section {
          .choose-survey-label {
            margin-bottom: 0;
          }
          input + span {
            // margin-left:5px; 
          }
          .jimu-widget-setting--section-header.row >h6 {
            font-size: 0.875rem;
            color: ${t.colors.palette.dark[600]};
          }
  
          .survey-list-msg {
            padding: 0 5px;
          }
          .survey-list-loading-outter {
            position: relative;
            top: -18px;
          }
          .survey123__section-createSurvey {
            >.container >.w-100.setting-header {
              padding-bottom: 1rem!important;
              >div:first-child {
                padding-bottom: 0.5rem;
              }
              >.jimu-input span.input-wrapper {
                height: 1.625rem;
              }
              .summary{
                height: 5rem;
              }
            }
          }
          
          .survey123__section-createSurvey, .select-survey-section {
            .error-message {
              color: ${t.colors.danger};
              word-break: break-word;
            }
            .no-survey-message {
              color: ${t.colors.palette.dark[400]};
            }
            .newSurvey-msg {
              color: ${t.colors.danger};
              marginTop: '10px';
              word-break: break-word;
            }
          }
          .select-survey-section {
            hr.split-line {
              display: none;
            }
          }
          .create-survey-container {
            .jimu-widget-setting--row.items {
              margin-top: 1.2rem;
              display: block;
              h6 {
                color: ${t.colors.palette.dark[500]};
              }
              div.w-100 {
                font-size: 0.8125rem;
                line-height: 1.1875rem;
                margin-top: 0.3125rem;
  
              }
            }
            .jimu-widget-setting--row >label {
              font-size: 0.875rem;
              font-weight: 400;
              +p.w-100 {
                font-size: 0.8125rem;
                line-height: 1.1875rem;
                margin-top: 0.3125rem;
              }
            }
          }
      
          .appearance, .section-title {
            display: flex;
            justify-content: space-between;
            width:100%;
            h6 {
              margin-bottom: 0;
            }
          }
  
          .select{
            select {
              width: 100%;
            }
          }
  
          .mapping-container {
            padding: 0.615em;
            background: ${t.colors.secondary};
            border-radius: 2px;
            margin: 0.6em 0;
            position: relative;
            >select {
              height: 26px;
              vertical-align: middle;
              font-size: 1em;
              line-height: 26px;
              padding: 0 22px 0 6px;
              &:first-of-type {
                margin-bottom: 8px;
              }
            }
            .btn-group {
              width: 100%;
              overflow: hidden;
              .icon-remove-mapping {
                padding: 0 0.25em;
                margin-left: 0;
                margin-right: 0;
                cursor: pointer;
                .remove-mapping {
                  margin-right: 0;
                  margin-left: 0;
                }
              }
              button {
                margin: 8px 0 8px 8px;
                height: 26px;
                line-height: 26px;
                padding: 0;
                padding: 0px 14px;
              }
            }
            >.link-info {
              > p {
                margin-bottom: 0;
                line-height: 2em;
              }
              > div.center-line {
                width: 96%;
                height: 1px;
                background: ${t.colors.palette.secondary[800]};
                text-align: center;
                margin: 0.5em 2% 0.5em 2%;
                >.connect {
                  display: inline-block;
                  width: 26px;
                  height: 20px;
                  background: ${t.colors.secondary};
                  position: relative;
                  top: -10px;
                }
              }
              > div.delete-connect {
                display: none;
                position: absolute;
                right: 0;
                top: 0;
                cursor: pointer;
                background: ${t.colors.palette.secondary[400]};
                text-align: center;
                width: 24px;
                height: 24px;
              }
              &:hover > div.delete-connect {
                display: block;
              }
            }
            
          }
  
          .setting-row {
            margin: 0.5rem 0 0 0;
            display: flex;
            flex-flow: row wrap;
            align-items: center;
          }
      
          .section-title h5{
            display: inline-block;
            font-weight: 500;
          }
          
          .section-title h6{
            word-break: break-word;
          }
  
          .fea-layer-outter {
            flex-wrap:wrap;
          }
  
          .use-feature-layer-setting {
            width: 100%;
            margin-top: 0.92em;
          }
          .feature-layer-dropdown {
            width: 100%;
            margin: 0.5rem 0 0 0;
          }
          &-resetSurvey {
            position:relative;
            // top: -8px;
            height: 26px;
            float:right;
            line-height: 8px;
  
            svg {
              margin:0px !important;
            }
          }
  
          .cursor-pointer{
            &:hover{
              cursor:pointer;
            }
          }
            
          &-surveyMenu {}
      
          &-selectExistingSurvey {}
      
          &-createSurvey {
            overflow-y: hidden;
            
            span.isRequired{
              position:relative;
              /* left:-180px; */
              color: ${t.colors.danger};
              top: 4px;
              left: 4px;
            }
          }
      
          &-surveySettings {
            
          }
        }
      }
    `}var p=l(55339),h=l.n(p);const c=t=>{const{className:s}=t,i=function(e,t){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(s[i[a]]=e[i[a]])}return s}(t,["className"]),a=(0,e.classNames)("jimu-icon-component",s);return e.React.createElement(r.Icon,Object.assign({className:a,icon:h()},i))};var g=l(66319),y=l.n(g);const v=t=>{const{className:s}=t,i=function(e,t){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(s[i[a]]=e[i[a]])}return s}(t,["className"]),a=(0,e.classNames)("jimu-icon-component",s);return e.React.createElement(r.Icon,Object.assign({className:a,icon:y()},i))};var m=l(54357),S=l.n(m);const f=t=>{const{className:s}=t,i=function(e,t){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(s[i[a]]=e[i[a]])}return s}(t,["className"]),a=(0,e.classNames)("jimu-icon-component",s);return e.React.createElement(r.Icon,Object.assign({className:a,icon:S()},i))};class w extends e.React.PureComponent{constructor(i){super(i),this.supportedMapTypes=(0,e.Immutable)([a.ArcGISDataSourceTypes.WebMap]),this.supportedLayerTypes=(0,e.Immutable)([e.DataSourceTypes.FeatureLayer]),this.dsManager=e.DataSourceManager.getInstance(),this.state={userTags:[],canCreateSurvey:!0,loadApiFailed:!1,newSurveyTitle:null,newSurveyTags:[],newSurveyTitleDirty:!1,newSurveyTagsDirty:!1,newSurveySnippet:null,newSurveyItemId:null,newSurveyThumbnailUrls:["https://survey123.arcgis.com/assets/img/default-thumbnails/Image01.png","https://survey123.arcgis.com/assets/img/default-thumbnails/Image02.png","https://survey123.arcgis.com/assets/img/default-thumbnails/Image03.png"],newSurveyMsg:null,newSurveyLoading:!1,existSurveyMsg:null,existSurveys:[],selectedSurvey:null,modalIsOpen:!1,mode:"none",isCheckedSurveyItemId:!1,isShowSurveyQuestionField:!1,surveyQuestionFields:[],selectedQuestionField:null,createSurveyErrorMsg:null,surveyStatusCode:0,isShowCloseDesignerAlert:!1,surveyChanged:!1,dsMapView:null,dsFeatureLayer:null,dsFeatureLayerFields:[],mapWidgetList:[],addMapping:null,editMapping:null,layerViewInfoInNewMode:null,layerViewInfoInEditMode:null,layerViewInfoInViewMode:null,useMapWidgetIdsInNewMode:null,useMapWidgetIdsInEditMode:null,useMapWidgetIdsInViewMode:null},this.newDefaultValue={key:"",value:""},this.API={survey123:null,Survey123WebForm:null},this.isPortal=!1,this.isOrgAdmin=!1,this.setDefaultVal=()=>{this.props.config.mode||this.setMode("new");const e=this.props.config.mode||"new",t=this.props.config.layerViewInfo||null,s=this.props.useMapWidgetIds||null;"new"===e?this.setState({layerViewInfoInNewMode:t,useMapWidgetIdsInNewMode:s}):"edit"===e?this.setState({layerViewInfoInEditMode:t,useMapWidgetIdsInEditMode:s}):"view"===e&&this.setState({layerViewInfoInViewMode:t,useMapWidgetIdsInViewMode:s})},this.prepare=()=>Promise.resolve(!0).then((()=>{if(this.isPortal){const e=this.props.config.portalUrl||this.props.portalUrl;return n.getSurveyHostUrlFromPortal(e)}return!0})).then((()=>!this.isPortal||this.loadSurveyAPI())),this.componentDidMount=()=>{this.checkPrivilige();const t=this.props.useDataSources,s=t&&t.length?t[0].dataSourceId:null;if(s){const e=this.dsManager.getDataSource(s),t=e?e.layer:null;this.setState({dsFeatureLayer:t,dsFeatureLayerFields:this.getLayerFields(t)})}const i=this.props.user;this.isOrgAdmin=!(!i||"org_admin"!==i.role),this.isPortal=!e.portalUrlUtils.isAGOLDomain(this.props.config.portalUrl||this.props.portalUrl),this.getUserTags()},this.loadSurveyAPI=()=>{const t=n.getSurvey123HostAPIUrl();return this.API.survey123?Promise.resolve(this.API.survey123):e.moduleLoader.loadModule(t).then((e=>{if(this.API=e,!e){const e=this.props.intl.formatMessage({id:"errLoadS123JSAPI",defaultMessage:o.errLoadS123JSAPI},{S123JSAPIURL:t});throw this.setState({loadApiFailed:!0}),new Error(e)}return this.setState({loadApiFailed:!1,existSurveyMsg:"",newSurveyMsg:""}),e}))},this.checkPrivilige=()=>{const t=(0,e.getAppStore)().getState().user.privileges||[],s=t.includes("portal:user:createItem")&&t.includes("portal:publisher:publishFeatures");this.setState({canCreateSurvey:s})},this.getUserTags=()=>{if(window.jimuConfig.isDevEdition)return!1;const t=(0,e.getAppStore)().getState().user.username;s.appServices.getUserTags(t).then((e=>{var t;const s=null===(t=null==e?void 0:e.tags)||void 0===t?void 0:t.map((e=>e.tag));this.setState({userTags:s||[]})}))},this.getLayerFields=e=>{if(!e)return[];const t=Object.assign({},{fields:e.fields}).fields;if("feature"!==e.type)return t;if((t||[]).find((e=>"geometry"===e.name)))return t;const s=e.geometryType,i=this.nls("geometryType"+s.substr(0,1).toUpperCase()+s.substr(1));return t.push({alias:`${this.nls("geometryLabel")}(${i})`,name:"geometry"}),t},this.onValueChanged=e=>{const t=e.currentTarget;this.props.onSettingChange({id:this.props.id,config:this.props.config.set(t.name,t.value)})},this.nls=e=>this.props.intl.formatMessage({id:e,defaultMessage:o[e]}),this.addDefaultValue=e=>{this.newDefaultValue.key&&this.newDefaultValue.value&&(this.newDefaultValue={key:"",value:""})},this.addDesigerHandler=()=>{window.addEventListener("message",(e=>{if(e.data){let s=e.data;try{"string"==typeof e.data&&(s=JSON.parse(e.data)||{})}catch(e){}if("survey123:design:onFormPublished"===s.event&&s.data){let e=this.state.surveyStatusCode||0;e++,t.builderAppSync.publishChangeWidgetStatePropToApp({widgetId:this.props.id,propKey:"surveyStatusCode",value:e}),this.setState({surveyStatusCode:e}),this.handleCloseModal()}else"survey123:design:onFormUnsaved"===s.event&&s.data?this.setState({surveyChanged:!0}):"survey123:design:onFormSaved"===s.event&&s.data&&this.setState({surveyChanged:!1})}}))},this.getFielAlias=e=>{const t=(this.state.dsFeatureLayerFields||[]).find((t=>t.name===e));return t?t.alias||t.name:e},this.getQuestionLabel=e=>{const t=(this.state.surveyQuestionFields||[]).find((t=>t.name===e));return t?t.label||t.name:e},this.onNewSurveyValueChanged=(e,t)=>{const s=e.currentTarget;t&&this.setState({[t]:s.value}),"newSurveyTags"===t&&this.setState({newSurveyTagsDirty:!0}),"newSurveyTitle"===t&&this.setState({newSurveyTitleDirty:!0})},this.onExistSurveyChanged=e=>{e&&e.length?(this.updateMapWidgetList(),this.setState({selectedSurvey:e[0]})):this.setState({selectedSurvey:null})},this.createSurvey=()=>{if(!this.state.canCreateSurvey)return;const e=this.state.newSurveyTitle;let t=null;this.state.newSurveyTags&&this.state.newSurveyTags.length&&(t=this.state.newSurveyTags.map((e=>e.trim())));const s=this.state.newSurveySnippet;return e||this.setState({newSurveyTitleDirty:!0}),this.state.newSurveyTags&&this.state.newSurveyTags.length||this.setState({newSurveyTagsDirty:!0}),e&&t&&t.length?Promise.resolve(!0).then((()=>{var i;this.setState({newSurveyMsg:"",newSurveyLoading:!0});const a=parseInt(10*Math.random()+"")%3,r=this.state.newSurveyThumbnailUrls[a];if(this.isPortal){const s={title:e,tags:t,token:this.props.token,thumbnailUrl:r,portalUrl:this.props.config.portalUrl||this.props.portalUrl};return this.API.survey123.createSurvey(s)}return n.createSurvey(e,t,{token:this.props.token,username:null===(i=this.props.user)||void 0===i?void 0:i.username,portalUrl:this.props.config.portalUrl||this.props.portalUrl},{snippet:s,thumbnailUrl:r})})).then((e=>{if(this.isPortal&&e.id||!this.isPortal&&!0===e.success)return this.updateMapWidgetList(),this.setState({createSurveyErrorMsg:null,newSurveyItemId:e.id,selectedSurvey:e,newSurveyLoading:!1}),e.id;throw e})).then((e=>{e&&(this.props.onSettingChange({id:this.props.id,config:this.props.config.set("hides",["navbar","header","description","footer","theme"])}),this.showSurvey123DesignerModal(e))})).catch((e=>{if(e){const t=e.error?e.error:e;let s=t.message?t.message:"string"==typeof t?e:"";t.details&&t.details.length&&t.details.forEach((e=>{s+=" "+e})),this.setState({newSurveyMsg:s,newSurveyLoading:!1})}console.error(e)})):void 0},this.querySurvey=e=>(e=Object.assign({isShared:!1,isPublished:!1},e||{}),Promise.resolve(!0).then((()=>{var t;if(this.props.config.surveyItemId&&this.props.config.selectedSurvey){const s=this.props.config.selectedSurvey;setTimeout((()=>{this.props.onSettingChange({id:this.props.id,config:this.props.config.set("surveyItemId",s.id)}),this.updateMapWidgetList(),this.setState({existSurveyMsg:null,mode:"settings",selectedSurvey:s})}),0);const i={isShared:e.isShared,isPublished:e.isPublished,queryFromClient:this.isPortal,surveyClientAPI:this.API};return this.isOrgAdmin&&(i.searchSurveyType="all-admin"),n.querySurvey({username:null===(t=this.props.user)||void 0===t?void 0:t.username,token:this.props.token,portalUrl:this.props.config.portalUrl||this.props.portalUrl},i).then((e=>{const t=this.getSurveyItems(e);this.setState({existSurveys:t})}))}})).then((()=>{"none"===this.state.mode&&this.setState({mode:"survey-createSurvey"}),this.setState({existSurveyMsg:'<div class="survey-list-loading-outter"><div class="jimu-secondary-loading"></div></div>'});const t={isShared:e.isShared,isPublished:e.isPublished,queryFromClient:this.isPortal,surveyClientAPI:this.API};return this.isOrgAdmin&&(t.searchSurveyType="all-admin"),n.querySurvey({username:this.props.user.username,token:this.props.token,portalUrl:this.props.config.portalUrl||this.props.portalUrl},t)})).then((e=>{const t=this.getSurveyItems(e);this.setState({existSurveyMsg:null,existSurveys:t}),e&&e.length||this.setState({existSurveyMsg:`<p class="no-survey-message">${this.props.intl.formatMessage({id:"noExistingSurvey",defaultMessage:o.noExistingSurvey})}</p>`});const s=this.props.config.surveyItemId;if(s){const t=e.find((e=>e.id===s));t&&(this.updateMapWidgetList(),this.setState({selectedSurvey:t}),this.props.onSettingChange({id:this.props.id,config:this.props.config.set("selectedSurvey",t)}))}})).catch((e=>{this.setState({mode:"survey-createSurvey",existSurveyMsg:`<p class="error-message">${this.props.intl.formatMessage({id:"errmsgGeneralLoading",defaultMessage:o.errmsgGeneralLoading})}</p>`}),console.log(e)}))),this.getSurveyItems=t=>((t||[]).forEach((t=>{t.value=t.id,t.label=t.title,t.render=()=>(0,e.jsx)("div",{css:e.css`width: 178px;text-overflow: ellipsis; white-space: nowrap;overflow: hidden;`,title:t.title},(0,e.jsx)("span",null,t.title))})),t),this.getSurveyQuestionFields=()=>{const e=this.props.config.surveyItemId;return Promise.resolve(!0).then((()=>{if(e&&this.props.token&&this.isPortal&&this.API.getForm){const t={itemId:e,token:this.props.token,portalUrl:this.props.config.portalUrl||this.props.portalUrl||"https://www.arcgis.com"};return this.API.getForm(t).then((e=>e&&e.questions?e.questions:null))}return null})).then((t=>t||(e&&this.props.token?n.getSurveyQuestionFields(e,{token:this.props.token,portalUrl:this.props.config.portalUrl||this.props.portalUrl||"https://www.arcgis.com"}):null))).then((e=>(e&&this.setState({surveyQuestionFields:e}),e)))},this.showSettingPage=()=>{this.setState({mode:"settings"}),this.getSurveyQuestionFields()},this.handleCloseModal=()=>{if(this.state.surveyChanged)return void this.setState({isShowCloseDesignerAlert:!0});this.setState({modalIsOpen:!1}),this.setState({surveyChanged:!1}),this.showSettingPage();const e=this.state.newSurveyItemId||this.props.config.surveyItemId;e&&this.props.onSettingChange({id:this.props.id,config:this.props.config.set("surveyItemId",e).set("timestamp",Date.now()).set("mode","new")}),this.querySurvey()},this.handleCloseDesignerAlert=e=>{this.setState({isShowCloseDesignerAlert:!1}),e&&(this.setState({surveyChanged:!1}),setTimeout((()=>{this.handleCloseModal()}),0))},this.onTagInputChange=e=>{this.setState({newSurveyTags:e})},this.getThumbnailUrl=()=>{const e=this.props.config.portalUrl||this.props.portalUrl||"https://www.arcgis.com",t=this.state.selectedSurvey.id,s=this.state.selectedSurvey.thumbnail;return(s+"").startsWith("http://")||(s+"").startsWith("https://")?s:`${e}/sharing/rest/content/items/${t}/info/${s}?token=${this.props.token}`},this.setSurveyItemId=()=>{const e=this.state.selectedSurvey;e&&e.id&&(this.props.onSettingChange({id:this.props.id,config:this.props.config.set("surveyItemId",e.id).set("hides",["navbar","header","description","footer","theme"]).set("mode","new")}),this.setState({mode:"settings"}))},this.editSurvey=()=>{this.showSurvey123DesignerModal()},this.setAppearance=(e,t)=>{const s=[].concat(this.props.config.hides||[]);if(e&&s.indexOf(t)>=0){const e=s.indexOf(t);s.splice(e,1)}else s.push(t);this.props.onSettingChange({id:this.props.id,config:this.props.config.set("hides",s)})},this.setMode=e=>{this.props.config.mode!==e&&this.props.onSettingChange({id:this.props.id,config:this.props.config.set("mode",e)})},this.onMapWidgetSelected=e=>{const t=this.props.config.mode||"new";"new"===t?(e&&e.length||this.clearMapping(),this.setState({useMapWidgetIdsInNewMode:e})):"edit"===t?this.setState({useMapWidgetIdsInEditMode:e}):"view"===t&&this.setState({useMapWidgetIdsInViewMode:e}),this.props.onSettingChange({id:this.props.id,useMapWidgetIds:e})},this.updateMapWidgetList=()=>{const e=window._appState,t=window&&window.jimuConfig&&window.jimuConfig.isBuilder?e.appStateInBuilder&&e.appStateInBuilder.appConfig:e.appConfig,s=t&&t.widgets,i=s?Object.keys(s).filter((e=>s[e]&&s[e].manifest&&s[e].manifest.properties&&s[e].manifest.properties.canCreateMapView)).map((e=>s[e])):[];this.setState({mapWidgetList:i})},this.activeLinkDataChange=e=>{const t=e.currentTarget.checked;t&&this.updateMapWidgetList(),this.props.onSettingChange({id:this.props.id,config:this.props.config.set("activeLinkData",t)})},this.onFieldSelected=(e,t,s)=>{this.props.onSettingChange({id:this.props.id,config:this.props.config.setIn(["title","field"],t.name),useDataSources:[{dataSourceId:this.props.useDataSources[0].dataSourceId,mainDataSourceId:this.props.useDataSources[0].mainDataSourceId,dataViewId:this.props.useDataSources[0].dataViewId,rootDataSourceId:this.props.useDataSources[0].rootDataSourceId,fields:[t.name]}]})},this.onDataSourceSelected=e=>{const t=this.props.config.mode||"new";"new"!==t||e||this.clearMapping();const s=e?e.dataSourceId:null,i=this.dsManager.getDataSource(s),a=i?i.layer:null;"new"===t?(s&&i&&a||this.clearMapping(),this.setState({layerViewInfoInNewMode:e,dsFeatureLayer:a,dsFeatureLayerFields:this.getLayerFields(a)})):"edit"===t?this.setState({layerViewInfoInEditMode:e}):"view"===t&&this.setState({layerViewInfoInViewMode:e});const r=e?e.rootDataSourceId:null;this.props.onSettingChange({id:this.props.id,useDataSources:[{dataSourceId:s,mainDataSourceId:s,rootDataSourceId:r}],config:this.props.config.set("layerViewInfo",e).set("fieldQuestionMapping",null)})},this.addMapppingChange=(e,t)=>{const s=t.currentTarget.value;let i=this.state.addMapping?this.state.addMapping.field:null,a=this.state.addMapping?this.state.addMapping.question:null;"field"===e?i=s:a=s,this.setState({addMapping:{field:i,question:a}})},this.clearMapping=()=>{},this.onDataSourceRemoved=()=>{},this.triggerEventTypeChange=()=>{},this.showEditMappingPanel=(e,t)=>{if((this.state.editMapping||{}).index===e)return;let s=this.props.config.fieldQuestionMapping||[];s=e>=0&&e<s.length?s[e]:null;const i=Object.assign({},s);i.index=e,this.setState({editMapping:i,addMapping:null})},this.changeEditMapping=(e,t)=>{const s=t.currentTarget.value,i=Object.assign({},this.state.editMapping||{});"field"===e?i.field=s:i.question=s,this.setState({editMapping:i})},this.editMapping=e=>{const t=[].concat(this.props.config.fieldQuestionMapping||[]),s=this.state.editMapping||{};e>=0&&e<t.length&&(t[e]={field:s.field,question:s.question}),this.props.onSettingChange({id:this.props.id,config:this.props.config.set("fieldQuestionMapping",t)})},this.activeAddFieldQuestionConnPanel=()=>{this.setState({addMapping:{field:null,question:null},editMapping:null})},this.deactiveAddFieldQuestionConnPanel=()=>{this.setState({addMapping:null})},this.deleteConnection=(e,t)=>{t&&t.stopPropagation();const s=[].concat(this.props.config.fieldQuestionMapping||[]);e>=0&&e<s.length&&s.splice(e,1),this.props.onSettingChange({id:this.props.id,config:this.props.config.set("fieldQuestionMapping",s)})},this.addFieldQuestionConn=e=>{const t=this.state.addMapping.field,s=this.state.addMapping.question;if(!t||!s)return void console.log("Please ensure field/question is not null.");const i=[].concat(this.props.config.fieldQuestionMapping||[]);i.push({field:t,question:s}),this.props.onSettingChange({id:this.props.id,config:this.props.config.set("fieldQuestionMapping",i)}),this.deactiveAddFieldQuestionConnPanel()},this.onSurveyQuestionFieldChanged=e=>{const t=e.currentTarget.value;t&&"null"!==t&&this.props.onSettingChange({id:this.props.id,config:this.props.config.set("selectedSurveyQuestionFields",[t])})},this.isDsConfigured=()=>!(!this.props.useDataSources||1!==this.props.useDataSources.length),this.resetSurvey=()=>{this.props.onSettingChange({id:this.props.id,config:this.props.config.set("surveyItemId",null).set("hides",[]).set("embeds",["fullScreen","onSubmitted"]).set("selectedSurveyQuestionFields",[]).set("fieldQuestionMapping",[]).set("activeLinkData",!1).set("dsType",null).set("selectedSurvey",null).set("mode","new")}),this.setState({mode:"survey-createSurvey",selectedSurvey:null,isCheckedSurveyItemId:!1,surveyQuestionFields:[],dsMapView:null,dsFeatureLayer:null,dsFeatureLayerFields:[]})},n.setQueryObject(this.props.queryObject),this.isPortal=!e.portalUrlUtils.isAGOLDomain(this.props.config.portalUrl||this.props.portalUrl);const r=this.props.user;this.isOrgAdmin=!(!r||"org_admin"!==r.role),this.prepare().then((()=>{this.setDefaultVal(),this.querySurvey(),this.addDesigerHandler()})).catch((e=>{setTimeout((()=>{this.state.loadApiFailed&&this.setState({existSurveyMsg:`<p class="error-message">${e.message||""}</p>`,mode:"survey-createSurvey",newSurveyMsg:e.message||"",loadApiFailed:!0})}),0)}))}showSurvey123DesignerModal(t){t=t||this.props.config.surveyItemId;const s=e.SessionManager.getInstance(),i=this.props.config.portalUrl||this.props.portalUrl;if(!t)throw new Error("cannot get survey item id to open survey123 designer");let a=n.getSurvey123DesignerUrl(t,{portalUrl:i});const r=s.getMainSession();r&&r.token&&r.username&&r.tokenDuration&&(a+=`#access_token=${r.token}&username=${r.username}&expires_in=${r.tokenDuration}`),this.setState({modalIsOpen:!0,newSurveyMsg:null});const o=this;let l=0;const u=setInterval((()=>{o.state.modalIsOpen||o.setState({modalIsOpen:!0}),l++;const e=document.getElementById("survey123-designer");(e||l>100)&&(clearInterval(u),e.src=a)}),50)}render(){return this.state.selectedSurvey&&this.props.config.surveyItemId&&!1===this.state.isCheckedSurveyItemId&&(this.setState({isCheckedSurveyItemId:!0}),this.showSettingPage()),(0,e.jsx)("div",{css:d(this.props.theme),className:"jimu-widget-setting survey123"},(0,e.jsx)("div",{className:"survey123__section",style:-1!==this.state.mode.indexOf("survey-")?{display:"block"}:{display:"none"}},(0,e.jsx)(i.SettingSection,null,(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("p",{className:"choose-survey-label"},this.props.intl.formatMessage({id:"chooseSurvey",defaultMessage:o.chooseSurvey}))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)(r.Radio,{name:"survey-survey",className:"cursor-pointer",id:"survey-survey-createNewSurvey",checked:"survey-createSurvey"===this.state.mode,onChange:()=>{this.setState({mode:"survey-createSurvey"})}}),(0,e.jsx)(r.Label,{for:"survey-survey-createNewSurvey",className:"cursor-pointer"},"  ",this.props.intl.formatMessage({id:"createNewSurveyLabel",defaultMessage:o.createNewSurveyLabel}))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)(r.Radio,{name:"survey-survey",className:"cursor-pointer",id:"survey-survey-chooseExistingSurvey",checked:"survey-selectExistingSurvey"===this.state.mode,onChange:()=>{this.setState({mode:"survey-selectExistingSurvey"})}}),(0,e.jsx)(r.Label,{for:"survey-survey-chooseExistingSurvey",className:"cursor-pointer"},"  ",this.props.intl.formatMessage({id:"chooseSurveyLabel",defaultMessage:o.chooseSurveyLabel})))),(0,e.jsx)("div",{className:"survey123__section-selectExistingSurvey",style:"survey-selectExistingSurvey"===this.state.mode?{display:"block"}:{display:"none"}},(0,e.jsx)(i.SettingSection,{className:"select-survey-section"},(0,e.jsx)(i.SettingRow,null,(0,e.jsx)(r.AdvancedSelect,{size:"sm",className:"survey-dropdown",fluid:!0,staticValues:this.state.existSurveys,selectedValues:this.state.selectedSurvey?[this.state.selectedSurvey]:[],allTag:this.props.intl.formatMessage({id:"selectSurveyTip",defaultMessage:o.selectSurveyTip}),onChange:this.onExistSurveyChanged,placeholder:this.props.intl.formatMessage({id:"selectSurveyTip",defaultMessage:o.selectSurveyTip})})),(0,e.jsx)("div",{className:"survey-list-msg",dangerouslySetInnerHTML:{__html:this.state.existSurveyMsg}})),(0,e.jsx)("div",{style:{display:this.state.selectedSurvey?"block":"none"}},(0,e.jsx)(i.SettingSection,{title:this.nls("surveyDetailLabel"),className:"create-survey-container"},this.state.selectedSurvey?[(0,e.jsx)(i.SettingRow,{key:"surveyThumnail"},(0,e.jsx)("img",{src:this.getThumbnailUrl(),style:{width:"100%",height:"auto"}})),(0,e.jsx)(i.SettingRow,{key:"surveyTitle"},(0,e.jsx)("span",{style:{wordBreak:"break-word",fontSize:"0.8125rem",color:"#FFFFFF"}},this.state.selectedSurvey.title)),this.state.selectedSurvey.snippet?(0,e.jsx)(i.SettingRow,{className:"items",key:"surveySnippet"},(0,e.jsx)("h6",null,this.nls("summaryLabel")),(0,e.jsx)("div",{className:"w-100"},this.state.selectedSurvey.snippet)):null,(0,e.jsx)(i.SettingRow,{key:"surveyInsertBtn"},(0,e.jsx)(r.Button,{type:"primary",className:"w-100",onClick:this.setSurveyItemId},this.props.intl.formatMessage({id:"insertLabel",defaultMessage:o.insertLabel})))]:null))),(0,e.jsx)("div",{className:"survey123__section-createSurvey",style:"survey-createSurvey"===this.state.mode?{display:"block"}:{display:"none"}},(0,e.jsx)(i.SettingSection,null,(0,e.jsx)("div",{className:"w-100 d-flex flex-wrap align-items-center justify-content-between setting-header setting-title pb-2"},(0,e.jsx)("div",null,this.nls("surveyTitleLabel"),(0,e.jsx)("span",{className:"isRequired"},"*")),(0,e.jsx)(r.TextInput,{className:"w-100",value:this.state.newSurveyTitle||"",onChange:e=>this.onNewSurveyValueChanged(e,"newSurveyTitle")}),!this.state.newSurveyTitle&&this.state.newSurveyTitleDirty?(0,e.jsx)("div",{className:"error-message"},this.props.intl.formatMessage({id:"surveyTitleRequiredMsg",defaultMessage:o.surveyTitleRequiredMsg})):"",this.state.createSurveyErrorMsg&&!this.state.newSurveyTitleDirty?(0,e.jsx)("div",{className:"error-message"},this.props.intl.formatMessage({id:"surveyTitleDuplicateMsg",defaultMessage:o.surveyTitleDuplicateMsg})):""),(0,e.jsx)("div",{className:"w-100 d-flex flex-wrap align-items-center justify-content-between setting-header setting-title pb-2"},(0,e.jsx)("div",null,this.nls("surveyTagLabel"),(0,e.jsx)("span",{className:"isRequired"},"*")),(0,e.jsx)(r.TagInput,{data:this.state.newSurveyTags,selectListData:this.state.userTags,onChange:this.onTagInputChange,name:this.nls("surveyTagLabel"),menuProps:{maxHeight:80}}),this.state.newSurveyTags&&this.state.newSurveyTags.length||!this.state.newSurveyTagsDirty?"":(0,e.jsx)("div",{className:"error-message"},this.props.intl.formatMessage({id:"surveyTagsRequiredMsg",defaultMessage:o.surveyTagsRequiredMsg}))),(0,e.jsx)("div",{className:"w-100 d-flex flex-wrap align-items-center justify-content-between setting-header setting-title pb-2"},(0,e.jsx)("div",null,this.nls("surveySummaryLabel")),(0,e.jsx)(r.TextArea,{className:"w-100 summary",value:this.state.newSurveySnippet||"",onChange:e=>this.onNewSurveyValueChanged(e,"newSurveySnippet")})),(0,e.jsx)(i.SettingRow,{flow:"wrap"},(0,e.jsx)(r.Button,{type:"primary",className:"w-100",disabled:!0===this.state.newSurveyLoading||!this.state.canCreateSurvey||this.isPortal&&this.state.loadApiFailed,onClick:this.createSurvey},this.props.intl.formatMessage({id:"createSurveyBtn",defaultMessage:o.createSurveyBtn})),(0,e.jsx)("span",{className:"newSurvey-msg"},this.state.canCreateSurvey?this.state.newSurveyMsg:this.nls("createSurveyDisabled1")),(0,e.jsx)("div",{className:"w-100",style:{position:"relative",display:"block",marginTop:"50px"}},(0,e.jsx)("div",{className:"jimu-secondary-loading",style:!0===this.state.newSurveyLoading?{display:"block"}:{display:"none"}})))))),(0,e.jsx)("div",{className:"survey123__section",style:-1!==this.state.mode.indexOf("settings")?{display:"block"}:{display:"none"}},(0,e.jsx)(i.SettingSection,null,(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("div",{className:"section-title"},(0,e.jsx)("h6",null,this.state.selectedSurvey?this.state.selectedSurvey.title:""),(0,e.jsx)(r.Button,{className:"survey123__section-resetSurvey",onClick:()=>this.setState({mode:"confirmResetSurvey"})},(0,e.jsx)(c,{size:8})))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)(r.Button,{className:"w-100",color:"primary",type:"primary",onClick:this.editSurvey},this.props.intl.formatMessage({id:"editSurveyBtn",defaultMessage:o.editSurveyBtn})))),(0,e.jsx)(i.SettingSection,{title:this.nls("appearanceTitle")},(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("div",{className:"appearance"},(0,e.jsx)("span",null,this.props.intl.formatMessage({id:"showOptionsBarLabel",defaultMessage:o.showOptionsBarLabel})),(0,e.jsx)(r.Switch,{className:"can-x-switch",checked:!this.props.config.hides.includes("navbar"),onChange:e=>{this.setAppearance(e.target.checked,"navbar")}}))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("div",{className:"appearance"},(0,e.jsx)("span",null,this.props.intl.formatMessage({id:"showOptionsHeaderLabel",defaultMessage:o.showOptionsHeaderLabel})),(0,e.jsx)(r.Switch,{className:"can-x-switch",checked:!this.props.config.hides.includes("header"),onChange:e=>{this.setAppearance(e.target.checked,"header")}}))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("div",{className:"appearance"},(0,e.jsx)("span",null,this.props.intl.formatMessage({id:"showOptionsDesLabel",defaultMessage:o.showOptionsDesLabel})),(0,e.jsx)(r.Switch,{className:"can-x-switch",checked:!this.props.config.hides.includes("description"),onChange:e=>{this.setAppearance(e.target.checked,"description")}}))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("div",{className:"appearance"},(0,e.jsx)("span",null,this.props.intl.formatMessage({id:"showOptionsFooterLabel",defaultMessage:o.showOptionsFooterLabel})),(0,e.jsx)(r.Switch,{className:"can-x-switch",checked:!this.props.config.hides.includes("footer"),onChange:e=>{this.setAppearance(e.target.checked,"footer")}}))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("div",{className:"appearance"},(0,e.jsx)("span",null,this.props.intl.formatMessage({id:"useSurveyTheme",defaultMessage:o.useSurveyTheme})),(0,e.jsx)(r.Switch,{className:"can-x-switch",checked:!this.props.config.hides.includes("theme"),onChange:e=>{this.setAppearance(e.target.checked,"theme")}})))),(0,e.jsx)(i.SettingSection,{title:this.nls("surveyModeTitle")},(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("div",{className:"d-flex justify-content-between w-100 align-items-center"},(0,e.jsx)("div",{className:"align-items-center d-flex"},(0,e.jsx)(r.Radio,{style:{cursor:"pointer"},onChange:()=>this.setMode("new"),checked:"new"===this.props.config.mode,title:this.props.intl.formatMessage({id:"surveyModeNew",defaultMessage:o.surveyModeNew})}),(0,e.jsx)("label",{className:"m-0 ml-2",style:{cursor:"pointer"},onClick:()=>this.setMode("new"),title:this.props.intl.formatMessage({id:"surveyModeNew",defaultMessage:o.surveyModeNew})},this.props.intl.formatMessage({id:"surveyModeNew",defaultMessage:o.surveyModeNew}))))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("div",{className:"d-flex justify-content-between w-100 align-items-center"},(0,e.jsx)("div",{className:"align-items-center d-flex"},(0,e.jsx)(r.Radio,{style:{cursor:"pointer"},onChange:()=>this.setMode("edit"),checked:"edit"===this.props.config.mode,title:this.props.intl.formatMessage({id:"surveyModeEdit",defaultMessage:o.surveyModeEdit})}),(0,e.jsx)("label",{className:"m-0 ml-2",style:{cursor:"pointer"},onClick:()=>this.setMode("edit"),title:this.props.intl.formatMessage({id:"surveyModeEdit",defaultMessage:o.surveyModeEdit})},this.props.intl.formatMessage({id:"surveyModeEdit",defaultMessage:o.surveyModeEdit}))))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("div",{className:"d-flex justify-content-between w-100 align-items-center"},(0,e.jsx)("div",{className:"align-items-center d-flex"},(0,e.jsx)(r.Radio,{style:{cursor:"pointer"},onChange:()=>this.setMode("view"),checked:"view"===this.props.config.mode,title:this.props.intl.formatMessage({id:"surveyModeView",defaultMessage:o.surveyModeView})}),(0,e.jsx)("label",{className:"m-0 ml-2",style:{cursor:"pointer"},onClick:()=>this.setMode("view"),title:this.props.intl.formatMessage({id:"surveyModeView",defaultMessage:o.surveyModeView})},this.props.intl.formatMessage({id:"surveyModeView",defaultMessage:o.surveyModeView}))))),"new"===this.props.config.mode&&(0,e.jsx)(e.React.Fragment,null,(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("div",{className:"section-title"},(0,e.jsx)("h6",null,this.nls("sendDataToSurveyTitle")),(0,e.jsx)(r.Switch,{className:"can-x-switch",checked:this.props.config.activeLinkData,onChange:this.activeLinkDataChange}))),this.props.config.activeLinkData&&(0,e.jsx)(e.React.Fragment,null,this.state.mapWidgetList&&this.state.mapWidgetList.length>0?(0,e.jsx)(e.React.Fragment,null,(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("span",{className:"w-100"},this.nls("sendDataToSurveyDesc"))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("span",null,this.nls("selectSourceWidget"))),(0,e.jsx)("div",{className:"setting-row"},(0,e.jsx)(i.MapWidgetSelector,{onSelect:this.onMapWidgetSelected,useMapWidgetIds:this.state.useMapWidgetIdsInNewMode})),(0,e.jsx)(i.SettingRow,{className:"fea-layer-outter"},(0,e.jsx)(i.SettingRow,{className:"use-feature-layer-setting"},(0,e.jsx)("span",null,this.nls("selectSourceLayer"))),(0,e.jsx)("div",{className:"feature-layer-dropdown"},(0,e.jsx)(i.JimuLayerViewSelector,{onSelect:this.onDataSourceSelected,useMapWidgetIds:this.state.useMapWidgetIdsInNewMode,jimuLayerViewInfo:this.state&&this.state.layerViewInfoInNewMode}))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("span",{className:"w-100"},this.nls("triggerEventDesc1"))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("span",null,this.nls("addConnTitle"))),this.state.useMapWidgetIdsInNewMode&&this.state.useMapWidgetIdsInNewMode.length&&this.state&&this.state.layerViewInfoInNewMode&&this.state.layerViewInfoInNewMode.dataSourceId?(0,e.jsx)(e.React.Fragment,null,this.props.config.fieldQuestionMapping&&this.props.config.fieldQuestionMapping.length>0?(0,e.jsx)("div",null,this.props.config.fieldQuestionMapping.asMutable().map(((t,s)=>{const i=t.field,a=t.question;return(0,e.jsx)("div",{key:i+"_"+a+"_"+s,className:"mapping-container"},this.state.editMapping&&this.state.editMapping.index===s?(0,e.jsx)(e.React.Fragment,null,(0,e.jsx)(r.Select,{value:this.state.editMapping.field||"",style:{marginBottom:"8px"},onChange:e=>this.changeEditMapping("field",e)},this.state.dsFeatureLayerFields.map((t=>(0,e.jsx)("option",{key:"edit_"+t.name+"_"+s,value:t.name},t.alias||t.name)))),(0,e.jsx)(r.Select,{value:this.state.editMapping.question||"",onChange:e=>this.changeEditMapping("question",e)},this.state.surveyQuestionFields.length>0&&this.state.surveyQuestionFields.map((t=>(0,e.jsx)("option",{key:"edit_"+t.name+"_"+s,value:t.name},t.label)))),(0,e.jsx)("div",{className:"btn-group"},(0,e.jsx)(r.Button,{className:"float-left icon-remove-mapping",type:"primary",color:"primary",onClick:()=>{this.deleteConnection(s),this.setState({editMapping:null})}},(0,e.jsx)(f,{className:"remove-mapping"})),(0,e.jsx)(r.Button,{className:"float-right",type:"secondary",onClick:()=>{this.setState({editMapping:null})}},this.nls("cancel")),(0,e.jsx)(r.Button,{className:"float-right",type:"primary",color:"primary",onClick:()=>{this.editMapping(s),this.setState({editMapping:null})}},this.nls("ok")))):(0,e.jsx)(e.React.Fragment,null,(0,e.jsx)("div",{className:"link-info",onClick:e=>this.showEditMappingPanel(s,e)},(0,e.jsx)("p",null,this.getFielAlias(i)),(0,e.jsx)("div",{className:"center-line"},(0,e.jsx)("div",{className:"connect"},(0,e.jsx)(v,null))),(0,e.jsx)("p",null,this.getQuestionLabel(a)),(0,e.jsx)("div",{className:"delete-connect",onClick:e=>this.deleteConnection(s,e)},(0,e.jsx)(f,{size:"s"})))))}))):"",this.state.addMapping&&this.state.dsFeatureLayer&&this.state.dsFeatureLayerFields&&this.state.dsFeatureLayerFields.length>0&&(0,e.jsx)("div",{className:"mapping-container"},(0,e.jsx)(r.Select,{value:this.state.addMapping.field||"null",style:{marginBottom:"8px"},onChange:e=>this.addMapppingChange("field",e)},(0,e.jsx)("option",{key:"add_field_default",value:"null"},this.nls("addConnSelectField")),this.state.dsFeatureLayerFields.map((t=>(0,e.jsx)("option",{key:"add_"+t.name,value:t.name},t.alias||t.name)))),(0,e.jsx)(r.Select,{value:this.state.addMapping.question||"null",onChange:e=>this.addMapppingChange("question",e)},(0,e.jsx)("option",{key:"add_question_default",value:"null"},this.nls("addConnSelectQuestion")),this.state.surveyQuestionFields.length>0&&this.state.surveyQuestionFields.map((t=>(0,e.jsx)("option",{key:"add_"+t.name,value:t.name},t.label)))),(0,e.jsx)("div",{className:"btn-group"},(0,e.jsx)(r.Button,{className:"float-right",type:"secondary",onClick:this.deactiveAddFieldQuestionConnPanel},this.nls("cancel")),(0,e.jsx)(r.Button,{className:"float-right",type:"primary",disabled:!this.state.addMapping.field||"null"===this.state.addMapping.field||!this.state.addMapping.question||"null"===this.state.addMapping.question,onClick:this.addFieldQuestionConn},this.nls("ok"))))):"",(0,e.jsx)(i.SettingRow,null,(0,e.jsx)(r.Button,{className:"w-100",type:"primary",disabled:null!==this.state.addMapping||null!==this.state.editMapping||!(this.state.useMapWidgetIdsInNewMode&&this.state.useMapWidgetIdsInNewMode.length&&this.state&&this.state.layerViewInfoInNewMode&&this.state.layerViewInfoInNewMode.dataSourceId),onClick:this.activeAddFieldQuestionConnPanel},this.nls("addConnBtn")))):(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("span",null,this.nls("sendDataDisabled1"))))),"edit"===this.props.config.mode&&(0,e.jsx)(e.React.Fragment,null,this.state.mapWidgetList&&this.state.mapWidgetList.length>0?(0,e.jsx)(e.React.Fragment,null,(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("div",{className:"section-title"},(0,e.jsx)("h6",null,this.nls("chooseExistDataTitle")))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("span",{className:"w-100"},this.nls("chooseExistDataEditDesc"))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("span",null,this.nls("selectSourceWidget"))),(0,e.jsx)("div",{className:"setting-row"},(0,e.jsx)(i.MapWidgetSelector,{onSelect:this.onMapWidgetSelected,useMapWidgetIds:this.state.useMapWidgetIdsInEditMode})),(0,e.jsx)(i.SettingRow,{className:"fea-layer-outter"},(0,e.jsx)(i.SettingRow,{className:"use-feature-layer-setting"},(0,e.jsx)("span",{title:this.nls("selectSurveyLayerTip")},this.nls("selectSurveyLayer"))),(0,e.jsx)("div",{className:"feature-layer-dropdown",title:this.nls("selectSurveyLayerTip")},(0,e.jsx)(i.JimuLayerViewSelector,{onSelect:this.onDataSourceSelected,useMapWidgetIds:this.state.useMapWidgetIdsInEditMode,jimuLayerViewInfo:this.state&&this.state.layerViewInfoInEditMode}))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("span",null,this.nls("chooseExistDataLoadDesc")))):(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("span",null,this.nls("sendDataDisabled2")))),"view"===this.props.config.mode&&(0,e.jsx)(e.React.Fragment,null,this.state.mapWidgetList&&this.state.mapWidgetList.length>0?(0,e.jsx)(e.React.Fragment,null,(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("div",{className:"section-title"},(0,e.jsx)("h6",null,this.nls("chooseExistDataTitle")))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("span",{className:"w-100"},this.nls("chooseExistDataViewDesc"))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("span",null,this.nls("selectSourceWidget"))),(0,e.jsx)("div",{className:"setting-row"},(0,e.jsx)(i.MapWidgetSelector,{onSelect:this.onMapWidgetSelected,useMapWidgetIds:this.state.useMapWidgetIdsInViewMode})),(0,e.jsx)(i.SettingRow,{className:"fea-layer-outter"},(0,e.jsx)(i.SettingRow,{className:"use-feature-layer-setting"},(0,e.jsx)("span",{title:this.nls("selectSurveyLayerTip")},this.nls("selectSurveyLayer"))),(0,e.jsx)("div",{className:"feature-layer-dropdown",title:this.nls("selectSurveyLayerTip")},(0,e.jsx)(i.JimuLayerViewSelector,{onSelect:this.onDataSourceSelected,useMapWidgetIds:this.state.useMapWidgetIdsInViewMode,jimuLayerViewInfo:this.state&&this.state.layerViewInfoInViewMode}))),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("span",null,this.nls("chooseExistDataLoadDesc")))):(0,e.jsx)(i.SettingRow,null,(0,e.jsx)("span",null,this.nls("sendDataDisabled2")))))),(0,e.jsx)("div",{className:"survey123__section",style:-1!==this.state.mode.indexOf("confirmResetSurvey")?{display:"block"}:{display:"none"}},(0,e.jsx)(i.SettingSection,{title:this.nls("resetSurveyLabel")},(0,e.jsx)(i.SettingRow,null,this.props.intl.formatMessage({id:"resetSurveyTip",defaultMessage:o.resetSurveyTip})),this.props.intl.formatMessage({id:"confirmResetSurveyTip",defaultMessage:o.confirmResetSurveyTip}),(0,e.jsx)(i.SettingRow,null),(0,e.jsx)(i.SettingRow,null,(0,e.jsx)(r.Button,{type:"primary",onClick:()=>this.resetSurvey()},this.nls("yes")),(0,e.jsx)(r.Button,{onClick:()=>this.showSettingPage()},this.nls("no"))))),(0,e.jsx)(r.Modal,{isOpen:this.state.modalIsOpen,className:"w-100 h-100 p-0 m-0",css:e.css`
            z-index: 100000;
            overflow: hidden;
            max-width: 100% !important;
            .modal-content{
              width: 100%;
              height: 100%;
            }
          `},(0,e.jsx)("div",{style:{width:"100%",height:"80px",padding:"23px 60px 23px 30px",color:"#ffffff",backgroundColor:"#000000"}},(0,e.jsx)("p",{style:{fontSize:"24px",marginBottom:0,lineHeight:"33px"}},this.props.intl.formatMessage({id:"editSurveyBtn",defaultMessage:o.editSurveyBtn})),(0,e.jsx)("button",{color:"primary",onClick:this.handleCloseModal,style:{position:"absolute",top:"28px",right:"30px",backgroundColor:"#000000",color:"#ffffff",border:"0px",cursor:"pointer",padding:0}},(0,e.jsx)(c,{size:24}))),(0,e.jsx)("iframe",{id:"survey123-designer",width:"100%",style:{height:"calc(100% - 90px)",width:"100%",border:"0px"}}),(0,e.jsx)(r.AlertPopup,{isOpen:this.state.isShowCloseDesignerAlert,okLabel:this.nls("ok"),title:this.props.label,toggle:this.handleCloseDesignerAlert},(0,e.jsx)("div",{style:{fontSize:"1rem"}},this.nls("msgUnsavedBeforeLeaving")))))}}})(),u})())}}}));