1(()=>{"use strict";var e={5848:function(e,t,i){var n=this&&this.__decorate||function(e,t,i,n){var s,r=arguments.length,a=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(a=(r<3?s(a):r>3?s(t,i,a):s(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.BaseNode=t.exclude=t.include=t.dependencyTracked=t.qualifiedName=t.target=t.staticFields=t.dynamicProps=t.editableProperties=void 0;const r=i(9333),a=i(3332),o=i(8744),l=i(3820),u=s(i(8224)),d=i(4476);t.editableProperties=["value","label","description","visible","enabled","valid","errorMessage","readOnly","enum","enumNames","required","properties","exclusiveMinimum","exclusiveMaximum","maximum","maxItems","minimum","minItems","checked"],t.dynamicProps=[...t.editableProperties,"index","activeChild"],t.staticFields=["plain-text","image"];class c{constructor(e,t){this._action=e,e.target?(this._currentTarget=t,this._target=e.target):(this._target=t,this._currentTarget=t)}get type(){return this._action.type}get payload(){return this._action.payload}get metadata(){return this._action.metadata}get target(){return this._target}get currentTarget(){return this._currentTarget}get isCustomEvent(){return this._action.isCustomEvent}get originalAction(){return this._action.originalAction}toString(){return this._action.toString()}}t.target=Symbol("target"),t.qualifiedName=Symbol("qualifiedName"),t.dependencyTracked=function(){return function(e,t,i){const n=i.get;null!=n&&(i.get=function(){return this.ruleEngine.trackDependency(this,t),n.call(this)})}};const h=e=>(...t)=>(i,n,s)=>{const r=s.get;null!=r&&(s.get=function(){if(t.indexOf(this.fieldType)>-1===e)return r.call(this)});const a=s.set;null!=a&&(s.set=function(i){t.indexOf(this.fieldType)>-1===e&&a.call(this,i)})};t.include=h(!0),t.exclude=h(!1);class p{constructor(e,i){var n,s;this._options=i,this._lang="",this._callbacks={},this._dependents=[],this._tokens=[],this._eventSource=r.EventSource.CODE,this._fragment="$form",this._idSet=this.createIdSet(),this[t.qualifiedName]=null,this._jsonModel=Object.assign(Object.assign({},e),{id:this.form.getUniqueId(null==e?void 0:e.id)}),(null===(n=this.parent)||void 0===n?void 0:n.isFragment)?this._fragment=this.parent.qualifiedName:(null===(s=this.parent)||void 0===s?void 0:s.fragment)&&(this._fragment=this.parent.fragment),this._propertiesManager=new o.PropertiesManager(this)}createIdSet(){return new Set}get isContainer(){return!1}get fragment(){return this._fragment}setupRuleNode(){const e=this;this._ruleNode=new Proxy(this.ruleNodeReference(),{get:(t,i)=>e.getFromRule(t,i)})}ruleNodeReference(){return this}getRuleNode(){return this._ruleNode}getFromRule(e,i){if(i===Symbol.toPrimitive||"valueOf"===i&&!e.hasOwnProperty("valueOf"))return this.valueOf;if(i===t.target)return this;if("string"==typeof i)if(i.startsWith("$")){if("function"!=typeof this[i=i.substr(1)]){const e=this[i];return e instanceof p?e.getRuleNode():e instanceof Array?e.map((e=>e instanceof p?e.getRuleNode():e)):e}}else{if(e.hasOwnProperty(i))return e[i];if("function"==typeof e[i])return e[i]}}get id(){return this._jsonModel.id}get index(){return this.parent?this.parent.indexOf(this):0}get parent(){return this._options.parent}get type(){return this._jsonModel.type}get repeatable(){var e;return null===(e=this.parent)||void 0===e?void 0:e.hasDynamicItems()}get fieldType(){return this._jsonModel.fieldType||"text-input"}get":type"(){return this._jsonModel[":type"]||this.fieldType}get name(){return this._jsonModel.name}get screenReaderText(){return this._jsonModel.screenReaderText}get description(){return this._jsonModel.description}set description(e){this._setProperty("description",e)}get dataRef(){return this._jsonModel.dataRef}get visible(){var e,t;return void 0!==(null===(e=this.parent)||void 0===e?void 0:e.visible)?!!(null===(t=this.parent)||void 0===t?void 0:t.visible)&&this._jsonModel.visible:this._jsonModel.visible}set visible(e){if(e!==this._jsonModel.visible){const t=(0,a.propertyChange)("visible",e,this._jsonModel.visible);this._jsonModel.visible=e,this.notifyDependents(t)}}get form(){return this._options.form}get ruleEngine(){return this.form.ruleEngine}get label(){return this._jsonModel.label}set label(e){if(!(null!==e&&null!==this._jsonModel.label&&"object"==typeof e&&"object"==typeof this._jsonModel.label?JSON.stringify(e)===JSON.stringify(this._jsonModel.label):e===this._jsonModel.label)){const t=(0,a.propertyChange)("label",e,this._jsonModel.label);this._jsonModel=Object.assign(Object.assign({},this._jsonModel),{label:e}),this.notifyDependents(t)}}get uniqueItems(){return this._jsonModel.uniqueItems}
1isTransparent(){var e,t;const i="array"===(null===(t=null===(e=this.parent)||void 0===e?void 0:e._jsonModel)||void 0===t?void 0:t.type);return!this._jsonModel.name&&!i}getDependents(){return this._dependents.map((e=>({id:e.node.id,propertyName:e.propertyName})))}getState(e=!1){return this.withDependencyTrackingControl(!0,(()=>Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this._jsonModel),{properties:this.properties,index:this.index,parent:void 0,qualifiedName:this.qualifiedName}),!0===this.repeatable?{repeatable:!0,minOccur:this.parent.minItems,maxOccur:this.parent.maxItems}:{}),{":type":this[":type"]}),e?{_dependents:this._dependents.length?this.getDependents():void 0,allowedComponents:void 0,columnClassNames:void 0,columnCount:void 0,gridClassNames:void 0}:{})))}subscribe(e,t="change"){return this._callbacks[t]=this._callbacks[t]||[],this._callbacks[t].push(e),{unsubscribe:()=>{this._callbacks[t]=this._callbacks[t].filter((t=>t!==e))}}}_addDependent(e,i){if(void 0===this._dependents.find((({node:t})=>t===e))){const n=this.subscribe((n=>{const s=n.payload.changes,r=[...t.dynamicProps,"items"];s.findIndex((e=>{const t=e.propertyName;return r.includes(t)||t.startsWith("properties.")&&i===t}))>-1&&("deps"===this.form.changeEventBehaviour?e.dispatch(n):e.dispatch(new a.ExecuteRule))}));this._dependents.push({node:e,propertyName:i,subscription:n})}}removeDependent(e){const t=this._dependents.findIndex((({node:t})=>t===e));t>-1&&(this._dependents[t].subscription.unsubscribe(),this._dependents.splice(t,1))}queueEvent(e){const t=new c(e,this);this.form.getEventQueue().queue(this,t,["valid","invalid"].indexOf(t.type)>-1)}dispatch(e){this.queueEvent(e),this.form.getEventQueue().runPendingQueue()}withDependencyTrackingControl(e,t){const i=this.form.ruleEngine.getDependencyTracking();e&&this.form.ruleEngine.setDependencyTracking(!1);try{return t()}finally{e&&this.form.ruleEngine.setDependencyTracking(i)}}notifyDependents(e){const t=this._jsonModel._dependents;t&&(t.forEach((e=>{const t=this.form.getElement(e.id);t&&this._addDependent(t,e.propertyName)})),this._jsonModel._dependents=void 0),(this._callbacks[e.type]||[]).forEach((t=>{this.withDependencyTrackingControl(!0,(()=>{t(new c(e,this))}))}))}isEmpty(e=this._jsonModel.value){return null==e||""===e}_setProperty(e,t,i=!0,n=(e=>{})){const s=this._jsonModel[e];let r=!1;if(r=null!==t&&null!==s&&"object"==typeof t&&"object"==typeof s?JSON.stringify(t)===JSON.stringify(s):s===t,!r){this._jsonModel[e]=t;const r=(0,a.propertyChange)(e,t,s);return i&&this.notifyDependents(r),n.call(this,r),d.validationConstraintsList.includes(e)&&this.validate(),r.payload.changes}return[]}bindToDataModel(e){if("form"===this.fieldType||"$form"===this.id)return void(this._data=e);const i=this._jsonModel.dataRef;let n,s=e,r="";if(null===i)n=u.default;else if(void 0===i||this.repeatable){if(e!==u.default&&-1===t.staticFields.indexOf(this.fieldType)){s=e;const t=this._jsonModel.name||"",i="array"===e.$type?this.index:t;if(r=i,""!==i){const t=this.defaultDataModel(i);void 0!==t&&(n=e.$getDataNode(i),void 0===n&&(n=t,e.$addDataNode(i,n)))}else n=void 0}}else try{0===this._tokens.length&&(this._tokens=(0,l.tokenize)(i));let t=e;if(this._tokens[0].type===l.TOK_GLOBAL)t=this.form.getDataNode();else if(this._tokens[0].type===l.TOK_REPEATABLE){let e=this.parent;for(;!e.repeatable&&e!==this.form;)e=e.parent;t=e.getDataNode()}if(void 0!==t){const e=this._tokens[this._tokens.length-1].value,i=this.defaultDataModel(e);n=(0,l.resolveData)(t,this._tokens,i),s=(0,l.resolveData)(t,this._tokens.slice(0,-1)),r=e}}catch(e){console.error(`Error parsing dataRef "${i}" for field "${this.id}". The data of this field will not be exported.`)}return n&&(this.isContainer||s===u.default||n===u.default||(n=null==n?void 0:n.$convertToDataValue(),s.$addDataNode(r,n,!0)),null==n||n.$bindToField(this),this._data=n),this._data}getDataNode(){return this._data}get lang(){return this._jsonModel.lang&&(this._lang=this._jsonModel.lang),this._lang||(this.parent?this._lang=this.parent.lang:this._lang=Intl.DateTimeFormat().resolvedOptions().locale),this._lang}get properties(){return this._propertiesManager.properties}set properties(e){this._propertiesManager.properties=e}getPropertiesManager(){return this._propertiesManager}getNonTransparentParent(){let e=this.parent;for(;
1null!=e&&e.isTransparent();)e=e.parent;return e}_isAncestorRepeatable(){let e=this.parent;for(;e&&!e.repeatable;)e=e.parent;return Boolean(e)}_initialize(e){if(void 0===this._data){let e,t=this.parent;do{e=t.getDataNode(),t=t.parent}while(void 0===e);this.bindToDataModel(e)}}_applyUpdates(e,t){return e.reduce(((e,i)=>{const n=t[i],s=this._setProperty(i,n,!1);return s.length>0&&(e[i]=s[0]),e}),{})}get qualifiedName(){if(this.isTransparent())return null;if(null!==this[t.qualifiedName])return this[t.qualifiedName];const e=this.getNonTransparentParent();let i;return i=e&&"array"===e.type?`${e.qualifiedName}[${this.index}]`:`${e.qualifiedName}.${this.name}`,this._isAncestorRepeatable()||(this[t.qualifiedName]=i),i}focus(){this.parent&&(this.parent.activeChild=this)}_getDefaults(){return{}}_applyDefaultsInModel(){Object.entries(this._getDefaults()).map((([e,t])=>{void 0===this._jsonModel[e]&&void 0!==t?this._jsonModel[e]=t:"object"!=typeof t||null===t||Array.isArray(t)||Object.keys(t).forEach((i=>{void 0===this._jsonModel[e][i]&&(this._jsonModel[e][i]=t[i])}))}))}}n([function(e,t,i){const n=i.get;null!=n&&(i.get=function(){return this.ruleEngine.trackDependency(this,t),n.call(this)})}],p.prototype,"index",null),n([function(e,t,i){const n=i.get;null!=n&&(i.get=function(){return this.ruleEngine.trackDependency(this,t),n.call(this)})}],p.prototype,"description",null),n([function(e,t,i){const n=i.get;null!=n&&(i.get=function(){return this.ruleEngine.trackDependency(this,t),n.call(this)})}],p.prototype,"visible",null),n([function(e,t,i){const n=i.get;null!=n&&(i.get=function(){return this.ruleEngine.trackDependency(this,t),n.call(this)})}],p.prototype,"label",null),t.BaseNode=p},3544:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(560)),r=i(3332);class a extends s.default{click(){var e;if(!(null===(e=this._events)||void 0===e?void 0:e.click)&&this._jsonModel.buttonType)return"submit"===this._jsonModel.buttonType?this.form.dispatch(new r.Submit({validate_form:!0})):"reset"===this._jsonModel.buttonType?this.form.dispatch(new r.Reset):void 0}}t.default=a},3968:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(560));class r extends s.default{constructor(e,t){super(e,t),this._captchaDisplayMode=e.captchaDisplayMode,this._captchaProvider=e.captchaProvider,this._captchaSiteKey=e.captchaSiteKey}getDataNode(){}custom_setProperty(e){this.applyUpdates(e.payload)}get captchaDisplayMode(){return this._captchaDisplayMode}get captchaProvider(){return this._captchaProvider}get captchaSiteKey(){return this._captchaSiteKey}}t.default=r},2716:function(e,t,i){var n=this&&this.__decorate||function(e,t,i,n){var s,r=arguments.length,a=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(a=(r<3?s(a):r>3?s(t,i,a):s(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(i(560)),a=i(4476),o=i(5848);class l extends r.default{offValue(){const e=this.enum;return e.length>1?e[1]:null}_getConstraintObject(){const e=Object.assign({},super._getConstraintObject());var t;return e.required=(t=this.offValue(),(e,i)=>({valid:a.Constraints.required(e,i).valid&&(!e||i!=t),value:i})),e}_applyDefaults(){var e,t;"boolean"==typeof this._jsonModel.checked&&(this._jsonModel.checked?this._jsonModel.default=null===(e=this._jsonModel.enum)||void 0===e?void 0:e[0]:this._jsonModel.default=null===(t=this._jsonModel.enum)||void 0===t?void 0:t[1]),super._applyDefaults()}_getDefaults(){return Object.assign(Object.assign({},super._getDefaults()),{enforceEnum:!0})}get enum(){return this._jsonModel.enum||[]}updateDataNodeAndTypedValue(e){var t,i;const n=super.updateDataNodeAndTypedValue(e),s=n.find((e=>"value"===e.propertyName));if(s){const e=s.prevValue===(null===(t=this._jsonModel.enum)||void 0===t?void 0:t[0]),r=s.currentValue===(null===(i=this._jsonModel.enum)||void 0===i?void 0:i[0]);e!==r&&n.push({propertyName:"checked",prevValue:e,currentValue:r})}return n}set checked(e){var t,i;this.value=e?null===(t=this._jsonModel.enum)||void 0===t?void 0:t[0]:null===(i=this._jsonModel.enum)||void 0===i?void 0:i[1]}get checked(){var e;return this.value===(null===(e=this._jsonModel.enum)||void 0===e?void 0:e[0])}getState(e=!1,t=!1){return Object.assign(Object.assign({},super.getState(e,t)),{checked:this.checked})}}n([(0,o.dependencyTracked)()],l.prototype,"checked",null),t.default=l},7288:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esMo
1dule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(560));class r extends s.default{constructor(e,t){super(e,t)}_getFallbackType(){const e=super._getFallbackType();return"string"==typeof e?`${e}[]`:"string[]"}_getDefaults(){return Object.assign(Object.assign({},super._getDefaults()),{enforceEnum:!0,enum:[]})}}t.default=r},5504:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FIELD_TYPE=void 0,t.FIELD_TYPE={TEXT_INPUT:"text-input",EMAIL:"email",CAPTCHA:"captcha",MULTILINE_INPUT:"multiline-input",NUMBER_INPUT:"number-input",DATE_INPUT:"date-input",FILE_INPUT:"file-input",DROP_DOWN:"drop-down",RADIO_GROUP:"radio-group",PLAIN_TEXT:"plain-text",CHECKBOX:"checkbox",BUTTON:"button",PANEL:"panel",FORM:"form",CHECKBOX_GROUP:"checkbox-group",IMAGE:"image",TELEPHONE:"tel",PASSWORD:"password"}},5716:function(e,t,i){var n=this&&this.__decorate||function(e,t,i,n){var s,r=arguments.length,a=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(a=(r<3?s(a):r>3?s(t,i,a):s(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(5088),a=s(i(5376)),o=i(3332),l=s(i(9576)),u=i(5848),d=["readOnly","enabled"];class c extends a.default{constructor(e,t){var i,n;super(e,{form:t.form,parent:t.parent,mode:t.mode}),this._children=[],this._itemTemplate=null,this._isFragment=!1,this._insideFragment=!1,this._activeChild=null,this._isFragment=!0===(null===(n=null===(i=this._jsonModel)||void 0===i?void 0:i.properties)||void 0===n?void 0:n["fd:fragment"]),this.fieldFactory=t.fieldFactory}_getDefaults(){return Object.assign(Object.assign({},super._getDefaults()),{enabled:!0,readOnly:!1})}ruleNodeReference(){return this._childrenReference}get items(){return this._children}get maxItems(){return this._jsonModel.maxItems}set maxItems(e){this._jsonModel.maxItems=e;const t=this._jsonModel.minItems||1,i=this._children.length,n=Math.min(i-e,i-t);if(n>0){for(let t=0;t<n;t++)this.getDataNode().$removeDataNode(e+t),this._childrenReference.pop();const t=this._children.splice(e,n);this.notifyDependents((0,o.propertyChange)("items",t,null))}}get minItems(){return this._jsonModel.minItems}set minItems(e){this._jsonModel.minItems=e;const t=this._children.length-e,i=Math.abs(t);if(t<0){const e=[];for(let t=0;t<i;t++)e.push(this._addChild(this._itemTemplate,null,!0));this.notifyDependents((0,o.propertyChange)("items",e,null))}}hasDynamicItems(){return null!=this._itemTemplate}get isContainer(){return!0}isSiteContainer(e){return(":items"in e||"cqItems"in e)&&!("fieldType"in e)}isAFormField(e){return"fieldType"in e||"id"in e||"name"in e||"dataRef"in e||"type"in e}_getFormAndSitesState(e=!1,t=!1){return this._jsonModel.items?this._jsonModel.items.map((i=>{if(this.isSiteContainer(i)){const e=Object.assign({},(null==i?void 0:i.id)?{id:this.form.getUniqueId()}:{});return Object.assign(Object.assign(Object.assign({},i),e),{":items":this.walkSiteContainerItems(i)})}return this.isAFormField(i)?Object.assign({},this.form.getElement(null==i?void 0:i.id).getState(e,t)):i})):[]}getItemsState(e=!1,t=!1){return"array"===this._jsonModel.type||(0,r.isRepeatable)(this._jsonModel)?this._children.map((e=>Object.assign({},e.getState(!0,t)))):this._getFormAndSitesState(e,t)}getState(e=!1,t=!1){return this.withDependencyTrackingControl(!0,(()=>Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},super.getState(t)),t?{":items":void 0,":itemsOrder":void 0}:{}),{items:this.getItemsState(e,t)}),("array"===this._jsonModel.type||(0,r.isRepeatable)(this._jsonModel))&&this._itemTemplate?{_itemTemplate:Object.assign({},this._itemTemplate)}:{}),{enabled:this.enabled,readOnly:this.readOnly})))}_createChild(e,t){return this.fieldFactory.createField(e,t)}walkSiteContainerItems(e){return Object.fromEntries(Object.entries(e[":items"]).map((([e,t])=>{if(this.isAFormField(t))return[e,this.form.getElement(null==t?void 0:t.id).getState()];if(this.isSiteContainer(t))return this.walkSiteContainerItems(t);if("object"==typeof t){const i=Object.assign({},(null==t?void 0:t.id)?{id:this.form.getUniqueId()}:{});return[e,Object.assign(Object.assign({},t),i)]}return[e,t]})))}_addChildToRuleNode(e,t){const i=this,{parent:n=this}=t,s="array"==n.type?n._children.length+"":e.name||"";s.length>0&&Object.defineProperty(n._childrenReference,s,{get:()=>(e.isContainer&&e.hasDynamicItems()&&i.ruleEngine.trackDependency(e,"items"),i.hasDynamicItems()?(i.ruleEngine.trackDependency(i,"items"),void 0!==this._children[s]?this._children[s].getRuleNode():void 0):e.getRuleNode()),configurable:!0,enumerable:!0})}_addChild(e,t,i=!1,n="create"){let s=this;for(;
1null!=s&&s.isTransparent();)s=s.parent;("number"!=typeof t||t>s._children.length)&&(t=this._children.length);const a=this.form,o=Object.assign({index:t},(0,r.deepClone)(e,i?()=>a.getUniqueId():void 0)),l=this._createChild(o,{parent:this,form:this.form,mode:n});return e.id=l.id,this.form.fieldAdded(l),this._addChildToRuleNode(l,{parent:s}),t===this._children.length?this._children.push(l):this._children.splice(t,0,l),l}indexOf(e){return this._children.indexOf(e)}defaultDataModel(e){const t=this._jsonModel.type||void 0;if(void 0!==t){const i="array"===t?[]:{};return new l.default(e,i,t)}}_canHaveRepeatingChildren(e="create"){const t=this._jsonModel.items;return"array"==this._jsonModel.type&&null!=this.getDataNode()&&(1===t.length||t.length>0&&1==t[0].repeatable&&"restore"===e)}get isFragment(){var e,t;return this._isFragment||(null===(t=null===(e=this._jsonModel)||void 0===e?void 0:e.properties)||void 0===t?void 0:t["fd:fragment"])}_initialize(e){super._initialize(e);const t=this._jsonModel.items||[];if(this._childrenReference="array"==this._jsonModel.type?[]:{},this._canHaveRepeatingChildren(e)){this._itemTemplate=this._jsonModel._itemTemplate||(0,r.deepClone)(t[0]),this._jsonModel._itemTemplate=void 0,"restore"===e&&(this._itemTemplate.repeatable=void 0),"number"!=typeof this._jsonModel.minItems&&(this._jsonModel.minItems=0),"number"!=typeof this._jsonModel.maxItems&&(this._jsonModel.maxItems=-1),"number"!=typeof this._jsonModel.initialItems&&(this._jsonModel.initialItems=Math.max(1,this._jsonModel.minItems));const i="restore"===e?this._jsonModel.items.length:this._jsonModel.initialItems;for(let n=0;n<i;n++){let i;if("restore"===e){let s=this._itemTemplate;n<this._jsonModel.items.length&&(s=(0,r.deepClone)(t[n]),s.repeatable=void 0),i=this._addChild(s,void 0,n>this._jsonModel.items.length-1,e)}else i=this._addChild(this._itemTemplate,void 0,n>this._jsonModel.items.length-1);"create"===e&&(t[0].id=i.id),i._initialize(e)}}else t.length>0?(t.forEach((t=>{this.isSiteContainer(t)?this._initializeSiteContainer(t):this.isAFormField(t)?this._addChild(t,void 0,!1,e)._initialize(e):this.form.logger.warn(`A container item was not initialized. ${t}`)})),this._jsonModel.minItems=this._children.length,this._jsonModel.maxItems=this._children.length,this._jsonModel.initialItems=this._children.length):this.form.logger.warn("A container exists with no items.");this.setupRuleNode()}_initializeSiteContainer(e){Object.entries(e[":items"]).forEach((([e,t])=>{if(this.isAFormField(t))this._addChild(t)._initialize();else if(this.isSiteContainer(t))return this._initializeSiteContainer(t)}))}addItem(e){if(("addItem"===e.type||"addInstance"==e.type)&&null!=this._itemTemplate&&(-1===this._jsonModel.maxItems||this._children.length<this._jsonModel.maxItems)){const t=this.getDataNode();let i=e.payload;const n=this._addChild(this._itemTemplate,e.payload,!0);("number"!=typeof i||i>this._children.length)&&(i=this._children.length);const s=n.defaultDataModel(i);s&&t.$addDataNode(i,s,!1,this),n._initialize("create"),this.notifyDependents((0,o.propertyChange)("items",n.getState(),null)),n.dispatch(new o.Initialize),n.dispatch(new o.ExecuteRule);for(let e=i+1;e<this._children.length;e++)this._children[e].dispatch(new o.ExecuteRule)}}removeItem(e){if(("removeItem"===e.type||"removeInstance"==e.type)&&null!=this._itemTemplate){if(0==this._children.length)return;let t=e.payload;"number"!=typeof t&&(t=this._children.length-1);const i=this._children[t].getState();if(this._children.length>this._jsonModel.minItems){this._childrenReference.pop(),this._children.splice(t,1),this.getDataNode().$removeDataNode(t,this);for(let e=t;e<this._children.length;e++)this._children[e].dispatch(new o.ExecuteRule);this.notifyDependents((0,o.propertyChange)("items",null,i))}}}queueEvent(e){var t;super.queueEvent(e),(null===(t=e.metadata)||void 0===t?void 0:t.dispatch)&&this.items.forEach((t=>{t.queueEvent(e)}))}reset(){if(("array"===this.type||(0,r.isRepeatable)(this._jsonModel))&&this.items.length>this._jsonModel.initialItems){const e=this.items.length-this._jsonModel.initialItems;for(let t=0;t<e;t++)this.dispatch(new o.RemoveItem)}
1this.items.forEach((e=>{e.reset()}))}validate(){return this.items.flatMap((e=>e.validate())).filter((e=>""!==e.fieldName))}dispatch(e){super.dispatch(e)}importData(e){var t;if(void 0!==this._data&&"array"===this.type&&Array.isArray(e)){const i=new l.default(this._data.$name,e,this._data.$type,this._data.parent);try{null===(t=this._data.parent)||void 0===t||t.$addDataNode(i.$name,i,!0)}catch(e){return void this.form.logger.error(`unable to setItems for ${this.qualifiedName} : ${e}`)}this._data=i;const n=this.syncDataAndFormModel(i),s=this.items.length;n.added.forEach((e=>{this.notifyDependents((0,o.propertyChange)("items",e.getState(),null)),e.dispatch(new o.Initialize)}));for(let e=0;e<s;e+=1)this._children[e].dispatch(new o.ExecuteRule);n.removed.forEach((e=>{this.notifyDependents((0,o.propertyChange)("items",null,e.getState()))}))}else void 0===this._data&&console.warn(`Data node is null, hence importData did not work for panel "${this.name}". Check if parent has a dataRef set to null.`)}syncDataAndFormModel(e){const t={added:[],removed:[]};if("array"===(null==e?void 0:e.$type)&&null!=this._itemTemplate){const i=null==e?void 0:e.$value.length,n=this._children.length,s=-1===this._jsonModel.maxItems?i:this._jsonModel.maxItems,r=this._jsonModel.minItems;let a=Math.min(i-n,s-n);const o=Math.min(n-i,n-r);for(;a>0;){a--;const e=this._addChild(this._itemTemplate,this.items.length,!0);e._initialize("create"),t.added.push(e)}if(o>0)for(let e=0;e<o;e++)this._childrenReference.pop(),t.removed.push(this._children.pop())}return this._children.forEach((t=>{let i=t.bindToDataModel(e);t.isContainer&&!i&&(i=e),t.syncDataAndFormModel(i)})),t}get activeChild(){return this._activeChild}set activeChild(e){if(e!==this._activeChild){let t=this._activeChild;for(;t instanceof c;){const e=t.activeChild;t.activeChild=null,t=e}const i=(0,o.propertyChange)("activeChild",e,this._activeChild);this._activeChild=e,this.parent&&null!==e&&(this.parent.activeChild=this),this._jsonModel.activeChild=null==e?void 0:e.id,this.notifyDependents(i)}}get enabled(){var e;const t=null===(e=this.parent)||void 0===e?void 0:e.enabled;return void 0!==t?!!t&&this._jsonModel.enabled:this._jsonModel.enabled}set enabled(e){this._setProperty("enabled",e,!0,this.notifyChildren)}get readOnly(){var e;return void 0!==(null===(e=this.parent)||void 0===e?void 0:e.readOnly)&&!!this.parent.readOnly||this._jsonModel.readOnly}set readOnly(e){this._setProperty("readOnly",e,!0,this.notifyChildren)}notifyChildren(e){if(void 0!==e.payload&&void 0!==e.payload.changes)for(const t of e.payload.changes)void 0!==t.propertyName&&d.includes(t.propertyName)&&this.items.forEach((i=>{t.currentValue!==i._jsonModel[t.propertyName]&&(i._jsonModel[t.propertyName]=t.currentValue,this.notifyDependents.call(i,(0,o.propertyChange)(t.propertyName,i.getState()[t.propertyName],null))),"panel"===i.fieldType&&this.notifyChildren.call(i,e)}))}}n([(0,u.dependencyTracked)()],c.prototype,"maxItems",null),n([(0,u.dependencyTracked)()],c.prototype,"minItems",null),n([(0,u.dependencyTracked)()],c.prototype,"activeChild",null),t.default=c},6884:function(e,t,i){var n,s,r=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=a(i(560)),l=i(6608);class u extends o.default{constructor(){super(...arguments),n.add(this),this._dataFormat="yyyy-MM-dd"}_applyDefaults(){super._applyDefaults(),this.locale=(new Intl.DateTimeFormat).resolvedOptions().locale,this._jsonModel.editFormat||(this._jsonModel.editFormat="short"),this._jsonModel.displayFormat||(this._jsonModel.displayFormat=this._jsonModel.editFormat),this._jsonModel.placeholder||(this._jsonModel.placeholder=(0,l.parseDateSkeleton)(this._jsonModel.editFormat,this.locale))}get value(){return super.value}set value(e){if("number"==typeof e){const t=r(this,n,"m",s).call(this,e);t&&(super.value=t)}else if("short"!==this._jsonModel.editFormat&&"date|short"!==this._jsonModel.editFormat){const t=(0,l.parseDate)(e,this.locale,this._jsonModel.editFormat)||(0,l.parseDate)(e,this.locale,"yyyy-MM-dd");t instanceof Date?super.value=(0,l.formatDate)(t,this.locale,this._dataFormat):super.value=e}else super.value=e}get minimum(){return super.minimum}set minimum(e){if("number"==typeof e){const t=r(this,n,"m",s).call(this,e);t&&(super.minimum=t)}else"string"==typeof e&&(super.minimum=e)}get maximum(){return super.maximum}set maximum(e){if("number"==typeof e){const t=r(this,n,"m",s).call(this,e);t&&(super.maximum=t)}else"string"==typeof e&&(super.maximum=e)}}n=new WeakSet,s=function(e){const t=(0,l.numberToDatetime)(e);return isNaN(t)?null:(0,l.formatDate)(t,this.locale,this._dataFormat)},t.default=u},3260:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esMo
1dule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(6884));class r extends s.default{constructor(){super(...arguments),this._dataFormat="yyyy-MM-ddTHH:mm"}_applyDefaults(){super._applyDefaults()}get value(){return super.value}set value(e){super.value=e}}t.default=r},6764:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(560));class r extends s.default{_getDefaults(){return Object.assign(Object.assign({},super._getDefaults()),{format:"email"})}}t.default=r},560:function(e,t,i){var n,s,r=this&&this.__decorate||function(e,t,i,n){var s,r=arguments.length,a=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(a=(r<3?s(a):r>3?s(t,i,a):s(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a},a=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const l=i(9333),u=i(4476),d=i(3332),c=o(i(5376)),h=i(9616),p=o(i(584)),f=i(5848),m=o(i(8224)),g=i(6608),_=i(1060),v=["string","number","integer","boolean","file","string[]","number[]","integer[]","boolean[]","file[]","array","object"];class y extends c.default{constructor(e,t){super(e,t),n.add(this),this._ruleNodeReference=[],"restore"!==t.mode&&(this._applyDefaults(),this.queueEvent(new d.Initialize),"deps"===this.form.changeEventBehaviour?this.queueEvent(new d.Change({changes:[]})):this.queueEvent(new d.ExecuteRule))}_initialize(){super._initialize(),this.setupRuleNode()}ruleNodeReference(){var e;return(null===(e=this.type)||void 0===e?void 0:e.endsWith("[]"))?this._ruleNodeReference=[]:this._ruleNodeReference=this,this._ruleNodeReference}_getDefaults(){return{readOnly:!1,enabled:!0,visible:!0,label:{visible:!0,richText:!1},required:!1,type:this._getFallbackType()}}_getFallbackType(){const e=this._jsonModel.type;let t=e;if("string"!=typeof e||-1===v.indexOf(e)){const e=this.enum;t=typeof(null==e?void 0:e[0]),"undefined"===t&&void 0!==this._jsonModel.default&&(t=this._jsonModel.default instanceof Array&&this._jsonModel.default.length>0?typeof this._jsonModel.default[0]+"[]":typeof this._jsonModel.default),0===t.indexOf("undefined")&&(t={"text-input":"string","multiline-input":"string","number-input":"number","date-input":"string","date-time":"string",email:"string","plain-text":"string",image:"string",checkbox:"boolean"}[this.fieldType])}return t}_applyDefaults(){var e,t,i;super._applyDefaultsInModel(),this.coerceParam("required","boolean"),this.coerceParam("readOnly","boolean"),this.coerceParam("enabled","boolean");const n=this._jsonModel.type;if("string"==typeof n&&-1!==v.indexOf(n)||(this._jsonModel.type=this._getFallbackType()),-1===["plain-text","image"].indexOf(this.fieldType)?this._jsonModel.value=void 0:"image"===this.fieldType?this._jsonModel.value=null!==(i=null===(t=null===(e=this._jsonModel)||void 0===e?void 0:e.properties)||void 0===t?void 0:t["fd:repoPath"])&&void 0!==i?i:this._jsonModel.value:this._jsonModel.default=this._jsonModel.default||this._jsonModel.value,void 0===this._jsonModel.value){const e=u.Constraints.type(this.getInternalType()||"string",this._jsonModel.default);this._jsonModel.value=e.value}if("string"!==this._jsonModel.type&&this.unset("emptyValue"),void 0===this._jsonModel.fieldType&&(this.form.logger.debug("fieldType property is mandatory. Please ensure all the fields have a fieldType"),this._jsonModel.viewType?(this._jsonModel.viewType.startsWith("custom:")?this.form.logger.error("viewType property has been removed. For custom types, use :type property"):this.form.logger.error("viewType property has been removed. Use fieldType property"),this._jsonModel.fieldType=this._jsonModel.viewType):this._jsonModel.fieldType=(0,h.defaultFieldTypes)(this._jsonModel)),void 0===this._jsonModel.enum)"boolean"===this._jsonModel.type&&(this._jsonModel.enum=[!0,!1]);else for(void 0===this._jsonModel.enumNames&&(this._jsonModel.enumNames=this._jsonModel.enum.map((e=>e.toString())));this._jsonModel.enumNames.length<this._jsonModel.enum.length;)this._jsonModel.enumNames.push(this._jsonModel.enum[this._jsonModel.enumNames.length].toString());const s=["minimum","maximum","exclusiveMinimum","exclusiveMaximum"];"string"!==this._jsonModel.type?this.unset("format","pattern","minLength","maxLength"):"date-input"===this._jsonModel.fieldType&&(this._jsonModel.format="date"),this.coerceParam("minLength","number"),this.coerceParam("maxLength","number"),"number"!==this._jsonModel.type&&"date"!==this._jsonModel.format&&"date-time"!==this._jsonModel.format&&"integer"!==this._jsonModel.type&&this.unset("step",...s),s.forEac
1h((e=>{this.coerceParam(e,"integer"===this._jsonModel.type?"number":this._jsonModel.type)})),"number"!=typeof this._jsonModel.step&&this.coerceParam("step","number")}unset(...e){e.forEach((e=>this._jsonModel[e]=void 0))}coerceParam(e,t){const i=this._jsonModel[e];if(void 0!==i&&typeof i!==t){this.form.logger.info(`${e} is not of type ${t}. Trying to coerce.`);try{this._jsonModel[e]=(0,u.coerceType)(i,t)}catch(t){this.form.logger.warn(t),this.unset(e)}}}get editFormat(){return this.withCategory(this._jsonModel.editFormat)}get displayFormat(){return this.withCategory(this._jsonModel.displayFormat)}get displayValueExpression(){return this._jsonModel.displayValueExpression}get placeholder(){return this._jsonModel.placeholder}get readOnly(){return void 0!==this.parent.readOnly&&!0===this.parent.readOnly||this._jsonModel.readOnly}set readOnly(e){this._setProperty("readOnly",e)}get enabled(){var e;const t=null===(e=this.parent)||void 0===e?void 0:e.enabled;return void 0!==t?!!t&&this._jsonModel.enabled:this._jsonModel.enabled}set enabled(e){this._setProperty("enabled",e)}get valid(){var e,t;return null===(t=null===(e=this._jsonModel)||void 0===e?void 0:e.validity)||void 0===t?void 0:t.valid}set valid(e){const t=Object.assign({valid:e},e?{}:{customConstraint:!0});this._setProperty("valid",e),this._setProperty("validity",t)}get validity(){return this._jsonModel.validity}get emptyValue(){return"null"===this._jsonModel.emptyValue?null:""===this._jsonModel.emptyValue&&"string"===this.type?"":void 0}get enum(){return this._jsonModel.enum}set enum(e){this._setProperty("enum",e)}get enumNames(){return this._jsonModel.enumNames}set enumNames(e){this._setProperty("enumNames",e)}get required(){return this._jsonModel.required||!1}set required(e){this._setProperty("required",e)}get maximum(){if("number"===this.type||"date"===this.format||"date-time"===this.format||"integer"===this.type)return this._jsonModel.maximum}set maximum(e){"number"!==this.type&&"date"!==this.format&&"date-time"!==this.format&&"integer"!==this.type||this._setProperty("maximum",e)}get minimum(){if("number"===this.type||"date"===this.format||"date-time"===this.format||"integer"===this.type)return this._jsonModel.minimum}set minimum(e){"number"!==this.type&&"date"!==this.format&&"date-time"!==this.format&&"integer"!==this.type||this._setProperty("minimum",e)}withCategory(e){return e&&null===(null==e?void 0:e.match(/^(?:date|num)\|/))?("date"===this.format?e=`date|${e}`:"number"!==this.type&&"integer"!==this.type||(e=`num|${e}`),e):e}get editValue(){const e=this.editFormat;if(!e||!this.isNotEmpty(this.value)||!1===this.valid)return this.value;try{return(0,g.format)(this.value,this.lang,e)}catch(e){return this.value}}get displayValue(){var e,t;if(this.displayValueExpression&&"string"==typeof this.displayValueExpression&&0!==this.displayValueExpression.length)return this.executeExpression(this.displayValueExpression);const i=this.displayFormat;if(!i||!this.isNotEmpty(this.value)||!0===(null===(e=null==this?void 0:this.validity)||void 0===e?void 0:e.typeMismatch)||("date"===this.format||"date-time"===this.format)&&!0===(null===(t=null==this?void 0:this.validity)||void 0===t?void 0:t.formatMismatch))return this.value;try{return(0,g.format)(this.value,this.lang,i)}catch(e){return this.value}}getDataNodeValue(e){return this.isEmpty()?this.emptyValue:e}updateDataNodeAndTypedValue(e){const t=this.getDataNode();if(f.staticFields.indexOf(this.fieldType)>-1&&void 0!==t&&t!==m.default)return;const i=this._getConstraintObject().type(this.getInternalType()||"string",e),n=this._setProperty("value",i.value,!1);return n.length>0&&(this._updateRuleNodeReference(i.value),void 0!==t&&t.setValue(this.getDataNodeValue(this._jsonModel.value),this._jsonModel.value,this)),n}get value(){return void 0===this._jsonModel.value?null:this._jsonModel.value}set value(e){const t=this.updateDataNodeAndTypedValue(e);let i={valid:!0},n="type";if((null==t?void 0:t.length)>0){let s={};const r=u.Constraints.type(this.getInternalType()||"string",e);if(this.parent.uniqueItems&&"array"===this.parent.type&&(i=u.Constraints.uniqueItems(this.parent.uniqueItems,this.parent.getDataNode().$value),n="uniqueItems"),r.valid&&i.valid)s=this.evaluateConstraints();else{const e=r.valid&&i.valid,t=Object.assign({valid:e,errorMessage:r.valid&&i.valid?"":this.getErrorMessage("type")},e?{}:{validationMessage:e?"":this.getErrorMessage(n),validity:{valid:e,[l.constraintKeys[n]]:!0}});s=this._applyUpdates(["valid","errorMessage","validationMessage","validity"],t)}s.valid&&this.triggerValidationEvent(s);const a=new d.Change({changes:t.concat(Object.values(s)),eventSource:this._eventSource});this.dispatch(a)}}uiChange(e){this._eventSource=l.EventSource.UI,"value"in e.payload?this.value=e.payload.value:"checked"in e.payload&&(this.checked=e.payload.checked),this._eventSource=l.EventSource.CODE}reset(){const e=this.updateDataNodeAndTypedValue(this.default);if(!e)return;const t=this._applyUpdates(["valid","errorMessage","validationMessage","validity"],{valid:void 0,errorMessage:"",validationMessage:"",validity:{valid:void 0}}),i=new d.Change({changes:e.concat(Object.values(t))});this.dispatch(i)}_updateRuleNodeReference(e){var t;if(null===(t=this.type)||void 0===t?void 0:t.endsWith("[]"))if(null!=e)for(e.forEach(((e,t)=>{this._ruleNodeReference[t]=e}));e.length!==this._ruleNodeReference.length;)this._ruleNodeReference.pop();else for(;0!==this._ruleNodeReference.length;)this._ruleNodeReference.pop()}getInternalType(){return this.type}valueOf(){const e=this[f.target],t=void 0===e?this:e;return t.ruleEngine.trackDependency(t,"value"),t._jsonModel.value||null}toString(){var e;const t=this[f.target];return(null===(e=(void 0===t?this:t)._jsonModel.value)||void 0===e?void 0:e.toString())||""}getErrorMessage(e){var t;const i=e,n=l.constraintKeys[i],s=(0,l.getConstraintTypeMessages)();return(null===(t=this._jsonModel.constraintMessages)||void 0===t?void 0:t["exclusiveMaximum"===i?"maximum":"exclusiveMinimum"===i?"minimum":i])||(0,_.replaceTemplatePlaceholders)(s[n],[this._jsonModel[i]])}get errorMessage(){return this._jsonModel.errorMessage}set errorMessage(e){this._setProperty("errorMessage",e),this._setProperty("validationMessage",e)}_getConstraintObject(){return u.Constraints}isArrayType(){return!!this.type&&this.type.indexOf("[]")>-1}checkEnum(e,t){if(!0===this._jsonModel.enforceEnum&&null!=e){const i=t.enum;return e instanceof Array&&this.isArrayType()?e.every((e=>i(this.enum||[],e).valid)):i(this.enum||[],e).valid}return!0}checkStep(){var e,t;const i=this._jsonModel.value,n=this._jsonModel.step;if("number"==typeof n){const s=(null===(t=null===(e=n.toString().split("."))||void 0===e?void 0:e[1])||void 0===t?void 0:t.length)||0,r=Math.pow(10,s),a=n*r,o=i*r,l=(this._jsonModel.minimum||this._jsonModel.default||0)*r,u=(o-l)/a,d=Math.abs(o-l)%a<.001;let c,h;return d||(c=(Math.ceil(u)*a+l)/r,h=(c-a)/r),{valid:d,next:c,prev:h}}return{valid:!0}}checkValidationExpression(){const e=this._jsonModel.validationExpression;return"string"!=typeof e||0===e.length||this.executeExpression(e)}getConstraints(){switch(this.type){case"string":switch(this.format){case"date":return u.ValidConstraints.date;case"date-time":return u.ValidConstraints.datetime;case"email":return u.ValidConstraints.email;case"binary":case"data-url":return u.ValidConstraints.file;default:return u.ValidConstraints.string}case"file":return u.ValidConstraints.file;case"number":case"integer":return u.ValidConstraints.number}return this.isArrayType()?u.ValidConstraints.array:[]}get format(){if(void 0===this._jsonModel.format&&"string"===this.type)switch(this.fieldType){case"date-input"
1:this._jsonModel.format="date";break;case"file-input":this._jsonModel.format="data-url";break;case"date-time":this._jsonModel.format="date-time"}return this._jsonModel.format}get enforceEnum(){return this._jsonModel.enforceEnum}get tooltip(){return this._jsonModel.tooltip}get maxLength(){return this._jsonModel.maxLength}get minLength(){return this._jsonModel.minLength}get pattern(){return this._jsonModel.pattern}get step(){if("number"===this.type||"date"===this.format)return this._jsonModel.step}get exclusiveMinimum(){if("number"===this.type||"date"===this.format||"integer"===this.type)return this._jsonModel.exclusiveMinimum}set exclusiveMinimum(e){"number"!==this.type&&"date"!==this.format&&"integer"!==this.type||(this._jsonModel.exclusiveMinimum=e)}get exclusiveMaximum(){if("number"===this.type||"date"===this.format||"integer"===this.type)return this._jsonModel.exclusiveMaximum}set exclusiveMaximum(e){"number"!==this.type&&"date"!==this.format&&"integer"!==this.type||(this._jsonModel.exclusiveMaximum=e)}get default(){return this._jsonModel.default}isNotEmpty(e){return null!=e&&""!==e}evaluateConstraints(){let e="type";const t=this._jsonModel,i=this._jsonModel.value,n=this._getConstraintObject(),s=this.getConstraints();let r=!0;if(r&&(r=n.required(this.required,i).valid&&(!this.isArrayType()||!this.required||i.length>0),e="required"),r&&this.isNotEmpty(i)){const a=s.find((e=>{if(e in t&&void 0!==t[e]){const s=t[e],r=n[e];return i instanceof Array&&this.isArrayType()?-1!==u.ValidConstraints.array.indexOf(e)?!r(s,i).valid:i.some((e=>!r(s,e).valid)):"function"==typeof r&&!r(s,i).valid}return!1}));null!=a?(r=!1,e=a):(r=this.checkEnum(i,n),e="enum",r&&"number"===this.type&&(r=this.checkStep().valid,e="step"),r&&(r=this.checkValidationExpression(),e="validationExpression"))}r||this.form.logger.info(`${e} constraint evaluation failed ${this._jsonModel[e]}. Received ${this._jsonModel.value}`);const a=Object.assign({valid:r,errorMessage:r?"":this.getErrorMessage(e)},{validationMessage:r?"":this.getErrorMessage(e),validity:Object.assign({valid:r},r?{}:{[l.constraintKeys[e]]:!0})});return this._applyUpdates(["valid","errorMessage","validationMessage","validity"],a)}triggerValidationEvent(e){e.validity&&a(this,n,"m",s).call(this)}validate(){var e;if(!1===this.visible)return[];if(!1===this.valid&&this.errorMessage&&(null===(e=null==this?void 0:this.validity)||void 0===e?void 0:e.customConstraint))return[new l.ValidationError(this.id,[this._jsonModel.errorMessage])];const t=this.evaluateConstraints();return a(this,n,"m",s).call(this),t.validity&&this.notifyDependents(new d.Change({changes:Object.values(t)})),this.valid?[]:[new l.ValidationError(this.id,[this._jsonModel.errorMessage])]}syncDataAndFormModel(e){if(void 0!==e&&e!==m.default&&e.$value!==this._jsonModel.value){const t=(0,d.propertyChange)("value",e.$value,this._jsonModel.value);this._jsonModel.value=e.$value,this.queueEvent(t)}}defaultDataModel(e){const t=f.staticFields.indexOf(this.fieldType)>-1?void 0:this.getDataNodeValue(this._jsonModel.value);return new p.default(e,t,this.type||"string")}getState(e=!1,t=!1){return Object.assign(Object.assign({},super.getState(t)),{editFormat:this.editFormat,displayFormat:this.displayFormat,editValue:this.editValue,displayValue:this.displayValue,enabled:this.enabled,readOnly:this.readOnly})}markAsInvalid(e,t=null){const i={valid:!1,errorMessage:e,validationMessage:e,validity:Object.assign({valid:!1},null!=t?{[l.constraintKeys[t]]:!0}:{customConstraint:!0})},n=this._applyUpdates(["valid","errorMessage","validationMessage","validity"],i),s=new d.Change({changes:[].concat(Object.values(n))});0!==s.payload.changes.length&&(this.triggerValidationEvent(n),this.dispatch(s))}}n=new WeakSet,s=function(){this.validity.valid?this.dispatch(new d.Valid):this.dispatch(new d.Invalid)},r([(0,f.dependencyTracked)(),(0,f.exclude)("button","image","plain-text")],y.prototype,"readOnly",null),r([(0,f.dependencyTracked)(),(0,f.exclude)("image","plain-text")],y.prototype,"enabled",null),r([(0,f.dependencyTracked)()],y.prototype,"valid",null),r([(0,f.dependencyTracked)()],y.prototype,"validity",null),r([(0,f.depen
1dencyTracked)()],y.prototype,"enum",null),r([(0,f.dependencyTracked)()],y.prototype,"enumNames",null),r([(0,f.dependencyTracked)()],y.prototype,"required",null),r([(0,f.include)("date-input","number-input")],y.prototype,"editValue",null),r([(0,f.dependencyTracked)()],y.prototype,"value",null),r([(0,f.dependencyTracked)()],y.prototype,"errorMessage",null),r([(0,f.include)("text-input","date-input","file-input","email","datetime-input")],y.prototype,"format",null),r([(0,f.include)("text-input")],y.prototype,"maxLength",null),r([(0,f.include)("text-input")],y.prototype,"minLength",null),r([(0,f.include)("text-input")],y.prototype,"pattern",null),r([(0,f.dependencyTracked)()],y.prototype,"exclusiveMinimum",null),r([(0,f.dependencyTracked)()],y.prototype,"exclusiveMaximum",null),t.default=y},2692:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Fieldset=void 0;const s=n(i(5716)),r=i(3332);class a extends s.default{constructor(e,t){super(e,t),"restore"!==t.mode&&(this._applyDefaults(),this.queueEvent(new r.Initialize),this.queueEvent(new r.ExecuteRule))}_getDefaults(){return Object.assign(Object.assign({},super._getDefaults()),{visible:!0,required:!1,label:{visible:!0,richText:!1}})}_applyDefaults(){super._applyDefaultsInModel(),this._jsonModel.dataRef&&void 0===this._jsonModel.type&&(this._jsonModel.type="object")}get type(){const e=super.type;if("array"===e||"object"===e)return e}get items(){return super.items?super.items:[]}get value(){var e;return null===(e=this.getDataNode())||void 0===e?void 0:e.$value}get fieldType(){return"panel"}}t.Fieldset=a},6440:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FileObject=void 0,t.FileObject=class{constructor(e){this.mediaType="application/octet-stream",this.name="unknown",this.size=0,Object.assign(this,e)}get type(){return this.mediaType}set type(e){this.mediaType=e}toJSON(){return{name:this.name,size:this.size,mediaType:this.mediaType,data:this.data.toString()}}equals(e){return this.data===e.data&&this.mediaType===e.mediaType&&this.name===e.name&&this.size===e.size}}},5432:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function o(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,o)}l((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(3332),a=s(i(560)),o=i(1060),l=i(6440),u=i(4476),d=s(i(8224));function c(e,t){return e.replace(";base64",`;name=${encodeURIComponent(t)};base64`)}function h(e){return n(this,void 0,void 0,(function*(){const{name:t,size:i,type:n}=e;return yield new Promise(((s,r)=>{const a=new FileReader;a.onload=e=>{s(new l.FileObject({data:c(e.target.result,t),type:n,name:t,size:i}))},a.readAsDataURL(e.data)}))}))}class p extends a.default{_getDefaults(){return Object.assign(Object.assign({},super._getDefaults()),{accept:["audio/*","video/*","image/*","text/*","application/pdf"],maxFileSize:"2MB"})}_getFallbackType(){return"file"}get maxFileSize(){return(0,o.getFileSizeInBytes)(this._jsonModel.maxFileSize)}get accept(){return this._jsonModel.accept}_applyUpdates(e,t){return e.reduce(((e,i)=>{const n=this._jsonModel[i],s=t[i];return s!==n&&(e[i]={propertyName:i,currentValue:s,prevValue:n},n instanceof l.FileObject&&"object"==typeof s&&"value"===i?this._jsonModel[i]=new l.FileObject(Object.assign(Object.assign({},n),{data:s.data})):this._jsonModel[i]=s),e}),{})}getInternalType(){var e;return(null===(e=this.type)||void 0===e?void 0:e.endsWith("[]"))?"file[]":"file"}getDataNodeValue(e){var t;let i=e;return null!=i&&("string"===this.type?i=null===(t=i.data)||void 0===t?void 0:t.toString():"string[]"===this.type&&(i=i instanceof Array?i:[i],i=i.map((e=>{var t;return null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.toString()})))),i}serialize(){return n(this,void 0,void 0,(function*(){const e=this._jsonModel.value;return void 0===e?null:yield(t=e instanceof Array?e:[e],Promise.all([].map.call(t,h)));var t}))}syncDataAndFormModel(e){if(void 0!==e&&e!==d.default){const t=null==e?void 0:e.$value;if(null!=t){const e=u.Constraints.type(this.getInternalType(),t);e.valid||this.form.logger.debug(`unable to bind ${this.name} to data`),this.form.getEventQueue().queue(this,(0,r.propertyChange)("value",e.value,this._jsonModel.value)),this._jsonModel.value=e.value}else this._jsonModel.value=null}}}t.default=p},3416:function(e,t,i){var n,s,r,a,o,l,u,d=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Prom
1ise))((function(s,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function o(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,o)}l((n=n.apply(e,t||[])).next())}))},c=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.currentVersion=void 0;const p=h(i(5716)),f=h(i(1316)),m=h(i(5840)),g=h(i(9712)),_=i(3332),v=i(2267),y=h(i(9576)),b=i(7279),E=i(9333),T=i(1060),M=i(7888),I=i(7177);t.currentVersion=new I.Version("0.13");const O=new I.Version("0.13");class w extends p.default{constructor(e,t,i,s=new g.default,r="off",a="create"){super(e,{fieldFactory:t,mode:a}),this._ruleEngine=i,this._eventQueue=s,n.add(this),this.additionalSubmitMetadata={},this._fields={},this._invalidFields=[],this._exportDataAttachmentMap={},this.promises=[],this._captcha=null,this.dataRefRegex=/("[^"]+?"|[^.]+?)(?:\.|$)/g,this._logger=new v.Logger(r),this._applyDefaultsInModel(),"create"===a&&(this.queueEvent(new _.Initialize),"deps"===this.changeEventBehaviour?this.queueEvent(new _.Change({changes:[]})):this.queueEvent(new _.ExecuteRule)),this._ids=(0,T.IdGenerator)(),this.bindToDataModel(new y.default("$form",{})),this._initialize(a),"create"===a&&this.queueEvent(new _.FormLoad)}addPromises(e){this.promises.push(e)}waitForPromises(){return d(this,void 0,void 0,(function*(){let e=0;for(;this.promises.length>e;)e=this.promises.length,yield Promise.all(this.promises);this.promises=[]}))}_applyDefaultsInModel(){const e=this.specVersion;this._jsonModel.properties=this._jsonModel.properties||{},this._jsonModel.fieldType=this._jsonModel.fieldType||"form",(e.lessThan(O)||"string"!=typeof this._jsonModel.properties["fd:changeEventBehaviour"])&&(this._jsonModel.properties["fd:changeEventBehaviour"]="self")}get activeField(){return this._findActiveField(this)}_findActiveField(e){return(null==e?void 0:e.isContainer)?this._findActiveField(null==e?void 0:e.activeChild):e}get logger(){return this._logger}get changeEventBehaviour(){return"deps"===this.properties["fd:changeEventBehaviour"]?"deps":"self"}get metaData(){const e=this._jsonModel.metadata||{};return new f.default(e)}get action(){return this._jsonModel.action}get isFragment(){return!1}importData(e){this.bindToDataModel(new y.default("$form",e)),this.syncDataAndFormModel(this.getDataNode()),this._eventQueue.runPendingQueue()}exportData(e={}){var t;this._exportDataAttachmentMap=e;const i=null===(t=this.getDataNode())||void 0===t?void 0:t.$value;return this._exportDataAttachmentMap={},i}setAdditionalSubmitMetadata(e){this.additionalSubmitMetadata=Object.assign(Object.assign({},this.additionalSubmitMetadata),e)}get specVersion(){if("string"!=typeof this._jsonModel.adaptiveform)return t.currentVersion;try{return new I.Version(this._jsonModel.adaptiveform)}catch(e){return console.log(e),console.log("Falling back to default version"+t.currentVersion.toString()),t.currentVersion}}resolveQualifiedName(e){if(this.qualifiedName===e)return this;let t=null;return this.visit((i=>{i.qualifiedName===e&&(t=i)})),t}exportSubmitMetaData(){return this.withDependencyTrackingControl(!0,(()=>{const e={};this.visit((t=>{"captcha"===t.fieldType&&(e[t.qualifiedName]=t.value)}));const t={},i=this.properties["fd:draftId"]||"";i&&(t["fd:draftId"]=i);const n=this.properties["fd:dor"];if(n&&"none"!==n.dorType){const e=n["fd:excludeFromDoRIfHidden"];let i=[];i=Object.values(this._fields).filter((t=>!1===t.enabled||e&&!1===t.visible)).map((e=>(0,M.transformFieldName)(e.qualifiedName))),i&&i.length>0&&(t.excludeFromDoR=i)}Object.keys(t).length>0&&this.setAdditionalSubmitMetadata(t);const s=Object.assign({lang:this.lang,captchaInfo:e},this.additionalSubmitMetadata);return new m.default(s)}))}setFocus(e,t){const i=this._ruleEngine.getDependencyTracking();this._ruleEngine.setDependencyTracking(!1);try{if(!t)return c(this,n,"m",u).call(this,e),void c(this,n,"m",a).call(this,e);const i=(null==e?void 0:e.isContainer)?e:e.parent,r=c(this,n,"m",s).call(this,i.items);let d=i.activeChild,h=null!==d?r.indexOf(d):-1;if(null===i.activeChild)return c(this,n,"m",a).call(this,r[0]),void(h=0);t===E.FocusOption.NEXT_ITEM?d=c(this,n,"m",o).call(this,h,r):t===E.FocusOption.PREVIOUS_ITEM&&(d=c(this,n,"m",l).call(this,h,r)),null!==d&&c(this,n,"m",a).call(this,d)}finally{this._ruleEngine.setDependencyTracking(i)}}getState(e=!1){const t=this,i=super.getState(!1,e);return i.id="$form",Object.defineProperty(i,"data",{get:function(){return t.exportData()}}),Object.defineProperty(i,"attachments",{get:function(){return(0,T.getAttachments)(t)}}),i}get type(){return"object"}
1isTransparent(){return!1}get form(){return this}get ruleEngine(){return this._ruleEngine}getUniqueId(e){var t,i,n;if(e&&!(null===(t=this._idSet)||void 0===t?void 0:t.has(e)))return null===(i=this._idSet)||void 0===i||i.add(e),e;if(null==this._ids)return"";const s=this._ids.next().value;return null===(n=this._idSet)||void 0===n||n.add(s),s}clearIdRegistry(){var e;null===(e=this._idSet)||void 0===e||e.clear()}fieldAdded(e){"captcha"!==e.fieldType||this._captcha||(this._captcha=e),this._fields[e.id]=e,e.subscribe((e=>{-1===this._invalidFields.indexOf(e.target.id)&&this._invalidFields.push(e.target.id)}),"invalid"),e.subscribe((e=>{const t=this._invalidFields.indexOf(e.target.id);t>-1&&this._invalidFields.splice(t,1)}),"valid"),e.subscribe((e=>{const t=e.target.getState();if(e.payload.changes.length>0&&t){const i=e=>e&&"object"==typeof e?Array.isArray(e)?e.map(i):Object.assign({},e):e,n=e.payload.changes.map((({propertyName:e,currentValue:t,prevValue:n})=>({propertyName:e,currentValue:i(t),prevValue:i(n)}))),s=new _.FieldChanged(n,t,e.payload.eventSource);this.notifyDependents(s)}}))}visit(e){this.traverseChild(this,e)}traverseChild(e,t){e.items.forEach((e=>{e.isContainer&&this.traverseChild(e,t),t(e)}))}validate(){const e=super.validate();return this.dispatch(new _.ValidationComplete(e)),e}isValid(){return 0===this._invalidFields.length}dispatch(e){"submit"===e.type?(super.queueEvent(e),this._eventQueue.runPendingQueue()):super.dispatch(e)}submit(e,t){var i;if(!1===(null===(i=null==e?void 0:e.payload)||void 0===i?void 0:i.validate_form)||0===this.validate().length){const i=(null==e?void 0:e.payload)||{},n=(null==i?void 0:i.success)?null==i?void 0:i.success:"submitSuccess",s=(null==i?void 0:i.error)?null==i?void 0:i.error:"submitError",r=i.action||this.action,a=i.metadata||{submitMetadata:this.exportSubmitMetaData()},o=(null==i?void 0:i.save_as)||(null==i?void 0:i.submit_as);(0,b.submit)(t,n,s,o,null==i?void 0:i.data,r,a)}}save(e,t){const i=(null==e?void 0:e.payload)||{};i.save_as="multipart/form-data",i.metadata={draftMetadata:{lang:this.lang,"fd:draftId":this.properties["fd:draftId"]||""}},i.success="custom:saveSuccess",i.error="custom:saveError",this.submit(e,t),this.subscribe((e=>{this._saveSuccess(e)}),"saveSuccess")}_saveSuccess(e){var t,i;const n=(null===(i=null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.body)||void 0===i?void 0:i.draftId)||"",s=this.properties;n&&s&&(s["fd:draftId"]=n)}reset(){super.reset(),this._invalidFields=[]}getElement(e){return e==this.id?this:this._fields[e]}get qualifiedName(){return"$form"}getEventQueue(){return this._eventQueue}get name(){return"$form"}get value(){return null}get id(){return this._jsonModel.id||"$form"}get title(){return this._jsonModel.title||""}get captcha(){return this._captcha}}n=new WeakSet,s=function(e){return e.filter((e=>!0===e.visible))},r=function(e){const t=c(this,n,"m",s).call(this,e.items);return t&&t.length>0?t[0]:null},a=function e(t){if(!t.isContainer)return void(t.parent.activeChild=t);c(this,n,"m",u).call(this,t);const i=t.activeChild||c(this,n,"m",r).call(this,t);null!==i?c(this,n,"m",e).call(this,i):t.parent.activeChild=t},o=function(e,t){return e<t.length-1?t[e+1]:null},l=function(e,t){return e>0?t[e-1]:null},u=function(e){const t=e.parent;null!=t&&null!=t.activeChild&&(t.activeChild=null)},t.default=w},9916:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,s)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return s(t,e),t},a=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function o(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,o)}l((n=n.apply(e,t||[])).next())}))}
1,o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerFunctions=t.fetchForm=t.validateFormData=t.validateFormInstance=t.restoreFormInstance=t.createFormInstanceSync=t.createFormInstance=void 0;const l=r(i(3416)),u=i(5088),d=i(372),c=o(i(6552)),h=o(i(9712)),p=i(2267),f=i(8608),m=i(7279),g=i(1060),_=o(i(9576)),v=(e,t,i)=>{let n=i;null==n&&(e=(0,g.sitesModelToFormModel)(e),n=new l.default(Object.assign({},e),f.FormFieldFactory,new c.default,new h.default(new p.Logger(t)),t));const s=null==e?void 0:e.data;return s&&n.importData(s),n};t.createFormInstance=(e,t,i="error",n=void 0)=>{try{const s=v(e,i,n);return"function"==typeof t&&t(s),s.getEventQueue().runPendingQueue(),s}catch(e){throw console.error(`Unable to create an instance of the Form ${e}`),new Error(e)}},t.createFormInstanceSync=(e,t,i="error",n=void 0)=>a(void 0,void 0,void 0,(function*(){try{const s=v(e,i,n);return"function"==typeof t&&t(s),s.getEventQueue().runPendingQueue(),yield s.waitForPromises(),s}catch(e){throw console.error(`Unable to create an instance of the Form ${e}`),new Error(e)}})),t.createFormInstance.currentVersion=l.currentVersion;const y={logLevel:"error"};t.restoreFormInstance=(e,t=null,{logLevel:i}=y)=>{try{const n=new l.default(Object.assign({},e),f.FormFieldFactory,new c.default,new h.default(new p.Logger(i)),i,"restore");return t&&(n.bindToDataModel(new _.default("$form",t)),n.syncDataAndFormModel(n.getDataNode())),n.getEventQueue().empty(),n}catch(e){throw console.error(`Unable to restore an instance of the Form ${e}`),new Error(e)}},t.validateFormInstance=(e,t)=>{try{const i=new l.default(Object.assign({},e),f.FormFieldFactory,new c.default);return t&&i.importData(t),0===i.validate().length}catch(e){throw new Error(e)}},t.validateFormData=(e,t)=>{try{const i=new l.default(Object.assign({},e),f.FormFieldFactory,new c.default);t&&i.importData(t);const n=i.validate();return{messages:n,valid:0===n.length}}catch(e){throw new Error(e)}},t.fetchForm=(e,t={})=>{const i=new Headers;return Object.entries(t).forEach((([e,t])=>{i.append(e,t)})),new Promise(((i,n)=>{(0,d.request)(`${e}.model.json`,null,{headers:t}).then((e=>{if(200!==e.status)n("Not Found");else{let t=e.body;if("model"in t){const{model:e}=t;t=e}i((0,u.jsonString)(t))}}))}))},t.registerFunctions=e=>{m.FunctionRuntime.registerFunctions(e)}},1316:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(140));class r extends s.default{get version(){return this.getP("version","")}get grammar(){return this.getP("grammar","")}}t.default=r},3336:function(e,t,i){var n=this&&this.__decorate||function(e,t,i,n){var s,r=arguments.length,a=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(a=(r<3?s(a):r>3?s(t,i,a):s(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};Object.defineProperty(t,"__esModule",{value:!0}),t.InstanceManager=void 0;const s=i(2692),r=i(5848);class a extends s.Fieldset{get maxOccur(){return this._jsonModel.maxItems}set maxOccur(e){this.maxItems=e}get minOccur(){return this.minItems}addInstance(e){return this.addItem(e)}removeInstance(e){return this.removeItem(e)}}n([(0,r.dependencyTracked)()],a.prototype,"maxOccur",null),n([(0,r.dependencyTracked)()],a.prototype,"minOccur",null),t.InstanceManager=a},140:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=i(5088);t.default=class{constructor(e){this._jsonModel=Object.assign({},e)}getP(e,t){return(0,n.getProperty)(this._jsonModel,e,t)}get isContainer(){return!1}}},8744:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PropertiesManager=void 0;const n=i(3332);t.PropertiesManager=class{constructor(e){this.host=e,this._definedProperties=new Set,this._propertiesWrapper={},this._initialized=!1}get properties(){return this._initialized||(this._setupInitialProperties(),this._initialized=!0),this._propertiesWrapper}set properties(e){const t=this.host._jsonModel.properties||{},i=Object.assign({},e);
1this.host._jsonModel.properties=i,Object.keys(i).forEach((e=>{this._ensurePropertyDescriptor(e)})),Object.keys(Object.assign(Object.assign({},t),i)).forEach((e=>{if(t[e]!==i[e]){const s=(0,n.propertyChange)(`properties.${e}`,i[e],t[e]);this.host.notifyDependents(s)}}))}ensurePropertyDescriptor(e){this._ensurePropertyDescriptor(e)}_setupInitialProperties(){const e=this.host._jsonModel.properties||{};Object.keys(e).forEach((e=>{this._ensurePropertyDescriptor(e)})),this.host._jsonModel.properties||(this.host._jsonModel.properties={})}_ensurePropertyDescriptor(e){this._definedProperties.has(e)||(Object.defineProperty(this._propertiesWrapper,e,{get:()=>(e.startsWith("fd:")||this.host.ruleEngine.trackDependency(this.host,`properties.${e}`),(this.host._jsonModel.properties||{})[e]),set:t=>{const i=this.host._jsonModel.properties||{},s=i[e];if(s!==t){const r=Object.assign(Object.assign({},i),{[e]:t});this.host._jsonModel.properties=r;const a=(0,n.propertyChange)(`properties.${e}`,t,s);this.host.notifyDependents(a)}},enumerable:!0,configurable:!0}),this._definedProperties.add(e))}updateNestedProperty(e,t){const i=e.split("."),s=i[0];this._ensurePropertyDescriptor(s);const r=this.host._jsonModel.properties||{},a=JSON.parse(JSON.stringify(r)),o=a[s]||{};a[s]=o;let l=o;for(let e=1;e<i.length-1;e++)l[i[e]]?"object"!=typeof l[i[e]]&&(l[i[e]]={}):l[i[e]]={},l=l[i[e]];const u=i[i.length-1],d=l[u];l[u]=t,this.host._jsonModel.properties=a;const c=(0,n.propertyChange)(`properties.${e}`,t,d);this.host.notifyDependents(c)}updateSimpleProperty(e,t){this._ensurePropertyDescriptor(e),this._propertiesWrapper[e]=t}}},5376:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=i(5848);class s extends n.BaseNode{constructor(){super(...arguments),this._events={},this._rules={}}getRules(){return"object"!=typeof this._jsonModel.rules?{}:this._jsonModel.rules}getCompiledRule(e,t){if(!(e in this._rules)){const i=t||this.getRules()[e];if(!("string"==typeof i&&i.length>0))throw new Error(`only expression strings are supported. ${typeof i} types are not supported`);try{let t=i;"$form"!==this.fragment&&(t=i.replaceAll("$form",this.fragment)),this._rules[e]=this.ruleEngine.compileRule(t,this.lang)}catch(t){this.form.logger.error(`Unable to compile rule \`"${e}" : "${i}"\` Exception : ${t}`)}}return this._rules[e]}getCompiledEvent(e){var t;if(!(e in this._events)){let i=null===(t=this._jsonModel.events)||void 0===t?void 0:t[e];"string"==typeof i&&i.length>0&&(i=[i]),void 0!==i&&i.length>0&&(this._events[e]=i.map((t=>{try{let e=t;return"$form"!==this.fragment&&(e=t.replaceAll("$form",this.fragment)),this.ruleEngine.compileRule(e,this.lang)}catch(t){this.form.logger.error(`Unable to compile expression \`"${e}" : "${i}"\` Exception : ${t}`)}return null})).filter((e=>null!==e)))}return this._events[e]||[]}applyUpdates(e){"object"==typeof e?null!==e&&Object.entries(e).forEach((([e,t])=>{if(e in n.editableProperties||e in this&&"function"!=typeof this[e])try{this[e]=t}catch(e){console.error(e)}})):void 0!==e&&(this.value=e)}executeAllRules(e){const t=Object.entries(this.getRules());if(t.length>0){const i=this.getExpressionScope();t.forEach((([t,s])=>{const r=this.getCompiledRule(t,s);if(r){const a=this.ruleEngine.execute(r,i,e,!0,s);n.editableProperties.indexOf(t)>-1?this.isEmpty()&&this.isEmpty(a)&&"value"===t||(this[t]=a):this.form.logger.warn(`${t} is not a valid editable property.`)}}))}}getExpressionScope(){const e=this.getNonTransparentParent(),t={self:this.getRuleNode(),siblings:(null==e?void 0:e.ruleNodeReference())||{}},i=new Proxy(t,{get:(e,t)=>{if(t===Symbol.toStringTag)return"Object";if("string"==typeof t&&t.startsWith("$")){const i=e.self[t];return i instanceof n.BaseNode?i.getRuleNode():i instanceof Array?i.map((e=>e instanceof n.BaseNode?e.getRuleNode():e)):i}return t in e.siblings?e.siblings[t]:e.self[t]},has:(e,t)=>{const i=e.self[t],n=e.siblings[t];return void 0!==i||void 0!==n}});return i}executeEvent(e,t,i){let n;t&&(n=this.ruleEngine.execute(t,this.getExpressionScope(),e,!1,i),n instanceof Promise&&this.form.addPromises(n)),void 0!==n&&null!=n&&this.applyUpdates(n)}executeRule(e,t){void 0===e.payload.ruleName&&this.executeAllRules(t)}executeExpression(e){const t={form:this.form,$form:this.form.getRuleNode(),$field:this.getRuleNode(),field:this},i=this.ruleEngine.compileRule(e,this.lang);return this.ruleEngine.execute(i,this.getExpressionScope(),t,!1,e)}change(e,t){"deps"===this.form.changeEventBehaviour&&this.executeAllRules(t)}executeAction(e){var t;const i={form:this.form,$form:this.form.getRuleNode(),$field:this.getRuleNode(),field:this,$event:{type:e.type,payload:e.payload,target:this.getRuleNode()}};this.ruleEngine.setDependencyTracking(["change","executeRule"].includes(e.type));const n=e.isCustomEvent?`custom:${e.type}`:e.type,s=e.isCustomEvent?`custom_${e.type}`:e.type,r=this.getCompiledEvent(n),a=null===(t=this._jsonModel.events)||void 0===t?void 0:t[n];s in this&&"function"==typeof this[s]&&this[s](e,i),r.forEach(((e,t)=>{let n="";Array.isArray(a)?n=a[t]:"string"==typeof a&&(n=a),this.executeEvent(i,e,n)})),e.target===this&&this.notifyDependents(e)}}t.default=s},5840:(e,t)=>
1{Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(e={}){this.lang=e.lang||"en",this.captchaInfo=e.captchaInfo||{},Object.keys(e).forEach((t=>{"lang"!==t&&"captchaInfo"!==t&&(this[t]=e[t])}))}}},9712:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=i(2267);class s{constructor(e,t){this._node=e,this._event=t}get node(){return this._node}get event(){return this._event}isEqual(e){return null!=e&&this._node==e._node&&this._event.type==e._event.type}toString(){return this._node.id+"__"+this.event.type}valueOf(){return this.toString()}}class r{constructor(e=new n.Logger("off")){this.logger=e,this._isProcessing=!1,this._pendingEvents=[],this._runningEventCount={}}get length(){return this._pendingEvents.length}get isProcessing(){return this._isProcessing}isQueued(e,t){const i=new s(e,t);return void 0!==this._pendingEvents.find((e=>i.isEqual(e)))}queue(e,t,i=!1){e&&t&&(t instanceof Array||(t=[t]),t.forEach((t=>{var n;const a=new s(e,t),o=this._runningEventCount[a.valueOf()]||0;if(o<r.MAX_EVENT_CYCLE_COUNT){let s="";if("change"!==(null==t?void 0:t.type)||(null===(n=null==t?void 0:t.payload)||void 0===n?void 0:n.changes.map((e=>e.propertyName)).includes("activeChild"))?(null==t?void 0:t.type.includes("setProperty"))&&(s=JSON.stringify(t.payload,null,2)):s=JSON.stringify(t.payload.changes,null,2),this.logger.isLevelEnabled("info")&&e.withDependencyTrackingControl(!0,(()=>{this.logger.info(`Queued event : ${t.type} node: ${e.id} - ${e.qualifiedName} - ${s}`)})),i){const e=this._isProcessing?1:0;this._pendingEvents.splice(e,0,a)}else this._pendingEvents.push(a);this._runningEventCount[a.valueOf()]=o+1}else this.logger.info(`Skipped queueing event : ${t.type} node: ${e.id} - ${e.name} with count=${o}`)})))}empty(){this._pendingEvents=[]}runPendingQueue(){if(!this._isProcessing){for(this._isProcessing=!0;this._pendingEvents.length>0;
1){const e=this._pendingEvents[0];this.logger.info(`Dequeued event : ${e.event.type} node: ${e.node.id} - ${e.node.name}`),e.node.executeAction(e.event),this._pendingEvents.shift()}this._runningEventCount={},this._isProcessing=!1}}}r.MAX_EVENT_CYCLE_COUNT=10,t.default=r},3332:(e,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.RequestFailure=t.RequestSuccess=t.RemoveInstance=t.AddInstance=t.RemoveItem=t.AddItem=t.CustomEvent=t.FieldChanged=t.Reset=t.SubmitError=t.SubmitFailure=t.SubmitSuccess=t.Save=t.Submit=t.Focus=t.ValidationComplete=t.Blur=t.Click=t.FormLoad=t.Initialize=t.propertyChange=t.ExecuteRule=t.Valid=t.Invalid=t.UIChange=t.Change=void 0,function(e){e.CODE="code",e.UI="ui"}(i||(i={}));class n{constructor(e,t,i){this._metadata=i,this._payload=e,this._type=t}get type(){return this._type}get payload(){return this._payload}get metadata(){return this._metadata}get target(){return this._target}get currentTarget(){return this._currentTarget}get isCustomEvent(){return!1}payloadToJson(){return this.payload}
1toJson(){return{payload:this.payloadToJson(),type:this.type,isCustomEvent:this.isCustomEvent}}toString(){return JSON.stringify(this.toJson())}}class s extends n{constructor(e,t=!1){super(e,"change",{dispatch:t})}withAdditionalChange(e){return new s(this.payload.changes.concat(e.payload.changes),this.metadata)}}t.Change=s,t.UIChange=class extends n{constructor(e,t=!1){super(e,"uiChange",{dispatch:t})}},t.Invalid=class extends n{constructor(e={}){super(e,"invalid",{})}},t.Valid=class extends n{constructor(e={}){super(e,"valid",{})}},t.ExecuteRule=class extends n{constructor(e={},t=!1){super(e,"executeRule",{dispatch:t})}},t.propertyChange=(e,t,i)=>new s({changes:[{propertyName:e,currentValue:t,prevValue:i}]}),t.Initialize=class extends n{constructor(e,t=!1){super(e,"initialize",{dispatch:t})}},t.FormLoad=class extends n{constructor(){super({},"load",{dispatch:!1})}},t.Click=class extends n{constructor(e,t=!1){super(e,"click",{dispatch:t})}},t.Blur=class extends n{constructor(e,t=!1){super(e,"blur",{dispatch:t})}},t.ValidationComplete=class extends n{constructor(e,t=!1){super(e,"validationComplete",{dispatch:t})}},t.Focus=class extends n{constructor(e,t=!1){super(e,"focus",{dispatch:t})}},t.Submit=class extends n{constructor(e,t=!1){super(e,"submit",{dispatch:t})}},t.Save=class extends n{constructor(e,t=!1){super(e,"save",{dispatch:t})}},t.SubmitSuccess=class extends n{constructor(e,t=!1){super(e,"submitSuccess",{dispatch:t})}},t.SubmitFailure=class extends n{constructor(e,t=!1){super(e,"submitFailure",{dispatch:t})}},t.SubmitError=class extends n{constructor(e,t=!1){super(e,"submitError",{dispatch:t})}},t.Reset=class extends n{constructor(e,t=!1){super(e,"reset",{dispatch:t})}},t.FieldChanged=class extends n{constructor(e,t,n=i.CODE){super({field:t,changes:e,eventSource:n},"fieldChanged")}},t.CustomEvent=class extends n{constructor(e,t={},i=!1){super(t,e,{dispatch:i})}get isCustomEvent(){return!0}},t.AddItem=class extends n{constructor(e){super(e,"addItem")}},t.RemoveItem=class extends n{constructor(e){super(e,"removeItem")}},t.AddInstance=class extends n{constructor(e){super(e,"addInstance")}},t.RemoveInstance=class extends n{constructor(e){super(e,"removeInstance")}},t.RequestSuccess=class extends n{constructor(e,t=!1){super(e,"requestSuccess",{dispatch:t})}},t.RequestFailure=class extends n{constructor(e,t=!1){super(e,"requestFailure",{dispatch:t})}}},2267:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Logger=void 0;const i={off:0,debug:1,info:2,warn:3,error:4};t.Logger=class{constructor(e="off"){this.logLevel=i[e]}debug(e){this.log(e,"debug")}info(e){this.log(e,"info")}warn(e){this.log(e,"warn")}error(e){this.log(e,"error")}log(e,t){0!==this.logLevel&&this.logLevel<=i[t]&&console[t](e)}isLevelEnabled(e){return 0!==this.logLevel&&this.logLevel<=i[e]}}},9576:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(584)),r=n(i(8224));class a extends s.default{constructor(e,t,i=typeof t,n){super(e,t,i,n),this.$_items=t instanceof Array?t.map(((e,t)=>this.createEntry(t,e,this))):Object.fromEntries(Object.entries(t).map((([e,t])=>[e,this.createEntry(e,t,this)])))}createEntry(e,t,i){const n=Array.isArray(t)?"array":typeof t;return"object"==typeof t&&null!=t?new a(e,t,n,i):new s.default(e,t,n,i)}get $value(){return"array"===this.$type?Object.values(this.$_items).filter((e=>void 0!==e&&!e.disabled)).map((e=>e.$value)):Object.fromEntries(Object.values(this.$_items).filter((e=>void 0!==e&&!e.disabled)).map((e=>[e.$name,e.$value])))}get $length(){return Object.entries(this.$_items).length}$convertToDataValue(){return new s.default(this.$name,this.$value,this.$type,this.parent)}syncDataAndFormModel(e){this.$_fields.forEach((t=>{e&&e!==t&&t.syncDataAndFormModel(this)}))}
1$addDataNode(e,t,i=!1,n=null){if(t!==r.default){if("array"===this.$type){const s=e;i?this.$_items[e]=t:this.$_items.splice(s,0,t),this.syncDataAndFormModel(n)}else this.$_items[e]=t;t.parent=this}}$removeDataNode(e,t=null){"array"===this.$type?(this.$_items.splice(e,1),this.syncDataAndFormModel(t)):this.$_items[e]=void 0}$getDataNode(e){if(this.$_items.hasOwnProperty(e))return this.$_items[e]}$containsDataNode(e){return this.$_items.hasOwnProperty(e)&&void 0!==this.$_items[e]}get $isDataGroup(){return!0}}t.default=a},584:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=i(5088);t.default=class{constructor(e,t,i=typeof t,n){this.$_name=e,this.$_value=t,this.$_type=i,this.$_fields=[],this.parent=n}valueOf(){return this.$_value}get $name(){return this.$_name}get disabled(){return!this.$_fields.find((e=>!1!==e.enabled))&&this.$_fields.length}get $value(){const e=this.$_fields.find((e=>{if((0,n.isFile)(e))return e}));if(e&&this.$_fields.every((e=>["string","string[]"].includes(e.type)))){const t=e.form._exportDataAttachmentMap;if(t&&t[e.id]){const i=t[e.id];return Array.isArray(i)?i.map((e=>e.data)):i.data}}return this.$_value}setValue(e,t,i){this.$_value=e,this.$_fields.forEach((e=>{i!==e&&(e.value=t)}))}get $type(){return this.$_type}$bindToField(e){-1===this.$_fields.indexOf(e)&&this.$_fields.push(e)}$convertToDataValue(){return this}get $isDataGroup(){return!1}$addDataNode(e,t,i=!1){throw"add Data Node is called on a data value"}}},8224:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(584)),r=Symbol("NullValue");class a extends s.default{constructor(){super("",r,"null")}setValue(){}$bindToField(){}$length(){return 0}$convertToDataValue(){return this}$addDataNode(){}$removeDataNode(){}$getDataNode(){return this}$containsDataNode(){return!1}}const o=new a;t.default=o},5444:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,s)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),s=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Captcha=t.EmailInput=t.SubmitMetaData=t.isEmpty=t.request=t.FunctionRuntime=t.readAttachments=t.extractFileInfo=t.getFileSizeInBytes=t.Scriptable=t.Node=t.FormMetaData=t.FileUpload=t.FileObject=t.Fieldset=t.Field=t.Container=t.CheckboxGroup=t.Checkbox=t.BaseNode=t.Form=void 0,s(i(9916),t),s(i(9333),t),s(i(3332),t),s(i(712),t),s(i(5088),t),s(i(9616),t),s(i(5504),t);const a=i(1060);Object.defineProperty(t,"getFileSizeInBytes",{enumerable:!0,get:function(){return a.getFileSizeInBytes}}),Object.defineProperty(t,"extractFileInfo",{enumerable:!0,get:function(){return a.extractFileInfo}}),Object.defineProperty(t,"isEmpty",{enumerable:!0,get:function(){return a.isEmpty}}),Object.defineProperty(t,"readAttachments",{enumerable:!0,get:function(){return a.readAttachments}});const o=i(5848);Object.defineProperty(t,"BaseNode",{enumerable:!0,get:function(){return o.BaseNode}});const l=r(i(2716));t.Checkbox=l.default;const u=r(i(7288));t.CheckboxGroup=u.default;const d=r(i(6764));t.EmailInput=d.default;const c=r(i(3968));t.Captcha=c.default;const h=r(i(5716));t.Container=h.default;const p=r(i(560));t.Field=p.default;const f=i(2692);Object.defineProperty(t,"Fieldset",{enumerable:!0,get:function(){return f.Fieldset}});const m=i(6440);Object.defineProperty(t,"FileObject",{enumerable:!0,get:function(){return m.FileObject}});const g=r(i(5432));t.FileUpload=g.default;const _=r(i(1316));t.FormMetaData=_.default;const v=r(i(5840));t.SubmitMetaData=v.default;const y=r(i(140));t.Node=y.default;const b=r(i(5376));t.Scriptable=b.default;const E=r(i(3416));t.Form=E.default;const T=i(7279);Object.defineProperty(t,"FunctionRuntime",{enumerable:!0,get:function(){return T.FunctionRuntime}}),Object.defineProperty(t,"request",{enumerable:!0,get:function(){return T.request}})},7279:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Prom
1ise))((function(s,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function o(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,o)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.FunctionRuntime=t.submit=t.request=void 0;const s=i(3332),r=i(372),a=i(6440),o=i(1060),l=i(5088),u=i(9333),d=e=>{const t=e;return t.length>0&&t.startsWith("custom:")?t.substring(7):t};t.request=(e,t,i,o,l,u,p)=>n(void 0,void 0,void 0,(function*(){var n;const f=t,m={method:i};let g,_={};try{o instanceof Promise&&(o=yield o)}catch(e){throw console.error("Error resolving payload Promise:",e),e}if(o.body&&o.headers&&(_=Object.assign({},o),p=Object.assign({},o.headers),g=o=o.body),o&&o instanceof a.FileObject&&o.data instanceof File){const e=new FormData;e.append(o.name,o.data),g=e}else if(o instanceof FormData)g=o;else if(o&&("string"==typeof o||"object"==typeof o&&Object.keys(o).length>0)){const e=Object.keys(p);e.length>0?m.headers=Object.assign(Object.assign({},p),-1===e.indexOf("Content-Type")?{"Content-Type":"application/json"}:{}):m.headers={"Content-Type":"application/json"};const t=(null===(n=null==m?void 0:m.headers)||void 0===n?void 0:n["Content-Type"])||"application/json";"object"==typeof o&&("application/json"===t?g=JSON.stringify(o):t.indexOf("multipart/form-data")>-1?g=h(o):t.indexOf("application/x-www-form-urlencoded")>-1&&(g=c(o))),"text/plain"===t&&(g=String(o))}const v=yield(0,r.request)(f,g,m);v.originalRequest=Object.assign({url:f,method:i},_);const y=e.$field||null,b=e.$event||null;v.submitter=y;const E={request:v.originalRequest,response:v,targetField:y,targetEvent:b};if((null==v?void 0:v.status)>=200&&(null==v?void 0:v.status)<=299){const t=d(l);"submitSuccess"===l?e.form.dispatch(new s.SubmitSuccess(v,!0)):e.field?e.field.dispatch(new s.CustomEvent(t,v,!0)):e.form.dispatch(new s.CustomEvent(t,v,!0)),e.form.dispatch(new s.RequestSuccess(E,!1))}else{e.form.logger.error("Error invoking a rest API");const t=d(u);"submitError"===u?(e.form.dispatch(new s.SubmitError(v,!0)),e.form.dispatch(new s.SubmitFailure(v,!0))):e.field?e.field.dispatch(new s.CustomEvent(t,v,!0)):e.form.dispatch(new s.CustomEvent(t,v,!0)),e.form.dispatch(new s.RequestFailure(E,!1))}return v}));const c=e=>{const t=new URLSearchParams;return Object.entries(e).forEach((([e,i])=>{null!=i&&"object"==typeof i?t.append(e,(0,l.jsonString)(i)):t.append(e,i)})),t};t.submit=(e,i,s,r="multipart/form-data",a=null,l="",u=null)=>n(void 0,void 0,void 0,(function*(){const n=l||e.form.action;let d=a;const c=yield(0,o.readAttachments)(e.form,!0);"object"==typeof d&&null!=d||(d=e.form.exportData(c));let p=r;const f=Object.assign({data:d},u);let m=f;(Object.keys(c).length>0||"multipart/form-data"===r)&&(m=h(f,c),p="multipart/form-data"),yield(0,t.request)(e,n,"POST",m,i,s,{"Content-Type":p})}));const h=(e,t)=>{const i=new FormData;Object.entries(e).forEach((([e,t])=>{null!=t&&"object"==typeof t?i.append(e,(0,l.jsonString)(t)):i.append(e,t)}));const n=(e,t)=>{if((null==e?void 0:e.data)instanceof File){let i=`${null==e?void 0:e.dataRef}/${null==e?void 0:e.name}`;i.startsWith("/")||(i=`/${i}`),t.append(i,e.data)}};return t&&Object.keys(t).reduce(((e,s)=>{const r=t[s];return r&&r instanceof Array?[...e,...r.map((e=>n(e,i)))]:[...e,n(r,i)]}),[]),i},p=(e,t={},i=!1)=>{switch(e){case"change":return new s.Change(t);case"submit":return new s.Submit(t);case"save":return new s.Save(t);case"click":return new s.Click(t);case"addItem":return new s.AddItem(t);case"removeItem":return new s.RemoveItem(t);case"reset":return new s.Reset(t);case"addInstance":return new s.AddInstance(t);case"removeInstance":return new s.RemoveInstance(t);case"invalid":return new s.Invalid(t);case"valid":return new s.Valid(t);case"initialize":return new s.Initialize(t);case"focus":return new s.Focus(t);default:console.error("invalid action")}};class f{constructor(){this.customFunctions={}}static getInstance(){return f.instance||(f.instance=new f),f.instance}registerFunctions(e){Object.entries(e).forEach((([e,t])=>{let i=t;"function"==typeof t&&(i={_func:(e,i,n)=>{const s={form:n.globals.$form,field:n.globals.$field,event:n.globals.$event,functions:{setProperty:(e,t)=>{const s=[e,"custom:setProperty",t];return f.getInstance().getFunctions().dispatchEvent._func.call(void 0,s,i,n)},reset:e=>{const t=[e=e||"reset","reset"];return n.globals.form.logger.warn("This usage of reset is deprecated. Please see the documentation and update."),f.getInstance().getFunctions().dispatchEvent._func.call(void 0,t,i,n)},validate:e=>{const t=[e];return f.getInstance().getFunctions().validate._func.call(void 0,t,i,n)},importData:(e,t)=>{const s=[e,t];return f.getInstance().getFunctions().importData._func.call(void 0,s,i,n)},exportData:()=>f.getInstance().getFunctions().exportData._func.call(void 0,e,i,n),submitForm:(e,t,s)=>{const r=[e,t,s||"multipart/form-data"];return f.getInstance().getFunctions().submitForm._func.call(void 0,r,i,n)},markFieldAsInvalid:(e,t,i)=>{var s,r;!i||i.useId?null===(s=n.globals.form.getElement(e))||void 0===s||s.markAsInvalid(t):i&&i.useDataRef?n.globals.form.visit((function(i){i.dataRef===e&&i.markAsInvalid(t)})):i&&i.useQualifiedName&&(null===(r=n.globals.form.resolveQualifiedName(e))||void 0===r||r.markAsInvalid(t))},setFocus:(e,t)=>{const s=[e,t];return f.getInstance().getFunctions().setFocus._func.call(void 0,s,i,n)},dispatchEvent:(e,t,s,r)=>{const a=[e,t,s,r];return f.getInstance().getFunctions().dispatchEvent._func.call(void 0,a,i,n)},getFiles:e=>{const t={};e||n.globals.form.visit((function(e){"file-input"===e.fieldType&&e.value&&(t[e.qualifiedName]=e.serialize())}));const i=n.globals.form.resolveQualifiedName(e);return"file-input"===(null==i?void 0:i.fieldType)&&(null==i?void 0:i.value)&&(t[e]=i.serialize()),t}}};return t(...e,s)},_signature:[]}),i.hasOwnProperty("_func")?f.getInstance().customFunctions[e]=i:console.warn(`Unable to register function with name ${e}.`)}))}unregisterFunctions(...e){e.forEach((e=>{e in f.getInstance().customFunctions&&(null==f||delete f.getInstance().customFunctions[e])}))}getFunctions(){function e(t){return null==t?t:null!==(i=t)&&"[object Array]"===Object.prototype.toString.call(i)?t.map((t=>e(t))):t.valueOf();var i}function i(e){return null==e?"":e.toString()}const r={validate:{_func:(e,t,i)=>{const n=e[0];let s;return s="string"==typeof n||void 0===n?i.globals.form.validate():i.globals.form.getElement(n.$id).validate(),Array.isArray(s)&&s.length&&i.globals.form.logger.warn("Form Validation Error"),s},_signature:[]},setFocus:{_func:(e,t,i)=>{const n=e[0],s=e[1];try{const e=i.globals.form.getElement(null==n?void 0:n.$id)||i.globals.field;
1i.globals.form.setFocus(e,s)}catch(e){i.globals.form.logger.error("An error has occurred within the setFocus API.")}},_signature:[]},getData:{_func:(e,t,i)=>(i.globals.form.logger.warn("The `getData` function is depricated. Use `exportData` instead."),i.globals.form.exportData()),_signature:[]},exportData:{_func:(e,t,i)=>i.globals.form.exportData(),_signature:[]},importData:{_func:(e,t,i)=>i.globals.form.withDependencyTrackingControl(!0,(()=>{const t=e[0],n=e[1];if("object"!=typeof t||null===t||n){const e=i.globals.form.resolveQualifiedName(n);(null==e?void 0:e.isContainer)?e.importData(t,n):i.globals.form.logger.error("Invalid argument passed in importData. A container is expected")}else i.globals.form.importData(t);return{}})),_signature:[]},submitForm:{_func:(t,r,a)=>n(this,void 0,void 0,(function*(){var n,o,l,d,c;let h,p,f,m=null,g=null;t.length>0&&"object"==typeof e(t[0])?(h=t.length>0?e(t[0]):null,p=!(t.length>1)||e(t[1]),f=t.length>2?i(t[2]):"multipart/form-data"):(a.globals.form.logger.warn("This usage of submitForm is deprecated. Please see the documentation and update"),m=i(t[0]),g=i(t[1]),f=t.length>2?i(t[2]):"multipart/form-data",h=t.length>3?e(t[3]):null,p=!(t.length>4)||e(t[4]));const _=a.globals.form;if(_.captcha&&(_.captcha.captchaDisplayMode===u.CaptchaDisplayMode.INVISIBLE||"enterprise"===(null===(o=null===(n=_.captcha.properties["fd:captcha"])||void 0===n?void 0:n.config)||void 0===o?void 0:o.version)&&"score"===(null===(d=null===(l=_.captcha.properties["fd:captcha"])||void 0===l?void 0:l.config)||void 0===d?void 0:d.keyType))){if("function"!=typeof(null===(c=a.runtime.functionTable.fetchCaptchaToken)||void 0===c?void 0:c._func))return a.globals.form.logger.error("fetchCaptchaToken is not defined"),a.globals.form.dispatch(new s.SubmitError({type:"FetchCaptchaTokenNotDefined"})),{};try{const e=yield a.runtime.functionTable.fetchCaptchaToken._func([],r,a);_.captcha.value=e}catch(e){return a.globals.form.logger.error("Error while fetching captcha token"),a.globals.form.dispatch(new s.SubmitError({type:"FetchCaptchaTokenFailed"})),{}}}return a.globals.form.dispatch(new s.Submit({success:m,error:g,submit_as:f,validate_form:p,data:h})),{}})),_signature:[]},saveForm:{_func:(e,t,n)=>{const r=i(e[0]),a=e[2]||!1;return n.globals.form.dispatch(new s.Save({action:r,validate_form:a})),{}},_signature:[]},setVariable:{_func:(e,t,n)=>{const s=i(e[0]);let r=e[1];const a=e[2]||n.globals.form;return r&&"object"==typeof r&&r.$qualifiedName&&(r=n.globals.form.getElement(r.$id)._jsonModel.value),(a.$id?n.globals.form.getElement(a.$id):n.globals.form).getPropertiesManager().updateSimpleProperty(s,r),{}},_signature:[]},getVariable:{_func:(e,t,n)=>{const s=i(e[0]),r=e[1]||n.globals.form;if(!s)return;const a=(r.$id?n.globals.form.getElement(r.$id):n.globals.form).getPropertiesManager();if(s.includes(".")){const e=s.replace(/\[/g,".").replace(/\]/g,"").split(".").filter(Boolean);let t=a.properties;for(const i of e){if(null==t)return;t=t[i]}return t}return a.ensurePropertyDescriptor(s),a.properties[s]},_signature:[]},request:{_func:(n,s,r)=>{const a=i(n[0]),o=i(n[1]);let l,u,d,c={};if(n[2]&&"object"==typeof n[2]&&!n[2].then&&("data"in n[2]||"headers"in n[2])){const t=e(n[2]);l=t.data,c=t.headers||{},u=e(n[3]),d=e(n[4])}else l=e(n[2]),"string"==typeof n[3]?(r.globals.form.logger.warn("This usage of request is deprecated. Please see the documentation and update"),u=e(n[3]),d=e(n[4])):(c=e(n[3]),u=e(n[4]),d=e(n[5]));return(0,t.request)(r.globals,a,o,l,u,d,c)},_signature:[]},requestWithRetry:{_func:(s,r,a)=>{const o=i(s[0]),l=i(s[1]);let u,d,c=e(s[2]);return"string"==typeof s[3]&&5===s.length?(u=e(s[3]),d=e(s[4])):"string"==typeof s[4]&&6===s.length&&(u=e(s[4]),d=e(s[5])),e=>n(this,void 0,void 0,(function*(){try{c instanceof Promise&&(c=yield c)}catch(e){throw console.error("Error resolving payload Promise:",e),e}let i={},n={};5===s.length?(n=c.body||{},i=c.headers||{}):(n=c||{},i=s[3]||{}),e&&(e.body&&(n=Object.assign(Object.assign({},n),e.body)),e.headers&&(i=Object.assign(Object.assign({},i),e.headers)));const r={body:n,headers:i};try{return yield(0,t.request)(a.globals,o,l,r,u,d,i)}catch(e){if(e&&"object"==typeof e&&"status"in e&&e.status>=400)throw e;throw new Error("Request failed")}}))},_signature:[]},retryHandler:{_func:(t,i,n)=>e(t[0])(),_signature:[]},awaitFn:{_func:(e,t,i)=>n(this,void 0,void 0,(function*(){const n=e[1],s=i.globals.$field;try{const a=yield e[0];r.dispatchEvent._func([s,n,a],t,i)}catch(n){const a=e[2];a&&r.dispatchEvent._func([s,a,n],t,i)}return{}})),_signature:[]},addInstance:{_func:(t,i,n)=>{const s=t[0],r=t.length>1?e(t[1]):void 0;try{const e=n.globals.form.getElement(s.$id),t=p("addInstance",r);e.addItem(t)}catch(e){n.globals.form.logger.error("Invalid argument passed in addInstance. An element is expected")}},_signature:[]},removeInstance:{_func:(t,i,n)=>{const s=t[0],r=t.length>1?e(t[1]):void 0;try{const e=n.globals.form.getElement(s.$id),t=p("removeInstance",r);e.removeItem(t)}catch(e){n.globals.form.logger.error("Invalid argument passed in removeInstance. An element is expected")}},_signature:[]},dispatchEvent:{_func:(t,i,n)=>{const r=t[0];if(null===r&&"string"!=typeof n)return n.debug.push("Invalid argument passed in dispatchEvent. An element is expected"),{};let a,o=e(t[1]),l=t.length>2?e(t[2]):void 0,u=t.length>3&&e(t[3]);if("string"==typeof r&&(l=o,o=r,u=!0),a=o.startsWith("custom:")?new s.CustomEvent(o.substring(7),l,u):p(o,l,u),null!=a)if("string"==typeof r)n.globals.form.dispatch(a);else{const e=(e,t,i)=>{i.globals.form.getElement(e.$id).dispatch(t)};Array.isArray(r)&&r.length>0&&void 0===r.$id?r.forEach((t=>{e(t,a,n)})):e(r,a,n)}return{}},_signature:[]},encrypt:{_func:(t,i,s)=>n(this,void 0,void 0,(function*(){return e(t[0])})),_signature:[]},decrypt:{_func:(t,i,s)=>n(this,void 0,void 0,(function*(){return e(t[0])})),_signature:[]},getQueryParameter:{_func:(e,t,n)=>{var s,r,a,o;const l=i(e[0]);if(!l)return n.globals.form.logger.error("Argument is missing in getQueryParameter. A parameter is expected"),"";if(null===(a=null===(r=null===(s=n.globals.form)||void 0===s?void 0:s.properties)||void 0===r?void 0:r.queryParams)||void 0===a?void 0:a[l])return n.globals.form.properties.queryParams[l];try{return new URLSearchParams((null===(o=null===window||void 0===window?void 0:window.location)||void 0===o?void 0:o.search)||"").get(l)}catch(e){n.globals.form.logger.warn("Error reading URL parameters:",e)}return""},_signature:[]}
1,getBrowserDetail:{_func:(e,t,n)=>{var s,r,a;const o=i(e[0]);return o?(null===(a=null===(r=null===(s=n.globals.form)||void 0===s?void 0:s.properties)||void 0===r?void 0:r.browserDetails)||void 0===a?void 0:a[o])?n.globals.form.properties.browserDetails[o]:"undefined"!=typeof navigator&&o in navigator?navigator[o]||"":(n.globals.form.logger.warn(`Invalid or unsupported browser detail requested: "${o}"`),""):(n.globals.form.logger.error("Argument is missing in getBrowserDetail. A parameter is expected"),"")},_signature:[]},getURLDetail:{_func:(e,t,n)=>{var s,r,a;const o=i(e[0]);return o?(null===(a=null===(r=null===(s=n.globals.form)||void 0===s?void 0:s.properties)||void 0===r?void 0:r.urlDetails)||void 0===a?void 0:a[o])?n.globals.form.properties.urlDetails[o]:"undefined"!=typeof window&&void 0!==window.location&&o in window.location?window.location[o]||"":(n.globals.form.logger.warn(`Invalid or unsupported url parameter requested: "${o}"`),""):(n.globals.form.logger.error("Argument is missing in getURLDetail. A parameter is expected"),"")},_signature:[]},getRelativeInstanceIndex:{_func:(t,i,n)=>{if(!Array.isArray(t[0])||0===t[0].length)return-1;const s=e(t[0])[0].$parent,r=n.globals.$field,a=s.$qualifiedName,o=r.$qualifiedName;if(o.startsWith(a+"[")){const e=a.length+1,t=o.indexOf("]",e);if(-1!==t){const i=Number(o.slice(e,t));if(!Number.isNaN(i))return i}}return s.length-1},_signature:[]},today:{_func:()=>{const e=new Date(Date.now());return new Date(e.getFullYear(),e.getMonth(),e.getDate())/864e5},_signature:[]}};return Object.assign(Object.assign({},r),f.getInstance().customFunctions)}}f.instance=null,t.FunctionRuntime=f.getInstance()},6552:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=n(i(3548)),r=i(7279),a=i(8416);t.default=class{constructor(){this._globalNames=["$form","$field","$event"],this.debugInfo=[],this.dependencyTracking=!0,this.customFunctions=r.FunctionRuntime.getFunctions()}compileRule(e,t){const i=new s.default(this.customFunctions,function(e){if(null==e){const t=(new Intl.DateTimeFormat).resolvedOptions();e=t.locale}return t=>(0,a.stringToNumber)(t,e)}(t),this.debugInfo);return{formula:i,ast:i.compile(e,this._globalNames)}}execute(e,t,i,n=!1,s){var r,a,o,l,u,d,c,h,p;const{formula:f,ast:m}=e,g=this._context;let _;this._context=i;try{_=f.run(m,t,"en-US",i)}catch(e){null===(o=null===(a=null===(r=this._context)||void 0===r?void 0:r.form)||void 0===a?void 0:a.logger)||void 0===o||o.error(e)}if(this.debugInfo.length)for(null===(d=null===(u=null===(l=this._context)||void 0===l?void 0:l.form)||void 0===u?void 0:u.logger)||void 0===d||d.warn(`Form rule expression string: ${s}`);this.debugInfo.length>0;)null===(p=null===(h=null===(c=this._context)||void 0===c?void 0:c.form)||void 0===h?void 0:h.logger)||void 0===p||p.warn(this.debugInfo.pop());let v=_;return n&&"object"==typeof _&&null!==_&&(v=Object.getPrototypeOf(_).valueOf.call(_)),this._context=g,v}trackDependency(e,t){this.dependencyTracking&&this._context&&void 0!==this._context.field&&this._context.field!==e&&e._addDependent(this._context.field,t)}setDependencyTracking(e){this.dependencyTracking=e}getDependencyTracking(){return this.dependencyTracking}}},9136:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getConstraintTypeMessages=t.setCustomDefaultConstraintTypeMessages=t.constraintKeys=t.ConstraintType=t.constraintProps=t.translationProps=void 0,t.translationProps=["description","placeholder","enum","enumNames","label.value","constraintMessages.accept","constraintMessages.enum","constraintMessages.exclusiveMinimum","constraintMessages.exclusiveMaximum","constraintMessages.format","constraintMessages.maxFileSize","constraintMessages.maxLength","constraintMessages.maximum","constraintMessages.maxItems","constraintMessages.minLength","constraintMessages.minimum","constraintMessages.minItems","constraintMessages.pattern","constraintMessages.required","constraintMessages.step","constraintMessages.type","constraintMessages.validationExpression"],t.constraintProps=["accept","enum","exclusiveMinimum","exclusiveMaximum","format","maxFileSize","maxLength","maximum","maxItems","minLength","minimum","minItems","pattern","required","step","validationExpression","enumNames"],t.ConstraintType=Object.freeze({PATTERN_MISMATCH:"patternMismatch",TOO_SHORT:"tooShort",TOO_LONG:"tooLong",RANGE_OVERFLOW:"rangeOverflow",RANGE_UNDERFLOW:"rangeUnderflow",TYPE_MISMATCH:"typeMismatch",VALUE_MISSING:"valueMissing",STEP_MISMATCH:"stepMismatch",FORMAT_MISMATCH:"formatMismatch",ACCEPT_MISMATCH:"acceptMismatch",FILE_SIZE_MISMATCH:"fileSizeMismatch",UNIQUE_ITEMS_MISMATCH:"uniqueItemsMismatch",MIN_ITEMS_MISMATCH:"minItems
1Mismatch",MAX_ITEMS_MISMATCH:"maxItemsMismatch",EXPRESSION_MISMATCH:"expressionMismatch",EXCLUSIVE_MAXIMUM_MISMATCH:"exclusiveMaximumMismatch",EXCLUSIVE_MINIMUM_MISMATCH:"exclusiveMinimumMismatch"}),t.constraintKeys=Object.freeze({pattern:t.ConstraintType.PATTERN_MISMATCH,minLength:t.ConstraintType.TOO_SHORT,maxLength:t.ConstraintType.TOO_LONG,maximum:t.ConstraintType.RANGE_OVERFLOW,minimum:t.ConstraintType.RANGE_UNDERFLOW,type:t.ConstraintType.TYPE_MISMATCH,required:t.ConstraintType.VALUE_MISSING,step:t.ConstraintType.STEP_MISMATCH,format:t.ConstraintType.FORMAT_MISMATCH,accept:t.ConstraintType.ACCEPT_MISMATCH,maxFileSize:t.ConstraintType.FILE_SIZE_MISMATCH,uniqueItems:t.ConstraintType.UNIQUE_ITEMS_MISMATCH,minItems:t.ConstraintType.MIN_ITEMS_MISMATCH,maxItems:t.ConstraintType.MAX_ITEMS_MISMATCH,validationExpression:t.ConstraintType.EXPRESSION_MISMATCH,exclusiveMinimum:t.ConstraintType.EXCLUSIVE_MINIMUM_MISMATCH,exclusiveMaximum:t.ConstraintType.EXCLUSIVE_MAXIMUM_MISMATCH});const i=Object.freeze({[t.ConstraintType.PATTERN_MISMATCH]:"Please match the format requested.",[t.ConstraintType.TOO_SHORT]:"Please lengthen this text to ${0} characters or more.",[t.ConstraintType.TOO_LONG]:"Please shorten this text to ${0} characters or less.",[t.ConstraintType.RANGE_OVERFLOW]:"Value must be less than or equal to ${0}.",[t.ConstraintType.RANGE_UNDERFLOW]:"Value must be greater than or equal to ${0}.",[t.ConstraintType.TYPE_MISMATCH]:"Please enter a valid value.",[t.ConstraintType.VALUE_MISSING]:"Please fill in this field.",[t.ConstraintType.STEP_MISMATCH]:"Please enter a valid value.",[t.ConstraintType.FORMAT_MISMATCH]:"Specify the value in allowed format : ${0}.",[t.ConstraintType.ACCEPT_MISMATCH]:"The specified file type not supported.",[t.ConstraintType.FILE_SIZE_MISMATCH]:"File too large. Reduce size and try again.",[t.ConstraintType.UNIQUE_ITEMS_MISMATCH]:"All the items must be unique.",[t.ConstraintType.MIN_ITEMS_MISMATCH]:"Specify a number of items equal to or greater than ${0}.",[t.ConstraintType.MAX_ITEMS_MISMATCH]:"Specify a number of items equal to or less than ${0}.",[t.ConstraintType.EXPRESSION_MISMATCH]:"Please enter a valid value.",[t.ConstraintType.EXCLUSIVE_MINIMUM_MISMATCH]:"Value must be greater than ${0}.",[t.ConstraintType.EXCLUSIVE_MAXIMUM_MISMATCH]:"Value must be less than ${0}."}),n=(e,t)=>"object"!=typeof e||null===e?e:Array.isArray(e)?e.map((e=>n(e,t))):Object.keys(e).reduce(((i,s)=>{const r=t(s),a=e[s];return i[r]=n(a,t),i}),{});let s={};t.setCustomDefaultConstraintTypeMessages=e=>{s=n(e,(e=>t.constraintKeys[e]))},t.getConstraintTypeMessages=()=>Object.assign(Object.assign({},i),s)},9048:(e,t)=>{var i,n,s;Object.defineProperty(t,"__esModule",{value:!0}),t.CaptchaDisplayMode=t.FocusOption=t.ValidationError=t.EventSource=void 0,(i=t.EventSource||(t.EventSource={})).CODE="code",i.UI="ui",t.ValidationError=class{constructor(e="",t=[]){this.errorMessages=t,this.fieldName=e}},(s=t.FocusOption||(t.FocusOption={})).NEXT_ITEM="nextItem",s.PREVIOUS_ITEM="previousItem",(n=t.CaptchaDisplayMode||(t.CaptchaDisplayMode={})).INVISIBLE="invisible",n.VISIBLE="visible"},9333:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,s)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),s=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),s(i(9136),t),s(i(9048),t)},8416:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stringToNumber=void 0;const n=i(6608);t.stringToNumber=function(e,t){if(null===e)return 0;const i=+e;if(!isNaN(i))return i;if(t){const i=(0,n.parseDefaultDate)(e,t,!0);if(i!==e)return(0,n.datetimeToNumber)(i)}return 0}},3820:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveData=t.tokenize=t.repeatable=t.global$=t.bracket=t.identifier=t.TOK_REPEATABLE=t.TOK_GLOBAL=void 0;const s=n(i(9576)),r="Identifier";t.TOK_GLOBAL="Global",t.TOK_REPEATABLE="Repeatable";const a="bracket";t.identifier=(e,t)=>({type:r,value:e,start:t}),t.bracket=(e,t)=>({type:a,value:e,start:t}),t.global$=()=>({type:t.TOK_GLOBAL,start:0,value:"$"}),t.repeatable=()=>({type:t.TOK_REPEATABLE,start:0,value:"#"});const o=function(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||"_"===e},l=(e,t,i)=>
1null===e&&"$"===t[i],u=(e,t,i)=>null===e&&"#"===t[i],d=(e,t)=>{const i=e[t];return"$"===i?e.length>t&&o(e[t+1]):i>="a"&&i<="z"||i>="A"&&i<="Z"||"_"===i},c=e=>e>="0"&&e<="9";class h{constructor(e){this.stream=e,this._tokens=[],this._result_tokens=[],this._current=0}_consumeGlobal(){return this._current+=1,(0,t.global$)()}_consumeRepeatable(){return this._current+=1,(0,t.repeatable)()}_consumeUnquotedIdentifier(e){const i=this._current;for(this._current+=1;this._current<e.length&&o(e[this._current]);)this._current+=1;return(0,t.identifier)(e.slice(i,this._current),i)}_consumeQuotedIdentifier(e){const i=this._current;this._current+=1;const n=e.length;for(;'"'!==e[this._current]&&this._current<n;){let t=this._current;"\\"!==e[t]||"\\"!==e[t+1]&&'"'!==e[t+1]?t+=1:t+=2,this._current=t}return this._current+=1,(0,t.identifier)(JSON.parse(e.slice(i,this._current)),i)}_consumeNumber(e){const t=this._current;this._current+=1;const i=e.length;for(;c(e[this._current])&&this._current<i;)this._current+=1;const n=e.slice(t,this._current);return{type:"Number",value:parseInt(n,10),start:t}}_consumeBracket(e){const i=this._current;let n;if(this._current+=1,!c(e[this._current]))throw new Error(`unexpected exception at position ${this._current}. Must be a character`);if(n=this._consumeNumber(e).value,this._current<this.stream.length&&"]"!==e[this._current])throw new Error(`unexpected exception at position ${this._current}. Must be a character`);return this._current++,(0,t.bracket)(n,i)}tokenize(){const e=this.stream;for(;this._current<e.length;){const t=this._tokens.length?this._tokens.slice(-1)[0]:null;if(l(t,e,this._current)){const e=this._consumeGlobal();this._tokens.push(e),this._result_tokens.push(e)}else if(u(t,e,this._current)){const e=this._consumeRepeatable();this._tokens.push(e),this._result_tokens.push(e)}else if(d(e,this._current)){const t=this._consumeUnquotedIdentifier(e);this._tokens.push(t),this._result_tokens.push(t)}else if("."===e[this._current]&&null!=t&&"DOT"!==t.type)this._tokens.push({type:"DOT",value:".",start:this._current}),this._current+=1;else if("["===e[this._current]){const t=this._consumeBracket(e);this._tokens.push(t),this._result_tokens.push(t)}else{if('"'!==e[this._current]){const e=Math.max(0,this._current-2),t=Math.min(this.stream.length,this._current+2);throw new Error(`Exception at parsing stream ${this.stream.slice(e,t)}`)}{const t=this._consumeQuotedIdentifier(e);this._tokens.push(t),this._result_tokens.push(t)}}}return this._result_tokens}}t.tokenize=e=>new h(e).tokenize(),t.resolveData=(e,i,n)=>{let o;o="string"==typeof i?(0,t.tokenize)(i):i;let l=e,u=0;const d=(e,t,i)=>null===t?i:t.type===a?new s.default(e.value,[],"array"):new s.default(e.value,{});for(;u<o.length&&null!=l;){const i=o[u];if(i.type===t.TOK_GLOBAL)l=e;else if(i.type===r){if(!(l instanceof s.default&&"object"===l.$type))throw new Error(`Looking for ${i.value} in ${l.$value}`);if(l.$containsDataNode(i.value)&&null!==l.$getDataNode(i.value).$value)l=l.$getDataNode(i.value);else if(n){const e=d(i,u<o.length-1?o[u+1]:null,n);l.$addDataNode(i.value,e),l=e}else l=void 0}else if(i.type===a){if(!(l instanceof s.default&&"array"===l.$type))throw new Error(`Looking for index ${i.value} in non array${l.$value}`);{const e=i.value;if(e<l.$length)l=l.$getDataNode(e);else if(n){const t=d(i,u<o.length-1?o[u+1]:null,n);l.$addDataNode(e,t),l=t}else l=void 0}}u+=1}return l}},7888:(e,t)=>
1{Object.defineProperty(t,"__esModule",{value:!0}),t.transformFieldName=void 0,t.transformFieldName=e=>e.split(".").slice(1).map((e=>e.match(/\[\d+\]$/)?e:""!==e?`${e}[0]`:e)).join(".")},372:function(e,t){var i=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function o(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,o)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.convertQueryString=t.request=void 0,t.request=(e,s=null,r={})=>{const a=Object.assign(Object.assign({},n),r),o="GET"===a.method&&s?(0,t.convertQueryString)(e,s):e;return"GET"!==a.method&&(a.body=s),fetch(o,Object.assign({},a)).then((t=>i(void 0,void 0,void 0,(function*(){var i,n,s;let r;t.ok||console.error(`Error while fetching response from ${e} : ${t.statusText}`),r=(null===(n=null===(i=null==t?void 0:t.headers)||void 0===i?void 0:i.get("Content-Type"))||void 0===n?void 0:n.includes("application/json"))?yield t.json():yield t.text();const a={};return null===(s=null==t?void 0:t.headers)||void 0===s||s.forEach(((e,t)=>{a[t]=e})),{status:t.status,body:r,headers:a}}))))};const n={method:"GET"};t.convertQueryString=(e,t)=>{if(!t)return e;let i={};try{i=JSON.parse(t)}catch(e){console.log("Query params invalid")}const n=[];
1return Object.keys(i).forEach((e=>{Array.isArray(i[e])?n.push(`${encodeURIComponent(e)}=${encodeURIComponent(JSON.stringify(i[e]))}`):n.push(`${encodeURIComponent(e)}=${encodeURIComponent(i[e])}`)})),n.length?e.includes("?")?`${e}&${n.join("&")}`:`${e}?${n.join("&")}`:e}},8608:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FormFieldFactory=void 0;const s=i(3336),r=i(2692),a=i(5088),o=n(i(5432)),l=n(i(2716)),u=n(i(7288)),d=n(i(6884)),c=n(i(3260)),h=n(i(560)),p=n(i(6764)),f=n(i(3968)),m=n(i(3544)),g={text:"text-input",number:"number-input",email:"email",file:"file-input",range:"range",textarea:"multiline-input"};t.FormFieldFactory=new class{createField(e,t){let i;const n=Object.assign(Object.assign({},t),{fieldFactory:this});if(e.fieldType=e.fieldType?e.fieldType in g?g[e.fieldType]:e.fieldType:"text-input",(0,a.isRepeatable)(e)){const t=Object.assign(Object.assign(Object.assign({},e),"items"in e&&{type:"object"}),{minOccur:void 0,maxOccur:void 0,repeatable:void 0,name:void 0}),r=Object.assign({minItems:e.minOccur||0,maxItems:e.maxOccur||-1,fieldType:e.fieldType,type:"array",name:e.name,dataRef:e.dataRef,events:{"custom:setProperty":"$event.payload"}},{items:[t]});i=new s.InstanceManager(r,n)}else i="items"in e||"panel"===e.fieldType?new r.Fieldset(e,n):(0,a.isFile)(e)||"file-input"===e.fieldType?new o.default(e,n):(0,a.isCheckbox)(e)?new l.default(e,n):(0,a.isCheckboxGroup)(e)?new u.default(e,n):(0,a.isEmailInput)(e)?new p.default(e,n):(0,a.isDateField)(e)?new d.default(e,n):(0,a.isDateTimeField)(e)?new c.default(e,n):(0,a.isCaptcha)(e)?new f.default(e,n):(0,a.isButton)(e)?new m.default(e,n):new h.default(e,n);return i}}},1060:function(e,t,i){var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(s,r){function a(e){try{l(n.next(e))}catch(e){r(e)}}function o(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,o)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.replaceTemplatePlaceholders=t.sitesModelToFormModel=t.dataURItoBlob=t.extractFileInfo=t.isDataUrl=t.IdGenerator=t.getFileSizeInBytes=t.getAttachments=t.readAttachments=t.isEmpty=t.randomWord=void 0;const s=i(5088),r=i(6440),a="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_".split(""),o=/^(\d*\.?\d+)(\\?(?=[KMGT])([KMGT])(?:i?B)?|B?)$/i;t.randomWord=e=>{const t=[];for(let i=0;i<=e;i++){let e;e=0===i?Math.floor(Math.random()*(a.length-11)):Math.floor(Math.random()*a.length),t.push(a[e])}return t.join("")},t.isEmpty=e=>""===e||null==e;const l=(e,i,n)=>{if(i&&null===e.dataRef)return n?Promise.resolve(null):null;let r=null;if(e.isContainer)return n?(0,t.readAttachments)(e,i).then((e=>e)):(0,t.getAttachments)(e,i);if((0,s.isFile)(e.getState())){r={};const t=e.name||"",i=null!=e.dataRef?e.dataRef:t.length>0?e.name:void 0;if(e.value instanceof Array)if("string[]"===e.type){if(n)return e.serialize().then((t=>(r[e.id]=t.map((e=>Object.assign(Object.assign({},e),{dataRef:i}))),r)));r[e.id]=e.value.map((e=>Object.assign(Object.assign({},e),{dataRef:i})))}else r[e.id]=e.value.map((e=>Object.assign(Object.assign({},e),{dataRef:i})));else if(null!=e.value)if("string"===e.type){if(n)return e.serialize().then((t=>(r[e.id]=Object.assign(Object.assign({},t[0]),{dataRef:i}),r)));r[e.id]=Object.assign(Object.assign({},e.value),{dataRef:i})}else r[e.id]=Object.assign(Object.assign({},e.value),{dataRef:i})}return n?Promise.resolve(r):r};t.readAttachments=(e,t=!1)=>n(void 0,void 0,void 0,(function*(){return(e.items||[]).reduce(((e,i)=>n(void 0,void 0,void 0,(function*(){const n=yield e,s=yield l(i,t,!0);return Object.assign(n,s)}))),Promise.resolve({}))})),t.getAttachments=(e,t=!1)=>(e.items||[]).reduce(((e,i)=>{const n=l(i,t,!1);return Object.assign(e,n)}),{}),t.getFileSizeInBytes=e=>{let t=0;if("string"==typeof e){const i=o.exec(e.trim());null!=i&&(t=u(parseFloat(i[1]),(i[2]||"kb").toUpperCase()))}return t};const u=(e,t)=>{const i=Math.pow(1024,{KB:1,MB:2,GB:3,TB:4}[t]);return Math.round(e*i)};t.IdGenerator=function*(e=50){const i=function(){const i=[];for(let n=0;n<e;n++)i.push((0,t.randomWord)(10));return i},n={};let s=i();do{let e=s.pop();for(;e in n;)0===s.length&&(s=i()),e=s.pop();n[e]=!0,yield s.pop(),0===s.length&&(s=i())}while(s.length>0)},t.isDataUrl=e=>null!=/^data:([a-z]+\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/.exec(e.trim()),t.extractFileInfo=e=>{if(null!==e){let i=null;if(e instanceof r.FileObject)i=e;else if("undefined"!=typeof File&&e instanceof File)i={name:e.name,mediaType:e.type,size:e.size,data:e};else if("string"==typeof e&&(0,t.isDataUrl)(e)){const n=(0,t.dataURItoBlob)(e);if(null!==n){const{blob:e,name:t}=n;i={name:t,mediaType:e.type,size:e.size,data:e}}}else{let n=e;try{n=JSON.parse(e),i=n,i.mediaType||(i.mediaType=i.type)}catch(e){}if("string"==typeof(null==n?void 0:n.data)&&(0,t.isDataUrl)(null==n?void 0:n.data)){const e=(0,t.dataURItoBlob)(null==n?void 0:n.data);if(null!==e){const t=e.blob;i={name:null==n?void 0:n.name,mediaType:(null==n?void 0:n.type)||(null==n?void 0:n.mediaType),size:t.size,data:t}}}else"string"==typeof n?i={name:n.split("/").pop(),mediaType:"application/octet-stream",size:0,data:n}:"object"==typeof n&&(i={name:null==n?void 0:n.name,mediaType:(null==n?void 0:n.type)||(null==n?void 0:n.mediaType),size:null==n?void 0:n.size,data:null==n?void 0:n.data})}return null!==i&&null!=i.data?new r.FileObject(i):null}return null},t.dataURItoBlob=e=>{const t=/^data:([a-z]+\/[a-z0-9-+.]+)?(?:;name=([^;]+))?(;base64)?,(.+)$/.exec(e);if(null!==t){const e=t[1]||"",i=t[2]||"unknown";if("string"==typeof t[3]){const n=atob(t[4]),s=[];for(let e=0;e<n.length;e++)s.push(n.charCodeAt(e));return{name:i,blob:new window.Blob([new Uint8Array(s)],{type:e})}}return{name:i,blob:new window.Blob([t[4]],{type:e})}}return null},t.sitesModelToFormModel=e=>{if(!e||!Object.keys(e).length)return e;
1if((":items"in(i=e)||"cqItems"in i)&&(":itemsOrder"in i||"cqItemsOrder"in i)){const i=[],n=e[":itemsOrder"]||e.cqItemsOrder,s=e[":items"]||e.cqItems;n.forEach((e=>{i.push((0,t.sitesModelToFormModel)(s[e]))})),e.items=i}var i;return e},t.replaceTemplatePlaceholders=(e,t=[])=>null==e?void 0:e.replace(/\${(\d+)}/g,((e,i)=>{const n=t[i];return void 0!==n?n:e}))},5088:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isRepeatable=t.jsonString=t.checkIfKeyAdded=t.deepClone=t.isButton=t.isCaptcha=t.isDateField=t.isDateTimeField=t.isEmailInput=t.isCheckboxGroup=t.isCheckbox=t.checkIfConstraintsArePresent=t.isFile=t.getProperty=void 0;const n=i(9333),s=i(9616);t.getProperty=(e,t,i)=>{if(t in e)return e[t];if(!t.startsWith(":")){const i=`:${t}`;if(i in e)return e[i]}return i},t.isFile=function(e){return"file"===(null==e?void 0:e.type)||"file[]"===(null==e?void 0:e.type)||("string"===(null==e?void 0:e.type)||"string[]"===(null==e?void 0:e.type))&&("binary"===(null==e?void 0:e.format)||"data-url"===(null==e?void 0:e.format))||"file-input"===(null==e?void 0:e.fieldType)},t.checkIfConstraintsArePresent=function(e){return n.constraintProps.some((t=>void 0!==e[t]))},t.isCheckbox=function(e){return"checkbox"===((null==e?void 0:e.fieldType)||(0,s.defaultFieldTypes)(e))},t.isCheckboxGroup=function(e){return"checkbox-group"===((null==e?void 0:e.fieldType)||(0,s.defaultFieldTypes)(e))},t.isEmailInput=function(e){const t=(null==e?void 0:e.fieldType)||(0,s.defaultFieldTypes)(e);return"text-input"===t&&"email"===(null==e?void 0:e.format)||"email"===t},t.isDateTimeField=function(e){const t=(null==e?void 0:e.fieldType)||(0,s.defaultFieldTypes)(e);return"text-input"===t&&"date-time"===(null==e?void 0:e.format)||"datetime-input"===t},t.isDateField=function(e){const t=(null==e?void 0:e.fieldType)||(0,s.defaultFieldTypes)(e);return"text-input"===t&&"date"===(null==e?void 0:e.format)||"date-input"===t},t.isCaptcha=function(e){return"captcha"===((null==e?void 0:e.fieldType)||(0,s.defaultFieldTypes)(e))},t.isButton=function(e){return"button"===(null==e?void 0:e.fieldType)},t.deepClone=function e(t,i){if(null===t||"object"!=typeof t)return t;let n;if(Array.isArray(t)){n=new Array(t.length);for(let s=0;s<t.length;s++)n[s]=e(t[s],i)}else{n={};for(const s of Object.keys(t))n[s]=e(t[s],i)}return i&&n&&n.id&&(n.id=i()),n},t.checkIfKeyAdded=function(e,i,n){if(null!=e&&null!=i){const s=Object.assign({},i);return s[n]=e[n],""===(0,t.jsonString)(e).replace((0,t.jsonString)(s),"")}return!1},t.jsonString=e=>JSON.stringify(e,null,2),t.isRepeatable=e=>e.repeatable&&(void 0===e.minOccur&&void 0===e.maxOccur||void 0!==e.minOccur&&void 0!==e.maxOccur&&0!==e.maxOccur||void 0!==e.minOccur&&void 0!==e.maxOccur&&0!==e.minOccur&&0!==e.maxOccur||void 0!==e.minOccur&&e.minOccur>=0||void 0!==e.maxOccur&&0!==e.maxOccur)||!1},9616:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.exportDataSchema=t.defaultFieldTypes=void 0;const i=e=>new Map(Object.entries(e)),n=i({date:"date-input","data-url":"file-input",binary:"file-input"}),s=i({number:"number-input",boolean:"checkbox",object:"panel",array:"panel",file:"file-input","file[]":"file-input"}),r=["string[]","boolean[]","number[]","array"];t.defaultFieldTypes=e=>{const t=e.type||"string";return"enum"in e?e.enum.length>2||r.indexOf(t)>-1?"drop-down":"checkbox":"string"===t||"string[]"===t?n.get(e.format)||"text-input":s.get(t)||"text-input"};const a=e=>{var t;if("items"in e){const t=e,i=t.items;if("array"===t.type)return{type:"array",items:a(i[0]),minItems:null==t?void 0:t.minItems,maxItems:null==t?void 0:t.maxItems};{const e=i.filter((e=>null!=e.name));return{type:"object",properties:Object.fromEntries(e.map((e=>[e.name,a(e)]))),required:e.filter((e=>e.required)).map((e=>e.name))}}}{const i=e,n=["type","maxLength","minLength","minimum","maximum","format","pattern","step","enum"].reduce(((e,t)=>{const n=t;return t in i&&null!=i[n]&&(e[t]=i[n]),e}),{});if("none"===i.dataRef||0==Object.keys(n).length)return;return Object.assign({title:null===(t=i.label)||void 0===t?void 0:t.value,description:i.description},n)}};t.exportDataSchema=e=>a(e)},712:(e,t,i)=>
1{Object.defineProperty(t,"__esModule",{value:!0}),t.createTranslationObject=t.createTranslationObj=t.getOrElse=t.addTranslationId=t.invalidateTranslation=t.CUSTOM_PROPS_KEY=t.TRANSLATION_ID=t.TRANSLATION_TOKEN=void 0;const n=i(9333);t.TRANSLATION_TOKEN="##",t.TRANSLATION_ID="afs:translationIds",t.CUSTOM_PROPS_KEY="properties";const s=["de-DE","en-US","es-ES","fr-FR","it-IT","ja-JP","ko-KR","pt-BR","zh-CN","zh-TW"];t.invalidateTranslation=(e,i)=>{n.translationProps.forEach((n=>{var s,r,a,o;n in i&&(null===(r=null===(s=null==e?void 0:e[t.CUSTOM_PROPS_KEY])||void 0===s?void 0:s[t.TRANSLATION_ID])||void 0===r?void 0:r[n])&&(null===(o=null===(a=null==e?void 0:e[t.CUSTOM_PROPS_KEY])||void 0===a?void 0:a[t.TRANSLATION_ID])||void 0===o||delete o[n])}))},t.addTranslationId=(e,t=[])=>{const i=e,s=[...n.translationProps,...t];return r(i,"",s),i};const r=(e,i,n)=>{Object.entries(e).forEach((([s,a])=>{if("object"==typeof a)e instanceof Array?a&&"name"in a&&r(a,`${""===i?i:i+t.TRANSLATION_TOKEN}${a.name}`,n):r(a,"items"===s?i:`${""===i?i:i+t.TRANSLATION_TOKEN}${s}`,n);else if(":type"in e||"type"in e||"fieldType"in e)for(const s of n)null!=(0,t.getOrElse)(e,s)&&(t.CUSTOM_PROPS_KEY in e||(e[t.CUSTOM_PROPS_KEY]={}),t.TRANSLATION_ID in e[t.CUSTOM_PROPS_KEY]||(e[t.CUSTOM_PROPS_KEY][t.TRANSLATION_ID]={}),s in e[t.CUSTOM_PROPS_KEY][t.TRANSLATION_ID]||(e[t.CUSTOM_PROPS_KEY][t.TRANSLATION_ID][s]=`${i}${t.TRANSLATION_TOKEN}${s}${t.TRANSLATION_TOKEN}${Math.floor(1e4*Math.random())+1}`))}))},a=(e,i,n)=>{Object.values(e).forEach((s=>{var r,o;if("object"==typeof s)a(s,i,n);else for(const s of n){const n=(0,t.getOrElse)(e,s);n&&(null===(o=null===(r=null==e?void 0:e[t.CUSTOM_PROPS_KEY])||void 0===r?void 0:r[t.TRANSLATION_ID])||void 0===o?void 0:o[s])&&(n instanceof Array?n.forEach(((n,r)=>{"string"==typeof n&&(i[`${e[t.CUSTOM_PROPS_KEY][t.TRANSLATION_ID][s]}${t.TRANSLATION_TOKEN}${r}`]=n)})):i[`${e[t.CUSTOM_PROPS_KEY][t.TRANSLATION_ID][s]}`]=n)}}))};t.getOrElse=(e,t,i=null)=>{if(!t)return i;const n=Array.isArray(t)?t:t.split(".");let s=e,r=0;for(;r<n.length&&s.hasOwnProperty(n[r]);)s=s[n[r]],r++;return r==n.length?s:i},t.createTranslationObj=(e,t=[])=>{const i={},s=[...n.translationProps,...t];return a(e,i,s),i},t.createTranslationObject=(e,i=[],r=[])=>{const a=[...n.translationProps,...i],o=JSON.parse(JSON.stringify(e)),l=(0,t.createTranslationObj)((0,t.addTranslationId)(o,i),a),u=[...s,...r],d={};for(const e of u)d[e]=JSON.parse(JSON.stringify(l));return[o,d]}},4476:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Constraints=t.validationConstraintsList=t.ValidConstraints=t.coerceType=void 0;const n=i(1060),s=i(6440),r=/^(\d{4})-(\d{1,2})-(\d{1,2})$/,a=/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/,o=[31,28,31,30,31,30,31,31,30,31,30,31];t.coerceType=(e,t)=>{let i;switch(t){case"string":return e+"";case"number":if(i=+e,!isNaN(i))return i;break;case"boolean":if("string"==typeof e)return"true"===e;if("number"==typeof e)return 0!==e}throw`${e} has invalid type. Expected : ${t}, Actual ${typeof e}`};const l=e=>{if(""===e||null==e)return{value:"",valid:!0};let t=parseFloat(e);const i=!isNaN(t);return i||(t=e),{value:t,valid:i}},u=e=>{if(""===e||null==e)return{value:"",valid:!0};let t=parseFloat(e);const i=!isNaN(t)&&Math.round(t)===t;return i||(t=e),{value:t,valid:i}},d=e=>null==e||e instanceof Array?e:[e],c=e=>{const t="boolean"==typeof e||"true"===e||"false"===e;return{valid:t,value:"boolean"==typeof e?e:t?"true"===e:e}},h=e=>{const t=(0,n.extractFileInfo)(e),i=null!==t;return{value:i?t:e,valid:i}},p=(e,t)=>{const i=d(e);return null==i?[[],[i]]:i.reduce(((e,i)=>{if(0==e[1].length){const n=t(i);e[n.valid?0:1].push(n.value)}return e}),[[],[]])};t.ValidConstraints={date:["minimum","maximum","exclusiveMinimum","exclusiveMaximum","format"],string:["minLength","maxLength","pattern"],number:["minimum","maximum","exclusiveMinimum","exclusiveMaximum"],array:["minItems","maxItems","uniqueItems"],file:["accept","maxFileSize"],email:["minLength","maxLength","format","pattern"],datetime:["minimum","maximum"]},t.validationConstraintsList=["type","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","minItems","maxItems","uniqueItems","minLength","maxLength","pattern","required","enum","accept","maxFileSize"],t.Constraints={type:(e,t)=>{let i=t;if(null==t)return{valid:!0,value:t};let n,s=!0;switch(e){case"string":s=!0,i=t.toString();break;case"string[]":i=d(t);break;case"number":n=l(t),i=n.value,s=n.valid;break;case"boolean":n=c(t),s=n.valid,i=n.value;break;case"integer":n=u(t),s=n.valid,i=n.value;break;case"integer[]":n=p(t,u),s=0===n[1].length,i=s?n[0]:t;break;case"file":n=h(t instanceof Array?t[0]:t),s=n.valid,i=n.value;break;case"file[]":n=p(t,h),s=0===n[1].length,i=s?n[0]:t;break;case"number[]":n=p(t,l),s=0===n[1].length,i=s?n[0]:t;break;case"boolean[]":n=p(t,c),s=0===n[1].length,i=s?n[0]:t}return{valid:s,value:i}},format:(e,t)=>
1{let i=!0;const n=t;if(null===t)return{value:n,valid:i};let s;switch(e){case"date":if(s=r.exec((t||"").trim()),null!=s){const[e,t,n,r]=s,[a,l]=[+n,+r],u=(e=>e%400==0||e%4==0&&e%100!=0)(+t);i=a>=1&&a<=12&&l>=1&&l<=((e,t)=>e&&2==t?29:o[t-1])(u,a)}else i=!1;break;case"email":i=new RegExp(a).test((t||"").trim());break;case"data-url":i=!0}return{valid:i,value:n}},minimum:(e,t)=>({valid:t>=e,value:t}),maximum:(e,t)=>({valid:t<=e,value:t}),exclusiveMinimum:(e,t)=>({valid:t>e,value:t}),exclusiveMaximum:(e,t)=>({valid:t<e,value:t}),minItems:(e,t)=>({valid:t instanceof Array&&t.length>=e,value:t}),maxItems:(e,t)=>({valid:t instanceof Array&&t.length<=e,value:t}),uniqueItems:(e,t)=>({valid:!e||t instanceof Array&&t.length===new Set(t).size,value:t}),minLength:(e,i)=>Object.assign(Object.assign({},t.Constraints.minimum(e,"string"==typeof i?i.length:0)),{value:i}),maxLength:(e,i)=>Object.assign(Object.assign({},t.Constraints.maximum(e,"string"==typeof i?i.length:0)),{value:i}),pattern:(e,t)=>{let i;return i="string"==typeof e?new RegExp(e):e,{valid:i.test(t),value:t}},required:(e,t)=>({valid:!e||null!=t&&""!==t,value:t}),enum:(e,t)=>({valid:e.indexOf(t)>-1,value:t}),accept:(e,t)=>e&&0!==e.length&&null!=t?{valid:!(t instanceof Array?t:[t]).some((t=>{return!(""!==(i=t.type)&&(!i||e.some((e=>{const t=e.trim(),n=t.split("/")[0],s=t.split(".")[1];return t.includes("*")&&i.startsWith(n)||t.includes(".")&&i.endsWith(s)||t===i}))));var i})),value:t}:{valid:!0,value:t},maxFileSize:(e,t)=>{const i="string"==typeof e?(0,n.getFileSizeInBytes)(e):e;return{valid:!(t instanceof s.FileObject)||t.size<=i,value:t}}}},7177:function(e,t){var i,n,s,r,a=this&&this.__classPrivateFieldSet||function(e,t,i,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(e,i):s?s.value=i:t.set(e,i),i},o=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Version=void 0,t.Version=class{constructor(e){i.set(this,void 0),n.set(this,void 0),s.set(this,void 0),r.set(this,!0);const t=e.match(/([^.]+)\.([^.]+)(?:\.(.+))?/);if(!t)throw new Error("Invalid version string "+e);if(a(this,n,+t[1],"f"),a(this,i,+t[2],"f"),a(this,s,t[3]?+t[3]:0,"f"),isNaN(o(this,n,"f"))||isNaN(o(this,i,"f"))||isNaN(o(this,s,"f")))throw new Error("Invalid version string "+e)}get major(){return o(this,n,"f")}get minor(){return o(this,i,"f")}get subversion(){return o(this,s,"f")}completeMatch(e){return this.major===e.major&&this.minor===e.minor&&o(this,s,"f")===e.subversion}lessThan(e){return this.major<e.major||this.major===e.major&&this.minor<e.minor||this.major===e.major&&this.minor===e.minor&&o(this,s,"f")<e.subversion}toString(){return`${this.major}.${this.minor}.${this.subversion}`}valueOf(){return this.toString()}},i=new WeakMap,n=new WeakMap,s=new WeakMap,r=new WeakMap},2435:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.adjustTimeZone=o,t.datetimeToNumber=function(e){return null===e?0:e.getTime()/864e5},t.formatDate=function(e,t,i,s){if(i.startsWith("date|")&&(i=i.split("|")[1]),n.ShorthandStyles.find((e=>i.includes(e)))){const r={timeZone:s},a=i.split(/\s/).filter((e=>e.length));return n.ShorthandStyles.indexOf(a[0])>-1&&(r.dateStyle=a[0]),a.length>1&&n.ShorthandStyles.indexOf(a[1])>-1&&(r.timeStyle=a[1]),new Intl.DateTimeFormat(t,r).format(e)}return function(e,t,i,s){const r=(0,n.parseDateTimeSkeleton)(i,t);r.push(["timeZone",s]);const a=r.filter((e=>!e[0].startsWith("x-"))),o=r.filter((e=>e[0].startsWith("x-"))),l=Object.fromEntries(a);delete l.literal;const u=new Intl.DateTimeFormat(t,l).formatToParts(e);return function(e,t){["hour","minute","second"].forEach((i=>{const n=e.find((e=>e.type===i));if(!n)return;const s=t.find((e=>e[0]===i))[1];"2-digit"===s&&1===n.value.length&&(n.value=`0${n.value}`),"numeric"===s&&2===n.value.length&&"0"===n.value.charAt(0)&&(n.value=n.value.slice(1))}))}(u,r),function(e,t){const i=e.find((e=>"year"===e.type));if(!i)return;const n=t.find((e=>"year"===e[0]))[2];for(;i.value.length<n;)i.value=`0${i.value}`}(u,a),a.reduce(((e,t)=>
1{if("literal"===t[0])e.push(t);else{const i=u.find((e=>{return e.type===({hour12:"dayPeriod",fractionalSecondDigits:"fractionalSecond"}[i=t[0]]||i);var i}));if(i&&"timeZoneName"===i.type){const e=o.find((e=>"x-timeZoneName"===e[0]))[1],t=e[0];"Z"===t&&(e.length<4?(i.value=i.value.replace(/(GMT|:)/g,""),""===i.value&&(i.value="+0000")):5===e.length&&("GMT"===i.value?i.value="Z":i.value=i.value.replace(/GMT/,""))),"X"===t||"x"===t?(1===e.length&&(i.value=i.value.replace(/(GMT|:(00)?)/g,"")),2===e.length&&(i.value=i.value.replace(/(GMT|:)/g,"")),3===e.length&&(i.value=i.value.replace(/GMT/g,"")),"X"===t&&""===i.value&&(i.value="Z")):"O"===e&&(i.value=i.value.replace(/GMT/g,"").replace(/0(\d+):/,"$1:").replace(/:00/,""),""===i.value&&(i.value="+0"))}i&&e.push([i.type,i.value])}return e}),[])}(e,t,i,s).map((e=>e[1])).join("")},t.numberToDatetime=function(e){return new Date(Math.round(1e3*e*60*60*24))},t.offsetMS=r,t.offsetMSFallback=a,t.parseDate=l,t.parseDefaultDate=function(e,t,i){return l(e,t,"yyyy-MM-dd",null,i)};var n=i(8880);const s=[0,1,2,3,4,5,6,7,8,9,10,11].map((e=>new Date(2e3,e,1)));function r(e,t){let i;try{i=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"longOffset"}).format(e)}catch(e){return a(0,t)}const n=/GMT([+\-−])?(\d{1,2}):?(\d{0,2})?/.exec(i);if(!n)return 0;const[s,r,o]=n.slice(1),l=60*(60*(isNaN(parseInt(r))?0:parseInt(r))+(isNaN(parseInt(o))?0:parseInt(o)))*1e3;return"-"===s?-l:l}function a(e,t){return 60*function(e){var t=new Date;function i(e){var t=e.replace(":"," ").split(" ");return{day:parseInt(t[0]),hour:parseInt(t[1]),minute:parseInt(t[2])}}var n=t.toLocaleString("en-US",{timeZone:e,day:"numeric",hour:"numeric",minute:"numeric",hourCycle:"h23"}),s=i(n),r=i(n=t.toLocaleString("en-US",{day:"numeric",hour:"numeric",minute:"numeric",hourCycle:"h23"}));return 24*s.day*60+60*s.hour+s.minute-(24*r.day*60+60*r.hour+r.minute)-t.getTimezoneOffset()}(t)*1e3}function o(e,t){if(null===e)return null;let i=e.getTime()-60*e.getTimezoneOffset()*1e3;const n=r(e,t);return a(0,t),i+=-n,new Date(i)}function l(e,t,i,r){let a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];i.startsWith("date|")&&(i=i.split("|")[1]);const l=[],u=[],d=(c=t,"هـ"===(null===(h=new Intl.DateTimeFormat(c,{era:"short"}).formatToParts(new Date).find((e=>"era"===e.type)))||void 0===h?void 0:h.value)?"islamic":"gregory");var c,h;const p=function(e){return new Intl.NumberFormat(e,{style:"decimal",useGrouping:!1}).format(9876543210).split("").reverse()}(t),f=`([${p[0]}-${p[9]}]{1,2})`,m=`([${p[0]}-${p[9]}]{1,3})`,g=`([${p[0]}-${p[9]}]{1,4})`;let _="h12",v=a,y=!1;const b=e=>E(e)-1,E=e=>e.split("").reduce(((e,t)=>10*e+p.indexOf(t)),0),T=(0,n.parseDateTimeSkeleton)(i,t),M=function(e,t){return s.map((i=>{const n=new Intl.DateTimeFormat(e,t).formatToParts(i).find((e=>"month"===e.type));return n&&n.value}))}(t,Object.fromEntries(T));T.forEach((e=>{let[i,n,s]=e;if("literal"===i)u.push(n);else if("month"===i&&["numeric","2-digit"].includes(n))u.push(f),l.push(["month",b]);else if("month"===i&&["formatted","long","short","narrow"].includes(n))u.push(`(${M.join("|")})`),l.push(["month",(a=M,e=>a.indexOf(e))]);else if(["day","minute","second"].includes(i))"minute"!==i&&"second"!==i||(v=!1),u.push(f),l.push([i,E]);else if("fractionalSecondDigits"===i)v=!1,u.push(m),l.push([i,(e,t)=>t.fractionalSecondDigits+E(e)]);else if("hour"===i)v=!1,u.push(f),l.push([i,(e,t)=>t.hour+E(e)]);else if("year"===i)u.push("numeric"===n?g:f),l.push(["year",(r=s,e=>{let t=E(e);return t=t<100&&2===r?t+2e3:t,"islamic"===d&&(t=Math.ceil(.97*t+622)),r>2&&t<100&&(y=!0),t})]);else if("dayPeriod"===i){v=!1;const e=function(e){const t=new Date(2e3,1,1,1,1,1),i=new Date(2e3,1,1,16,1,1),n=new Intl.DateTimeFormat(e,{dateStyle:"full",timeStyle:"full"}),s=n.formatToParts(t).find((e=>"dayPeriod"===e.type)),r=n.formatToParts(i).find((e=>"dayPeriod"===e.type));return s&&r?{regex:`(${s.value}|${r.value})`,fn:(e,t)=>t.hour+=e===r.value?12:0}:null}(t);e&&(u.push(e.regex),l.push(["hour",e.fn]))}else"hourCycle"===i?(v=!1,_=n):"x-timeZoneName"===i?(v=!1,u.push("(?:GMT|UTC|Z)?([+\\-−0-9]{0,3}:?[0-9]{0,2})"),l.push([i,(e,t)=>{if(v=!0,!e)return;const i=e.replace(/−/,"-").match(/([+\-\d]{2,3}):?(\d{0,2})/),n=1*i[1];t.hour-=n;const s=i.length>2?1*i[2]:0;t.minute-=n<0?-s:s}])):"timeZoneName"!==i&&(v=!1,u.push(".+?"));var r,a;return u}),[]);const I=new RegExp(`^${u.join("")}$`),O=e.match(I);if(null===O)return null;const w={year:1972,month:0,day:1,hour:0,minute:0,second:0,fractionalSecondDigits:0};
1if(O.slice(1).forEach(((e,t)=>{const[i,n]=l[t];w[i]=n(e,w)})),"h24"===_&&24===w.hour&&(w.hour=0),"h12"===_&&12===w.hour&&(w.hour=0),v){const e=new Date(Date.UTC(w.year,w.month,w.day,w.hour,w.minute,w.second,w.fractionalSecondDigits));return y&&e.setUTCFullYear(w.year),e}const A=new Date(w.year,w.month,w.day,w.hour,w.minute,w.second,w.fractionalSecondDigits);return y&&A.setFullYear(w.year),null==r?A:o(A,r)}},8880:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ShorthandStyles=void 0,t.getSkeleton=function(e,t){if(n.find((t=>e.includes(t)))){const i=s(e,t),n=[],r={month:"M",year:"Y",day:"d"};return i.forEach((e=>{let[t,i,s]=e;t in r?n.push(Array(s).fill(r[t]).join("")):"literal"===t&&n.push(i)})),n.join("")}return e},t.parseDateTimeSkeleton=function(e,t){if(n.find((t=>e.includes(t))))return s(e,t);const r=[];return e.replace(i,(e=>{const t=e.length;switch(e[0]){case"G":r.push(["era",4===t?"long":5===t?"narrow":"short",t]);break;case"y":r.push(["year",2===t?"2-digit":"numeric",t]);break;case"Y":case"u":case"U":case"r":throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");case"q":case"Q":throw new RangeError("`q/Q` (quarter) patterns are not supported");case"M":case"L":r.push(["month",["numeric","2-digit","short","long","narrow"][t-1],t]);break;case"w":case"W":throw new RangeError("`w/W` (week) patterns are not supported");case"d":r.push(["day",["numeric","2-digit"][t-1],t]);break;case"D":case"F":case"g":throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");case"E":r.push(["weekday",["short","short","short","long","narrow","narrow"][t-1],t]);break;case"e":if(t<4)throw new RangeError("`e..eee` (weekday) patterns are not supported");r.push(["weekday",["short","long","narrow","short"][t-4],t]);break;case"c":if(t<3||t>5)throw new RangeError("`c, cc, cccccc` (weekday) patterns are not supported");r.push(["weekday",["short","long","narrow","short"][t-3],t]);break;case"a":r.push(["hour12",!0,1]);break;case"b":case"B":throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");case"h":r.push(["hourCycle","h12"]),r.push(["hour",["numeric","2-digit"][t-1],t]);break;case"H":r.push(["hourCycle","h23",1]),r.push(["hour",["numeric","2-digit"][t-1],t]);break;case"K":r.push(["hourCycle","h11",1]),r.push(["hour",["numeric","2-digit"][t-1],t]);break;case"k":r.push(["hourCycle","h24",1]),r.push(["hour",["numeric","2-digit"][t-1],t]);break;case"j":case"J":case"C":throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");case"m":r.push(["minute",["numeric","2-digit"][t-1],t]);break;case"s":r.push(["second",["numeric","2-digit"][t-1],t]);break;case"S":r.push(["fractionalSecondDigits",t,t]);break;case"A":throw new RangeError("`S/A` (millisecond) patterns are not supported, use `s` instead");case"O":r.push(["timeZoneName",t<4?"shortOffset":"longOffset",t]),r.push(["x-timeZoneName",t<4?"O":"OOOO",t]);break;case"X":case"x":case"Z":r.push(["timeZoneName","longOffset",1]),r.push(["x-timeZoneName",e,1]);break;case"z":case"v":case"V":throw new RangeError("z/v/V` (timeZone) patterns are not supported, use `X/x/Z/O` instead");case"'":r.push(["literal",e.slice(1,-1).replace(/''/g,"'"),-1]);break;default:r.push(["literal",e,-1])}return""})),r};const i=/(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvV]{1,5}|[zZOvVxX]{1,3}|S{1,3}|'(?:[^']|'')*')|[^a-zA-Z']+/g,n=["full","long","medium","short"];function s(e,t){const i={},n=e.split(/\s/).filter((e=>e.length));i.dateStyle=n[0],n.length>1&&(i.timeStyle=n[1]);const s=new Date(2e3,2,1,2,3,4),r=new Intl.DateTimeFormat(t,i).formatToParts(s),a=r.find((e=>"month"===e.type)).value,o=new Intl.DateTimeFormat(t,{month:"long"}).formatToParts(s)[0].value,l=new Intl.DateTimeFormat(t,{month:"short"}).formatToParts(s)[0].value,u=[];return r.forEach((t=>{let i,{type:n,value:s}=t;"month"===n&&(i={[a]:"medium"===e?"short":"long",[o]:"long",[l]:"short","03":"2-digit",3:"numeric"}[s]),"year"===n&&(i={2e3:"numeric","00":"2-digit"}[s]),["day","hour","minute","second"].includes(n)&&(i=2===s.length?"2-digit":"numeric"),"literal"
1===n&&(i=s),"dayPeriod"===n&&(i="short"),u.push([n,i,s.length])})),u}t.ShorthandStyles=n,new Date(2e3,2,1,2,3,4)},9704:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"datetimeToNumber",{enumerable:!0,get:function(){return n.datetimeToNumber}}),Object.defineProperty(t,"formatDate",{enumerable:!0,get:function(){return n.formatDate}}),Object.defineProperty(t,"getSkeleton",{enumerable:!0,get:function(){return s.getSkeleton}}),Object.defineProperty(t,"numberToDatetime",{enumerable:!0,get:function(){return n.numberToDatetime}}),Object.defineProperty(t,"parseDate",{enumerable:!0,get:function(){return n.parseDate}}),Object.defineProperty(t,"parseDefaultDate",{enumerable:!0,get:function(){return n.parseDefaultDate}});var n=i(2435),s=i(8880)},6608:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"datetimeToNumber",{enumerable:!0,get:function(){return n.datetimeToNumber}}),t.format=void 0,Object.defineProperty(t,"formatDate",{enumerable:!0,get:function(){return n.formatDate}}),Object.defineProperty(t,"formatNumber",{enumerable:!0,get:function(){return s.formatNumber}}),Object.defineProperty(t,"numberToDatetime",{enumerable:!0,get:function(){return n.numberToDatetime}}),t.parse=void 0,Object.defineProperty(t,"parseDate",{enumerable:!0,get:function(){return n.parseDate}}),Object.defineProperty(t,"parseDateSkeleton",{enumerable:!0,get:function(){return n.getSkeleton}}),Object.defineProperty(t,"parseDefaultDate",{enumerable:!0,get:function(){return n.parseDefaultDate}}),Object.defineProperty(t,"parseNumber",{enumerable:!0,get:function(){return s.parseNumber}});var n=i(9704),s=i(1960);const r=function(e){const t=null==e?void 0:e.match(/^(?:(num|date)\|)?(.+)/);return[null==t?void 0:t[1],null==t?void 0:t[2]]};t.format=function(e,t,i,a){const[o,l]=r(i);switch(o){case"date":return e instanceof Date||(e=new Date(e.replace(/-/g,"/").replace(/T.+/,""))),(0,n.formatDate)(e,t,l,a);case"num":return(0,s.formatNumber)(e,t,l);default:throw"unable to deduce the format. The skeleton should be date|<format> for date formats and num|<format> for numbers"}},t.parse=function(e,t,i,a){const[o,l]=r(i);switch(o){case"date":return(0,n.parseDate)(e,t,l,a);case"number":return(0,s.parseNumber)(e,t,l);default:throw"unable to deduce the format. The skeleton should be date|<format> for date formats and num|<format> for numbers"}}},1960:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.formatNumber=function(e,t,i){if(i.startsWith("num|")&&(i=i.split("|")[1]),!i)return e;t=t||"en";const{options:s,order:r}=(0,n.parseNumberSkeleton)(i,t);return new Intl.NumberFormat(t,s).format(e)},t.parseDefaultNumber=function(e,t){return s(e,t,`currency/${currencies[t]||"USD"}`)},t.parseNumber=s;var n=i(1764);function s(e,t,i){try{i.startsWith("num|")&&(i=i.split("|")[1]);let s=1,r=e;const a=function(e,t){const i={};let s=new Intl.NumberFormat(e,{style:"decimal",useGrouping:!1}
1).formatToParts(9876543210.1);i.digits=s.find((e=>"integer"===e.type)).value.split("").reverse(),i.decimal=s.find((e=>"decimal"===e.type)).value;const r=e=>{const t=s.find((t=>t.type===e));t&&(i[e]=t.value)},a=(0,n.parseNumberSkeleton)(t),o=new Intl.NumberFormat(e,a);return s=o.formatToParts(-987654321),r("group"),r("minusSign"),r("percentSign"),i.currency=s.filter((e=>"currency"===e.type)).map((e=>e.value)),i.literal=s.filter((e=>"literal"===e.type)).map((e=>e.value)),s=o.formatToParts(987654321),r("plusSign"),r("exponentSeparator"),r("unit"),i}(t,i);if(a.group&&(r=r.replaceAll(a.group,"")),r=r.replace(a.decimal,"."),a.unit&&(r=r.replaceAll(a.unit,"")),a.minusSign&&r.includes(a.minusSign)&&(r=r.replace(a.minusSign,""),s*=-1),a.percentSign&&r.includes(a.percentSign)&&(s/=100,r=r.replace(a.percentSign,"")),a.currency.forEach((e=>r=r.replace(e,""))),a.literal.forEach((e=>{r.includes(e)&&("("===e&&(s*=-1),r=r.replace(e,""))})),a.plusSign&&(r=r.replace(a.plusSign,"")),a.exponentSeparator){let e;[r,e]=r.split(a.exponentSeparator),s*=Math.pow(10,e)}const o=s*r;return isNaN(o)?e:o}catch(t){return console.dir(t),e}}},1764:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ShorthandStyles=void 0,t.parseNumberSkeleton=function(e,t){const i={},r=[];let o,l;for(l=0;l<a.length&&null==o;l++)o=a[l].exec(e);if(o){switch(l){case 1:i.style="currency",i.currencyDisplay="narrowSymbol",o[1]?i.currency=o[1]:i.currency=(0,n.getCurrency)(t);break;case 2:new Intl.NumberFormat(t,{}).resolvedOptions(),i.minimumFractionDigits=i.minimumFractionDigits||2;break;case 3:i.minimumFractionDigits=0,i.maximumFractionDigits=0;break;case 4:i.style="percent",i.maximumFractionDigits=2;break;case 5:i.style="unit",i.unitDisplay="long",i.unit=o[1]}return{options:i,order:r}}return i.useGrouping=!1,i.minimumIntegerDigits=1,i.maximumFractionDigits=0,i.minimumFractionDigits=0,e.replace(s,((s,a,o,l)=>{const u=s.length;switch(s[0]){case"#":r.push(["digit",u]),!0===(null==i?void 0:i.decimal)&&(i.maximumFractionDigits=i.minimumFractionDigits+u);break;case"@":if(null!=i&&i.minimumSignificantDigits)throw"@ symbol should occur together";const d=a||"";r.push(["@",u-d.length]),i.minimumSignificantDigits=u-d.length,i.maximumSignificantDigits=u,r.push(["digit",d.length]);break;case",":if(!0===(null==i?void 0:i.decimal))throw"grouping character not supporting for fractions";r.push(["group",1]),i.useGrouping="auto";break;case".":null!=i&&i.decimal?console.error("only one decimal symbol is allowed"):(r.push(["decimal",1]),i.decimal=!0);break;case"0":if(r.push("0",u),i.minimumSignificantDigits||i.maximumSignificantDigits)throw"0 is not supported with @";!0===(null==i?void 0:i.decimal)?(i.minimumFractionDigits=u,i.maximumFractionDigits||(i.maximumFractionDigits=u)):i.minimumIntegerDigits=u;break;case"-":0!==l&&console.error("sign display is always in the beginning"),i.signDisplay="negative",r.push(["signDisplay",1,"-"]);break;case"+":0!==l&&"E"===r[r.length-1][0]&&console.error("sign display is always in the beginning"),0===l&&(i.signDisplay="always"),r.push(["signDisplay",1,"+"]);break;case"¤":0!==l&&l!==e.length-1?console.error("currency display should be either in the beginning or at the end"):(i.style="currency",i.currencyDisplay=["symbol","code","name","narrowSymbol"][u-1],i.currency=o||(0,n.getCurrency)(t),r.push(["currency",u]));break;case"%":0!==l&&l!==e.length-1?console.error("percent display should be either in the beginning or at the end"):(r.push(["%",1]),i.style="percent");break;case"E":r.push(["E",u]),i.style=["scientific","engineering"](u-1);break;default:console.error("unknown chars"+s)}})),{options:i,order:r}};var n=i(8763);const s=/(?:[#]+|[@]+(#+)?|[0]+|[,]|[.]|[-]|[+]|[%]|[¤]{1,4}(?:\/([a-zA-Z]{3}))?|[;]|[K]{1,2}|E{1,2}[+]?|'(?:[^']|'')*')|[^a-zA-Z']+/g,r=["acre","bit","byte","celsius","centimeter","day","degree","fahrenheit","fluid-ounce","foot","gallon","gigabit","gigabyte","gram","hectare","hour","inch","kilobit","kilobyte","kilogram","kilometer","liter","megabit","megabyte","meter","mile","mile-scandinavian","milliliter","millimeter","millisecond","minute","month","ounce","percent","petabyte","pound","second","stone","terabit","terabyte","
1week","yard","year"].join("|"),a=[/^currency(?:\/([a-zA-Z]{3}))?$/,/^decimal$/,/^integer$/,/^percent$/,new RegExp(`^unit/(${r})$`)];t.ShorthandStyles=a},8763:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getCurrency=void 0;const i={"da-DK":"DKK","de-DE":"EUR","en-US":"USD","en-GB":"GBP","es-ES":"EUR","fi-FI":"EUR","fr-FR":"EUR","it-IT":"EUR","ja-JP":"JPY","nb-NO":"NOK","nl-NL":"EUR","pt-BR":"BRL","sv-SE":"SEK","zh-CN":"CNY","zh-TW":"TWD","ko-KR":"KRW","cs-CZ":"CZK","pl-PL":"PLN","ru-RU":"RUB","tr-TR":"TRY"},n=Object.keys(i);t.getCurrency=function(e){if(n.indexOf(e)>-1)return i[e];{const t=n.find((t=>t.startsWith(e)));if(t)return i[t]}return""}},3548:(e,t,i)=>{i.r(t),i.d(t,{default:()=>At,jsonFormula:()=>Ct});const n={TYPE_NUMBER:0,TYPE_ANY:1,TYPE_STRING:2,TYPE_ARRAY:3,TYPE_OBJECT:4,TYPE_BOOLEAN:5,TYPE_EXPREF:6,TYPE_NULL:7,TYPE_ARRAY_NUMBER:8,TYPE_ARRAY_STRING:9,TYPE_CLASS:10,TYPE_ARRAY_ARRAY:11},s={TOK_EOF:"EOF",TOK_UNQUOTEDIDENTIFIER:"UnquotedIdentifier",TOK_QUOTEDIDENTIFIER:"QuotedIdentifier",TOK_RBRACKET:"Rbracket",TOK_RPAREN:"Rparen",TOK_COMMA:"Comma",TOK_COLON:"Colon",TOK_CONCATENATE:"Concatenate",TOK_RBRACE:"Rbrace",TOK_NUMBER:"Number",TOK_CURRENT:"Current",TOK_GLOBAL:"Global",TOK_FIELD:"Field",TOK_EXPREF:"Expref",TOK_PIPE:"Pipe",TOK_OR:"Or",TOK_AND:"And",TOK_ADD:"Add",TOK_SUBTRACT:"Subtract",TOK_UNARY_MINUS:"UnaryMinus",TOK_MULTIPLY:"Multiply",TOK_POWER:"Power",TOK_UNION:"Union",TOK_DIVIDE:"Divide",TOK_EQ:"EQ",TOK_GT:"GT",TOK_LT:"LT",TOK_GTE:"GTE",TOK_LTE:"LTE",TOK_NE:"NE",TOK_FLATTEN:"Flatten",TOK_STAR:"Star",TOK_FILTER:"Filter",TOK_DOT:"Dot",TOK_NOT:"Not",TOK_LBRACE:"Lbrace",TOK_LBRACKET:"Lbracket",TOK_LPAREN:"Lparen",TOK_LITERAL:"Literal"},{TYPE_NUMBER:r,TYPE_ANY:a,TYPE_STRING:o,TYPE_ARRAY:l,TYPE_OBJECT:u,TYPE_BOOLEAN:d,TYPE_EXPREF:c,TYPE_NULL:h,TYPE_ARRAY_NUMBER:p,TYPE_ARRAY_STRING:f,TYPE_CLASS:m,TYPE_ARRAY_ARRAY:g}=n,{TOK_EXPREF:_}=s,v={[r]:"number",[a]:"any",[o]:"string",[l]:"array",[u]:"object",[d]:"boolean",[c]:"expression",[h]:"null",[p]:"Array<number>",[f]:"Array<string>",[m]:"class",[g]:"Array<array>"};function y(e,t=!0){if(null===e)return h;let i=e;if(t){if("function"!=typeof e.valueOf)return u;i=e.valueOf.call(e)}switch(Object.prototype.toString.call(i)){case"[object String]":return o;case"[object Number]":return r;case"[object Array]":return l;case"[object Boolean]":return d;case"[object Null]":return h;case"[object Object]":return i.jmespathType===_?c:u;default:return u}}function b(e){return[y(e),y(e,!1)]}function E(e,t,i,n,s,c){const _=e[0];if(-1!==t.findIndex((e=>e===a||_===e)))return i;let y=!1;if((_===u||1===t.length&&t[0]===m)&&(y=!0),_===l&&1===t.length&&t[0]===u&&(y=!0),t.includes(g)){if(_===l&&(i.forEach((e=>{e instanceof Array||(y=!0)})),!y))return i;y=!0}if(y)throw new Error(`TypeError: ${n} expected argument to be type ${v[t[0]]} but received type ${v[_]} instead.`);let T=-1;if(_===l&&t.includes(f)&&t.includes(p)&&(T=i.length>0&&"string"==typeof i[0]?f:p),-1===T&&[f,p,l].includes(_)&&(T=t.find((e=>[f,p,l].includes(e)))),-1===T&&([T]=t),T===a)return i;if(T===f||T===p||T===l){if(T===l)return _===p||_===f?i:null===i?[]:[i];const t=T===p?r:o;if(_===l){const e=i.slice();for(let i=0;i<e.length;i+=1){const r=b(e[i]);e[i]=E(r,[t],e[i],n,s,c)}return e}if([r,o,h,d].includes(t))return[E(e,[t],i,n,s,c)]}else{if(T===r)return[o,d,h].includes(_)?s(i):0;if(T===o)return _===h||_===u?"":c(i);if(T===d)return!!i;if(T===u&&e[1]===u)return i}throw new Error(`TypeError: ${n} expected argument to be type ${v[t[0]]} but received type ${v[_]} instead.`)}function T(e){return null!==e&&"[object Array]"===Object.prototype.toString.call(e)}function M(e){return null!==e&&"[object Object]"===Object.prototype.toString.call(e)}function I(e){return null==e?e:T(e)?e.map((e=>I(e))):"function"!=typeof e.valueOf?e:e.valueOf()}function O(e,t){const i=I(e),n=I(t);if(i===n)return!0;if(Object.prototype.toString.call(i)!==Object.prototype.toString.call(n))return!1;if(!0===T(i)){if(i.length!==n.length)return!1;for(let e=0;e<i.length;e+=1)if(!1===O(i[e],n[e]))return!1;return!0}if(!0===M(i)){const e={};for(const t in i)if(hasOwnProperty.call(i,t)){if(!1===O(i[t],n[t]))return!1;e[t]=!0}for(const t in n)if(hasOwnProperty.call(n,t)&&!0!==e[t])return!1;return!0}return!1}const{TOK_CURRENT:w,TOK_GLOBAL:A,TOK_EXPREF:C,TOK_PIPE:N,TOK_EQ:j,TOK_GT:S,TOK_LT:R,TOK_GTE:x,TOK_LTE:D,TOK_NE:P,TOK_FLATTEN:F}=s,{TYPE_STRING:L,TYPE_ARRAY_STRING:k,TYPE_ARRAY:$}=n;function U(e){if(null===e)return!0;const t=I(e);if(""===t||!1===t||null===t)return!0;
1if(T(t)&&0===t.length)return!0;if(M(t)){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}return!t}class V{constructor(e,t,i,n,s,r){this.runtime=e,this.globals=t,this.toNumber=i,this.toString=n,this.debug=s,this.language=r}search(e,t){return this.visit(e,t)}visit(e,t){const i=e&&{Field:(e,t)=>{if(null!==t&&(M(t)||T(t))){let i=t[e.name];if("function"==typeof i&&(i=void 0),void 0===i){try{this.debug.push(`Failed to find: '${e.name}'`);const i=Object.keys(t).map((e=>`'${e}'`)).toString();i.length&&this.debug.push(`Available fields: ${i}`)}catch(e){}return null}return i}return null},Subexpression:(e,t)=>{let i=this.visit(e.children[0],t);for(let t=1;t<e.children.length;t+=1)if(i=this.visit(e.children[1],i),null===i)return null;return i},IndexExpression:(e,t)=>{const i=this.visit(e.children[0],t);return this.visit(e.children[1],i)},Index:(e,t)=>{if(T(t)){let i=this.toNumber(this.visit(e.value,t));i<0&&(i=t.length+i);const n=t[i];return void 0===n?(this.debug.push(`Index ${i} out of range`),null):n}if(M(t)){const i=this.toString(this.visit(e.value,t)),n=t[i];return void 0===n?(this.debug.push(`Key ${i} does not exist`),null):n}return this.debug.push(`left side of index expression ${t} is not an array or object.`),null},Slice:(e,t)=>{if(!T(t))return null;const i=e.children.slice(0).map((e=>null!=e?this.toNumber(this.visit(e,t)):null)),n=this.computeSliceParams(t.length,i),[s,r,a]=n,o=[];if(a>0)for(let e=s;e<r;e+=a)o.push(t[e]);else for(let e=s;e>r;e+=a)o.push(t[e]);return o},Projection:(e,t)=>{const i=this.visit(e.children[0],t);if(!T(i))return null;const n=[];return i.forEach((t=>{const i=this.visit(e.children[1],t);null!==i&&n.push(i)})),n},ValueProjection:(e,t)=>{const i=this.visit(e.children[0],t);if(!M(I(i)))return null;const n=[];var s;return(s=i,Object.values(s)).forEach((t=>{const i=this.visit(e.children[1],t);null!==i&&n.push(i)})),n},FilterProjection:(e,t)=>{const i=this.visit(e.children[0],t);if(!T(i))return null;const n=i.filter((t=>!U(this.visit(e.children[2],t)))),s=[];return n.forEach((t=>{const i=this.visit(e.children[1],t);null!==i&&s.push(i)})),s},Comparator:(e,t)=>{const i=this.visit(e.children[0],t),n=this.visit(e.children[1],t);if(e.name===j)return O(i,n);if(e.name===P)return!O(i,n);if(e.name===S)return i>n;if(e.name===x)return i>=n;if(e.name===R)return i<n;if(e.name===D)return i<=n;throw new Error(`Unknown comparator: ${e.name}`)},[F]:(e,t)=>{const i=this.visit(e.children[0],t);if(!T(i))return null;const n=[];return i.forEach((e=>{T(e)?n.push(...e):n.push(e)})),n},Identity:(e,t)=>t,MultiSelectList:(e,t)=>null===t?null:e.children.map((e=>this.visit(e,t))),MultiSelectHash:(e,t)=>{if(null===t)return null;const i={};return e.children.forEach((e=>{i[e.name]=this.visit(e.value,t)})),i},OrExpression:(e,t)=>{let i=this.visit(e.children[0],t);return U(i)&&(i=this.visit(e.children[1],t)),i},AndExpression:(e,t)=>{const i=this.visit(e.children[0],t);return!0===U(i)?i:this.visit(e.children[1],t)},AddExpression:(e,t)=>{const i=this.visit(e.children[0],t),n=this.visit(e.children[1],t);return this.applyOperator(i,n,"+")},ConcatenateExpression:(e,t)=>{let i=this.visit(e.children[0],t),n=this.visit(e.children[1],t);return i=E(b(i),[L,k],i,"concatenate",this.toNumber,this.toString),n=E(b(n),[L,k],n,"concatenate",this.toNumber,this.toString),this.applyOperator(i,n,"&")},UnionExpression:(e,t)=>{let i=this.visit(e.children[0],t),n=this.visit(e.children[1],t);return i=E(b(i),[$],i,"union",this.toNumber,this.toString),n=E(b(n),[$],n,"union",this.toNumber,this.toString),i.concat(n)},SubtractExpression:(e,t)=>{const i=this.visit(e.children[0],t),n=this.visit(e.children[1],t);return this.applyOperator(i,n,"-")},MultiplyExpression:(e,t)=>{const i=this.visit(e.children[0],t),n=this.visit(e.children[1],t);return this.applyOperator(i,n,"*")},DivideExpression:(e,t)=>{const i=this.visit(e.children[0],t),n=this.visit(e.children[1],t);return this.applyOperator(i,n,"/")},PowerExpression:(e,t)=>{const i=this.visit(e.children[0],t),n=this.visit(e.children[1],t);return this.applyOperator(i,n,"^")},NotExpression:(e,t)=>U(this.visit(e.children[0],t)),UnaryMinusExpression:(e,t)=>
1-1*this.visit(e.children[0],t),Literal:e=>e.value,Number:e=>e.value,[N]:(e,t)=>{const i=this.visit(e.children[0],t);return this.visit(e.children[1],i)},[w]:(e,t)=>t,[A]:e=>{const t=this.globals[e.name];return void 0===t?null:t},Function:(e,t)=>{if("if"===e.name)return this.runtime.callFunction(e.name,e.children,t,this,!1);const i=e.children.map((e=>this.visit(e,t)));return this.runtime.callFunction(e.name,i,t,this)},ExpressionReference:e=>{const[t]=e.children;return t.jmespathType=C,t}}[e.type];if(!i)throw new Error(`Unknown/missing node type ${e&&e.type||""}`);return i(e,t)}computeSliceParams(e,t){function i(e,t,i){let n=t;return n<0?(n+=e,n<0&&(n=i<0?-1:0)):n>=e&&(n=i<0?e-1:e),n}let[n,s,r]=t;if(null===r)r=1;else if(0===r){const e=new Error("Invalid slice, step cannot be 0");throw e.name="RuntimeError",e}const a=r<0;return n=null===n?a?e-1:0:i(e,n,r),s=null===s?a?-1:e:i(e,s,r),[n,s,r]}applyOperator(e,t,i){if(T(e)&&T(t)){const n=e.length<t.length?e:t,s=Math.abs(e.length-t.length);n.length+=s,n.fill(null,n.length-s);const r=[];for(let n=0;n<e.length;n+=1)r.push(this.applyOperator(e[n],t[n],i));return r}if(T(e))return e.map((e=>this.applyOperator(e,t,i)));if(T(t))return t.map((t=>this.applyOperator(e,t,i)));if("*"===i)return this.toNumber(e)*this.toNumber(t);if("&"===i)return e+t;if("+"===i)return this.toNumber(e)+this.toNumber(t);if("-"===i)return this.toNumber(e)-this.toNumber(t);if("/"===i){const i=e/t;return Number.isFinite(i)?i:null}if("^"===i)return e**t;throw new Error(`Unknown operator: ${i}`)}}const{TOK_UNQUOTEDIDENTIFIER:B,TOK_QUOTEDIDENTIFIER:Y,TOK_RBRACKET:K,TOK_RPAREN:H,TOK_COMMA:q,TOK_COLON:G,TOK_CONCATENATE:z,TOK_RBRACE:W,TOK_NUMBER:Q,TOK_CURRENT:J,TOK_GLOBAL:Z,TOK_EXPREF:X,TOK_PIPE:ee,TOK_OR:te,TOK_AND:ie,TOK_ADD:ne,TOK_SUBTRACT:se,TOK_UNARY_MINUS:re,TOK_MULTIPLY:ae,TOK_POWER:oe,TOK_DIVIDE:le,TOK_UNION:ue,TOK_EQ:de,TOK_GT:ce,TOK_LT:he,TOK_GTE:pe,TOK_LTE:fe,TOK_NE:me,TOK_FLATTEN:ge,TOK_STAR:_e,TOK_FILTER:ve,TOK_DOT:ye,TOK_NOT:be,TOK_LBRACE:Ee,TOK_LBRACKET:Te,TOK_LPAREN:Me,TOK_LITERAL:Ie}=s,Oe={".":ye,",":q,":":G,"{":Ee,"}":W,"]":K,"(":Me,")":H,"@":J},we={"<":!0,">":!0,"=":!0,"!":!0},Ae={" ":!0,"\t":!0,"\n":!0};function Ce(e){return e>="0"&&e<="9"||"."===e}function Ne(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||"_"===e}function je(e,t){const i=e[t];return"$"===i?e.length>t&&Ne(e[t+1]):i>="a"&&i<="z"||i>="A"&&i<="Z"||"_"===i}class Se{constructor(e=[],t=[]){this._allowedGlobalNames=e,this.debug=t}tokenize(e){const t=[];let i,n,s;for(this._current=0;this._current<e.length;){const r=t.length?t.slice(-1)[0].type:null;if(this._isGlobal(r,e,this._current))t.push(this._consumeGlobal(e));else if(je(e,this._current))i=this._current,n=this._consumeUnquotedIdentifier(e),t.push({type:B,value:n,start:i});else if(void 0!==Oe[e[this._current]])t.push({type:Oe[e[this._current]],value:e[this._current],start:this._current}),this._current+=1;else if("-"!==e[this._current]||[Z,J,Q,H,B,Y,K].includes(r))if(Ce(e[this._current]))s=this._consumeNumber(e),t.pu
1sh(s);else if("["===e[this._current])s=this._consumeLBracket(e),t.push(s);else if('"'===e[this._current])i=this._current,n=this._consumeQuotedIdentifier(e),t.push({type:Y,value:n,start:i});else if("'"===e[this._current])i=this._current,n=this._consumeRawStringLiteral(e),t.push({type:Ie,value:n,start:i});else if("`"===e[this._current]){i=this._current;const n=this._consumeLiteral(e);t.push({type:Ie,value:n,start:i})}else if(void 0!==we[e[this._current]])t.push(this._consumeOperator(e));else if(void 0!==Ae[e[this._current]])this._current+=1;else if("&"===e[this._current])i=this._current,this._current+=1,"&"===e[this._current]?(this._current+=1,t.push({type:ie,value:"&&",start:i})):r===q||r===Me?t.push({type:X,value:"&",start:i}):t.push({type:z,value:"&",start:i});else if("~"===e[this._current])i=this._current,this._current+=1,t.push({type:ue,value:"~",start:i});else if("+"===e[this._current])i=this._current,this._current+=1,t.push({type:ne,value:"+",start:i});else if("-"===e[this._current])i=this._current,this._current+=1,t.push({type:se,value:"-",start:i});else if("*"===e[this._current]){i=this._current,this._current+=1;const e=t.length&&t.slice(-1)[0].type;0===t.length||[Te,ye,ee,ie,te,q,G].includes(e)?t.push({type:_e,value:"*",start:i}):t.push({type:ae,value:"*",start:i})}else if("/"===e[this._current])i=this._current,this._current+=1,t.push({type:le,value:"/",start:i});else if("^"===e[this._current])i=this._current,this._current+=1,t.push({type:oe,value:"^",start:i});else{if("|"!==e[this._current]){const t=new Error(`Unknown character:${e[this._current]}`);throw t.name="LexerError",t}i=this._current,this._current+=1,"|"===e[this._current]?(this._current+=1,t.push({type:te,value:"||",start:i})):t.push({type:ee,value:"|",start:i})}else s=this._consumeUnaryMinus(e),t.push(s)}return t}_consumeUnquotedIdentifier(e){const t=this._current;for(this._current+=1;this._current<e.length&&Ne(e[this._current]);)this._current+=1;return e.slice(t,this._current)}_consumeQuotedIdentifier(e){const t=this._current;this._current+=1;const i=e.length;let n=!je(e,t+1);for(;'"'!==e[this._current]&&this._current<i;){let t=this._current;Ne(e[t])||(n=!0),"\\"!==e[t]||"\\"!==e[t+1]&&'"'!==e[t+1]?t+=1:t+=2,this._current=t}this._current+=1;const s=e.slice(t,this._current);try{n&&!s.includes(" ")||(this.debug.push(`Suspicious quotes: ${s}`),this.debug.push(`Did you intend a literal? '${s.replace(/"/g,"")}'?`))}catch(e){}return JSON.parse(s)}_consumeRawStringLiteral(e){const t=this._current;this._current+=1;const i=e.length;for(;"'"!==e[this._current]&&this._current<i;){let t=this._current;"\\"!==e[t]||"\\"!==e[t+1]&&"'"!==e[t+1]?t+=1:t+=2,this._current=t}return this._current+=1,e.slice(t+1,this._current-1).replaceAll("\\'","'")}_consumeNumber(e){const t=this._current;this._current+=1;const i=e.length;for(;Ce(e[this._current])&&this._current<i;)this._current+=1;const n=e.slice(t,this._current);let s;return s=n.includes(".")?parseFloat(n):parseInt(n,10),{type:Q,value:s,start:t}}_consumeUnaryMinus(){const e=this._current;return this._current+=1,{type:re,value:"-",start:e}}_consumeLBracket(e){const t=this._current;return this._current+=1,"?"===e[this._current]?(this._current+=1,{type:ve,value:"[?",start:t}):"]"===e[this._current]?(this._current+=1,{type:ge,value:"[]",start:t}):{type:Te,value:"[",start:t}}_isGlobal(e,t,i){if(null!==e&&e===ye)return!1;if("$"!==t[i])return!1;let n=i+1;for(;n<t.length&&Ne(t[n]);)n+=1;const s=t.slice(i,n);return this._allowedGlobalNames.includes(s)}_consumeGlobal(e){const t=this._current;for(this._current+=1;this._current<e.length&&Ne(e[this._current]);)this._current+=1;const i=e.slice(t,this._current);return{type:Z,name:i,start:t}}_consumeOperator(e){const t=this._current,i=e[t];return this._current+=1,"!"===i?"="===e[this._current]?(this._current+=1,{type:me,value:"!=",start:t}):{type:be,value:"!",start:t}:"<"===i?"="===e[this._current]?(this._current+=1,{type:fe,value:"<=",start:t}):{type:he,value:"<",start:t}:">"===i?"="===e[this._current]?(this._current+=1,{type:pe,value:">=",start:t}):{type:ce,value:">",start:t}:"="===e[this._current]?(this._current+=1,{type:de,value:"==",start:t}):{type:de,value:"=",start:t}}_consumeLiteral(e){this._current+=1;const t=this._current,i=e.length;let n,s=!1;for(;(s||"`"!==e[this._current])&&this._current<i;){let t=this._current;s&&"\\"===e[t]&&'"'===e[t+1]?t+=2:('"'===e[t]&&(s=!s),s&&"`"===e[t+1]?t+=2:"\\"!==e[t]||"\\"!==e[t+1]&&"`"!==e[t+1]?t+=1:t+=2),this._current=t}let r=e.slice(t,this._current).trimStart();return r=r.replaceAll("\\`","`"),n=function(e){if(""===e)return!1;if('[{"'.includes(e[0]))return!0;
1if(["true","false","null"].includes(e))return!0;if(!"-0123456789".includes(e[0]))return!1;try{return JSON.parse(e),!0}catch(e){return!1}}(r)?JSON.parse(r):JSON.parse(`"${r}"`),this._current+=1,n}}const{TOK_LITERAL:Re,TOK_COLON:xe,TOK_EOF:De,TOK_UNQUOTEDIDENTIFIER:Pe,TOK_QUOTEDIDENTIFIER:Fe,TOK_RBRACKET:Le,TOK_RPAREN:ke,TOK_COMMA:$e,TOK_CONCATENATE:Ue,TOK_RBRACE:Ve,TOK_NUMBER:Be,TOK_CURRENT:Ye,TOK_GLOBAL:Ke,TOK_FIELD:He,TOK_EXPREF:qe,TOK_PIPE:Ge,TOK_OR:ze,TOK_AND:We,TOK_ADD:Qe,TOK_SUBTRACT:Je,TOK_UNARY_MINUS:Ze,TOK_MULTIPLY:Xe,TOK_POWER:et,TOK_DIVIDE:tt,TOK_UNION:it,TOK_EQ:nt,TOK_GT:st,TOK_LT:rt,TOK_GTE:at,TOK_LTE:ot,TOK_NE:lt,TOK_FLATTEN:ut,TOK_STAR:dt,TOK_FILTER:ct,TOK_DOT:ht,TOK_NOT:pt,TOK_LBRACE:ft,TOK_LBRACKET:mt,TOK_LPAREN:gt}=s,_t={[De]:0,[Pe]:0,[Fe]:0,[Le]:0,[ke]:0,[$e]:0,[Ve]:0,[Be]:0,[Ye]:0,[Ke]:0,[He]:0,[qe]:0,[Ge]:1,[ze]:2,[We]:3,[Ue]:5,[Qe]:6,[Je]:6,[Xe]:7,[tt]:7,[et]:7,[it]:7,[nt]:5,[st]:5,[rt]:5,[at]:5,[ot]:5,[lt]:5,[ut]:9,[dt]:20,[ct]:21,[ht]:40,[pt]:30,[Ze]:30,[ft]:50,[mt]:55,[gt]:60};class vt{constructor(e=[]){this._allowedGlobalNames=e}parse(e,t){this._loadTokens(e,t),this.index=0;const i=this.expression(0);if(this._lookahead(0)!==De){const e=this._lookaheadToken(0),t=new Error(`Unexpected token type: ${e.type}, value: ${e.value}`);throw t.name="ParserError",t}return i}_loadTokens(e,t){const i=new Se(this._allowedGlobalNames,t).tokenize(e);i.push({type:De,value:"",start:e.length}),this.tokens=i}expression(e){const t=this._lookaheadToken(0);this._advance();let i=this.nud(t),n=this._lookahead(0);for(;e<_t[n];)this._advance(),i=this.led(n,i),n=this._lookahead(0);return i}_lookahead(e){return this.tokens[this.index+e].type}_lookaheadToken(e){return this.tokens[this.index+e]}_advance(){this.index+=1}_getIndex(){return this.index}_setIndex(e){this.index=e}nud(e){let t,i,n,s,r;switch(e.type){case Re:return{type:"Literal",value:e.value};case Be:return{type:"Number",value:e.value};case Pe:return{type:"Field",name:e.value};case Fe:if(s={type:"Field",name:e.value},this._lookahead(0)===gt)throw new Error("Quoted identifier not allowed for function names.");return s;case pt:return i=this.expression(_t.Not),{type:"NotExpression",children:[i]};case Ze:return i=this.expression(_t.UnaryMinus),{type:"UnaryMinusExpression",children:[i]};case dt:return t={type:"Identity"},i=this._lookahead(0)===Le?{type:"Identity"}:this._parseProjectionRHS(_t.Star),{type:"ValueProjection",children:[t,i]};case ct:return this.led(e.type,{type:"Identity"});case ft:return this._parseMultiselectHash();case ut:return t={type:ut,children:[{type:"Identity"}]},i=this._parseProjectionRHS(_t.Flatten),{type:"Projection",children:[t,i]};case mt:return this._lookahead(0)===dt&&this._lookahead(1)===Le?(this._advance(),this._advance(),i=this._parseProjectionRHS(_t.Star),{type:"Projection",children:[{type:"Identity"},i]}):this._parseUnchainedIndexExpression();case Ye:return{type:Ye};case Ke:return{type:Ke,name:e.name};case He:return{type:He};case qe:return n=this.expression(_t.Expref),{type:"ExpressionReference",children:[n]};case gt:for(r=[];this._lookahead(0)!==ke;)n=this.expression(0),r.push(n);return this._match(ke),r[0];default:this._errorToken(e)}}led(e,t){let i,n,s,r,a,o,l,u,d;switch(e){case Ue:return n=this.expression(_t.Concatenate),{type:"ConcatenateExpression",children:[t,n]};case ht:return l=_t.Dot,this._lookahead(0)!==dt?(n=this._parseDotRHS(l),{type:"Subexpression",children:[t,n]}):(this._advance(),n=this._parseProjectionRHS(l),{type:"ValueProjection",children:[t,n]});case Ge:return n=this.expression(_t.Pipe),{type:Ge,children:[t,n]};case ze:return n=this.expression(_t.Or),{type:"OrExpression",children:[t,n]};case We:return n=this.expression(_t.And),{type:"AndExpression",children:[t,n]};case Qe:return n=this.expression(_t.Add),{type:"AddExpression",children:[t,n]};case Je:return n=this.expression(_t.Subtract),{type:"SubtractExpression",children:[t,n]};case Xe:return n=this.expression(_t.Multiply),{type:"MultiplyExpression",children:[t,n]};case tt:return n=this.expression(_t.Divide),{type:"DivideExpression",children:[t,n]};case et:return n=this.expression(_t.Power),{type:"PowerExpression",children:[t,n]};case it:return n=this.expression(_t.Power),{type:"UnionExpression",children:[t,n]};case gt:for(s=t.name,r=[];this._lookahead(0)!==ke;)a=this.expression(0),this._lookahead(0)===$e&&this._match($e),r.push(a);return this._match(ke),o={type:"Function",name:s,children:r},o;case ct:return i=this.expression(0),this._match(Le),n=this._lookahead(0)===ut?{type:"Identity"}:this._parseProjectionRHS(_t.Filter),{type:"FilterProjection",children:[t,n,i]};case ut:return u={type:ut,children:[t]},d=this._parseProjectionRHS(_t.Flatten),{type:"Projection",children:[u,d]};case nt:case lt:case st:case at:case rt:case ot:return this._parseComparator(t,e);case mt:return this._lookahead(0)===dt&&this._lookahead(1)===Le?(this._advance(),this._advance(),n=this._parseProjectionRHS(_t.Star),{type:"Projection",children:[t,n]}):(n=this._parseChainedIndexExpression(),this._projectIfSlice(t,n));default:this._errorToken(this._lookaheadToken(0))}}_match(e){if(this._lookahead(0)!==e){const t=this._lookaheadToken(0),i=new Error(`Expected ${e}, got: ${t.type}`);throw i.name="ParserError",i}this._advance()}_errorToken(e){const t=new Error(`Invalid token (${e.type}): "${e.value}"`);throw t.name="ParserError",t}_parseChainedIndexExpression(){const e=this._getIndex();if(this._lookahead(0)===xe)return this._parseSliceExpression();const t=this.expression(0);return this._lookahead(0)===xe?(this._setIndex(e),this._parseSliceExpression()):(this._match(Le),{type:"Index",value:t})}
1_parseUnchainedIndexExpression(){const e=this._getIndex(),t=this._lookahead(0);if(t===xe){const e=this._parseSliceExpression();return this._projectIfSlice({type:"Identity"},e)}const i=this.expression(0),n=this._lookahead(0);if(n===$e)return this._setIndex(e),this._parseMultiselectList();if(n===xe){this._setIndex(e);const t=this._parseSliceExpression();return this._projectIfSlice({type:"Identity"},t)}return t===Be||t===Ze?(this._match(Le),{type:"Index",value:i}):(this._setIndex(e),this._parseMultiselectList())}_projectIfSlice(e,t){const i={type:"IndexExpression",children:[e,t]};return"Slice"===t.type?{type:"Projection",children:[i,this._parseProjectionRHS(_t.Star)]}:i}_parseSliceExpression(){const e=[null,null,null];let t=0,i=this._lookahead(0);for(;i!==Le&&t<3;){if(i===xe&&t<2)t+=1,this._advance();else{e[t]=this.expression(0);const i=this._lookahead(0);if(i!==xe&&i!==Le){const e=new Error(`Syntax error, unexpected token: ${i.value}(${i.type})`);throw e.name="Parsererror",e}}i=this._lookahead(0)}return this._match(Le),{type:"Slice",children:e}}_parseComparator(e,t){return{type:"Comparator",name:t,children:[e,this.expression(_t[t])]}}_parseDotRHS(e){const t=this._lookahead(0);return[Pe,Fe,dt].indexOf(t)>=0?this.expression(e):t===mt?(this._match(mt),this._parseMultiselectList()):t===ft?(this._match(ft),this._parseMultiselectHash()):void 0}_parseProjectionRHS(e){let t;if(_t[this._lookahead(0)]<10)t={type:"Identity"};else if(this._lookahead(0)===mt)t=this.expression(e);else if(this._lookahead(0)===ct)t=this.expression(e);else{if(this._lookahead(0)!==ht){const e=this._lookaheadToken(0),t=new Error(`Sytanx error, unexpected token: ${e.value}(${e.type})`);throw t.name="ParserError",t}this._match(ht),t=this._parseDotRHS(e)}return t}_parseMultiselectList(){const e=[];for(;this._lookahead(0)!==Le;){const t=this.expression(0);if(e.push(t),this._lookahead(0)===$e&&(this._match($e),this._lookahead(0)===Le))throw new Error("Unexpected token Rbracket")}return this._match(Le),{type:"MultiSelectList",children:e}}_parseMultiselectHash(){const e=[],t=[Pe,Fe];let i,n,s,r;if(this._lookahead(0)===Ve)return this._advance(),{type:"MultiSelectHash",children:[]};for(;;){if(i=this._lookaheadToken(0),t.indexOf(i.type)<0)throw new Error(`Expecting an identifier token, got: ${i.type}`);if(n=i.value,this._advance(),this._match(xe),s=this.expression(0),r={type:"KeyValuePair",name:n,value:s},e.push(r),this._lookahead(0)===$e)this._match($e);else if(this._lookahead(0)===Ve){this._match(Ve);break}}return{type:"MultiSelectHash",children:e}}}function yt(e,t){const i=10**t;return Math.round(e*i)/i}const bt=864e5;const{TYPE_CLASS:Et,TYPE_ANY:Tt}=n;function Mt(e){return null==e?"":e.toString()}const It=e=>{const t=+e;return Number.isNaN(t)?0:t};class Ot{constructor(e,t,i={}){this.strictDeepEqual=O,this.toNumber=t,this.functionTable=function(e,t,i,s,r,a,o,l){const{TYPE_NUMBER:u,TYPE_ANY:d,TYPE_STRING:c,TYPE_ARRAY:h,TYPE_OBJECT:p,TYPE_BOOLEAN:f,TYPE_EXPREF:m,TYPE_NULL:g,TYPE_ARRAY_NUMBER:_,TYPE_ARRAY_STRING:v}=n;function y(t,i){return n=>{const s=e.interpreter.visit(t,n);if(i.indexOf(r(s))<0){const e=`TypeError: expected one of ${i}, received ${r(s)}`;throw new Error(e)}return s}}const b={abs:{_func:e=>Math.abs(e[0]),_signature:[{types:[u]}]},avg:{_func:e=>{let t=0;const i=e[0];return i.forEach((e=>{t+=e})),t/i.length},_signature:[{types:[_]}]},ceil:{_func:e=>Math.ceil(e[0]),_signature:[{types:[u]}]},contains:{_func:e=>a(e[0]).indexOf(a(e[1]))>=0,_signature:[{types:[c,h]},{types:[d]}]},endsWith:{_func:e=>{const t=a(e[0]),i=a(e[1]);return-1!==t.indexOf(i,t.length-i.length)},_signature:[{types:[c]},{types:[c]}]},floor:{_func:e=>Math.floor(e[0]),_signature:[{types:[u]}]},join:{_func:e=>{const t=e[0];return e[1].join(t)},_signature:[{types:[c]},{types:[v]}]},keys:{_func:e=>null===e[0]?[]:Object.keys(e[0]),_signature:[{types:[d]}]},length:{_func:e=>{const n=a(e[0]);return t(n)?Object.keys(n).length:i(n)?n.length:o(n).length},_signature:[{types:[c,h,p]}]},map:{_func:t=>{const i=t[0];return t[1].map((t=>e.interpreter.visit(i,t)))},_signature:[{types:[m]},{types:[h]}]},max:{_func:e=>{const t=e.reduce(((e,t)=>(Array.isArray(t)?e.push(...t):e.push(t),e)),[]),i=t.find((e=>null!==e));if(0===t.length||void 0===i)return null;const n=r(i,!0)===u,a=n?(e,t)=>{const i=s(t);return e<=i?i:e}:(e,t)=>{const i=o(t);return 1===e.localeCompare(i)?e:i};return t.reduce(a,n?s(i):o(i))},_signature:[{types:[h,_,v],variadic:!0}]},maxBy:{_func:e=>{const t=e[1],i=e[0],n=y(t,[u,c]);let s,r,a=-1/0;
1return i.forEach((e=>{r=n(e),r>a&&(a=r,s=e)})),s},_signature:[{types:[h]},{types:[m]}]},merge:{_func:e=>{const t={};return e.forEach((e=>{Object.entries(e||{}).forEach((([e,i])=>{t[e]=i}))})),t},_signature:[{types:[p],variadic:!0}]},min:{_func:e=>{const t=e.reduce(((e,t)=>(Array.isArray(t)?e.push(...t):e.push(t),e)),[]),i=t.find((e=>null!==e));if(0===t.length||void 0===i)return null;const n=r(i,!0)===u,a=n?(e,t)=>{const i=s(t);return e<=i?e:i}:(e,t)=>{const i=o(t);return 1===e.localeCompare(i)?i:e};return t.reduce(a,n?s(i):o(i))},_signature:[{types:[h,_,v],variadic:!0}]},minBy:{_func:e=>{const t=e[1],i=e[0],n=y(t,[u,c]);let s,r,a=1/0;return i.forEach((e=>{r=n(e),r<a&&(a=r,s=e)})),s},_signature:[{types:[h]},{types:[m]}]},notNull:{_func:e=>e.find((e=>r(e)!==g))||null,_signature:[{types:[d],variadic:!0}]},reduce:{_func:t=>{const i=t[0];return t[1].reduce(((t,n,s,r)=>e.interpreter.visit(i,{accumulated:t,current:n,index:s,array:r})),3===t.length?t[2]:null)},_signature:[{types:[m]},{types:[h]},{types:[d],optional:!0}]},register:{_func:t=>{const i=t[0],n=t[1];return b[i]?(l.push(`Cannot re-register '${i}'`),{}):(b[i]={_func:t=>e.interpreter.visit(n,...t),_signature:[{types:[d],optional:!0}]},{})},_signature:[{types:[c]},{types:[m]}]},reverse:{_func:e=>{const t=a(e[0]);if(r(t)===c){let e="";for(let i=t.length-1;i>=0;i-=1)e+=t[i];return e}const i=e[0].slice(0);return i.reverse(),i},_signature:[{types:[c,h]}]},sort:{_func:e=>{const t=e[0].slice(0);if(t.length>0){const i=r(e[0][0])===u?s:o;t.sort(((e,t)=>{const n=i(e),s=i(t);return n<s?-1:n>s?1:0}))}return t},_signature:[{types:[h,v,_]}]},sortBy:{_func:t=>{const i=t[0].slice(0);if(0===i.length)return i;const n=t[1],s=r(e.interpreter.visit(n,i[0]));if([u,c].indexOf(s)<0)throw new Error("TypeError");const a=[];for(let e=0;e<i.length;e+=1)a.push([e,i[e]]);a.sort(((t,i)=>{const a=e.interpreter.visit(n,t[1]),o=e.interpreter.visit(n,i[1]);if(r(a)!==s)throw new Error(`TypeError: expected ${s}, received ${r(a)}`);if(r(o)!==s)throw new Error(`TypeError: expected ${s}, received ${r(o)}`);return a>o?1:a<o?-1:t[0]-i[0]}));for(let e=0;e<a.length;e+=1)[,i[e]]=a[e];return i},_signature:[{types:[h]},{types:[m]}]},startsWith:{_func:e=>a(e[0]).startsWith(a(e[1])),_signature:[{types:[c]},{types:[c]}]},sum:{_func:e=>{let t=0;
1return e[0].forEach((e=>{t+=1*e})),t},_signature:[{types:[_]}]},toArray:{_func:e=>r(e[0])===h?e[0]:[e[0]],_signature:[{types:[d]}]},toNumber:{_func:e=>{const t=r(e[0]);return t===u?e[0]:t===c?s(e[0]):null},_signature:[{types:[d]}]},toString:{_func:e=>r(e[0])===c?e[0]:JSON.stringify(e[0]),_signature:[{types:[d]}]},type:{_func:e=>({[u]:"number",[c]:"string",[h]:"array",[p]:"object",[f]:"boolean",[m]:"expref",[g]:"null"}[r(e[0])]),_signature:[{types:[d]}]},values:{_func:e=>{const t=a(e[0]);return null===t?[]:Object.values(t)},_signature:[{types:[d]}]},zip:{_func:e=>{const t=e.reduce(((e,t)=>Math.min(e,t.length)),e[0].length),i=new Array(t);for(let n=0;n<t;n+=1)i[n]=[],e.forEach((e=>{i[n].push(e[n])}));return i},_signature:[{types:[h],variadic:!0}]}};return b}(this,M,T,t,y,I,Mt,e),Object.entries(function(e,t,i,s=[]){return{and:{_func:t=>{let i=!!e(t[0]);return t.slice(1).forEach((t=>{i=i&&!!e(t)})),i},_signature:[{types:[n.TYPE_ANY],variadic:!0}]},casefold:{_func:(e,i,n)=>t(e[0]).toLocaleUpperCase(n.language).toLocaleLowerCase(n.language),_signature:[{types:[n.TYPE_STRING]}]},datedif:{_func:e=>{const n=i(e[0]),s=i(e[1]),r=t(e[2]).toLowerCase();if(s===n)return 0;if(s<n)return null;if("d"===r)return Math.floor(s-n);const a=new Date(n*bt),o=new Date(s*bt),l=o.getFullYear()-a.getFullYear();let u=o.getMonth()-a.getMonth();const d=o.getDate()-a.getDate();if("y"===r){let e=l;return u<0&&(e-=1),0===u&&d<0&&(e-=1),e}if("m"===r)return 12*l+u+(d<0?-1:0);if("ym"===r)return d<0&&(u-=1),u<=0&&l>0?12+u:u;if("yd"===r)return d<0&&(u-=1),u<0?o.setFullYear(a.getFullYear()+1):o.setFullYear(a.getFullYear()),Math.floor((o.getTime()-a.getTime())/bt);throw new TypeError(`Unrecognized unit parameter "${r}" for datedif()`)},_signature:[{types:[n.TYPE_NUMBER]},{types:[n.TYPE_NUMBER]},{types:[n.TYPE_STRING]}]},datetime:{_func:e=>{const n=i(e[0]),s=i(e[1]),r=i(e[2]),a=e.length>3?i(e[3]):0,o=e.length>4?i(e[4]):0,l=e.length>5?i(e[5]):0,u=e.length>6?i(e[6]):0,d=e.length>7?t(e[7]):null;let c=new Date(n,s-1,r,a,o,l,u);return d&&(c=function(e,t){if(null===e)return null;let i=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds());return i+=function(e,t){const i=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"longOffset"}).format(e),n=/GMT([+\-−])?(\d{1,2}):?(\d{0,2})?/.exec(i);if(!n)return 0;const[s,r,a]=n.slice(1),o=60*(60*(r||0)+1*(a||0))*1e3;return"-"===s?-1*o:o}(e,t),new Date(i)}(c,d)),c.getTime()/bt},_signature:[{types:[n.TYPE_NUMBER]},{types:[n.TYPE_NUMBER]},{types:[n.TYPE_NUMBER]},{types:[n.TYPE_NUMBER],optional:!0},{types:[n.TYPE_NUMBER],optional:!0},{types:[n.TYPE_NUMBER],optional:!0},{types:[n.TYPE_NUMBER],optional:!0},{types:[n.TYPE_STRING],optional:!0}]},day:{_func:e=>{const t=i(e[0]);return new Date(t*bt).getDate()},_signature:[{types:[n.TYPE_NUMBER]}]},deepScan:{_func:e=>{const[t,i]=e,n=i.toString(),s=[];return null===t||function e(t){Object.entries(t).forEach((([t,i])=>{t===n&&s.push(i),"object"==typeof i&&e(i)}))}(t),s},_signature:[{types:[n.TYPE_OBJECT,n.TYPE_ARRAY,n.TYPE_NULL]},{types:[n.TYPE_STRING,n.TYPE_NUMBER]}]},entries:{_func:t=>{const i=e(t[0]);return Object.entries(i)},_signature:[{types:[n.TYPE_NUMBER,n.TYPE_STRING,n.TYPE_ARRAY,n.TYPE_OBJECT,n.TYPE_BOOLEAN]}]},eomonth:{_func:e=>{const t=i(e[0]),n=i(e[1]),s=new Date(t*bt);return new Date(s.getFullYear(),s.getMonth()+n+1,0).getTime()/bt},_signature:[{types:[n.TYPE_NUMBER]},{types:[n.TYPE_NUMBER]}]},exp:{_func:e=>{const t=i(e[0]);return Math.exp(t)},_signature:[{types:[n.TYPE_NUMBER]}]},false:{_func:()=>!1,_signature:[]},find:{_func:e=>{const n=t(e[0]),s=t(e[1]),r=e.length>2?i(e[2]):0,a=s.indexOf(n,r);return-1===a?null:a},_signature:[{types:[n.TYPE_STRING]},{types:[n.TYPE_STRING]},{types:[n.TYPE_NUMBER],optional:!0}]},fromEntries:{_func:e=>{const t=e[0];return Object.fromEntries(t)},_signature:[{types:[n.TYPE_ARRAY_ARRAY]}]},hour:{_func:e=>{const t=i(e[0])%1;if(t<0)return null;const n=yt(24*t,14);return Math.floor(n%24)},_signature:[{types:[n.TYPE_NUMBER]}]},if:{_func:(t,i,n)=>{const s=t[0],r=t[1],a=t[2],o=n.visit(s,i);return e(o)?n.visit(r,i):n.visit(a,i)},_signature:[{types:[n.TYPE_ANY]},{types:[n.TYPE_ANY]},{types:[n.TYPE_ANY]}]},left:{_func:e=>{const n=e.length>1?i(e[1]):1;return n<0?null:e[0]instanceof Array?e[0].slice(0,n):t(e[0]).substr(0,n)},_signature:[{types:[n.TYPE_STRING,n.TYPE_ARRAY]}
1,{types:[n.TYPE_NUMBER],optional:!0}]},lower:{_func:e=>t(e[0]).toLowerCase(),_signature:[{types:[n.TYPE_STRING]}]},mid:{_func:e=>{const n=i(e[1]),s=i(e[2]);return n<0?null:e[0]instanceof Array?e[0].slice(n,n+s):t(e[0]).substr(n,s)},_signature:[{types:[n.TYPE_STRING,n.TYPE_ARRAY]},{types:[n.TYPE_NUMBER]},{types:[n.TYPE_NUMBER]}]},minute:{_func:e=>{const t=i(e[0])%1;if(t<0)return null;const n=Math.round(1440*t,10);return Math.floor(n%60)},_signature:[{types:[n.TYPE_NUMBER]}]},mod:{_func:e=>i(e[0])%i(e[1]),_signature:[{types:[n.TYPE_NUMBER]},{types:[n.TYPE_NUMBER]}]},month:{_func:e=>{const t=i(e[0]);return new Date(t*bt).getMonth()+1},_signature:[{types:[n.TYPE_NUMBER]}]},not:{_func:t=>!e(t[0]),_signature:[{types:[n.TYPE_ANY]}]},now:{_func:()=>Date.now()/bt,_signature:[]},null:{_func:()=>null,_signature:[]},or:{_func:t=>{let i=!!e(t[0]);return t.slice(1).forEach((t=>{i=i||!!e(t)})),i},_signature:[{types:[n.TYPE_ANY],variadic:!0}]},power:{_func:e=>i(e[0])**i(e[1]),_signature:[{types:[n.TYPE_NUMBER]},{types:[n.TYPE_NUMBER]}]},proper:{_func:e=>t(e[0]).split(" ").map((e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())).join(" "),_signature:[{types:[n.TYPE_STRING]}]},replace:{_func:e=>{const n=t(e[0]),s=i(e[1]),r=i(e[2]),a=t(e[3]);return s<0?null:n.substr(0,s)+a+n.substr(s+r)},_signature:[{types:[n.TYPE_STRING]},{types:[n.TYPE_NUMBER]},{types:[n.TYPE_NUMBER]},{types:[n.TYPE_STRING]}]},rept:{_func:e=>{const n=t(e[0]),s=i(e[1]);return s<0?null:n.repeat(s)},_signature:[{types:[n.TYPE_STRING]},{types:[n.TYPE_NUMBER]}]},right:{_func:e=>{const n=e.length>1?i(e[1]):1;if(n<0)return null;if(e[0]instanceof Array)return 0===n?[]:e[0].slice(-1*n);const s=t(e[0]),r=s.length-n;return s.substr(r,n)},_signature:[{types:[n.TYPE_STRING,n.TYPE_ARRAY]},{types:[n.TYPE_NUMBER],optional:!0}]},round:{_func:e=>yt(i(e[0]),i(e[1])),_signature:[{types:[n.TYPE_NUMBER]},{types:[n.TYPE_NUMBER]}]},search:{_func:e=>{const n=t(e[0]),s=t(e[1]),r=i(e[2]);if(null===n||null===s||0===s.length)return[];const a=n.replace(/([[.\\^$()+{])/g,"\\$1").replace(/~?\?/g,(e=>"~?"===e?"\\?":".")).replace(/~?\*/g,(e=>"~*"===e?"\\*":".*?")).replace(/~~/g,"~"),o=new RegExp(a),l=s.substring(r).match(o);return null===l?[]:[l.index+r,l[0]]},_signature:[{types:[n.TYPE_STRING]},{types:[n.TYPE_STRING]},{types:[n.TYPE_NUMBER],optional:!0}]},second:{_func:e=>{const t=i(e[0])%1;if(t<0)return null;const n=yt(86400*t,10);return Math.floor(n%60)},_signature:[{types:[n.TYPE_NUMBER]}]},split:{_func:e=>{const i=t(e[0]),n=t(e[1]);return i.split(n)},_signature:[{types:[n.TYPE_STRING]},{types:[n.TYPE_STRING]}]},sqrt:{_func:e=>{const t=Math.sqrt(i(e[0]));return Number.isNaN(t)?null:t},_signature:[{types:[n.TYPE_NUMBER]}]},stdev:{_func:e=>{const t=e[0]||[];if(t.length<=1)return null;const n=t.map((e=>i(e))),s=n.reduce(((e,t)=>e+t),0)/t.length,r=n.reduce(((e,t)=>e+t*t),0),a=Math.sqrt((r-t.length*s*s)/(t.length-1));return Number.isNaN(a)?null:a},_signature:[{types:[n.TYPE_ARRAY_NUMBER]}]},stdevp:{_func:e=>{const t=e[0]||[];if(0===t.length)return null;const n=t.map((e=>i(e))),s=n.reduce(((e,t)=>e+t),0)/t.length,r=n.reduce(((e,t)=>e+t*t),0)/t.length,a=Math.sqrt(r-s*s);return Number.isNaN(a)?null:a},_signature:[{types:[n.TYPE_ARRAY_NUMBER]}]},substitute:{_func:e=>{const n=t(e[0]),s=t(e[1]),r=t(e[2]);if(e.length<=3)return n.replaceAll(s,r);const a=i(e[3]);if(a<1)return n;let o=-1;for(let e=0;e<a;e+=1){o+=1;const e=n.slice(o).indexOf(s);if(-1===e)return n;o+=e}return n.slice(0,o)+n.slice(o).replace(s,r)},_signature:[{types:[n.TYPE_STRING]},{types:[n.TYPE_STRING]},{types:[n.TYPE_STRING]},{types:[n.TYPE_NUMBER],optional:!0}]},time:{_func:e=>{const t=(3600*i(e[0])+60*i(e[1])+i(e[2]))/86400;return t<0?null:t-Math.floor(t)},_signature:[{types:[n.TYPE_NUMBER]},{types:[n.TYPE_NUMBER]},{types:[n.TYPE_NUMBER]}]},today:{_func:()=>Math.floor(Date.now()/bt),_signature:[]},trim:{_func:e=>t(e[0]).split(" ").filter((e=>e)).join(" "),_signature:[{types:[n.TYPE_STRING]}]},true:{_func:()=>!0,_signature:[]},trunc:{_func:e=>{const t=i(e[0]),n=e.length>1?i(e[1]):0;return(t>=0?Math.floor:Math.ceil)(t*10**n)/10**n}
1,_signature:[{types:[n.TYPE_NUMBER]},{types:[n.TYPE_NUMBER],optional:!0}]},unique:{_func:t=>{const i=t[0].map((t=>e(t)));return t[0].filter(((t,n)=>i.indexOf(e(t))===n))},_signature:[{types:[n.TYPE_ARRAY]}]},upper:{_func:e=>t(e[0]).toUpperCase(),_signature:[{types:[n.TYPE_STRING]}]},value:{_func:e=>{const t=e[0]||{},i=e[1],n=t[i];if(void 0===n){s.push(`Failed to find: '${i}'`);const e=Object.keys(t).map((e=>`'${e}'`)).toString();return e.length&&s.push(`Available fields: ${e}`),null}return n},_signature:[{types:[n.TYPE_OBJECT,n.TYPE_ARRAY,n.TYPE_NULL]},{types:[n.TYPE_STRING,n.TYPE_NUMBER]}]},weekday:{_func:e=>{const t=i(e[0]),n=e.length>1?i(e[1]):1,s=new Date(t*bt).getDay();switch(n){case 1:return s+1;case 2:return(s+6)%7+1;case 3:return(s+6)%7;default:return null}},_signature:[{types:[n.TYPE_NUMBER]},{types:[n.TYPE_NUMBER],optional:!0}]},year:{_func:e=>{const t=i(e[0]);return new Date(t*bt).getFullYear()},_signature:[{types:[n.TYPE_NUMBER]}]},charCode:{_func:e=>{const t=i(e[0]);return Number.isInteger(t)?String.fromCharCode(t):null},_signature:[{types:[n.TYPE_NUMBER]}]},codePoint:{_func:e=>{const i=t(e[0]);return 0===i.length?null:i.codePointAt(0)},_signature:[{types:[n.TYPE_STRING]}]},encodeUrlComponent:{_func:e=>encodeURIComponent(e[0]),_signature:[{types:[n.TYPE_STRING]}]},encodeUrl:{_func:e=>encodeURI(e[0]),_signature:[{types:[n.TYPE_STRING]}]},decodeUrlComponent:{_func:e=>decodeURIComponent(e[0]),_signature:[{types:[n.TYPE_STRING]}]},decodeUrl:{_func:e=>decodeURI(e[0]),_signature:[{types:[n.TYPE_STRING]}]}}}(I,Mt,t,e)).forEach((([e,t])=>{this.functionTable[e]=t})),Object.entries(i).forEach((([e,t])=>{this.functionTable[e]=t}))}_validateArgs(e,t,i,n){if(0===i.length)return;let s;const r=i.filter((e=>!e.optional)).length;if(i[i.length-1].variadic){if(t.length<i.length)throw s=1===i.length?" argument":" arguments",new Error(`ArgumentError: ${e}() takes at least${i.length}${s} but received ${t.length}`)}else if(t.length<r||t.length>i.length)throw s=1===i.length?" argument":" arguments",new Error(`ArgumentError: ${e}() takes ${i.length}${s} but received ${t.length}`);if(!n)return;let a,o;const l=Math.min(i.length,t.length);for(let n=0;n<l;n+=1)a=i[n].types,u=t[n],d=void 0,a.includes(Et)&&null!==(d=u)&&!Array.isArray(d)&&"Object"!==d.constructor.name||a.includes(Tt)||(o=b(t[n]),t[n]=E(o,a,t[n],e,this.toNumber,Mt));var u,d}callFunction(e,t,i,n,s=!0){if(!Object.prototype.hasOwnProperty.call(this.functionTable,e))throw new Error(`Unknown function: ${e}()`);const r=this.functionTable[e];return this._validateArgs(e,t,r._signature,s),r._func.call(this,t,i,n)}}class wt{constructor(e,t,i){this.debug=e,this.toNumber=function(e,t=[]){return i=>{const n=I(i);if(null===n)return null;if(n instanceof Array)return t.push("Converted array to zero"),0;const s=typeof n;return"number"===s?n:"string"===s?e(n,t):"boolean"===s?n?1:0:(t.push("Converted object to zero"),0)}}(i||It,e),this.runtime=new Ot(e,this.toNumber,t)}compile(e,t=[]){let i;try{i=new vt(t).parse(e,this.debug)}catch(e){throw this.debug.push(e.toString()),e}return i}search(e,t,i={},n="en-US"){this.runtime.interpreter=new V(this.runtime,i,this.toNumber,Mt,this.debug,n);try{return this.runtime.interpreter.search(e,t)}catch(e){throw this.debug.push(e.message||e.toString()),e}}}class At{constructor(e={},t=null,i=[]){this.customFunctions={...e},this.stringToNumber=t,this.debug=i,this.formula=new wt(i,e,t)}search(e,t,i={},n="en-US"){const s=this.compile(e,Object.keys(i));return this.run(s,t,n,i)}run(e,t,i,n){return this.formula.search(e,t,n,i)}compile(e,t=[]){return this.debug.length=0,this.formula.compile(e,t)}}function Ct(e,t,i,n={},s=null,r=[],a="en-US"){return new At(n,s,r).search(i,e,t,a)}}},t={};function i(n){var s=t[n];if(void 0!==s)return s.exports;var r=t[n]={exports:{}};return e[n].call(r.exports,r,r.exports,i),r.exports}i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}
1),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{i.r(n),i.d(n,{Actions:()=>A,Constants:()=>t,FileAttachmentUtils:()=>N,FormCheckBox:()=>y,FormContainer:()=>h,FormField:()=>p,FormFieldBase:()=>f,FormFileInput:()=>b,FormFileInputWidget:()=>M,FormFileInputWidgetBase:()=>E,FormOptionFieldBase:()=>T,FormPanel:()=>g,FormTabs:()=>v,Formatters:()=>C,FunctionRuntime:()=>e.FunctionRuntime,HTTPAPILayer:()=>s,LanguageUtils:()=>c,Utils:()=>d,createFormInstance:()=>e.createFormInstance,customFunctions:()=>o});var e=i(5444);const t={NS:"cmp",FORM_CONTAINER_INITIALISED:"AF_FormContainerInitialised",PANEL_INSTANCE_ADDED:"AF_PanelInstanceAdded",PANEL_INSTANCE_REMOVED:"AF_PanelInstanceRemoved",FORM_LANGUAGE_INITIALIZED:"AF_LanguageInitialised",ELEMENT_FOCUS_CHANGED:"elementFocusChanged",ELEMENT_HELP_SHOWN:"elementHelpShown",ELEMENT_ERROR_SHOWN:"elementErrorShown",ELEMENT_VALUE_CHANGED:"elementValueChanged",FORM_CONTAINER_DATA_ATTRIBUTE:"adaptiveformcontainerPath",DATA_HOOK_ADD_INSTANCE:"data-cmp-hook-add-instance",DATA_HOOK_REMOVE_INSTANCE:"data-cmp-hook-remove-instance",DATA_ATTRIBUTE_VALID:"data-cmp-valid",DATA_ATTRIBUTE_ENABLED:"data-cmp-enabled",DATA_ATTRIBUTE_VISIBLE:"data-cmp-visible",DATA_ATTRIBUTE_REQUIRED:"data-cmp-required",DATA_ATTRIBUTE_READONLY:"data-cmp-readonly",DATA_ATTRIBUTE_ACTIVE:"data-cmp-active",ARIA_DISABLED:"aria-disabled",ARIA_HIDDEN:"aria-hidden",ARIA_INVALID:"aria-invalid",ARIA_CHECKED:"aria-checked",ARIA_SELECTED:"aria-selected",GUIDE_BRIDGE_INITIALIZE_START:"bridgeInitializeStart",HTML_ATTRS:{DISABLED:"disabled",CHECKED:"checked"},TABINDEX:"tabindex",ARIA_CURRENT:"aria-current",API_PATH_PREFIX:"/adobe/forms/af",FIELD_TYPE:e.FIELD_TYPE},s=class{static REQ_PARAMETER_DATA_REF="dataRef";static async getForm(e){const t=e.indexOf("/jcr:content/guideContainer");let i=e;-1!==t&&(i=e.substring(0,t));const n=await this.#e();if(n)return await this.#t(i,n);console.debug("Error in fetching form")}static async getFormDefinition(e,t){const i=new URLSearchParams(window.location.search),n=Object.fromEntries(i.entries());let s=null;if("afAcceptLang"in n)s=`${n.afAcceptLang}`;else{const e=window.location.pathname.split(".");e?.length>=3&&(s=`${e[e.length-2]}`)}return null===s&&null!=t&&(s=t),await this.getJson(`${e}.model.${null!==s?`${s}.`:""}json${this.REQ_PARAMETER_DATA_REF in n?`?${this.REQ_PARAMETER_DATA_REF}=${n[this.REQ_PARAMETER_DATA_REF]}`:""}`)}static async#t(e,t){const i=t.items.find((t=>t.path===e));if(i)return i;if(t.cursor){const i=await this.#e(t.cursor);return await this.#t(e,i)}console.debug("Form at "+e+" Not Found")}static async#e(e=""){return await this.getJson(`${t.API_PATH_PREFIX}/listforms?cursor=${e}`)}static async getPrefillData(e,i){return await this.getJson(t.API_PATH_PREFIX+"/data/"+e+"?"+Object.keys(i).map((e=>e+"="+i[e])).join("&"))}static async getJson(e){let t=`${d.getContextPath()}${e}`;return new Promise((e=>{let i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="json",i.onload=function(){let t=i.status;e(200===t?i.response:null)},i.send()}))}static async getCustomFunctionConfig(e){return await this.getJson(t.API_PATH_PREFIX+"/customfunctions/"+e)}};function r(e){try{const t=new URL(e,window.location.href);return"http:"===t.protocol||"https:"===t.protocol}catch(e){return!1}}function a(e){return window?.Granite?.HTTP&&"function"==typeof window.Granite.HTTP.externalize?window.Granite.HTTP.externalize(e):e}const o={toObject:function(e){if("string"==typeof e)try{return JSON.parse(e)}catch(e){return{}}return e},externalize:a,validateURL:r,navigateTo:(e,t)=>function(e,t){let i=null,n=window,s=null;"_newwindow"===t&&(i="_blank",s="width=1000,height=800"),i||(i=t||"_blank"),r(e)&&n.open(e,i,s)}(o.externalize(e),t),defaultErrorHandler:function(e,t,i){e&&e.validationErrors&&e.validationErrors?.forEach((function(e){e.details&&(e.fieldName?i.functions.markFieldAsInvalid(e.fieldName,e.details.join("\n"),{useQualifiedName:!0}):e.dataRef&&i.functions.markFieldAsInvalid(e.dataRef,e.details.join("\n"),{useDataRef:!0}))}))},defaultSubmitSuccessHandler:function(e){const t=e.event,i=t?.payload?.body,n=e.form;if(i)if(i.redirectUrl)window.location.href=encodeURI(i.redirectUrl);else if(i.thankYouMessage){let e=document.getElementById(`${n.$id}`),t=document.createElement("div");t.setAttribute("class","tyMessage"),t.setAttribute("tabindex","-1"),t.setAttribute("role","alertdialog"),t.innerHTML=i.thankYouMessage,e.replaceWith(t),t.focu
1s()}},defaultSubmitErrorHandler:function(e,t){window.alert(e)},fetchCaptchaToken:async function(e){return new Promise(((t,i)=>{const n=function(e){t(e)},s=function(e){i(e)};try{const r=e.form.$captcha;if("turnstile"===r.$captchaProvider){const e=document.getElementsByClassName("cmp-adaptiveform-turnstile__widget")[0],t={sitekey:r.$captchaSiteKey,callback:n,"error-callback":s};if(null!=turnstile){const n=turnstile.render(e,t);n?turnstile.execute(n):i({error:"Failed to render turnstile captcha"})}else i({error:"Turnstile captcha not loaded"})}else{const e=r?.$properties["fd:captcha"]?.config?.siteKey,n=r.$name.replaceAll("-","_");let s=r?.$properties["fd:path"];const a=s.indexOf("/jcr:content");let o="";a>0&&(s=s.substring(0,a),o=s.substring(s.lastIndexOf("/")+1).replaceAll("-","_"));let l=`submit_${o}_${n}`;grecaptcha.enterprise.ready((()=>{grecaptcha.enterprise.execute(e,{action:l}).then((e=>t(e))).catch((e=>i(e)))}))}}catch(e){i(e)}}))},dateToDaysSinceEpoch:function(e){let t;if("string"==typeof e)t=new Date(e);else{if("number"==typeof e)return Math.floor(e);if(!(e instanceof Date))throw new Error("Invalid date input");t=e}if(isNaN(t.getTime()))throw new Error("Invalid date input");return Math.floor(t.getTime()/864e5)},downloadDoR:function(e,t){const i=t.form.$lang,n=new URLSearchParams({locale:i}).toString();let s=a("/adobe/forms/af/dor/"+t.form.$id+"?"+n);const r=new FormData;var o=JSON.stringify(t.functions.exportData());r.append("data",o),t.form.$id;var l=new XMLHttpRequest;l.open("POST",s,!0),l.responseType="arraybuffer",l.onreadystatechange=function(){if(4===l.readyState)if(200===l.status){const t=new Blob([l.response],{type:"application/pdf"}),i=URL.createObjectURL(t),n=document.createElement("a");n.href=i,n.download=e||"Downloaded_DoR.pdf",document.body.appendChild(n),n.click(),URL.revokeObjectURL(i),document.body.removeChild(n)}else console.error("Error while generating pdf")},l.send(r)},exportFormData:function(e,t,i){null==e&&(e=!0);const n=i.functions.exportData();if(!n)return;if(null==t)return e&&"object"==typeof n?JSON.stringify(n):n;const s=t.replace(/\[/g,".").replace(/\]/g,"").split(".").filter(Boolean);let r=n;for(const e of s){if(null==r)return;r=r[e]}return r&&"object"==typeof r&&e?JSON.stringify(r):r}},l=class{static async registerCustomFunctions(t){const i=await s.getCustomFunctionConfig(t);if(console.debug("Fetched custom functions: "+JSON.stringify(i)),i&&i.customFunction){const t=i.customFunction.reduce(((e,t)=>(window[t.id]&&(e[t.id]=window[t.id]),e)),{});e.FunctionRuntime.registerFunctions(t)}}static async registerCustomFunctionsV2(t){let i,n=[];const r=t.properties["fd:customFunctionsUrl"];i=r?await s.getJson(r):await s.getCustomFunctionConfig(t.id),console.debug("Fetched custom functions: "+JSON.stringify(i)),i&&i.clientSideParsingEnabled?n=this.extractFunctionNames(t):i&&i.customFunction&&(n=i.customFunction);const a=n.reduce(((e,t)=>(Object.prototype.hasOwnProperty.call(window,t.id)&&"function"==typeof window[t.id]&&(e[t.id]=window[t.id]),e)),{});console.debug("Registering custom functions:",a),e.FunctionRuntime.registerFunctions(a)}static extractFunctionNames=e=>{const t=new Set,i=e=>{const i=/(\w+)\s*\(/g;let n;for(;null!==(n=i.exec(e));)t.add(n[1])};e.events&&Object.values(e.events).forEach((e=>{e.forEach((e=>{i(e)}))})),e.rules&&Object.values(e.rules).forEach((e=>{i(e)}));const n=e=>{e&&Object.values(e).forEach((e=>{e.events&&Object.values(e.events).forEach((e=>{e.forEach((e=>{i(e)}))})),e.rules&&Object.values(e.rules).forEach((e=>{i(e)})),e[":items"]&&n(e[":items"])}))};return e[":items"]&&n(e[":items"]),console.debug("Extracted function names from form JSON:",t),Array.from(t).map((e=>({id:e})))};static async registerCustomFunctionsByUrl(t){try{if(null!=t&&t.trim().length>0){const i=await import(t),n=Object.keys(i),s=[];for(const e of n){const t=i[e];"function"==typeof t&&(s[e]=t)}e.FunctionRuntime.registerFunctions(s)}}catch(e){window.console&&console.error("error in loading custom functions from url "+t+" with message "+e.message)}}};class u{static#i="";static#n={};static#s=[];static readData(e,i){const n=e.dataset;let s={};const r=["is"];if(i){const e=i.charAt(0).toUpperCase()+i.substring(1);r.push("hook"+e)}for(let e in n)if(Object.prototype.hasOwnProperty.call(n,e)){let i=n[e];0===e.indexOf(t.NS)&&(e=e.slice(t.NS.length),e=e.charAt(0).toLowerCase()+e.substring(1),-1===r.indexOf(e)&&(s[e]=i))}return s}static registerMutationObserver(e,t,i,n){let s=new(window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver)((function(n){n.forEac
1h((function(n){var s=[].slice.call(n.addedNodes);s.length>0&&s.forEach((function(n){if(n.querySelectorAll){var s=[].slice.call(n.querySelectorAll(i));u.#r(s,t,e)}}))}))}));const r='[data-cmp-path="'+e.getPath()+'"]',a=document.querySelector(r);s.observe(a,{subtree:!0,childList:!0,characterData:!0})}static#r(e,t,i){for(let n=0;n<e.length;n++){const s=e[n].id,r=e[n].getAttribute("data-cmp-adaptiveformcontainer-path"),a=i.getFormElement().getAttribute("data-cmp-path");if(null==i.getField(s)&&r==a){let s=t({element:e[n],formContainer:i});i.addField(s)}}}static createFieldsForAddedElement(e,t){Object.values(u.#s).forEach((function(i){let n=u.#n[i];const s=e.querySelectorAll(n.fieldSelector);u.#r(s,n.fieldCreator,t)}))}static setupField(e,t,i){t in u.#n||u.#s.push(t),u.#n[t]={fieldCreator:e,fieldSelector:t,fieldClass:i}}static initializeAllFields(e){console.debug("Initializing field views ",e),Object.values(u.#s).forEach((function(t){const{fieldSelector:i,fieldCreator:n,fieldClass:s}=u.#n[t];console.debug("Initializing all fields of field selector ",i);let r=document.querySelectorAll(i);u.#r(r,n,e),u.registerMutationObserver(e,n,i,s)}))}static#a(e,t){e&&e.getAllFields()&&delete e.getAllFields()[t]}static#o(e,t){let i=e.children;if(i)for(let e=0;e<i.length;e++)u.#o(i[e]);e.getInstanceManager&&e.getInstanceManager()&&u.#a(t,e.getInstanceManager().id),u.#a(t,e.id)}static removeFieldReferences(e,t){let i=e.children;if(i)for(let e=0;e<i.length;e++)u.#o(i[e]);u.#a(t,e.id)}static updateId(e,t,i){let n=e.querySelectorAll("#"+t)[0];n&&(n.id=i)}static setContextPath(e){null!=u.#i&&0!==u.#i.length||(u.#i=e)}static getContextPath(){return u.#i}static registerClickHandler(e,t,i){const n="["+t+"]";e.querySelectorAll(n).forEach((e=>e.addEventListener("click",i)))}static async setupFormContainer(i,n,r){e.FunctionRuntime.registerFunctions(o);let a=document.querySelectorAll(n);for(let e=0;e<a.length;e++){const n=u.readData(a[e],r),o=n.customFunctionsModuleUrl,d=n.path,c=n.pageLang;if("contextPath"in n&&u.setContextPath(n.contextPath),null==d)console.error(`data-${t.NS}-${r}-path attribute is not present in the HTML element. Form cannot be initialized`);else{const n=await s.getFormDefinition(d,c);console.debug("fetched model json",n),await l.registerCustomFunctionsV2(n),await l.registerCustomFunctionsByUrl(o);const r=new URLSearchParams(window.location.search),h=Object.fromEntries(r.entries());let p={};!0===n?.properties?.["fd:formDataEnabled"]&&(p=await s.getJson(n.properties["fd:dataUrl"]+"?"+Object.keys(h).map((e=>e+"="+h[e])).join("&")),p=p||{},p=u.stripIfWrapped(p));const f=await i({_formJson:n,_prefillData:p,_path:d,_element:a[e]});u.initializeAllFields(f);const m=new CustomEvent(t.FORM_CONTAINER_INITIALISED,{detail:f});document.dispatchEvent(m)}}}static stripIfWrapped(e){if(e&&e.hasOwnProperty("data")){const t=e.data;if(t&&t.hasOwnProperty("afData")){const e=t.afData;if(e&&e.hasOwnProperty("afBoundData"))return e.afBoundData}}return e}static isUserAgent(e){if(navigator.userAgent)return new RegExp("^((?!chrome|android).)*"+e,"i").test(navigator.userAgent)}}const d=u,c=class{static#l={};static async loadLang(i,n,r=!1){const a=await s.getJson(n);if(a&&(console.debug("fetched language data",a),this.#l[i]=a,(0,e.setCustomDefaultConstraintTypeMessages)(a)),r){await this.#u(i);const e=new CustomEvent(t.FORM_LANGUAGE_INITIALIZED,{detail:i});document.dispatchEvent(e)}}static async#u(e){let t=guideBridge.getConfigsForKey(guideBridge.ConfigKeys.LOCALE_CONFIG)||[];t=t.map((e=>e.fn)).filter((e=>"function"==typeof e));for(const i of t)await i(e)}static getTranslatedString(e,t,i){let n="";return e in this.#l&&(n=this.#l[e][t],i&&(n=n.replace(/\${(\d+)}/g,(function(e,t){return void 0!==i[t]?i[t]:e})))),n}},h=class{constructor(t){let i=t._prefillData.data&&0===Object.keys(t._prefillData.data).length?null:t._prefillData.data;this._model=(0,e.createFormInstance)({...t._formJson,data:i}),this._path=t._path,this._fields={},this._deferredParents={},this._element=t._element,this.#d()}#d(){this._element&&this._element.addEventListener("keydown",(e=>{if("Enter"!==e.key)return;const t=e.target;"INPUT"===t.tagName&&["text","password","email","url","search","tel","number"].includes(t.type)&&e.preventDefault()}))}addInstanceManager(e){this._fields[e.id]=e}getField(e){return this._fields.hasOwnProperty(e)?this._fields[e]:null}getModel(e){return e?this._model.getElement(e):this._model}getLang(){return this._model.lang||"en"}getParentFormElementId(e){const t=e.fieldType&&e.repeatable?e.parent.parent:e.parent;return"form"===t.fieldType?"$form":t.id}addField(e){if(e.getFormContainerPath()===this._path){let t=e.getId();this._fields[t]=e;let i=this.getModel(t);e.setModel(i),e.syncMarkupWithModel();const n=this.getParentFormElementId(i);if("$form"!=n){let t=this._fields[n];t?e.setParent(t):(this._deferredParents[n]||(this._deferredParents[n]=[]),this._deferredParents[n].push(e))}else e.setParent(this);if(this._deferredParents[t]){let i=this._deferredParents[t];for(let t=0;t<i.length;t++)i[t].setParent(e);delete this._deferredParents[t]}e.subscribe()}}setFocus(e){if(e){let t=this._fields[e];
1t&&t.setFocus?t.setFocus():console.log("View on which focus is to be set, not initialized.")}}getFormId(){return this._model._jsonModel.id}getFormTitle(){return this._model._jsonModel.title}getPath(){return this._path}getFormElement(){return this._element}getAllFields(){return this._fields}updateActiveChild(e){this.setFocus(e?._activeChild?.id||e?.id)}#c(e){const t=e[0].fieldName;this.setFocus(t)}subscribe(){this._model.subscribe((e=>{let t=e.target.getState();e.payload.changes.forEach((e=>{const i=`update${(n=e.propertyName)[0].toUpperCase()+n.slice(1)}`;var n;"function"==typeof this[i]?this[i](e.currentValue,t):console.warn(`changes to ${e.propertyName} are not supported at form. Please raise an issue`)}))})),this._model.subscribe((e=>{e.payload.length>0&&this.#c(e.payload)}),"validationComplete")}},p=class{constructor(e){this.formContainer=e.formContainer,this.element=e.element,this.options=d.readData(this.element,this.getClass()),this.setId(this.element.id),this.active=!1}setId(e){this.id=e}setParent(e){this.parentView=e,this.parentView.addChild&&this.parentView.addChild(this),this.getInstanceManager()&&!this.getInstanceManager().getRepeatableParentView()&&this.getInstanceManager().setRepeatableParentView(e)}setInstanceManager(e){this.instanceManager=e}setActive(){this.isActive()||(this.element.setAttribute(t.DATA_ATTRIBUTE_ACTIVE,!0),this.parentView&&this.parentView?._model?.activeChild!==this._model&&(this.parentView._model.activeChild=this._model),this.active=!0)}setInactive(){this.isActive()&&this.element.setAttribute(t.DATA_ATTRIBUTE_ACTIVE,!1)}isActive(){return"true"===this.element.getAttribute(t.DATA_ATTRIBUTE_ACTIVE)}getFormContainerPath(){return this.options.adaptiveformcontainerPath}getId(){return this.id}setModel(e){if(void 0!==this._model&&null!==this._model)throw"Re-initializing model is not permitted";this._model=e}setModelValue(e){this._model.dispatch(new FormView.Actions.UIChange({value:e}))}syncMarkupWithModel(){throw"method not implemented"}toggle(e,t,i){this.toggleAttribute(this.element,e,t,i)}toggleAttribute(e,t,i,n){e&&(!1===t?e.setAttribute(i,n):e.removeAttribute(i))}getLayoutProperties(){let e={};const t=this.getModel().getState();return t&&t.properties&&t.properties["afs:layout"]&&(e=t.properties["afs:layout"]),e}getModel(){return this._model}subscribe(){throw"the field does not subscribe to the model"}initializeHelpContent(e){throw"method not implemented"}getInstanceManager(){return this.instanceManager}},f=class extends p{constructor(e){super(e),this.widget=this.getWidget(),this.description=this.getDescription(),this.label=this.getLabel(),this.errorDiv=this.getErrorDiv(),this.qm=this.getQuestionMarkDiv(),this.tooltip=this.getTooltipDiv(),this.updateEmptyStatus()}ELEMENT_FOCUS_CHANGED=t.ELEMENT_FOCUS_CHANGED;ELEMENT_HELP_SHOWN=t.ELEMENT_HELP_SHOWN;ELEMENT_ERROR_SHOWN=t.ELEMENT_ERROR_SHOWN;ELEMENT_VALUE_CHANGED=t.ELEMENT_VALUE_CHANGED;getWidget(){throw"method not implemented"}getDescription(){throw"method not implemented"}getLabel(){throw"method not implemented"}getErrorDiv(){throw"method not implemented"}getTooltipDiv(){throw"method not implemented"}getQuestionMarkDiv(){throw"method not implemented"}getClass(){return this.constructor.IS}setModel(e){super.setModel(e);const t=this._model.getState();this.applyState(t),this.#h()}getWidgetId(){return this.getId()+"-widget"}#p(){let e="function"==typeof this.getWidget?this.getWidget():null;e=("function"==typeof this.getWidgets?this.getWidgets():null)||e,e&&e.setAttribute("id",this.getWidgetId())}#f(){let e="function"==typeof this.getLabel?this.getLabel():null;e&&e.setAttribute("for",this.getWidgetId())}#m(){let e="function"==typeof this.getErrorDiv?this.getErrorDiv():null;e&&e.setAttribute("id",`${this.getId()}__errormessage`)}#g(){let e="function"==typeof this.getTooltipDiv?this.getTooltipDiv():null;e&&e.setAttribute("id",`${this.getId()}__shortdescription`)}#_(){let e="function"==typeof this.getDescription?this.getDescription():null;e&&e.setAttribute("id",`${this.getId()}__longdescription`)}#v(){let e="",t="function"==typeof this.getWidget?this.getWidget():null;function i(t,i){e?e+=` ${i}__${t}`:e=`${i}__${t}`}if(t=("function"==typeof this.getWidgets?this.getWidgets():null)||t,t){if(this.getDescription()){const e=this.getDescription();""!==e.innerHTML.trim()&&0!==e.children.length&&i("longdescription",this.getId())}this.getTooltipDiv()&&i("shortdescription",this.getId()),this.getErrorDiv()&&this.getErrorDiv().innerHTML&&i("errormessage",this.getId()),t.setAttribute("aria-describedby",e)}}#y(){let e="function"==typeof this.getWidget?this.getWidget():null;e=("function"==typeof this.getWidgets?this.getWidgets():null)||e;const t=this.getModel?.();if(e&&t?.screenReaderText){const i=window.DOMPurify?window.DOMPurify.sanitize(t.screenReaderText,{ALLOWED_TAGS:[]}):t.screenReaderText;e.setAttribute("aria-label",i)}}syncMarkupWithModel(){this.#f(),this.#p(),this.#g(),this.#_(),this.#v(),this.#m(),this.#y()}setFocus(e){const t=this.parentView?.getModel()?.fieldType;"form"!==t&&this.parentView?.setFocus&&this.parentView.setFocus(this.getId()),this.isActive()||(this.widget=this.getWidget(),this.widget instanceof NodeList?this.widget[0].focus():"adaptiveFormFileInput"===this.getClass()?this.getAttachButtonLabel().focus():this.widget.focus())}
1applyState(e){e.value&&this.updateValue(e.value),this.updateVisible(e.visible,e),this.updateReadOnly(e.readOnly),this.updateEnabled(e.enabled,e),this.initializeHelpContent(e),this.updateLabel(e.label),this.updateRequired(e.required,e),this.updateDescription(e.description)}initializeHelpContent(e){this.#b(!1),this.getDescription()&&this.#E(e)}#h(){this.#T(),this.#M()}#M(){const e=this.qm;e&&e.addEventListener("click",(()=>{this.#I(this.ELEMENT_HELP_SHOWN)}))}#T(){const e=this.getWidget();if(e)if(e.length&&e.length>1)for(let t of e)t.onfocus=()=>{this.#I(this.ELEMENT_FOCUS_CHANGED)};else e.onfocus=()=>{this.#I(this.ELEMENT_FOCUS_CHANGED)}}#I(e,t){const i=this.formContainer.getFormId(),n=this.formContainer.getFormTitle(),s=this.#O(),r={formId:i,formTitle:n,fieldName:this._model.name,fieldId:this._model.id,panelName:s,fieldQualifiedName:this._model.qualifiedName,...void 0!==t?.prevValue?{prevText:t?.prevValue}:{},...void 0!==t?.currentValue?{newText:t?.currentValue}:{},..."object"==typeof t&&null!==t?t:{}},a=this.formContainer.getPath();window.guideBridge.trigger(e,r,a)}#O(){return this.parentView?.getModel()?.name}setWidgetValueToDisplayValue(){this._model.displayValueExpression&&this._model.displayValue&&(this.widget.value=this._model.displayValue)}setWidgetValueToModelValue(){this._model.displayValueExpression&&this._model.displayValue&&(this.widget.value=this._model.value)}#w(e){this.tooltip&&this.toggleAttribute(this.getTooltipDiv(),e,t.DATA_ATTRIBUTE_VISIBLE,!1)}#b(e){this.getDescription()&&this.toggleAttribute(this.getDescription(),e,t.DATA_ATTRIBUTE_VISIBLE,!1)}#A(){return!!this.getLayoutProperties().tooltipVisible}updateVisible(e,i){this.toggle(e,t.ARIA_HIDDEN,!0),this.element.setAttribute(t.DATA_ATTRIBUTE_VISIBLE,e),null!=this.parentView&&"panel"===this.parentView.getModel().fieldType&&this.parentView.updateChildVisibility(e,i)}updateEnabled(e,i){this.widget&&(this.element.setAttribute(t.DATA_ATTRIBUTE_ENABLED,e),!1===e?this.widget.setAttribute("disabled","disabled"):this.widget.removeAttribute("disabled"))}updateReadOnly(e){this.widget&&(this.element.setAttribute(t.DATA_ATTRIBUTE_READONLY,e),!0===e?this.widget.setAttribute("readonly","readonly"):this.widget.removeAttribute("readonly"))}updateRequired(e,i){this.widget&&(this.element.toggleAttribute("required",e),this.element.setAttribute(t.DATA_ATTRIBUTE_REQUIRED,e),!0===e?this.widget.setAttribute("required","required"):this.widget.removeAttribute("required"))}updateValid(e,t){}updateValidity(e,i){const n=e.valid;this.errorDiv&&(this.element.setAttribute(t.DATA_ATTRIBUTE_VALID,n),this.widget.setAttribute(t.ARIA_INVALID,!n),this.updateValidationMessage(i.validationMessage,i))}updateErrorMessage(e,t){}updateValidationMessage(e,t){if(this.errorDiv&&this.errorDiv.innerHTML!==t.validationMessage){if(this.errorDiv.innerHTML=t.validationMessage,!1===t.validity.valid){const e=Object.keys(t.validity).find((e=>"valid"!==e&&!0===t.validity[e]));this.#I(this.ELEMENT_ERROR_SHOWN,{validationMessage:t.validationMessage,validationType:e}),t.validationMessage||(this.errorDiv.innerHTML=c.getTranslatedString(this.formContainer.getModel().lang,"defaultError"))}this.#v()}}updateValue(e){let t=void 0===e?null:e;this.widget&&(this.widget.value=t,this.updateEmptyStatus())}updateEmptyStatus(){if(!this.getWidget())return;let e="";const t=["radio","checkbox"];e=this.widget instanceof NodeList?Array.from(this.widget).map((e=>t.includes(e.type)?e.checked:e.value)).find((e=>e)):t.includes(this.widget.type)?this.widget.checked:this.widget.value;const i=Array.from(this.element.classList).filter((e=>!e.includes("--")))[0],n=`${i}--filled`,s=`${i}--empty`;this.element.classList.add(e?n:s),this.element.classList.remove(e?s:n)}updateLabel(e){this.label&&(e.hasOwnProperty("value")&&(this.label.innerHTML=e.value),e.hasOwnProperty("visible")&&(this.toggleAttribute(this.label,e.visible,t.ARIA_HIDDEN,!0),this.label.setAttribute(t.DATA_ATTRIBUTE_VISIBLE,e.visible)))}updateActiveChild(e){this.formContainer.setFocus(e?._activeChild?.id||e?.id)}updateDescription(e){if(void 0!==e){const t=window.DOMPurify?window.DOMPurify.sanitize(e,{ALLOWED_TAGS:[]}).trim():e;let i=this.getDescription();if(i){if(i.innerText.trim()===t)return;let e=i.querySelectorAll("p");e||(e=document.createElement("p"),i.innerHTML="",i.appendChild(pElement)),1===e.length&&(e[0].innerHTML=t)}else this.#C(t)}}#C(e){const t=Array.from(this.element.classList).filter((e=>!e.includes("--")))[0],i=this.element.querySelector(`.${t}__label-container`);if(!i)return void console.error("label container not found");{const e=document.createElement("button");e.className=`${t}__questionmark`,e.title="Help text",i.appendChild(e)}const n=document.createElement("div");n.className=`${t}__longdescription`,n.id=`${this.getId()}__longdescription`,n.setAttribute("aria-live","polite"),n.setAttribute("data-cmp-visible",!1);const s=document.createElement("p");s.textContent=e,n.appendChild(s);var r=this.getErrorDiv();r?(this.element.insertBefore(n,r),this.#E()):console.log("error div not found")}#E(e){const i=this.getQuestionMarkDiv(),n=this.getDescription(),s=this.#A(),r=this;i&&n&&i.addEventListener("click",(e=>{e.preventDefault(),"false"===n.getAttribute(t.DATA_ATTRIBUTE_VISIBLE)?(r.#b(!0),s&&r.#w(!1)):(r.#b(!1),s&&r.#w(!0))}))}subscribe(){this._model.subscribe((e=>{let t=e.target.getState();
1e.payload.changes.forEach((e=>{const i=`update${(n=e.propertyName)[0].toUpperCase()+n.slice(1)}`;var n;"value"===e.propertyName&&this.#I(this.ELEMENT_VALUE_CHANGED,e),"function"==typeof this[i]?this[i](e.currentValue,t):console.warn(`changes to ${e.propertyName} are not supported. Please raise an issue`)}))}))}},m=class{constructor(e){this.formContainer=e.formContainer,this._model=e.model,this.parentElement=e.parentElement,this.id=this._model.id,this.children=[],this.subscribe()}#N(e,t,i){let n=null;return null==e?(n=this.#j(t,i),d.createFieldsForAddedElement(n,this.formContainer)):null==t?this.#S(e.getModel()):e.getId()!=t.id&&(n=this.#j(t,i),d.createFieldsForAddedElement(n,this.formContainer),this.#S(e.getModel())),n}#R(){const e=this.children,t=this._model.items,i=e.length,n=t.length,s=i>n?i:n;let r=null;for(let a=0;a<s;a++){const s=a<i?e[a]:null,o=a<n?t[a]:null;r=this.#N(s,o,r)}}#x(e,t,i){if("array"!=t.type&&d.updateId(e,t.id,i),"panel"==t.fieldType&&t.items)for(let n=0;n<t.items.length;n++)this.#x(e,t.items[n],i+"_"+n)}updateCloneIds(e,t,i){if("array"!=i.type&&d.updateId(e,t,i.id),"panel"==i.fieldType&&i.items)for(let n=0;n<i.items.length;n++)this.updateCloneIds(e,t+"_"+n,i.items[n])}updateTemplate(e){const t=e.element.parentElement;this._templateHTML=t.cloneNode(!0);let i=e.getModel();i||(i=this.formContainer.getModel(e.getId())),this.#x(this._templateHTML,i,"temp_0")}#D(e,t,i){const n=new CustomEvent(t);i&&(n.payload=i),this.getModel().dispatch(n)}#j(e,t){if(this._templateHTML)return this.handleAddition(e,t);console.error("Panel needs to have templateHTML to support repeatability.")}#S(e){const i=e.index;let n=this.children[i];-1==i&&(n=this.formContainer.getField(e.id)),d.removeFieldReferences(n,this.formContainer),this.handleRemoval(n),this.children.splice(i,1);const s=new CustomEvent(t.PANEL_INSTANCE_REMOVED,{detail:n});this.formContainer.getFormElement().dispatchEvent(s)}addInstance(e,t){this.#D(e,"addInstance",t)}removeInstance(e,t){this.#D(e,"removeInstance",t)}#P(e,t,i,n){const s=this.formContainer.getModel(e),r=new CustomEvent(t);r.payload=s.index+i,s.parent.dispatch(r),n.stopPropagation()}#F(e){if("function"==typeof this?.repeatableParentView?.getRepeatableRootElement){const i=this.repeatableParentView.getRepeatableRootElement(e);d.registerClickHandler(i,t.DATA_HOOK_ADD_INSTANCE,(e=>{const i=e.currentTarget.getAttribute(t.DATA_HOOK_ADD_INSTANCE);i?this.#P(i,"addInstance",1,e):this.addInstance(e)})),d.registerClickHandler(i,t.DATA_HOOK_REMOVE_INSTANCE,(e=>{const i=e.currentTarget.getAttribute(t.DATA_HOOK_REMOVE_INSTANCE);i?this.#P(i,"removeInstance",0,e):this.removeInstance(e)}))}}handleAddition(e,t){const i=e.index;let n=this._templateHTML.cloneNode(!0),s=this.formContainer.getModel(e.id);if(this.updateCloneIds(n,"temp_0",s),this.repeatableParentView&&"function"==typeof this.repeatableParentView.addRepeatableMarkup)n=this.repeatableParentView.addRepeatableMarkup(this,s,n);else if(0==this.children.length)this.parentElement.append(n);else if(0==s.index){let e=this.children[0].element.parentElement;this.parentElement.insertBefore(n,e)}else this.getElementAt(i-1).after(n);return n}getElementAt(e){let t=this._model.items.find((t=>t.index===e)),i=this.parentElement.querySelector(`#${t.id}`);if(i)for(;i.parentElement!==this.parentElement;)i=i.parentElement;return i}handleRemoval(e){this.repeatableParentView&&"function"==typeof this.repeatableParentView.handleChildRemoval&&this.repeatableParentView.handleChildRemoval(e),e.element.parentElement.remove()}addChild(e){this._templateHTML||this.updateTemplate(e),this.children.splice(e.getModel().index,0,e),this.#F(e);const i=new CustomEvent(t.PANEL_INSTANCE_ADDED,{detail:e});this.repeatableParentView&&"function"==typeof this.repeatableParentView.handleChildAddition&&this.repeatableParentView.handleChildAddition(e),this.formContainer.getFormElement().dispatchEvent(i)}updateItems(e,t,i){e?this.#S(e):t&&this.#j(t)}subscribe(){this.getModel().subscribe((e=>{let t=e.target.getState();
1e.payload.changes.forEach((e=>{"items"===e.propertyName?this.updateItems(e.prevValue,e.currentValue,t):console.warn(`changes to ${e.propertyName} are not supported. Please raise an issue`)}))}))}getId(){return this.id}getModel(){return this._model}setRepeatableParentView(e){this.repeatableParentView=e,this.#R(),this.children.length>0&&this.#F(this.children[0])}getRepeatableParentView(){return this.repeatableParentView}},g=class extends f{constructor(e){super(e),this.children=[]}instantiateInstanceManager(){return new m({formContainer:this.formContainer,model:this._model.parent,parentElement:this.element.parentElement.parentElement})}setModel(e){if(super.setModel(e),e.repeatable){let t=this.formContainer.getField(e.parent.id);null==t&&(t=this.instantiateInstanceManager(),this.formContainer.addInstanceManager(t)),this.setInstanceManager(t),t.addChild(this)}}setFocus(e){const t=this.parentView?.getModel()?.fieldType;"form"!==t&&this.parentView?.setFocus&&this.parentView.setFocus(this.getId())}getActiveRepeatableNonRepeatableTabId(e,t){for(const i of e){if(i.id===t)return t;if("panel"===i.fieldType&&"array"===i.type){const e=this.formContainer.getModel().getElement(i.id).getState(),n=this.getActiveRepeatableNonRepeatableTabId(e.items,t);if(n)return n}}return null}focusToFirstVisibleField(e){const t=this.formContainer.getModel(),i=this.getActiveRepeatableNonRepeatableTabId(this.getModel().getState().items,e),n=t.getElement(i);if(!n)return;const s=e=>{if(!e.visible||!e.enabled)return null;if(e.fieldType&&"panel"!==e.fieldType)return e;for(const t of e.items){const e=s(t);if(e)return e}return null},r=s(n);r&&setTimeout((()=>{this.formContainer.setFocus(r.id)}),0)}addChild(e){this.children.push(e)}getCountOfAllChildrenInModel(){var e=0;for(let i in this.getModel()._children){var t=this.getModel()._children[i];null!=t.minOccur&&null!=t.maxOccur&&null!=t._children?e+=0==t._children.length?1:t._children.length:e+=1}return e}getChild(e){for(let t in this.children)if(this.children[t].id===e)return this.children[t]}handleChildAddition(e){}handleChildRemoval(e){}applyState(e){this.updateVisible(e.visible),this.updateEnabled(e.enabled),this.initializeHelpContent(e),this.updateLabel(e.label)}updateEnabled(e){this.toggle(e,t.ARIA_DISABLED,!0),this.element.setAttribute(t.DATA_ATTRIBUTE_ENABLED,e)}updateValid(e,t){}updateValidity(e,i){const n=e.valid;this.toggle(n,t.ARIA_INVALID,!0),this.element.setAttribute(t.DATA_ATTRIBUTE_VALID,n)}getChildViewByIndex(e){}#L(e){var t={closestRepeatableFieldInstanceManagerIds:[]};for(let n=e-1;n>=0;n--){var i=this.getChildViewByIndex(n);if(null==i.getInstanceManager()){t.closestNonRepeatableFieldId=i.getId();break}if(t.closestRepeatableFieldInstanceManagerIds.push(i.getInstanceManager().getId()),0!=i.getInstanceManager().getModel().minOccur)break}return t}cacheClosestFieldsInView(){for(let n=0;n<this.children.length;n++){var e=this.getChildViewByIndex(n);if(null!=e.getInstanceManager()&&0==e.getInstanceManager().getModel().minOccur){var t=e.getInstanceManager().getId();if(null==this._templateHTML[t]&&(this._templateHTML[t]={}),null==this._templateHTML[t].closestNonRepeatableFieldId&&null==this._templateHTML[t].closestRepeatableFieldInstanceManagerIds){var i=this.#L(n);this._templateHTML[t].closestNonRepeatableFieldId=i.closestNonRepeatableFieldId,this._templateHTML[t].closestRepeatableFieldInstanceManagerIds=i.closestRepeatableFieldInstanceManagerIds}}}}getIndexToInsert(e,t){var i=-1;for(let s=this.children.length-1;s>=0;s--){var n=this.getChildViewByIndex(s);if(e===n.getId()){i=s;break}if(null!=n.getInstanceManager()&&t.includes(n.getInstanceManager().getId())){i=s;break}}return i+1}getRepeatableRootElement(e){return e.element.parentElement}updateChildVisibility(e,t){}handleHiddenChildrenVisibility(){for(let e=0;e<this.children.length;e++)"false"===this.children[e].element.getAttribute(t.DATA_ATTRIBUTE_VISIBLE)&&this.updateChildVisibility(!1,this.children[e].getModel().getState())}findFirstVisibleChild(e){for(let i=0;i<e.length;i++)if("false"!=e[i].getAttribute(t.DATA_ATTRIBUTE_VISIBLE))return e[i]}updateVisibilityOfNavigationElement(e,i){e&&(!1===i?e.setAttribute(t.ARIA_HIDDEN,!0):e.removeAttribute(t.ARIA_HIDDEN),e.setAttribute(t.DATA_ATTRIBUTE_VISIBLE,i))}updateEmptyStatus(){}};class _ extends g{static keyCodes={END:35,HOME:36,ARROW_LEFT:37,ARROW_UP:38,ARROW_RIGHT:39,ARROW_DOWN:40};#k;#$;#U;#V;#B="__tab";#Y="__tabpanel";_templateHTML={};constructor(e,t,i,n){super(e),this.#U=t,this.#$=i,this.#V=n;const{element:s}=e;this.#K(s),this.#k=this.getActiveTabId(this.#H()),this.#q(),this.#G()}#q(){var e=this.#z(),i=this.#H();if(e)for(var n=0;n<e.length;n++)i[n]&&(i[n].id===this.#k?(e[n].classList.add(this.#V.active.tabpanel),e[n].removeAttribute(t.ARIA_HIDDEN),i[n].classList.add(this.#V.active.tab),i[n].setAttribute(t.ARIA_SELECTED,!0),i[n].setAttribute(t.TABINDEX,"0"),i[n].setAttribute(t.ARIA_CURRENT,"true"),i[n].setAttribute("state","selected")):(e[n].classList.remove(this.#V.active.tabpanel),e[n].setAttribute(t.ARIA_HIDDEN,!0),i[n].classList.remove(this.#V.active.tab),i[n].setAttribute(t.ARIA_SELECTED,!1),i[n].setAttribute(t.TABINDEX,"-1"),i[n].setAttribute(t.ARIA_CURRENT,"false"),i[n].removeAttribute("state")))}#G(){var e=this.#H();if(e)for(var t=0;t<e.length;t++){var i=this;!function(t){e[t].addEventListener("click",(function(n){n?.target?.id===e[t].id&&i.navigateAndFocusTab(e[t].id)}))}(t),e[t].addEventListener("keydown",(function(e){i.#W(e)}))}}#K(e){this._elements={},this._elements.self=e;for(var t=this._elements.self.querySelectorAll("[data-"+this.#U+"-hook-"+this.#$+"]"),i=0;i<t.length;i++){var n=t[i];if(n.closest("[data-cmp-is="+this.#$+"]")===this._elements.self){var s=this.#$.toLowerCase(),r=s.charAt(0).toUpperCase()+s.slice(1),a=n.dataset[this.#U+"Hook"+r];if(this._elements[a]){if(!Array.isArray(this._elements[a])){var o=this._elements[a];this._elements[a]=[o]}this._elements[a].push(n)}else this._elements[a]=[n]}}}#W(e){var t=this.#Q(this.#k),i=this.#H(),n=i.length-1;switch(e.keyCode){case _.keyCodes.ARROW_LEFT:case _.keyCodes.ARROW_UP:e.preventDefault(),t>0&&this.navigateAndFocusTab(i[t-1].id);break;case _.keyCodes.ARROW_RIGHT:case _.keyCodes.ARROW_DOWN:e.preventDefault(),t<n&&this.navigateAndFocusTab(i[t+1].id);break;case _.keyCodes.HOME:e.preventDefault(),this.navigateAndFocusTab(i[0].id);break;case _.keyCodes.END:e.preventDefault(),this.navigateAndFocusTab(i[n].id);break;default:return}}#Q(e){var t=this.#H();if(t)for(var i=0;i<t.length;i++)if(t[i].id===e)return i;return-1}navigateAndFocusTab(e){if(this.setActive(),this.#k!==e){this.navigate(e),this.focusWithoutScroll(this.#J(e));const t=this.getActiveTabId(this.#H()).replace(this.#B,"");this.focusToFirstVisibleField(t)}}#J(e){var t=this.#H();if(t)for(var i=0;i<t.length;i++)if(t[i].id===e)return t[i]}focusWithoutScroll(e){if(e){var t=window.scrollX||window.pageXOffset,i=window.scrollY||window.pageYOffset;e.focus(),window.scrollTo(t,i)}}navigate(e){this.#k=e,this.addSteppedClass(e),this.#q()}addSteppedClass(e){var t=this.#H(),i=this.#z();const n=this.getActiveTabId(t),s=this.#J(n);if(s.classList.contains(this.#V.active.tab)){s.classList.add(this.#V.stepped.tab);const e=Array.from(i).find((e=>
1e.getAttribute("aria-labelledby")===s.id));e&&e.classList.add(this.#V.stepped.tabpanel)}}getActiveTabId(e){if(e){for(var t=e[0].id,i=0;i<e.length;i++)if(e[i].classList.contains(this.#V.active.tab)){t=e[i].id;break}return t}}#Z(){var e=this.#H(),t=this.#z();if(t)for(var i=0;i<t.length;i++){var n=t[i].querySelectorAll("[data-cmp-is]")[0].id;e[i].id=n+this.#B,e[i].setAttribute("aria-controls",n+this.#Y)}}#X(){var e=this.#z();if(e)for(var t=0;t<e.length;t++){var i=e[t].querySelectorAll("[data-cmp-is]")[0].id;e[t].id=i+this.#Y,e[t].setAttribute("aria-labelledby",i+this.#B)}}syncMarkupWithModel(){super.syncMarkupWithModel(),this.#Z(),this.#X()}handleChildAddition(e){if(null!=e.getInstanceManager()&&null!=this._templateHTML[e.getInstanceManager().getId()]){var t=this._templateHTML[e.getInstanceManager().getId()].navigationTab.cloneNode(!0);t.id=e.id+this.#B,t.setAttribute("aria-controls",e.id+this.#Y);var i=e.getModel().index,n=e.getInstanceManager().getId();if(0==i){var s=this._templateHTML[n].closestNonRepeatableFieldId,r=this._templateHTML[n].closestRepeatableFieldInstanceManagerIds,a=this.getIndexToInsert(s,r);if(0==a){var o=this.#ee();o.insertBefore(t,o.firstChild)}else this.#H()[a-1].after(t)}else{var l=e.getInstanceManager().children[i-1].element.id+this.#B;this.#J(l).after(t)}this.#K(this._elements.self);var u=this.#te(e.id+this.#Y);u.setAttribute("aria-labelledby",e.id+this.#B);const d=Array.from(t.classList).find((e=>e.includes("--stepped")));d&&t.classList.remove(d);const c=Array.from(u.classList).find((e=>e.includes("--stepped")));c&&u.classList.remove(c),this.#ie(t.id),this.#q(),null!=e.getInstanceManager().getModel().minOccur&&e.getInstanceManager().children.length>e.getInstanceManager().getModel().minOccur?this.navigateAndFocusTab(t.id):this.navigateAndFocusTab(this.findFirstVisibleChild(this.#H()).id)}}handleChildRemoval(e){var t=e.element.id+this.#Y,i=e.element.id+this.#B,n=this.#te(t),s=this.#J(i);const r=this.#H(),a=Array.from(r).findIndex((e=>e.id===i));let o=null;if(0===a)o=r[1];else for(let e=a-1;e>=0;e--){o=r[e];break}s.remove(),n.remove(),this.children.splice(this.children.indexOf(e),1),this.#K(this._elements.self),this.#q(),o&&this.navigateAndFocusTab(o.id)}addChild(e){super.addChild(e),this.#ne(e),this.getCountOfAllChildrenInModel()===this.children.length&&(this.cacheClosestFieldsInView(),this.handleHiddenChildrenVisibility())}#ne(e){if(null!=e.getInstanceManager()&&(null==this._templateHTML||null==this._templateHTML[e.getInstanceManager().getId()])){var t=e.element.id+this.#B,i=e.element.id+this.#Y,n=e.getInstanceManager().getId(),s=this.#J(t),r=this.#te(i);this._templateHTML[n]={},this._templateHTML[n].navigationTab=s,this._templateHTML[n].targetTabPanel=r}}#te(e){var t=this.#z();if(t)for(var i=0;i<t.length;i++)if(t[i].id===e)return t[i]}#ie(e){var t=this,i=this.#H(),n=this.#Q(e);i[n].addEventListener("click",(function(i){i?.target?.id===e&&t.navigateAndFocusTab(e)})),i[n].addEventListener("keydown",(function(e){t.#W(e)}))}#ee(){return this.element.querySelector(this.#V.olTabList)}#z(){return this._elements.tabpanel}#H(){return this._elements.tab}addRepeatableMarkup(e,t,i){let n=this._templateHTML[e.getId()].targetTabPanel.cloneNode(!1);return n.id=t.id+this.#Y,this.#se(e,t.index).beforeViewElement.after(n),n.append(i),n}#se(e,t){var i={},n=e.getId();if(0==t){var s=this._templateHTML[n].closestNonRepeatableFieldId,r=this._templateHTML[n].closestRepeatableFieldInstanceManagerIds,a=this.getIndexToInsert(s,r);i.beforeViewElement=a>0?this.#z()[a-1]:this.#ee()}else{let n=this.#re(e,t-1);i.beforeViewElement=n}return i}#re(e,t){let i=e._model.items.find((e=>e.index===t))?.id;return this.element.querySelector(`#${i}${this.#Y}`)}getChildViewByIndex(e){var t=this.#z(),i=t[e].id.substring(0,t[e].id.lastIndexOf("__"));return this.getChild(i)}updateChildVisibility(e,t){this.updateVisibilityOfNavigationElement(this.#J(t.id+this.#B),e);var i=this.getActiveTabId(this._elements.tab);if(!e&&i===t.id+this.#B){let e=this.findFirstVisibleChild(this.#H());e&&this.navigateAndFocusTab(e.id)}}}const v=_,y=class extends f{constructor(e){super(e)}updateValue(e){e===this._model._jsonModel.enum[0]?(this.widget.checked=!0,this.widget.setAttribute(FormView.Constants.HTML_ATTRS.CHECKED,FormView.Constants.HTML_ATTRS.CHECKED),this.widget.setAttribute(FormView.Constants.ARIA_CHECKED,!0)):(this.widget.checked=!1,this.widget.removeAttribute(FormView.Constants.HTML_ATTRS.CHECKED),this.widget.setAttribute(FormView.Constants.ARIA_CHECKED,!1)),this.widget.value=e,super.updateEmptyStatus()}setModel(e){super.setModel(e),this._onValue=this._model._jsonModel.enum[0],this._offValue=this._model._jsonModel.enum[1],this.widget.addEventListener("change",(e=>{const t=this.widget.checked?this._onValue:this._offValue;this._model.dispatch(new FormView.Actions.UIChange({value:t}))}))}},b=class extends f{constructor(e){super(e)}setModel(e){super.setModel(e),null==this.widgetObject&&(this.widgetObject=ne
1w FileInputWidget(this.widgetFields))}updateValue(e){null==this.widgetObject&&(this.widgetObject=new FileInputWidget(this.widgetFields)),this.widgetObject.setValue(e),super.updateEmptyStatus()}syncWidget(){let e=this.getWidget?this.getWidget():null;e&&(e.id=this.getId()+"__widget",this.getAttachButtonLabel().setAttribute("for",this.getId()+"__widget"))}syncLabel(){let e="function"==typeof this.getLabel?this.getLabel():null;e&&e.setAttribute("for",this.getId())}syncMarkupWithModel(){super.syncMarkupWithModel(),this.syncWidget(),this.syncLabel()}},E=class{fileItemSelector=".cmp-adaptiveform-fileinput__fileitem";widget=null;fileArr=[];fileList=null;lang="en";model=null;isFileUpdate=!1;options=null;regexMimeTypeList=[];values=[];invalidFeature={SIZE:1,NAME:2,MIMETYPE:3};extensionToMimeTypeMap={bat:"application/x-msdownload",com:"application/x-msdownload",dll:"application/x-msdownload",exe:"application/x-msdownload",msi:"application/x-msdownload",msg:"application/vnd.ms-outlook",dwg:"image/vnd.dwg",jxr:"image/vnd.ms-photo",psd:"image/vnd.adobe.photoshop",ico:"image/vnd.microsoft.icon",cab:"application/vnd.ms-cab-compressed",deb:"application/vnd.debian.binary-package",sqlite:"application/vnd.sqlite3",inf2:"image/vnd.cns.inf2",djv:"image/vnd.djvu",djvu:"image/vnd.djvu",dxf:"image/vnd.dxf",fbs:"image/vnd.fastbidsheet",fpx:"image/vnd.fpx",fst:"image/vnd.fst",mmr:"image/vnd.fujixerox.edmics-mmr",rlc:"image/vnd.fujixerox.edmics-rlc",pgb:"image/vnd.globalgraphics.pgb",mix:"image/vnd.mix",mdi:"image/vnd.ms-modi",npx:"image/vnd.net-fpx",radiance:"image/vnd.radiance","sealed.png":"image/vnd.sealed.png","softseal.gif":"image/vnd.sealedmedia.softseal.gif","softseal.jpg":"image/vnd.sealedmedia.softseal.jpg",svf:"image/vnd.svf"};initialFileValueFileNameMap;constructor(e){this.widget=e.widget,this.model=e.model(),this.fileList=e.fileListDiv,this.lang=this.model.lang,this.options=Object.assign({},{contextPath:""},this.model._jsonModel),this.attachEventHandlers(e?.widget,e?.dragArea),this.regexMimeTypeList=this.options.accept.map((function(e,t){try{return new RegExp(e.trim())}catch(e){window.console&&console.log(e)}}))}attachEventHandlers(e,t){e.addEventListener("change",(e=>{this.handleChange(e?.target?.files)}))}static isValid(e){return/^[^\\/:\*\;\$\%\?"<>\|]+$/.test(e)&&!/^\./.test(e)&&!/^(nul|prn|con|lpt[0-9]|com[0-9])(\.|$)/i.test(e)}getIndexOfText(e,t){let i=-1,n=this,s=!1;return this.values.find((function(r,a){let o=r,l="object"==typeof n.initialFileValueFileNameMap&&void 0!==typeof n.initialFileValueFileNameMap[r]?n._initialFileValueFileNameMap[r]:null;if(o.match(/\//g)&&o.match(/\//g).length>1&&(o=r.substring(r.lastIndexOf("/")+1)),o===e||l===e){if(i=a,s=-1!==n.values.indexOf(r,i+1),t&&s){let e=t.parentNode.parentNode;i=Array.prototype.indexOf.call(e.children,t.parentElement)}return r}})),i}static displaySVG(e){const t=e,i=document.createElement("img");i.src=t;const n=window.open("","_blank","scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no");n?.document?.body.appendChild(i)}static previewFileUsingObjectUrl(e){if(e){if(!window.navigator||!window.navigator.msSaveOrOpenBlob){let t=window.URL.createObjectURL(e);return"image/svg+xml"===e.type?this.displaySVG(t):window.open(t,"","scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no"),t}window.navigator.msSaveOrOpenBlob(e,e.name)}}static previewFile(e){let t=arguments[1].fileUrl,i=t.lastIndexOf("/");i>=0&&-1===t.indexOf("?")&&(t=t.substr(0,i)+"/"+encodeURIComponent(t.substr(i+1))),window.open(t,"","scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no")}handleFilePreview(e){let t=e.target,i=t.textContent,n=this.getIndexOfText(i,t),s=null;if(-1!==n)if(void 0!==t.dataset.key&&(s=t.dataset.key),s&&"[object Blob]"!==s)0!==s.lastIndexOf(this.options.contextPath,0)&&(s=this.options.contextPath+s),FileInputWidget.previewFile.apply(this,[null,{fileUrl:s}]);else{let e=this.fileArr[n]?.data,i=FileInputWidget.previewFileUsingObjectUrl(e);i&&(t.dataset.objectUrl=i)}}handleClick(e){let t=e.target,i=t.previousSibling.textContent,n=this.getIndexOfText(i,t),s=t.previousSibling.dataset.key,r=t.previousSibling.dataset.objectUrl;if(-1!==n){this.values.splice(n,1),this.fileArr.splice(n,1),this.model.value=this.fileArr;let e=Array.from(this.widget.files).findIndex((function(e){return e.name===i}));this.deleteFilesFromInputDom([e]),null!=s&&delete t.previousSibling.dataset.key,r&&window.URL.revokeObjectURL(r)}t.parentElement.remove(),this.widget.focus()}fileItem(e,t,i){let n=this,s=document.createElement("li");s.setAttribute("class","cmp-adaptiveform-fileinput__fileitem");let r=document.createElement("span");r.setAttribute("tabindex","0"),r.setAttribute("class","cmp-adaptiveform-fileinput__filename"),r.setAttribute("aria-label",e),r.textContent=e,r.addEventListener("keypress",(function(e){13!==e.keyCode&&32!==e.charCode||e.target.click()})),r.addEventListener("click",(function(e){n.handleFilePreview(e)})),s.appendChild(r),null!=i&&(r.dataset.key=i);let a=document.createElement("span");return a.setAttribute("tabindex","0"),a.setAttribute("class","cmp-adaptiveform-fileinput__filedelete"),a.setAttribute("aria-label",FormView.LanguageUtils.getTranslatedString(this.lang,"FileCloseAccessText")+e),a.setAttribute("role","button"),a.textContent="x",a.addEventListener("keypress",(function(e){13!==e.keyCode&&32!==e.charCode||e.target.click()})),a.addEventListener("click",(function(e){n.handleClick(e)})),s.appendChild(a),s}isMultiSelect(){return"file[]"===this.options.type||"string[]"===this.options.type}showFileList(e,t,i){if(!this.isMultiSelect()||null==e)for(;this.fileList.lastElementChild;)this.fileList.removeChild(this.fileList.lastElementChild);
1null!=e&&this.fileList.append(this.fileItem(e,t,i))}showInvalidMessage(e,t){let i=this,n=null!==navigator.userAgent.match(/iPad/i),s=null!==navigator.userAgent.match(/iPhone/i);n||s?setTimeout((function(){i.invalidMessage(i,e,t)}),0):this.invalidMessage(e,t)}invalidMessage(e,t){const i=this.options.constraintMessages||{},n={[this.invalidFeature.SIZE]:i.maxFileSize||FormView.LanguageUtils.getTranslatedString(this.lang,"FileSizeGreater",[e,this.options.maxFileSize]),[this.invalidFeature.NAME]:i.invalidFileName||FormView.LanguageUtils.getTranslatedString(this.lang,"FileNameInvalid",[e]),[this.invalidFeature.MIMETYPE]:i.invalidMimeType||FormView.LanguageUtils.getTranslatedString(this.lang,"FileMimeTypeInvalid",[e])};alert(n[t])}getFileListItem(e){try{let t=new DataTransfer||new ClipboardEvent("").clipboardData;return e.forEach((function(e){t.items.add(e)})),t.files}catch(e){throw console.error(e),e}}updateFilesInDom(e){this.isFileUpdate=!0,this.widget.files=this.getFileListItem(e),this.isFileUpdate=!1}deleteFilesFromInputDom(e){let t=[];Array.from(this.widget.files).forEach((function(i,n){e.includes(n)||t.push(i)}));try{this.updateFilesInDom(t)}catch(e){console.error("Deleting files is not supported in your browser")}}setValue(e){let t=!1;if(null!=e&&(e=Array.isArray(e)?e:[e]),null!=this.fileArr&&null!=e&&(t=JSON.stringify(FormView.FileAttachmentUtils.extractFileInfo(this.fileArr))===JSON.stringify(e)),!t){let t={};for(this.fileList.querySelectorAll(".cmp-adaptiveform-fileinput__filename").forEach((function(e){let i=e.dataset.key;if(void 0!==i){let e=i.substring(i.lastIndexOf("/")+1);t[e]=i}}));this.fileList.lastElementChild;)this.fileList.removeChild(this.fileList.lastElementChild);if(null!=e){let i=this;this.values=e.map((function(e,n){let s=!!window.File&&e.data instanceof window.File,r="string"==typeof e?e:e.name,a="string"==typeof e?e:s?"":e.data;return t[r]&&(a=t[r]),i.showFileList(r,null,a),r})),this.fileArr=[...e]}}}handleChange(e){if(!this.isFileUpdate){let t="",i="",n="",s="",r=this,a=e,o=!1,l=!1,u=!1;if(void 0!==a){let e=[];Array.from(a).forEach((function(a,d){let c=!1,h=!1,p=!1;if(t=a.name.split("\\").pop(),a.size/1024/1024>parseFloat(this.options.maxFileSize))o=c=!0,i=t+","+i;else if(FileInputWidget.isValid(t)){let e=!1,i=t.split(".").pop(),n=a.type?a.type:r.extensionToMimeTypeMap[i];null!=n&&n.trim().length>0&&(e=this.regexMimeTypeList.some((function(e){return e.test(n)}))),e||(u=p=!0,s=t+","+s)}else l=h=!0,n=t+","+n;c||h||p?e.push(d):this.isMultiSelect()?(this.values.push(t),this.fileArr.push(a)):(this.values=[t],this.fileArr=[a])}),this),e.length>0&&null!==this.widget&&this.deleteFilesFromInputDom(e)}this.model.value=this.fileArr,o?this.showInvalidMessage(i.substring(0,i.lastIndexOf(",")),this.invalidFeature.SIZE):l?this.showInvalidMessage(n.substring(0,n.lastIndexOf(",")),this.invalidFeature.NAME):u&&this.showInvalidMessage(s.substring(0,s.lastIndexOf(",")),this.invalidFeature.MIMETYPE)}this.widget.value=null}},T=class extends f{constructor(e){super(e)}updateEnum(e){}updateEnumNames(e){}applyState(e){super.applyState(e),e?.enum&&this.updateEnum(e.enum),e?.enumNames&&this.updateEnumNames(e.enumNames)}updateEnumForRadioButtonAndCheckbox(e,t){let i=this.getWidget().length;0===i?e.forEach((e=>{this.getWidgets().appendChild(t.call(this,e,e))})):i===e.length?this.widget.forEach(((t,i)=>{t.value=e[i]})):i<e.length?(this.widget.forEach(((t,i)=>{t.value=e[i]})),e.forEach(((e,n)=>{n>i-1&&this.getWidgets().appendChild(t.call(this,e,e))}))):this.widget.forEach(((t,i)=>{if(i<e.length)t.value=e[i];else{let e=t.parentElement.parentElement;this.getWidgets().removeChild(e)}}))}updateEnumNamesForRadioButtonAndCheckbox(e,t){let i=this.getWidget().length;0===i?e.forEach((e=>{this.getWidgets().appendChild(t.call(this,e,e))})):i>
1e.length?[...this.getOptions()].forEach(((t,i)=>{let n=t.querySelector("span"),s=t.querySelector("input"),r=i<e.length?e[i]:s.value;n.innerHTML=window.DOMPurify?window.DOMPurify.sanitize(r):r})):[...this.getOptions()].forEach(((t,i)=>{let n=t.querySelector("span");n&&(n.innerHTML=window.DOMPurify?window.DOMPurify.sanitize(e[i]):e[i])}))}},M=class extends E{attachEventHandlers(e,t,i){super.attachEventHandlers(e,i),t?.addEventListener("dragover",(e=>{e.preventDefault(),t.classList.add("cmp-adaptiveform-fileinput__dragarea--active")})),t?.addEventListener("dragleave",(e=>{t.classList.remove("cmp-adaptiveform-fileinput__dragarea--active")})),t?.addEventListener("drop",(e=>{e.preventDefault(),t.classList.remove("cmp-adaptiveform-fileinput__dragarea--active"),this.handleChange(e?.dataTransfer?.files)})),t?.addEventListener("paste",(e=>{e.preventDefault(),this.handleChange(e?.clipboardData?.files)}))}handleClick(e){let t=e.target,i=t.parentElement.previousSibling.textContent,n=this.getIndexOfText(i,t),s=t.parentElement.previousSibling.dataset.key,r=t.parentElement.previousSibling.dataset.objectUrl;if(-1!==n){this.values.splice(n,1),this.fileArr.splice(n,1),this.model.value=this.fileArr;let e=Array.from(this.widget.files).findIndex((function(e){return e.name===i}));this.deleteFilesFromInputDom([e]),null!=s&&delete t.parentElement.previousSibling.dataset.key,r&&window.URL.revokeObjectURL(r)}t.parentElement.parentElement.remove(),this.widget.focus()}formatBytes(e,t=0){if(!+e)return"0 Bytes";const i=t<0?0:t,n=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,n)).toFixed(i))} ${["bytes","kb","mb","gb","tb","pb"][n]}`}setValue(e){let t=!1;if(null!=e&&(e=Array.isArray(e)?e:[e]),null!=this.fileArr&&null!=e&&(t=JSON.stringify(FormView.FileAttachmentUtils.extractFileInfo(this.fileArr))===JSON.stringify(e)),!t){let t={};for(this.fileList.querySelectorAll(".cmp-adaptiveform-fileinput__filename").forEach((function(e){let i=e.dataset.key;if(void 0!==i){let e=i.substring(i.lastIndexOf("/")+1);t[e]=i}}));this.fileList.lastElementChild;)this.fileList.removeChild(this.fileList.lastElementChild);if(null!=e){let i=this;this.values=e.map((function(e,n){let s=!!window.File&&e.data instanceof window.File,r="string"==typeof e?e:e.name,a="string"==typeof e?e:s?"":e.data,o=e.size,l=a;return t[r]&&(l=t[r]),i.showFileList(r,o,null,l),r})),this.fileArr=[...e]}}}fileItem(e,t,i,n){let s=this,r=document.createElement("li");r.setAttribute("class","cmp-adaptiveform-fileinput__fileitem");let a=document.createElement("span"),o=document.createElement("span");o.setAttribute("class","cmp-adaptiveform-fileinput__filesize"),o.textContent=this.formatBytes(t),a.setAttribute("tabindex","0"),a.setAttribute("class","cmp-adaptiveform-fileinput__filename"),a.setAttribute("aria-label",e),a.textContent=e,a.addEventListener("keypress",(function(e){13!==e.keyCode&&32!==e.charCode||e.target.click()})),a.addEventListener("click",(function(e){s.handleFilePreview(e)})),r.appendChild(a),null!=n&&(a.dataset.key=n);let l=document.createElement("span"),u=document.createElement("span");return l.setAttribute("class","cmp-adaptiveform-fileinput__fileendcontainer"),u.setAttribute("tabindex","0"),u.setAttribute("class","cmp-adaptiveform-fileinput__filedelete"),u.setAttribute("aria-label",FormView.LanguageUtils.getTranslatedString(this.lang,"FileCloseAccessText")+e),u.setAttribute("role","button"),u.textContent="x",u.addEventListener("keypress",(function(e){13!==e.keyCode&&32!==e.charCode||e.target.click()})),u.addEventListener("click",(function(e){s.handleClick(e)})),l.appendChild(o),l.appendChild(u),r.appendChild(l),r}showFileList(e,t,i,n){if(!this.isMultiSelect()||null==e)for(;this.fileList.lastElementChild;)this.fileList.removeChild(this.fileList.lastElementChild);null!=e&&this.fileList.append(this.fileItem(e,t,i,n))}},I=class{#ae;#oe;#le;#ue;constructor(e){this.errors=!1,this.data=e.data,this.#ae=[],this.#oe=[],this.#le=[],this.#ue=this.#le}addMessage(e,t,i){this.errors=!0,this.#ae.push(t),this.#le.push(i),this.#oe.push(e)}getNextMessage(){if(0===this.#oe.length)return null;let e=this.#le.pop();return{code:this.#oe.pop(),somExpression:e,qualifiedName:e,message:this.#ae.pop()}}},O=class{data;contentType;attachments;constructor(e){this.data=e.data,this.contentType="application/json",this.attachments=e.attachments}getData(){return this.data}getContentType(){return this.contentType}getAttachments(){return this.attachments}
1toHTMLFormData(){let e=new FormData;this.contentType&&e.append("contentType",this.contentType),e.append("data",this.data);for(let t=0;t<this.attachments.length;t++){let i=this.attachments[t];if("undefined"!=typeof File&&i.data instanceof File)e.append("fileAttachments",i.data,i.name);else{let t=new Blob([JSON.stringify({data:i.data,name:i.name,contentType:i.contentType})],{type:"application/json"});e.append("fileAttachments",t)}e.append("fileAttachmentBindRefs",i.dataRef)}return e}toJsObject(){return{data:this.data,contentType:this.contentType,attachments:this.attachments}}};var w=i(6608);window.guideBridge=new class{#de={};#ce=[];#he="";#pe={};ConfigKeys={LOCALE_CONFIG:"localeConfig",RENDER_CONFIG:"renderConfig",SUBMIT_CONFIG:"submitConfig"};constructor(){let e=document.createEvent("CustomEvent");if(e.initCustomEvent(t.GUIDE_BRIDGE_INITIALIZE_START,!0,!0,{guideBridge:this}),window.dispatchEvent(e),window!==window.parent)try{window.parent.document.getElementById(window.name),window.parent.dispatchEvent(e)}catch(e){console.debug("Cross-origin access to parent window blocked")}let i=this;document.addEventListener(t.FORM_CONTAINER_INITIALISED,(function(e){let t=e.detail;i.#de[t.getPath()]=t,i.#fe(t.getPath())}))}#fe(e){this.#ce.forEach((function(t){t.formContainerPath===e&&t.handler.call(t.context),t.formContainerPath||t.handler.call(t.context)}))}getFormDataString(t){let i=this.getFormModel();if(!i)throw new Error("formModel is not defined");(0,e.readAttachments)(i).then((e=>{let n=Object.keys(e).flatMap((t=>e[t])),s=new O({data:JSON.stringify(i.exportData()),attachments:n}),r=new I({data:s});t&&"function"==typeof t.success&&t.success(r)}))}getFormDataObject(e){this.getFormDataString({success:function(t){e&&"function"==typeof e.success&&e.success(t)}})}getFormModel(){if(this.#he)return this.#de[this.#he]?this.#de[this.#he].getModel():null;{const e=this.#me();return this.#he=e,this.#de[e]?this.#de[e].getModel():null}}#me(){let e=this.#he;if(!e)for(let t in this.#de)this.#de.hasOwnProperty(t)&&(e=t);return e}validate(){let e=this.getFormModel();if(!e)throw new Error("formModel is not defined");let t=e.validate();return!(t&&t.length>0)}connect(e,t,i){if(t=t||this,i&&(this.#he=i),!e)throw new Error("handler arg is null");this.isConnected()?e.call(t):this.#ce.push({handler:e,context:t,formContainerPath:i})}isConnected(){return!!this.getFormModel()}disableForm(){let e=this.getFormModel();if(!e)throw new Error("formModel is not defined");e.enabled=!1}reset(){let e=this.getFormModel();if(!e)throw new Error("formModel is not defined");e.dispatch({type:"reset"})}hideSubmitButtons(){if(!this.isConnected())throw new Error("GuideBridge is not connected");this.#ge("submit")}hideResetButtons(){if(!this.isConnected())throw new Error("GuideBridge is not connected");this.#ge("reset")}#ge(e){this.getFormModel().visit((t=>{t.properties["fd:buttonType"]===e&&(t.visible=!1,t.subscribe((e=>
1{e.target.getState(),e.payload.changes.forEach((e=>{"visible"===e.propertyName&&e.currentValue&&(t.visible=!1)}))})))}))}hideSaveButtons(){}hideSummaryPanel(){}trigger(e,t,i){let n;n=i?this.#de[i]:this.#de[this.#me()],n&&n.getFormElement()&&n.getFormElement().dispatchEvent(new CustomEvent(e,{detail:t}))}on(e,t){if(!this.isConnected())throw new Error("GuideBridge is not connected");{const i=this.#de[this.#he];i&&i.getFormElement()&&i.getFormElement().addEventListener(e,t)}}registerConfig(e,t){this.#pe[e]||(this.#pe[e]=[]);const i="function"==typeof t?{fn:t,formContainerPath:this.#he}:{...t,formContainerPath:this.#he};return this.#pe[e].push(i),this.#pe[e]}resolveNode(e){return this.getFormModel().resolveQualifiedName(e)}getConfigsForKey(e){return this.#pe[e]||[]}};const A={Click:e.Click,Change:e.Change,Submit:e.Submit,Blur:e.Blur,AddItem:e.AddItem,RemoveItem:e.RemoveItem,UIChange:e.UIChange,Save:e.Save,CustomEvent:e.CustomEvent},C={formatDate:w.formatDate,parseDate:w.parseDate},N={FileObject:e.FileObject,extractFileInfo:e.extractFileInfo,readAttachments:e.readAttachments}})(),window.FormView=n})(); 2/******************************************************************************* 3 * Copyright 2024 Adobe 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 ******************************************************************************/ 17 18if (typeof window.HamburgerMenu === 'undefined') { 19 window.HamburgerMenu = class HamburgerMenu { 20 static activeItemId = ''; 21 22 static bemBlock = 'cmp-adaptiveform-container__hamburger-menu'; 23 static nestingSupport = 10; 24 25 static selectors = { 26 active: `.${HamburgerMenu.bemBlock}-item--active`, 27 hamburgerMenuMainContainer: `.${HamburgerMenu.bemBlock}-container`, 28 hamburgerMenuTopContainer: { 29 self: `.${HamburgerMenu.bemBlock}-top`, 30 hamburgerMenuIconContainer: `.${HamburgerMenu.bemBlock}-icon-container`, 31 hamburgerMenuIcon: `.${HamburgerMenu.bemBlock}-icon`, 32 }, 33 hamburgerMenuWidget: { 34 hamburgerMenu: `.${HamburgerMenu.bemBlock}-dropdown`, 35 hamburgerSubMenu: `.${HamburgerMenu.bemBlock}-submenu`, 36 hamburgerMenuNavLink: `.${HamburgerMenu.bemBlock}-link`, 37 hamburgerMenuCloseNavButton: `.${HamburgerMenu.bemBlock}-button--close`, 38 hamburgerMenuOpenNavButton: `.${HamburgerMenu.bemBlock}-button--open`, 39 }, 40 hamburgerMenuMiddleContainer: `.${HamburgerMenu.bemBlock}-middle`, 41 hamburgerMenuBottomContainer: { 42 self: `.${HamburgerMenu.bemBlock}-bottom`, 43 hamburgerMenuActiveItemTitle: `.${HamburgerMenu.bemBlock}-active-item-title`, 44 hamburgerMenuNextNavButton: `.${HamburgerMenu.bemBlock}-button--next`, 45 hamburgerMenuPreviousNavButton: `.${HamburgerMenu.bemBlock}-button--prev`, 46 hamburgerMenuNavButtonsContainer: `.${HamburgerMenu.bemBlock}-navigation-container`, 47 }, 48 }; 49 50 static cssClasses = { 51 active: `${HamburgerMenu.bemBlock}-item--active`, 52 activeParent: `${HamburgerMenu.bemBlock}-item--activeparent`, 53 hamburgerMenuWidget: { 54 hamburgerMenu: `${HamburgerMenu.bemBlock}-dropdown`, 55 hamburgerSubMenu: `${HamburgerMenu.bemBlock}-submenu`, 56 hamburgerMenuNavLink: `${HamburgerMenu.bemBlock}-link`, 57 hamburgerMenuCloseNavButton: `${HamburgerMenu.bemBlock}-button--close`, 58 hamburgerMenuOpenNavButton: `${HamburgerMenu.bemBlock}-button--open`, 59 }, 60 } 61 62 constructor(formContainer) { 63 this.formContainer = formContainer; 64 formContainer._model.subscribe((action) => { 65 const { payload } = action; 66 const { changes, field } = payload; 67 const { items } = field; 68 if (changes && changes.length > 0) {
69 changes.forEach((change) => { 70 switch (change.propertyName) { 71 case "activeChild": 72 this.#handleActiveItem(field); 73 break; 74 case "items": 75 this.#handleItemsChange(change, items); 76 break; 77 case "visible": 78 this.#updateAttribute(field.id, 'data-panel-visible', field.visible); 79 break; 80 case "enabled": 81 this.#updateAttribute(field.id, 'data-panel-enabled', field.enabled); 82 break; 83 } 84 }); 85 } 86 }, "fieldChanged"); 87 } 88 89 #updateAttribute(id, attributeName, value) { 90 const element = document.querySelector(`[data-panel-id='${id}']`); 91 if (attributeName === 'data-panel-enabled' && element) { 92 if (value === 'false') { 93 element.setAttribute('disabled', 'true'); 94 } else { 95 element.removeAttribute('disabled'); 96 } 97 } 98 if (element) { 99 element.setAttribute(attributeName, value); 100 } 101 } 102 103 #createListItem(item) { 104 const li = document.createElement('li'); 105 const link = document.createElement('a'); 106 const textSpan = document.createElement('span'); 107 link.href = "#"; 108 textSpan.textContent = item?.label?.value; 109 textSpan.setAttribute('tabindex', "0"); 110 link.appendChild(textSpan); 111 li.appendChild(link); 112 li.setAttribute('data-panel-id', item?.id); 113 li.setAttribute('data-panel-visible', item?.visible); 114 li.setAttribute('data-panel-enabled', item?.enabled); 115 return li; 116 } 117 118 #handleItemsChange(change, items) { 119 if (change?.prevValue !== null) {
120 document.querySelector(`[data-panel-id='${change?.prevValue?.id}']`)?.remove(); 121 } else { 122 items.forEach((item) => { 123 if (item.id === change.currentValue.id) { 124 const prevListItem = document.querySelector(`[data-panel-id='${items[change.currentValue.index - 1]?.id}']`); 125 const newListItem = this.#createListItem(change.currentValue); 126 prevListItem?.parentNode?.insertBefore(newListItem, prevListItem?.nextSibling); 127 } 128 }); 129 } 130 } 131 132 133 #handleActiveItem(field) { 134 const menu = document.querySelector(HamburgerMenu.selectors.hamburgerMenuWidget.hamburgerMenu); 135 if (field !== null && field) { 136 const activeListItem = document.querySelector(`[data-panel-id='${field.id}']`); 137 if(activeListItem && activeListItem.tagName === 'LI') { 138 const menuItems = document.querySelectorAll(HamburgerMenu.selectors.hamburgerMenuWidget.hamburgerMenu + ' li'); 139 const fieldModel = this.formContainer?.getField(activeListItem?.getAttribute('data-panel-id'))?.getModel(); 140 const elementID = this.#checkFirstNonPanel(fieldModel); 141 const targetElement = menu.querySelector("[data-panel-id='"+ elementID + "']"); 142 this.#resetMenuItems(menuItems); 143 this.#activateCurrentItem(targetElement); 144 const anchorElement = targetElement?.querySelector('a'); 145 anchorElement?.classList.add(HamburgerMenu.cssClasses.active); 146 anchorElement?.querySelector('button')?.classList?.toggle(HamburgerMenu.cssClasses.hamburgerMenuWidget.hamburgerMenuCloseNavButton); 147 this.#updateSelectedPanelTitle(anchorElement); 148 this.#highlightMenuTree(anchorElement); 149 this.#renderBreadCrumbs(menu); 150 } 151 } 152 } 153 154 #updateSelectedPanelTitle(anchorElement, clickedAnchorElement) { 155 const activeItemTitleContent = anchorElement?.innerText; 156 const clickedAnchorElementText = clickedAnchorElement?.innerText; 157 const activeItemTitle = document.querySelector(HamburgerMenu.selectors.hamburgerMenuBottomContainer.hamburgerMenuActiveItemTitle); 158 activeItemTitle.innerText = activeItemTitleContent || clickedAnchorElementText || ''; 159 } 160 161 #checkFirstNonPanel(fieldModel) { 162 if(fieldModel && fieldModel._children && fieldModel._children[0]) { 163 if(fieldModel._children[0]?.fieldType !== 'panel') { 164 return fieldModel._children[0].parent.id; 165 } 166 return this.#checkFirstNonPanel(fieldModel?._children[0]) 167 } 168 return fieldModel?.id; 169 } 170 171 #clickHandler(event) { 172 const menu = document.querySelector(HamburgerMenu.selectors.hamburgerMenuWidget.hamburgerMenu); 173 event.stopPropagation(); 174 let targetElement = event.target.closest('li'); 175 if(targetElement?.getAttribute('data-panel-enabled') === 'false') { 176 return; 177 } 178 if(event.target.tagName === "BUTTON" && (event.target.classList.contains(HamburgerMenu.cssClasses.hamburgerMenuWidget.hamburgerMenuCloseNavButton) || event.target.classList.contains(HamburgerMenu.cssClasses.hamburgerMenuWidget.hamburgerMenuOpenNavButton))) { 179 const isExpanded = event.target.getAttribute('aria-expanded') === 'true'; 180 event.target.classList.toggle(HamburgerMenu.cssClasses.hamburgerMenuWidget.hamburgerMenuCloseNavButton); 181 event.target.setAttribute('aria-expanded', !isExpanded); 182 return; 183 } 184 const menuItems = document.querySelectorAll(HamburgerMenu.selectors.hamburgerMenuWidget.hamburgerMenu + ' li'); 185 const fieldModel = this.formContainer?.getModel().getElement(targetElement?.getAttribute('data-panel-id')); 186 const elementID = this.#checkFirstNonPanel(fieldModel) || targetElement?.getAttribute('data-panel-id'); 187 188 const parentAnchorElement = targetElement?.querySelector('a'); 189 targetElement = menu.querySelector("[data-panel-id='"+ elementID + "']"); 190 this.#resetMenuItems(menuItems); 191 this.#activateCurrentItem(targetElement); 192 const anchorElement = targetElement?.querySelector('a'); 193 anchorElement?.classList.add(HamburgerMenu.cssClasse
193s.active); 194 anchorElement?.querySelector('button')?.classList?.toggle(HamburgerMenu.cssClasses.hamburgerMenuWidget.hamburgerMenuCloseNavButton); 195 const isExpanded = anchorElement?.querySelector('button')?.getAttribute('aria-expanded') === 'true'; 196 anchorElement?.querySelector('button')?.setAttribute('aria-expanded', !isExpanded); 197 this.#updateSelectedPanelTitle(anchorElement, parentAnchorElement); 198 this.#highlightMenuTree(anchorElement, parentAnchorElement); 199 200 this.formContainer.getModel().getElement('accordion-9fbafbc6e6'); 201 202 const itemId = targetElement?.getAttribute('data-panel-id') || HamburgerMenu.activeItemId; 203 const form = this.formContainer?.getModel(); 204 const field = form?.getElement(itemId); 205 menu.style.display = menu.style.display === 'flex' ? 'none' : 'flex'; 206 this.#renderBreadCrumbs(menu); 207 if (form && field) { 208 form.setFocus(field); 209 } 210 } 211 212 #resetMenuItems(menuItems) { 213 menuItems.forEach(item => { 214 const subMenu = item.querySelector(HamburgerMenu.selectors.hamburgerMenuWidget.hamburgerSubMenu); 215 if (subMenu) { 216 subMenu.style.display = 'none'; 217 subMenu.setAttribute('aria-hidden', true); 218 } 219 const link = item.querySelector('a'); 220 if(link) { 221 link?.querySelector('button')?.classList.remove(HamburgerMenu.cssClasses.hamburgerMenuWidget.hamburgerMenuCloseNavButton); 222 link?.querySelector('button')?.classList.add(HamburgerMenu.cssClasses.hamburgerMenuWidget.hamburgerMenuOpenNavButton); 223 link?.classList.remove(HamburgerMenu.cssClasses.active, HamburgerMenu.cssClasses.activeParent); 224 link.style.fontWeight = 'normal'; 225 } 226 }); 227 } 228 229 #activateCurrentItem(currentItem) { 230 while (currentItem) { 231 const subMenu = currentItem.querySelector(HamburgerMenu.selectors.hamburgerMenuWidget.hamburgerSubMenu); 232 if (subMenu) { 233 subMenu.style.display = 'block'; 234 subMenu.setAttribute('aria-hidden', false); 235 } 236 currentItem = currentItem.parentElement.closest('li'); 237 } 238 } 239 240 #menuItemClickHandler(event, subMenu, li, link) { 241 event.preventDefault(); 242 if (li.getAttribute('data-panel-enabled') === 'false') { 243 return; 244 } 245 const expanded = link.getAttribute('aria-expanded') === 'true'; 246 link.setAttribute('aria-expanded', !expanded); 247 if (subMenu.style.display === 'flex' || subMenu.style.display === 'block') { 248 subMenu.style.display = 'none'; 249 subMenu.setAttribute('aria-hidden', true); 250 } else { 251 subMenu.style.display = 'flex'; 252 subMenu.setAttribute('aria-hidden', false); 253 } 254 } 255 256 #createDownArrowButton() { 257 const downArrowButton = document.createElement('button'); 258 downArrowButton.type='button'; 259 downArrowButton.classList.add(HamburgerMenu.cssClasses.hamburgerMenuWidget.hamburgerMenuOpenNavButton); 260 downArrowButton.setAttribute('aria-expanded', false); 261 return downArrowButton; 262 } 263 264 #createHamburgerMenu(items, counter = 0) { 265 if (counter >= HamburgerMenu.nestingSupport) { 266 return; 267 } 268 if (!items?.length) return; 269 const ul = document.createElement('ul'); 270 let activeItemTitleUpdated = false; 271 items.forEach((item) => { 272 if (item?.fieldType !== "panel") return; 273 274 if (!activeItemTitleUpdated) { 275 const activeItemTitle = document.querySelector(HamburgerMenu.selectors.hamburgerMenuBottomContainer.hamburgerMenuActiveItemTitle); 276 if(activeItemTitle) { 277 activeItemTitle.innerText = item?.label?.value; 278 activeItemTitleUpdated = true; 279 } 280 } 281 282 const li = document.createElement('li'); 283 const link = document.createElement('a'); 284 link.setAttribute('role', 'menuitem'); 285 link.setAttribute('aria-expanded', 'false'); 286 const textSpan = document.createElement('span'); 287 textSpan.setAttribute('tabindex', "0"); 288 link.href = "#"; 289 textSpan.textContent = item?.label?.value; 290 link.appendChild(textSpan); 291 link.style.visibility = item?.label?.visible ? 'visible' : 'hidden'; 292 li.appendChild(link); 293 294 li.setAttribute('data-panel-id', item?.id); 295 li.setAttribute('data-panel-visible', item?.visible); 296 li.setAttribute('data-panel-enabled', item?.enabled); 297 const children = this.formContainer?.getModel()?.getElement(item.id)?._children; 298 let flag = false;
299 300 // setting an attibute(data-panel-has-input) if the item is having an input field 301 if(children) { 302 for(let i = 0; i< children.length; i++) { 303 if(children[i].fieldType !== 'panel') { 304 flag = true; 305 } 306 } 307 } 308 if(flag) { 309 li.setAttribute('data-panel-has-input', flag); 310 } 311 312 link.classList.add(HamburgerMenu.cssClasses.hamburgerMenuWidget.hamburgerMenuNavLink); 313 if (item?.repeatable) { 314 const subMenu = this.#createHamburgerMenu(item.items, counter + 1); 315 subMenu?.childNodes.forEach(child => ul.appendChild(child)); 316 } else if (Array.isArray(item.items) && item.items.length > 0) { 317 const subMenu = this.#createHamburgerMenu(item.items, counter + 1); 318 if (subMenu?.childNodes?.length) { 319 subMenu.classList.add(HamburgerMenu.cssClasses.hamburgerMenuWidget.hamburgerSubMenu); 320 li.appendChild(subMenu); 321 link.insertBefore(this.#createDownArrowButton(), link.firstChild); 322 link.addEventListener('click', (event) => { 323 this.#menuItemClickHandler(event, subMenu, li, link) 324 }); 325 link.addEventListener('keydown', (event) => { 326 if(event.key === 'Enter' || event.key === ' ') { 327 this.#menuItemClickHandler(event, subMenu, li, link); 328 } 329 }); 330 } 331 } 332 ul.appendChild(li); 333 }); 334 335 return ul; 336 } 337 338 // Function to find the currently active li 339 #findActiveLi() { 340 return document.querySelector(HamburgerMenu.selectors.active).parentElement; 341 } 342 343 #highlightMenuTree(element, parentAnchorElement) { 344 const closestLI = element?.closest('li'); 345 const clickedClosestLI = parentAnchorElement?.closest('li'); 346 347 const li = closestLI || clickedClosestLI; 348 349 if (!li || li === document.body) { 350 return; 351 } 352 let anchorElement = li?.querySelector('a'); 353 354 if(anchorElement) { 355 anchorElement?.classList.add(HamburgerMenu.cssClasses.activeParent); 356 anchorElement?.querySelector('button')?.classList.add(HamburgerMenu.cssClasses.hamburgerMenuWidget.hamburgerMenuCloseNavButton); 357 if(anchorElement?.querySelector('button')?.classList.contains(HamburgerMenu.cssClasses.hamburgerMenuWidget.hamburgerMenuCloseNavButton)) { 358 anchorElement?.querySelector('button')?.setAttribute('aria-expanded', true); 359 } 360 if(li.parentElement.classList.contains(HamburgerMenu.cssClasses.hamburgerMenuWidget.hamburgerMenu)) { 361 anchorElement.style.fontWeight = 'bold' 362 } 363 this.#highlightMenuTree(li.parentElement); 364 } 365 } 366 367 #isEligible(element, direction) { 368 if (element && element?.getAttribute('data-panel-visible') === 'false' || element?.getAttribute('data-panel-enabled') === 'false' || (direction === 'prev' && element?.getAttribute('data-panel-has-input') !== 'true')) { 369 return false; 370 } else if (element && element.parentNode && element.parentNode !== document) { 371 return this.#isEligible(element.parentNode); 372 } else { 373 return true; 374 } 375 } 376 377 #moveTo(menuListItems, direction) { 378 const currentActive = this.#findActiveLi(); 379 if (!currentActive) return; 380 381 let newActiveItemIndex = -1; 382 menuListItems.forEach((item, index) => { 383 if (item.getAttribute('data-panel-id') === currentActive.getAttribute('data-panel-id')) { 384 newActiveItemIndex = direction === 'prev' ? index - 1 : index + 1; 385 } 386 }); 387 388 if (direction === 'prev' && newActiveItemIndex < 0) { 389 newActiveItemIndex = menuListItems.length - 1; 390 } 391 while (!this.#isEligible(menuListItems[newActiveItemIndex], direction)) { 392 if(direction === 'prev') { 393 newActiveItemIndex = (newActiveItemIndex - 1) % menuListItems.length; 394 if(newActiveItemIndex<=0) { 395 newActiveItemIndex = 0; 396 break; 397 } 398 } else { 399 newActiveItemIndex = (newActiveItemIndex + 1) % menuListItems.length; 400 } 401 } 402 const newActiveItem = menuListItems[newActiveItemIndex]; 403 HamburgerMenu.activeItemId = newActiveItem?.getAttribute('data-panel-id'); 404 newActiveItem?.click(); 405 } 406 407 #movePrev(menuListItems) { 408 this.#moveTo(menuListItems, 'prev'); 409 } 410 411 #moveNext(menuListItems) { 412 this.#moveTo(menuListItems, 'next'); 413 } 414 415 #addEventsToNavigationButtons() { 416 const previousNavButton = document.querySelector(HamburgerMenu.selectors.hamburgerMenuBottomContainer.hamburgerMenuPreviousNavButton); 417 const nextNavButton = document.querySelector(HamburgerMenu.selectors.hamburgerMenuBottomContainer.hamburgerMenuNextNavButton); 418 const menuListItems = document.querySelector(HamburgerMenu.selectors.hamburgerMenuWidget.hamburgerMenu).querySelectorAll('li'); 419 previousNavButton.addEventListener('click', () => this.#movePrev(menuListItems)); 420 nextNavButton.addEventListener('click', () => this.#moveNext(menuListItems)); 421 } 422 423 #generateBreadcrumbs(breadcrumbs) { 424 const container = document.createElement('nav'); 425 container.setAttribute('aria-label', 'Breadcrumb'); 426 const list = document.createElement('ul'); 427 list.style.listStyleType = 'none'; 428 list.style.padding = '0'; 429 list.style.margin = '0'; 430 if(breadcrumbs && breadcrumbs.length) {
431 [...breadcrumbs].forEach((breadcrumb, index) => { 432 const listItem = document.createElement('li'); 433 listItem.style.display = 'inline'; 434 const span = document.createElement('span'); 435 span.textContent = breadcrumb.innerText; 436 listItem.appendChild(span); 437 if (index < breadcrumbs.length - 1) { 438 const separator = document.createElement('span'); 439 separator.textContent = ' > '; 440 separator.style.margin = '0 5px'; 441 listItem.appendChild(separator); 442 } 443 if(index === breadcrumbs?.length-1) { 444 listItem.style.fontWeight = 'bold'; 445 } 446 list.appendChild(listItem); 447 }); 448 } 449 container.appendChild(list); 450 return container; 451 } 452 453 #renderBreadCrumbs(menu) { 454 const selectedPanels = menu.getElementsByClassName(HamburgerMenu.cssClasses.activeParent); 455 const breadCrumbsContainer = document.querySelector(HamburgerMenu.selectors.hamburgerMenuMiddleContainer); 456 breadCrumbsContainer.innerHTML = ''; 457 const breadCrumbs = this.#generateBreadcrumbs(selectedPanels) 458 breadCrumbsContainer.appendChild(breadCrumbs); 459 breadCrumbsContainer.scrollLeft = breadCrumbs.scrollWidth; 460 } 461 462 #renderHamburgerItems(panels) { 463 const parentContainer = document.querySelector(HamburgerMenu.selectors.hamburgerMenuTopContainer.self); 464 const hamburgerIcon = document.querySelector(HamburgerMenu.selectors.hamburgerMenuTopContainer.hamburgerMenuIcon); 465 const hamburgerMenuIconContainer = document.querySelector(HamburgerMenu.selectors.hamburgerMenuTopContainer.hamburgerMenuIconContainer); 466 467 const menu = this.#createHamburgerMenu(panels); 468 if(menu) { 469 menu.classList.add(HamburgerMenu.cssClasses.hamburgerMenuWidget.hamburgerMenu); 470 menu.setAttribute('role', 'menu'); 471 menu.setAttribute('id', 'hamburger-menu'); 472 473 this.#attachHamburgerEventListeners(hamburgerIcon, menu); 474 this.#attachOutsideClickHandler(hamburgerIcon, menu); 475 this.#attachMenuEventListeners(menu); 476 this.#styleSubmenuItems(menu); 477 parentContainer.innerHTML=''; 478 parentContainer.appendChild(hamburgerMenuIconContainer); 479 parentContainer.appendChild(menu); 480 481 // Add events to navigation buttons 482 this.#addEventsToNavigationButtons(); 483 484 // Automatically click the first root list item if it exists 485 const rootListItems = menu.querySelectorAll(HamburgerMenu.selectors.hamburgerMenuWidget.hamburgerMenu + ' > li'); 486 if (rootListItems[0] && rootListItems[0].tagName === 'LI') { 487 rootListItems[0].click(); 488 menu.style.display = 'none'; 489 } 490 } 491 } 492 493 #attachMenuEventListeners(menu) { 494 menu.addEventListener('click', (event) => this.#clickHandler(event)); 495 menu.addEventListener('keydown', (event) => { 496 if (event.key === 'Enter' || event.key === ' ') { 497 event.preventDefault(); 498 this.#clickHandler(event); 499 } 500 }); 501 menu.addEventListener('ontouchstart', (event) => this.#clickHandler(event)); 502 } 503 504 #attachHamburgerEventListeners(hamburgerIcon, menu) { 505 const toggleMenuVisibility = () => { 506 menu.style.display = menu.style.display === 'flex' ? 'none' : 'flex'; 507 }; 508 hamburgerIcon?.addEventListener('click', toggleMenuVisibility); 509 hamburgerIcon?.addEventListener('ontouchstart', toggleMenuVisibility); 510 } 511 512 #styleSubmenuItems(menu) { 513 const rootListItems = menu.querySelectorAll(HamburgerMenu.selectors.hamburgerMenuWidget.hamburgerMenu + ' > li');
514 rootListItems.forEach((item) => { 515 let padding = 30; 516 const submenus = item.querySelectorAll(HamburgerMenu.selectors.hamburgerMenuWidget.hamburgerSubMenu); 517 submenus.forEach((submenu) => { 518 const links = submenu.querySelectorAll('a'); 519 links.forEach((link) => { 520 if(link.querySelector('button')) { 521 link.style.paddingInlineStart = `${padding}px`; 522 } else { 523 link.style.paddingInlineStart = `${padding + 30}px`; 524 } 525 }); 526 padding += 15; 527 }); 528 }); 529 } 530 531 #attachOutsideClickHandler(hamburger, menu) { 532 window.addEventListener('click', (e) => { 533 if (!hamburger.contains(e.target) && !menu.contains(e.target) && menu.style.display === 'flex') { 534 menu.style.display = 'none'; 535 } 536 }); 537 } 538 539 #getAllPanels() { 540 let items = this.formContainer?._model.getItemsState() || []; 541 const panels = items.filter(item => item?.fieldType === "panel"); 542 return panels; 543 } 544 545 init() { 546 if(this.formContainer?.getModel()?.properties?.['fd:isHamburgerMenuEnabled']) { 547 document.querySelector('.cmp-adaptiveform-container')?.setAttribute('data-cmp-hamburger-menu-enabled', 'true'); 548 const panels = this.#getAllPanels(); 549 this.#renderHamburgerItems(panels); 550 } 551 } 552 } 553} 554/******************************************************************************* 555 * Copyright 2024 Adobe 556 * 557 * Licensed under the Apache License, Version 2.0 (the "License"); 558 * you may not use this file except in compliance with the License. 559 * You may obtain a copy of the License at 560 * 561 * http://www.apache.org/licenses/LICENSE-2.0 562 * 563 * Unless required by applicable law or agreed to in writing, software 564 * distributed under the License is distributed on an "AS IS" BASIS, 565 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 566 * See the License for the specific language governing permissions and 567 * limitations under the License. 568 ******************************************************************************/ 569 570(function() { 571 572 "use strict"; 573 class FormContainerV2 extends FormView.FormContainer { 574 static NS = FormView.Constants.NS; 575 static IS = "adaptiveFormContainer"; 576 static bemBlock = 'cmp-adaptiveform-container'; 577 static selectors = { 578 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 579 }; 580 static loadingClass = `${FormContainerV2.bemBlock}--loading`; 581 #hamburgerMenuInstance = ''; 582 583 constructor(params) { 584 super(params); 585 let self = this; 586 this.#hamburgerMenuInstance = new HamburgerMenu(this); 587 this._model.subscribe((action) => { 588 let state = action.target.getState(); 589 // execute the handler only if there are no rules configured on submitSuccess event. 590 if (!state.events.submitSuccess || state.events.submitSuccess.length === 0) { 591 const globals = { 592 form: self.getModel().getRuleNode(), 593 event: { 594 type: action.type, 595 payload: action.payload, 596 } 597 }; 598 FormView.customFunctions.defaultSubmitSuccessHandler(globals); 599 } 600 }, "submitSuccess"); 601 this._model.subscribe((action) => { 602 let state = action.target.getState(); 603 // execute the handler only if there are no rules configured on submitError event. 604 if (!state.events.submitError || state.events.submitError.length === 0) { 605 let defaultSubmissionError = FormView.LanguageUtils.getTranslatedString(self.getLang(), "InternalFormSubmissionError"); 606 const globals = { 607 form: self.getModel().getRuleNode(), 608 event: { 609 type: action.type, 610 payload: action.payload, 611 } 612 }; 613 FormView.customFunctions.defaultSubmitErrorHandler(defaultSubmissionError, globals); 614 } 615 }, "submitError"); 616 this._model.subscribe((action) => { 617 let state = action.target.getState(); 618 // execute the handler only if there are no rules configured on custom:saveSuccess event. 619 if (!state.events['custom:saveSuccess'] || state.events['custom:saveSuccess'].length === 0) { 620 console.log("Draft id = " + action?.payload?.body?.draftId); 621 window.alert(FormView.LanguageUtils.getTranslatedString(self.getLang(), "saveDraftSuccessMessage")); 622 } 623 }, "saveSuccess"); 624 this._model.subscribe((action) => { 625 let state = action.target.getState(); 626 // execute the handler only if there are no rules configured on custom:saveError event. 627 if (!state.events['custom:saveError'] || state.events['custom:saveError'].length === 0) { 628 window.alert(FormView.LanguageUtils.getTranslatedString(self.getLang(), "saveDraftErrorMessage")); 629 } 630 }, "saveError"); 631 this.#setupAutoSave(self.getModel()); 632 } 633 634 initialiseHamburgerMenu() { 635 this.#hamburgerMenuInstance.init(); 636 } 637 638 /** 639 * Register time based auto save 640 * @param formModel. 641 */ 642 #setupAutoSave(formModel) { 643 const autoSaveProperties = formModel?.properties?.['fd:autoSave']; 644 const enableAutoSave = this.#getAutoSaveAttribute(); 645 if (enableAutoSave) { 646 const autoSaveStrategyType = autoSaveProperties['fd:autoSaveStrategyType']; 647 const autoSaveInterval = autoSaveProperties['fd:autoSaveInterval']; 648 const saveEndPoint = FormView.Utils.getContextPath() + '/adobe/forms/af/save/' + formModel.id; 649 if (autoSaveStrategyType === 'time' && autoSaveInterval) { 650 console.log("Registering time based auto save"); 651 setInterval(() => { 652 formModel.dispatch(new FormView.Actions.Save({ 653 'action': saveEndPoint 654 })); 655 }, parseInt(autoSaveInterval) * 1000); 656 } 657 } 658 } 659 660 #getAutoSaveAttribute() { 661 return this.getFormElement()?.getAttribute('data-cmp-auto-save') === 'true'; 662 } 663 } 664 665 async function onDocumentReady() { 666 const startTime = new Date().getTime(); 667 let elements = document.querySelectorAll(FormContainerV2.selectors.self); 668 669 for (let i = 0; i < elements.length; i++) { 670 let loaderToAdd = document.querySelector("[data-cmp-adaptiveform-container-loader='"+ elements[i].id + "']"); 671 if(loaderToAdd){ 672 loaderToAdd.classList.add(FormContainerV2.loadingClass); 673 } 674 console.debug("Form loading started", elements[i].id); 675 } 676 function onInit(e) { 677 let formContainer = e.detail; 678 let formEl = formContainer.getFormElement(); 679 formContainer.initialiseHamburgerMenu(); 680 setTimeout(() => { 681 let loaderToRemove = document.querySelector("[data-cmp-adaptiveform-container-loader='"+ formEl.id + "']"); 682 if(loaderToRemove){ 683 loaderToRemove.classList.remove(FormContainerV2.loadingClass); 684 } 685 const timeTaken = new Date().getTime() - startTime; 686 console.debug("Form loading complete", formEl.id, timeTaken); 687 }, 10); 688 } 689 document.addEventListener(FormView.Constants.FORM_CONTAINER_INITIALISED, onInit); 690 await FormView.Utils.setupFormContainer(async ({ 691 _formJson, _prefillData, _path, _element 692 }) => { 693 let formContainer = new FormContainerV2({_formJson, _prefillData, _path, _element}); 694 // before initializing the form container load all the locale specific json resources 695 // for runtime 696 const formLanguage = formContainer.getLang(); 697 const aemLangUrl = `/etc.clientlibs/core/fd/af-clientlibs/core-forms-components-runtime-all/resources/i18n/${formLanguage}.json`; 698 await FormView.LanguageUtils.loadLang(formLanguage, aemLangUrl, true); 699 formContainer.subscribe(); 700 return formContainer; 701 }, FormContainerV2.selectors.self, FormContainerV2.IS); 702 } 703 704 // This is to ensure that the there is no WCM Mode cookie when Form Container is rendered. 705 // max-age=0 ensures that the cookie is deleted. 706 document.cookie="wcmmode=disabled; max-age=0; path=/"; 707 708 if (document.readyState !== "loading") { 709 onDocumentReady(); 710 } else { 711 document.addEventListener("DOMContentLoaded", onDocumentReady); 712 } 713})(); 714 715/******************************************************************************* 716 * Copyright 2023 Adobe 717 * 718 * Licensed under the Apache License, Version 2.0 (the "License");
719 * you may not use this file except in compliance with the License. 720 * You may obtain a copy of the License at 721 * 722 * http://www.apache.org/licenses/LICENSE-2.0 723 * 724 * Unless required by applicable law or agreed to in writing, software 725 * distributed under the License is distributed on an "AS IS" BASIS, 726 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 727 * See the License for the specific language governing permissions and 728 * limitations under the License. 729 ******************************************************************************/ 730(function() { 731 732 "use strict"; 733 class Cache { 734 735 store = {}; 736 737 put(el, key, value) { 738 this.store[el.id ] = {}; 739 this.store[el.id][key] = value; 740 } 741 742 get(el, key) { 743 return this.store[el.id][key]; 744 } 745 } 746 window.afCache = new Cache(); 747})(); 748 749/******************************************************************************* 750 * Copyright 2022 Adobe 751 * 752 * Licensed under the Apache License, Version 2.0 (the "License"); 753 * you may not use this file except in compliance with the License. 754 * You may obtain a copy of the License at 755 * 756 * http://www.apache.org/licenses/LICENSE-2.0 757 * 758 * Unless required by applicable law or agreed to in writing, software 759 * distributed under the License is distributed on an "AS IS" BASIS, 760 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 761 * See the License for the specific language governing permissions and 762 * limitations under the License. 763 ******************************************************************************/ 764(function() { 765 766 "use strict"; 767 class DatePicker extends FormView.FormFieldBase { 768 769 static NS = FormView.Constants.NS; 770 static IS = "adaptiveFormDatePicker"; 771 static bemBlock = 'cmp-adaptiveform-datepicker'; 772 static selectors = { 773 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 774 widget: `.${DatePicker.bemBlock}__widget`, 775 label: `.${DatePicker.bemBlock}__label`, 776 description: `.${DatePicker.bemBlock}__longdescription`, 777 qm: `.${DatePicker.bemBlock}__questionmark`, 778 errorDiv: `.${DatePicker.bemBlock}__errormessage`, 779 tooltipDiv: `.${DatePicker.bemBlock}__shortdescription` 780 }; 781 782 constructor(params) { 783 super(params); 784 } 785 786 getWidget() { 787 return this.element.querySelector(DatePicker.selectors.widget); 788 } 789 790 getDescription() { 791 return this.element.querySelector(DatePicker.selectors.description); 792 } 793 794 getLabel() { 795 return this.element.querySelector(DatePicker.selectors.label); 796 } 797 798 getErrorDiv() { 799 return this.element.querySelector(DatePicker.selectors.errorDiv); 800 } 801 802 getQuestionMarkDiv() { 803 return this.element.querySelector(DatePicker.selectors.qm); 804 } 805 806 getTooltipDiv() { 807 return this.element.querySelector(DatePicker.selectors.tooltipDiv); 808 } 809 810 updateValue(value) { 811 if (this.widgetObject) { 812 if (this.isActive()) { 813 // Replacing undefined / null with empty string on reset 814 this.widgetObject.setValue(value || ''); 815 } else { 816 // Replacing undefined / null with empty string on reset 817 this.widgetObject.setDisplayValue(value || ''); 818 } 819 } else { 820 // Replacing undefined / null with empty string on reset 821 super.updateValue(value || ''); 822 } 823 } 824 825 updateReadOnly(readOnly, state) { 826 super.updateReadOnly(readOnly, state); 827 if (this.widgetObject != null) { 828 this.widgetObject.markAsReadOnly(readOnly); 829 } 830 } 831 832 833 setModel(model) { 834 super.setModel(model); 835 if (!this.#noFormats()) { 836 if (this.widgetObject == null) { 837 this.widgetObject = new DatePickerWidget(this, this.getWidget(), model); 838 } 839 if (this.isActive()) { 840 this.widgetObject.setValue(model.value); 841 } else { 842 this.widgetObject.setDisplayValue(model.value); 843 } 844 this.widgetObject.addEventListener('blur', (e) => { 845 this.setModelValue(this.widgetObject.getValue()) 846 //setDisplayValue is required for cases where value remains same while focussing in and out. 847 this.widgetObject.setDisplayValue(this._model.value); 848 this.widgetObject.setCalendarWidgetValue(this._model.value); 849 this.setInactive(); 850 }, this.getWidget()); 851 this.widgetObject.addEventListener('focus', (e) => { 852 this.widgetObject.setValue(e.target.value); 853 this.setActive(); 854 }, this.getWidget()); 855 this.widgetObject.addEventListener('input', (e) => { 856 if( e.target.value === '') { 857 // clear the value if user manually empties the value in date input box 858 this.setModelValue(""); 859 } 860 }, this.getWidget()); 861 } else { 862 if (this.widget.value !== '') { 863 this.setModelValue(this.widget.value); 864 } 865 this.widget.addEventListener('blur', (e) => { 866 this.setModelValue(e.target.value); 867 this.setInactive(); 868 }); 869 this.widget.addEventListener('focus', (e) => { 870 this.setActive(); 871 }); 872 } 873 } 874 875 #noFormats() { 876 return (this._model.editFormat == null || this._model.editFormat === 'date|short') && 877 (this._model.displayFormat == null || this._model.displayFormat === 'date|short') && (this._model.displayValueExpression == null) 878 } 879 } 880 881 FormView.Utils.setupField(({element, formContainer}) => { 882 return new DatePicker({element, formContainer}) 883 }, DatePicker.selectors.self); 884})(); 885 886/******************************************************************************* 887 * Copyright 2023 Adobe 888 * 889 * Licensed under the Apache License, Version 2.0 (the "License");
890 * you may not use this file except in compliance with the License. 891 * You may obtain a copy of the License at 892 * 893 * http://www.apache.org/licenses/LICENSE-2.0 894 * 895 * Unless required by applicable law or agreed to in writing, software 896 * distributed under the License is distributed on an "AS IS" BASIS, 897 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 898 * See the License for the specific language governing permissions and 899 * limitations under the License. 900 ******************************************************************************/ 901 902if (typeof window.DatePickerWidget === 'undefined') { 903 904 window.DatePickerWidget = class { 905 906 #widget = null; 907 #model = null // passed by reference 908 #options = null 909 910 #lang = "en"; 911 912 #dp = null; 913 #curInstance = null; 914 #calendarIcon = null; 915 #documentTouchListener = null; 916 static #visible = false; 917 static #clickedWindow; 918 919 /** default configuration options 920 * 921 * yearsPerView: number of years to show in the yearset view 922 * 923 * width: with of the widget 924 * 925 * viewHeight: Height of the month,year and yearset view. This doesn't include 926 * the height of the header 927 * 928 * locale: locale information for the locale in which to show the datepicker which comprises of 929 * days: day names to display in the monthview 930 * months: month names to display in the yearview 931 * zero: string representation of zero in the locale. Numbers will be 932 * displayed in that locale only 933 * clearText: Text to display for the reset button 934 * name: name of the locale 935 * 936 * format: input format for the datepicker (not implemented) 937 * 938 * pickerType: type of the datetimepicker (date, datetime and time) 939 * 940 * positioning: element around which datepicker will be displayed. if null then it 941 * will be displayed around the input element 942 * 943 * showCalendarIcon: to show the Calendar on the right of the text field or not 944 */ 945 #defaultOptions = { 946 yearsPerView: 16, 947 width: 340, 948 viewHeight: 248, 949 locale: { 950 days: ["S","M","T","W","T","F","S"], 951 months: ["January","February","March","April","May","June","July","August","September","October","November","December"], 952 zero: "0", 953 clearText: "Clear", 954 name: "en_US" 955 }, 956 format: "YYYY-MM-DD", 957 pickerType: "date", 958 positioning: null, 959 showCalendarIcon: true 960 } 961 962 #dates = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] 963 /* 964 * Actions to perform when clicked on the datepicker buttons 965 * for different views 966 * caption: view to show when clicked on caption 967 * (Year/YearSet/Month/null) null means don't change the view 968 * li: view to show when clicked on date, month or year element 969 * upDown: add(up key) or subtract(down key) current date (for monthview), 970 * month(Year View) or year(YearSetView) with the number provided 971 * key: identifies the key that needs to be changed for that view 972 */ 973 #viewAction = { 974 Month: { 975 caption: 'Year', 976 li: null, 977 key: "day", 978 upDown: 7 979 }, 980 Year: { 981 caption: "Yearset", 982 li: "Month", 983 key: "month", 984 upDown: 3 985 }, 986 Yearset: { 987 caption: null, 988 li: "Year", 989 key: "year", 990 upDown: 4 991 } 992 } 993 994 selectedDay = 0; 995 selectedMonth = 0; 996 selectedYear = 0; 997 currentDay = 0; 998 currentMonth = 0; 999 currentYear = 0; 1000 //view="Month"; 1001 #touchSupported = !!("ontouchstart" in window || window.DocumentTouch 1002 && document instanceof DocumentTouch); 1003 #defaultView = "Month"; 1004 #keysEnabled = false; 1005 #focusedOnLi = false; 1006 #keyboardAccessibility = true; 1007 #scriptFocus; 1008 1009 /* template for the clear Button */ 1010 #clearButtonTemplate = '<div class="dp-clear">' + 1011 '<a></a>' + 1012 '</div>'; 1013 1014 /* template for the calendar 1015 * header contains the navigation icons (left and right arrows) 1016 * and the current caption (which can be date, year or month) 1017 * 1018 * monthview displays the grid for showing the dates for a particular 1019 * month 1020 * 1021 * yearview displays all the months of that year 1022 * 1023 * yearsetview displays a grid of 16 years. This can be configured
1024 * through the option: yearsPerView 1025 * 1026 */ 1027 #calendarTemplate = '<div class="dp-header">' + 1028 '<div class="dp-leftnav"></div>' + 1029 '<div class="dp-caption"></div>' + 1030 '<div class="dp-rightnav"></div>' + 1031 '</div>' + 1032 '<div class="view dp-monthview"></div>' + 1033 '<div class="view dp-yearview"></div>' + 1034 '<div class="view dp-yearsetview"></div>'; 1035 1036 constructor(view, widget, model) { 1037 this.#model = model; 1038 this.#lang = view.getModel().lang; 1039 let editValFn = () => { 1040 return model.editValue; 1041 }; 1042 let displayValueFn = () => { 1043 return model.displayValue; 1044 }; 1045 this.#localizeDateElements(this.#defaultOptions, this.#lang); 1046 this.#options = Object.assign( 1047 {editValue: editValFn, displayValue: displayValueFn}, 1048 this.#defaultOptions, this.#model._jsonModel); 1049 1050 this.#initialiseCalenderElement(); 1051 1052 //update widget markup to have input type=text element. 1053 let newDatePickerElement = widget.cloneNode(true); 1054 newDatePickerElement.setAttribute("type", "text"); 1055 newDatePickerElement.id = model.id + '-widget'; 1056 1057 widget.parentNode.replaceChild(newDatePickerElement, widget); 1058 this.#widget = view.getWidget(); 1059 this.#attachField(view.getWidget(), this.#options); 1060 } 1061 1062 #initialiseCalenderElement() { 1063 let self = this, 1064 html = ""; 1065 if (this.#options.pickerType.match(/date/)) { 1066 html += this.#calendarTemplate; 1067 } 1068 html += this.#clearButtonTemplate; 1069 1070 if (!this.#dp) { 1071 this.#dp = document.createElement("div"); 1072 this.#dp.classList.add("datetimepicker", "datePickerTarget"); 1073 this.#dp.innerHTML = html; 1074 //Always inserting it in body 1075 document.body.appendChild(this.#dp); 1076 } 1077 // attach click event on entire datePicker popup 1078 this.#dp.addEventListener("click", 1079 function (evnt) { 1080 //focus only if the device doesn't support touch 1081 // input otherwise on screen keyboard will popup 1082 if (!self.#touchSupported) { 1083 if (self.#curInstance) { 1084 self.#curInstance.$field.focus(); 1085 } 1086 } 1087 }, false); 1088 "touchstart mousedown".split(" ").forEach(function (e) { 1089 self.#dp.addEventListener(e, function (evt) { 1090 self.#checkWindowClicked(evt) 1091 }, false); 1092 }); 1093 1094 this.$month = this.#dp.getElementsByClassName("dp-monthview")[0]; 1095 this.$year = this.#dp.getElementsByClassName("dp-yearview")[0]; 1096 this.$yearset = this.#dp.getElementsByClassName("dp-yearsetview")[0]; 1097 1098 this.clear = this.#dp.getElementsByClassName( 1099 "dp-clear")[0].getElementsByTagName("a")[0]; 1100 this.clear.addEventListener("click", function (evnt) { 1101 if (self.view && self.#curInstance) { 1102 self.#clearDate(self.view); 1103 } 1104 }); 1105 this.prevNavWidthBtn = this.#dp.getElementsByClassName("dp-leftnav")[0]; 1106 this.prevNavWidthBtn.addEventListener("click", 1107 function (evnt) { 1108 if (self.view && self.#curInstance) { 1109 self.#adjustDate(-1, self.view, false) 1110 } 1111 }); 1112 this.nextNavWidthBtn = this.#dp.getElementsByClassName("dp-rightnav")[0]; 1113 this.nextNavWidthBtn.addEventListener("click", 1114 function (evnt) { 1115 if (self.view && self.#curInstance) { 1116 self.#adjustDate(1, self.view, false) 1117 } 1118 }); 1119 this.caption = this.#dp.getElementsByClassName("dp-caption")[0]; 1120 this.caption.addEventListener("click", 1121 function (evnt) { 1122 if (self.view && self.#curInstance) { 1123 if (!self.caption.classList.contains("disabled")) { 1124 self.#layout(self.#viewAction[self.view].caption); 1125 } 1126 } 1127 }); 1128 if (this.#keyboardAccessibility) { 1129 [this.prevNavWidthBtn, this.caption, this.nextNavWidthBtn, 1130 this.clear].forEach(function (elem, i) { 1131 elem.setAttribute("tabIndex", i + 1); 1132 }); 1133 } 1134 1135 } 1136 1137 /* 1138 * attaches the date picker to the field. This is a one time operation 1139 * First creates a configuration object and stores it in the field data attributes 1140 * then attaches event handlers on click, focus (to show the picker) and blur
1140(to hide) events 1141 */ 1142 #attachField(widget, options) { 1143 let inst = this.#newInst(widget, options), 1144 self = this, 1145 activateField = function (evnt) { 1146 if (!self.#curInstance) { 1147 self.#activateField(evnt); 1148 } 1149 1150 if (self.#options.showCalendarIcon) { 1151 if (evnt.type === self.#getEvent()) { 1152 if (self._iconClicked) { 1153 self._iconClicked = false; 1154 if (DatePickerWidget.#visible) { 1155 self.#hide(); // hide the calendar popup if visible when calendar icon is clicked 1156 self.#curInstance.$field.focus(); // bring back focus in field 1157 } else { 1158 self.#show(); //// show the calendar popup if not visible when calendar icon is clicked 1159 } 1160 } 1161 } 1162 } else { 1163 /*show the popup only if 1164 1. click/touch event 1165 2. focus event in case of non-touch devices and focus is not done using script 1166 */ 1167 if (evnt.type === self.#getEvent() || (evnt.type === "focus" 1168 && !self.#touchSupported && !self.#scriptFocus)) { 1169 self.#show(evnt); 1170 } 1171 } 1172 1173 DatePickerWidget.#clickedWindow = true; 1174 self.#scriptFocus = false; 1175 }, 1176 deactivateField = function (evnt) { 1177 //deactivate only if clicked outside window 1178 // on touch devices only keyboard or calendar should be active at once, touching keyboard should deactivate calendar 1179 if ((DatePickerWidget.#clickedWindow && !self.#focusedOnLi) 1180 && (self.#options.showCalendarIcon || !self.#touchSupported)) { 1181 self.#hide(); 1182 self.#deactivateField(); 1183 DatePickerWidget.#clickedWindow = true; 1184 } 1185 }; 1186 1187 window.afCache.put(widget, "datetimepicker", inst); 1188 1189 widget.addEventListener(this.#getEvent(), activateField); 1190 widget.onfocus = activateField; 1191 widget.onblur = deactivateField; 1192 1193 if (options.showCalendarIcon) { 1194 let existingCalendarIcons = widget.parentNode.querySelectorAll('.cmp-adaptiveform-datepicker__calendar-icon'); 1195 existingCalendarIcons.forEach(icon => icon.remove()); 1196 1197 let calendarIcon = document.createElement("div"); 1198 calendarIcon.classList.add("cmp-adaptiveform-datepicker__calendar-icon"); 1199 1200 widget.parentNode.insertBefore(calendarIcon, widget.nextSibling); 1201 1202 if (this.#keyboardAccessibility) { 1203 calendarIcon.setAttribute("tabindex", 0); 1204 } 1205 calendarIcon.addEventListener(this.#getEvent(), function (evnt) { 1206 self._iconClicked = true; 1207 widget.click(); 1208 }); 1209 calendarIcon.addEventListener("keydown", function (event) { 1210 if (event.keyCode === 32 || event.keyCode === 13) { 1211 event.preventDefault(); 1212 event.stopPropagation(); 1213 self._iconClicked = true; 1214 widget.click(); 1215 } 1216 }); 1217 this.#calendarIcon = calendarIcon; 1218 if (options.readOnly) { 1219 this.markAsReadOnly(true) 1220 } 1221 } 1222 } 1223 1224 markAsReadOnly(readonly) { 1225 if (readonly) { 1226 this.#calendarIcon.style.display = "none"; 1227 } else { 1228 this.#calendarIcon.style.display = ""; 1229 } 1230 } 1231 1232 #newInst(widget, options) { 1233 return { 1234 $field: widget, 1235 locale: options.locale, 1236 positioning: options.positioning || widget, 1237 access: options.access, 1238 selectedDate: options.value, 1239 editValue: options.editValue, 1240 displayValue: options.displayValue, 1241 minValidDate: options.minimum, 1242 maxValidDate: options.maximum, 1243 exclMinDate: options.exclusiveMinimum, 1244 exclMaxDate: options.exclusiveMaximum 1245 } 1246 } 1247 1248 /* 1249 * To check where the click happened, if happened outside the datepicker 1250 * then hide the picker. This is checked whether any ancestor of clicked target 1251 * has a class datePickerTarget. This class is added to the attached element as well 1252 */ 1253 #checkWindowClicked(evnt) { 1254 let self = this; 1255 if (self.#curInstance) { 1256 // datepickerTarget class depicts that the component is a part of the Date Field 1257 // and on click of that class, we should not hide the datepicker or fire exit events. 1258 if (!evnt.target.closest(".datePickerTarget")) { 1259 //non-touch devices do not deactivate on blur. Hence needs to be done here 1260 if (self.#touchSupported) { 1261 self.#hide(); 1262 //clicking outside a field doesn't blur the field in IPad. Doing it by script 1263 self.#curInstance.$field.blur(); 1264 self.#deactivateField(); 1265 } else { 1266 DatePickerWidget.#clickedWindow = true; 1267 } 1268 } else { 1269 DatePickerWidget.#clickedWindow = false;
1270 } 1271 } 1272 } 1273 1274 /* 1275 * handling of key strokes. All the key strokes prevent the default browser action 1276 * unless specified otherwise 1277 * tab: set focus on calendar icon when dateinput field is active, navigates through date picker buttons when datepicker is open, 1278 * otherwise perform default browser action 1279 * escape: hides the datepicker 1280 * down arrow key: navigate the picker downwards by the number specified in actionView.upDown of the current View 1281 * up arrow key: navigate the picker upwards by the number specified in actionView.upDown of the current View 1282 * left arrow key: navigate the picker one unit of that view backward 1283 * right arrow key: navigate the picker one unit of that view forward 1284 * shift + up: perform the action that happens on clicking the caption (as specified in actionView.caption) 1285 * shift + left: perform the action that happens on clicking the left navigation button 1286 * shift + right: perform the action that happens on clicking the right navigation button 1287 * space/enter: triggers the click event for the current focused element from datepicker/ opens datepicker when calendar icon is focused. 1288 */ 1289 #hotKeys(evnt) { 1290 var handled = false, date; 1291 switch (evnt.keyCode) { 1292 case 9: //tab 1293 // CQ-4239352 : Setting clickedWindow property to true on tabbing so that deactivateField logic gets executed 1294 // When clicking on "x" on input field in in IE and when selecting the content and releasing the mouse select outside the field 1295 // the click event is not trigerred on the field and hence activateField is not executed, so clickedWindow remains as false 1296 DatePickerWidget.#clickedWindow = true; 1297 handled = false; 1298 break; 1299 case 27://escape 1300 if (DatePickerWidget.#visible) { 1301 this.#hide(); 1302 this.#curInstance.$field.focus(); 1303 this.#deactivateField(); 1304 handled = true; 1305 } 1306 break; 1307 case 32: //space 1308 case 13: // enter 1309 if (evnt.target.classList.contains("cmp-adaptiveform-datepicker__calendar-icon")) { 1310 if (!DatePickerWidget.#visible) { 1311 this.#show(); 1312 handled = true; 1313 } else { 1314 this.$focusedDate.classList.add("dp-focus"); 1315 handled = true; 1316 } 1317 } 1318 break; 1319 case 40: //down arrow key 1320 if (!DatePickerWidget.#visible) { 1321 this.#show(); 1322 return; 1323 } 1324 this.$focusedDate.classList.add("dp-focus"); 1325 break; 1326 } 1327 1328 if (DatePickerWidget.#visible && this.#keysEnabled) { 1329 var v = this.#viewAction[this.view].key, 1330 updown = this.#viewAction[this.view].upDown; 1331 switch (evnt.keyCode) { 1332 case 9: // tab 1333 if (evnt.shiftKey) { 1334 if (evnt.target.classList.contains("dp-leftnav") 1335 || evnt.target.classList.contains("dp-focus")) { 1336 this.#hide(); 1337 this.#curInstance.$field.focus(); 1338 handled = true; 1339 } else { 1340 handled = false; 1341 } 1342 } else { 1343 const buttonTabindex = evnt.target.getAttribute("tabindex"); 1344 if (buttonTabindex === '0') { 1345 if (evnt.target.tagName.toLocaleLowerCase() === "input") { 1346 this.#hide(); 1347 handled = false; 1348 } else { 1349 this.prevNavWidthBtn.focus(); 1350 handled = true; 1351 } 1352 } else if (buttonTabindex === '4') { 1353 this.#hide(); 1354 this.#curInstance.$field.focus(); 1355 handled = true; 1356 } else { 1357 handled = false; 1358 } 1359 } 1360 break; 1361 case 32: //select on space 1362 case 13: // select on enter 1363 this.hotKeyPressed = true; 1364 this.#focusedOnLi = false; 1365 if (!this.#focusedOnLi) { 1366 evnt.target.click(); 1367 } else { 1368 if (this.$focusedDate) { 1369 this.$focusedDate.click() //todo 1370 } 1371 } 1372 this.hotKeyPressed = false;
1373 handled = true; 1374 break; 1375 case 37: //left arrow key 1376 if (evnt.shiftKey) { 1377 this.prevNavWidthBtn.click(); 1378 } else { 1379 this.#adjustDate(-1, v, true); 1380 } 1381 handled = true; 1382 break; 1383 case 38: //up arrow key 1384 if (evnt.shiftKey) { 1385 this.caption.click(); 1386 } else { 1387 this.#adjustDate(-updown, v, true); 1388 } 1389 handled = true; 1390 break; 1391 case 39: //right arrow key 1392 if (evnt.shiftKey) { 1393 this.nextNavWidthBtn.click(); 1394 } else { 1395 this.#adjustDate(+1, v, true); 1396 } 1397 handled = true; 1398 break; 1399 case 40: //down arrow key 1400 this.#adjustDate(updown, v, true); 1401 handled = true; 1402 break; 1403 default: 1404 } 1405 } 1406 if (handled) { 1407 evnt.preventDefault(); 1408 } 1409 } 1410 1411 /* 1412 * show the datepicker. //TODO: migrate this to vanilla js 1413 */ 1414 #show() { 1415 this.#options.locale = this.#curInstance.locale; 1416 if (!DatePickerWidget.#visible) { 1417 let date = new Date(), 1418 validDate, 1419 parsedDate; 1420 if (this.#curInstance.selectedDate) { 1421 validDate = this.#curInstance.selectedDate; 1422 } else if (this.#model.valid) { 1423 validDate = this.#model.value; 1424 } 1425 if (validDate) { 1426 parsedDate = validDate ? new Date(validDate) : null; 1427 date = (parsedDate == null || parsedDate == 'Invalid Date') ? date : parsedDate; 1428 } 1429 const timezoneOffset = date.getTimezoneOffset(); 1430 date.setMinutes(date.getMinutes() + timezoneOffset); 1431 this.selectedDay = this.currentDay = date.getDate(); 1432 this.selectedMonth = this.currentMonth = date.getMonth(); 1433 this.selectedYear = this.currentYear = date.getFullYear(); 1434 this.maxValidDate = this.#options.maximum ? new Date( 1435 this.#curInstance.maxValidDate) : null; 1436 this.minValidDate = this.#options.minimum ? new Date( 1437 this.#curInstance.minValidDate) : null; 1438 this.exclMaxDate = this.#curInstance.exclMaxDate; 1439 this.exclMinDate = this.#curInstance.exclMinDate; 1440 this.#dp.getElementsByClassName("dp-clear")[0].getElementsByTagName( 1441 "a")[0].innerText = this.#options.locale.clearText; 1442 this.#layout(this.#defaultView); 1443 this.#dp.style.display = "flex"; 1444 this.#focusedOnLi = false; 1445 DatePickerWidget.#visible = true; 1446 this.#position(); 1447 1448 // Add document touch listener for mobile to close datepicker when tapping outside 1449 if (this.#touchSupported && !this.#documentTouchListener) { 1450 this.#documentTouchListener = (evt) => { 1451 if (DatePickerWidget.#visible && this.#curInstance) { 1452 this.#checkWindowClicked(evt); 1453 } 1454 }; 1455 document.addEventListener("touchstart", this.#documentTouchListener, false); 1456 } 1457 1458 if (this.#options.showCalendarIcon) { 1459 this.#curInstance.$field.setAttribute('readonly', true); // when the datepicker is active, deactivate the field 1460 } 1461 } 1462 1463 // Disabling the focus on ipad due to a bug where value of 1464 // date picker is not being set 1465 // Removing this code will only hamper one use case 1466 // where on ipad if you click on the calander then 1467 // the field becomes read only so 1468 // there is no indication where the current focus is 1469 // And if you remove this foucs code all together 1470 // then what happens is that on desktop MF in iframe the exit event 1471 // is not getting called hence calander getting remained open even 1472 // when you click somewhere on window or focus into some other field 1473 if (this.#options.showCalendarIcon && !this.#touchSupported) { 1474 this.#curInstance.$field.focus(); // field loses focus after being marked readonly, causing blur event not to be fired later 1475 } 1476 } 1477 1478 /* 1479 * position the datepicker around the positioning element //TODO: migrate this to vanilla js 1480 * provided in the options 1481 */ 1482 #position() { 1483 let $elem = this.#curInstance.positioning, 1484 windowScrollX = window.scrollX, 1485 windowScrollY = window.scrollY, 1486 windowInnerHeight = window.innerHeight, 1487 windowInnerWidth = window.innerWidth, 1488 inputRect = $elem.getBoundingClientRect(), 1489 height = $elem.offsetHeight, 1490 top = this.#getOffset($elem).top + height, 1491 left = this.#getOffset($elem).left, 1492 styles = {"top": (top + "px"), "left": (left + "px")}, 1493 diffBottom = top + this.#dp.offsetHeight - windowInnerHeight - windowScrollY, //this.#dp.offsetHeight is the widget's height 1494 newLeft, 1495 newTop; 1496 if (diffBottom > 0) { 1497 //can't appear at the bottom 1498 //check top 1499 newTop = top - height - this.#dp.offsetHeight - 20; 1500 if (newTop < windowScrollY) { 1501 //can't appear at the top as well ... the datePicker pop up overlaps the date field 1502 newTop = top - diffBottom; 1503 } 1504 styles.top = newTop + "px"; 1505 } 1506 if (left + this.#dp.offsetWidth > windowScrollX + windowInnerWidth) { 1507 //align with the right edge 1508 newLeft = windowScrollX + windowInnerWidth - this.#dp.offsetWidth - 20; 1509 styles.left = newLeft + "px"; 1510 } 1511 this.#dp.style.top = styles.top; 1512 this.#dp.style.left = styles.left; 1513 const localeObj = new Intl.Locale(this.#lang); 1514 if(localeObj?.textInfo?.direction == "rtl") { 1515 let right = windowInnerWidth - (left + inputRect.width); // Calculate right offset 1516 if (right + this.#dp.offsetWidth > windowInnerWidth) { // this.#dp.offsetWidth is the widget's width 1517 // Align with the right edge of the viewport 1518 right = windowScrollX + windowInnerWidth - this.#dp.offsetWidth - 20;
1518 // Adjust with a 20px margin 1519 } 1520 this.#dp.style.right = right + "px"; 1521 this.#dp.style.left = "unset" 1522 } 1523 return this; 1524 } 1525 1526 #getOffset(elem) { 1527 let box = elem.getBoundingClientRect(); 1528 return { 1529 top: box.top + window.scrollY, 1530 left: box.left + window.scrollX 1531 }; 1532 } 1533 1534 /* 1535 * layout the nextView. if nextView is null return 1536 * 1537 */ 1538 #layout(nextView) { 1539 if (nextView == null) { 1540 this.#hide(); 1541 } else { 1542 if (this.view) { 1543 this['$' + this.view.toLowerCase()].style.display = "none"; 1544 } 1545 this.view = nextView; 1546 this.caption.classList.toggle("disabled", 1547 !this.#viewAction[this.view].caption); 1548 this['$' + this.view.toLowerCase()].style.display = "block"; 1549 this["show" + this.view](); 1550 } 1551 return this; 1552 } 1553 1554 /* 1555 * show the month view 1556 */ 1557 showMonth() { 1558 var self = this, 1559 curDate = new Date(this.currentYear, this.currentMonth), 1560 maxDay = this.#maxDate(this.currentMonth), 1561 prevMaxDay = this.#maxDate((this.currentMonth + 11) % 12), 1562 day1 = new Date(this.currentYear, this.currentMonth, 1).getDay(), 1563 data, display; 1564 var localizedYear = this.#getLocalizedYear(curDate); 1565 1566 this.#tabulateView( 1567 { 1568 caption: this.#options.locale.months[this.currentMonth] + ", " 1569 + this.#convertNumberToLocale(localizedYear), 1570 header: this.#options.locale.days, 1571 numRows: 7, 1572 numColumns: 7, 1573 elementAt: function (row, col) { 1574 var day = (row - 1) * 7 + col - day1 + 1; 1575 var monthVal = self.currentMonth + 1; 1576 let gridId = "day-" + day; 1577 display = self.#convertNumberToLocale(day); 1578 data = day; 1579 if (day < 1) { 1580 display = self.#convertNumberToLocale(prevMaxDay + day); 1581 data = -1; 1582 monthVal = self.currentMonth; 1583 } else if (day > maxDay) { 1584 display = self.#convertNumberToLocale(day - maxDay); 1585 data = -1; 1586 monthVal = self.currentMonth + 2; 1587 } else { 1588 curDate.setDate(day); 1589 // check if the currentdate is valid based on max and min valid date 1590 if (self.#compareVal(curDate, self.maxValidDate, 1591 self.exclMaxDate) || self.#compareVal(self.minValidDate, 1592 curDate, self.exclMinDate)) { 1593 data = -1; 1594 } 1595 } 1596 return { 1597 data: data, 1598 gridId: gridId, 1599 display: display, 1600 ariaLabel: self.#options.editValue( 1601 self.currentYear + "-" + self.#pad2(monthVal) 1602 + "-" + self.#pad2(display)) 1603 }; 1604 } 1605 }); 1606 } 1607 1608 /**
1609 * returns boolean based on val1, val2, checkEqual 1610 * For comparing date, use date object 1611 */ 1612 #compareVal(val1, val2, checkEqual) { 1613 if (!val1 || !val2) { 1614 return false; 1615 } 1616 1617 if (checkEqual) { 1618 return val1 >= val2; 1619 } else { 1620 return val1 > val2; 1621 } 1622 } 1623 1624 /* 1625 * show the year view 1626 */ 1627 showYear() { 1628 var self = this, 1629 minDate = this.minValidDate ? new Date( 1630 this.minValidDate.getFullYear(), this.minValidDate.getMonth()) 1631 : null, 1632 maxDate = this.maxValidDate ? new Date( 1633 this.maxValidDate.getFullYear(), this.maxValidDate.getMonth()) 1634 : null, 1635 curDate = new Date(this.currentYear, 0), //can't omit month, if only one param present it is treated as millisecond 1636 data, 1637 month; 1638 var localizedYear = this.#getLocalizedYear(curDate); 1639 this.#tabulateView( 1640 { 1641 caption: this.#convertNumberToLocale(localizedYear), 1642 numRows: 4, 1643 numColumns: 3, 1644 elementAt: function (row, col) { 1645 data = month = row * 3 + col; 1646 let gridId = "month-" + data; 1647 curDate.setMonth(month); 1648 if ((minDate && curDate < minDate) || (maxDate && curDate 1649 > maxDate)) { 1650 data = -1; 1651 } 1652 return { 1653 data: data, 1654 gridId: gridId, 1655 display: self.#options.locale.months[month], 1656 ariaLabel: self.#options.locale.months[month] + " " 1657 + self.currentYear 1658 }; 1659 } 1660 }); 1661 } 1662 1663 #getLocalizedYear(date) { 1664 /* 1665 // Only Thai language return year according to Buddhist calendar, rest all languages follows gregorian calendar in practice. 1666 // The Buddhist Year in 2024 = 543 + 2024 = B.E. 2567 (reference https://wesak.org.my/calculating-b-e/) 1667 // Intl.DateTimeFormat#formatToParts returns number (2024) for all languages except for Thai (2567) & for Persian ('Û±Û´Û°Û³') 1668 // For Persian ('Û±Û´Û°Û³'), returned year is not in numbers that is breaking next flow. 1669 */ 1670 if(this.#lang === 'th') { 1671 const dateFormat = new Intl.DateTimeFormat(this.#lang, { 1672 year: 'numeric' 1673 }); 1674 const dateParts = dateFormat.formatToParts(date); 1675 const yearObject = dateParts.find(yearObject => yearObject.type === "year"); 1676 const localizedYear = yearObject.value; 1677 return Number(localizedYear); 1678 } 1679 else { 1680 return Number(date.getFullYear()); 1681 } 1682 } 1683 1684 /* 1685 * show the year set view 1686 */ 1687 showYearset() { 1688 var year, 1689 minDate = this.minValidDate ? new Date( 1690 this.minValidDate.getFullYear(), 0) : null, 1691 maxDate = this.maxValidDate ? new Date( 1692 this.maxValidDate.getFullYear() + 1, 0) : null, 1693 curDate = new Date(), 1694 data, 1695 self = this; 1696 var localizedYear = this.#getLocalizedYear(new Date(this.currentYear, 0)), 1697 localizedYearSet = this.#getLocalizedYear(new Date(self.currentYear, 0)); 1698 1699 this.#tabulateView( 1700 { 1701 caption: this.#convertNumberToLocale( 1702 localizedYear - this.#options.yearsPerView / 2) + "-" 1703 + this.#convertNumberToLocale( 1704 localizedYear - this.#options.yearsPerView / 2 1705 + this.#options.yearsPerView - 1), 1706 numRows: 4, 1707 numColumns: 4, 1708 elementAt: function (row, col) { 1709 data = year = localizedYearSet - 8 + (row * 4 + col); 1710 let gridId = "year-" + data; 1711 curDate.setFullYear(year); 1712 if ((minDate && curDate < minDate) || (maxDate && curDate 1713 > maxDate)) { 1714 data = -1; 1715 } 1716 return { 1717 "data": data, 1718 "gridId": gridId, 1719 "display": self.#convertNumberToLocale(year), 1720 ariaLabel: year 1721 }; 1722 } 1723 }); 1724 } 1725 1726 insertRow(rowNum, rowArray, isHeader, elementAt) { 1727 let $view = this["$" + this.view.toLowerCase()], 1728 $row = $view.getElementsByTagName("ul")[rowNum], 1729 items, $li, element, $tmp, 1730 self = this; 1731 if (!$row) { 1732 let rowEl = document.createElement("ul"); 1733 rowEl.removeAttribute("aria-label"); 1734 rowEl.classList.toggle("header", isHeader); 1735 $row = $view.appendChild(rowEl); 1736 } 1737 items = $row.getElementsByTagName("li").length; 1738 while (items++ < rowArray.length) { 1739 let listItemEl = document.createElement("li"); 1740 listItemEl.id = "li-" + elementAt(rowNum, items).gridId; 1741 $tmp = $row.appendChild(listItemEl); 1742 if (!isHeader) { 1743 let cb = function (evnt) { 1744 self.#selectDate(evnt); 1745 }; 1746 $tmp.addEventListener("click", cb); 1747 } 1748 } 1749 1750 rowArray.forEach(function (el, index) { 1751 $li = $row.getElementsByTagName("li")[index]; 1752 if (isHeader) { 1753 $li.innerText = rowArray[index]; 1754 } else { 1755 element = rowArray[index]; 1756 window.afCache.put($li, "value", element.data); 1757 if (self.#checkDateIsFocussed(element.data)) { 1758 if (self.$focusedDate) { 1759 self.$focusedDate.classList.remove("dp-focus"); 1760 self.$focusedDate.setAttribute("tabindex", "-1"); 1761 } 1762 self.$focusedDate = $li; 1763 if (self.#keysEnabled) { 1764 self.$focusedDate.classList.add("dp-focus") 1765 } 1766 } 1767 $li.setAttribute("title", element.ariaLabel); 1768 $li.setAttribute("aria-label", element.ariaLabel); 1769 $li.setAttribute("tabindex", -1); 1770 $li.classList.toggle("dp-selected", 1771 self.#checkDateIsSelected(element.data)); 1772 $li.classList.toggle("disabled", element.data === -1); 1773 $li.innerText = element.display; 1774 } 1775 }); 1776 return $row; 1777 } 1778 1779 /* 1780 * creates a tabular view based on the options provided. The options that can be passed are 1781 * numRows: number of rows that needs rendering
1782 * numCols: number of columns that needs rendering 1783 * caption: text for the datepickers caption element 1784 * header: an array of elements that identifies the header row 1785 * elementAt: a function(row, column) that returns an object (data: <data>, display: <display>) where 1786 * <data> is the value to set for that view when the element at (row,column) is clicked and 1787 * <display> is the value that will be visible to the user 1788 */ 1789 #tabulateView(options) { 1790 var r = 0, rows = 0, 1791 row = [], 1792 c; 1793 this.caption.innerHTML = options.caption; 1794 if (options.header) { 1795 this.insertRow(r++, options.header, true, options.elementAt); 1796 } 1797 while (r < options.numRows) { 1798 c = 0; 1799 while (c < options.numColumns) { 1800 row[c] = options.elementAt(r, c); 1801 c++; 1802 } 1803 this.insertRow(r++, row, false, options.elementAt); 1804 } 1805 } 1806 1807 #hotKeysCallBack = this.#hotKeys.bind(this); 1808 1809 #activateField(evnt) { 1810 let self = this; 1811 this.#curInstance = window.afCache.get(evnt.target, "datetimepicker"); 1812 // Issue LC-7049: 1813 // datepickerTarget should be added when activate the field and should be removed 1814 // after the fields gets deactivated. 1815 if (this.#options.showCalendarIcon) { 1816 this.#curInstance.$field.parentNode.classList.add("datePickerTarget"); 1817 } 1818 //enable hot keys only for non touch devices 1819 if (!this.#touchSupported && !this.#keysEnabled) { 1820 document.addEventListener("keydown", self.#hotKeysCallBack); 1821 this.#keysEnabled = true; 1822 } 1823 } 1824 1825 #deactivateField() { 1826 let self = this; 1827 if (self.#curInstance) { 1828 if (this.#keysEnabled) { 1829 document.removeEventListener("keydown", self.#hotKeysCallBack); 1830 this.#keysEnabled = false; 1831 } 1832 // Remove document touch listener if it exists 1833 if (this.#documentTouchListener) { 1834 document.removeEventListener("touchstart", this.#documentTouchListener); 1835 this.#documentTouchListener = null; 1836 } 1837 // Issue LC-7049: 1838 // datepickerTarget should be added when activate the field and should be removed 1839 // after the fields gets deactivated. Otherwise clicking on any other datefield 1840 // will not hide the existing datepicker 1841 if (this.#options.showCalendarIcon) { 1842 self.#curInstance.$field.parentNode.classList.remove( 1843 "datePickerTarget"); 1844 } 1845 self.#curInstance = null; 1846 this.#hideAllViews(); 1847 } 1848 } 1849 1850 #hide() { 1851 if (DatePickerWidget.#visible) { 1852 this.#dp.style.display = "none"; 1853 this.#hideAllViews(); 1854 DatePickerWidget.#visible = false; 1855 if (this.#options.showCalendarIcon) { 1856 this.#curInstance.$field.removeAttribute('readonly'); // when the datepicker is deactivated, activate the field 1857 } 1858 } 1859 } 1860 1861 #hideAllViews() { 1862 this['$month'].replaceChildren(); 1863 this['$year'].replaceChildren(); 1864 this['$yearset'].replaceChildren(); 1865 this['$month'].style.display = "none"; 1866 this['$year'].style.display = "none"; 1867 this['$yearset'].style.display = "none"; 1868 } 1869 1870 #adjustDate(step, view, focus) { 1871 let maxDate, prevMaxDate; 1872 let _focus = focus || false; 1873 switch (view.toLowerCase()) { 1874 case "day": 1875 this.currentDay += step; 1876 maxDate = this.#maxDate(this.currentMonth) 1877 if (this.currentDay < 1) { 1878 prevMaxDate = this.#maxDate((this.currentMonth - 1 + 12) % 12); 1879 this.currentDay = prevMaxDate + this.currentDay; 1880 return this.#adjustDate(-1, "month", _focus); 1881 } 1882 if (this.currentDay > maxDate) { 1883 this.currentDay -= maxDate; 1884 return this.#adjustDate(+1, "month", _focus); 1885 } 1886 break; 1887 case "month": 1888 this.currentMonth += step; 1889 if (this.currentMonth > 11) { 1890 this.currentYear++; 1891 this.currentMonth = 0; 1892 } 1893 if (this.currentMonth < 0) { 1894 this.currentYear--; 1895 this.currentMonth = 11; 1896 } 1897 break; 1898 case "year": 1899 this.currentYear += step; 1900 break;
1901 case "yearset": 1902 this.currentYear += step * this.#options.yearsPerView; 1903 break; 1904 } 1905 this.#layout(this.view); 1906 if (_focus) { 1907 this.#focusedOnLi = true; 1908 this.$focusedDate.setAttribute("tabindex", 0); 1909 this.$focusedDate.focus(); 1910 } 1911 } 1912 1913 #checkDateIsSelected(data) { 1914 switch (this.view.toLowerCase()) { 1915 case "month": 1916 return this.currentYear === this.selectedYear && this.currentMonth 1917 === this.selectedMonth && data === this.selectedDay; 1918 case "year": 1919 return this.currentYear === this.selectedYear && this.selectedMonth 1920 === data; 1921 case "yearset": 1922 return this.selectedYear === data; 1923 } 1924 } 1925 1926 #checkDateIsFocussed(data) { 1927 switch (this.view.toLowerCase()) { 1928 case "month": 1929 return data === this.currentDay; 1930 case "year": 1931 return this.currentMonth === data; 1932 case "yearset": 1933 return this.currentYear === data; 1934 } 1935 } 1936 1937 #convertNumberToLocale(number) { 1938 const zeroCode = this.#options.locale.zero.charCodeAt(0); 1939 number += ""; 1940 let newNumber = []; 1941 for (let i = 0; i < number.length; i++) { 1942 newNumber.push( 1943 String.fromCharCode(zeroCode + parseInt(number.charAt(i)))); 1944 } 1945 return newNumber.join(""); 1946 } 1947 1948 #clearDate(view) { 1949 this.#model.dispatch(new FormView.Actions.UIChange({'value': ''})); 1950 let existingSelectedItem = this['$' + view.toLowerCase()].getElementsByClassName("dp-selected")[0]; 1951 if (existingSelectedItem) { 1952 existingSelectedItem.classList.remove("dp-selected"); 1953 } 1954 } 1955 1956 #getEvent() { 1957 return "click";//this.#touchSupported ? "touchstart" : "click"; 1958 } 1959 1960 #pad2(m) { 1961 return m = m < 10 ? "0" + m : m; 1962 } 1963 1964 toString() { 1965 if(this.selectedYear === -1 || this.selectedMonth === -1 || this.selectedDay === -1){ 1966 return ""; 1967 } 1968 const formattedDate = `${this.selectedYear}-${this.#pad2(this.selectedMonth + 1)}-${this.#pad2(this.selectedDay)}`; 1969 return formattedDate; 1970 } 1971 1972 #selectDate(evnt) { 1973 let val = window.afCache.get(evnt.target, "value"), 1974 nextView = this.#viewAction[this.view].li; 1975 1976 //disabled dates have a value of -1. Do nothing in that case 1977 if (val === -1) { 1978 return; 1979 } 1980 switch (this.view.toLowerCase()) { 1981 case "month": 1982 this.selectedMonth = this.currentMonth; 1983 this.selectedYear = this.currentYear; 1984 this.selectedDay = val; 1985 this.setValue(this.toString()); 1986 this.#model.dispatch(new FormView.Actions.UIChange({'value': this.toString()})); // updating model value to the latest when calender is changed 1987 this.#curInstance.$field.focus(); 1988 let existingSelectedElement = this['$' 1989 + this.view.toLowerCase()].getElementsByClassName("dp-selected")[0]; 1990 if (existingSelectedElement) { 1991 existingSelectedElement.classList.remove("dp-selected"); 1992 } 1993 evnt.target.classList.add("dp-selected"); 1994 break; 1995 case "year": 1996 this.currentMonth = val; 1997 break;
1998 case "yearset": 1999 this.currentYear = val; 2000 break; 2001 } 2002 this.#layout(nextView); 2003 //manually focus on the field if clicked on the popup buttons for non-touch device 2004 if (!this.#touchSupported) { 2005 //No need to focus if selection is made by pressing space. 2006 if (!this.hotKeyPressed) { 2007 this.#scriptFocus = true; 2008 } 2009 } else if (nextView == null) { 2010 //For touch devices, deactivate the field if a selection is made 2011 this.#deactivateField() 2012 } 2013 } 2014 2015 #leapYear() { 2016 return this.currentYear % 400 === 0 || (this.currentYear % 100 !== 0 2017 && this.currentYear % 4 === 0); 2018 } 2019 2020 #maxDate(m) { 2021 if (this.#leapYear() && m === 1) { 2022 return 29; 2023 } else { 2024 return this.#dates[m]; 2025 } 2026 } 2027 2028 #localizeDateElements(defaultOptions, locale) { 2029 var calendarSymbols = FormView.LanguageUtils.getTranslatedString(locale, "calendarSymbols"); 2030 if (calendarSymbols && calendarSymbols.abbrdayNames) { 2031 defaultOptions.locale.days = calendarSymbols.abbrdayNames; 2032 } 2033 if (calendarSymbols && calendarSymbols.abbrdayNames) { 2034 defaultOptions.locale.months = calendarSymbols.monthNames; 2035 } 2036 var clearText = FormView.LanguageUtils.getTranslatedString(locale, "clearText"); 2037 if (clearText) { 2038 defaultOptions.locale.clearText = clearText; 2039 } 2040 var zero = FormView.LanguageUtils.getTranslatedString(locale, "0"); 2041 if (zero) { 2042 defaultOptions.locale.zero = zero; 2043 } 2044 } 2045 2046 #isEditValueOrDisplayValue(value) { 2047 return (this.#model.editValue === value || this.#model.displayValue 2048 === value); 2049 } 2050 2051 /** 2052 * returns the original value of format YYYY-MM-DD 2053 * @returns {*|string} 2054 */ 2055 getValue() { 2056 if (this.#isEditValueOrDisplayValue(this.#widget.value)) { 2057 return this.#model.value; // if the widget has edit/display value thiss method should return model value 2058 } 2059 return this.#widget.value; 2060 } 2061 2062 /** 2063 * Sets the formatted display value on the widget. 2064 * value should be in YYYY-MM-DD format 2065 * @param value 2066 */ 2067 setDisplayValue(value) { 2068 if (this.#curInstance != null) { 2069 this.#curInstance.$field.value = this.#curInstance.displayValue( 2070 this.toString()) || value; 2071 } else { 2072 this.#widget.value = this.#model.displayValue || value; 2073 } 2074 } 2075 2076 setCalendarWidgetValue(value) { 2077 if (this.#curInstance === null && this.#widget != null) { 2078 this.#curInstance = window.afCache.get(this.#widget, "datetimepicker"); 2079 } 2080 if (this.#curInstance != null) { 2081 // also change the date of the calendar widget 2082 this.#curInstance.selectedDate = value; 2083 } 2084 } 2085 2086 /** 2087 * Sets the formatted edit value on the widget 2088 * @param value 2089 */ 2090 2091 setValue(value) { 2092 let currDate; 2093 if (value instanceof Date && !isNaN(value)) { 2094 // If value is already a Date object and it's valid, use it as is 2095 currDate = value; 2096 } else { 2097 // Otherwise, construct a new Date object 2098 currDate = new Date(value); 2099 const timezoneOffset = currDate.getTimezoneOffset(); 2100 currDate.setMinutes(currDate.getMinutes() + timezoneOffset); 2101 } 2102 2103 if (!isNaN(currDate) && value != null) { 2104 //in case the value is directly updated from the field without using calendar widget 2105 this.selectedMonth = currDate.getMonth(); 2106 this.selectedYear = currDate.getFullYear(); 2107 this.selectedDay = currDate.getDate(); 2108 } else { 2109 this.selectedYear 2110 = this.selectedMonth 2111 = this.selectedYear 2112 = -1; 2113 } 2114 if (this.#curInstance != null) { 2115 if (!this.#isEditValueOrDisplayValue(value)) { 2116 this.#curInstance.selectedDate = value; // prevent edit/display value from getting set in calender 2117 } 2118 this.#curInstance.$field.value = this.#curInstance.editValue() || value; 2119 } else { 2120 this.#widget.value = value; 2121 } 2122 } 2123 2124 addEventListener(event, handler, widget) { 2125 let inst = window.afCache.get(widget, "datetimepicker"); 2126 inst.$field.addEventListener(event, function (e) { 2127 switch (e.type) { 2128 case 'blur': 2129 if (!DatePickerWidget.#visible) { 2130 handler(e); 2131 } 2132 break; 2133 case 'focus': 2134 handler(e); 2135 break; 2136 case 'input': 2137 handler(e); 2138 break; 2139 2140 } 2141 }); 2142 } 2143 2144 } 2145 2146} 2147 2148/******************************************************************************* 2149 * Copyright 2022 Adobe 2150 * 2151 * Licensed under the Apache License, Version 2.0 (the "License");
2152 * you may not use this file except in compliance with the License. 2153 * You may obtain a copy of the License at 2154 * 2155 * http://www.apache.org/licenses/LICENSE-2.0 2156 * 2157 * Unless required by applicable law or agreed to in writing, software 2158 * distributed under the License is distributed on an "AS IS" BASIS, 2159 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2160 * See the License for the specific language governing permissions and 2161 * limitations under the License. 2162 ******************************************************************************/ 2163(function() { 2164 2165 "use strict"; 2166 class TextInput extends FormView.FormFieldBase { 2167 2168 static NS = FormView.Constants.NS; 2169 /** 2170 * Each FormField has a data attribute class that is prefixed along with the global namespace to 2171 * distinguish between them. If a component wants to put a data-attribute X, the attribute in HTML would be 2172 * data-{NS}-{IS}-x="" 2173 * @type {string} 2174 */ 2175 static IS = "adaptiveFormTextInput"; 2176 static bemBlock = 'cmp-adaptiveform-textinput' 2177 static selectors = { 2178 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 2179 widget: `.${TextInput.bemBlock}__widget`, 2180 label: `.${TextInput.bemBlock}__label`, 2181 description: `.${TextInput.bemBlock}__longdescription`, 2182 qm: `.${TextInput.bemBlock}__questionmark`, 2183 errorDiv: `.${TextInput.bemBlock}__errormessage`, 2184 tooltipDiv: `.${TextInput.bemBlock}__shortdescription` 2185 }; 2186 2187 constructor(params) { 2188 super(params); 2189 } 2190 2191 getWidget() { 2192 return this.element.querySelector(TextInput.selectors.widget); 2193 } 2194 2195 getDescription() { 2196 return this.element.querySelector(TextInput.selectors.description); 2197 } 2198 2199 getLabel() { 2200 return this.element.querySelector(TextInput.selectors.label); 2201 } 2202 2203 getErrorDiv() { 2204 return this.element.querySelector(TextInput.selectors.errorDiv); 2205 } 2206 2207 getTooltipDiv() { 2208 return this.element.querySelector(TextInput.selectors.tooltipDiv); 2209 } 2210 2211 getQuestionMarkDiv() { 2212 return this.element.querySelector(TextInput.selectors.qm); 2213 } 2214 2215 setModel(model) { 2216 super.setModel(model); 2217 if (this.widget.value !== '') { 2218 this.setModelValue(this.widget.value); 2219 } 2220 this.widget.addEventListener('blur', (e) => { 2221 this.setModelValue(e.target.value); 2222 this.setWidgetValueToDisplayValue(); 2223 this.setInactive(); 2224 }); 2225 this.widget.addEventListener('focus', (e) => { 2226 this.setActive(); 2227 this.setWidgetValueToModelValue(); 2228 }); 2229 if (model.fieldType === "multiline-input") { 2230 this.widget.addEventListener('keydown', (event) => { 2231 if (event.key === 'Enter') { 2232 // Prevent default action of Enter key to avoid form submission 2233 event.preventDefault(); 2234 // Add a newline character to the widget value 2235 let cursorPosition = this.widget.selectionStart; 2236 let textBefore = this.widget.value.substring(0, cursorPosition); 2237 let textAfter = this.widget.value.substring(this.widget.selectionEnd); 2238 this.widget.value = textBefore + '\n' + textAfter; 2239 this.widget.selectionStart = this.widget.selectionEnd = cursorPosition + 1; 2240 } 2241 }); 2242 } 2243 } 2244 } 2245 2246 FormView.Utils.setupField(({element, formContainer}) => { 2247 return new TextInput({element, formContainer}) 2248 }, TextInput.selectors.self); 2249 2250})(); 2251 2252/******************************************************************************* 2253 * Copyright 2022 Adobe 2254 * 2255 * Licensed under the Apache License, Version 2.0 (the "License"); 2256 * you may not use this file except in compliance with the License. 2257 * You may obtain a copy of the License at 2258 * 2259 * http://www.apache.org/licenses/LICENSE-2.0 2260 * 2261 * Unless required by applicable law or agreed to in writing, softw
2261are 2262 * distributed under the License is distributed on an "AS IS" BASIS, 2263 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2264 * See the License for the specific language governing permissions and 2265 * limitations under the License. 2266 ******************************************************************************/ 2267(function() { 2268 2269 "use strict"; 2270 class TelephoneInput extends FormView.FormFieldBase { 2271 2272 static NS = FormView.Constants.NS; 2273 /** 2274 * Each FormField has a data attribute class that is prefixed along with the global namespace to 2275 * distinguish between them. If a component wants to put a data-attribute X, the attribute in HTML would be 2276 * data-{NS}-{IS}-x="" 2277 * @type {string} 2278 */ 2279 static IS = "adaptiveFormTelephoneInput"; 2280 static bemBlock = 'cmp-adaptiveform-telephoneinput' 2281 static selectors = { 2282 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 2283 widget: `.${TelephoneInput.bemBlock}__widget`, 2284 label: `.${TelephoneInput.bemBlock}__label`, 2285 description: `.${TelephoneInput.bemBlock}__longdescription`, 2286 qm: `.${TelephoneInput.bemBlock}__questionmark`, 2287 errorDiv: `.${TelephoneInput.bemBlock}__errormessage`, 2288 tooltipDiv: `.${TelephoneInput.bemBlock}__shortdescription` 2289 }; 2290 2291 constructor(params) { 2292 super(params); 2293 } 2294 2295 getWidget() { 2296 return this.element.querySelector(TelephoneInput.selectors.widget); 2297 } 2298 2299 getDescription() { 2300 return this.element.querySelector(TelephoneInput.selectors.description); 2301 } 2302 2303 getLabel() { 2304 return this.element.querySelector(TelephoneInput.selectors.label); 2305 } 2306 2307 getErrorDiv() { 2308 return this.element.querySelector(TelephoneInput.selectors.errorDiv); 2309 } 2310 2311 getTooltipDiv() { 2312 return this.element.querySelector(TelephoneInput.selectors.tooltipDiv); 2313 } 2314 2315 getQuestionMarkDiv() { 2316 return this.element.querySelector(TelephoneInput.selectors.qm); 2317 } 2318 2319 setModel(model) { 2320 super.setModel(model); 2321 if (this.widget.value !== '') { 2322 this.setModelValue(this.widget.value); 2323 } 2324 this.widget.addEventListener('blur', (e) => { 2325 this.setModelValue(e.target.value); 2326 this.setWidgetValueToDisplayValue(); 2327 this.setInactive(); 2328 }); 2329 this.widget.addEventListener('focus', (e) => { 2330 this.setActive(); 2331 this.setWidgetValueToModelValue(); 2332 }); 2333 } 2334 } 2335 2336 FormView.Utils.setupField(({element, formContainer}) => { 2337 return new TelephoneInput({element, formContainer}) 2338 }, TelephoneInput.selectors.self); 2339 2340})(); 2341 2342/******************************************************************************* 2343 * Copyright 2022 Adobe 2344 * 2345 * Licensed under the Apache License, Version 2.0 (the "License"); 2346 * you may not use this file except in compliance with the License. 2347 * You may obtain a copy of the License at 2348 * 2349 * http://www.apache.org/licenses/LICENSE-2.0 2350 * 2351 * Unless required by applicable law or agreed to in writing, software 2352 * distributed under the License is distributed on an "AS IS" BASIS, 2353 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2354 * See the License for the specific language governing permissions and 2355 * limitations under the License. 2356 ******************************************************************************/ 2357(function() { 2358 2359 "use strict"; 2360 class EmailInput extends FormView.FormFieldBase { 2361 2362 static NS = FormView.Constants.NS; 2363 /** 2364 * Each FormField has a data attribute class that is prefixed along with the global namespace to 2365 * distinguish between them. If a component wants to put a data-attribute X, the attribute in HTML would be 2366 * data-{NS}-{IS}-x="" 2367 * @type {string} 2368 */ 2369 static IS = "adaptiveFormEmailInput"; 2370 static bemBlock = 'cmp-adaptiveform-emailinput' 2371 static selectors = { 2372 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 2373 widget: `.${EmailInput.bemBlock}__widget`, 2374 label: `.${EmailInput.bemBlock}__label`, 2375 description: `.${EmailInput.bemBlock}__longdescription`, 2376 qm: `.${EmailInput.bemBlock}__questionmark`, 2377 errorDiv: `.${EmailInput.bemBlock}__errormessage`, 2378 tooltipDiv: `.${EmailInput.bemBlock}__shortdescription` 2379 }; 2380 2381 constructor(params) { 2382 super(params); 2383 } 2384 2385 getWidget() { 2386 return this.element.querySelector(EmailInput.selectors.widget); 2387 } 2388 2389 getDescription() { 2390 return this.element.querySelector(EmailInput.selectors.description); 2391 } 2392 2393 getLabel() { 2394 return this.element.querySelector(EmailInput.selectors.label); 2395 } 2396 2397 getErrorDiv() { 2398 return this.element.querySelector(EmailInput.selectors.errorDiv); 2399 } 2400 2401 getTooltipDiv() { 2402 return this.element.querySelector(EmailInput.selectors.tooltipDiv); 2403 } 2404 2405 getQuestionMarkDiv() { 2406 return this.element.querySelector(EmailInput.selectors.qm); 2407 } 2408 2409 setModel(model) { 2410 super.setModel(model); 2411 if (this.widget.value !== '') { 2412 this.setModelValue(this.widget.value); 2413 } 2414 this.widget.addEventListener('blur', (e) => { 2415 this.setModelValue(e.target.value); 2416 this.setWidgetValueToDisplayValue(); 2417 this.setInactive(); 2418 }); 2419 this.widget.addEventListener('focus', (e) => { 2420 this.setActive(); 2421 this.setWidgetValueToModelValue(); 2422 }); 2423 } 2424 } 2425 2426 FormView.Utils.setupField(({element, formContainer}) => { 2427 return new EmailInput({element, formContainer}) 2428 }, EmailInput.selectors.self); 2429 2430})(); 2431 2432/******************************************************************************* 2433 * Copyright 2022 Adobe 2434 * 2435 * Licensed under the Apache License, Version 2.0 (the "License");
2436 * you may not use this file except in compliance with the License. 2437 * You may obtain a copy of the License at 2438 * 2439 * http://www.apache.org/licenses/LICENSE-2.0 2440 * 2441 * Unless required by applicable law or agreed to in writing, software 2442 * distributed under the License is distributed on an "AS IS" BASIS, 2443 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2444 * See the License for the specific language governing permissions and 2445 * limitations under the License. 2446 ******************************************************************************/ 2447 2448/** 2449 * This class is responsible for interacting with the numeric input widget. It implements edit/display format 2450 * for numeric input, along with the following features 2451 * - Convert's input type number to text to support display/edit format (for example `$` symbol) 2452 * - One cannot type or paste alphabets in the html input element 2453 */ 2454 2455 if (typeof window.NumericInputWidget === 'undefined') { 2456 2457 window.NumericInputWidget = class { 2458 #widget=null 2459 #model=null // passed by reference 2460 #options=null 2461 #defaultOptions={ 2462 value : null, 2463 curValue: null, 2464 pos: 0, 2465 lengthLimitVisible: true, 2466 zero:"0", 2467 decimal:".", 2468 minus:"-" 2469 } 2470 //TODO: to support writing in different locales \d should be replaced by [0-9] for different locales 2471 #matchArray ={ 2472 "integer":"^[+-]?{digits}*$" 2473 } 2474 #regex=null 2475 #processedValue=null 2476 #engRegex=null 2477 #writtenInLocale=false 2478 #previousCompositionVal="" 2479 2480 #toLatinForm (halfOrFullWidthStr) { 2481 // refer http://www.fileformat.info/info/unicode/block/halfwidth_and_fullwidth_forms/utf8test.htm 2482 return halfOrFullWidthStr.replace( 2483 /[\uff00-\uffef]/g, 2484 function(ch) { return String.fromCharCode(ch.charCodeAt(0) - 0xfee0); } 2485 ); 2486 } 2487 2488 constructor(widget, model) { 2489 // initialize the widget and model 2490 this.#widget = widget; 2491 this.#model = model; 2492 // initialize options for backward compatibility 2493 this.#options = Object.assign({}, this.#defaultOptions, this.#model._jsonModel); 2494 let matchStr = this.#matchArray[this.#options.type]; 2495 if(matchStr) { 2496 let ld = this.#options.leadDigits, 2497 fd = this.#options.fracDigits, 2498 ldstr = ld && ld !== -1 ? "{0,"+ld+"}" 2499 : "*", 2500 fdstr = fd && fd !== -1 ? "{0,"+fd+"}" 2501 : "*"; 2502 matchStr = matchStr.replace("{leading}",ldstr) 2503 .replace("{fraction}",fdstr); 2504 let localeStr = matchStr.replace(/{digits}/g,this.#getDigits()) 2505 .replace("{decimal}",this.#escape(this.#options.decimal)), 2506 engStr = matchStr.replace(/{digits}/g,"[0-9]") 2507 .replace("{decimal}","\\.") 2508 this.#processedValue = !(this.#getDigits() === "[0123456789]" && this.#options.decimal === ".") 2509 this.#regex = new RegExp(localeStr, "g"); 2510 this.#engRegex = new RegExp(engStr, "g"); 2511 } 2512 2513 // change the input type to text for patterns 2514 this.#widget.setAttribute("type", "text"); 2515 this.#attachEventHandlers(widget); 2516 } 2517 2518 #attachEventHandlers(widget, model) { 2519 widget.addEventListener('keydown', (e)=> { 2520 this.#handleKeyDown(e); 2521 }); 2522 widget.addEventListener('keypress', (e)=> { 2523 this.#handleKeyPress(e); 2524 }); 2525 widget.addEventListener('focus', (e)=> { 2526 this.#widget.value = this.#model.value; 2527 }); 2528 widget.addEventListener('paste', (e)=> { 2529 this.#handlePaste(e); 2530 }); 2531 widget.addEventListener('cut', (e)=> { 2532 this.#handleCut(e); 2533 }); 2534 widget.addEventListener('blur', (e) => { 2535 this.#model.dispatch(new FormView.Actions.UIChange({'value': this.getValue(e.target.value)})); 2536 this.#widget.value = this.#model.displayValue; 2537 }); 2538 // IME specific handling, to handle japanese languages max limit 2539 this.#attachCompositionEventHandlers(widget); 2540 } 2541 2542 #attachCompositionEventHandlers(widget) { 2543 let isComposing = false; // IME Composing going on 2544 let hasCompositionJustEnded = false; // Used to swallow keyup event related to compositionend 2545 // IME specific handling, to handle japanese languages max limit 2546 // since enter can also be invoked during composing, a special handling is done here 2547 let that = this, 2548 changeCaratPosition = function() { 2549 // change the carat selection position to further limit input of characters 2550 let range = window.getSelection(); 2551 range.selectAllChildren(widget); 2552 range.collapseToEnd(); 2553 }; 2554 widget.addEventListener('keyup', function(event) { 2555 if (/*isComposing || */hasCompositionJustEnded) { 2556 if (that.#compositionUpdateCallback(event)) { 2557 changeCaratPosition(); 2558 } 2559 // IME composing fires keydown/keyup events 2560 hasCompositionJustEnded = false;
2561 } 2562 }); 2563 widget.addEventListener('compositionstart', 2564 function(event) { 2565 isComposing = true; 2566 }); 2567 widget.addEventListener("compositionupdate", 2568 function(event) { 2569 // event.originalEvent.data refers to the actual content 2570 if (that.#compositionUpdateCallback(event)) { 2571 changeCaratPosition(); 2572 } 2573 }); 2574 widget.addEventListener("compositionend", 2575 function(event) { 2576 isComposing = false; 2577 // some browsers (IE, Firefox, Safari) send a keyup event after 2578 // compositionend, some (Chrome, Edge) don't. This is to swallow 2579 // the next keyup event, unless a keydown event happens first 2580 hasCompositionJustEnded = true; 2581 }); 2582 widget.addEventListener("keydown", 2583 function(event) { 2584 // Safari on OS X may send a keydown of 229 after compositionend 2585 if (event.which !== 229) { 2586 hasCompositionJustEnded = false; 2587 } 2588 }); 2589 } 2590 2591 #getDigits() { 2592 let zeroCode = this.#options.zero.charCodeAt(0), 2593 digits = ""; 2594 for(let i = 0;i < 10;i++) { 2595 digits += String.fromCharCode(zeroCode + i); 2596 } 2597 return "["+digits+"]" 2598 } 2599 2600 #escape(str) { 2601 return str.replace(".", "\\.") 2602 } 2603 2604 2605 getValue(value) { 2606 // we support full width, half width and locale specific numbers 2607 value = this.#toLatinForm(value); 2608 if(value.length > 0 && this.#processedValue && !value.match(this.#engRegex)) { 2609 this.#writtenInLocale = true; 2610 value = this.#convertValueFromLocale(value); 2611 } else { 2612 this.#writtenInLocale = false 2613 } 2614 if(value && value.length >= this.#options.combCells ) 2615 value = value.slice(0,this.#options.combCells); 2616 this.#previousCompositionVal = value; 2617 return value; 2618 } 2619 2620 #compositionUpdateCallback(event) { 2621 let that = this; 2622 let flag = false; 2623 let leadDigits = that.#options.leadDigits; 2624 let fracDigits = that.#options.fracDigits; 2625 // we don't check use-case where just fracDigits is set since in case of composition update, the value to update is not known 2626 if (leadDigits !== -1) { 2627 let val = this.#widget.value; 2628 if (event.type === "compositionupdate" && event.originalEvent.data) { 2629 val = val + event.originalEvent.data.substr(event.originalEvent.data.length - 1); 2630 } 2631 // can't use the existing regex (since current regex checks for english digits), rather doing leadDigit compare 2632 let totalLength = leadDigits + (fracDigits !== -1 ? (fracDigits + that.#options.decimal.length) : 0); 2633 if (val.indexOf(that.#options.decimal) === -1) { 2634 totalLength = leadDigits; 2635 } 2636 let latinVal = this.#toLatinForm(val); 2637 // match both since we support full width, half width and locale specific input 2638 let match = latinVal.match(that.#regex)|| latinVal.match(this.#engRegex); 2639 flag = !match; 2640 if (match === null) { 2641 // entered invalid character, revert to previous value 2642 that.#widget.value = that.#previousCompositionVal; 2643 flag = true; 2644 } else if (flag) { 2645 // if max reached 2646 let newVal = val.substr(0, totalLength); 2647 that.#widget.value = newVal; 2648 that.#previousCompositionVal = newVal; 2649 flag = true; 2650 } else { 2651 that.#previousCompositionVal = val; 2652 } 2653 } 2654 return flag; 2655 } 2656 2657 trigger(event, detail) { 2658 if (!this.#widget) { 2659 return this; 2660 } 2661 const eventName = event.split('.')[0]; 2662 const isNativeEvent = 2663 typeof document.body[`on${eventName}`] !== 'undefined'; 2664 if (isNativeEvent) {
2665 this.#widget.dispatchEvent(new Event(eventName)); 2666 return this; 2667 } 2668 const customEvent = new CustomEvent(eventName, { 2669 detail: detail || null, 2670 }); 2671 this.#widget.dispatchEvent(customEvent); 2672 return this; 2673 } 2674 2675 getHTMLSupportedAttr(domElement, attr){ 2676 try{ 2677 return domElement[attr]; 2678 } 2679 catch (err){ 2680 return undefined; 2681 } 2682 } 2683 2684 #handleKeyInput(event, character, code){ 2685 if(event.ctrlKey && !(['paste', 'cut'].includes(event.type))) { 2686 return true; 2687 } 2688 2689 this.#handleKeyDown(arguments); 2690 this.#options.lengthLimitVisible = true; 2691 let val = this.#widget.value, 2692 // if selectionStart attribute isn't supported then its value will be undefined 2693 selectionStart = this.getHTMLSupportedAttr(this.#widget, "selectionStart") || 0, 2694 isSelectionAttrSupported = !(selectionStart === undefined || selectionStart === null), 2695 selectionEnd = this.getHTMLSupportedAttr(this.#widget, "selectionEnd") || 0, 2696 combCells = parseInt(this.#options.combCells) || 0, 2697 current, 2698 change = character; 2699 2700 if (combCells > 0 ) { 2701 change = character.substr(0, combCells - val.length + selectionEnd - selectionStart); 2702 } 2703 2704 // CQ-4245407 : selectionStart and selectionEnd attributes aren't supported in case of input type = number 2705 // it is used for providing native HTML5 implementation for numeric field, so no further processing is required 2706 // As it is specific to AF and AF doesn't support change event on each keypress, so this change should be fine 2707 if (!isSelectionAttrSupported) { 2708 return true; 2709 } 2710 2711 current = val.substr(0, selectionStart) + change + val.substr(selectionEnd); 2712 // done to handle support for both full width, half width or mixed input in number field 2713 let latinCurrentValue = this.#toLatinForm(current); 2714 2715 if (!(this.#regex == null || latinCurrentValue.match(this.#regex) || latinCurrentValue.match(this.#engRegex))) { 2716 event.preventDefault(); 2717 return false; 2718 } 2719 if (!(['keydown', 'cut'].includes(event.type)) && combCells && (val.length >= combCells || current.length > combCells) && selectionStart === selectionEnd) { 2720 event.preventDefault(); 2721 return false; 2722 } 2723 2724 this.#options.curValue = val; 2725 this.#previousCompositionVal = val; 2726 this.#options.pos = selectionStart; 2727 } 2728 2729 #handleKeyDown(event){ 2730 if (event) { 2731 let code = event.charCode || event.which || event.keyCode || 0; 2732 if(code === 8 || code === 46) // backspace and del 2733 this.#handleKeyInput(event, "", code); 2734 else if(code === 32) { // suppress space 2735 event.preventDefault(); 2736 return false; 2737 } 2738 } 2739 } 2740 2741 #isValidChar(character) { 2742 character = this.#toLatinForm(character); 2743 let lastSingleDigitChar = String.fromCharCode(this.#options.zero.charCodeAt(0) + 9); 2744 // we only full width, half width and also locale specific if customer has overlayed the i18n file 2745 return (character >= "0" && character <= "9") || (character>=this.#options.zero && character<=lastSingleDigitChar) || character===this.#options.decimal || character===this.#options.minus; 2746 } 2747 2748 isNonPrintableKey(key) { 2749 return (key // In IE, event.key returns words instead of actual characters for some keys. 2750 && !['MozPrintableKey','Divide','Multiply','Subtract','Add','Enter','Decimal','Spacebar','Del'].includes(key) 2751 && key.length !== 1 ) 2752 } 2753 2754 #handleKeyPress(event){ 2755 if (event) { 2756 let code = event.charCode || event.which || event.keyCode || 0, 2757 character = String.fromCharCode(code); 2758 2759 if(this.isNonPrintableKey(event.key)) { // mozilla also generates a keypress, along with keydown 2760 return true; // for all keys, so only handling printable keys in keypress 2761 } 2762 2763 if (this.#isValidChar(character)) 2764 this.#handleKeyInput(event, character, code); 2765 else if (!event.ctrlKey){ 2766 event.preventDefault(); 2767 return false;
2768 } 2769 } 2770 } 2771 2772 #handlePaste(event){ 2773 if (event) { 2774 // get the contents 2775 let pastedChar = undefined; 2776 if (window.clipboardData && window.clipboardData.getData) { // IE 2777 pastedChar = window.clipboardData.getData('Text'); 2778 } else if ((event.originalEvent || event).clipboardData && (event.originalEvent || event).clipboardData.getData) { 2779 pastedChar = (event.originalEvent || event).clipboardData.getData('text/plain'); 2780 } 2781 2782 if(pastedChar) { 2783 let allPastedCharsValid = pastedChar.split('').every(function (character) { 2784 return this.#isValidChar(character); 2785 }, this); 2786 if (allPastedCharsValid) { 2787 // during paste we support both half width, full width and locale specific numbers 2788 pastedChar = this.#toLatinForm(pastedChar); 2789 this.#handleKeyInput(event, pastedChar, 0); 2790 } 2791 else if (!event.ctrlKey) { 2792 event.preventDefault(); 2793 return false; 2794 } 2795 } 2796 } 2797 } 2798 2799 #handleCut(event) { 2800 if (event) { 2801 this.#handleKeyInput(event, "", 0); 2802 } 2803 } 2804 2805 #convertValueToLocale(val) { 2806 let zeroCode = this.#options.zero.charCodeAt(0); 2807 return val.map(function(c) { 2808 if(c === ".") { 2809 return this.#options.decimal; 2810 } else if(c === "-") { 2811 return this.#options.minus; 2812 } else { 2813 return String.fromCharCode(parseInt(c) + zeroCode); 2814 } 2815 },this).join(""); 2816 } 2817 2818 #convertValueFromLocale(val) { 2819 val = this.#toLatinForm(val); 2820 let zeroCode = this.#options.zero.charCodeAt(0); 2821 return val.map(function(c) { 2822 if(c === this.#options.decimal) { 2823 return "."; 2824 } else if(c === this.#options.minus) { 2825 return "-"; 2826 } else { 2827 return (c.charCodeAt(0) - zeroCode).toString(); 2828 } 2829 },this).join(""); 2830 } 2831 2832 /** 2833 * Checks if the edit value is same as value present in the user control(html form element) 2834 * @returns {boolean} 2835 */ 2836 #isValueSame() { 2837 return (((this.#model.value === null) && (this.#widget.value === "")) || (this.#model.value === this.#widget.value)); 2838 } 2839 2840 setValue(value) { 2841 // if the value is same, don't do anything 2842 if(!this.#isValueSame()){ 2843 if(value && this.#writtenInLocale) { 2844 this.#widget.value = this.#convertValueToLocale(value); 2845 } else { 2846 this.#widget.value= this.#model.displayValue; 2847 } 2848 } 2849 } 2850 } 2851 } 2852 2853 2854/******************************************************************************* 2855 * Copyright 2022 Adobe 2856 * 2857 * Licensed under the Apache License, Version 2.0 (the "License"); 2858 * you may not use this file except in compliance with the License. 2859 * You may obtain a copy of the License at 2860 * 2861 * http://www.apache.org/licenses/LICENSE-2.0 2862 * 2863 * Unless required by applicable law or agreed to in writing, software 2864 * distributed under the License is distributed on an "AS IS" BASIS, 2865 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2866 * See the License for the specific language governing permissions and 2867 * limitations under the License. 2868 ******************************************************************************/ 2869(function() { 2870 2871 "use strict"; 2872 class NumberInput extends FormView.FormFieldBase { 2873 2874 static NS = FormView.Constants.NS; 2875 static IS = "adaptiveFormNumberInput"; 2876 static bemBlock = 'cmp-adaptiveform-numberinput'; 2877 static selectors = { 2878 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 2879 widget: `.${NumberInput.bemBlock}__widget`, 2880 label: `.${NumberInput.bemBlock}__label`, 2881 description: `.${NumberInput.bemBlock}__longdescription`, 2882 errorDiv: `.${NumberInput.bemBlock}__errormessage`, 2883 qm: `.${NumberInput.bemBlock}__questionmark`, 2884 tooltipDiv: `.${NumberInput.bemBlock}__shortdescription` 2885 }; 2886 2887 constructor(params) { 2888 super(params); 2889 } 2890 2891 getClass() { 2892 return NumberInput.IS; 2893 } 2894 2895 getWidget() { 2896 return this.element.querySelector(NumberInput.selectors.widget); 2897 } 2898 2899 getDescription() { 2900 return this.element.querySelector(NumberInput.selectors.description); 2901 } 2902 2903 getLabel() { 2904 return this.element.querySelector(NumberInput.selectors.label); 2905 } 2906 2907 getErrorDiv() { 2908 return this.element.querySelector(NumberInput.selectors.errorDiv); 2909 } 2910 2911 getTooltipDiv() { 2912 return this.element.querySelector(NumberInput.selectors.tooltipDiv); 2913 } 2914 2915 getQuestionMarkDiv() { 2916 return this.element.querySelector(NumberInput.selectors.qm); 2917 } 2918 2919 initializeWidget() {
2920 this.widgetObject = new NumericInputWidget(this.getWidget(), this._model); 2921 this.getWidget().addEventListener('blur', (e) => { 2922 if(this.element) { 2923 this.setInactive(); 2924 } 2925 }); 2926 } 2927 2928 updateValue(value) { 2929 if (this.widgetObject == null && (this._model._jsonModel.editFormat || this._model._jsonModel.displayFormat || FormView.Utils.isUserAgent('safari'))) { 2930 this.initializeWidget(); 2931 } 2932 if (this.widgetObject) { 2933 this.widgetObject.setValue(value); 2934 super.updateEmptyStatus(); 2935 } else { 2936 super.updateValue(value); 2937 } 2938 } 2939 2940 setModel(model) { 2941 super.setModel(model); 2942 // only initialize if patterns are set 2943 if (this._model._jsonModel.editFormat || this._model._jsonModel.displayFormat || this._model._jsonModel.displayValueExpression 2944 || this._model._jsonModel.type === 'integer' || FormView.Utils.isUserAgent('safari')) { 2945 if (this.widgetObject == null) { 2946 this.initializeWidget(); 2947 } 2948 } else { 2949 if (this.widget.value !== '') { 2950 this.setModelValue(this.widget.value); 2951 } 2952 this.getWidget().addEventListener('blur', (e) => { 2953 this.setModelValue(e.target.value); 2954 if(this.element) { 2955 this.setInactive(); 2956 } 2957 }); 2958 } 2959 this.getWidget().addEventListener('focus', (e) => { 2960 if (this.element) { 2961 this.setActive(); 2962 } 2963 }); 2964 } 2965 } 2966 2967 FormView.Utils.setupField(({element, formContainer}) => { 2968 return new NumberInput({element,formContainer}) 2969 }, NumberInput.selectors.self); 2970})(); 2971 2972/******************************************************************************* 2973 * Copyright 2022 Adobe 2974 * 2975 * Licensed under the Apache License, Version 2.0 (the "License"); 2976 * you may not use this file except in compliance with the License. 2977 * You may obtain a copy of the License at 2978 * 2979 * http://www.apache.org/licenses/LICENSE-2.0 2980 * 2981 * Unless required by applicable law or agreed to in writing, software 2982 * distributed under the License is distributed on an "AS IS" BASIS, 2983 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2984 * See the License for the specific language governing permissions and 2985 * limitations under the License. 2986 ******************************************************************************/ 2987(function () { 2988 2989 class Panel extends FormView.FormPanel { 2990 2991 _templateHTML = {}; 2992 #childIdMap = {} 2993 2994 static NS = FormView.Constants.NS; 2995 static IS = "adaptiveFormPanel"; 2996 static bemBlock = 'cmp-container'; 2997 static selectors = { 2998 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 2999 label: `.${Panel.bemBlock}__label`, 3000 description: `.${Panel.bemBlock}__longdescription`, 3001 qm: `.${Panel.bemBlock}__questionmark`, 3002 tooltipDiv: `.${Panel.bemBlock}__shortdescription` 3003 }; 3004 3005 constructor(params) { 3006 super(params); 3007 } 3008 3009 getClass() { 3010 return Panel.IS; 3011 } 3012 3013 setFocus(id) { 3014 super.setFocus(id); 3015 this.setActive(); 3016 } 3017 3018 getWidgetId(){ 3019 return this.getId(); 3020 } 3021 3022 getWidget() { 3023 return null; 3024 } 3025 3026 getDescription() { 3027 return this.element.querySelector(Panel.selectors.description); 3028 } 3029 3030 getLabel() { 3031 return this.element.querySelector(Panel.selectors.label); 3032 } 3033 3034 getErrorDiv() { 3035 //error div is not defined 3036 //return this.element.querySelector(Panel.selectors.errorDiv); 3037 return null; 3038 } 3039 3040 getTooltipDiv() { 3041 return this.element.querySelector(Panel.selectors.tooltipDiv); 3042 } 3043 3044 getQuestionMarkDiv() { 3045 return this.element.querySelector(Panel.selectors.qm); 3046 } 3047 3048 addChild(childView) { 3049 super.addChild(childView); 3050 if (this.getCountOfAllChildrenInModel() === this.children.length) { 3051 this.#cacheElements(this.element); 3052 this.#cacheDivToAppendChildMarkup(); 3053 this.cacheClosestFieldsInView(); 3054 } else if (childView.getInstanceManager() != null) { 3055 // this is for cases when repeatable instances are added after first initialisation 3056 this.#cacheElements(this.element); 3057 } 3058 } 3059 3060 getChildViewByIndex(index) { 3061 if (this.#getCachedElements()[index] != null) { 3062 return this.getChild(this.#getCachedElements()[index].id) 3063 } 3064 } 3065 3066 /** 3067 * Adds unique HTML for added instance corresponding to requirements of different types of repeatableParent 3068 * @param instanceManager of the repeated component 3069 * @param addedModel of the repeated component 3070 * @param htmlElement of the repeated component 3071 */ 3072 addRepeatableMarkup(instanceManager, addedModel, htmlElement) { 3073 let result = this.#getBeforeViewElement(instanceManager, addedModel.index); 3074 if (result.beforeViewElement != null) { 3075 result.beforeViewElement.after(htmlElement); 3076 } else if (result.parentElement != null) { 3077 if (result.parentElement.children.length == 0) { 3078 result.parentElement.append(htmlElement); 3079 } else { 3080 result.parentElement.insertBefore(htmlElement, result.parentElement.firstElementChild); 3081 } 3082 } 3083 return htmlElement; 3084 } 3085 3086 handleChildRemoval(removedInstanceView) { 3087 this.children.splice(this.children.indexOf(removedInstanceView), 1); 3088 this.#cacheElements(this._elements.self); 3089 } 3090 3091 handleChildAddition(childView) { 3092 //can't initiate cacheElement From here as children property of the panel is not updated at this point, 3093 // hence cacheElement is called from addChild method which ensures panel's addChild is called first and children 3094 // property is updated 3095 } 3096 3097 #cacheElements(wrapper) { 3098 this._elements = {}; 3099 this._elements.self = wrapper; 3100 this._elements.items = []; 3101 this.#childIdMap = {}; 3102 for (let i = 0; i < this.children.length; i++) { 3103 this.#childIdMap[this.children[i].id] = this.children[i]; 3104 } 3105 let components = this._elements.self.querySelectorAll("[data-cmp-is]"); 3106 for (let i = 0; i < components.length; i++) { 3107 //only consider this panel's child and not children of some child panel. 3108 if (this.#childIdMap.hasOwnProperty(components[i].id)) { 3109 this._elements.items.push(components[i]); 3110 } 3111 } 3112 } 3113 3114 #getCachedElements() { 3115 return this._elements.items; 3116 } 3117 3118 #getCachedElementById(id) { 3119 for (let i = 0; i < this.#getCachedElements().length; i++) { 3120 if (this.#getCachedElements()[i].id == id) { 3121 return this.#getCachedElements()[i]; 3122 } 3123 } 3124 } 3125 3126 #cacheDivToAppendChildMarkup() { 3127 if (this.children.length > 0 && this._templateHTML['divToAppendChild'] === undefined) { 3128 var fieldView = this.children[0]; 3129 //because htmlElement cached for repeating is element.parentElement in instanceManager 3130 this._templateHTML['divToAppendChild'] = fieldView.element.parentElement.parentElement; 3131 } 3132 } 3133 3134 #getBeforeViewElement(instanceManager, instanceIndex) { 3135 var result = {}; 3136 var instanceManagerId = instanceManager.getId(); 3137 if (instanceIndex == 0) { 3138 var closestNonRepeatableFieldId = this._templateHTML[instanceManagerId]['closestNonRepeatableFieldId']; 3139 var closestRepeatableFieldInstanceManagerIds = this._templateHTML[instanceManagerId]['closestRepeatableFieldInstanceManagerIds']; 3140 var indexToInsert = this.getIndexToInsert(closestNonRepeatableFieldId, closestRepeatableFieldInstanceManagerIds); 3141 if (indexToInsert > 0) { 3142 result.beforeViewElement = this.#getCachedElements()[indexToInsert - 1].parentElement; 3143 } else { 3144 result.parentElement = this._templateHTML['divToAppendChild']; 3145 } 3146 } else { 3147 let previousInstanceItemDiv = instanceManager.getElementAt(instanceIndex - 1); 3148 result.beforeViewElement = previousInstanceItemDiv; 3149 } 3150 return result; 3151 } 3152 } 3153 3154 FormView.Utils.setupField(({element, formContainer}) => { 3155 return new Panel({element, formContainer}) 3156 }, Panel.selectors.self); 3157})(); 3158 3159/******************************************************************************* 3160 * Copyright 2022 Adobe 3161 * 3162 * Licensed under the Apache License, Version 2.0 (the "License");
3163 * you may not use this file except in compliance with the License. 3164 * You may obtain a copy of the License at 3165 * 3166 * http://www.apache.org/licenses/LICENSE-2.0 3167 * 3168 * Unless required by applicable law or agreed to in writing, software 3169 * distributed under the License is distributed on an "AS IS" BASIS, 3170 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3171 * See the License for the specific language governing permissions and 3172 * limitations under the License. 3173 ******************************************************************************/ 3174(function() { 3175 3176 "use strict"; 3177 class RadioButton extends FormView.FormOptionFieldBase { 3178 3179 static NS = FormView.Constants.NS; 3180 /** 3181 * Each FormField has a data attribute class that is prefixed along with the global namespace to 3182 * distinguish between them. If a component wants to put a data-attribute X, the attribute in HTML would be 3183 * data-{NS}-{IS}-x="" 3184 * @type {string} 3185 */ 3186 static IS = "adaptiveFormRadioButton"; 3187 static bemBlock = 'cmp-adaptiveform-radiobutton'; 3188 static selectors = { 3189 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 3190 widgets: `.${RadioButton.bemBlock}__widget`, 3191 widget: `.${RadioButton.bemBlock}__option__widget`, 3192 label: `.${RadioButton.bemBlock}__label`, 3193 description: `.${RadioButton.bemBlock}__longdescription`, 3194 qm: `.${RadioButton.bemBlock}__questionmark`, 3195 errorDiv: `.${RadioButton.bemBlock}__errormessage`, 3196 tooltipDiv: `.${RadioButton.bemBlock}__shortdescription`, 3197 option: `.${RadioButton.bemBlock}__option`, 3198 optionLabel: `.${RadioButton.bemBlock}__option-label` 3199 }; 3200 3201 constructor(params) { 3202 super(params); 3203 this.qm = this.element.querySelector(RadioButton.selectors.qm); 3204 } 3205 3206 getWidgets() { 3207 return this.element.querySelector(RadioButton.selectors.widgets); 3208 } 3209 3210 getWidget() { 3211 return this.element.querySelectorAll(RadioButton.selectors.widget); 3212 } 3213 3214 getDescription() { 3215 return this.element.querySelector(RadioButton.selectors.description); 3216 } 3217 3218 getLabel() { 3219 return this.element.querySelector(RadioButton.selectors.label); 3220 } 3221 3222 getQuestionMarkDiv() { 3223 return this.element.querySelector(RadioButton.selectors.qm); 3224 } 3225 3226 getTooltipDiv() { 3227 return this.element.querySelector(RadioButton.selectors.tooltipDiv); 3228 } 3229 3230 getErrorDiv() { 3231 return this.element.querySelector(RadioButton.selectors.errorDiv); 3232 } 3233 3234 getOptions() { 3235 return this.element.querySelectorAll(RadioButton.selectors.option); 3236 } 3237 3238 setModel(model) { 3239 super.setModel(model); 3240 let widgets = this.widget; 3241 widgets.forEach(widget => { 3242 widget.addEventListener('change', (e) => { 3243 this.setModelValue(e.target.value); 3244 }); 3245 widget.addEventListener('focus', (e) => { 3246 this.setActive(); 3247 }); 3248 widget.addEventListener('blur', (e) => { 3249 this.setInactive(); 3250 }); 3251 }); 3252 } 3253 3254 updateEnabled(enabled, state) { 3255 this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_ENABLED, enabled); 3256 let widgets = this.widget; 3257 widgets.forEach(widget => { 3258 if (enabled === false) { 3259 if(state.readOnly === false){ 3260 widget.setAttribute(FormView.Constants.HTML_ATTRS.DISABLED, "disabled"); 3261 } 3262 } else if (state.readOnly === false) { 3263 widget.removeAttribute(FormView.Constants.HTML_ATTRS.DISABLED); 3264 } 3265 }); 3266 } 3267 3268 updateReadOnly(readonly) { 3269 let widgets = this.widget; 3270 this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_READONLY, readonly);
3271 widgets.forEach(widget => { 3272 if (readonly === true) { 3273 widget.setAttribute(FormView.Constants.HTML_ATTRS.DISABLED, "disabled"); 3274 } else { 3275 widget.removeAttribute(FormView.Constants.HTML_ATTRS.DISABLED); 3276 } 3277 }); 3278 } 3279 3280 updateValidity(validity) { 3281 if(validity.valid === undefined) { 3282 this.element.removeAttribute(FormView.Constants.DATA_ATTRIBUTE_VALID); 3283 this.widget.forEach(widget => widget.removeAttribute(FormView.Constants.ARIA_INVALID)); 3284 } else { 3285 this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_VALID, validity.valid); 3286 this.widget.forEach(widget => widget.setAttribute(FormView.Constants.ARIA_INVALID, !validity.valid)); 3287 } 3288 } 3289 3290 updateValue(modelValue) { 3291 this.widget.forEach(widget => { 3292 if (modelValue != null && widget.value != null && (modelValue.toString() == widget.value.toString())) { 3293 widget.checked = true; 3294 widget.setAttribute(FormView.Constants.HTML_ATTRS.CHECKED, FormView.Constants.HTML_ATTRS.CHECKED); 3295 widget.setAttribute(FormView.Constants.ARIA_CHECKED, true); 3296 } else { 3297 widget.checked = false; 3298 widget.removeAttribute(FormView.Constants.HTML_ATTRS.CHECKED); 3299 widget.setAttribute(FormView.Constants.ARIA_CHECKED, false); 3300 } 3301 }, this) 3302 super.updateEmptyStatus(); 3303 } 3304 3305 #createRadioOption(value, itemLabel) { 3306 const optionTemplate = ` 3307 <div class="${RadioButton.selectors.option.slice(1)}"> 3308 <label class="${RadioButton.selectors.optionLabel.slice(1)}"> 3309 <input type="checkbox" class="${RadioButton.selectors.widget.slice(1)}" value="${value}"> 3310 <span>${itemLabel}</span> 3311 </label> 3312 </div>`; 3313 3314 const container = document.createElement('div'); // Create a container element to hold the template 3315 container.innerHTML = optionTemplate; 3316 return container.firstElementChild; // Return the first child, which is the created option 3317 } 3318 3319 updateEnum(newEnums) { 3320 super.updateEnumForRadioButtonAndCheckbox(newEnums, this.#createRadioOption); 3321 } 3322 3323 updateEnumNames(newEnumNames) { 3324 super.updateEnumNamesForRadioButtonAndCheckbox(newEnumNames, this.#createRadioOption) 3325 } 3326 3327 updateRequired(required, state) { 3328 if (this.widget) { 3329 this.element.toggleAttribute("required", required); 3330 this.element.setAttribute("data-cmp-required", required); 3331 } 3332 } 3333 3334 syncMarkupWithModel() { 3335 super.syncMarkupWithModel(); 3336 this.#syncWidgetName(); 3337 } 3338 3339 #syncWidgetName() { 3340 const name = this.getModel()?.name; 3341 this.widget.forEach(widget => { 3342 widget.setAttribute("name", `${this.id}_${name}`); 3343 }); 3344 } 3345 } 3346 3347 FormView.Utils.setupField(({element, formContainer}) => { 3348 return new RadioButton({element, formContainer}); 3349 }, RadioButton.selectors.self); 3350 3351})(); 3352 3353/******************************************************************************* 3354 * Copyright 2022 Adobe 3355 * 3356 * Licensed under the Apache License, Version 2.0 (the "License"); 3357 * you may not use this file except in compliance with the License. 3358 * You may obtain a copy of the License at 3359 * 3360 * http://www.apache.org/licenses/LICENSE-2.0 3361 * 3362 * Unless required by applicable law or agreed to in writing, software 3363 * distributed under the License is distributed on an "AS IS" BASIS, 3364 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3365 * See the License for the specific language governing permissions and 3366 * limitations under the License. 3367 ******************************************************************************/ 3368(function() { 3369 "use strict"; 3370 3371 class Text extends FormView.FormFieldBase { 3372 3373 static NS = FormView.Constants.NS; 3374 static IS = "adaptiveFormText"; 3375 static bemBlock = 'cmp-adaptiveform-text'; 3376 3377 static selectors = { 3378 self: "[data-" + this.NS + '-is="' + this.IS + '"]' 3379 }; 3380 3381 constructor(params) { 3382 super(params); 3383 } 3384 3385 getWidget() { 3386 return null; 3387 } 3388 3389 getDescription() { 3390 return null; 3391 } 3392 3393 getLabel() { 3394 return null; 3395 } 3396 3397 getErrorDiv() { 3398 return null; 3399 } 3400 3401 getTooltipDiv() { 3402 return null; 3403 } 3404 3405 getQuestionMarkDiv() { 3406 return null; 3407 } 3408 3409 getClass() { 3410 return Text.IS; 3411 } 3412 3413 setFocus() { 3414 const fieldType = this.parentView?.getModel()?.fieldType; 3415 if (fieldType !== 'form' && this.parentView.setFocus) { 3416 this.parentView.setFocus(this.getId()); 3417 } 3418 this.setActive(); 3419 this.element.scrollIntoView({ behavior: 'smooth', block: 'start' }); 3420 } 3421
3422 updateValue(value) { 3423 // html sets undefined value as undefined string in input value, hence this check is added 3424 let actualValue = typeof value === "undefined" ? "" : value; 3425 3426 // Custom configuration for DOMPurify for RTE content 3427 const cleanHTML = (dirtyHTML) => { 3428 // Specify the allowed tags and attributes 3429 const allowedTags = [ 3430 'b', 'strong', 'caption', 'i', 'em', 'u', 3431 'sub', 'sup', 'small', 'blockquote', 3432 'ul', 'ol', 'li', 'a', 'img', 3433 'table', 'tbody', 'tr', 'td', 'th', 3434 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 3435 'br', 'p', 'span' 3436 ]; 3437 const allowedAttributes = [ 3438 'href', 'target', 'rel', '_rte_href', 3439 'src', 'alt' , 'style', '_rte_a_id_repl', 3440 'class', 'id', 'title', 'colspan', 'rowspan', 3441 'cellPadding', 'cellSpacing', 'border', 'width', 'height', 'scope' 3442 ]; 3443 3444 // Sanitize the HTML 3445 const sanitizedHTML = window.DOMPurify ? window.DOMPurify.sanitize(dirtyHTML, { 3446 ALLOWED_TAGS: allowedTags, 3447 ALLOWED_ATTR: allowedAttributes, 3448 }) : dirtyHTML; 3449 3450 return sanitizedHTML; 3451 }; 3452 3453 const sanitizedValue = cleanHTML(actualValue); 3454 3455 // since there is no widget for textview, the innerHTML is being changed 3456 if (this.element.children[0]) { 3457 this.element.children[0].innerHTML = sanitizedValue; 3458 } else { 3459 this.element.innerHTML = sanitizedValue; 3460 } 3461 } 3462 } 3463 3464 FormView.Utils.setupField(({element, formContainer}) => { 3465 return new Text({element, formContainer}) 3466 }, Text.selectors.self); 3467})(); 3468 3469/******************************************************************************* 3470 * Copyright 2022 Adobe 3471 * 3472 * Licensed under the Apache License, Version 2.0 (the "License"); 3473 * you may not use this file except in compliance with the License. 3474 * You may obtain a copy of the License at 3475 * 3476 * http://www.apache.org/licenses/LICENSE-2.0 3477 * 3478 * Unless required by applicable law or agreed to in writing, software 3479 * distributed under the License is distributed on an "AS IS" BASIS, 3480 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3481 * See the License for the specific language governing permissions and 3482 * limitations under the License. 3483 ******************************************************************************/ 3484(function() { 3485 3486 3487 "use strict"; 3488 class CheckBoxGroup extends FormView.FormOptionFieldBase { 3489 3490 static NS = FormView.Constants.NS; 3491 /** 3492 * Each FormField has a data attribute class that is prefixed along with the global namespace to 3493 * distinguish between them. If a component wants to put a data-attribute X, the attribute in HTML would be 3494 * data-{NS}-{IS}-x="" 3495 * @type {string} 3496 */ 3497 static IS = "adaptiveFormCheckBoxGroup"; 3498 static bemBlock = 'cmp-adaptiveform-checkboxgroup' 3499 static checkboxBemBlock = 'cmp-adaptiveform-checkbox' 3500 static selectors = { 3501 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 3502 widgets: `.${CheckBoxGroup.bemBlock}__widget`, 3503 widget: `.${CheckBoxGroup.bemBlock}__option__widget`, 3504 widgetLabel: `.${CheckBoxGroup.bemBlock}__label`, 3505 label: `.${CheckBoxGroup.bemBlock}__label`, 3506 description: `.${CheckBoxGroup.bemBlock}__longdescription`, 3507 qm: `.${CheckBoxGroup.bemBlock}__questionmark`, 3508 errorDiv: `.${CheckBoxGroup.bemBlock}__errormessage`, 3509 tooltipDiv: `.${CheckBoxGroup.bemBlock}__shortdescription`, 3510 item: `.${CheckBoxGroup.bemBlock}-item`, 3511 optionLabel: `${CheckBoxGroup.bemBlock}__option-label` 3512 }; 3513 3514 constructor(params) { 3515 super(params); 3516 this.qm = this.element.querySelector(CheckBoxGroup.selectors.qm) 3517 this.widgetLabel = this.element.querySelector(CheckBoxGroup.selectors.widgetLabel) 3518 } 3519 3520 getWidgets() { 3521 return this.element.querySelector(CheckBoxGroup.selectors.widgets); 3522 } 3523 3524 getWidget() { 3525 return this.element.querySelectorAll(CheckBoxGroup.selectors.widget); 3526 } 3527 3528 getDescription() { 3529 return this.element.querySelector(CheckBoxGroup.selectors.description); 3530 } 3531 3532 getLabel() { 3533 return this.element.querySelector(CheckBoxGroup.selectors.label); 3534 } 3535 3536 getErrorDiv() { 3537 return this.element.querySelector(CheckBoxGroup.selectors.errorDiv); 3538 } 3539 3540 getQuestionMarkDiv() { 3541 return this.element.querySelector(CheckBoxGroup.selectors.qm); 3542 } 3543 3544 getTooltipDiv() { 3545 return this.element.querySelector(CheckBoxGroup.selectors.tooltipDiv); 3546 } 3547 3548 getOptions() { 3549 return this.element.querySelectorAll(CheckBoxGroup.selectors.item); 3550 } 3551 3552 setModel(model) { 3553 super.setModel(model); 3554 let widgets = this.widget;
3555 widgets.forEach(widget => { 3556 let self = widget; 3557 this.#updateModelValue(self); 3558 widget.addEventListener('change', (e) => { 3559 this.#updateModelValue(self); 3560 }); 3561 widget.addEventListener('focus', (e) => { 3562 this.setActive(); 3563 }); 3564 widget.addEventListener('blur', (e) => { 3565 this.setInactive(); 3566 }); 3567 }) 3568 } 3569 3570 #updateModelValue(widget) { 3571 let value = []; 3572 this.widget.forEach(widget => { 3573 if (widget.checked) { 3574 value.push(widget.value) 3575 } 3576 }, this); 3577 if (value.length !== 0 || this._model.value != null) { 3578 this.setModelValue(value) 3579 } 3580 } 3581 3582 updateValidity(validity) { 3583 if(validity.valid === undefined) { 3584 this.element.removeAttribute(FormView.Constants.DATA_ATTRIBUTE_VALID); 3585 this.widget.forEach(widget => widget.removeAttribute(FormView.Constants.ARIA_INVALID)); 3586 } else { 3587 this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_VALID, validity.valid); 3588 this.widget.forEach(widget => widget.setAttribute(FormView.Constants.ARIA_INVALID, !validity.valid)); 3589 } 3590 } 3591 3592 updateValue(modelValue) { 3593 modelValue = [].concat(modelValue); 3594 let selectedWidgetValues = modelValue.map(String); 3595 this.widget.forEach(widget => { 3596 if (selectedWidgetValues.includes((widget.value))) { 3597 widget.checked = true 3598 widget.setAttribute(FormView.Constants.HTML_ATTRS.CHECKED, FormView.Constants.HTML_ATTRS.CHECKED) 3599 widget.setAttribute(FormView.Constants.ARIA_CHECKED, true) 3600 } else { 3601 widget.checked = false 3602 widget.removeAttribute(FormView.Constants.HTML_ATTRS.CHECKED); 3603 widget.setAttribute(FormView.Constants.ARIA_CHECKED, false); 3604 } 3605 }, this) 3606 super.updateEmptyStatus(); 3607 } 3608 3609 #createCheckBoxItem(value, itemLabel) { 3610 const optionTemplate = ` 3611 <div class="${CheckBoxGroup.selectors.item.slice(1)}"> 3612 <label class="${CheckBoxGroup.selectors.optionLabel.slice(1)}"> 3613 <input type="checkbox" class="${CheckBoxGroup.selectors.widget.slice(1)}" value="${value}"> 3614 <span>${itemLabel}</span> 3615 </label> 3616 </div>`; 3617 3618 const container = document.createElement('div'); // Create a container element to hold the template 3619 container.innerHTML = optionTemplate; 3620 return container.firstElementChild; // Return the first child, which is the created option 3621 } 3622 updateEnum(newEnums) { 3623 super.updateEnumForRadioButtonAndCheckbox(newEnums, this.#createCheckBoxItem); 3624 } 3625 3626 updateEnumNames(newEnumNames) { 3627 super.updateEnumNamesForRadioButtonAndCheckbox(newEnumNames, this.#createCheckBoxItem); 3628 } 3629 3630 updateEnabled(enabled, state) { 3631 this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_ENABLED, enabled); 3632 let widgets = this.widget; 3633 widgets.forEach(widget => { 3634 if (enabled === false) { 3635 if(state.readOnly === false){ 3636 widget.setAttribute(FormView.Constants.HTML_ATTRS.DISABLED, "disabled"); 3637 } 3638 } else if (state.readOnly === false) { 3639 widget.removeAttribute(FormView.Constants.HTML_ATTRS.DISABLED); 3640 } 3641 }); 3642 } 3643 3644 updateReadOnly(readonly) { 3645 let widgets = this.widget; 3646 this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_READONLY, readonly); 3647 widgets.forEach(widget => { 3648 if (readonly === true) { 3649 widget.setAttribute(FormView.Constants.HTML_ATTRS.DISABLED, "disabled"); 3650 widget.setAttribute("aria-readonly", true); 3651 } else { 3652 widget.removeAttribute(FormView.Constants.HTML_ATTRS.DISABLED); 3653 widget.removeAttribute("aria-readonly"); 3654 } 3655 }); 3656 } 3657 updateRequired(required, state) { 3658 if (this.widget) { 3659 this.element.toggleAttribute("required", required); 3660 this.element.setAttribute("data-cmp-required", required); 3661 } 3662 } 3663 3664 syncMarkupWithModel() { 3665 super.syncMarkupWithModel(); 3666 this.updateEnum(this._model.enum); 3667 this.updateEnumNames(this._model.enumNames); 3668 } 3669 } 3670 3671 FormView.Utils.setupField(({element, formContainer}) => { 3672 return new CheckBoxGroup({element, formContainer}) 3673 }, CheckBoxGroup.selectors.self); 3674 3675})(); 3676 3677/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3678 ~ Copyright 2024 Adobe 3679 ~ 3680 ~ Licensed under the Apache License, Version 2.0 (the "License");
3681 ~ you may not use this file except in compliance with the License. 3682 ~ You may obtain a copy of the License at 3683 ~ 3684 ~ http://www.apache.org/licenses/LICENSE-2.0 3685 ~ 3686 ~ Unless required by applicable law or agreed to in writing, software 3687 ~ distributed under the License is distributed on an "AS IS" BASIS, 3688 ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3689 ~ See the License for the specific language governing permissions and 3690 ~ limitations under the License. 3691 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ 3692(function() { 3693 3694 "use strict"; 3695 class Button extends FormView.FormFieldBase { 3696 3697 static NS = FormView.Constants.NS; 3698 /** 3699 * Each FormField has a data attribute class that is prefixed along with the global namespace to 3700 * distinguish between them. If a component wants to put a data-attribute X, the attribute in HTML would be 3701 * data-{NS}-{IS}-x="" 3702 * @type {string} 3703 */ 3704 static IS = "adaptiveFormButton"; 3705 static bemBlock = 'cmp-adaptiveform-button'; 3706 static selectors = { 3707 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 3708 widget: `.${Button.bemBlock}__widget`, 3709 label: `.${Button.bemBlock}__text`, 3710 description: `.${Button.bemBlock}__longdescription`, 3711 qm: `.${Button.bemBlock}__questionmark`, 3712 tooltipDiv: `.${Button.bemBlock}__shortdescription` 3713 }; 3714 3715 getQuestionMarkDiv() { 3716 return this.element.querySelector(Button.selectors.qm); 3717 } 3718 3719 getLabel() { 3720 return this.element.querySelector(Button.selectors.label); 3721 } 3722 3723 getWidget() { 3724 return this.element.querySelector(Button.selectors.widget); 3725 } 3726 3727 /** 3728 * Return the description element. 3729 * @returns {HTMLElement} 3730 */ 3731 getDescription() { 3732 return this.element.querySelector(Button.selectors.description); 3733 } 3734 3735 getErrorDiv() { 3736 return null; 3737 } 3738 3739 getTooltipDiv() { 3740 return this.element.querySelector(Button.selectors.tooltipDiv); 3741 } 3742 3743 setModel(model) { 3744 super.setModel(model); 3745 this.getWidget().addEventListener("click", (event) => { 3746 if (this.widget.type === 'submit' || this.widget.type === 'reset') { 3747 event.preventDefault(); 3748 } 3749 this._model.dispatch(new FormView.Actions.Click()); 3750 }); 3751 } 3752 } 3753 3754 FormView.Utils.setupField(({element, formContainer}) => { 3755 return new Button({element, formContainer}) 3756 }, Button.selectors.self); 3757 3758})(); 3759 3760/******************************************************************************* 3761 * Copyright 2022 Adobe 3762 * 3763 * Licensed under the Apache License, Version 2.0 (the "License"); 3764 * you may not use this file except in compliance with the License. 3765 * You may obtain a copy of the License at 3766 * 3767 * http://www.apache.org/licenses/LICENSE-2.0 3768 * 3769 * Unless required by applicable law or agreed to in writing, software 3770 * distributed under the License is distributed on an "AS IS" BASIS, 3771 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3772 * See the License for the specific language governing permissions and 3773 * limitations under the License. 3774 ******************************************************************************/ 3775(function(document) { 3776 3777 "use strict"; 3778 class Image extends FormView.FormFieldBase { 3779 3780 static NS = FormView.Constants.NS; 3781 static IS = "adaptiveFormImage"; 3782 static bemBlock = 'cmp-image'; 3783 3784 static selectors = { 3785 self: "[data-" + this.NS + '-is="' + this.IS + '"]' 3786 }; 3787 3788 constructor(params) { 3789 super(params); 3790 } 3791 3792 getClass() { 3793 return Image.IS; 3794 } 3795 3796 getWidget() { 3797 return null; 3798 } 3799 3800 getDescription() { 3801 return null; 3802 } 3803 3804 getLabel() { 3805 return null; 3806 } 3807 3808 getErrorDiv() { 3809 return null; 3810 } 3811 3812 getTooltipDiv() { 3813 return null; 3814 } 3815 3816 getQuestionMarkDiv() { 3817 return null; 3818 } 3819 3820 setFocus() { 3821 this.setActive(); 3822 } 3823
3824 updateValue(value) { 3825 if (this.element) { 3826 this.element.setAttribute('data-cmp-src', value); 3827 const imgElement = this.element.querySelector('img'); 3828 if (imgElement) { 3829 imgElement.setAttribute('src', value); 3830 } 3831 } 3832 } 3833 } 3834 3835 FormView.Utils.setupField(({element, formContainer}) => { 3836 return new Image({element, formContainer}) 3837 }, Image.selectors.self); 3838})(); 3839 3840/******************************************************************************* 3841 * Copyright 2022 Adobe 3842 * 3843 * Licensed under the Apache License, Version 2.0 (the "License"); 3844 * you may not use this file except in compliance with the License. 3845 * You may obtain a copy of the License at 3846 * 3847 * http://www.apache.org/licenses/LICENSE-2.0 3848 * 3849 * Unless required by applicable law or agreed to in writing, software 3850 * distributed under the License is distributed on an "AS IS" BASIS, 3851 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3852 * See the License for the specific language governing permissions and 3853 * limitations under the License. 3854 ******************************************************************************/ 3855(function() { 3856 3857 "use strict"; 3858 class DropDown extends FormView.FormOptionFieldBase { 3859 3860 static NS = FormView.Constants.NS; 3861 /** 3862 * Each FormField has a data attribute class that is prefixed along with the global namespace to 3863 * distinguish between them. If a component wants to put a data-attribute X, the attribute in HTML would be 3864 * data-{NS}-{IS}-x="" 3865 * @type {string} 3866 */ 3867 static IS = "adaptiveFormDropDown"; 3868 static bemBlock = 'cmp-adaptiveform-dropdown'; 3869 static selectors = { 3870 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 3871 widget: `.${DropDown.bemBlock}__widget`, 3872 options: `.${DropDown.bemBlock}__option`, 3873 label: `.${DropDown.bemBlock}__label`, 3874 description: `.${DropDown.bemBlock}__longdescription`, 3875 qm: `.${DropDown.bemBlock}__questionmark`, 3876 errorDiv: `.${DropDown.bemBlock}__errormessage`, 3877 tooltipDiv: `.${DropDown.bemBlock}__shortdescription` 3878 }; 3879 3880 constructor(params) { 3881 super(params); 3882 this.qm = this.element.querySelector(DropDown.selectors.qm); 3883 } 3884 3885 getWidget() { 3886 return this.element.querySelector(DropDown.selectors.widget); 3887 } 3888 3889 getDescription() { 3890 return this.element.querySelector(DropDown.selectors.description); 3891 } 3892 3893 getLabel() { 3894 return this.element.querySelector(DropDown.selectors.label); 3895 } 3896 3897 getErrorDiv() { 3898 return this.element.querySelector(DropDown.selectors.errorDiv); 3899 } 3900 3901 getQuestionMarkDiv() { 3902 return this.element.querySelector(DropDown.selectors.qm); 3903 } 3904 3905 getTooltipDiv() { 3906 return this.element.querySelector(DropDown.selectors.tooltipDiv); 3907 } 3908 3909 getOptions() { 3910 return this.element.querySelectorAll(DropDown.selectors.options); 3911 } 3912 3913 #checkIfEqual = function(value, optionValue, multiSelect) { 3914 if(multiSelect) { 3915 let isPresent = false; 3916 value.forEach((saveValue) => { 3917 if(String(saveValue) === optionValue) // save value can be number and boolean also. 3918 isPresent = true; 3919 }) 3920 return isPresent; 3921 } 3922 return String(value) === optionValue; 3923 } 3924 3925 updateEnabled(enabled, state) { 3926 this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_ENABLED, enabled); 3927 let widget = this.widget; 3928 if (enabled === false) { 3929 if(state.readOnly === false){ 3930 widget.setAttribute(FormView.Constants.HTML_ATTRS.DISABLED, "disabled"); 3931 } 3932 } else if (state.readOnly === false) { 3933 widget.removeAttribute(FormView.Constants.HTML_ATTRS.DISABLED); 3934 } 3935 } 3936 3937 updateReadOnly(readonly) { 3938 let widget = this.widget; 3939 this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_READONLY, readonly); 3940 if (readonly === true) { 3941 widget.setAttribute(FormView.Constants.HTML_ATTRS.DISABLED, "disabled"); 3942 widget.setAttribute("aria-readonly", true); 3943 } else { 3944 widget.removeAttribute(FormView.Constants.HTML_ATTRS.DISABLED); 3945 widget.removeAttribute("aria-readonly"); 3946 } 3947 } 3948
3949 updateValue(value) { 3950 if(value == null) { // if undefined or null, reset the widget 3951 this.widget.selectedIndex = -1; 3952 return; 3953 } 3954 let isMultiSelect = this._model.isArrayType(); 3955 [...this.widget].forEach((option) => { 3956 // clear of any selection, and re-add selection (otherwise HTML shows stale state if it already existed) 3957 option.removeAttribute('selected'); 3958 if(this.#checkIfEqual(value, option.value, isMultiSelect)) { 3959 option.setAttribute('selected', 'selected'); 3960 } 3961 }); 3962 super.updateEmptyStatus(); 3963 } 3964 3965 #createDropDownOptions(value, label) { 3966 const optionTemplate = `<option value="${value}" class="${DropDown.selectors.options.slice(1)}">${label}</option>`; 3967 const container = document.createElement('div'); // Create a container element to hold the template 3968 container.innerHTML = optionTemplate; 3969 return container.firstElementChild; // Return the first child, which is the created option 3970 } 3971 3972 #removeAllOptions() { 3973 while(this.getOptions().length !== 0) { 3974 this.getWidget().remove(this.getOptions().length) // not removing the blank option 3975 } 3976 } 3977 3978 /** 3979 * @override 3980 * Method for updating the saved value in the option field. 3981 * It contains the logic for updating the 'enum' value. 3982 * 3983 * @param {Array} newEnums - An array of primitive values to be saved in the option field. 3984 */ 3985 updateEnum(newEnums) { 3986 let options = this.getOptions(); 3987 let currentEnumSize = options.length; 3988 let startIndex = options[0] && options[0].value === '' ? 1 : 0; // Check if the first option is a blank option 3989 3990 // Update existing options and add new options in the same loop 3991 newEnums.forEach((value, index) => { 3992 if (index + startIndex < currentEnumSize) { 3993 // Update existing option 3994 options[index + startIndex].value = value; 3995 } else { 3996 // Add new option 3997 this.getWidget().add(this.#createDropDownOptions(value, value)); 3998 } 3999 }); 4000 4001 // Remove extra options, but never remove the first option 4002 while (currentEnumSize > newEnums.length + startIndex) { 4003 this.getWidget().remove(currentEnumSize--); 4004 } 4005 } 4006 4007 /** 4008 * @override 4009 * Method for updating the display value in the option field. 4010 * It contains the logic for updating the 'enumNames' value. 4011 * 4012 * @param {Array} newEnumNames - An array of primitive values to be displayed in the option field. 4013 */ 4014 updateEnumNames(newEnumNames) { 4015 let options = this.getOptions(); 4016 let currentEnumNameSize = options.length; 4017 if(currentEnumNameSize === 0) { // case 1: Create all dropdown new options 4018 newEnumNames.forEach((value) => { 4019 this.getWidget().add(this.#createDropDownOptions(value, value)); 4020 }) 4021 } else if(currentEnumNameSize > newEnumNames.length) { // case 2: Replace existing enumNames, remaining enumNames = enums 4022 newEnumNames.forEach((value, index) => { 4023 options[index].text = value; 4024 }); 4025 4026 options.forEach((option, index) => { 4027 if(index >= newEnumNames.length) { 4028 option.text = option.value; 4029 } 4030 }) 4031 } else { // case 3: Replace all existing enumNames 4032 options.forEach((option, index) => { 4033 option.text = newEnumNames[index]; 4034 }); 4035 } 4036 } 4037 4038 setModel(model) { 4039 super.setModel(model); 4040 if (this.widget.value !== '') { 4041 this.#updateModelValue(this.widget); 4042 } 4043 this.widget.addEventListener('change', (e) => { 4044 this.#updateModelValue(e.target); 4045 }); 4046 this.widget.addEventListener('focus', (e) => { 4047 this.setActive(); 4048 }); 4049 this.widget.addEventListener('blur', (e) => { 4050 this.setInactive(); 4051 }); 4052 } 4053 4054 #updateModelValue(widget) { 4055 if(this._model.isArrayType()) { 4056 let valueArray = []; 4057 [...this.widget].forEach((option) => { 4058 if(option.selected) { 4059 valueArray.push(option.value); 4060 } 4061 }); 4062 if (valueArray.length !== 0 || this._model.value != null) { 4063 this.setModelValue(valueArray); 4064 } 4065 } else { 4066 this.setModelValue(widget.value); 4067 } 4068 } 4069 } 4070 4071 FormView.Utils.setupField(({element, formContainer}) => { 4072 return new DropDown({element, formContainer}) 4073 }, DropDown.selectors.self); 4074 4075})(); 4076 4077/******************************************************************************* 4078 * Copyright 2025 Adobe 4079 * 4080 * Licensed under the Apache License, Version 2.0 (the "License");
4081 * you may not use this file except in compliance with the License. 4082 * You may obtain a copy of the License at 4083 * 4084 * http://www.apache.org/licenses/LICENSE-2.0 4085 * 4086 * Unless required by applicable law or agreed to in writing, software 4087 * distributed under the License is distributed on an "AS IS" BASIS, 4088 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4089 * See the License for the specific language governing permissions and 4090 * limitations under the License. 4091 ******************************************************************************/ 4092 4093/** 4094 * This class is responsible for interacting with the file input widget. It implements the file preview, 4095 * file list, handling invalid file size, file name, file mime type functionality 4096 */ 4097 4098if (typeof window.FileInputWidget === 'undefined') { 4099 window.FileInputWidget = class extends FormView.FormFileInputWidget { 4100 4101 constructor(params) { 4102 super(params); 4103 this.invalidFeature = { 4104 ...this.invalidFeature, 4105 "SIZE_ZERO": 4 4106 } 4107 } 4108 4109 attachEventHandlers(widget, dragArea, model) { 4110 super.attachEventHandlers(widget, dragArea, model) 4111 const customBtn = dragArea?.querySelector(".cmp-adaptiveform-fileinput__widgetlabel") 4112 customBtn?.addEventListener("click", () => { 4113 widget.click(); 4114 }); 4115 customBtn?.addEventListener('keydown', function(event) { 4116 // Check if the Enter key is pressed 4117 if (event.key === 'Enter' || event.keyCode === 13) { 4118 // Trigger the click event of the file input 4119 widget.click(); 4120 } 4121 }); 4122 } 4123 4124 fileItem(fileName, fileSize, comment, fileUrl) { 4125 let self = this; 4126 let id = `${Date.now() + '_' + Math.floor(Math.random() * 10000)}_file_size` 4127 let fileItem = document.createElement('li'); 4128 fileItem.setAttribute("class", "cmp-adaptiveform-fileinput__fileitem"); 4129 let fileNameDom = document.createElement('a'); 4130 let fileSizeDom = document.createElement('span'); 4131 4132 fileSizeDom.setAttribute('class', "cmp-adaptiveform-fileinput__filesize"); 4133 fileSizeDom.setAttribute('id', id); 4134 fileSizeDom.textContent = this.formatBytes(fileSize); 4135 4136 fileNameDom.setAttribute('tabindex', '0'); 4137 fileNameDom.setAttribute('class', "cmp-adaptiveform-fileinput__filename"); 4138 fileNameDom.setAttribute('aria-describedBY', id); 4139 fileNameDom.textContent = fileName; 4140 fileNameDom.addEventListener('keypress', function(e) { 4141 if (e.keyCode === 13 || e.charCode === 32) { 4142 e.target.click(); 4143 } 4144 }); 4145 fileNameDom.addEventListener('click', function(e) { 4146 self.handleFilePreview(e); 4147 }); 4148 fileItem.appendChild(fileNameDom); 4149 if(fileUrl != null){ 4150 fileNameDom.dataset.key = fileUrl; 4151 } 4152 let fileEndContainer = document.createElement('span'); 4153 let fileClose = document.createElement('button'); 4154 fileEndContainer.setAttribute('class', "cmp-adaptiveform-fileinput__fileendcontainer"); 4155 fileClose.setAttribute('tabindex', '0'); 4156 fileClose.setAttribute('class', "cmp-adaptiveform-fileinput__filedelete"); 4157 fileClose.setAttribute('aria-label', FormView.LanguageUtils.getTranslatedString(this.lang, "FileCloseAccessText") + fileName); 4158 fileClose.textContent = "x"; 4159 fileClose.addEventListener('keypress', function(e) { 4160 if (e.keyCode === 13 || e.charCode === 32) { 4161 e.target.click(); 4162 } 4163 }); 4164 fileClose.addEventListener('click', function(e) { 4165 self.handleClick(e); 4166 }); 4167 fileEndContainer.appendChild(fileSizeDom); 4168 fileEndContainer.appendChild(fileClose); 4169 fileItem.appendChild(fileEndContainer); 4170 return fileItem; 4171 } 4172 validateFile(file, invalidFilesByType) { 4173 let currFileName = file.name.split("\\").pop(); 4174 let size = file.size / 1024 / 1024; 4175 if (file.size === 0) { 4176 invalidFilesByType.SIZE_ZERO.push(currFileName); 4177 return false;
4178 } else if (size > parseFloat(this.options.maxFileSize)) { 4179 invalidFilesByType.SIZE.push(currFileName); 4180 return false; 4181 } else if (!FileInputWidget.isValid(currFileName)) { 4182 invalidFilesByType.NAME.push(currFileName); 4183 return false; 4184 } else { 4185 let isMatch = false; 4186 let extension = currFileName.split('.').pop(); 4187 let mimeType = (file.type) ? file.type : this.extensionToMimeTypeMap[extension]; 4188 if (mimeType && mimeType.trim().length > 0) { 4189 isMatch = this.regexMimeTypeList.some(rx => rx.test(mimeType)); 4190 } 4191 if (!isMatch) { 4192 invalidFilesByType.MIMETYPE.push(currFileName); 4193 return false; 4194 } 4195 } 4196 return true; 4197 } 4198 handleChange(filesUploaded) { 4199 if (!this.isFileUpdate) { 4200 let self = this, 4201 files = filesUploaded; 4202 // Object of arrays to collect invalid file names by type 4203 let invalidFilesByType = { SIZE: [], SIZE_ZERO: [], NAME: [], MIMETYPE: [] }; 4204 if (typeof files !== "undefined") { 4205 let invalidFilesIndexes = []; 4206 Array.from(files).forEach(function (file, fileIndex) { 4207 if (self.validateFile(file, invalidFilesByType)) { 4208 if (self.isMultiSelect()) { 4209 self.values.push(file.name.split("\\").pop()); 4210 self.fileArr.push(file); 4211 } else { 4212 self.values = [file.name.split("\\").pop()]; 4213 self.fileArr = [file]; 4214 } 4215 } else { 4216 invalidFilesIndexes.push(fileIndex); 4217 } 4218 }, this); 4219 if (invalidFilesIndexes.length > 0 && this.widget !== null) { 4220 this.deleteFilesFromInputDom(invalidFilesIndexes); 4221 } 4222 } 4223 // set the new model value. 4224 this.model.value = this.fileArr; 4225 // Collate all error messages 4226 let errorMessages = []; 4227 if (invalidFilesByType.SIZE_ZERO.length > 0) { 4228 errorMessages.push(this.showInvalidMessage(invalidFilesByType.SIZE_ZERO.join(', '), this.invalidFeature.SIZE_ZERO)); 4229 } 4230 if (invalidFilesByType.SIZE.length > 0) { 4231 errorMessages.push(this.showInvalidMessage(invalidFilesByType.SIZE.join(', '), this.invalidFeature.SIZE)); 4232 } 4233 if (invalidFilesByType.NAME.length > 0) { 4234 errorMessages.push(this.showInvalidMessage(invalidFilesByType.NAME.join(', '), this.invalidFeature.NAME)); 4235 } 4236 if (invalidFilesByType.MIMETYPE.length > 0) { 4237 errorMessages.push(this.showInvalidMessage(invalidFilesByType.MIMETYPE.join(', '), this.invalidFeature.MIMETYPE)); 4238 } 4239 if (errorMessages.length > 0) { 4240 alert(errorMessages.join('\n')); 4241 } 4242 } 4243 this.widget.value = null; 4244 } 4245 showInvalidMessage(fileNames, invalidFeature) { 4246 let that = this; 4247 let IS_IPAD = navigator.userAgent.match(/iPad/i) !== null, 4248 IS_IPHONE = (navigator.userAgent.match(/iPhone/i) !== null); 4249 if (IS_IPAD || IS_IPHONE) { 4250 setTimeout(function () { 4251 return that.invalidMessage(fileNames, invalidFeature); 4252 }, 0); 4253 } else { 4254 return this.invalidMessage(fileNames, invalidFeature); 4255 } 4256 } 4257 invalidMessage(fileNames, invalidFeature) { 4258 const customMessages = this.options.constraintMessages || {}; 4259 const messages = { 4260 [this.invalidFeature.SIZE]: customMessages.maxFileSize || FormView.LanguageUtils.getTranslatedString(this.lang, "FileSizeGreater", [fileNames, this.options.maxFileSize]), 4261 [this.invalidFeature.NAME]: customMessages.invalidFileName || FormView.LanguageUtils.getTranslatedString(this.lang, "FileNameInvalid", [fileNames]), 4262 [this.invalidFeature.MIMETYPE]: customMessages.invalidMimeType || FormView.LanguageUtils.getTranslatedString(this.lang, "FileMimeTypeInvalid", [fileNames]), 4263 [this.invalidFeature.SIZE_ZERO]: customMessages.zeroFileSize || FormView.LanguageUtils.getTranslatedString(this.lang, "FileSizeZero", [fileNames]) 4264 }; 4265 return messages[invalidFeature]; 4266 } 4267 } 4268} 4269/******************************************************************************* 4270 * Copyright 2025 Adobe 4271 * 4272 * Licensed under the Apache License, Version 2.0 (the "License");
4273 * you may not use this file except in compliance with the License. 4274 * You may obtain a copy of the License at 4275 * 4276 * http://www.apache.org/licenses/LICENSE-2.0 4277 * 4278 * Unless required by applicable law or agreed to in writing, software 4279 * distributed under the License is distributed on an "AS IS" BASIS, 4280 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4281 * See the License for the specific language governing permissions and 4282 * limitations under the License. 4283 ******************************************************************************/ 4284(function() { 4285 4286 "use strict"; 4287 class FileInputV4 extends FormView.FormFileInput { 4288 4289 static NS = FormView.Constants.NS; 4290 /** 4291 * Each FormField has a data attribute class that is prefixed along with the global namespace to 4292 * distinguish between them. If a component wants to put a data-attribute X, the attribute in HTML would be 4293 * data-{NS}-{IS}-x="" 4294 * @type {string} 4295 */ 4296 static IS = "adaptiveFormFileInput"; 4297 static bemBlock = 'cmp-adaptiveform-fileinput' 4298 static selectors = { 4299 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 4300 widget: `.${FileInputV4.bemBlock}__widget`, 4301 label: `.${FileInputV4.bemBlock}__label`, 4302 description: `.${FileInputV4.bemBlock}__longdescription`, 4303 qm: `.${FileInputV4.bemBlock}__questionmark`, 4304 errorDiv: `.${FileInputV4.bemBlock}__errormessage`, 4305 tooltipDiv: `.${FileInputV4.bemBlock}__shortdescription`, 4306 fileListDiv : `.${FileInputV4.bemBlock}__filelist`, 4307 attachButtonLabel : `.${FileInputV4.bemBlock}__widgetlabel`, 4308 dragArea: `.${FileInputV4.bemBlock}__dragarea` 4309 }; 4310 4311 constructor(params) { 4312 super(params); 4313 } 4314 widgetFields = { 4315 widget: this.getWidget(), 4316 fileListDiv: this.getFileListDiv(), 4317 model: () => this._model, 4318 dragArea: this.getDragArea() 4319 }; 4320 4321 getWidget() { 4322 return this.element.querySelector(FileInputV4.selectors.widget); 4323 } 4324 4325 getDragArea() { 4326 return this.element.querySelector(FileInputV4.selectors.dragArea); 4327 } 4328 4329 getDescription() { 4330 return this.element.querySelector(FileInputV4.selectors.description); 4331 } 4332 4333 getLabel() { 4334 return this.element.querySelector(FileInputV4.selectors.label); 4335 } 4336 4337 getErrorDiv() { 4338 return this.element.querySelector(FileInputV4.selectors.errorDiv); 4339 } 4340 4341 getTooltipDiv() { 4342 return this.element.querySelector(FileInputV4.selectors.tooltipDiv); 4343 } 4344 4345 getQuestionMarkDiv() { 4346 return this.element.querySelector(FileInputV4.selectors.qm); 4347 } 4348 4349 getFileListDiv() { 4350 return this.element.querySelector(FileInputV4.selectors.fileListDiv); 4351 } 4352 4353 getAttachButtonLabel() { 4354 return this.element.querySelector(FileInputV4.selectors.attachButtonLabel); 4355 } 4356 4357 updateEnabled(enabled, state) { 4358 if (this.widget) { 4359 this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_ENABLED, enabled); 4360 const isDisabled = !enabled || state.readOnly; 4361 if (isDisabled) { 4362 this.widget.setAttribute("disabled", "disabled"); 4363 } else { 4364 this.widget.removeAttribute("disabled"); 4365 } 4366 } 4367 } 4368 4369 updateValue(value) { 4370 if (this.widgetObject == null) { 4371 this.widgetObject = new FileInputWidget(this.widgetFields); 4372 } 4373 this.widgetObject.setValue(value); 4374 super.updateEmptyStatus(); 4375 } 4376 4377 setModel(model) { 4378 super.setModel(model); 4379 if (this.widgetObject == null) { 4380 this.widgetObject = new FileInputWidget(this.widgetFields); 4381 } 4382 this.getAttachButtonLabel().addEventListener('focus', () => { 4383 this.setActive(); 4384 }) 4385 this.getAttachButtonLabel().addEventListener('blur', () => { 4386 this.setInactive(); 4387 }) 4388 } 4389 4390 syncWidget() { 4391 let widgetElement = this.getWidget ? this.getWidget() : null; 4392 if (widgetElement) { 4393 widgetElement.id = this.getId() + "__widget"; 4394 const closestElement = widgetElement?.previousElementSibling; 4395 if (closestElement && closestElement.tagName.toLowerCase() === 'label') { 4396 closestElement.setAttribute('for', this.getId() + "__widget"); 4397 } else { 4398 this.getAttachButtonLabel().removeAttribute('for'); 4399 } 4400 } 4401 } 4402 } 4403 4404 FormView.Utils.setupField(({element, formContainer}) => { 4405 return new FileInputV4({element, formContainer}) 4406 }, FileInputV4.selectors.self); 4407 4408})(); 4409 4410/******************************************************************************* 4411 * Copyright 2022 Adobe 4412 * 4413 * Licensed under the Apache License, Version 2.0 (the "License");
4414 * you may not use this file except in compliance with the License. 4415 * You may obtain a copy of the License at 4416 * 4417 * http://www.apache.org/licenses/LICENSE-2.0 4418 * 4419 * Unless required by applicable law or agreed to in writing, software 4420 * distributed under the License is distributed on an "AS IS" BASIS, 4421 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4422 * See the License for the specific language governing permissions and 4423 * limitations under the License. 4424 ******************************************************************************/ 4425(function () { 4426 4427 function onAccordionMixinLoaded(event) { 4428 const AccordionMixin = event.detail.AccordionMixin; 4429 4430 class Accordion extends AccordionMixin(FormView.FormPanel) { 4431 4432 static NS = FormView.Constants.NS; 4433 static DATA_ATTRIBUTE_VISIBLE = 'data-cmp-visible'; 4434 _templateHTML = {}; 4435 static selectors = { 4436 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 4437 widget: `.${Accordion.bemBlock}__widget`, 4438 description: `.${Accordion.bemBlock}__longdescription`, 4439 qm: `.${Accordion.bemBlock}__questionmark`, 4440 tooltipDiv: `.${Accordion.bemBlock}__shortdescription`, 4441 label: `.${Accordion.bemBlock}__label`, 4442 item: `.${Accordion.bemBlock}__item` 4443 }; 4444 4445 static keyCodes = { 4446 ENTER: 13, 4447 SPACE: 32, 4448 END: 35, 4449 HOME: 36, 4450 ARROW_LEFT: 37, 4451 ARROW_UP: 38, 4452 ARROW_RIGHT: 39, 4453 ARROW_DOWN: 40 4454 }; 4455 4456 constructor(params) { 4457 super(params); 4458 const {element} = params; 4459 this.cacheElements(element); 4460 if (this.getCachedItems()) { 4461 var expandedItems = this.getExpandedItems(); 4462 // multiple expanded items annotated, display the last item open. 4463 if (expandedItems.length > 1) { 4464 var lastExpandedItem = expandedItems[expandedItems.length - 1] 4465 this.expandItem(lastExpandedItem); 4466 this.collapseAllOtherItems(lastExpandedItem.id); 4467 } 4468 this.refreshItems(); 4469 this.#bindEvents(); 4470 } 4471 } 4472 4473 getClass() { 4474 return Accordion.IS; 4475 } 4476 4477 getWidget() { 4478 return null; 4479 } 4480 4481 getDescription() { 4482 return this.element.querySelector(Accordion.selectors.description); 4483 } 4484 4485 getLabel() { 4486 return this.element.querySelector(Accordion.selectors.label); 4487 } 4488 4489 getErrorDiv() { 4490 return null; 4491 } 4492 4493 getTooltipDiv() { 4494 return this.element.querySelector(Accordion.selectors.tooltipDiv); 4495 } 4496 4497 getQuestionMarkDiv() { 4498 return this.element.querySelector(Accordion.selectors.qm); 4499 } 4500 4501 setFocus(id) { 4502 super.setFocus(id); 4503 this.setActive(); 4504 this.#collapseAllItems(); 4505 const item = this.getItemById(id + '-item'); 4506 this.expandItem(item) 4507 } 4508 4509 #collapseAllItems() { 4510 var items = this.getCachedItems(); 4511 if (items) { 4512 for (var i = 0; i < items.length; i++) { 4513 if (this.isItemExpanded(items[i])) { 4514 this.collapseItem(items[i]) 4515 } 4516 } 4517 } 4518 } 4519 4520 /** 4521 * Binds Accordion event handling. 4522 * 4523 * @private 4524 */ 4525 #bindEvents() { 4526 var buttons = this.getCachedButtons(); 4527 if (buttons) { 4528 var _self = this; 4529 for (var i = 0; i < buttons.length; i++) { 4530 (function (index) { 4531 buttons[index].addEventListener("click", function (event) { 4532 var itemDivId = _self.#convertToItemDivId(buttons[index].id); 4533 _self.toggle(itemDivId); 4534 _self.collapseAllOtherItems(itemDivId); 4535 _self.#focusButton(buttons[index].id); 4536 }); 4537 buttons[index].addEventListener("keydown", function (event) { 4538 _self.#onButtonKeyDown(event, buttons[index].id); 4539 }); 4540 })(i); 4541 } 4542 } 4543 } 4544 4545 /** 4546 * Binds Accordion event handling. 4547 * 4548 * @private 4549 */ 4550 #bindEventsToAddedChild(addedChildId) { 4551 var _self = this; 4552 var buttonId = addedChildId + Accordion.idSuffixes.button; 4553 var button = this.#getButtonById(buttonId); 4554 button.addEventListener("click", function (event) { 4555 var itemDivId = _self.#convertToItemDivId(buttonId); 4556 _self.toggle(itemDivId); 4557 _self.collapseAllOtherItems(itemDivId); 4558 _self.#focusButton(buttonId); 4559 }); 4560 button.addEventListener("keydown", function (event) { 4561 _self.#onButtonKeyDown(event, buttonId); 4562 }); 4563 } 4564 4565 /** 4566 * Handles button keydown events. 4567 * 4568 * @private 4569 * @param {Object} event The keydown event 4570 * @param {Number} id The id of the button triggering the event 4571 */ 4572 #onButtonKeyDown(event, id) { 4573 var buttons = this.getCachedButtons(); 4574 var lastIndex = buttons.length - 1; 4575 var index = this.#getButtonIndexById(id); 4576 4577 switch (event.keyCode) { 4578 case Accordion.keyCodes.ARROW_LEFT: 4579 case Accordion.keyCodes.ARROW_UP: 4580 event.preventDefault(); 4581 if (index > 0) { 4582 this.#focusButton(buttons[index - 1].id); 4583 } 4584 break; 4585 case Accordion.keyCodes.ARROW_RIGHT: 4586 case Accordion.keyCodes.ARROW_DOWN: 4587 event.preventDefault(); 4588 if (index < lastIndex) { 4589 this.#focusButton(buttons[index + 1].id); 4590 } 4591 break; 4592 case Accordion.keyCodes.HOME: 4593 event.preventDefault(); 4594 this.#focusButton(buttons[0].id); 4595 break; 4596 case Accordion.keyCodes.END: 4597 event.preventDefault(); 4598 this.#focusButton(buttons[lastIndex].id); 4599 break;
4600 case Accordion.keyCodes.ENTER: 4601 case Accordion.keyCodes.SPACE: 4602 event.preventDefault(); 4603 var itemDivId = this.#convertToItemDivId(buttons[index].id); 4604 this.toggle(itemDivId); 4605 this.collapseAllOtherItems(itemDivId); 4606 this.#focusButton(buttons[index].id); 4607 break; 4608 default: 4609 return; 4610 } 4611 } 4612 4613 /** 4614 * Focuses the button at the provided index. 4615 * 4616 * @private 4617 * @param {Number} id The id of the button to focus 4618 */ 4619 #focusButton(id) { 4620 var button = this.#getButtonById(id); 4621 button.focus(); 4622 } 4623 4624 addChild(childView) { 4625 super.addChild(childView); 4626 this.#cacheTemplateHTML(childView); 4627 if (this.getCountOfAllChildrenInModel() === this.children.length) { 4628 this.cacheClosestFieldsInView(); 4629 this.handleHiddenChildrenVisibility(); 4630 } 4631 } 4632 4633 /** 4634 * Adds unique HTML for added instance corresponding to requirements of different types of repeatableParent 4635 * @param instanceManager of the repeated component 4636 * @param addedModel of the repeated component 4637 * @param htmlElement of the repeated component 4638 */ 4639 addRepeatableMarkup(instanceManager, addedModel, htmlElement) { 4640 var accordionItemDivToBeRepeated = this.#prepareAccordionMarkupToBeAdded(instanceManager, addedModel, htmlElement); 4641 let result = this.#getBeforeViewElement(instanceManager, addedModel.index); 4642 if (result.beforeViewElement != null) { 4643 result.beforeViewElement.after(accordionItemDivToBeRepeated); 4644 } else if (result.parentElement != null) { 4645 var firstChildAccordionItem = result.parentElement.querySelector(Accordion.selectors.item); 4646 if (firstChildAccordionItem != null) { 4647 result.parentElement.insertBefore(accordionItemDivToBeRepeated, firstChildAccordionItem); 4648 } else { 4649 result.parentElement.append(accordionItemDivToBeRepeated); 4650 } 4651 } 4652 this.#showHideRepeatableButtons(instanceManager); 4653 return accordionItemDivToBeRepeated; 4654 } 4655 4656 focusOnRepeatableInstances(id) { 4657 const panelId = id.replace(Accordion.idSuffixes.item, ""); 4658 const form = this.formContainer.getModel(); 4659 const tab = this.getModel().getState().items.find(item => item.type === 'array')?.items?.find(subItem => subItem.id === panelId) 4660 const field = form.getElement(tab?.id); 4661 if (field) { 4662 setTimeout(() => {form.setFocus(field)}, 0); 4663 } 4664 } 4665 4666 handleChildAddition(childView) { 4667 var itemDivToExpand; 4668 this.cacheElements(this._elements.self); 4669 this.#bindEventsToAddedChild(childView.id); 4670 if (childView.getInstanceManager().getModel().minOccur != undefined && childView.getInstanceManager().children.length > childView.getInstanceManager().getModel().minOccur) { 4671 itemDivToExpand = this.getItemById(childView.id + Accordion.idSuffixes.item); 4672 } else { 4673 //this will run at initial runtime loading when the repeatable panel is being added minOccur no of times. 4674 // in this case we want the focus to stay at first tab 4675 itemDivToExpand = this.findFirstVisibleChild(this.getCachedItems()); 4676 } 4677 this.expandItem(itemDivToExpand); 4678 this.collapseAllOtherItems(itemDivToExpand.id); 4679 4680 const cachedItems = this.getCachedItems();
4681 const newIndex = cachedItems.indexOf(itemDivToExpand); 4682 this.getCachedButtons()[newIndex].classList.remove(this.constructor.cssClasses.button.stepped); 4683 this.getCachedPanels()[newIndex].classList.remove(this.constructor.cssClasses.panel.stepped); 4684 4685 this.focusOnRepeatableInstances(itemDivToExpand.id); 4686 4687 this.#showHideRepeatableButtons(childView.getInstanceManager()); 4688 } 4689 4690 handleChildRemoval(removedInstanceView) { 4691 var removedAccordionItemDivId = removedInstanceView.element.id + Accordion.idSuffixes.item; 4692 var removedAccordionItemDiv = this.getItemById(removedAccordionItemDivId); 4693 4694 // Find the previous item before removing the current one 4695 var cachedItems = this.getCachedItems(); 4696 var currentIndex = cachedItems.indexOf(removedAccordionItemDiv); 4697 var itemDivToExpand = null; 4698 4699 // If there are items and current item is found 4700 if (cachedItems && cachedItems.length > 0 && currentIndex > -1) { 4701 // If there's a previous item, use it 4702 if (currentIndex > 0) { 4703 itemDivToExpand = cachedItems[currentIndex - 1]; 4704 } else { 4705 // If we're removing the first item, use the next one if available 4706 itemDivToExpand = cachedItems[1] || null; 4707 } 4708 } 4709 4710 // Now remove the item 4711 removedAccordionItemDiv.remove(); 4712 this.children.splice(this.children.indexOf(removedInstanceView), 1); 4713 this.cacheElements(this._elements.self); 4714 4715 // Expand the target item if found 4716 if (itemDivToExpand) { 4717 this.expandItem(itemDivToExpand); 4718 this.collapseAllOtherItems(itemDivToExpand.id); 4719 this.focusOnRepeatableInstances(itemDivToExpand.id) 4720 } 4721 4722 this.#showHideRepeatableButtons(removedInstanceView.getInstanceManager()); 4723 } 4724 4725 #syncLabel() { 4726 let labelElement = typeof this.getLabel === 'function' ? this.getLabel() : null; 4727 if (labelElement) { 4728 labelElement.setAttribute('for', this.getId()); 4729 } 4730 } 4731 4732 syncMarkupWithModel() { 4733 super.syncMarkupWithModel(); 4734 this.#syncLabel(); 4735 for (var itemDiv of this.getCachedItems()) { 4736 this.#syncAccordionMarkup(itemDiv); 4737 } 4738 } 4739 4740 getChildViewByIndex(index) { 4741 var accordionPanels = this.getCachedPanels(); 4742 var fieldId = accordionPanels[index].id.substring(0, accordionPanels[index].id.lastIndexOf("-")); 4743 return this.getChild(fieldId); 4744 } 4745 4746 #getBeforeViewElement(instanceManager, instanceIndex) { 4747 var result = {}; 4748 var instanceManagerId = instanceManager.getId(); 4749 if (instanceIndex == 0) { 4750 var closestNonRepeatableFieldId = this._templateHTML[instanceManagerId]['closestNonRepeatableFieldId']; 4751 var closestRepeatableFieldInstanceManagerIds = this._templateHTML[instanceManagerId]['closestRepeatableFieldInstanceManagerIds']; 4752 var indexToInsert = this.getIndexToInsert(closestNonRepeatableFieldId, closestRepeatableFieldInstanceManagerIds); 4753 if (indexToInsert > 0) { 4754 result.beforeViewElement = this.getCachedItems()[indexToInsert - 1]; 4755 } else { 4756 result.parentElement = this.element; 4757 } 4758 } else { 4759 let previousInstanceElement = this.#getRepeatableElementAt(instanceManager, instanceIndex - 1); 4760 result.beforeViewElement = previousInstanceElement; 4761 } 4762 return result; 4763 } 4764 4765 #getRepeatableElementAt(instanceManager, index) { 4766 let childId = instanceManager._model.items.find((model) => model.index === index)?.id; 4767 return this.element.querySelector(`#${childId}${Accordion.idSuffixes.item}`); 4768 } 4769 4770 #prepareAccordionMarkupToBeAdded(instanceManager, addedModel, htmlElement) { 4771 var accordionItemDivToBeRepeated = this._templateHTML[instanceManager.getId()]['accordionItemDiv'].cloneNode(true); 4772 var itemDivId = accordionItemDivToBeRepeated.id; 4773 var accordionPanelId = this.#convertToPanelId(itemDivId); 4774 var accordionPanelToBeRepeated = accordionItemDivToBeRepeated.querySelector('#' + accordionPanelId); 4775 while (accordionPanelToBeRepeated.hasChildNodes()) { 4776 accordionPanelToBeRepeated.removeChild(accordionPanelToBeRepeated.firstChild); 4777 } 4778 accordionPanelToBeRepeated.append(htmlElement); 4779 this.#syncAccordionMarkup(accordionItemDivToBeRepeated); 4780 return accordionItemDivToBeRepeated; 4781 } 4782 4783 #syncAccordionMarkup(accordionItemDiv) { 4784 var accordionItemDivId = accordionItemDiv.id; 4785 var accordionPanelId = this.#convertToPanelId(accordionItemDivId); 4786 var accordionButtonId = this.#convertToButtonId(accordionItemDivId); 4787 var accordionButton = accordionItemDiv.querySelector('#' + accordionButtonId); 4788 var accordionPanelDiv = accordionItemDiv.querySelector('#' + accordionPanelId); 4789 var childViewId = accordionItemDiv.querySelector("[data-cmp-is]").id; 4790 accordionItemDiv.id = childViewId + Accordion.idSuffixes.item; 4791 accordionButton.id = childViewId + Accordion.idSuffixes.button; 4792 accordionPanelDiv.id = childViewId + Accordion.idSuffixes.panel; 4793 accordionButton.setAttribute("aria-controls", childViewId + Accordion.idSuffixes.panel); 4794 accordionPanelDiv.setAttribute("aria-labelledby", childViewId + Accordion.idSuffixes.button); 4795 var accordionAdd = accordionItemDiv.querySelector(".cmp-accordion__add-button"); 4796 if (accordionAdd) { 4797 accordionAdd.setAttribute('data-cmp-hook-add-instance',
4797childViewId); 4798 } 4799 var accordionRemove = accordionItemDiv.querySelector(".cmp-accordion__remove-button"); 4800 if (accordionRemove) { 4801 accordionRemove.setAttribute('data-cmp-hook-remove-instance', childViewId); 4802 } 4803 } 4804 4805 #cacheTemplateHTML(childView) { 4806 if (childView.getInstanceManager() != null && (this._templateHTML == null || this._templateHTML[childView.getInstanceManager().getId()] == null)) { 4807 var accordionItemDivId = childView.element.id + Accordion.idSuffixes.item; 4808 var instanceManagerId = childView.getInstanceManager().getId(); 4809 var accordionItemDiv = this.getItemById(accordionItemDivId); 4810 this._templateHTML[instanceManagerId] = {}; 4811 this._templateHTML[instanceManagerId]['accordionItemDiv'] = accordionItemDiv; 4812 } 4813 } 4814 4815 #getButtonById(buttonId) { 4816 var buttons = this.getCachedButtons(); 4817 if (buttons) { 4818 for (var i = 0; i < buttons.length; i++) { 4819 if (buttons[i].id === buttonId) { 4820 return buttons[i]; 4821 } 4822 } 4823 } 4824 } 4825 4826 #getButtonIndexById(buttonId) { 4827 var buttons = this.getCachedButtons(); 4828 if (buttons) { 4829 for (var i = 0; i < buttons.length; i++) { 4830 if (buttons[i].id === buttonId) { 4831 return i; 4832 } 4833 } 4834 } 4835 return -1; 4836 } 4837 4838 /** 4839 * Changes provided panel or buttonId to ItemId 4840 * 4841 * @private 4842 * @param {Number} id The id of the panel/button to convert to corresponding item div 4843 */ 4844 #convertToItemDivId(idToConvert) { 4845 return idToConvert.substring(0, idToConvert.lastIndexOf("-")) + Accordion.idSuffixes.item; 4846 } 4847 4848 /** 4849 * Changes provided panel or item id to Button Id 4850 * 4851 * @private 4852 * @param {Number} id The id of the panel/item to convert to corresponding button id 4853 */ 4854 #convertToButtonId(idToConvert) { 4855 return idToConvert.substring(0, idToConvert.lastIndexOf("-")) + Accordion.idSuffixes.button; 4856 } 4857 4858 /** 4859 * Changes provided button or item id to Panel Id 4860 * 4861 * @private 4862 * @param {Number} id The id of the button/item to convert to corresponding button id 4863 */ 4864 #convertToPanelId(idToConvert) { 4865 return idToConvert.substring(0, idToConvert.lastIndexOf("-")) + Accordion.idSuffixes.panel; 4866 } 4867 4868 updateChildVisibility(visible, state) { 4869 this.updateVisibilityOfNavigationElement(this.getItemById(state.id + Accordion.idSuffixes.item), visible); 4870 if (!visible) { 4871 var expandedItems = this.getExpandedItems(); 4872 for (let i = 0; i < expandedItems.length; i++) { 4873 if (expandedItems[i].getAttribute(Accordion.DATA_ATTRIBUTE_VISIBLE) === 'false') { 4874 this.collapseItem(expandedItems[i]); 4875 } 4876 } 4877 let child = this.findFirstVisibleChild(this.getCachedItems()); 4878 if (child) { 4879 this.expandItem(child); 4880 } 4881 } 4882 } 4883 4884 getRepeatableRootElement(childView) { 4885 return this.element.querySelector('#' + childView.id + '-item div[data-cmp-hook-adaptiveFormAccordion="repeatableButton"]') 4886 } 4887 4888 #showHideRepeatableButtons(instanceManager) { 4889 const {_model: {minOccur, maxOccur, items = []} = {}, children} = instanceManager;
4890 children.forEach(child => { 4891 const addButtonElement = this.element.querySelector('#' + child.id + '-item')?.querySelector('[data-cmp-hook-add-instance]'); 4892 const removeButtonElement = this.element.querySelector('#' + child.id + '-item')?.querySelector('[data-cmp-hook-remove-instance]'); 4893 if (addButtonElement) { 4894 addButtonElement.setAttribute(Accordion.DATA_ATTRIBUTE_VISIBLE, !(items.length === maxOccur && maxOccur != -1)) 4895 } 4896 if (removeButtonElement) { 4897 removeButtonElement.setAttribute(Accordion.DATA_ATTRIBUTE_VISIBLE, items.length > minOccur && minOccur != -1) 4898 } 4899 }); 4900 } 4901 } 4902 4903 FormView.Utils.setupField(({element, formContainer}) => { 4904 return new Accordion({element, formContainer}) 4905 }, Accordion.selectors.self); 4906 } 4907 4908 if (window.Forms && window.Forms.CoreComponentsCommons && window.Forms.CoreComponentsCommons.AccordionMixin) { 4909 onAccordionMixinLoaded({ detail: { AccordionMixin: window.Forms.CoreComponentsCommons.AccordionMixin } }); 4910 } else { 4911 window.addEventListener('AccordionMixinLoaded', onAccordionMixinLoaded); 4912 } 4913})(); 4914 4915/******************************************************************************* 4916 * Copyright 2022 Adobe 4917 * 4918 * Licensed under the Apache License, Version 2.0 (the "License"); 4919 * you may not use this file except in compliance with the License. 4920 * You may obtain a copy of the License at 4921 * 4922 * http://www.apache.org/licenses/LICENSE-2.0 4923 * 4924 * Unless required by applicable law or agreed to in writing, software 4925 * distributed under the License is distributed on an "AS IS" BASIS, 4926 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4927 * See the License for the specific language governing permissions and 4928 * limitations under the License. 4929 ******************************************************************************/ 4930 4931(function () { 4932 4933 class Tabs extends FormView.FormTabs { 4934 _templateHTML = {}; 4935 static NS = FormView.Constants.NS; 4936 static IS = "adaptiveFormTabs"; 4937 static bemBlock = "cmp-tabs"; 4938 static selectors = { 4939 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 4940 active: { 4941 tab: "cmp-tabs__tab--active", 4942 tabpanel: "cmp-tabs__tabpanel--active" 4943 }, 4944 stepped: { 4945 tab: "cmp-tabs__tab--stepped", 4946 tabpanel: "cmp-tabs__tabpanel--stepped" 4947 }, 4948 label: `.${Tabs.bemBlock}__label`, 4949 description: `.${Tabs.bemBlock}__longdescription`, 4950 qm: `.${Tabs.bemBlock}__questionmark`, 4951 tooltipDiv: `.${Tabs.bemBlock}__shortdescription`, 4952 olTabList: `.${Tabs.bemBlock}__tablist`, 4953 widget: `.${Tabs.bemBlock}__tablist` 4954 }; 4955 4956 constructor(params) { 4957 super(params, Tabs.NS, Tabs.IS, Tabs.selectors); 4958 } 4959 4960 4961 getClass() { 4962 return Tabs.IS; 4963 } 4964 4965 setFocus(id) { 4966 super.setFocus(id); 4967 this.setActive(); 4968 if (id) { 4969 this.navigateAndFocusTab(id + '__tab'); 4970 } 4971 } 4972 4973 getWidget() { 4974 return this.element.querySelector(Tabs.selectors.widget); 4975 } 4976 4977 getDescription() { 4978 return this.element.querySelector(Tabs.selectors.description); 4979 } 4980 4981 getLabel() { 4982 return this.element.querySelector(Tabs.selectors.label); 4983 } 4984 4985 getErrorDiv() { 4986 return this.element.querySelector(Tabs.selectors.errorDiv); 4987 } 4988 4989 getTooltipDiv() { 4990 return this.element.querySelector(Tabs.selectors.tooltipDiv); 4991 } 4992 4993 getQuestionMarkDiv() { 4994 return this.element.querySelector(Tabs.selectors.qm); 4995 } 4996 } 4997 4998 FormView.Utils.setupField(({element, formContainer}) => { 4999 return new Tabs({element, formContainer}) 5000 }, Tabs.selectors.self); 5001 5002}()); 5003 5004/******************************************************************************* 5005 * Copyright 2022 Adobe 5006 * 5007 * Licensed under the Apache License, Version 2.0 (the "License");
5008 * you may not use this file except in compliance with the License. 5009 * You may obtain a copy of the License at 5010 * 5011 * http://www.apache.org/licenses/LICENSE-2.0 5012 * 5013 * Unless required by applicable law or agreed to in writing, software 5014 * distributed under the License is distributed on an "AS IS" BASIS, 5015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5016 * See the License for the specific language governing permissions and 5017 * limitations under the License. 5018 ******************************************************************************/ 5019 5020(function () { 5021 5022 function onWizardMixinLoaded(event) { 5023 const WizardMixin = event.detail.WizardMixin; 5024 const keyCodes = { 5025 END: 35, 5026 HOME: 36, 5027 ARROW_LEFT: 37, 5028 ARROW_UP: 38, 5029 ARROW_RIGHT: 39, 5030 ARROW_DOWN: 40 5031 }; 5032 5033 class Wizard extends WizardMixin(FormView.FormPanel) { 5034 5035 _templateHTML = {}; 5036 5037 static NS = FormView.Constants.NS; 5038 static #tabIdSuffix = "_wizard-item-nav"; 5039 static #wizardPanelIdSuffix = "__wizardpanel"; 5040 5041 static selectors = { 5042 self: "[data-" + Wizard.NS + '-is="' + Wizard.IS + '"]', 5043 active: { 5044 tab: "cmp-adaptiveform-wizard__tab--active", 5045 wizardpanel: "cmp-adaptiveform-wizard__wizardpanel--active" 5046 }, 5047 stepped: { 5048 tab: "cmp-adaptiveform-wizard__tab--stepped", 5049 wizardpanel: "cmp-adaptiveform-wizard__wizardpanel--stepped", 5050 }, 5051 label: `.${Wizard.bemBlock}__label`, 5052 description: `.${Wizard.bemBlock}__longdescription`, 5053 qm: `.${Wizard.bemBlock}__questionmark`, 5054 widget: `.${Wizard.bemBlock}__widget`, 5055 tooltipDiv: `.${Wizard.bemBlock}__shortdescription`, 5056 previousButton: `.${Wizard.bemBlock}__previousNav`, 5057 previousButtonHidden: "cmp-adaptiveform-wizard__previousNav--hidden", 5058 nextButton: `.${Wizard.bemBlock}__nextNav`, 5059 previousButtonV2: `.${Wizard.bemBlock}__nav--previous`, 5060 nextButtonV2: `.${Wizard.bemBlock}__nav--next`, 5061 nextButtonHidden: "cmp-adaptiveform-wizard__nextNav--hidden", 5062 olTabList: `.${Wizard.bemBlock}__tabList` 5063 }; 5064 5065 constructor(params) { 5066 super(params); 5067 const {element} = params; 5068 this.cacheElements(element); 5069 this.setActive(this.getCachedTabs()) 5070 this._active = this.getActiveIndex(this.getCachedTabs()); 5071 this.#setNavigationRange(); 5072 this.#hideUnhideNavButtons(this._active); 5073 this.refreshActive(); 5074 5075 this.#bindEvents(); 5076 } 5077 5078 getClass() { 5079 return Wizard.IS; 5080 } 5081 5082 setFocus(id) { 5083 super.setFocus(id); 5084 this.setActive(); 5085 const index = this.#getTabIndexById(id + '_wizard-item-nav'); 5086 this.navigate(index); 5087 } 5088 5089 getWidget() { 5090 return this.element.querySelector(Wizard.selectors.widget); 5091 } 5092 5093 getDescription() { 5094 return this.element.querySelector(Wizard.selectors.description); 5095 } 5096 5097 getLabel() { 5098 return this.element.querySelector(Wizard.selectors.label); 5099 } 5100 5101 getErrorDiv() { 5102 return this.element.querySelector(Wizard.selectors.errorDiv); 5103 } 5104 5105 getTooltipDiv() { 5106 return this.element.querySelector(Wizard.selectors.tooltipDiv); 5107 } 5108 5109 getQuestionMarkDiv() { 5110 return this.element.querySelector(Wizard.selectors.qm); 5111 } 5112 5113 getPreviousButtonDiv() { 5114 return (this.element.querySelector(Wizard.selectors.previousButton) || this.element.querySelector(Wizard.selectors.previousButtonV2)); 5115 } 5116 5117 getNextButtonDiv() { 5118 return (this.element.querySelector(Wizard.selectors.nextButton) || this.element.querySelector(Wizard.selectors.nextButtonV2)); 5119 } 5120 5121 #getTabListElement() { 5122 return this.element.querySelector(Wizard.selectors.olTabList) 5123 } 5124 5125 5126 /** 5127 * Binds navigation buttons event handling 5128 * 5129 * @private 5130 */ 5131 #bindEvents() { 5132 const _self = this; 5133 this.getNextButtonDiv().addEventListener("click", function (event) { 5134 _self.#navigateToNextTab(); 5135 }) 5136 this.getPreviousButtonDiv().addEventListener("click", function (event) { 5137 _self.#navigateToPreviousTab(); 5138 }) 5139 5140 5141 } 5142 5143 /** 5144 * Handles tab keydown events 5145 * 5146 * @private 5147 * @param {Object} event The keydown event 5148 */ 5149 #onKeyDown(event) { 5150 const index = this._active; 5151 5152 const lastIndex = this.getCachedTabs().length - 1; 5153 5154 switch (event.keyCode) { 5155 case keyCodes.ARROW_LEFT: 5156 case keyCodes.ARROW_UP: 5157 event.preventDefault(); 5158 if (index > 0) { 5159 this.#navigateAndFocusTab(index - 1); 5160 } 5161 break; 5162 case keyCodes.ARROW_RIGHT: 5163 case keyCodes.ARROW_DOWN: 5164 event.preventDefault(); 5165 if (index < lastIndex) { 5166 this.#navigateAndFocusTab(index + 1); 5167 } 5168 break; 5169 case keyCodes.HOME: 5170 event.preventDefault(); 5171 this.#navigateAndFocusTab(0); 5172 break; 5173 case keyCodes.END: 5174 event.preventDefault(); 5175 this.#navigateAndFocusTab(lastIndex); 5176 break; 5177 default: 5178 return; 5179 } 5180 } 5181 5182 /** 5183 * Refreshes the tab markup based on the current {@code Tabs_active} index 5184 * 5185 * @private 5186 */ 5187 refreshActive() { 5188 super.refreshActive(); 5189 this.#hideUnhideNavButtons(this._active); 5190 } 5191 5192 /** 5193 * Focuses the element and prevents scrolling the element into view 5194 * 5195 * @param {HTMLElement} element Element to focus 5196 */ 5197 focusWithoutScroll(element) { 5198 const x = window.scrollX || window.pageXOffset; 5199 const y = window.scrollY || window.pageYOffset; 5200 element.focus(); 5201 window.scrollTo(x, y); 5202 } 5203 5204 5205 getFocusElementId() { 5206 const activeIndex = this._active; 5207 const activeTabElement = this.getCachedTabs()[activeIndex]; 5208 return activeTabElement.id.substring(0, activeTabElement.id.lastIndexOf(Wizard.#tabIdSuffix)); 5209 } 5210 5211 #navigateToNextTab() { 5212 const activeIndex = this._active; 5213 const activeTabElement = this.getCachedTabs()[activeIndex]; 5214 const activeChildId = activeTabElement.id.substring(0, activeTabElement.id.lastIndexOf(Wizard.#tabIdSuffix)); 5215 const activeChildView = this.getChild(activeChildId); 5216 let activeChildModel; 5217 if (activeChildView) { 5218 activeChildModel = activeChildView.getModel(); 5219 } else { 5220 activeChildModel = this.getModel().items.find(child => child.id === activeChildId); 5221 } 5222 let validationErrorList; 5223 if (!this.#isAuthoring()) { 5224 validationErrorList = activeChildModel.validate(); 5225 } 5226 if (validationErrorList === undefined || validationErrorList.length == 0) { 5227 let tabs = this.getCachedTabs(); 5228 let nextVisibleIndex = this.#findNextVisibleChildIndex(activeIndex); 5229 if (tabs && nextVisibleIndex >= 0) { 5230 this.#navigateAndFocusTab(nextVisibleIndex); 5231 } 5232 } 5233 this.#hideUnhideNavButtons(this._active); 5234 } 5235 5236 #isAuthoring() { 5237 return window.Granite && window.Granite.author; 5238 } 5239 5240 #navigateToPreviousTab() { 5241 const activeIndex = this._active; 5242 const tabs = this.getCachedTabs(); 5243 const lastVisibleIndex = this.#findLastVisibleChildIndex(activeIndex); 5244 if (tabs && lastVisibleIndex >= 0) { 5245 this.#navigateAndFocusTab(lastVisibleIndex); 5246 } 5247 this.#hideUnhideNavButtons(this._active); 5248 } 5249 5250 /** 5251 * Hides or shows, next and previous navigation buttons 5252 * 5253 * @private 5254 * @param {Number} index The index of the tab to navigate to 5255 * @param {Number} total number of tabs 5256 */ 5257 #hideUnhideNavButtons(activeTabIndex) { 5258 const tabsLength = this.getCachedTabs() ? this.getCachedTabs().length : 0; 5259 5260 const nextVisible = this.#findNextVisibleChildIndex(activeTabIndex); 5261 const previousVisible = this.#findLastVisibleChildIndex(activeTabIndex); 5262 5263 if (tabsLength === 0 || this.maxEnabledTab <= this.minEnabledTab) { 5264 this.getPreviousButtonDiv().setAttribute(Wizard.DATA_ATTRIBUTE_VISIBLE, "false"); 5265 this.getNextButtonDiv().setAttribute(Wizard.DATA_ATTRIBUTE_VISIBLE, "false"); 5266 } 5267 5268 if (activeTabIndex <= this.minEnabledTab || previousVisible === -1) { 5269 this.getPreviousButtonDiv().setAttribute(Wizard.DATA_ATTRIBUTE_VISIBLE, "false"); 5270 } 5271 if (activeTabIndex === this.maxEnabledTab || nextVisible === -1) { 5272 this.getNextButtonDiv().setAttribute(Wizard.DATA_ATTRIBUTE_VISIBLE, "false"); 5273 } 5274 5275 if (tabsLength > 1 && activeTabIndex > this.minEnabledTab && previousVisible > -1) { 5276 this.getPreviousButtonDiv().setAttribute(Wizard.DATA_ATTRIBUTE_VISIBLE, "true"); 5277 } 5278 5279 if (activeTabIndex < this.maxEnabledTab && nextVisible > -1) { 5280 this.getNextButtonDiv().setAttribute(Wizard.DATA_ATTRIBUTE_VISIBLE, "true"); 5281 } 5282 } 5283 5284 #setNavigationRange() { 5285 const wizardPanels = this.getCachedWizardPanels(); 5286 if (wizardPanels) { 5287 this.maxEnabledTab = wizardPanels.length - 1; 5288 this.minEnabledTab = 0; 5289 for (let i = 0; i < wizardPanels.length; i++) { 5290 if (!this.#childComponentVisible(this.getCachedWizardPanels()[i])) { 5291 this.minEnabledTab = i + 1; 5292 } else { 5293 break; 5294 } 5295 } 5296 for (let i = wizardPanels.length - 1; i >= 0; i--) { 5297 if (!this.#childComponentVisible(this.getCachedWizardPanels()[i])) { 5298 this.maxEnabledTab = i; 5299 } else { 5300 break; 5301 } 5302 } 5303 this.minEnabledTab = Math.max(0, this.minEnabledTab); 5304 this.maxEnabledTab = Math.min(this.getCachedTabs().length - 1, this.maxEnabledTab); 5305 } 5306 } 5307 5308 #childComponentVisible(wizardTab) { 5309 return wizardTab.children[0].getAttribute('data-cmp-visible') === 'true'; 5310 } 5311 5312 #findNextVisibleChildIndex(currentIndex) { 5313 const tabs = this.getCachedTabs(); 5314 const tabsLength = tabs ? tabs.length : 0; 5315 for (let i = currentIndex + 1; i < tabsLength; i++) { 5316 let isVisible = tabs[i].getAttribute(Wizard.DATA_ATTRIBUTE_VISIBLE); 5317 if (isVisible === null || isVisible === 'true') { 5318 return i; 5319 } 5320 } 5321 return -1; 5322 } 5323 5324 #findLastVisibleChildIndex(currentIndex) { 5325 const tabs = this.getCachedTabs(); 5326 if (tabs) { 5327 for (let i = currentIndex - 1; i >= 0; i--) { 5328 let isVisible = tabs[i].getAttribute(Wizard.DATA_ATTRIBUTE_VISIBLE); 5329 if (isVisible === null || isVisible === 'true') { 5330 return i; 5331 } 5332 } 5333 } 5334 return -1; 5335 } 5336 5337 /** 5338 * Navigates to the item at the provided index and ensures the active tab gains focus 5339 * 5340 * @private 5341 * @param {Number} index The index of the item to navigate to 5342 */ 5343 #navigateAndFocusTab(index) { 5344 this.navigate(index); 5345 this.focusWithoutScroll(this.getCachedTabs()[index]); 5346 const id = this.getFocusElementId(); 5347 this.focusToFirstVisibleField(id); 5348 } 5349 5350 #syncWizardNavLabels() { 5351 const tabs = this.getCachedTabs(); 5352 const wizardPanels = this.getCachedWizardPanels(); 5353 if (tabs) { 5354 for (let i = 0; i < tabs.length; i++) { 5355 let id = wizardPanels[i].querySelectorAll("[data-cmp-is]")[0].id; 5356 tabs[i].id = id + Wizard.#tabIdSuffix; 5357 tabs[i].setAttribute("aria-controls", id + Wizard.#wizardPanelIdSuffix); 5358 } 5359 } 5360 } 5361 5362 #syncWizardPanels() { 5363 const wizardPanels = this.getCachedWizardPanels(); 5364 if (wizardPanels) { 5365 for (let i = 0; i < wizardPanels.length; i++) { 5366 let id = wizardPanels[i].querySelectorAll("[data-cmp-is]")[0].id; 5367 wizardPanels[i].id = id + Wizard.#wizardPanelIdSuffix; 5368 wizardPanels[i].setAttribute("aria-labelledby", id + Wizard.#tabIdSuffix); 5369 } 5370 } 5371 } 5372 5373 syncMarkupWithModel() { 5374 super.syncMarkupWithModel(); 5375 this.#syncWizardNavLabels(); 5376 this.#syncWizardPanels(); 5377 } 5378 5379 handleChildAddition(childView) { 5380 if (childView.getInstanceManager() != null && this._templateHTML[childView.getInstanceManager().getId()] != null) { 5381 let navigationTabToBeRepeated = this._templateHTML[childView.getInstanceManager().getId()]['navigationTab'] 5382 .cloneNode(true); 5383 navigationTabToBeRepeated.id = childView.id + Wizard.#tabIdSuffix; 5384 navigationTabToBeRepeated.setAttribute("aria-controls", childView.id + Wizard.#wizardPanelIdSuffix); 5385 let instanceIndex = childView.getModel().index; 5386 let instanceManagerId = childView.getInstanceManager().getId() 5387 if (instanceIndex == 0) { 5388 let closestNonRepeatableFieldId = this._templateHTML[instanceManagerId]['closestNonRepeatableFieldId']; 5389 let closestRepeatableFieldInstanceManagerIds = this._templateHTML[instanceManagerId]['closestRepeatableFieldInstanceManagerIds']; 5390 let indexToInsert = this.getIndexToInsert(closestNonRepeatableFieldId, closestRepeatableFieldInstanceManagerIds); 5391 if (indexToInsert == 0) { 5392 let tabListParentElement = this.#getTabListElement(); 5393
5393 tabListParentElement.insertBefore(navigationTabToBeRepeated, tabListParentElement.firstChild); 5394 } else { 5395 let beforeElement = this.getCachedTabs()[indexToInsert - 1]; 5396 beforeElement.after(navigationTabToBeRepeated); 5397 } 5398 } else { 5399 let beforeTabNavElementId = childView.getInstanceManager().children[instanceIndex - 1].element.id + Wizard.#tabIdSuffix 5400 let beforeElement = this.getTabNavElementById(beforeTabNavElementId); 5401 beforeElement.after(navigationTabToBeRepeated); 5402 } 5403 this.cacheElements(this._elements.self); 5404 let repeatedWizardPanel = this.#getWizardPanelElementById(childView.id + Wizard.#wizardPanelIdSuffix); 5405 repeatedWizardPanel.setAttribute("aria-labelledby", childView.id + Wizard.#tabIdSuffix); 5406 5407 const steppedTabClass = Array.from(navigationTabToBeRepeated.classList).find(cls => cls.includes('--stepped')); 5408 if (steppedTabClass) { 5409 navigationTabToBeRepeated.classList.remove(steppedTabClass); 5410 } 5411 const steppedWizardPanelClass = Array.from(repeatedWizardPanel.classList).find(cls => cls.includes('--stepped')); 5412 if (steppedWizardPanelClass) { 5413 repeatedWizardPanel.classList.remove(steppedWizardPanelClass); 5414 } 5415 this.refreshActive(); 5416 this.#getTabIndexById(); 5417 if (childView.getInstanceManager().getModel().minOccur != undefined && childView.getInstanceManager().children.length > childView.getInstanceManager().getModel().minOccur) { 5418 this.#navigateAndFocusTab(this.#getTabIndexById(navigationTabToBeRepeated.id)); 5419 } 5420 } 5421 } 5422 5423 handleChildRemoval(removedInstanceView) { 5424 let removedTabPanelId = removedInstanceView.element.id + Wizard.#wizardPanelIdSuffix; 5425 let removedTabNavId = removedTabPanelId.substring(0, removedTabPanelId.lastIndexOf("__")) + Wizard.#tabIdSuffix; 5426 let wizardPanelElement = this.#getWizardPanelElementById(removedTabPanelId); 5427 let tabNavElement = this.getTabNavElementById(removedTabNavId); 5428 5429 const tabs = this.getCachedTabs(); 5430 const currentIndex = Array.from(tabs).findIndex(tab => tab.id === removedTabNavId); 5431 let nextIndex = -1; 5432 5433 if (currentIndex === 0) { 5434 // If removing first tab, focus on the next one 5435 nextIndex = 1; 5436 } else { 5437 // Look for previous visible tab 5438 for (let i = currentIndex - 1; i >= 0; i--) { 5439 nextIndex = i; 5440 break; 5441 } 5442 } 5443 5444 tabNavElement.remove(); 5445 wizardPanelElement.remove(); 5446 this.children.splice(this.children.indexOf(removedInstanceView), 1); 5447 this.cacheElements(this._elements.self); 5448 this._active = this.getActiveIndex(this.getCachedTabs()); 5449 this.refreshActive(); 5450 5451 // Focus the next tab after active state is updated 5452 if (nextIndex !== -1 && tabs[nextIndex]) { 5453 this.#navigateAndFocusTab(nextIndex); 5454 } 5455 } 5456 5457 addChild(childView) { 5458 super.addChild(childView); 5459 this.#cacheTemplateHTML(childView); 5460 //when all children are available in view 5461 if (this.getCountOfAllChildrenInModel() === this.children.length) { 5462 this.cacheClosestFieldsInView(); 5463 this.handleHiddenChildrenVisibility(); 5464 } 5465 this.#setNavigationRange(); 5466 this.#hideUnhideNavButtons(this._active); 5467 } 5468 5469 getChildViewByIndex(index) { 5470 let wizardPanels = this.getCachedWizardPanels(); 5471 let fieldId = wizardPanels[index].id.substring(0, wizardPanels[index].id.lastIndexOf("__")); 5472 return this.getChild(fieldId); 5473 } 5474 5475 /** 5476 * Adds unique HTML for added instance corresponding to requirements of different types of repeatableParent 5477 * @param instanceManager of the repeated component 5478 * @param addedModel of the repeated component 5479 * @param htmlElement of the repeated component 5480 */ 5481 addRepeatableMarkup(instanceManager, addedModel, htmlElement) { 5482 let elementToEnclose = this._templateHTML[instanceManager.getId()]['targetWizardPanel'].cloneNode(false); 5483 elementToEnclose.id = addedModel.id + Wizard.#wizardPanelIdSuffix; 5484 let result = this.#getBeforeViewElement(instanceManager, addedModel.index); 5485 let beforeViewElement = result.beforeViewElement; 5486 beforeViewElement.after(elementToEnclose); 5487 elementToEnclose.append(htmlElement.querySelector('#' + addedModel.id)); 5488 return elementToEnclose; 5489 } 5490 5491 #cacheTemplateHTML(childView) { 5492 if (childView.getInstanceManager() != null && (this._templateHTML == null || this._templateHTML[childView.getInstanceManager().getId()] == null)) {
5493 let tabId = childView.element.id + Wizard.#tabIdSuffix; 5494 let wizardPanelId = childView.element.id + Wizard.#wizardPanelIdSuffix; 5495 let instanceManagerId = childView.getInstanceManager().getId(); 5496 let navigationTabToBeRepeated = this.getTabNavElementById(tabId); 5497 let wizardPanelToBeRepeated = this.#getWizardPanelElementById(wizardPanelId) 5498 this._templateHTML[instanceManagerId] = {}; 5499 this._templateHTML[instanceManagerId]['navigationTab'] = navigationTabToBeRepeated; 5500 this._templateHTML[instanceManagerId]['targetWizardPanel'] = wizardPanelToBeRepeated; 5501 } 5502 } 5503 5504 #getWizardPanelElementById(wizardPanelId) { 5505 let wizardPanels = this.getCachedWizardPanels(); 5506 if (wizardPanels) { 5507 for (let i = 0; i < wizardPanels.length; i++) { 5508 if (wizardPanels[i].id === wizardPanelId) { 5509 return wizardPanels[i]; 5510 } 5511 } 5512 } 5513 } 5514 5515 #getTabIndexById(tabId) { 5516 let tabs = this.getCachedTabs(); 5517 if (tabs) { 5518 for (let i = 0; i < tabs.length; i++) { 5519 if (tabs[i].id === tabId) { 5520 return i; 5521 } 5522 } 5523 } 5524 return -1; 5525 } 5526 5527 #getBeforeViewElement(instanceManager, instanceIndex) { 5528 let result = {}; 5529 let instanceManagerId = instanceManager.getId(); 5530 if (instanceIndex == 0) { 5531 let closestNonRepeatableFieldId = this._templateHTML[instanceManagerId]['closestNonRepeatableFieldId']; 5532 let closestRepeatableFieldInstanceManagerIds = this._templateHTML[instanceManagerId]['closestRepeatableFieldInstanceManagerIds']; 5533 let indexToInsert = this.getIndexToInsert(closestNonRepeatableFieldId, closestRepeatableFieldInstanceManagerIds); 5534 let wizardPanels = this.getCachedWizardPanels(); 5535 if (indexToInsert > 0) { 5536 result.beforeViewElement = this.#getWizardPanelElementById(wizardPanels[indexToInsert - 1].id); 5537 } else { 5538 result.beforeViewElement = this.getPreviousButtonDiv(); 5539 } 5540 } else { 5541 let previousInstanceElement = this.#getRepeatableElementAt(instanceManager, instanceIndex - 1) 5542 result.beforeViewElement = previousInstanceElement; 5543 } 5544 return result; 5545 } 5546 5547 #getRepeatableElementAt(instanceManager, index) { 5548 let childId = instanceManager._model.items.find((model) => model.index === index)?.id; 5549 return this.element.querySelector(`#${childId}${Wizard.#wizardPanelIdSuffix}`); 5550 } 5551 5552 updateChildVisibility(visible, state) { 5553 this.updateVisibilityOfNavigationElement(this.getTabNavElementById(state.id + Wizard.#tabIdSuffix), visible); 5554 let activeTabNavElement = this.getCachedTabs()[this._active]; 5555 this.#setNavigationRange(); 5556 this.#hideUnhideNavButtons(this._active); 5557 if (!visible && activeTabNavElement.id === state.id + Wizard.#tabIdSuffix) { 5558 let child = this.findFirstVisibleChild(this.getCachedTabs()); 5559 if (child) { 5560 this.#navigateAndFocusTab(this.#getTabIndexById(child.id)); 5561 } 5562 } 5563 } 5564 } 5565 5566 FormView.Utils.setupField(({element, formContainer}) => { 5567 return new Wizard({element, formContainer}) 5568 }, Wizard.selectors.self); 5569 } 5570 5571 if (window.Forms && window.Forms.CoreComponentsCommons && window.Forms.CoreComponentsCommons.WizardMixin) { 5572 onWizardMixinLoaded({ detail: { WizardMixin: window.Forms.CoreComponentsCommons.WizardMixin } }); 5573 } else { 5574 window.addEventListener('WizardMixinLoaded', onWizardMixinLoaded); 5575 } 5576 5577}()); 5578 5579/******************************************************************************* 5580 * Copyright 2023 Adobe 5581 * 5582 * Licensed under the Apache License, Version 2.0 (the "License");
5583 * you may not use this file except in compliance with the License. 5584 * You may obtain a copy of the License at 5585 * 5586 * http://www.apache.org/licenses/LICENSE-2.0 5587 * 5588 * Unless required by applicable law or agreed to in writing, software 5589 * distributed under the License is distributed on an "AS IS" BASIS, 5590 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5591 * See the License for the specific language governing permissions and 5592 * limitations under the License. 5593 ******************************************************************************/ 5594 5595(function () { 5596 5597 class VerticalTabs extends FormView.FormTabs { 5598 _templateHTML = {}; 5599 static NS = FormView.Constants.NS; 5600 static IS = "adaptiveFormVerticalTabs"; 5601 static bemBlock = "cmp-verticaltabs"; 5602 static selectors = { 5603 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 5604 active: { 5605 tab: "cmp-verticaltabs__tab--active", 5606 tabpanel: "cmp-verticaltabs__tabpanel--active" 5607 }, 5608 stepped: { 5609 tab: "cmp-verticaltabs__tab--stepped", 5610 tabpanel: "cmp-verticaltabs__tabpanel--stepped" 5611 }, 5612 label: `.${VerticalTabs.bemBlock}__label`, 5613 description: `.${VerticalTabs.bemBlock}__longdescription`, 5614 qm: `.${VerticalTabs.bemBlock}__questionmark`, 5615 tooltipDiv: `.${VerticalTabs.bemBlock}__shortdescription`, 5616 olTabList: `.${VerticalTabs.bemBlock}__tablist`, 5617 widget: `.${VerticalTabs.bemBlock}__tabs-container` 5618 }; 5619 5620 constructor(params) { 5621 super(params, VerticalTabs.NS, VerticalTabs.IS, VerticalTabs.selectors); 5622 } 5623 5624 getClass() { 5625 return VerticalTabs.IS; 5626 } 5627 5628 setFocus(id) { 5629 super.setFocus(id); 5630 this.setActive(); 5631 if(id) { 5632 this.navigateAndFocusTab(id + '__tab'); 5633 } 5634 } 5635 5636 getWidget() { 5637 return this.element.querySelector(VerticalTabs.selectors.widget); 5638 } 5639 5640 getDescription() { 5641 return this.element.querySelector(VerticalTabs.selectors.description); 5642 } 5643 5644 getLabel() { 5645 return this.element.querySelector(VerticalTabs.selectors.label); 5646 } 5647 5648 getErrorDiv() { 5649 return this.element.querySelector(VerticalTabs.selectors.errorDiv); 5650 } 5651 5652 getTooltipDiv() { 5653 return this.element.querySelector(VerticalTabs.selectors.tooltipDiv); 5654 } 5655 5656 getQuestionMarkDiv() { 5657 return this.element.querySelector(VerticalTabs.selectors.qm); 5658 } 5659 } 5660 5661 FormView.Utils.setupField(({element, formContainer}) => { 5662 return new VerticalTabs({element, formContainer}) 5663 }, VerticalTabs.selectors.self); 5664 5665}()); 5666 5667/******************************************************************************* 5668 * Copyright 2023 Adobe 5669 * 5670 * Licensed under the Apache License, Version 2.0 (the "License"); 5671 * you may not use this file except in compliance with the License. 5672 * You may obtain a copy of the License at 5673 * 5674 * http://www.apache.org/licenses/LICENSE-2.0 5675 * 5676 * Unless required by applicable law or agreed to in writing, software 5677 * distributed under the License is distributed on an "AS IS" BASIS, 5678 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5679 * See the License for the specific language governing permissions and 5680 * limitations under the License. 5681 ******************************************************************************/ 5682(function() { 5683 5684 "use strict"; 5685 class Recaptcha extends FormView.FormFieldBase { 5686 5687 static NS = FormView.Constants.NS; 5688 static IS = "adaptiveFormRecaptcha"; 5689 static bemBlock = 'cmp-adaptiveform-recaptcha'; 5690 static selectors = { 5691 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 5692 widget: `.${Recaptcha.bemBlock}__widget`, 5693 label: `.${Recaptcha.bemBlock}__label`, 5694 errorDiv: `.${Recaptcha.bemBlock}__errormessage` 5695 }; 5696 5697 constructor(params) { 5698 super(params); 5699 } 5700 5701 getWidget() { 5702 return this.element.querySelector(Recaptcha.selectors.widget); 5703 } 5704 5705 getDescription() { 5706 return null; 5707 } 5708 5709 getLabel() { 5710 return this.element.querySelector(Recaptcha.selectors.label); 5711 } 5712 5713 getTooltipDiv() { 5714 return null; 5715 } 5716 5717 getErrorDiv() { 5718 return this.element.querySelector(Recaptcha.selectors.errorDiv); 5719 } 5720 5721 getQuestionMarkDiv() { 5722 return null; 5723 } 5724 5725 initializeWidget() { 5726 this.widgetObject = new RecaptchaWidget(this, this._model, this.getWidget()); 5727 this.getWidget().addEventListener('blur', (e) => { 5728 if(this.element) { 5729 this.setInactive(); 5730 } 5731 }); 5732 5733 } 5734 5735 setModel(model) { 5736 super.setModel(model); 5737 if (this.widgetObject == null) { 5738 this.initializeWidget(); 5739 } else { 5740 if (this.widget.value !== '') { 5741 this._model.dispatch(new FormView.Actions.UIChange({'value': this.widget.value})); 5742 } 5743 } 5744 } 5745 } 5746 5747 FormView.Utils.setupField(({element, formContainer}) => { 5748 return new Recaptcha({element, formContainer}) 5749 }, Recaptcha.selectors.self); 5750 5751})(); 5752 5753/******************************************************************************* 5754 * Copyright 2023 Adobe 5755 * 5756 * Licensed under the Apache License, Version 2.0 (the "License");
5757 * you may not use this file except in compliance with the License. 5758 * You may obtain a copy of the License at 5759 * 5760 * http://www.apache.org/licenses/LICENSE-2.0 5761 * 5762 * Unless required by applicable law or agreed to in writing, software 5763 * distributed under the License is distributed on an "AS IS" BASIS, 5764 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5765 * See the License for the specific language governing permissions and 5766 * limitations under the License. 5767 ******************************************************************************/ 5768 5769/** 5770 * This class is responsible for interacting with the recaptcha widget. It displays Google reCAPTCHA challenge. 5771 */ 5772 5773if (typeof window.RecaptchaWidget === 'undefined') { 5774 window.RecaptchaWidget = class { 5775 #widget = null 5776 #model = null // passed by reference 5777 #options = null 5778 #lang = 'en' 5779 static FD_CAPTCHA = "fd:captcha"; 5780 5781 constructor(view, model, widget) { 5782 // initialize the widget and model 5783 this.#widget = widget; 5784 this.#model = model; 5785 this.#widget = document.createElement("div"); 5786 this.#widget.classList.add("cmp-adaptiveform-recaptcha__widget"); 5787 this.#lang = view.formContainer.getModel().lang; 5788 5789 //Always inserting it in body 5790 document.body.appendChild(this.#widget); 5791 this.#options = Object.assign({}, this.#model._jsonModel); 5792 5793 this.#renderRecaptcha(widget); 5794 } 5795 5796 #renderRecaptcha(element) { 5797 5798 var self = this; 5799 var recaptchaConfigData = this.#options; 5800 element.innerHTML = '<div class="g-recaptcha"></div>'; 5801 var gcontainer = document.getElementsByClassName("g-recaptcha")[0]; 5802 var widgetId; 5803 var url = recaptchaConfigData.properties[RecaptchaWidget.FD_CAPTCHA].config.uri; 5804 if (recaptchaConfigData.properties[RecaptchaWidget.FD_CAPTCHA].config.size == "invisible") { 5805 gcontainer.classList.add('g-recaptcha-invisible'); 5806 recaptchaConfigData.required = false; 5807 } 5808 5809 var successCallback = function(response) { 5810 self.setCaptchaModel(response); 5811 }; 5812 5813 var expiredCallback = function() { 5814 if (isRecaptchaEnterprise()) { 5815 grecaptcha.enterprise.reset(widgetId); 5816 } else { 5817 grecaptcha.reset(widgetId); 5818 } 5819 self.setCaptchaModel(""); 5820 }; 5821 5822 var onloadCallbackInternal = function() { 5823 widgetId = isRecaptchaEnterprise() ? grecaptcha.enterprise.render(gcontainer, gparameters) 5824 : grecaptcha.render(gcontainer, gparameters); 5825 return widgetId; 5826 }; 5827 5828 var gparameters = { 5829 'sitekey': recaptchaConfigData.properties[RecaptchaWidget.FD_CAPTCHA].config.siteKey, 5830 'size': recaptchaConfigData.properties[RecaptchaWidget.FD_CAPTCHA].config.size, 5831 'theme': recaptchaConfigData.properties[RecaptchaWidget.FD_CAPTCHA].config.theme || 'light', 5832 'type': recaptchaConfigData.properties[RecaptchaWidget.FD_CAPTCHA].config.type || 'image', 5833 'callback': successCallback, 5834 'expired-callback': expiredCallback 5835 }; 5836 5837 const isRecaptchaEnterprise = function () { 5838 return recaptchaConfigData.properties[RecaptchaWidget.FD_CAPTCHA].config.version === "enterprise"; 5839 } 5840 const isScoreBasedKey = function () { 5841 return isRecaptchaEnterprise() && recaptchaConfigData.properties[RecaptchaWidget.FD_CAPTCHA].config.keyType === "score"; 5842 } 5843 5844 window.onloadRecaptchaCallback = onloadCallbackInternal; 5845 5846 var runtimeLocale = this.#lang; 5847 5848 var scr = document.createElement('script'); 5849 let queryParams = isScoreBasedKey() ? "?render=" + recaptchaConfigData.properties[RecaptchaWidget.FD_CAPTCHA].config.siteKey 5850 : "?onload=onloadRecaptchaCallback&render=explicit"; 5851 queryParams += "&hl=" + runtimeLocale; 5852 scr.src = url + queryParams; 5853 scr.async = true; 5854 element.appendChild(scr); 5855 } 5856 5857 setCaptchaModel = function(response) { 5858 this.#model.dispatch(new FormView.Actions.UIChange({'value': response})); 5859 } 5860 } 5861} 5862 5863/******************************************************************************* 5864 * Copyright 2022 Adobe 5865 * 5866 * Licensed under the Apache License, Version 2.0 (the "License");
5867 * you may not use this file except in compliance with the License. 5868 * You may obtain a copy of the License at 5869 * 5870 * http://www.apache.org/licenses/LICENSE-2.0 5871 * 5872 * Unless required by applicable law or agreed to in writing, software 5873 * distributed under the License is distributed on an "AS IS" BASIS, 5874 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5875 * See the License for the specific language governing permissions and 5876 * limitations under the License. 5877 ******************************************************************************/ 5878(function() { 5879 5880 5881 "use strict"; 5882 class CheckBox extends FormView.FormCheckBox { 5883 5884 static NS = FormView.Constants.NS; 5885 /** 5886 * Each FormField has a data attribute class that is prefixed along with the global namespace to 5887 * distinguish between them. If a component wants to put a data-attribute X, the attribute in HTML would be 5888 * data-{NS}-{IS}-x="" 5889 * @type {string} 5890 */ 5891 static IS = "adaptiveFormCheckBox"; 5892 static bemBlock = 'cmp-adaptiveform-checkbox' 5893 static selectors = { 5894 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 5895 widget: `.${CheckBox.bemBlock}__widget`, 5896 widgetLabel: `.${CheckBox.bemBlock}__label`, 5897 label: `.${CheckBox.bemBlock}__label`, 5898 description: `.${CheckBox.bemBlock}__longdescription`, 5899 qm: `.${CheckBox.bemBlock}__questionmark`, 5900 errorDiv: `.${CheckBox.bemBlock}__errormessage`, 5901 tooltipDiv: `.${CheckBox.bemBlock}__shortdescription` 5902 }; 5903 5904 constructor(params) { 5905 super(params); 5906 this.qm = this.element.querySelector(CheckBox.selectors.qm) 5907 this.widgetLabel = this.element.querySelector(CheckBox.selectors.widgetLabel) 5908 } 5909 5910 getWidget() { 5911 return this.element.querySelector(CheckBox.selectors.widget); 5912 } 5913 5914 getDescription() { 5915 return this.element.querySelector(CheckBox.selectors.description); 5916 } 5917 5918 getLabel() { 5919 return this.element.querySelector(CheckBox.selectors.label); 5920 } 5921 5922 getErrorDiv() { 5923 return this.element.querySelector(CheckBox.selectors.errorDiv); 5924 } 5925 5926 getQuestionMarkDiv() { 5927 return this.element.querySelector(CheckBox.selectors.qm); 5928 } 5929 5930 getTooltipDiv() { 5931 return this.element.querySelector(CheckBox.selectors.tooltipDiv); 5932 } 5933 5934 updateEnabled(enabled, state) { 5935 if (this.widget) { 5936 this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_ENABLED, enabled); 5937 const isDisabled = !enabled || state.readOnly; 5938 if (isDisabled) { 5939 this.widget.setAttribute("disabled", "disabled"); 5940 } else { 5941 this.widget.removeAttribute("disabled"); 5942 } 5943 } 5944 } 5945 5946 updateReadOnly(readonly) { 5947 if (this.widget) { 5948 this.element.setAttribute(FormView.Constants.DATA_ATTRIBUTE_READONLY, readonly); 5949 if (readonly === true) { 5950 this.widget.setAttribute(FormView.Constants.HTML_ATTRS.DISABLED, "disabled"); 5951 } else { 5952 this.widget.removeAttribute(FormView.Constants.HTML_ATTRS.DISABLED); 5953 } 5954 } 5955 } 5956 } 5957 5958 FormView.Utils.setupField(({element, formContainer}) => { 5959 return new CheckBox({element, formContainer}) 5960 }, CheckBox.selectors.self); 5961 5962})(); 5963 5964/******************************************************************************* 5965 * Copyright 2023 Adobe 5966 * 5967 * Licensed under the Apache License, Version 2.0 (the "License"); 5968 * you may not use this file except in compliance with the License. 5969 * You may obtain a copy of the License at 5970 * 5971 * http://www.apache.org/licenses/LICENSE-2.0 5972 * 5973 * Unless required by applicable law or agreed to in writing, software 5974 * distributed under the License is distributed on an "AS IS" BASIS, 5975 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5976 * See the License for the specific language governing permissions and 5977 * limitations under the License. 5978 ******************************************************************************/ 5979(function() { 5980 5981 "use strict"; 5982 class Fragment extends FormView.FormPanel { 5983 5984 static NS = FormView.Constants.NS; 5985 /** 5986 * Each FormField has a data attribute class that is prefixed along with the global namespace to 5987 * distinguish between them. If a component wants to put a data-attribute X, the attribute in HTML would be 5988 * data-{NS}-{IS}-x="" 5989 * @type {string} 5990 */ 5991 static IS = "adaptiveFormFragment";
5992 static bemBlock = 'cmp-adaptiveform-fragment' 5993 static selectors = { 5994 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 5995 widget: `.${Fragment.bemBlock}__widget`, 5996 label: `.${Fragment.bemBlock}__label`, 5997 description: `.${Fragment.bemBlock}__longdescription`, 5998 qm: `.${Fragment.bemBlock}__questionmark`, 5999 errorDiv: `.${Fragment.bemBlock}__errormessage`, 6000 tooltipDiv: `.${Fragment.bemBlock}__shortdescription` 6001 }; 6002 6003 constructor(params) { 6004 super(params); 6005 } 6006 6007 getWidget() { 6008 return this.element.querySelector(Fragment.selectors.widget); 6009 } 6010 6011 getDescription() { 6012 return this.element.querySelector(Fragment.selectors.description); 6013 } 6014 6015 getLabel() { 6016 return this.element.querySelector(Fragment.selectors.label); 6017 } 6018 6019 getErrorDiv() { 6020 return this.element.querySelector(Fragment.selectors.errorDiv); 6021 } 6022 6023 getTooltipDiv() { 6024 return this.element.querySelector(Fragment.selectors.tooltipDiv); 6025 } 6026 6027 getQuestionMarkDiv() { 6028 return this.element.querySelector(Fragment.selectors.qm); 6029 } 6030 } 6031 6032 FormView.Utils.setupField(({element, formContainer}) => { 6033 return new Fragment({element, formContainer}) 6034 }, Fragment.selectors.self); 6035 6036})(); 6037 6038/******************************************************************************* 6039 * Copyright 2023 Adobe 6040 * 6041 * Licensed under the Apache License, Version 2.0 (the "License"); 6042 * you may not use this file except in compliance with the License. 6043 * You may obtain a copy of the License at 6044 * 6045 * http://www.apache.org/licenses/LICENSE-2.0 6046 * 6047 * Unless required by applicable law or agreed to in writing, software 6048 * distributed under the License is distributed on an "AS IS" BASIS, 6049 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6050 * See the License for the specific language governing permissions and 6051 * limitations under the License. 6052 ******************************************************************************/ 6053(function() { 6054 6055 6056 "use strict"; 6057 class Switch extends FormView.FormCheckBox { 6058 6059 static NS = FormView.Constants.NS; 6060 static IS = "adaptiveFormSwitch"; 6061 static bemBlock = 'cmp-adaptiveform-switch'; 6062 static selectors = { 6063 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 6064 widget: `.${Switch.bemBlock}__widget`, 6065 label: `.${Switch.bemBlock}__label`, 6066 description: `.${Switch.bemBlock}__longdescription`, 6067 errorDiv: `.${Switch.bemBlock}__errormessage`, 6068 qm: `.${Switch.bemBlock}__questionmark`, 6069 tooltipDiv: `.${Switch.bemBlock}__shortdescription` 6070 }; 6071 6072 constructor(params) { 6073 super(params); 6074 this.qm = this.element.querySelector(Switch.selectors.qm) 6075 } 6076 6077 getClass() { 6078 return Switch.IS; 6079 } 6080 6081 getWidget() { 6082 return this.element.querySelector(Switch.selectors.widget); 6083 } 6084 6085 getDescription() { 6086 return this.element.querySelector(Switch.selectors.description); 6087 } 6088 6089 getLabel() { 6090 return this.element.querySelector(Switch.selectors.label); 6091 } 6092 6093 getErrorDiv() { 6094 return this.element.querySelector(Switch.selectors.errorDiv); 6095 } 6096 6097 getTooltipDiv() { 6098 return this.element.querySelector(Switch.selectors.tooltipDiv); 6099 } 6100 6101 getQuestionMarkDiv() { 6102 return this.element.querySelector(Switch.selectors.qm); 6103 } 6104 } 6105 6106 FormView.Utils.setupField(({element, formContainer}) => { 6107 return new Switch({element,formContainer}) 6108 }, Switch.selectors.self); 6109 6110})(); 6111 6112/******************************************************************************* 6113 * Copyright 2023 Adobe 6114 * 6115 * Licensed under the Apache License, Version 2.0 (the "License"); 6116 * you may not use this file except in compliance with the License. 6117 * You may obtain a copy of the License at 6118 * 6119 * http://www.apache.org/licenses/LICENSE-2.0 6120 * 6121 * Unless required by applicable law or agreed to in writing, softw
6121are 6122 * distributed under the License is distributed on an "AS IS" BASIS, 6123 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6124 * See the License for the specific language governing permissions and 6125 * limitations under the License. 6126 ******************************************************************************/ 6127 6128(function () { 6129 6130 class TermsAndConditions extends FormView.FormPanel { 6131 static NS = FormView.Constants.NS; 6132 static IS = "adaptiveFormTermsAndConditions"; 6133 static bemBlock = 'cmp-adaptiveform-termsandcondition'; 6134 static selectors = { 6135 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 6136 label: `.${TermsAndConditions.bemBlock}__label`, 6137 description: `.${TermsAndConditions.bemBlock}__longdescription`, 6138 qm: `.${TermsAndConditions.bemBlock}__questionmark`, 6139 tooltipDiv: `.${TermsAndConditions.bemBlock}__shortdescription`, 6140 tncContentWrapper: `.${TermsAndConditions.bemBlock}__content-container`, 6141 closePopupButton: `.${TermsAndConditions.bemBlock}__close-button` 6142 }; 6143 6144 constructor(params) { 6145 super(params); 6146 this.#handleScroll() 6147 } 6148 6149 addChild(childView) { 6150 super.addChild(childView); 6151 if (childView.getModel()._jsonModel.fieldType === 'checkbox-group') { 6152 this.#addLinkClickListener(childView); 6153 } 6154 if (childView.getModel()._jsonModel.fieldType === 'checkbox') { 6155 this.#handlePopup(childView); 6156 } 6157 } 6158 6159 #addLinkClickListener(childView) { 6160 childView.getWidgets().querySelectorAll('label').forEach((item) => { 6161 const checkboxInput = item.querySelector('input'); 6162 item.querySelector('a').addEventListener('click', (e) => { 6163 checkboxInput.click(); 6164 }) 6165 }) 6166 } 6167 6168 #handleScroll() { 6169 const intersection = this.element.querySelector('.cmp-adaptiveform-termsandcondition__text-intersect'); 6170 if (intersection) { 6171 const self = this; 6172 const io = new IntersectionObserver(onIntersection, { 6173 threshold: [1], 6174 }) 6175 function onIntersection ([{isIntersecting}]) { 6176 const isEnabled = self.getModel()?.enabled && !self.getModel()?.readOnly; 6177 if (isIntersecting) { 6178 if (isEnabled) { 6179 self.children.filter(c => c.getModel()._jsonModel.fieldType === 'checkbox').forEach(cb => { 6180 cb.getModel().enabled = true; 6181 })} 6182 io.unobserve(intersection); 6183 } 6184 } 6185 io.observe(intersection) 6186 } 6187 } 6188 6189 #handlePopup(approvalCheckbox) { 6190 const closePopUpBtn = this.getClosePopupButton(); 6191 if (closePopUpBtn) { 6192 closePopUpBtn.addEventListener('click', () => { 6193 this.toggleAttribute(this.getContentDivWrapper(), false, 'data-cmp-visible', false); 6194 }) 6195 6196 approvalCheckbox.label.addEventListener('click', () => { 6197 const contentDiv = this.getContentDivWrapper(); 6198 if (contentDiv) { 6199 this.toggleAttribute(this.getContentDivWrapper(), true, 'data-cmp-visible', false); 6200 } 6201 }) 6202 } 6203 } 6204 6205 getContentDivWrapper() { 6206 return this.element.querySelector(TermsAndConditions.selectors.tncContentWrapper); 6207 } 6208 6209 getClosePopupButton() { 6210 return this.element.querySelector(TermsAndConditions.selectors.closePopupButton); 6211 } 6212 6213 getWidget() { 6214 return null; 6215 } 6216 6217 getDescription() { 6218 return this.element.querySelector(TermsAndConditions.selectors.description); 6219 } 6220 6221 getLabel() { 6222 return null; 6223 } 6224 6225 getErrorDiv() { 6226 return null; 6227 } 6228 6229 getTooltipDiv() { 6230 return this.element.querySelector(TermsAndConditions.selectors.tooltipDiv); 6231 } 6232 6233 getQuestionMarkDiv() { 6234 return this.element.querySelector(TermsAndConditions.selectors.qm); 6235 } 6236 } 6237 6238 FormView.Utils.setupField(({element, formContainer}) => { 6239 return new TermsAndConditions({element, formContainer}) 6240 }, TermsAndConditions.selectors.self); 6241})(); 6242 6243/******************************************************************************* 6244 * Copyright 2024 Adobe 6245 * 6246 * Licensed under the Apache License, Version 2.0 (the "License");
6247 * you may not use this file except in compliance with the License. 6248 * You may obtain a copy of the License at 6249 * 6250 * http://www.apache.org/licenses/LICENSE-2.0 6251 * 6252 * Unless required by applicable law or agreed to in writing, software 6253 * distributed under the License is distributed on an "AS IS" BASIS, 6254 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6255 * See the License for the specific language governing permissions and 6256 * limitations under the License. 6257 ******************************************************************************/ 6258 6259(function () { 6260 6261 "use strict"; 6262 class Review extends FormView.FormFieldBase { 6263 6264 static NS = FormView.Constants.NS; 6265 /** 6266 * Each FormField has a data attribute class that is prefixed along with the global namespace to 6267 * distinguish between them. If a component wants to put a data-attribute X, the attribute in HTML would be 6268 * data-{NS}-{IS}-x="" 6269 * @type {string} 6270 */ 6271 static IS = "adaptiveFormReview"; 6272 static bemBlock = 'cmp-adaptiveform-review'; 6273 static templateAttribute = 'data-cmp-review'; 6274 static DATA_ATTRIBUTE_VISIBLE = 'data-cmp-visible'; 6275 static FIELD_TYPE = FormView.Constants.FIELD_TYPE; 6276 static HIDE_FIELD_FROM_REVIEW = [Review.FIELD_TYPE.BUTTON, Review.FIELD_TYPE.PLAIN_TEXT, Review.FIELD_TYPE.CAPTCHA, Review.FIELD_TYPE.IMAGE]; 6277 static panelModifier = '__panel--repeatable'; 6278 static fieldModifier = '__field--'; 6279 static selectors = { 6280 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 6281 container: `.${Review.bemBlock}__container`, 6282 templates: "template[data-cmp-review-fieldType]", 6283 label: '[' + Review.templateAttribute + '-label]', 6284 value: '[' + Review.templateAttribute + '-value]', 6285 editButton:'[' + Review.templateAttribute + '-editButton]', 6286 fieldId: Review.templateAttribute + '-fieldId', 6287 fieldType: Review.templateAttribute + '-fieldType', 6288 panelContent:'[' + Review.templateAttribute + '-content]', 6289 labelContainer: `.${Review.bemBlock}__label-container`, 6290 intersection: Review.templateAttribute + "-intersection=" 6291 }; 6292 static intersectionOptions = { 6293 root: null, 6294 rootMargin: "0px", 6295 threshold: Review.buildThresholdList(), 6296 }; 6297 static buildThresholdList() { 6298 let thresholds = []; 6299 let numSteps = 20; 6300 for (let i = 1.0; i <= numSteps; i++) { 6301 thresholds.push(i / numSteps); 6302 } 6303 thresholds.push(0); 6304 return thresholds; 6305 } 6306 6307 static sanitizedValue(value, options) { 6308 if(options){ 6309 return window.DOMPurify ? window.DOMPurify.sanitize(value, options) : value; 6310 } 6311 return window.DOMPurify ? window.DOMPurify.sanitize(value) : value; 6312 } 6313 6314 static hasChild(element) { 6315 return element && element.children && element.children.length; 6316 } 6317 6318 static addClassModifier(element, item) { 6319 if(item.fieldType !== Review.FIELD_TYPE.PANEL){ 6320 element.querySelector('div').classList.add(Review.bemBlock + Review.fieldModifier + item.fieldType); 6321 } 6322 if(item.repeatable){ 6323 element.querySelector('div').classList.add(Review.bemBlock + Review.panelModifier); 6324 } 6325 if(item.name){ 6326 element.querySelector('div').classList.add(item.name); 6327 } 6328 } 6329 6330 static renderLabel(element, item) { 6331 const label = element.querySelector(Review.selectors.label); 6332 label.innerHTML = item.fieldType === Review.FIELD_TYPE.PLAIN_TEXT ? Review.sanitizedValue(item.value) : Review.sanitizedValue(item?.label?.value, {ALLOWED_TAGS: [] }); 6333 if (item.required) { 6334 label.setAttribute('data-cmp-required', item.required); 6335 } 6336 } 6337 6338 static renderValue(element, item) { 6339 const value = element.querySelector(Review.selectors.value); 6340 if (value) { 6341 const plainText = Review.getValue(item, item.value) || ''; 6342 value.innerHTML = Review.sanitizedValue(plainText); 6343 } 6344 } 6345 6346 static addAccessibilityAttributes(element, item) { 6347 const container = element.querySelector('div'); 6348 const label = element.querySelector(Review.selectors.label); 6349 const value = element.querySelector(Review.selectors.value); 6350 const editButton = element.querySelector(Review.selectors.editButton); 6351 const id = `${item.id}-review-label`; 6352 if(label){ 6353 label.setAttribute('id', id); 6354 container.setAttribute('role', 'region'); 6355 container.setAttribute('aria-labelledby', id); 6356 } 6357 if(value){ 6358 value.setAttribute('aria-labelledby', id); 6359 } 6360 if(editButton && editButton.getAttribute(Review.DATA_ATTRIBUTE_VISIBLE) === 'true'){ 6361 editButton.setAttribute('aria-describedby', id); 6362 } 6363 } 6364 6365 static isRepeatable(item) { 6366 return item.fieldType === Review.FIELD_TYPE.PANEL && item.type === 'array' 6367 } 6368 6369 /* return value of the field, if value is array then return comma separated string and 6370 if value is file then return file name 6371 */ 6372 static getValue(item, value) { 6373 if (value === undefined || value === null) return ''; 6374 if (item.fieldType === Review.FIELD_TYPE.FILE_INPUT) { 6375 return Array.isArray(value) ? value.filter(file => file && file.name).map(file => file.name).join(', ') : (value.name || ''); 6376 } 6377 if (Array.isArray(item.enumNames)) { 6378 const values = Array.isArray(value) ? value : [value]; 6379 return values.reduce((names, val) => { 6380 const index = item.enum.indexOf(val); 6381 if (index >= 0) { 6382 names.push(item.enumNames[index]); 6383 } 6384 return names; 6385 }, []).join(', '); 6386 } 6387 if (Array.isArray(value)) { 6388 return value.join(', '); 6389 } 6390 return value; 6391 } 6392 6393 constructor(params) { 6394 super(params); 6395 this.#attachIntersectionObserver(); 6396 this.#attachClickEventOnEdit(); 6397 this.#setFieldTemplateMapping(); 6398 } 6399 getContainer() { 6400 return this.element.querySelector(Review.selectors.container); 6401 } 6402 getTemplates() { 6403 return this.element.querySelectorAll(Review.selectors.templates); 6404 } 6405 getIntersectionElement() { 6406 return this.element.querySelector("[" + Review.selectors.intersection + this.id + "]"); 6407 } 6408 getWidget() { return null } 6409 getDescription() { return null; } 6410 getLabel() { return null; } 6411 getErrorDiv() { return null; } 6412 getTooltipDiv() { return null; } 6413 getQuestionMarkDiv() { return null; } 6414 setModel(model) { 6415 super.setModel(model); 6416 } 6417 6418 // attach intersection observer to the review container for lazy loading 6419 #attachIntersectionObserver() { 6420 let observer = new IntersectionObserver(this.#intersectionObserverHandler.bind(this), Review.intersectionOptions); 6421 const ele = this.getIntersectionElement(); 6422 if(ele){ 6423 observer.observe(ele); 6424 } 6425 } 6426 6427 // attach click event on edit button to set focus on the field 6428 #attachClickEventOnEdit() { 6429 this.getContainer().addEventListener('click', this.#clickHandler.bind(this)) 6430 } 6431 6432 // create template mapping based on field type and use it to render review fields 6433 #setFieldTemplateMapping() { 6434 const templates = this.getTemplates(); 6435 let mappings = {};
6436 templates.forEach(template => { 6437 const type = template.getAttribute(Review.selectors.fieldType); 6438 mappings[type || 'default'] = template; 6439 }); 6440 this.templateMappings = mappings; 6441 } 6442 6443 // click handler to set focus on the field when use click on edit button 6444 #clickHandler(event) { 6445 if (event?.target?.nodeName === 'BUTTON') { 6446 const id = event.target.getAttribute(Review.selectors.fieldId); 6447 const form = this.formContainer.getModel();; 6448 const field = this.formContainer.getField(id); 6449 if (form && field) { 6450 form.setFocus(field._model); 6451 } 6452 } 6453 } 6454 6455 // if review container is in view port then render review fields 6456 #intersectionObserverHandler(entries) { 6457 entries.forEach(entry => { 6458 if (entry.isIntersecting && this._model) { 6459 const panels = this.#getPanels(); 6460 const reviewContainer = this.getContainer(); 6461 const children = this.#renderReviewFields(panels); 6462 reviewContainer.innerHTML = ''; 6463 reviewContainer.appendChild(children); 6464 } 6465 }) 6466 } 6467 6468 // iterate over all the panels or linked panels and render child of each panel 6469 #renderReviewFields(items) { 6470 if (!items) return; 6471 const currentFragment = document.createDocumentFragment(); 6472 items.filter(item => item.visible !== false && item.fieldType && item[':type']).forEach(item => { 6473 if (Review.isRepeatable(item)) { 6474 const repeatableItems = this.getModel().form.getElement(item.id).getState(); 6475 const repeatablePanel = this.#renderReviewFields(repeatableItems.items); 6476 if (Review.hasChild(repeatablePanel)) { 6477 currentFragment.appendChild(repeatablePanel); 6478 } 6479 } else { 6480 let template = this.templateMappings[item.fieldType] || this.templateMappings['default']; 6481 const cloneNode = template.content.cloneNode(true); 6482 Review.addClassModifier(cloneNode, item); 6483 Review.renderLabel(cloneNode, item); 6484 this.#renderEditButton(cloneNode, item); 6485 if (item.fieldType === Review.FIELD_TYPE.PANEL) { 6486 const fields = this.#renderReviewFields(item.items); 6487 if (Review.hasChild(fields)) { 6488 const labelContainer = cloneNode.querySelector(Review.selectors.labelContainer); 6489 if(item?.label?.visible === false && labelContainer){ 6490 labelContainer.remove(); 6491 } 6492 Review.addAccessibilityAttributes(cloneNode, item); 6493 const contentElement = cloneNode.querySelector(Review.selectors.panelContent); 6494 if(contentElement){ 6495 contentElement.appendChild(fields); 6496 } 6497 currentFragment.appendChild(cloneNode); 6498 } 6499 } else if (!Review.HIDE_FIELD_FROM_REVIEW.includes(item.fieldType) && !item[':type'].endsWith('review')) { 6500 Review.renderValue(cloneNode, item); 6501 Review.addAccessibilityAttributes(cloneNode, item); 6502 currentFragment.appendChild(cloneNode); 6503 } 6504 } 6505 }); 6506 return currentFragment; 6507 } 6508 6509 #getPanels() { 6510 const linkedPanels = this.getModel().properties["fd:linkedPanels"] || []; 6511 if (linkedPanels.length) { 6512 return this.#getLinkedPanels([...linkedPanels]); 6513 } 6514 return this.#getAllPanels(); 6515 } 6516 6517 // return all top lavel panels if author has not linked any panel 6518 #getAllPanels() { 6519 let state = this.getModel().form.getState(); 6520 while (state?.items?.length === 1) { 6521 state = state.items[0]; 6522 } 6523 return state.items || []; 6524 } 6525 6526 // return linked panels if author has linked any panel 6527 #getLinkedPanels(linkedPanels) { 6528 let queue = [], result = []; 6529 let state = this.getModel().form.getState(); 6530 queue.push(state); 6531 while (queue.length && linkedPanels.length) { 6532 const items = Array.isArray(queue[0]) ? queue[0] : [queue[0]]; 6533 items.forEach(item => { 6534 const index = linkedPanels.indexOf(item.name); 6535 if (index > -1) { 6536 result.push(item); 6537 linkedPanels.splice(index, 1); 6538 } 6539 if (item.items) { 6540 queue.push(item.items); 6541 } 6542 }) 6543 queue.shift(); 6544 } 6545 return result; 6546 } 6547 6548 // render edit button of the field 6549 #renderEditButton(cloneNode, item) { 6550 const editButton = cloneNode.querySelector(Review.selectors.editButton); 6551 if (editButton) { 6552 editButton.setAttribute(Review.selectors.fieldId, item.id); 6553 editButton.setAttribute('aria-label', item?.label?.value); 6554 if (item.enabled === false) { 6555 editButton.setAttribute('disabled', true); 6556 } 6557 editButton.setAttribute(Review.DATA_ATTRIBUTE_VISIBLE, this.#isVisibleEditButton(item.fieldType)); 6558 } 6559 } 6560 #isVisibleEditButton(fieldType) { 6561 let editModeAction = this.getModel().properties?.['fd:editModeAction']; 6562 if (editModeAction === 'both' || 6563 (editModeAction === Review.FIELD_TYPE.PANEL && fieldType === Review.FIELD_TYPE.PANEL) || 6564 (editModeAction === 'field' && fieldType !== Review.FIELD_TYPE.PANEL)) { 6565 return true; 6566 } 6567 return false;
6568 } 6569 } 6570 6571 FormView.Utils.setupField(({ element, formContainer }) => { 6572 return new Review({ element, formContainer }) 6573 }, Review.selectors.self); 6574 6575})(); 6576 6577/******************************************************************************* 6578 * Copyright 2025 Adobe 6579 * 6580 * Licensed under the Apache License, Version 2.0 (the "License"); 6581 * you may not use this file except in compliance with the License. 6582 * You may obtain a copy of the License at 6583 * 6584 * http://www.apache.org/licenses/LICENSE-2.0 6585 * 6586 * Unless required by applicable law or agreed to in writing, software 6587 * distributed under the License is distributed on an "AS IS" BASIS, 6588 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6589 * See the License for the specific language governing permissions and 6590 * limitations under the License. 6591 ******************************************************************************/ 6592 6593if(window.GeoLocationQuery === undefined) { 6594 window.GeoLocationQuery = class GeoLocationQuery { 6595 constructor() { 6596 this._active = false; 6597 } 6598 6599 init(success, failure) { 6600 this._successHandler = success; 6601 this._errorHandler = failure; 6602 this._active = true; 6603 return this; 6604 } 6605 6606 _handleSuccess(data) { 6607 if (this._successHandler) { 6608 this._successHandler(data); 6609 } 6610 } 6611 6612 _handleError(err) { 6613 if (this._errorHandler) { 6614 this._errorHandler(err); 6615 } 6616 } 6617 6618 query() { 6619 const onSuccess = (pos) => { 6620 if (this._active) { 6621 this._handleSuccess(pos); 6622 } 6623 this._active = false; 6624 }; 6625 6626 const onError = (err) => { 6627 if (this._active) { 6628 this._handleError(err); 6629 } 6630 this._active = false; 6631 }; 6632 6633 navigator.geolocation.getCurrentPosition(onSuccess, onError, { timeout: 10000 }); 6634 } 6635 6636 cancel() { 6637 this._active = false; 6638 } 6639 } 6640} 6641/******************************************************************************* 6642 * Copyright 2025 Adobe 6643 * 6644 * Licensed under the Apache License, Version 2.0 (the "License"); 6645 * you may not use this file except in compliance with the License. 6646 * You may obtain a copy of the License at 6647 * 6648 * http://www.apache.org/licenses/LICENSE-2.0 6649 * 6650 * Unless required by applicable law or agreed to in writing, software 6651 * distributed under the License is distributed on an "AS IS" BASIS, 6652 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6653 * See the License for the specific language governing permissions and 6654 * limitations under the License. 6655 ******************************************************************************/ 6656 6657 6658(function() { 6659 "use strict"; 6660 /** 6661 * class definition for GeoLocationQueryRequest 6662 * encapsulated success and error handlers 6663 */ 6664 class Scribble extends FormView.FormFieldBase { 6665 _geoLocQuery=null; 6666 _signSubmitted=false; 6667 _enforceGeoLoc=!!navigator.userAgent.match(/iPad/i); 6668 existingSign = ''; 6669 existingCanvas = ''; 6670 lang = "en"; 6671 static NS = FormView.Constants.NS; 6672 static IS = "adaptiveFormScribble"; 6673 static bemBlock = 'cmp-adaptiveform-scribble'; 6674 static selectors = { 6675 self: `[data-${this.NS}-is="${this.IS}"]`, 6676 scribbleContainer: `.${Scribble.bemBlock}__container`, 6677 scribbleContainerPanel: `.${Scribble.bemBlock}__panel`, 6678 keyboardSignBox: `.${Scribble.bemBlock}__keyboard-sign-box`, 6679 scribbleControlPanel: `.${Scribble.bemBlock}__controlpanel`, 6680 geoCanvas: `.${Scribble.bemBlock}__geocanvas`, 6681 canvasSignedContainer: `.${Scribble.bemBlock}__canvas-signed-container`, 6682 canvas: `.${Scribble.bemBlock}__canvas`, 6683 label: `.${Scribble.bemBlock}__label`, 6684 description: `.${Scribble.bemBlock}__longdescription`, 6685 qm: `.${Scribble.bemBlock}__questionmark`, 6686 errorDiv: `.${Scribble.bemBlock}__errormessage`, 6687 tooltipDiv: `.${Scribble.bemBlock}__shortdescription`, 6688 scribbleCloseButton: `.${Scribble.bemBlock}__button-close`, 6689 brushControl: `.${Scribble.bemBlock}__control-brush`, 6690 scribbleGeoControl: `.${Scribble.bemBlock}__control-geo`, 6691 clearControl: `.${Scribble.bemBlock}__control-clear`, 6692 scribbleTextControl: `.${Scribble.bemBlock}__control-text`, 6693 scribbleMessage: `.${Scribble.bemBlock}__control-message`, 6694 clearSignButton: `.${Scribble.bemBlock}__button--primary`, 6695 cancelClearSignButton: `.${Scribble.bemBlock}__button--secondary`, 6696 clearSignContainer: `.${Scribble.bemBlock}__clearsign-container`, 6697 scribbleSubmitControl: `.${Scribble.bemBlock}__save-button`, 6698 scribbleBrushList: `.${Scribble.bemBlock}__brushlist`, 6699 signCanvases: `.${Scribble.bemBlock}__signcanvases`, 6700 saveCanvas: `.${Scribble.bemBlock}__save-button`, 6701 canvasSignedImage: `.${Scribble.bemBlock}__canvas-signed-image`, 6702 mainCanvas: `.${Scribble.bemBlock}__canvas__main` 6703 }; 6704 6705 constructor(params) { 6706 super(params); 6707 this.initializeScribble(); 6708 } 6709 6710 setModel(model) { 6711 super.setModel(model); 6712 this.lang = model.lang; 6713 } 6714 6715 initializeScribble() { 6716 this.getCanvasContainer().addEventListener('click', () => this.scribbleContainerClickHandler()); 6717 this.initScribbleModal(); 6718 } 6719 6720 getWidget() { 6721 return this.element.querySelector(Scribble.selectors.canvasSignedContainer); 6722 } 6723 6724 getLabel() { 6725 return this.element.querySelector(Scribble.selectors.label); 6726 } 6727 6728 getErrorDiv() { 6729 return this.element.querySelector(Scribble.selectors.errorDiv); 6730 } 6731 6732 getTooltipDiv() { 6733 return this.element.querySelector(Scribble.selectors.tooltipDiv); 6734 } 6735 6736 getQuestionMarkDiv() { 6737 return this.element.querySelector(Scribble.selectors.qm); 6738 } 6739 6740 getScribbleControlPanel() { 6741 return this.element.querySelector(Scribble.selectors.scribbleControlPanel); 6742 } 6743 6744 getScribbleContainer() { 6745 return this.element.querySelector(Scribble.selectors.scribbleContainer); 6746 } 6747 6748 getMessage() { 6749 return this.element.querySelector(Scribble.selectors.scribbleMessage); 6750 } 6751 6752 getClearSignContainer() { 6753 return this.element.querySelector(Scribble.selectors.clearSignContainer); 6754 } 6755 6756 getClearSignButton() { 6757 return this.element.querySelector(Scribble.selectors.clearSignButton); 6758 } 6759 6760 getCancelClearSignButton() { 6761 return this.element.querySelector(Scribble.selectors.cancelClearSignButton); 6762 } 6763 6764 getBrushList() { 6765 return this.element.querySelector(Scribble.selectors.scribbleBrushList); 6766 } 6767 6768 getBrush() { 6769 return this.element.querySelector(Scribble.selectors.brushControl); 6770 } 6771 6772 getClearControl() { 6773 return this.element.querySelector(Scribble.selectors.clearControl); 6774 } 6775 6776 getSaveControl() { 6777 return this.element.querySelector(Scribble.selectors.saveCanvas); 6778 } 6779 6780 getGeoLocationIcon() { 6781 return this.element.querySelector(Scribble.selectors.scribbleGeoControl); 6782 } 6783 6784 getTextSignControl() { 6785 return this.element.querySelector(Scribble.selectors.scribbleTextControl); 6786 } 6787 6788 getScribbleContainerPanel() { 6789 return this.element.querySelector(Scribble.selectors.scribbleContainerPanel); 6790 } 6791 6792 getKeyboardSignBox() { 6793 return this.element.querySelector(Scribble.selectors.keyboardSignBox); 6794 } 6795 6796 getGeoCanvas() { 6797 return this.element.querySelector(Scribble.selectors.geoCanvas); 6798 } 6799 6800 getCanvasContainer() { 6801 return this.element.querySelector(Scribble.selectors.canvasSignedContainer); 6802 } 6803 6804 getScribbleCloseButton() { 6805 return this.element.querySelector(Scribble.selectors.scribbleCloseButton); 6806 } 6807 6808 getCanvas() { 6809 return this.element.querySelector(Scribble.selectors.canvas); 6810 } 6811 6812 getMainCanvas() { 6813 return this.element.querySelector(Scribble.selectors.mainCanvas); 6814 } 6815 6816 getSignCanvasesContainer() { 6817 return this.element.querySelector(Scribble.selectors.signCanvases); 6818 } 6819 6820 getDescription() { 6821 return this.element.querySelector(Scribble.selectors.description); 6822 } 6823 6824 getSignedCanvasImage() { 6825 return this.element.querySelector(Scribble.selectors.canvasSignedImage); 6826 } 6827 6828 showMessage(msg){ 6829 if(this._msgTimeout) { clearTimeout(this._msgTimeout); this._msgTimeout=0; } 6830 const scribbleMessage = this.getMessage(); 6831 scribbleMessage.innerHTML = msg; 6832 scribbleMessage.style.display = 'block'; 6833 this._msgTimeout = window.setTimeout(function(){ 6834 scribbleMessage.innerHTML = ''; 6835 },15000); 6836 } 6837 6838 openClearSignModal() { 6839 const clearSignContainer = this.getClearSignContainer(); 6840 const clearSignButton = this.getClearSignButton(); 6841 const cancelClearSignButton = this.getCancelClearSignButton(); 6842 6843 clearSignContainer.style.display = 'inline-block'; 6844 // Set focus to the clear sign modal container for accessibility 6845 clearSignContainer.setAttribute('tabindex', '-1'); 6846 clearSignContainer.focus(); 6847 6848 const handleClearSign = () => { 6849 this.existingSign = ''; 6850 const mainCanvas = this.getMainCanvas(); 6851 const existingCanvas = this.existingCanvas; 6852 6853 if (mainCanvas && existingCanvas) { 6854 mainCanvas.parentNode.replaceChild(existingCanvas, mainCanvas); 6855 const ctx = existingCanvas.getContext('2d'); 6856 ctx.clearRect(0, 0, existingCanvas.width, existingCanvas.height); 6857 } 6858 6859 const geoCanvas = this.getGeoCanvas(); 6860 if (geoCanvas) { 6861 const geoCtx = geoCanvas.getContext('2d'); 6862 geoCtx.clearRect(0, 0, geoCanvas.width, geoCanvas.height); 6863 } 6864 6865 this.enableControls(['brushes', 'geolocation', 'clearSign', 'textSign', 'save']); 6866
6867 const signedImage = this.getSignedCanvasImage(); 6868 if (signedImage) { 6869 signedImage.removeAttribute('alt'); 6870 signedImage.removeAttribute('title'); 6871 signedImage.removeAttribute('src'); 6872 signedImage.removeAttribute('style'); 6873 this.element.querySelector('.cmp-adaptiveform-scribble__clear-sign')?.remove(); 6874 clearSignContainer.style.display = 'none'; 6875 this.getKeyboardSignBox().value = ''; 6876 } 6877 6878 this._signSubmitted = false; 6879 this.setModelValue(undefined); 6880 }; 6881 6882 clearSignButton.addEventListener('click', handleClearSign); 6883 6884 cancelClearSignButton.addEventListener('click', () => { 6885 clearSignContainer.style.display = 'none'; 6886 }); 6887 } 6888 6889 createCanvas() { 6890 const mainCanvas = document.createElement('canvas'); 6891 mainCanvas.classList.add('cmp-adaptiveform-scribble__canvasImage'); 6892 } 6893 6894 updateEmptyStatus () { 6895 super.updateEmptyStatus(); 6896 } 6897 6898 updateValue(value) { 6899 let that = this; 6900 this._model.serialize().then((files) => { 6901 if (files && files.length > 0 && files[0]) { 6902 let signatureDataUrl = files[0].data; 6903 signatureDataUrl = typeof signatureDataUrl === "undefined" ? null : signatureDataUrl; 6904 const signedImage = that.getSignedCanvasImage(); 6905 if (signedImage && signatureDataUrl) { 6906 signedImage.src = signatureDataUrl; 6907 signedImage.setAttribute('alt', FormView.LanguageUtils.getTranslatedString(this.lang, 'signature') || 'Signature'); 6908 signedImage.setAttribute('title', FormView.LanguageUtils.getTranslatedString(this.lang, 'signature') || 'Signature'); 6909 that.updateEmptyStatus(); 6910 } 6911 } 6912 }); 6913 } 6914 6915 isCanvasEmpty(canvas) { 6916 const ctx = canvas.getContext('2d'); 6917 const width = canvas.width; 6918 const height = canvas.height; 6919 6920 // Get pixel data from the canvas 6921 const imageData = ctx.getImageData(0, 0, width, height); 6922 6923 // Check if any pixel is not transparent (not [0, 0, 0, 0] = transparent) 6924 for (let i = 0; i < imageData.data.length; i += 4) { 6925 if (imageData.data[i + 3] > 0) { 6926 return false; // Found non-transparent pixel 6927 } 6928 } 6929 6930 return true; // No non-transparent pixels found 6931 } 6932 6933 submitSign() { 6934 if (!this.isCanvasEmpty(this.canvas)) { 6935 const mainCanvas = this.createMainCanvas(); 6936 const sigCnv = this.getCanvas(); // Get the sign canvas 6937 const geoCnv = this.getGeoCanvas(); // Get the geo canvas 6938 6939 this.drawCanvasesOnMainCanvas(mainCanvas, sigCnv, geoCnv); 6940 6941 this.existingCanvas = sigCnv; 6942 sigCnv.height = mainCanvas.height; 6943 sigCnv.parentNode.replaceChild(mainCanvas, sigCnv); 6944 6945 let submitData = mainCanvas.toDataURL("image/png"); 6946 submitData = submitData.replace("data:image/png;base64,", "data:image/png;name=fd_type_signature.png;base64,") 6947 this.existingSign = mainCanvas; 6948 6949 this.updateSignedImage(submitData); 6950 this.setModelValue(submitData); 6951 this.addClearSignButton(); 6952 6953 if (this._geoLocQuery) { 6954 this._geoLocQuery.cancel(); // Cancel the current geo loc request 6955 } 6956 6957 this.closeEditModal(); 6958 this._signSubmitted = true; 6959 } 6960 } 6961 6962 createMainCanvas() { 6963 const mainCanvas = document.createElement('canvas'); 6964 mainCanvas.classList.add('cmp-adaptiveform-scribble__canvas__main'); 6965 mainCanvas.ariaLabel = FormView.LanguageUtils.getTranslatedString(this.lang, "SignatureCanvas"); 6966 return mainCanvas; 6967 } 6968 6969 drawCanvasesOnMainCanvas(mainCanvas, sigCnv, geoCnv) { 6970 const ctx = mainCanvas.getContext('2d'); 6971 if (geoCnv && geoCnv.width > 0 && geoCnv.height > 0) { 6972 // Set the dimensions of the mainCanvas to accommodate both canvases vertically 6973 mainCanvas.width = Math.max(sigCnv.width, geoCnv.width); 6974 mainCanvas.height = sigCnv.height + geoCnv.height; 6975 // Draw the sign canvas on the main canvas 6976 ctx.drawImage(sigCnv, 0, 0); 6977 // Draw the geo canvas below the sign canvas 6978 ctx.drawImage(geoCnv, 0, sigCnv.height, geoCnv.width, geoCnv.height); 6979 } else { 6980 mainCanvas.width = sigCnv.width; 6981 mainCanvas.height = sigCnv.height; 6982 ctx.drawImage(sigCnv, 0, 0); 6983 } 6984 } 6985 6986 updateSignedImage(newData) {
6987 const img = this.getSignedCanvasImage(); 6988 img.src = newData; 6989 img.style.width = '100%'; 6990 img.style.height = '150px'; 6991 } 6992 6993 addClearSignButton() { 6994 const clearSignButton = document.createElement('div'); 6995 clearSignButton.setAttribute('role', 'button'); 6996 clearSignButton.setAttribute('tabindex', '0'); 6997 clearSignButton.setAttribute('aria-label', FormView.LanguageUtils.getTranslatedString(this.lang, 'clearSign') || 'Clear Signature'); 6998 clearSignButton.classList.add('cmp-adaptiveform-scribble__clear-sign'); 6999 7000 const mainCanvasImageContainer = this.getCanvasContainer(); 7001 mainCanvasImageContainer.appendChild(clearSignButton); 7002 7003 clearSignButton.addEventListener('click', (e) => { 7004 e.stopPropagation(); 7005 this.openClearSignModal(); 7006 }); 7007 // Keyboard accessibility: allow Enter/Space to trigger clear 7008 clearSignButton.addEventListener('keydown', (e) => { 7009 if (e.key === 'Enter' || e.key === ' ') { 7010 e.preventDefault(); 7011 this.openClearSignModal(); 7012 } 7013 }); 7014 } 7015 7016 geoQueryErrorHandler(err){ 7017 this.showMessage('errorFetchGeoLocation'); 7018 } 7019 7020 renderBrushList() { 7021 [2,3,4,5,6,7,8,9,10].forEach((brush) => { 7022 var divel = document.createElement('div'); 7023 var cnv = document.createElement('canvas'); 7024 var ctx = cnv.getContext('2d'); 7025 cnv.style.border='1px solid #AAAAAA'; 7026 cnv.width=100; 7027 cnv.height=20; 7028 cnv.style.backgroundColor = 'white'; 7029 cnv.ariaLabel = FormView.LanguageUtils.getTranslatedString(this.lang, "brushSize") + brush; 7030 ctx.lineWidth=brush; 7031 ctx.beginPath(); 7032 ctx.moveTo(10,cnv.height/2); 7033 ctx.lineTo(cnv.width-10,cnv.height/2); 7034 ctx.stroke(); 7035 divel.appendChild(cnv); 7036 divel.addEventListener('click', (e) => { 7037 e.stopPropagation(); 7038 this.context.lineWidth=brush; 7039 this.toggleBrushList(); 7040 }) 7041 this.getBrushList().append(divel); 7042 }); 7043 } 7044 7045 resizeCanvas(percentage) { 7046 const signCanvas = this.getCanvas(); 7047 const ctx = signCanvas.getContext('2d', { willReadFrequently: true }); 7048 const container = this.getCanvasContainer();
7049 this.getSignCanvasesContainer().style.width = `${percentage}%`; 7050 7051 // Ensure the canvas has valid dimensions 7052 if (signCanvas.width === 0 || signCanvas.height === 0) { 7053 return; 7054 } 7055 7056 // Save the content of the canvas if it has valid dimensions 7057 let imgData = null; 7058 if (signCanvas.width > 0 && signCanvas.height > 0) { 7059 imgData = ctx.getImageData(0, 0, signCanvas.width, signCanvas.height); 7060 } 7061 // Calculate the new width based on the percentage of the container's width 7062 const newWidth = container.offsetWidth * (percentage / 100); 7063 // Set the new width and height of the canvas 7064 signCanvas.width = newWidth; 7065 // Restore the content back to the resized canvas if it has valid content 7066 if (imgData) { 7067 ctx.putImageData(imgData, 0, 0); 7068 } 7069 } 7070 7071 geoQuerySuccessHandler(position) { 7072 if (position && position.coords) { 7073 this.showMessage(''); 7074 const { latitude, longitude } = position.coords; 7075 const latStr = `Latitude: ${latitude}`; 7076 const longStr = `Longitude: ${longitude}`; 7077 const dateObj = new Date(); 7078 const tZone = (dateObj.getTimezoneOffset() / 60) * -1; 7079 const timeStr = `${dateObj.getTime()}: ${(dateObj.getMonth() + 1)}/${dateObj.getDate()}/${dateObj.getFullYear()} ${dateObj.getHours()}:${dateObj.getMinutes()}:${dateObj.getSeconds()}${tZone > 0 ? ' +' : ' '}${tZone}`; 7080 this.updateGeoCanvas(latStr, longStr, timeStr); 7081 } 7082 } 7083 7084 updateGeoCanvas(latStr, longStr, timeStr) { 7085 const geoCanvas = this.getGeoCanvas(); 7086 geoCanvas.style.height = '50px'; 7087 geoCanvas.style.width = '200px'; 7088 geoCanvas.style.display = 'block'; 7089 7090 if (geoCanvas) { 7091 const ctx = geoCanvas.getContext('2d'); 7092 geoCanvas.width = geoCanvas.offsetWidth; 7093 geoCanvas.height = geoCanvas.offsetHeight; 7094 7095 ctx.font = 'bold 10px Arial'; // Font size and type 7096 ctx.fillStyle = 'black'; // Text color 7097 ctx.measureText("m").width * 1.5; 7098 let x = 0; 7099 let y = 15; 7100 7101 // Draw the text on the canvas 7102 ctx.fillText(latStr, x, y); 7103 ctx.fillText(longStr, x, y + 15); 7104 ctx.fillText(timeStr, x, y + 30); 7105 } 7106 } 7107 7108 handleGeoLocation() { 7109 if (navigator.geolocation) { 7110 this._geoLocQuery = new GeoLocationQuery(); 7111 this._geoLocQuery.init( 7112 this.geoQuerySuccessHandler.bind(this), 7113 this.geoQueryErrorHandler.bind(this) 7114 ); 7115 this._geoLocQuery.query(); 7116 var message = FormView.LanguageUtils.getTranslatedString(this.lang, 'geoLocationFetch'); 7117 this.showMessage(message); 7118 } 7119 } 7120 7121 geoQueryErrorHandler(err) { 7122 var message = FormView.LanguageUtils.getTranslatedString(this.lang, 'geoLocationError') 7123 this.showMessage(message); 7124 } 7125 7126 enableControls(controls) { 7127 controls.forEach(control => { 7128 const element = this.element.querySelector('[data-cmp-scribble-button="'+ control +'"]'); 7129 element?.classList.remove('disable_button'); 7130 element?.removeAttribute('disabled'); 7131 }); 7132 } 7133 7134 disableControl(controls) { 7135 controls.forEach(control => { 7136 const element = this.element.querySelector('[data-cmp-scribble-button="'+ control +'"]'); 7137 element?.classList.add('disable_button'); 7138 element?.setAttribute('disabled', 'true'); 7139 }); 7140 } 7141 7142 toggleBrushList(event) { 7143 var brushList = this.getBrushList(); 7144 if(getComputedStyle(brushList).display === 'none') { 7145 brushList.style.display = 'block'; 7146 } else { 7147 brushList.style.display = 'none'; 7148 } 7149 } 7150 7151 controlPanelClickHandler(event) { 7152 const scribbleButton = event.target.getAttribute('data-cmp-scribble-button'); 7153 switch(scribbleButton){ 7154 case 'save': 7155 this.submitSign(); 7156 break; 7157 case 'close': 7158 this.closeEditModal(); 7159 break; 7160 case 'clearSign': 7161 this.eraseSignature(); 7162 this.widget.value = ''; 7163 break; 7164 case 'textSign': 7165 this.enableSignatureTextBox(); 7166 break; 7167 case 'geolocation': 7168 this.handleGeoLocation(); 7169 break; 7170 case 'brushes': 7171 this.handleBrush(event); 7172 this.toggleBrushList(); 7173 break; 7174 } 7175 } 7176 7177 closeEditModal() { 7178 if(this.getCanvas()) this.getCanvas().style.display = 'block'; 7179 if(!this._signSubmitted) { 7180 this.eraseSignature() 7181 } 7182 this.hideScribbleModal(); 7183 } 7184 7185 handleBrush(evt){ 7186 this.getKeyboardSignBox().style.display = 'none'; 7187 if (this.canvas.style.display == "none") { 7188 this.canvas.style.display = "block"; 7189 this.context.clearRect(0, 0, this.canvas?.width, this.canvas?.height); 7190 this.eraseSignature(); 7191 this.initializeCanvas(); 7192 } 7193 } 7194 initScribbleModal() {
7195 const controlPanel = this.getScribbleControlPanel(); 7196 const toggleBrushListIcon = this.getBrush(); 7197 const brushList = this.getBrushList(); 7198 const keyboardSignBox = this.getKeyboardSignBox(); 7199 7200 this.renderBrushList(); 7201 7202 this.addEventListeners(controlPanel, 'click', this.controlPanelClickHandler.bind(this)); 7203 7204 keyboardSignBox.addEventListener('input', (event) => { 7205 if (event?.target?.value) { 7206 this.enableControls(['save', 'clearSign']); 7207 } else { 7208 this.disableControl(['save', 'clearSign']); 7209 } 7210 }); 7211 7212 keyboardSignBox.addEventListener('keyup', () => { 7213 this.updateKeyboardSignBoxFont(keyboardSignBox); 7214 }); 7215 7216 document.addEventListener('click', (event) => { 7217 if (!brushList.contains(event.target) && !toggleBrushListIcon.contains(event.target)) { 7218 brushList.style.display = 'none'; 7219 } 7220 }); 7221 } 7222 7223 addEventListeners(element, eventType, handler, checkDisabled = false) { 7224 if (element) { 7225 element.addEventListener(eventType, (event) => { 7226 if (!checkDisabled || element.getAttribute('disabled') !== 'true') { 7227 handler(event); 7228 } 7229 }); 7230 } 7231 } 7232 7233 updateKeyboardSignBoxFont(keyboardSignBox) { 7234 const fontFamily = "sans-serif, Georgia"; 7235 const fontStyle = "italic"; 7236 keyboardSignBox.style.font = `${fontStyle} 2rem ${fontFamily}`; 7237 const value = keyboardSignBox.value; 7238 const canvas = this.getCanvas(); 7239 const ctx = this.context; 7240 const maxFontSize = 10; // rem 7241 const minFontSize = 1; // rem 7242 // Set to max font size to measure 7243 ctx.clearRect(0, 0, canvas.width, canvas.height); 7244 // Find the largest font size that fits the text within the canvas width 7245 let fontSize = maxFontSize; 7246 ctx.font = `${fontStyle} ${fontSize}rem ${fontFamily}`; 7247 let textWidth = ctx.measureText(value).width; 7248 const canvasWidth = canvas.width; 7249 while (fontSize > minFontSize && textWidth > canvasWidth) { 7250 fontSize -= 0.5; 7251 ctx.font = `${fontStyle} ${fontSize}rem ${fontFamily}`; 7252 textWidth = ctx.measureText(value).width; 7253 } 7254 fontSize = Math.max(minFontSize, fontSize); 7255 ctx.font = `${fontStyle} ${fontSize}rem ${fontFamily}`; 7256 ctx.fillText(value, 0, canvas.height / 2); 7257 } 7258 7259 enableSignatureTextBox() { 7260 this.eraseSignature(); 7261 this.getKeyboardSignBox().style.display = "inline-block"; 7262 this.getCanvas().style.display = "none"; 7263 } 7264 7265 eraseSignature() { 7266 this.context?.clearRect(0, 0, this.canvas?.width, this.canvas?.height); 7267 const geoCnv = this.getGeoCanvas(); 7268 if(geoCnv) { 7269 const geoCanvasContext = geoCnv?.getContext('2d'); 7270 geoCanvasContext?.clearRect(0, 0, geoCnv.width, geoCnv.height); 7271 geoCnv.style.display = 'none'; 7272 } 7273 this.getKeyboardSignBox().value=''; 7274 this.disableControl(['clearSign','save']); 7275 } 7276 7277 resizeAndFixCanvas() { 7278 const dpr = window.devicePixelRatio || 1; 7279 let imgData = null; 7280 if (this.canvas.width > 0 && this.canvas.height > 0) { 7281 imgData = this.context.getImageData(0, 0, this.canvas.width, this.canvas.height); 7282 } 7283 this.canvas.width = this.canvas.offsetWidth * dpr; 7284 this.canvas.height = this.canvas.offsetHeight * dpr; 7285 if (imgData) { 7286 this.context.putImageData(imgData, 0, 0); 7287 } 7288 } 7289 7290 handleCanvasEvent(event) { 7291 switch (event.type) { 7292 case 'mousedown': 7293 case 'touchstart': 7294 this.startDrawing(event); 7295 break; 7296 case 'mousemove': 7297 case 'touchmove': 7298 this.draw(event); 7299 break; 7300 case 'mouseup': 7301 case 'mouseleave': 7302 case 'touchend': 7303 case 'touchcancel': 7304 this.stopDrawing(); 7305 break; 7306 } 7307 } 7308 7309 addCanvasEventListeners() { 7310 const events = ['mousedown', 'mousemove', 'mouseup', 'mouseleave', 'touchstart', 'touchmove', 'touchend', 'touchcancel'];
7311 events.forEach(event => { 7312 this.canvas.addEventListener(event, this.handleCanvasEvent.bind(this)); 7313 }); 7314 } 7315 7316 initializeCanvas() { 7317 if(this.existingSign) { 7318 this.getCanvasContainer().style.width = '100%'; 7319 this.getMainCanvas().style.border = '1px solid black'; 7320 this.getKeyboardSignBox().style.display = 'none'; 7321 this.disableControl(['brushes','geolocation','clearSign','textSign','save']); 7322 } else { 7323 this.canvas = this.getCanvas(); 7324 this.canvas.style.display = 'block'; 7325 this.context = this.canvas.getContext('2d', { willReadFrequently: true }); 7326 this.resizeCanvas(100); 7327 this.resizeAndFixCanvas(); 7328 if (this.canvas) { 7329 this.canvas.style.border = '1px dashed #AAAAAA'; 7330 this.getKeyboardSignBox().style.display = 'none'; 7331 this.addCanvasEventListeners(); 7332 this.isDrawing = false; 7333 } 7334 } 7335 // Add event listener for window resize to make the canvas responsive 7336 window.addEventListener('resize', this.resizeAndFixCanvas.bind(this)); 7337 // } 7338 } 7339 7340 showScribbleModal() { 7341 if(window.getComputedStyle(this.getScribbleContainer()).display !== 'block') { 7342 this.disableControl(['clearSign','save']); 7343 } 7344 const container = this.getScribbleContainer(); 7345 container.style.display = 'block'; 7346 // Set focus to the modal container for accessibility 7347 container.setAttribute('tabindex', '-1'); 7348 container.focus(); 7349 } 7350 7351 hideScribbleModal() {
7352 this.getScribbleContainer().style.display = 'none'; 7353 } 7354 7355 scribbleContainerClickHandler() { 7356 this.showScribbleModal(); 7357 this.initializeCanvas(); 7358 } 7359 7360 startDrawing(event) { 7361 // Ensure the context is initialized 7362 if (!this.context) { 7363 return; 7364 } 7365 7366 // Normalize event coordinates for touch events 7367 const { offsetX, offsetY } = this.getEventCoordinates(event); 7368 7369 this.isDrawing = true; 7370 this.context.beginPath(); 7371 this.context.moveTo(offsetX, offsetY); 7372 } 7373 7374 getMousePos(event) { 7375 const rect = this.canvas.getBoundingClientRect(); 7376 const offsetX = event.clientX - rect.left; 7377 const offsetY = event.clientY - rect.top; 7378 return { offsetX, offsetY }; 7379 } 7380 7381 getEventCoordinates(event) { 7382 const rect = this.canvas.getBoundingClientRect(); 7383 const dpr = window.devicePixelRatio || 1; 7384 if (event.touches && event.touches.length > 0) { 7385 const touch = event.touches[0]; 7386 return { 7387 offsetX: (touch.clientX - rect.left) * dpr, 7388 offsetY: (touch.clientY - rect.top) * dpr 7389 }; 7390 } else { 7391 return { 7392 offsetX: (event.clientX - rect.left) * dpr, 7393 offsetY: (event.clientY - rect.top) * dpr 7394 }; 7395 } 7396 } 7397 7398 draw(event) { 7399 if (!this.isDrawing) return; 7400 const { offsetX, offsetY } = this.getEventCoordinates(event); 7401 this.context.lineTo(offsetX, offsetY); 7402 this.context.stroke(); 7403 this.enableControls(['clearSign','save']); 7404 } 7405 7406 stopDrawing() { 7407 if (this.isDrawing) { 7408 this.context.closePath(); 7409 this.isDrawing = false; 7410 } 7411 } 7412 } 7413 7414 FormView.Utils.setupField(({element, formContainer}) => { 7415 return new Scribble({element, formContainer}) 7416 }, Scribble.selectors.self); 7417})(); 7418 7419/******************************************************************************* 7420 * Copyright 2025 Adobe 7421 * 7422 * Licensed under the Apache License, Version 2.0 (the "License"); 7423 * you may not use this file except in compliance with the License. 7424 * You may obtain a copy of the License at 7425 * 7426 * http://www.apache.org/licenses/LICENSE-2.0 7427 * 7428 * Unless required by applicable law or agreed to in writing, software 7429 * distributed under the License is distributed on an "AS IS" BASIS, 7430 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 7431 * See the License for the specific language governing permissions and 7432 * limitations under the License. 7433 ******************************************************************************/ 7434(function() { 7435 7436 "use strict"; 7437 class Datetime extends FormView.FormFieldBase { 7438 7439 static NS = FormView.Constants.NS; 7440 /** 7441 * Each FormField has a data attribute class that is prefixed along with the global namespace to 7442 * distinguish between them. If a component wants to put a data-attribute X, the attribute in HTML would be 7443 * data-{NS}-{IS}-x="" 7444 * @type {string} 7445 */ 7446 static IS = "adaptiveFormDatetime"; 7447 static bemBlock = 'cmp-adaptiveform-datetime' 7448 static selectors = { 7449 self: "[data-" + this.NS + '-is="' + this.IS + '"]', 7450 widget: `.${Datetime.bemBlock}__widget`, 7451 label: `.${Datetime.bemBlock}__label`, 7452 description: `.${Datetime.bemBlock}__longdescription`, 7453 qm: `.${Datetime.bemBlock}__questionmark`, 7454 errorDiv: `.${Datetime.bemBlock}__errormessage`, 7455 tooltipDiv: `.${Datetime.bemBlock}__shortdescription`, 7456 eyeIcon: `.${Datetime.bemBlock}__eyeicon` 7457 }; 7458 7459 constructor(params) { 7460 super(params); 7461 } 7462 7463 getWidget() { 7464 return this.element.querySelector(Datetime.selectors.widget); 7465 } 7466 7467 getDescription() { 7468 return this.element.querySelector(Datetime.selectors.description); 7469 } 7470 7471 getLabel() { 7472 return this.element.querySelector(Datetime.selectors.label); 7473 } 7474 7475 getErrorDiv() { 7476 return this.element.querySelector(Datetime.selectors.errorDiv); 7477 } 7478 7479 getTooltipDiv() { 7480 return this.element.querySelector(Datetime.selectors.tooltipDiv); 7481 } 7482 7483 getQuestionMarkDiv() { 7484 return this.element.querySelector(Datetime.selectors.qm); 7485 } 7486 7487 setModel(model) { 7488 super.setModel(model); 7489 if (this.widget.value !== '') { 7490 this._model.value = this.widget.value; 7491 } 7492 this.widget.addEventListener('blur', (e) => { 7493 this._model.value = e.target.value; 7494 this.setInactive(); 7495 }); 7496 this.widget.addEventListener('focus', (e) => { 7497 this.setActive(); 7498 }); 7499 } 7500 7501 } 7502 7503 FormView.Utils.setupField(({element, formContainer}) => { 7504 return new Datetime({element, formContainer}) 7505 }, Datetime.selectors.self); 7506 7507})(); 7508
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.