jupiter-dynamic-forms 1.18.2 β†’ 1.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-form.d.ts","sourceRoot":"","sources":["../../src/core/dynamic-form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAE5C,OAAO,EACL,cAAc,EACd,QAAQ,EAGR,SAAS,EACT,eAAe,EAOf,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAOrD,OAAO,gBAAgB,CAAC;AACxB,OAAO,uBAAuB,CAAC;AAE/B,qBACa,kBAAmB,SAAQ,UAAU;IACpB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,MAAM,EAAE,eAAe,CAAM;IAC7B,WAAW,EAAE,QAAQ,CAAM;IAC1B,QAAQ,UAAS;IACjB,QAAQ,UAAS;IAClB,eAAe,SAAgB;IAC/B,aAAa,SAAgB;IAC7B,QAAQ,SAAQ;IAChB,iBAAiB,SAAQ;IACzB,OAAO,EAAE,WAAW,GAAG,WAAW,CAAe;IACjD,IAAI,EAAE,WAAW,GAAG,OAAO,GAAG,UAAU,CAAe;IAEnF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAM3B,cAAc,EAAE,gBAAgB,EAAE,CAAM;IAIxC,2BAA2B,UAAS;IAIpC,aAAa,UAAS;IAKtB,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAM;IAIjD,QAAQ,SAAS;IAMjB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAQjC,iBAAiB,CAAC,EAAE,GAAG,CAAC;IAExB,cAAc,CAAC,EAAE,GAAG,CAAC;IAEZ,OAAO,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,+BAA+B;IA4CvC;;OAEG;IACH,OAAO,CAAC,iCAAiC;IAsBzC,OAAO,CAAC,sBAAsB;IAqD9B,OAAO,CAAC,6BAA6B;IAYrC,OAAO,CAAC,sBAAsB;IAgF9B,OAAO,CAAC,sBAAsB;IAmLvB,OAAO,IAAI,QAAQ;IAInB,OAAO,CAAC,IAAI,EAAE,QAAQ;IAOtB,QAAQ,IAAI,OAAO;IAK1B;;;;OAIG;IACI,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,IAAI;IAUjE,KAAK;IAIL,QAAQ,IAAI,SAAS;IAI5B,MAAM;CA2KP"}
package/dist/index.js CHANGED
@@ -2895,7 +2895,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
2895
2895
  .btn-text:hover {
2896
2896
  background: var(--menuBgColorLighter, var(--jupiter-hover-background, #f5f5f5));
2897
2897
  }
2898
- `,ne([S({type:Boolean,reflect:!0})],exports.JupiterFilterRolesDialog.prototype,"open",2),ne([S({type:Array})],exports.JupiterFilterRolesDialog.prototype,"availableRoles",2),ne([S({type:Array})],exports.JupiterFilterRolesDialog.prototype,"selectedRoleIds",2),ne([S({type:Object})],exports.JupiterFilterRolesDialog.prototype,"periodPreferences",2),ne([S({type:String})],exports.JupiterFilterRolesDialog.prototype,"mode",2),ne([S({type:Object})],exports.JupiterFilterRolesDialog.prototype,"hypercubeData",2),ne([S({type:Boolean})],exports.JupiterFilterRolesDialog.prototype,"showFactsOnly",2),ne([S({type:String})],exports.JupiterFilterRolesDialog.prototype,"conceptSearchText",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_tempSelectedRoles",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_searchQuery",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_filteredRoles",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_tempPeriodPreferences",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_selectedAvailableRole",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_selectedChosenRole",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_chosenSearchQuery",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_draggedRoleId",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_dragOverRoleId",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_chosenRoleOrder",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_showAdvancedFilter",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_showFactsOnly",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_conceptSearchText",2),exports.JupiterFilterRolesDialog=ne([t("jupiter-filter-roles-dialog")],exports.JupiterFilterRolesDialog);var se=Object.defineProperty,ae=Object.getOwnPropertyDescriptor,le=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?ae(t,i):t,s=e.length-1;s>=0;s--)(r=e[s])&&(n=(o?r(t,i,n):r(n))||n);return o&&n&&se(t,i,n),n};exports.JupiterDynamicForm=class extends e.LitElement{constructor(){super(...arguments),this.config={},this.initialData={},this.disabled=!1,this.readonly=!1,this.periodStartDate="2025-01-01",this.periodEndDate="2025-12-31",this.language="en",this.reportingLanguage="en",this.display="accordion",this.mode="inputForm",this.roleFilterAxes=[],this.showLastValidationResultBtn=!1,this.isDraftSaving=!1,this.defaultUnits=[],this.decimals="INF",this._formData={},this._draftLoaded=!1,this._preservedFormData={},this._periodData={},this._preservedPeriodData={},this._unitData={},this._preservedUnitData={},this._decimalsData={},this._effectiveMasterData=void 0,this._typedMemberData={},this._preservedTypedMemberData={},this._repeatCounts={},this._columns=[],this._errors=[],this._touched=new Set,this._dirty=!1,this._valid=!0,this._submitted=!1,this._xbrlFormErrors=[],this._showErrorPopup=!1,this._submitDisabled=!1,this._allSections=[],this._selectedRoleIds=[],this._showFilterDialog=!1,this._showFactsOnly=!1,this._conceptSearchText="",this._periodPreferences={},this._activeSidePanelRoleId=null,this._sidePanelSearchQuery="",this._sidePanelCollapsed=!1,this._adminRoleConfigs={},this._roleBorderStatuses=new Map,this._roleCompletedStates=new Map,this._showRoleContextMenu=!1,this._contextMenuX=0,this._contextMenuY=0,this._contextMenuRoleId=null,this._validationStatus="idle",this._skipDraftLoading=!1,this._skipPeriodPreferencesRestore=!1,this._autoSaveTimer=null,this._lastAutoSaveSnapshot="",this._lastSavedDraftSnapshot=""}connectedCallback(){super.connectedCallback(),this.addEventListener("period-change",e=>{console.log("🌍 [GLOBAL DynamicForm] Caught period-change event on element:",e);const t=e;console.log("🌍 [GLOBAL DynamicForm] Event detail:",t.detail),this._handlePeriodChange(t)}),this.addEventListener("unit-change",e=>{console.log("🏷️ [GLOBAL DynamicForm] Caught unit-change event on element:",e);const t=e;console.log("🏷️ [GLOBAL DynamicForm] Event detail:",t.detail),this._handleUnitChange(t)}),this.addEventListener("decimals-change",e=>{this._handleDecimalsChange(e)}),this.addEventListener("field-blur",e=>{console.log("🚨 [DynamicForm] field-blur event listener triggered!",e);const t=e;this._handleFieldBlur(t)}),document.addEventListener("click",()=>{this._showRoleContextMenu&&(this._showRoleContextMenu=!1,this.requestUpdate())}),this._autoSaveTimer=setInterval(()=>{const e=JSON.stringify(this._formData);if(""===this._lastAutoSaveSnapshot)return this._lastAutoSaveSnapshot=e,void console.log("ℹ️ [Auto Save] Baseline initialized; no draft save emitted.");e!==this._lastAutoSaveSnapshot?(this._lastAutoSaveSnapshot=e,this._handleSaveDraft("auto")):console.log("ℹ️ [Auto Save] No form state change detected; skipping draft save emit.")},3e4),this._initializeForm()}disconnectedCallback(){super.disconnectedCallback(),null!==this._autoSaveTimer&&(clearInterval(this._autoSaveTimer),this._autoSaveTimer=null)}updated(e){(e.has("decimals")||e.has("masterData"))&&this._computeEffectiveMasterData(),e.has("language")&&R.setLanguage(this.language),(e.has("xbrlInput")||e.has("defaultUnits"))&&this.xbrlInput&&this.defaultUnits&&this.defaultUnits.length>0&&this._applyDefaultUnitsToDatatypes(),(e.has("xbrlInput")||e.has("schema")||e.has("language")||e.has("periodStartDate")||e.has("periodEndDate")||e.has("roleFilterAxes"))&&this._initializeForm()}_applyDefaultUnitsToDatatypes(){var e;if(!(null==(e=this.xbrlInput)?void 0:e.datatypes)||!this.defaultUnits||0===this.defaultUnits.length)return;console.log("πŸ”§ [DynamicForm] Applying defaultUnits to datatypes:",this.defaultUnits);const t=Array.isArray(this.xbrlInput.datatypes)?this.xbrlInput.datatypes:this.xbrlInput.datatypes.concepts;t&&0!==t.length?this.defaultUnits.forEach(e=>{Object.entries(e).forEach(([e,i])=>{const o=t.find(t=>t.type===e||t.id===e);if(o&&o.units&&o.units.length>0){const t=o.units.find(e=>e.id===i);t?(o.units.forEach(e=>e.isDefault=!1),t.isDefault=!0,console.log(`βœ… [DynamicForm] Set isDefault=true for unit "${i}" in datatype "${e}"`)):console.warn(`⚠️ [DynamicForm] Unit "${i}" not found in datatype "${e}"`)}else console.warn(`⚠️ [DynamicForm] Datatype "${e}" not found or has no units`)})}):console.warn("⚠️ [DynamicForm] No datatypes found to apply defaults to")}_initializeForm(){var e;if(this._draftStorageService||(this._draftStorageService=new k(!1)),this.xbrlInput)try{if(console.log("πŸ”„ Initializing form from XBRL input:",this.xbrlInput),console.log("πŸ“… Using period dates:",this.periodStartDate,"to",this.periodEndDate),console.log("🌐 Using language:",this.language),this._initializePeriodPreferencesFromData(),this._applyAxisFilterToPeriodPreferences(),this._applyDimensionShowPreviousYear(),console.log("βš™οΈ Using period preferences:",this._periodPreferences),this._currentSchema=F.buildFormSchema(this.xbrlInput,this.periodStartDate,this.periodEndDate,this.language,this._periodPreferences),console.log("βœ… Generated schema with sections:",this._currentSchema.sections.length),this._allSections=[...this._currentSchema.sections],Array.isArray(this._selectedRoleIds)&&this._selectedRoleIds.length>0&&"object"==typeof this._selectedRoleIds[0]){console.log("πŸ”„ Applying custom role order to _allSections from _selectedRoleIds");const e=this._selectedRoleIds,t=new Map;e.forEach(e=>{t.set(e.roleId,e.order)}),this._allSections=[...this._allSections].sort((e,i)=>(t.get(e.id)??999)-(t.get(i.id)??999)),console.log("βœ… Custom order applied to _allSections:",this._allSections.map(e=>e.title))}if(0===this._selectedRoleIds.length){const e=this.roleFilterAxes&&this.roleFilterAxes.length>0?this._filterRolesByAxisConfig(this._allSections):this._allSections;this._selectedRoleIds=e.map(e=>e.id),console.log(`βœ… Auto-selected ${this._selectedRoleIds.length} roles (of ${this._allSections.length} total)`)}this._applyRoleFilter(),this._columns=[{id:"base",title:"Value",description:"Base values for concepts",type:"base",order:0,removable:!1}]}catch(t){console.error("❌ Error building form from XBRL input:",t),this._currentSchema=this._getDefaultSchema(),this._allSections=[],this._selectedRoleIds=[],this._columns=this._getDefaultColumns()}else this.schema?(this._currentSchema=this.schema,this._allSections=[...this.schema.sections],this._selectedRoleIds=this._allSections.map(e=>e.id),this._columns=this._getDefaultColumns()):(this._currentSchema=this._getDefaultSchema(),this._allSections=[],this._selectedRoleIds=[],this._columns=this._getDefaultColumns());this._formData={...this.initialData},(null==(e=this.xbrlInput)?void 0:e.initialData)&&(this._formData={...this._formData,...this.xbrlInput.initialData}),this._initializeGlobalDecimalsFromRoundingData(),this._extractTypedMembersFromFacts(),this._skipDraftLoading?(console.log("⏭️ Skipping draft loading during preference update"),this._analyzeAllVisibleRoles()):this._loadDraftIfExists().then(()=>{this._analyzeAllVisibleRoles()}).catch(()=>{this._analyzeAllVisibleRoles()}),this._validateForm()}_extractTypedMembersFromFacts(){var e;(null==(e=this._currentSchema)?void 0:e.sections)&&(this._currentSchema.sections.forEach(e=>{this._extractTypedMembersFromConcepts(e.concepts||[],e)}),console.log("βœ… [DynamicForm] Typed member data populated:",this._typedMemberData))}_extractTypedMembersFromConcepts(e,t){e.forEach(e=>{e.facts&&e.facts.length>0&&(console.log(`πŸ” [DynamicForm] Checking concept ${e.id} with ${e.facts.length} facts`),e.facts.forEach(i=>{if(i.dimensions&&Array.isArray(i.dimensions)){const o=i.dimensions.filter(e=>"typed"===e.dimensionType&&e.typedMemberValue);if(o.length>0){console.log(`πŸ“ [DynamicForm] Found ${o.length} typed dimensions in fact:`,{factName:i.name,typedDimensions:o.map(e=>({dimension:e.dimension,typedMemberValue:e.typedMemberValue}))});const r=this._findColumnWithTypedMembers(i,e,t);r?(console.log(`βœ… [DynamicForm] Found matching column: ${r.id}`),o.forEach(i=>{var o,n;const s=this._normalizeAxisId(i.dimension),a=null==(n=null==(o=r.dimensionData)?void 0:o.typedMembers)?void 0:n.find(e=>e.axisId===s||this._normalizeAxisId(e.axisId)===s);if(a){this._typedMemberData[r.id]||(this._typedMemberData[r.id]={});const o=a.axisId;this._typedMemberData[r.id][o]=i.typedMemberValue,console.log("βœ… [DynamicForm] Set typed member value:",{sectionId:t.id,conceptId:e.id,columnId:r.id,axisKey:o,typedMemberValue:i.typedMemberValue})}else console.warn(`⚠️ [DynamicForm] Typed member not found for axis: ${s}`)})):console.warn("⚠️ [DynamicForm] No matching column found for fact with typed dimensions")}}})),e.children&&e.children.length>0&&this._extractTypedMembersFromConcepts(e.children,t)})}_findColumnWithTypedMembers(e,t,i){var o;if(!t.fields||0===t.fields.length)return null;const r=i.columns||[];if(0===r.length)return null;for(const n of t.fields){const t=r.find(e=>e.id===n.columnId);if(t&&(null==(o=t.dimensionData)?void 0:o.hasTypedMembers)){const i=(e.dimensions||[]).filter(e=>"explicit"===e.dimensionType),o=t.dimensionData.combinations||[];if(0===i.length||i.length===o.length&&i.every(e=>o.some(t=>this._normalizeAxisId(e.dimension)===this._normalizeAxisId(t.axisId)&&this._normalizeMemberId(e.member)===this._normalizeMemberId(t.memberId))))return t}}return null}_findColumnForFactDimensions(e,t,i){if(!t.fields||0===t.fields.length)return console.log(`⚠️ [DynamicForm] No fields for concept: ${t.id}`),null;const o=i.columns||[];if(0===o.length)return console.log(`⚠️ [DynamicForm] No columns in section: ${i.id}`),null;for(const r of t.fields){const t=o.find(e=>e.id===r.columnId);if(t&&t.dimensionData){const i=e.dimensions||[],o=t.dimensionData.combinations||[];console.log(`πŸ” [DynamicForm] Checking column ${t.id}:`,{factDimensions:i.map(e=>({axis:e.dimension,member:e.member,type:e.dimensionType})),columnDimensions:o.map(e=>({axis:e.axisId,member:e.memberId}))});if(o.every(e=>i.some(t=>{const i=this._normalizeAxisId(t.dimension)===this._normalizeAxisId(e.axisId);if("explicit"===t.dimensionType){const o=this._normalizeMemberId(t.member)===this._normalizeMemberId(e.memberId);return i&&o}return"typed"===t.dimensionType&&i})))return t}}return null}_normalizeAxisId(e){return e?e.includes(":")?e.split(":").pop()||e:e.includes("_")&&e.split("_").pop()||e:""}_normalizeMemberId(e){return e?e.includes(":")?e.split(":").pop()||e:e.includes("_")&&e.split("_").pop()||e:""}_getDefaultSchema(){return{version:"1.0",formId:"default-form",title:"Dynamic Form",description:"Please provide form schema or XBRL input data",sections:[]}}_getDefaultColumns(){return[{id:"base",title:"Value",description:"Base values for concepts",type:"base",order:0,removable:!1}]}_initializePeriodPreferencesFromData(){var e,t,i;if(!(null==(i=null==(t=null==(e=this.xbrlInput)?void 0:e.presentation)?void 0:t[0])?void 0:i.roles))return;const o={...this._periodPreferences};this.xbrlInput.presentation[0].roles.forEach(e=>{if(!o[e.id]){const t=!0===e.showPreviousYear,i=void 0===e.instant||!0===e.instant,r=void 0===e.duration||!0===e.duration;o[e.id]={showDuration:r,showInstant:i,showPreviousYear:t}}}),this._periodPreferences=o}_applyAxisFilterToPeriodPreferences(){var e,t,i,o;if(!this.roleFilterAxes||0===this.roleFilterAxes.length)return;if(!(null==(i=null==(t=null==(e=this.xbrlInput)?void 0:e.hypercubes)?void 0:t[0])?void 0:i.roles))return;const r=this.xbrlInput.hypercubes[0].roles,n={...this._periodPreferences};for(const s of r){const e=s.roleId,t=n[e];if((null==t?void 0:t.dimensionSelections)&&t.dimensionSelections.length>0)continue;const i=[];for(const r of this.roleFilterAxes)for(const e of s.items||[]){if(null==(o=e.dimensions)?void 0:o.find(e=>e.id===r.id||r.conceptName&&e.conceptName===r.conceptName)){i.push({dimensionId:r.id,dimensionLabel:r.conceptName||r.id,selectedMemberIds:r.members.filter(e=>!0===e.available).map(e=>e.id)});break}}i.length>0&&(n[e]={showDuration:(null==t?void 0:t.showDuration)??!0,showInstant:(null==t?void 0:t.showInstant)??!0,showPreviousYear:(null==t?void 0:t.showPreviousYear)??!1,dimensionSelections:i})}this._periodPreferences=n}_applyDimensionShowPreviousYear(){var e,t;if("admin"!==this.mode)return;const i=!(!this.dynaformsFacts||!this.dynaformsMetadata),o=(null==(e=this._draftStorageService)?void 0:e.hasDraft())??!1;if(i||o)return;const r={...this._periodPreferences};let n=!1;for(const s of Object.keys(r)){const e=r[s];if(e.showPreviousYear)continue;((null==(t=e.dimensionSelections)?void 0:t.some(e=>e.selectedMemberIds&&e.selectedMemberIds.length>0))??!1)&&(r[s]={...e,showPreviousYear:!0},n=!0,console.log(`πŸ“… [JDF-010] Auto-enabled showPreviousYear for role "${s}" (has dimension members)`))}n&&(this._periodPreferences=r)}_getRoleIdsArray(){return Array.isArray(this._selectedRoleIds)&&0!==this._selectedRoleIds.length?"string"==typeof this._selectedRoleIds[0]?this._selectedRoleIds:this._selectedRoleIds.map(e=>e.roleId):[]}_applyRoleFilter(){if(!this._currentSchema||!this._allSections.length)return;const e=this._getRoleIdsArray();if(console.log(`πŸ” Applying role filter: ${e.length} selected out of ${this._allSections.length} total`),0===e.length)return console.log("πŸ“ No roles selected - showing empty form"),this._currentSchema={...this._currentSchema,sections:[]},void this.requestUpdate();this._preserveDataForHiddenSections();const t=this._allSections.filter(t=>e.includes(t.id)),i=this._sortSectionsByCustomOrder(t);console.log(`πŸ“Š Filtered sections: ${i.length}`),console.log("πŸ“‹ Custom order applied:",i.map(e=>e.title)),this._restoreDataForVisibleSections(i),this._currentSchema={...this._currentSchema,sections:i},console.log(`βœ… Schema updated with custom order. Current sections count: ${this._currentSchema.sections.length}`),this.requestUpdate()}_sortSectionsByCustomOrder(e){if(Array.isArray(this._selectedRoleIds)&&this._selectedRoleIds.length>0&&"object"==typeof this._selectedRoleIds[0]){const t=this._selectedRoleIds,i=new Map;return t.forEach(e=>{i.set(e.roleId,e.order)}),[...e].sort((e,t)=>(i.get(e.id)??999)-(i.get(t.id)??999))}return e}_filterRolesByAxisConfig(e){var t;if(!this.roleFilterAxes||0===this.roleFilterAxes.length)return e;if(!(null==(t=this.xbrlInput)?void 0:t.hypercubes)||0===this.xbrlInput.hypercubes.length)return e;const i=this.xbrlInput.hypercubes[0];return e.filter(e=>{var t;const o=null==(t=i.roles)?void 0:t.find(t=>t.roleId===e.id);if(!o||!o.items||0===o.items.length)return!0;for(const i of this.roleFilterAxes){const e=new Set(i.members.filter(e=>!0===e.available).map(e=>e.id));let t=!1,r=!1;for(const n of o.items){if(!n.dimensions||0===n.dimensions.length)continue;const o=n.dimensions.find(e=>e.id===i.id||i.conceptName&&e.conceptName===i.conceptName);if(o){if(t=!0,o.members)for(const t of o.members)if(e.has(t.id)){r=!0;break}if(r)break}}if(t&&!r)return!1}return!0})}_preserveDataForHiddenSections(){var e;const t=(null==(e=this._currentSchema)?void 0:e.sections.map(e=>e.id))||[],i=this._getRoleIdsArray();t.filter(e=>!i.includes(e)).forEach(e=>{const t=this._allSections.find(t=>t.id===e);t&&this._preserveSectionData(t)})}_restoreDataForVisibleSections(e){e.forEach(e=>{this._restoreSectionData(e)}),console.log(`πŸ”„ Restored data for ${e.length} visible sections`)}_preserveSectionData(e){e.concepts.forEach(e=>{this._preserveConceptData(e)})}_preserveConceptData(e){this._formData[e.id]&&(this._preservedFormData[e.id]={...this._formData[e.id]}),e.fields.forEach(t=>{this._typedMemberData[t.columnId]&&(this._preservedTypedMemberData[t.columnId]={...this._typedMemberData[t.columnId]});const i=`${e.id}__${t.columnId}`;this._typedMemberData[i]&&(this._preservedTypedMemberData[i]={...this._typedMemberData[i]})}),e.children&&e.children.forEach(e=>{this._preserveConceptData(e)})}_restoreSectionData(e){e.concepts.forEach(e=>{this._restoreConceptData(e)})}_restoreConceptData(e){this._preservedFormData[e.id]&&(this._formData[e.id]={...this._preservedFormData[e.id]}),e.fields.forEach(t=>{this._preservedTypedMemberData[t.columnId]&&(this._typedMemberData[t.columnId]={...this._preservedTypedMemberData[t.columnId]});const i=`${e.id}__${t.columnId}`;this._preservedTypedMemberData[i]&&(this._typedMemberData[i]={...this._preservedTypedMemberData[i]})}),e.children&&e.children.forEach(e=>{this._restoreConceptData(e)})}_shouldShowFilterButton(){return!0}_handleFilterRolesClick(){this._showFilterDialog=!0}_handleAdvancedFilterApply(e){this._showFactsOnly=e.detail.showFactsOnly,this._conceptSearchText=e.detail.conceptSearchText??"",this._showFilterDialog=!1}_handleFilterDialogCancel(){this._showFilterDialog=!1;const e=this._getRoleIdsArray().length;console.log(`🚫 Filter dialog cancelled. Current selection: ${e}/${this._allSections.length}`)}_handleRoleFilterApply(e){var t,i;const{selectedRoleIds:o,periodPreferences:r}=e.detail;console.log("🎯 Filter apply triggered"),console.log("πŸ“Š Old _selectedRoleIds:",this._selectedRoleIds),console.log("πŸ“Š New selectedRoleIds from dialog:",o),this._selectedRoleIds=o,this._periodPreferences=r,console.log("πŸ“Š Updated _selectedRoleIds:",this._selectedRoleIds),console.log("πŸ“Š New period preferences (including dimension selections):",this._periodPreferences),console.log("πŸ’Ύ Capturing current form data before reinitialization...");const n=this._generateSubmissionData(),s=this._draftStorageService.createMetadataSnapshot(this.periodStartDate,this.periodEndDate,this.language,this._selectedRoleIds,this._allSections,this._typedMemberData,this._periodPreferences,this._periodData,this._unitData,this.reportingLanguage,this._repeatCounts,this._decimalsData);this._draftStorageService.saveDraft(n,s),console.log("βœ… Current form data saved to draft storage with NEW preferences"),this._skipPeriodPreferencesRestore=!0,this._skipDraftLoading=!0,console.log("πŸ”„ Reinitializing form with new filter settings..."),this._initializeForm(),this._skipDraftLoading=!1,this._skipPeriodPreferencesRestore=!1,console.log("πŸ“Š After _initializeForm, _currentSchema.sections.length:",null==(t=this._currentSchema)?void 0:t.sections.length),console.log("πŸ“Š Section IDs:",null==(i=this._currentSchema)?void 0:i.sections.map(e=>e.id)),console.log("πŸ“₯ Restoring form data from draft after reinitialization..."),this._loadDraftIfExists().then(()=>{console.log("βœ… Form data restored successfully after reinitialization")}).catch(e=>{console.error("❌ Error restoring form data after reinitialization:",e)}),this._showFilterDialog=!1;const a=Array.isArray(this._selectedRoleIds)&&this._selectedRoleIds.length>0?(this._selectedRoleIds[0],this._selectedRoleIds.length):0;console.log(`🎯 Applied role filter: ${a}/${this._allSections.length} roles selected`),console.log("πŸ“‹ Enhanced selectedRoleIds structure:",this._selectedRoleIds),this.dispatchEvent(new CustomEvent("roles-filter-changed",{detail:{selectedRoleIds:o,totalRoles:this._allSections.length,visibleRoles:a,periodPreferences:r},bubbles:!0}))}_haveDimensionSelectionsChanged(e){var t;const i=new Set([...Object.keys(this._periodPreferences||{}),...Object.keys(e||{})]);for(const o of i){const i=null==(t=this._periodPreferences)?void 0:t[o],r=null==e?void 0:e[o],n=(null==i?void 0:i.dimensionSelections)||[],s=(null==r?void 0:r.dimensionSelections)||[];if(JSON.stringify(n.sort((e,t)=>e.dimensionId.localeCompare(t.dimensionId)))!==JSON.stringify(s.sort((e,t)=>e.dimensionId.localeCompare(t.dimensionId))))return console.log(`πŸ” Dimension selection changed for role: ${o}`),console.log(" Old:",n),console.log(" New:",s),!0}return!1}_validateForm(){var e;const t=[],i=this._currentSchema;if(i){for(const o of i.sections)for(const i of o.concepts)for(const o of i.fields){const r=null==(e=this._formData[i.id])?void 0:e[o.columnId],n=C.validateField(o.id,i.id,o.columnId,r,o.type,o.validation||[]);t.push(...n)}this._errors=t,this._valid=0===t.filter(e=>"error"===e.severity).length}}_handleFieldChange(e){const{fieldId:t,conceptId:i,columnId:o,value:r}=e.detail;console.log(`πŸ“ Field change: conceptId=${i}, columnId=${o}, value=${r}, fieldId=${t}`);const n={...this._formData};n[i]||(n[i]={});const s=n[i][o];n[i]={...n[i],[o]:r},this._formData=n,console.log(`πŸ’Ύ Updated formData[${i}]:`,this._formData[i]),this._touched.add(`${i}-${o}`),this._dirty=!0,this._validateForm(),this.requestUpdate(),this.dispatchEvent(new CustomEvent("field-change",{detail:{fieldId:t,conceptId:i,columnId:o,value:r,oldValue:s},bubbles:!0}))}_handlePeriodChange(e){console.log("🎯 [DynamicForm] _handlePeriodChange called with event:",e),console.log("🎯 [DynamicForm] Event detail:",e.detail);const{conceptId:t,columnId:i,periodType:o,periodStartDate:r,periodEndDate:n,periodInstantDate:s,unit:a}=e.detail;console.log(`πŸ“… Period change received: conceptId=${t}, columnId=${i}, periodType=${o}, startDate=${r}, endDate=${n}, instantDate=${s}, unit=${a}`);const l={...this._periodData};l[t]||(l[t]={}),l[t]={...l[t],[i]:{startDate:r,endDate:n,instantDate:s}},this._periodData=l,console.log(`πŸ’Ύ Period data stored for [${t}][${i}]:`,this._periodData[t][i]),console.log("πŸ“¦ Full period data state:",JSON.stringify(this._periodData,null,2)),a&&this._storeUnit(t,i,a),this._dirty=!0,this.requestUpdate()}_handleUnitChange(e){console.log("🏷️ [DynamicForm] _handleUnitChange called with event:",e),console.log("🏷️ [DynamicForm] Event detail:",e.detail);const{conceptId:t,columnId:i,unit:o}=e.detail;console.log(`🏷️ Unit change received: conceptId=${t}, columnId=${i}, unit=${o}`),this._storeUnit(t,i,o),this._dirty=!0,this.requestUpdate()}_storeUnit(e,t,i){console.log(`πŸ”§ [_storeUnit] Called with conceptId=${e}, columnId=${t}, unit=${i}`),console.log("πŸ”§ [_storeUnit] Current _unitData before update:",JSON.stringify(this._unitData,null,2));const o={...this._unitData};o[e]||(console.log(`πŸ”§ [_storeUnit] Creating new entry for conceptId: ${e}`),o[e]={}),o[e]={...o[e],[t]:i},this._unitData=o,console.log(`πŸ’Ύ [_storeUnit] Unit data stored for [${e}][${t}]:`,this._unitData[e][t]),console.log("πŸ“¦ [_storeUnit] Full unit data state after update:",JSON.stringify(this._unitData,null,2))}_handleDecimalsChange(e){const{conceptId:t,columnId:i,decimals:o}=e.detail;t&&i&&(this._storeDecimals(t,i,o),this._dirty=!0,this.requestUpdate())}_computeEffectiveMasterData(){const e="rj-i_DocumentIntendedRoundingLevel";if("INF"!==this.decimals){const t=parseFloat(this.decimals);if(!isNaN(t))return void(this._effectiveMasterData={...this.masterData||{},[e]:String(-t)})}this._effectiveMasterData=this.masterData?{...this.masterData}:void 0}_initializeGlobalDecimalsFromRoundingData(){if(this._hasValidGlobalDecimals())return;const e=this._findRoundingLevelFactValue(this._allSections)??this._findRoundingLevelValueInFormData(this._formData);if(null==e||""===e)return;const t=parseFloat(String(e));isNaN(t)||(this.decimals=String(Math.abs(t)))}_findRoundingLevelValueInFormData(e){if(e)for(const t of Object.keys(e)){if(!this._isRoundingLevelConcept(t))continue;const i=e[t]||{};for(const e of Object.keys(i)){const t=i[e];if(null!=t&&""!==t)return t}}}_findRoundingLevelFactValue(e){for(const t of e){const e=this._findRoundingLevelFactValueInConcepts(t.concepts||[]);if(null!=e&&""!==e)return e}}_findRoundingLevelFactValueInConcepts(e){for(const t of e){const e=t.originalConceptId||t.id;if(this._isRoundingLevelConcept(e)){const e=t.facts||[];for(const t of e)if(void 0!==(null==t?void 0:t.value)&&null!==(null==t?void 0:t.value)&&""!==(null==t?void 0:t.value))return t.value}if(t.children&&t.children.length>0){const e=this._findRoundingLevelFactValueInConcepts(t.children);if(null!=e&&""!==e)return e}}}_hasValidGlobalDecimals(){if(void 0===this.decimals||null===this.decimals)return!1;if("INF"===this.decimals)return!1;const e=parseFloat(this.decimals);return!isNaN(e)}_isRoundingLevelConcept(e){return!!e&&("rj-i_DocumentIntendedRoundingLevel"===e||e.includes("DocumentIntendedRoundingLevel"))}_findFactValueForField(e,t,i){var o,r;if(!e.facts||0===e.facts.length)return;const n=this._findColumnByIdInSection(t.columnId,i),s=null==(o=this._periodData[e.id])?void 0:o[t.columnId],a=(null==s?void 0:s.startDate)||(null==n?void 0:n.periodStartDate)||t.periodStartDate||this.periodStartDate,l=(null==s?void 0:s.endDate)||(null==n?void 0:n.periodEndDate)||t.periodEndDate||this.periodEndDate,d=(null==s?void 0:s.instantDate)||t.periodInstantDate||l||a,c=null==(r=this._unitData[e.id])?void 0:r[t.columnId],p={conceptId:e.originalConceptId||t.conceptId||e.id,columnId:t.columnId,periodStartDate:a,periodEndDate:l,periodInstantDate:d,periodType:t.periodType,unit:c,dimensionData:null==n?void 0:n.dimensionData},h=E.findMatchingFact(e.facts,p);return null==h?void 0:h.value}_storeDecimals(e,t,i){const o={...this._decimalsData};o[e]||(o[e]={}),o[e]={...o[e],[t]:i??""},this._decimalsData=o}_generateUniqueConceptKey(e,t){return`${e}::${t}`}_extractOriginalConceptId(e){const t=e.split("::");return t.length>1?t[1]:e}_handleAddConceptRepeat(e){const{conceptId:t}=e.detail;this._repeatCounts={...this._repeatCounts,[t]:(this._repeatCounts[t]||0)+1},this._dirty=!0}_handleRemoveConceptRepeat(e){const{conceptId:t}=e.detail,i=t.match(/^(.+)__repeat_(\d+)$/),o=i?i[1]:t,r=i?parseInt(i[2]):this._repeatCounts[t]||0,n=this._repeatCounts[o]||0;if(n<=0||r<1||r>n)return;const s={...this._formData},a={...this._typedMemberData},l={...this._unitData},d={...this._periodData};for(let h=r;h<n;h++){const e=`${o}__repeat_${h+1}`,t=`${o}__repeat_${h}`;void 0!==s[e]?s[t]=s[e]:delete s[t];const i=`${t}__`,r=`${e}__`,n=Object.keys(a).filter(e=>e.startsWith(r));Object.keys(a).filter(e=>e.startsWith(i)).forEach(e=>delete a[e]),n.forEach(e=>{a[`${t}__${e.slice(r.length)}`]=a[e]}),n.forEach(e=>delete a[e]),void 0!==l[e]?l[t]=l[e]:delete l[t],void 0!==d[e]?d[t]=d[e]:delete d[t]}const c=`${o}__repeat_${n}`;delete s[c],delete l[c],delete d[c];const p=`${c}__`;Object.keys(a).filter(e=>e.startsWith(p)).forEach(e=>delete a[e]),this._formData=s,this._typedMemberData=a,this._unitData=l,this._periodData=d,this._repeatCounts={...this._repeatCounts,[o]:n-1},this._dirty=!0}_handleTypedMemberChange(e){const{columnId:t,axisId:i,value:o,conceptId:r}=e.detail,n=r?`${r}__${t}`:t;console.log(`πŸ” [DynamicForm] Typed member change: storageKey=${n}, axisId=${i}, value=${o}`);const s={...this._typedMemberData};s[n]||(s[n]={}),s[n]={...s[n],[i]:o},this._typedMemberData=s,this._dirty=!0,this.requestUpdate(),this.dispatchEvent(new CustomEvent("typed-member-change",{detail:{columnId:t,axisId:i,value:o},bubbles:!0}))}_handleFieldBlur(e){var t;console.log("🟧 [DynamicForm] _handleFieldBlur received event:",e),console.log("🟧 [DynamicForm] Event detail:",e.detail);const{fieldId:i,conceptId:o,columnId:r,xbrlValidationErrors:n}=e.detail;console.log(`🟧 [DynamicForm] Extracted - fieldId: ${i}, conceptId: ${o}, columnId: ${r}`),console.log("🟧 [DynamicForm] xbrlValidationErrors:",n);let s="";const a=e.composedPath();console.log(`🟧 [DynamicForm] Event path length: ${a.length}`);for(const l of a){const e=l;if("JUPITER-FORM-SECTION"===e.tagName){s=e.getAttribute("section-id")||"",console.log(`🟧 [DynamicForm] Found section element with id: ${s}`);break}}if(console.log(`🟧 [DynamicForm] Found sectionId: ${s}`),console.log(`🟧 [DynamicForm] Processing errors - has errors: ${n&&n.length>0}`),n&&n.length>0){console.log(`🟧 [DynamicForm] Adding/updating error for fieldId: ${i}, sectionId: ${s}`);const e=(null==(t=this._formData[o])?void 0:t[r])||"",a=this._xbrlFormErrors.findIndex(e=>e.fieldId===i&&e.sectionId===s),l={sectionId:s,fieldId:i,conceptId:o,columnId:r,value:e,errors:n};console.log("🟧 [DynamicForm] New error object:",l),console.log(`🟧 [DynamicForm] Existing index: ${a}`),a>=0?(this._xbrlFormErrors=[...this._xbrlFormErrors.slice(0,a),l,...this._xbrlFormErrors.slice(a+1)],console.log(`🟧 [DynamicForm] Updated existing error at index ${a}`)):(this._xbrlFormErrors=[...this._xbrlFormErrors,l],console.log("🟧 [DynamicForm] Added new error"))}else{console.log(`🟧 [DynamicForm] Removing error (if exists) for fieldId: ${i}, sectionId: ${s}`);const e=this._xbrlFormErrors.length;this._xbrlFormErrors=this._xbrlFormErrors.filter(e=>!(e.fieldId===i&&e.sectionId===s)),console.log(`🟧 [DynamicForm] Removed ${e-this._xbrlFormErrors.length} errors`)}console.log(`πŸ” [Validation] Total errors: ${this._xbrlFormErrors.length}`,this._xbrlFormErrors)}_getSectionTitle(e){console.log(`πŸ” [_getSectionTitle] Looking for sectionId: "${e}"`),console.log("πŸ” [_getSectionTitle] Available sections:",this._allSections.map(e=>({id:e.id,title:e.title})));const t=this._allSections.find(t=>t.id===e),i=(null==t?void 0:t.title)||e||"(Unknown Section)";return console.log(`πŸ” [_getSectionTitle] Result: "${i}"`),i}_roleHasErrors(e){return this._xbrlFormErrors.some(t=>t.sectionId===e)}async _handleErrorFieldClick(e,t,i){var o,r,n,s;console.log(`🎯 [Error Click] Attempting to focus field: ${e}__${t} in section: ${i}`),this._showErrorPopup=!1,this.requestUpdate(),await this.updateComplete,"sidePanel"===this.display&&this._activeSidePanelRoleId!==i&&(console.log(`πŸ”€ Switching to section: ${i} (currently on: ${this._activeSidePanelRoleId})`),this._activeSidePanelRoleId=i,this.requestUpdate(),await this.updateComplete,await new Promise(e=>setTimeout(e,500)));const a=null==(o=this.shadowRoot)?void 0:o.querySelectorAll("jupiter-form-section");let l=null;if(null==a||a.forEach(e=>{var t;(null==(t=e.section)?void 0:t.id)===i&&(l=e)}),!l)return void console.warn(`⚠️ Section not found: ${i}`);if(console.log("βœ… Found section element:",l),(null==(r=l.section)?void 0:r.collapsed)?(console.log("πŸ“‚ Expanding collapsed section"),l.section.collapsed=!1,l.requestUpdate(),await l.updateComplete,await new Promise(e=>setTimeout(e,500))):(await l.updateComplete,await new Promise(e=>setTimeout(e,100))),console.log(`πŸ” Section shadow DOM exists: ${!!l.shadowRoot}`),l.shadowRoot){console.log(`πŸ” Shadow DOM innerHTML length: ${(null==(n=l.shadowRoot.innerHTML)?void 0:n.length)||0}`);const e=l.shadowRoot.querySelectorAll("*");console.log(`πŸ” Total elements in shadow DOM: ${e.length}`);const t=Array.from(e).filter(e=>{const t=e;return!(!t.tagName||!t.tagName.includes("-"))});console.log("πŸ” Custom elements found:",t.map(e=>e.tagName).join(", "))}const d=`${e}_${t}_field`;console.log(`πŸ” Looking for input with fieldId: ${d}`),console.log(`πŸ” Looking for field with conceptId: ${e} AND columnId: ${t}`);const c=null==(s=l.shadowRoot)?void 0:s.querySelectorAll("jupiter-concept-tree");let p=null;if(console.log(`πŸ” Found ${(null==c?void 0:c.length)||0} concept-tree elements`),c&&c.forEach((i,o)=>{var r;if(p)return;const n=null==(r=i.shadowRoot)?void 0:r.querySelectorAll("jupiter-form-field");console.log(`πŸ” Concept tree ${o}: Found ${(null==n?void 0:n.length)||0} form-field elements`),null==n||n.forEach((i,o)=>{var r;if(!p&&(console.log(` Field ${o}: conceptId=${i.conceptId}, columnId=${i.columnId}`),i.conceptId===e&&i.columnId===t)){const e=null==(r=i.shadowRoot)?void 0:r.querySelector("input, textarea");console.log(` -> Matched! Input element found: ${!!e}`),e&&(p=e,console.log("βœ… Found input element in form-field"))}})}),!p)return void console.warn(`⚠️ Input field not found for: ${d}`);const h=p;l.scrollIntoView({behavior:"smooth",block:"start"}),await new Promise(e=>setTimeout(e,300)),h.focus(),"INPUT"!==h.tagName&&"TEXTAREA"!==h.tagName||h.select(),h.style.boxShadow="0 0 0 3px rgba(220, 38, 38, 0.5)",setTimeout(()=>{h.style.boxShadow=""},2e3),console.log(`βœ… Successfully focused field: ${e}__${t}`)}_handleSectionExpand(e){this.dispatchEvent(new CustomEvent("section-expand",{detail:e.detail,bubbles:!0}))}_handleConceptExpand(e){this.dispatchEvent(new CustomEvent("concept-expand",{detail:e.detail,bubbles:!0}))}_handleColumnRemove(e){const{columnId:t,sectionId:i}=e.detail;if(this._currentSchema&&i){const e=this._currentSchema.sections.find(e=>e.id===i);e&&e.columns&&(e.columns=e.columns.filter(e=>e.id!==t))}else this._columns=this._columns.filter(e=>e.id!==t),this._currentSchema&&this._currentSchema.sections.forEach(e=>{e.columns&&(e.columns=e.columns.filter(e=>e.id!==t))});this._removeColumnData(t,i),this._dirty=!0,this._validateForm(),this.requestUpdate(),this.dispatchEvent(new CustomEvent("column-remove",{detail:{columnId:t,sectionId:i},bubbles:!0}))}_handleColumnAddRequest(e){const{sectionId:t,columnRequest:i,insertAfterColumnId:o}=e.detail;this._addColumnFromRequest(i,t,o)}_getAvailableDimensionsForSection(e){var t,i,o;if(!(null==(i=null==(t=this.xbrlInput)?void 0:t.hypercubes)?void 0:i[0]))return[];const r=this.xbrlInput.hypercubes[0].roles.find(t=>t.roleId===e);if(!(null==(o=null==r?void 0:r.items)?void 0:o.length))return console.log(`❌ No hypercube items found for role: ${e}`),[];const n=[],s=this.language||"en",a=(e,t)=>{var i;return(null==(i=(null==e?void 0:e.find(e=>e.lang===s&&"http://www.xbrl.org/2003/role/label"===e.role))||(null==e?void 0:e.find(e=>"en"===e.lang&&"http://www.xbrl.org/2003/role/label"===e.role))||(null==e?void 0:e.find(e=>"http://www.xbrl.org/2003/role/label"===e.role)))?void 0:i.label)||t};return r.items.forEach(e=>{e.dimensions&&e.dimensions.length>0&&e.dimensions.forEach(e=>{if(!n.find(t=>t.id===e.id)){const t=a(e.labels,e.conceptName),i={id:e.id,conceptName:e.conceptName,axisLabel:t};e.members&&e.members.length>0&&(i.members=e.members.map(e=>({id:e.id,label:a(e.labels,e.conceptName||e.id)}))),e.typedMember&&(i.typedMember={id:e.typedMember.id,dataType:"string"}),n.push(i)}})}),n}_formatPeriodDisplay(e,t){if(!e||!t)return`${e||""} / ${t||""}`;const i=e.substring(0,4);return i===t.substring(0,4)?i:`${e} / ${t}`}_resolveInstantDate(e,t,i,o){if(null==e?void 0:e.includes("periodStartLabel")){const e=i||"2025-01-01";try{const t=new Date(e);return t.setDate(t.getDate()-1),t.toISOString().split("T")[0]}catch{return e}}return t||o||i||"2025-01-01"}_addColumnFromRequest(e,t,i){var o,r,n,s,a;const l=`col-${Date.now()}`;let d="",c="";"instant"===e.periodType?(d=e.instantDate||"",c=""):"duration"!==e.periodType&&"mixed"!==e.periodType||(d=this._formatPeriodDisplay(e.startDate,e.endDate),c="");let p={dimensionId:"period",memberValue:"instant"===e.periodType?`instant-${e.instantDate}`:`duration-${e.startDate}-${e.endDate}`,memberLabel:d};if(e.selectedDimensions&&e.selectedDimensions.length>0){const t=[],i=[];for(const o of e.selectedDimensions)o.isTyped&&o.typedValue?(t.push(`${o.axisLabel}: ${o.typedValue}`),i.push(`${o.axisId}|${o.typedValue}`)):o.memberId&&o.memberLabel&&(t.push(o.memberLabel),i.push(`${o.axisId}|${o.memberId}`));t.length>0&&(d=t.join(" | "),c="instant"===e.periodType?e.instantDate||"":this._formatPeriodDisplay(e.startDate,e.endDate),p={dimensionId:l,memberValue:t.join(" | "),memberLabel:t.join(" | "),memberKey:t.join(" | "),dimensionIdKey:i.join("::"),selectedDimensions:e.selectedDimensions},console.log(`πŸ“Š Applied selected dimensions to new column: ${p.memberKey}`))}else if(null==(r=null==(o=this.xbrlInput)?void 0:o.hypercubes)?void 0:r[0]){const i=this.xbrlInput.hypercubes[0].roles.find(e=>e.roleId===t);if(1===(null==(n=null==i?void 0:i.items)?void 0:n.length)){const t=i.items[0];if(1===t.dimensions.length){const i=t.dimensions[0];if(i.members&&i.members.length>0){const t=(null==(s=i.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:s.label)||i.conceptName,o=i.members[0],r=(null==(a=o.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:a.label)||o.conceptName;d=r,c="instant"===e.periodType?e.instantDate||"":this._formatPeriodDisplay(e.startDate,e.endDate),p={dimensionId:l,axisId:i.id,memberId:o.id,memberValue:r,memberLabel:r,axis:t,axisLabel:t,memberKey:`${t} | ${r}`,dimensionIdKey:`${i.id} | ${o.id}`},console.log(`πŸ“Š Applied hypercube dimension to new column: ${p.memberKey}`)}}}}const h={id:l,title:d,description:c,type:(p.memberKey,"dimension"),order:this._columns.length,removable:!0,dimensionData:p,periodStartDate:"instant"===e.periodType?e.instantDate:e.startDate,periodEndDate:"instant"===e.periodType?e.instantDate:e.endDate};if(e.selectedDimensions&&e.selectedDimensions.length>0){const t={};let i=!1;for(const o of e.selectedDimensions)o.isTyped&&(t[o.axisId]=o.typedValue||"",i=!0);i&&(this._typedMemberData[l]=t,h.dimensionData&&(h.dimensionData.hasTypedMembers=!0,h.dimensionData.typedMembers=e.selectedDimensions.filter(e=>e.isTyped).map(e=>({axisId:e.axisId,axisLabel:e.axisLabel,typedMemberId:e.axisId,memberLabel:e.axisLabel}))))}if(this._currentSchema){const e=this._currentSchema.sections.find(e=>e.id===t);if(e)if(e.columns||(e.columns=[...this._columns]),i){const t=e.columns.findIndex(e=>e.id===i);e.columns=-1!==t?[...e.columns.slice(0,t+1),h,...e.columns.slice(t+1)]:[...e.columns,h]}else e.columns=[...e.columns,h]}this._replicateFieldsForNewColumn(l,e,t),this._dirty=!0,this.requestUpdate(),this.dispatchEvent(new CustomEvent("column-add",{detail:{column:h},bubbles:!0}))}_removeColumnData(e,t){if(this._currentSchema)if(t){const i=this._currentSchema.sections.find(e=>e.id===t);i&&this._removeColumnDataFromConcepts(i.concepts,e)}else for(const i in this._formData)void 0!==this._formData[i][e]&&delete this._formData[i][e]}_removeColumnDataFromConcepts(e,t){e.forEach(e=>{this._formData[e.id]&&void 0!==this._formData[e.id][t]&&delete this._formData[e.id][t],e.fields&&(e.fields=e.fields.filter(e=>e.columnId!==t)),e.children&&this._removeColumnDataFromConcepts(e.children,t)})}_shouldCreateFieldForConcept(e,t){if(e.abstract)return!1;if(!(t.selectedDimensions&&t.selectedDimensions.length>0)&&e.periodType){if("instant"===t.periodType&&"instant"!==e.periodType)return!1;if("duration"===t.periodType&&"duration"!==e.periodType)return!1}return!0}_replicateFieldsForNewColumn(e,t,i){if(!this._currentSchema)return;const o=new F,r=this._currentSchema.sections.find(e=>e.id===i);r&&this._replicateFieldsForSection(r.concepts,e,t,o)}_replicateFieldsForSection(e,t,i,o){e.forEach(e=>{var r;if(this._shouldCreateFieldForConcept(e,i)){const o=null==(r=e.fields)?void 0:r[0];let n;const s="instant"===i.periodType?i.instantDate:i.startDate,a="instant"===i.periodType?i.instantDate:i.endDate,l=this._resolveInstantDate(e.preferredLabel,i.instantDate,s,a);n=o?{id:`${e.id}_${t}`,conceptId:e.id,columnId:t,type:o.type,label:o.label,placeholder:o.placeholder,required:o.required,disabled:o.disabled,validation:o.validation,defaultValue:o.defaultValue,periodType:e.periodType,conceptType:e.type,periodStartDate:s,periodEndDate:a,periodInstantDate:"instant"===e.periodType?l:void 0}:{id:`${e.id}_${t}`,conceptId:e.id,columnId:t,type:"text",label:e.label||e.name,placeholder:`Enter ${e.name}`,required:!1,disabled:!1,validation:[],defaultValue:"",periodType:e.periodType,conceptType:e.type,periodStartDate:s,periodEndDate:a,periodInstantDate:"instant"===e.periodType?l:void 0},e.fields||(e.fields=[]),e.fields.push(n)}e.children&&this._replicateFieldsForSection(e.children,t,i,o)})}_addColumn(){const e={id:`dim-${Date.now()}`,title:`Dimension ${this._columns.length}`,description:"Additional dimension column",type:"dimension",order:this._columns.length,removable:!0,dimensionData:{dimensionId:"custom",memberValue:"default",memberLabel:"Default Member"}};this._columns=[...this._columns,e],this.requestUpdate(),this.dispatchEvent(new CustomEvent("column-add",{detail:{column:e},bubbles:!0}))}_handleSubmit(){if(console.log("πŸ“ Form submission started..."),this._submitted=!0,this._submitDisabled=!0,"admin"===this.mode)return this._handleSaveDraft(),this._handleAdminModeSubmit(),void(this._submitDisabled=!1);if(console.log("πŸ”΅ [Submit] Checking for errors..."),console.log(`πŸ”΅ [Submit] _xbrlFormErrors.length: ${this._xbrlFormErrors.length}`),console.log("πŸ”΅ [Submit] _xbrlFormErrors:",this._xbrlFormErrors),this._xbrlFormErrors.length>0)return console.log("❌ [Submit] Cannot submit - validation errors present:",this._xbrlFormErrors),this._showErrorPopup=!0,this._submitDisabled=!1,void this.requestUpdate();if(console.log("βœ… [Submit] No validation errors, proceeding with submission..."),this._validateForm(),!this._valid)return console.log("❌ [Submit] Cannot submit - form validation errors present:",this._errors),this._showErrorPopup=!0,this._submitDisabled=!1,void this.requestUpdate();const e=this._generateSubmissionData();console.log("πŸ“Š Form Submission Data:",JSON.stringify(e,null,2)),console.log("πŸ“Š Submission Data Summary:"),e.forEach((e,t)=>{console.log(` [${t}] conceptId: ${e.conceptId}, columnId: ${e.columnId}, value: ${e.value}, unit: ${e.unit||"none"}`)}),this.dispatchEvent(new CustomEvent("form-submit",{detail:{data:this._formData,submissionData:e,valid:this._valid,errors:this._errors,reportingLanguage:this.reportingLanguage},bubbles:!0})),console.log("βœ… Form submit event dispatched"),setTimeout(()=>{this._submitDisabled=!1},1e3)}_handleSaveDraft(e="manual"){if(console.log("πŸ”΅ [Save Draft] Checking for errors..."),console.log(`πŸ”΅ [Save Draft] _xbrlFormErrors.length: ${this._xbrlFormErrors.length}`),console.log("πŸ”΅ [Save Draft] _xbrlFormErrors:",this._xbrlFormErrors),this._xbrlFormErrors.length>0)return console.log("❌ [Save Draft] Cannot save - validation errors present:",this._xbrlFormErrors),this._showErrorPopup=!0,void this.requestUpdate();console.log("βœ… [Save Draft] No validation errors, proceeding with save..."),console.log("πŸ’Ύ Raw form data before submission generation:",this._formData),console.log("🏷️ Unit data before submission generation:",this._unitData),console.log("πŸ“‹ Enhanced selectedRoleIds with roleURI and order:",this._selectedRoleIds);const t=this._generateSubmissionData();console.log("πŸ“€ Generated submission data:",t),console.log("πŸ“Š Submission data breakdown:"),t.forEach((e,t)=>{console.log(` [${t}] conceptId: ${e.conceptId}, columnId: ${e.columnId}, value: ${e.value}, unit: ${e.unit||"none"}`)});const i=this._roleCompletedStates.size>0?Object.fromEntries(this._roleCompletedStates):void 0,o=this._draftStorageService.createMetadataSnapshot(this.periodStartDate,this.periodEndDate,this.language,this._selectedRoleIds,this._allSections,this._typedMemberData,this._periodPreferences,this._periodData,this._unitData,this.reportingLanguage,this._repeatCounts,this._decimalsData,i),r=JSON.stringify({draftData:t,metadata:o});if(r===this._lastSavedDraftSnapshot)return void console.log(`ℹ️ [Save Draft] No draft content change detected (${e}); skipping event emit.`);this._lastSavedDraftSnapshot=r;const n=this._draftStorageService.saveDraft(t,o);console.log("πŸ’Ύ [Save Draft] Metadata saved with enhanced selectedRoleIds:",o.selectedRoleIds),this.dynaformsFacts=t,this.dynaformsMetadata=o,this.dispatchEvent(new CustomEvent("form-save-draft",{detail:{data:this._formData,draftData:t,metadata:o,saved:n,valid:this._valid,errors:this._errors,dynaformsFacts:t,dynaformsMetadata:o,reportingLanguage:this.reportingLanguage,source:"auto"==e?"auto":"manual"},bubbles:!0,composed:!0}));const s=this._getRoleIdsArray().length;console.log("πŸ’Ύ Draft saved - localStorage + event emitted",{entries:t.length,saved:n,roles:s,customColumns:o.customColumns.length,eventEmitted:!0,enhancedRoleStructure:Array.isArray(this._selectedRoleIds)&&this._selectedRoleIds.length>0&&"object"==typeof this._selectedRoleIds[0]})}async _loadDraftIfExists(){if(console.log("πŸ“‹ Checking for saved draft..."),this.dynaformsFacts&&this.dynaformsMetadata){console.log("πŸ“¦ Using external draft data from properties");const e={formData:this.dynaformsFacts,metadata:this.dynaformsMetadata};return await this._restoreFromDraft(e),this._draftLoaded=!0,this._draftLoadedAt=this.dynaformsMetadata.savedAt||(new Date).toISOString(),this.dispatchEvent(new CustomEvent("form-draft-loaded",{detail:{draft:e,source:"external",compatible:!0,warnings:[]},bubbles:!0,composed:!0})),void console.log("πŸ“₯ External draft loaded successfully")}if(!this._draftStorageService.hasDraft())return void console.log("ℹ️ No saved draft found");const e=this._draftStorageService.loadDraft();if(!e)return void console.warn("⚠️ Failed to load draft");const{compatible:t,warnings:i}=this._draftStorageService.validateDraftCompatibility(e,this.periodStartDate,this.periodEndDate);i.length>0&&console.warn("⚠️ Draft compatibility warnings:",i),await this._restoreFromDraft(e),this.dispatchEvent(new CustomEvent("form-draft-loaded",{detail:{draft:e,compatible:t,warnings:i},bubbles:!0,composed:!0})),console.log("πŸ“₯ Draft loaded successfully",{entries:e.formData.length,savedAt:e.metadata.savedAt,age:this._draftStorageService.getDraftAge()})}async _restoreFromDraft(e){var t;const{formData:i,metadata:o}=e;o.selectedRoleIds&&o.selectedRoleIds.length>0&&(this._selectedRoleIds=o.selectedRoleIds,console.log(`πŸ”„ Restored ${this._selectedRoleIds.length} selected roles`)),o.typedMemberData&&(this._typedMemberData=o.typedMemberData,this._preservedTypedMemberData={},console.log("πŸ”„ Restored typed member data")),o.repeatCounts&&(this._repeatCounts=o.repeatCounts,console.log("πŸ”„ Restored repeat counts:",this._repeatCounts)),o.periodData&&(this._periodData=o.periodData,console.log("πŸ”„ Restored custom field-level period data:",Object.keys(this._periodData).length,"concepts")),o.unitData&&(this._unitData=o.unitData,console.log("πŸ”„ Restored custom field-level unit data:",Object.keys(this._unitData).length,"concepts")),o.decimalsData&&(this._decimalsData=o.decimalsData,console.log("πŸ”„ Restored per-fact decimals data:",Object.keys(this._decimalsData).length,"concepts")),o.roleCompletedStates&&(this._roleCompletedStates=new Map(Object.entries(o.roleCompletedStates)),console.log("πŸ”„ Restored role completed states:",Object.keys(o.roleCompletedStates).length,"roles")),o.periodPreferences?this._skipPeriodPreferencesRestore?console.log("⏭️ Skipping period preferences restoration - using new filter selections"):(this._periodPreferences=o.periodPreferences,console.log("πŸ”„ Restored period preferences (including previous year settings):",this._periodPreferences),this.xbrlInput&&(console.log("πŸ”„ Rebuilding schema with restored period preferences..."),this._currentSchema=F.buildFormSchema(this.xbrlInput,this.periodStartDate,this.periodEndDate,this.language,this._periodPreferences),this._allSections=[...this._currentSchema.sections],console.log("βœ… Schema rebuilt with restored period preferences"),console.log("πŸ”„ Applying custom period data to schema fields..."),this._applyCustomPeriodDataToFields(),o.customColumns&&o.customColumns.length>0&&(this._mergeAdditionalCustomColumns(o.customColumns),console.log(`πŸ”„ Merged ${o.customColumns.length} additional custom columns`)))):o.customColumns&&o.customColumns.length>0&&(this._restoreCustomColumns(o.customColumns),console.log(`πŸ”„ Restored ${o.customColumns.length} custom columns`));const r={},n={},s={};i.forEach(e=>{let{conceptId:t,draftInstanceId:i,value:o,columnId:a,period:l,unit:d}=e;if(!a&&l&&(a=this._inferColumnIdFromPeriod(l,t),!a))return void console.warn(`⚠️ Could not infer columnId for concept ${t}, skipping...`);const c=i||t,p=c.includes("__repeat_")?c.split("__repeat_")[0]:c,h=this._findActualConceptId(p),u=c.includes("__repeat_")?`${h||p}__repeat_${c.split("__repeat_")[1]}`:h||c;r[u]||(r[u]={}),r[u][a]=o,console.log(`πŸ“¦ Restored: ${u}[${a}] = ${o}${c!==t?" (repeat instance)":""}`),l&&(n[u]||(n[u]={}),"instant"===l.type?(n[u][a]={instantDate:l.date},console.log(`πŸ“… [Restore Period] Extracted instant date for ${u}/${a}: ${l.date}`)):"duration"===l.type&&(n[u][a]={startDate:l.startDate,endDate:l.endDate},console.log(`πŸ“… [Restore Period] Extracted duration dates for ${u}/${a}: ${l.startDate} - ${l.endDate}`))),d&&(s[u]||(s[u]={}),s[u][a]=d,console.log(`🏷️ [Restore Unit] Extracted unit for ${u}/${a}: ${d}`))}),this._formData={...this._formData,...r},console.log(`πŸ”„ Restored ${Object.keys(r).length} concepts with data`),this._initializeGlobalDecimalsFromRoundingData(),this._periodData={...this._periodData,...o.periodData||{},...n},console.log(`πŸ“… [Period Restore] Merged period data: ${Object.keys(this._periodData).length} concepts with custom periods`),console.log("πŸ“… [Period Restore] Full _periodData after merge:",JSON.stringify(this._periodData,null,2)),this._unitData={...this._unitData,...o.unitData||{},...s},console.log(`🏷️ [Unit Restore] Merged unit data: ${Object.keys(this._unitData).length} concepts with custom units`),console.log("🏷️ [Unit Restore] Full _unitData after merge:",JSON.stringify(this._unitData,null,2)),this._selectedRoleIds.length>0&&this._applyRoleFilter(),this._dirty=!0,this._touched.clear(),this._validateForm(),this._allSections=[...this._allSections],this.requestUpdate(),await this.updateComplete,await new Promise(e=>setTimeout(e,100));const a=(null==(t=this.shadowRoot)?void 0:t.querySelectorAll("input, textarea, select").length)||0;console.log(`πŸ” Found ${a} fields in DOM after update`),a>0?this._populateFieldValues(r):console.error("❌ No fields found in DOM even after updateComplete"),console.log("βœ… Draft restoration completed")}_findActualConceptId(e){for(const t of this._allSections){const i=this._findActualConceptIdInTree(t.concepts,e);if(i)return i}return null}_findActualConceptIdInTree(e,t){for(const i of e){if(i.originalConceptId===t||i.id===t)return i.id;if(i.children){const e=this._findActualConceptIdInTree(i.children,t);if(e)return e}}return null}_inferColumnIdFromPeriod(e,t){for(const i of this._allSections){if(this._findConceptInSection(i.concepts,t)&&i.columns){for(const o of i.columns){const i="instant"===e.type,r="duration"===e.type;if(i&&e.date){if(o.periodStartDate===e.date||o.periodStartDate===o.periodEndDate&&o.periodStartDate===e.date)return console.log(`βœ“ Inferred columnId: ${o.id} for concept ${t}`),o.id}else if(r&&e.startDate&&e.endDate&&o.periodStartDate===e.startDate&&o.periodEndDate===e.endDate)return console.log(`βœ“ Inferred columnId: ${o.id} for concept ${t}`),o.id}if("instant"===e.type){const e=i.columns.find(e=>"instant"===e.id);if(e)return e.id}else{const e=i.columns.find(e=>"duration"===e.id);if(e)return e.id}}}return null}_findConceptInSection(e,t){for(const i of e){if(i.id===t||i.originalConceptId===t)return i;if(i.children){const e=this._findConceptInSection(i.children,t);if(e)return e}}return null}_populateFieldValues(e){let t=0,i=0;console.log("πŸ” Starting field population..."),console.log("πŸ“¦ Form data to populate:",e),Object.keys(e).forEach(o=>{const r=e[o];Object.keys(r).forEach(e=>{var n,s;const a=r[e],l=`${o}__${e}`;console.log(`πŸ” Looking for field: ${l}`);const d=null==(n=this.shadowRoot)?void 0:n.querySelector(`#${CSS.escape(l)}`);d?(d instanceof HTMLInputElement||d instanceof HTMLTextAreaElement||d instanceof HTMLSelectElement)&&("checkbox"===d.type?d.checked=Boolean(a):d.value=null!=a?String(a):"",console.log(` βœ… Populated field ${l} with value:`,a),t++):(console.warn(` ❌ Field element NOT FOUND: ${l}`),console.warn(" Available fields in DOM:",Array.from((null==(s=this.shadowRoot)?void 0:s.querySelectorAll("input, textarea, select"))||[]).map(e=>e.id).filter(e=>e.includes(o.split("__")[0]))),i++)})}),console.log(`βœ… Field population complete: ${t} populated, ${i} not found`)}_restoreCustomColumns(e){const t=new Map;e.forEach(e=>{t.has(e.sectionId)||t.set(e.sectionId,[]),t.get(e.sectionId).push(e)}),this._allSections.forEach(e=>{var i;const o=t.get(e.id);if(o){if(e.columns=o.map(e=>{const t={id:e.columnId,title:e.label,description:e.description,type:e.dimensionData?"dimension":"base",periodStartDate:e.startDate||e.date,periodEndDate:e.endDate||e.date,dimensionData:e.dimensionData,order:0,removable:"duration"!==e.columnId&&"instant"!==e.columnId,periodType:e.periodType};return console.log(`πŸ“… [Draft Restore] Restoring column ${e.columnId}: title=${t.title}, description=${t.description}, startDate=${t.periodStartDate}, endDate=${t.periodEndDate}, periodType=${t.periodType}`),t}),(null==(i=this.xbrlInput)?void 0:i.datatypes)&&!e.datatypes){const t=Array.isArray(this.xbrlInput.datatypes)?this.xbrlInput.datatypes:this.xbrlInput.datatypes.concepts||[];e.datatypes=t,console.log(`βœ… [Draft Restore] Attached ${t.length} datatypes to section ${e.id}`)}else e.datatypes?console.log(`ℹ️ [Draft Restore] Section ${e.id} already has ${e.datatypes.length} datatypes`):console.warn(`⚠️ [Draft Restore] No datatypes available for section ${e.id}`);this._regenerateFieldsForSection(e),console.log(` └─ Restored ${o.length} columns for section ${e.id}`)}}),this._currentSchema&&(this._currentSchema={...this._currentSchema,sections:this._allSections})}_mergeAdditionalCustomColumns(e){const t=new Map;e.forEach(e=>{e.columnId.startsWith("col-")&&(t.has(e.sectionId)||t.set(e.sectionId,[]),t.get(e.sectionId).push(e))}),this._allSections.forEach(e=>{var i;const o=t.get(e.id);if(o&&o.length>0){if(e.columns||(e.columns=[]),(null==(i=this.xbrlInput)?void 0:i.datatypes)&&!e.datatypes){const t=Array.isArray(this.xbrlInput.datatypes)?this.xbrlInput.datatypes:this.xbrlInput.datatypes.concepts||[];e.datatypes=t,console.log(`βœ… [Merge Custom] Attached ${t.length} datatypes to section ${e.id}`)}else e.datatypes?console.log(`ℹ️ [Merge Custom] Section ${e.id} already has ${e.datatypes.length} datatypes`):console.warn(`⚠️ [Merge Custom] No datatypes available for section ${e.id}`);o.forEach(t=>{console.log(`πŸ“… [Merge Custom Column] Column ${t.columnId}: col.startDate=${t.startDate}, col.endDate=${t.endDate}, col.date=${t.date}, col.periodType=${t.periodType}`);if(!e.columns.find(e=>e.id===t.columnId)){const i={id:t.columnId,title:t.label,description:t.description,type:t.dimensionData?"dimension":"base",periodStartDate:t.startDate||t.date,periodEndDate:t.endDate||t.date,dimensionData:t.dimensionData,order:e.columns.length,removable:!0,periodType:t.periodType};console.log(`πŸ“… [New Column Created] Column ${i.id}: title=${i.title}, description=${i.description}, periodStartDate=${i.periodStartDate}, periodEndDate=${i.periodEndDate}, periodType=${i.periodType}`),e.columns.push(i),console.log(` └─ Added custom column ${t.columnId} to section ${e.id}`)}}),this._regenerateFieldsForSection(e)}}),this._currentSchema&&(this._currentSchema={...this._currentSchema,sections:this._allSections})}_applyCustomPeriodDataToFields(){if(!this._periodData||0===Object.keys(this._periodData).length)return void console.log("ℹ️ No custom period data to apply");let e=0;const t=i=>{i.forEach(i=>{if(this._periodData[i.id]){const t=this._periodData[i.id];i.fields&&i.fields.forEach(o=>{const r=t[o.columnId];r&&(r.startDate&&(o.periodStartDate=r.startDate),r.endDate&&(o.periodEndDate=r.endDate),r.instantDate&&(o.periodInstantDate=r.instantDate),e++,console.log(`βœ… [Apply Period] Updated field ${i.id}/${o.columnId}: start=${o.periodStartDate}, end=${o.periodEndDate}, instant=${o.periodInstantDate}`))})}i.children&&i.children.length>0&&t(i.children)})};this._allSections.forEach(e=>{e.concepts&&e.concepts.length>0&&t(e.concepts)}),console.log(`πŸ“… [Apply Period] Applied custom period data to ${e} fields`)}_regenerateFieldsForSection(e){if(!e.columns)return;const t=this._periodPreferences[e.id]||{showDuration:!0,showInstant:!0,showPreviousYear:!1},i=o=>{o.forEach(o=>{o.fields=[];this._shouldShowConceptBasedOnPeriodPreferences(o,t)&&e.columns.forEach(t=>{var i;const r=o.periodType,n=this._inferColumnPeriodType(t);if(o.abstract)return;const s=t.id.startsWith("col-"),a=t.id.startsWith("duration_")||t.id.startsWith("instant_")||t.id.startsWith("typed-"),l=!0===e.showPeriodControl;if(!(!n||"duration"===t.id||"default"===t.id||s&&l||a)&&r&&n&&r!==n)return void console.log(`⏭️ [Field Regeneration] Skipping field for ${o.id} in column ${t.id}: conceptPeriodType=${r}, columnPeriodType=${n}`);const d={id:`${o.id}_${t.id}`,conceptId:o.id,columnId:t.id,type:this._mapConceptTypeToFieldType(o.type),label:o.label,periodType:r,conceptType:o.type,periodStartDate:t.periodStartDate,periodEndDate:t.periodEndDate,periodInstantDate:"instant"===r?t.periodEndDate||t.periodStartDate:void 0};if(null==(i=this._periodData[o.id])?void 0:i[t.id]){const e=this._periodData[o.id][t.id];e.startDate&&(d.periodStartDate=e.startDate),e.endDate&&(d.periodEndDate=e.endDate),e.instantDate&&(d.periodInstantDate=e.instantDate),console.log(`βœ… [Field Regeneration] Applied custom period data to ${o.id}/${t.id}:`,e),console.log(`βœ… [Field Regeneration] Field properties after apply: periodStartDate=${d.periodStartDate}, periodEndDate=${d.periodEndDate}, periodInstantDate=${d.periodInstantDate}`)}else console.log(`ℹ️ [Field Regeneration] No custom period data for ${o.id}/${t.id}. Checking _periodData:`,this._periodData[o.id]);(o.id.includes("DescriptionLocationNL")||t.id.startsWith("col-"))&&console.log(`πŸ“… [Field Regeneration] Concept ${o.id}, Column ${t.id}: field.periodStartDate=${d.periodStartDate}, field.periodEndDate=${d.periodEndDate}, column.periodStartDate=${t.periodStartDate}`),o.fields.push(d)}),o.children&&i(o.children)})};i(e.concepts)}_shouldShowConceptBasedOnPeriodPreferences(e,t){return!!e.abstract||(!e.periodType||!("duration"===e.periodType&&!t.showDuration)&&!("instant"===e.periodType&&!t.showInstant))}_inferColumnPeriodType(e){return e.periodType?e.periodType:e.periodStartDate&&e.periodEndDate?e.periodStartDate===e.periodEndDate?"instant":"duration":e.periodStartDate&&!e.periodEndDate?"instant":void 0}_mapConceptTypeToFieldType(e){return e?e.includes("monetary")||e.includes("Monetary")?"number":e.includes("date")||e.includes("Date")?"date":e.includes("boolean")||e.includes("Boolean")?"boolean":e.includes("integer")||e.includes("Integer")||e.includes("decimal")||e.includes("Decimal")?"number":"text":"text"}_generateSubmissionData(){const e=[];if(!this._currentSchema)return e;this._currentSchema.sections.forEach(t=>{this._processConceptsForSubmission(t.concepts,e,t)}),this._includePreservedDataInSubmission(e);return this._removeDuplicateSubmissions(e)}_includePreservedDataInSubmission(e){Object.keys(this._preservedFormData).forEach(t=>{const i=this._preservedFormData[t];i&&Object.keys(i).forEach(o=>{const r=i[o];if(null!=r&&""!==r){const i=this._findConceptInAllSections(t);if(i){const n=this._findSectionForConcept(t);this._addConceptDataToSubmission(i,o,r,e,n||void 0)}}})}),console.log(`πŸ“€ Included preserved data in submission. Total entries: ${e.length}`)}_findConceptInAllSections(e){for(const t of this._allSections){const i=this._findConceptInSection(t.concepts,e);if(i)return i}return null}_findSectionForConcept(e){for(const t of this._allSections){if(this._findConceptInSection(t.concepts,e))return t}return null}_addConceptDataToSubmission(e,t,i,o,r){var n,s,a,l,d;const c=e.fields.find(e=>e.columnId===t);if(!c)return;const p="instant"===e.periodType,h=null==(n=this._periodData[e.id])?void 0:n[t],u=null==(s=this._unitData[e.id])?void 0:s[t],m=this._findColumnByIdInAllSections(t);console.log(`πŸ” [Submission] Concept: ${e.id}, Column: ${t}, Field Period: ${h?JSON.stringify(h):"none"}, Unit: ${u||"none"}, Column Period: ${(null==m?void 0:m.periodStartDate)||"none"} - ${(null==m?void 0:m.periodEndDate)||"none"}`);const f=(null==h?void 0:h.startDate)||(null==m?void 0:m.periodStartDate)||c.periodStartDate||this.periodStartDate,b=(null==h?void 0:h.endDate)||(null==m?void 0:m.periodEndDate)||c.periodEndDate||this.periodEndDate,g=(null==h?void 0:h.instantDate)||c.periodInstantDate||b||f,v={conceptId:e.originalConceptId||e.id,columnId:t,value:i,period:{type:e.periodType||"duration",...p?{date:g}:{startDate:f,endDate:b}}};u&&(v.unit=u,console.log(`βœ… [Submission] Adding unit to entry: ${u} for ${e.id}/${t}`));const y=null==(a=e.type)?void 0:a.toLowerCase().includes("monetary"),x=(null==(l=this._decimalsData[e.id])?void 0:l[t])||("INF"!==this.decimals?this.decimals:void 0);if(y&&x){const e=parseFloat(x);v.decimals=isNaN(e)?x:String(-Math.abs(e))}(null==(d=null==m?void 0:m.dimensionData)?void 0:d.memberLabel)&&(v.dimension=m.dimensionData.memberLabel),console.log("πŸ“€ [Submission Entry] Created entry:",JSON.stringify(v,null,2)),o.push(v)}_findColumnByIdInAllSections(e){for(const t of this._allSections)if(t.columns){const i=t.columns.find(t=>t.id===e);if(i)return i}}_removeDuplicateSubmissions(e){const t=new Map;return e.forEach(e=>{const i="instant"===e.period.type?e.period.date:`${e.period.startDate}_${e.period.endDate}`,o=`${e.conceptId}_${e.value}_${e.dimension||"no-dimension"}_${i}`;t.has(o)||t.set(o,e)}),Array.from(t.values())}_findColumnById(e){if(this._currentSchema)for(const t of this._currentSchema.sections)if(t.columns){const i=t.columns.find(t=>t.id===e);if(i)return i}}_findColumnByIdInSection(e,t){if(null==t?void 0:t.columns)return t.columns.find(t=>t.id===e)}_getTypedMemberNameForAxis(e,t){var i,o,r,n;if(!(null==(o=null==(i=this.xbrlInput)?void 0:i.hypercubes)?void 0:o[0]))return null;const s=null==t?void 0:t.id;if(!s)return null;const a=null==(r=this.xbrlInput.hypercubes[0].roles)?void 0:r.find(e=>e.roleId===s);if(!(null==a?void 0:a.items))return null;for(const l of a.items)if(l.dimensions){const t=l.dimensions.find(t=>t.id===e);if(null==(n=null==t?void 0:t.typedMember)?void 0:n.id)return t.typedMember.id}return null}_doesConceptApplyToTypedDimension(e,t,i){var o,r,n;if(!(null==(r=null==(o=this.xbrlInput)?void 0:o.hypercubes)?void 0:r[0]))return!1;const s=null==t?void 0:t.id;if(!s)return!1;const a=this.xbrlInput.hypercubes[0].roles.find(e=>e.roleId===s);if(!(null==(n=null==a?void 0:a.items)?void 0:n.length))return!1;for(const l of a.items){const t=e.originalConceptId||e.id;if(l.conceptIds&&l.conceptIds.includes(t)){const e=l.dimensions.some(e=>e.typedMember);return console.log(`πŸ” [DynamicForm] Concept ${t} found in hypercube item. Has typed dimensions:`,e),e}}return console.log(`πŸ” [DynamicForm] Concept ${e.originalConceptId||e.id} not found in any hypercube items for role ${s}`),!1}_getApplicableTypedDimensions(e,t){var i,o,r;if(!(null==(o=null==(i=this.xbrlInput)?void 0:i.hypercubes)?void 0:o[0])||!(null==t?void 0:t.id))return[];const n=this.xbrlInput.hypercubes[0].roles.find(e=>e.roleId===t.id);if(!(null==(r=null==n?void 0:n.items)?void 0:r.length))return[];const s=e.originalConceptId||e.id;for(const a of n.items)if(a.conceptIds&&a.conceptIds.includes(s)){const e=a.dimensions.filter(e=>e.typedMember).map(e=>e.id);return console.log(`πŸ” [DynamicForm] Found applicable typed dimensions for concept ${s}:`,e),e}return[]}_processConceptsForSubmission(e,t,i){const o="Toelichting op de geconsolideerde jaarrekening - FinanciΓ«le vaste activa: Deelnemingen: Volledig geconsolideerd: Specificatie",r=(null==i?void 0:i.title)||"Unknown";e.forEach(e=>{if(r===o&&(console.warn(`[DUPLICATE DEBUG] Processing concept ${e.originalConceptId||e.id} in target role`),e.fields&&(console.warn(`[DUPLICATE DEBUG] Concept has ${e.fields.length} fields`),e.fields.forEach((t,i)=>{var o;console.warn(`[DUPLICATE DEBUG] Field ${i}: columnId=${t.columnId}, current value=${null==(o=this._formData[e.id])?void 0:o[t.columnId]}`)}))),e.fields&&e.fields.length>1&&e.fields.forEach((e,t)=>{}),e.fields&&e.fields.length>0){e.fields.forEach(n=>{var s,a,l,d,c,p,h,u;const m=this._formData[e.id];let f=null==m?void 0:m[n.columnId];const b=n.conceptId||e.id.split("__").slice(0,-1).join("__")||e.id;if((null==f||""===f)&&this._isRoundingLevelConcept(b)&&!this._hasValidGlobalDecimals()){const t=this._findFactValueForField(e,n,i);null!=t&&""!==t&&(f=t)}if((null==f||""===f)&&this._effectiveMasterData){const e=null==(s=this._effectiveMasterData)?void 0:s[b];null!=e&&""!==e&&(f=e,console.warn(` πŸ“¦ [Submission] Using masterData for: ${b} [${n.columnId}] = ${JSON.stringify(f)}`))}if(null!=f&&""!==f){const s=this._findColumnByIdInSection(n.columnId,i),m=null==(a=this._periodData[e.id])?void 0:a[n.columnId],b={conceptId:e.id,draftInstanceId:e.id,columnId:n.columnId,value:f,period:{type:e.periodType||"duration"}};if("instant"===e.periodType){const e=(null==m?void 0:m.instantDate)||(null==m?void 0:m.endDate)||(null==s?void 0:s.periodEndDate)||n.periodInstantDate||n.periodEndDate||n.periodStartDate||this.periodStartDate;b.period.date=e}else{const e=(null==m?void 0:m.startDate)||(null==s?void 0:s.periodStartDate)||n.periodStartDate||this.periodStartDate,t=(null==m?void 0:m.endDate)||(null==s?void 0:s.periodEndDate)||n.periodEndDate||this.periodEndDate;b.period.startDate=e,b.period.endDate=t}console.log(`πŸ” [Submission] Concept: ${e.id}, Column: ${n.columnId}, Field Period: ${m?JSON.stringify(m):"none"}, Column Period: ${(null==s?void 0:s.periodStartDate)||"none"} - ${(null==s?void 0:s.periodEndDate)||"none"}, Used Period: ${"instant"===b.period.type?b.period.date:`${b.period.startDate} - ${b.period.endDate}`}`);const g=null==(l=this._unitData[e.id])?void 0:l[n.columnId];g?(b.unit=g,console.log(`βœ… [Submission] Adding unit to entry: ${g} for ${e.id}/${n.columnId}`)):console.log(`⚠️ [Submission] No unit found in _unitData for ${e.id}/${n.columnId}. _unitData state:`,JSON.stringify(this._unitData,null,2));const v=null==(d=e.type)?void 0:d.toLowerCase().includes("monetary"),y=(null==(c=this._decimalsData[e.id])?void 0:c[n.columnId])||("INF"!==this.decimals?this.decimals:void 0);if(v&&y){const e=parseFloat(y);b.decimals=isNaN(e)?y:String(-Math.abs(e))}if("dimension"===(null==s?void 0:s.type)&&(null==(p=s.dimensionData)?void 0:p.dimensionIdKey)?(b.dimension=s.dimensionData.dimensionIdKey,console.log(`πŸ” [DynamicForm] Using dimension key from field's column (${n.columnId}):`,s.dimensionData.dimensionIdKey)):console.log(`πŸ” [DynamicForm] No dimension data found for field column ${n.columnId}. Column type: ${null==s?void 0:s.type}, has dimensionData: ${!!(null==s?void 0:s.dimensionData)}`),this._typedMemberData[n.columnId]){const t=this._getApplicableTypedDimensions(e,i);if(console.log(`πŸ” [DynamicForm] Concept ${e.id} applicable typed dimensions:`,t),t.length>0){const e={},o=this._typedMemberData[n.columnId];t.forEach(t=>{if(o[t]){const r=this._getTypedMemberNameForAxis(t,i);e[t]={value:o[t],memberName:r||"Unknown"}}}),Object.keys(e).length>0?(b.typedMembers=e,console.log("πŸ” [DynamicForm] Adding filtered typed members to submission:",e)):console.log("πŸ” [DynamicForm] No typed member values found for applicable dimensions:",t)}else console.log(`πŸ” [DynamicForm] Skipping typed members for concept ${e.id} - not applicable to this hypercube`)}else console.log(`πŸ” [DynamicForm] No typed member data found for column ${n.columnId}. Available columns:`,Object.keys(this._typedMemberData)),s&&console.log("πŸ” [DynamicForm] Column details:",{id:s.id,type:s.type,hasTypedMembers:null==(h=s.dimensionData)?void 0:h.hasTypedMembers,dimensionData:s.dimensionData});if(!b.typedMembers&&(null==(u=n.crossRoleTypedMembers)?void 0:u.length)){const t=`${e.id}__${n.columnId}`,i=this._typedMemberData[t];if(i){const t={};n.crossRoleTypedMembers.forEach(e=>{const o=i[e.axisId];null!=o&&""!==o&&(t[e.axisId]={value:o,memberName:e.typedMemberId})}),Object.keys(t).length>0&&(b.typedMembers=t,console.log(`πŸ” [Submission] Adding cross-role typed members for ${e.id}/${n.columnId}:`,t))}}r===o&&console.warn("[DUPLICATE DEBUG] Final submission entry:",b),t.push(b)}});const n=this._repeatCounts[e.id]||0;if(n>0&&e.fields.some(e=>{var t;return null==(t=e.crossRoleTypedMembers)?void 0:t.length}))for(let o=1;o<=n;o++){const r=`${e.id}__repeat_${o}`;e.fields.forEach(o=>{var n,s,a,l,d;const c=null==(n=this._formData[r])?void 0:n[o.columnId];if(null==c||""===c)return;const p=this._findColumnByIdInSection(o.columnId,i),h=null==(s=this._periodData[r])?void 0:s[o.columnId],u={conceptId:e.id,draftInstanceId:r,columnId:o.columnId,value:c,period:{type:e.periodType||"duration"}};"instant"===e.periodType?u.period.date=(null==h?void 0:h.instantDate)||(null==h?void 0:h.endDate)||(null==p?void 0:p.periodEndDate)||o.periodInstantDate||o.periodEndDate||o.periodStartDate||this.periodStartDate:(u.period.startDate=(null==h?void 0:h.startDate)||(null==p?void 0:p.periodStartDate)||o.periodStartDate||this.periodStartDate,u.period.endDate=(null==h?void 0:h.endDate)||(null==p?void 0:p.periodEndDate)||o.periodEndDate||this.periodEndDate);const m=null==(a=this._unitData[r])?void 0:a[o.columnId];if(m&&(u.unit=m),"dimension"===(null==p?void 0:p.type)&&(null==(l=p.dimensionData)?void 0:l.dimensionIdKey)&&(u.dimension=p.dimensionData.dimensionIdKey),null==(d=o.crossRoleTypedMembers)?void 0:d.length){const e=`${r}__${o.columnId}`,t=this._typedMemberData[e];if(t){const e={};o.crossRoleTypedMembers.forEach(i=>{const o=t[i.axisId];null!=o&&""!==o&&(e[i.axisId]={value:o,memberName:i.typedMemberId})}),Object.keys(e).length>0&&(u.typedMembers=e)}}t.push(u)})}}e.children&&this._processConceptsForSubmission(e.children,t,i)})}_handleReset(){this._formData={...this.initialData},this._touched.clear(),this._dirty=!1,this._submitted=!1,this._preservedFormData={},this._preservedTypedMemberData={},console.log("πŸ”„ Form reset - all data and preserved data cleared"),this._validateForm(),this.requestUpdate(),this.dispatchEvent(new CustomEvent("form-reset",{detail:{},bubbles:!0}))}_getFormState(){return{data:this._formData,errors:this._errors,touched:this._touched,dirty:this._dirty,valid:this._valid,submitted:this._submitted}}_analyzeAllVisibleRoles(){if(this._currentSchema&&this._currentSchema.sections&&0!==this._currentSchema.sections.length){console.log(`πŸ” Analyzing ${this._currentSchema.sections.length} visible roles for initial border status...`);for(const e of this._currentSchema.sections)this._analyzeAndLogRole(e.id);console.log("βœ… Initial border status analysis complete for all visible roles")}else console.log("⏭️ No sections to analyze for initial border status")}_handleRoleContextMenu(e,t,i){e.preventDefault(),e.stopPropagation(),this._contextMenuX=e.clientX,this._contextMenuY=e.clientY,this._contextMenuRoleId=t,this._showRoleContextMenu=!0,console.log(`πŸ–±οΈ Context menu opened for role: ${i} (ID: ${t})`),this.requestUpdate()}_closeRoleContextMenu(){this._showRoleContextMenu=!1,this._contextMenuRoleId=null,this.requestUpdate()}_handleRemoveRole(){if(!this._contextMenuRoleId)return void this._closeRoleContextMenu();const e=this._allSections.find(e=>e.id===this._contextMenuRoleId),t=(null==e?void 0:e.title)||"Unknown";if(console.log("πŸ—‘οΈ Removing role from side panel:"),console.log(` - Role ID: ${this._contextMenuRoleId}`),console.log(` - Role Title: ${t}`),Array.isArray(this._selectedRoleIds)&&(this._selectedRoleIds.length>0&&"object"==typeof this._selectedRoleIds[0]?this._selectedRoleIds=this._selectedRoleIds.filter(e=>e.roleId!==this._contextMenuRoleId):this._selectedRoleIds=this._selectedRoleIds.filter(e=>e!==this._contextMenuRoleId)),console.log(`βœ… Role removed from _selectedRoleIds. Remaining roles: ${this._selectedRoleIds.length}`),this._activeSidePanelRoleId===this._contextMenuRoleId){const e=this._getRoleIdsArray();this._activeSidePanelRoleId=e.length>0?e[0]:null,console.log(`πŸ“Œ Active role changed to: ${this._activeSidePanelRoleId||"None"}`)}this._applyRoleFilter(),this.dispatchEvent(new CustomEvent("role-removed",{detail:{roleId:this._contextMenuRoleId,roleTitle:t,remainingRolesCount:this._selectedRoleIds.length},bubbles:!0,composed:!0})),console.log(`βœ… Role "${t}" successfully removed from side panel`),console.log("ℹ️ User can re-add this role using the Filter Roles dialog"),this._closeRoleContextMenu()}_handleRoleCompletedChange(e,t){t?this._roleCompletedStates.set(e,!0):this._roleCompletedStates.delete(e),this._roleCompletedStates=new Map(this._roleCompletedStates),this._handleSaveDraft("auto")}_handleSidePanelRoleClick(e){this._activeSidePanelRoleId&&this._activeSidePanelRoleId!==e&&this._analyzeAndLogRole(this._activeSidePanelRoleId),this._activeSidePanelRoleId=e}_analyzeAndLogRole(e){const t=this._allSections.find(t=>t.id===e);if(!t)return void console.warn(`⚠️ Section not found for roleId: ${e}`);console.warn("\n========================================"),console.warn(`πŸ” ANALYZING ROLE: "${t.title}"`),console.warn("========================================"),this.masterData?console.warn("πŸ“¦ masterData keys:",Object.keys(this.masterData)):console.warn("πŸ“¦ masterData: NOT PROVIDED");const i=[];this._collectAllFields(t.concepts||[],new Set((t.columns||[]).map(e=>e.id)),t.columns||[],i);const o=this._roleHasErrors(e),r=i.filter(e=>e.isEmpty).length,n=i.filter(e=>!e.isEmpty).length;let s;console.warn("\nπŸ“ˆ SUMMARY:"),console.warn(` Total Fields: ${i.length}`),console.warn(` Filled: ${n}`),console.warn(` Empty: ${r}`),console.warn(` Has Errors: ${o}`),o?(s="INVALID",console.warn("\nπŸ”΄ RESULT: INVALID (contains validation errors)")):0===n?(s="UNTOUCHED",console.warn("\n⬜ RESULT: UNTOUCHED (no data entered)")):r>0?(s="INCOMPLETE",console.warn(`\n🟠 RESULT: INCOMPLETE (${r} field(s) blank)`)):(s="COMPLETE",console.warn("\n🟒 RESULT: COMPLETE (all fields filled)")),console.warn("========================================\n"),"INVALID"===s||("UNTOUCHED"===s?(this._roleBorderStatuses.set(e,"untouched"),this._roleBorderStatuses=new Map(this._roleBorderStatuses)):"INCOMPLETE"===s?(this._roleBorderStatuses.set(e,"incomplete"),this._roleBorderStatuses=new Map(this._roleBorderStatuses)):(this._roleBorderStatuses.set(e,"complete"),this._roleBorderStatuses=new Map(this._roleBorderStatuses)))}_collectAllFields(e,t,i,o){var r,n,s;for(const a of e)if(a.abstract)a.children&&a.children.length>0&&this._collectAllFields(a.children,t,i,o);else{if(a.fields&&a.fields.length>0){const e=a.fields.filter(e=>t.has(e.columnId));for(const t of e){const e=a.id,l=t.conceptId;let d=null==(r=this._formData[e])?void 0:r[t.columnId];void 0===d&&e!==l&&(d=null==(n=this._formData[l])?void 0:n[t.columnId]);const c=null==(s=this._effectiveMasterData)?void 0:s[l];(null==d||"string"==typeof d&&""===d.trim())&&void 0!==c&&(d=c,console.warn(` πŸ“¦ Using masterData value for: ${l} [${t.columnId}] = ${JSON.stringify(d)}`));let p=null==d||"string"==typeof d&&""===d.trim();if(p&&a.facts&&a.facts.length>0){const e=i.find(e=>e.id===t.columnId),o={conceptId:l,columnId:t.columnId,periodStartDate:t.periodStartDate||(null==e?void 0:e.periodStartDate),periodEndDate:t.periodEndDate||(null==e?void 0:e.periodEndDate),periodInstantDate:t.periodInstantDate||("instant"===t.periodType?t.periodEndDate||t.periodStartDate:void 0),periodType:t.periodType,dimensionData:null==e?void 0:e.dimensionData},r=E.findMatchingFact(a.facts,o);r&&null!==r.value&&void 0!==r.value&&""!==r.value&&(d=r.value,p=!1)}o.push({conceptId:l,columnId:t.columnId,value:d,isEmpty:p})}}a.children&&a.children.length>0&&this._collectAllFields(a.children,t,i,o)}}_handleSidePanelSearchInput(e){const t=e.target;this._sidePanelSearchQuery=t.value}_clearSidePanelSearch(){var e;this._sidePanelSearchQuery="";const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".side-panel-search-input");t&&(t.value="",t.focus())}_toggleSidePanelCollapse(){this._sidePanelCollapsed=!this._sidePanelCollapsed}_isSectionBlank(e){const t=e.columns||this._columns,i=e=>{var o;for(const r of e){if(!r.abstract)for(const e of t){const t=null==(o=this._formData[r.id])?void 0:o[e.id];if(null!=t&&""!==t)return!0}if(r.children&&r.children.length>0&&i(r.children))return!0}return!1};return!i(e.concepts)}_getConceptSearchMatchIds(e){var t,i,o;const r=new Set;if(!e.trim()||!(null==(i=null==(t=this.xbrlInput)?void 0:t.presentation)?void 0:i.length))return r;const n=e.toLowerCase().trim(),s=e=>{var t,i,o;for(const a of e){let e=(null==(t=a.conceptName)?void 0:t.toLowerCase().includes(n))||(null==(i=a.id)?void 0:i.toLowerCase().includes(n));!e&&Array.isArray(a.labels)&&(e=a.labels.some(e=>{var t;return null==(t=e.label)?void 0:t.toLowerCase().includes(n)})),e&&r.add(a.id),(null==(o=a.children)?void 0:o.length)&&s(a.children)}};for(const a of this.xbrlInput.presentation)for(const e of a.roles||[])s((null==(o=e.presentationLinkbase)?void 0:o.concepts)||[]);return r}_isSectionConceptSearchMatch(e,t){if(0===t.size)return!1;const i=e=>{var o;for(const r of e){if(t.has(r.originalConceptId))return!0;if((null==(o=r.children)?void 0:o.length)&&i(r.children))return!0}return!1};return i(e.concepts)}_filterSidePanelSections(e){if(!this._sidePanelSearchQuery.trim())return e;const t=this._sidePanelSearchQuery.toLowerCase().trim();return e.filter(e=>{var i,o,r;const n=e.title.toLowerCase().includes(t),s=e.id.toLowerCase().includes(t),a=(null==(i=e.description)?void 0:i.toLowerCase().includes(t))||!1,l=(null==(r=null==(o=e.metadata)?void 0:o.roleURI)?void 0:r.toLowerCase().includes(t))||!1;return n||s||a||l})}_renderAdminModeContent(t){var i,o;if(!t)return e.html`
2898
+ `,ne([S({type:Boolean,reflect:!0})],exports.JupiterFilterRolesDialog.prototype,"open",2),ne([S({type:Array})],exports.JupiterFilterRolesDialog.prototype,"availableRoles",2),ne([S({type:Array})],exports.JupiterFilterRolesDialog.prototype,"selectedRoleIds",2),ne([S({type:Object})],exports.JupiterFilterRolesDialog.prototype,"periodPreferences",2),ne([S({type:String})],exports.JupiterFilterRolesDialog.prototype,"mode",2),ne([S({type:Object})],exports.JupiterFilterRolesDialog.prototype,"hypercubeData",2),ne([S({type:Boolean})],exports.JupiterFilterRolesDialog.prototype,"showFactsOnly",2),ne([S({type:String})],exports.JupiterFilterRolesDialog.prototype,"conceptSearchText",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_tempSelectedRoles",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_searchQuery",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_filteredRoles",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_tempPeriodPreferences",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_selectedAvailableRole",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_selectedChosenRole",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_chosenSearchQuery",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_draggedRoleId",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_dragOverRoleId",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_chosenRoleOrder",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_showAdvancedFilter",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_showFactsOnly",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_conceptSearchText",2),exports.JupiterFilterRolesDialog=ne([t("jupiter-filter-roles-dialog")],exports.JupiterFilterRolesDialog);var se=Object.defineProperty,ae=Object.getOwnPropertyDescriptor,le=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?ae(t,i):t,s=e.length-1;s>=0;s--)(r=e[s])&&(n=(o?r(t,i,n):r(n))||n);return o&&n&&se(t,i,n),n};exports.JupiterDynamicForm=class extends e.LitElement{constructor(){super(...arguments),this.config={},this.initialData={},this.disabled=!1,this.readonly=!1,this.periodStartDate="2025-01-01",this.periodEndDate="2025-12-31",this.language="en",this.reportingLanguage="en",this.display="accordion",this.mode="inputForm",this.roleFilterAxes=[],this.showLastValidationResultBtn=!1,this.isDraftSaving=!1,this.defaultUnits=[],this.decimals="INF",this._formData={},this._draftLoaded=!1,this._preservedFormData={},this._periodData={},this._preservedPeriodData={},this._unitData={},this._preservedUnitData={},this._decimalsData={},this._effectiveMasterData=void 0,this._typedMemberData={},this._preservedTypedMemberData={},this._repeatCounts={},this._columns=[],this._errors=[],this._touched=new Set,this._dirty=!1,this._valid=!0,this._submitted=!1,this._xbrlFormErrors=[],this._showErrorPopup=!1,this._submitDisabled=!1,this._allSections=[],this._selectedRoleIds=[],this._showFilterDialog=!1,this._showFactsOnly=!1,this._conceptSearchText="",this._periodPreferences={},this._activeSidePanelRoleId=null,this._sidePanelSearchQuery="",this._sidePanelCollapsed=!1,this._adminRoleConfigs={},this._roleBorderStatuses=new Map,this._roleCompletedStates=new Map,this._showRoleContextMenu=!1,this._contextMenuX=0,this._contextMenuY=0,this._contextMenuRoleId=null,this._validationStatus="idle",this._skipDraftLoading=!1,this._skipPeriodPreferencesRestore=!1,this._autoSaveTimer=null,this._lastAutoSaveSnapshot="",this._lastSavedDraftSnapshot=""}connectedCallback(){super.connectedCallback(),this.addEventListener("period-change",e=>{console.log("🌍 [GLOBAL DynamicForm] Caught period-change event on element:",e);const t=e;console.log("🌍 [GLOBAL DynamicForm] Event detail:",t.detail),this._handlePeriodChange(t)}),this.addEventListener("unit-change",e=>{console.log("🏷️ [GLOBAL DynamicForm] Caught unit-change event on element:",e);const t=e;console.log("🏷️ [GLOBAL DynamicForm] Event detail:",t.detail),this._handleUnitChange(t)}),this.addEventListener("decimals-change",e=>{this._handleDecimalsChange(e)}),this.addEventListener("field-blur",e=>{console.log("🚨 [DynamicForm] field-blur event listener triggered!",e);const t=e;this._handleFieldBlur(t)}),document.addEventListener("click",()=>{this._showRoleContextMenu&&(this._showRoleContextMenu=!1,this.requestUpdate())}),this._autoSaveTimer=setInterval(()=>{const e=JSON.stringify(this._formData);if(""===this._lastAutoSaveSnapshot)return this._lastAutoSaveSnapshot=e,void console.log("ℹ️ [Auto Save] Baseline initialized; no draft save emitted.");e!==this._lastAutoSaveSnapshot?(this._lastAutoSaveSnapshot=e,this._handleSaveDraft("auto")):console.log("ℹ️ [Auto Save] No form state change detected; skipping draft save emit.")},3e4),this._initializeForm()}disconnectedCallback(){super.disconnectedCallback(),null!==this._autoSaveTimer&&(clearInterval(this._autoSaveTimer),this._autoSaveTimer=null)}updated(e){(e.has("decimals")||e.has("masterData"))&&this._computeEffectiveMasterData(),e.has("language")&&R.setLanguage(this.language),(e.has("xbrlInput")||e.has("defaultUnits"))&&this.xbrlInput&&this.defaultUnits&&this.defaultUnits.length>0&&this._applyDefaultUnitsToDatatypes(),(e.has("xbrlInput")||e.has("schema")||e.has("language")||e.has("periodStartDate")||e.has("periodEndDate")||e.has("roleFilterAxes"))&&this._initializeForm()}_applyDefaultUnitsToDatatypes(){var e;if(!(null==(e=this.xbrlInput)?void 0:e.datatypes)||!this.defaultUnits||0===this.defaultUnits.length)return;console.log("πŸ”§ [DynamicForm] Applying defaultUnits to datatypes:",this.defaultUnits);const t=Array.isArray(this.xbrlInput.datatypes)?this.xbrlInput.datatypes:this.xbrlInput.datatypes.concepts;t&&0!==t.length?this.defaultUnits.forEach(e=>{Object.entries(e).forEach(([e,i])=>{const o=t.find(t=>t.type===e||t.id===e);if(o&&o.units&&o.units.length>0){const t=o.units.find(e=>e.id===i);t?(o.units.forEach(e=>e.isDefault=!1),t.isDefault=!0,console.log(`βœ… [DynamicForm] Set isDefault=true for unit "${i}" in datatype "${e}"`)):console.warn(`⚠️ [DynamicForm] Unit "${i}" not found in datatype "${e}"`)}else console.warn(`⚠️ [DynamicForm] Datatype "${e}" not found or has no units`)})}):console.warn("⚠️ [DynamicForm] No datatypes found to apply defaults to")}_initializeForm(){var e;if(this._draftStorageService||(this._draftStorageService=new k(!1)),this.xbrlInput)try{if(console.log("πŸ”„ Initializing form from XBRL input:",this.xbrlInput),console.log("πŸ“… Using period dates:",this.periodStartDate,"to",this.periodEndDate),console.log("🌐 Using language:",this.language),this._initializePeriodPreferencesFromData(),this._applyAxisFilterToPeriodPreferences(),this._applyDimensionShowPreviousYear(),console.log("βš™οΈ Using period preferences:",this._periodPreferences),this._currentSchema=F.buildFormSchema(this.xbrlInput,this.periodStartDate,this.periodEndDate,this.language,this._periodPreferences),console.log("βœ… Generated schema with sections:",this._currentSchema.sections.length),this._allSections=[...this._currentSchema.sections],Array.isArray(this._selectedRoleIds)&&this._selectedRoleIds.length>0&&"object"==typeof this._selectedRoleIds[0]){console.log("πŸ”„ Applying custom role order to _allSections from _selectedRoleIds");const e=this._selectedRoleIds,t=new Map;e.forEach(e=>{t.set(e.roleId,e.order)}),this._allSections=[...this._allSections].sort((e,i)=>(t.get(e.id)??999)-(t.get(i.id)??999)),console.log("βœ… Custom order applied to _allSections:",this._allSections.map(e=>e.title))}if(0===this._selectedRoleIds.length){const e=this.roleFilterAxes&&this.roleFilterAxes.length>0?this._filterRolesByAxisConfig(this._allSections):this._allSections;this._selectedRoleIds=e.map(e=>e.id),console.log(`βœ… Auto-selected ${this._selectedRoleIds.length} roles (of ${this._allSections.length} total)`)}this._applyRoleFilter(),this._columns=[{id:"base",title:"Value",description:"Base values for concepts",type:"base",order:0,removable:!1}]}catch(t){console.error("❌ Error building form from XBRL input:",t),this._currentSchema=this._getDefaultSchema(),this._allSections=[],this._selectedRoleIds=[],this._columns=this._getDefaultColumns()}else this.schema?(this._currentSchema=this.schema,this._allSections=[...this.schema.sections],this._selectedRoleIds=this._allSections.map(e=>e.id),this._columns=this._getDefaultColumns()):(this._currentSchema=this._getDefaultSchema(),this._allSections=[],this._selectedRoleIds=[],this._columns=this._getDefaultColumns());this._formData={...this.initialData},(null==(e=this.xbrlInput)?void 0:e.initialData)&&(this._formData={...this._formData,...this.xbrlInput.initialData}),this._initializeGlobalDecimalsFromRoundingData(),this._extractTypedMembersFromFacts(),this._skipDraftLoading?(console.log("⏭️ Skipping draft loading during preference update"),this._analyzeAllVisibleRoles()):this._loadDraftIfExists().then(()=>{this._analyzeAllVisibleRoles()}).catch(()=>{this._analyzeAllVisibleRoles()}),this._validateForm()}_extractTypedMembersFromFacts(){var e;(null==(e=this._currentSchema)?void 0:e.sections)&&(this._currentSchema.sections.forEach(e=>{this._extractTypedMembersFromConcepts(e.concepts||[],e)}),console.log("βœ… [DynamicForm] Typed member data populated:",this._typedMemberData))}_extractTypedMembersFromConcepts(e,t){e.forEach(e=>{e.facts&&e.facts.length>0&&(console.log(`πŸ” [DynamicForm] Checking concept ${e.id} with ${e.facts.length} facts`),e.facts.forEach(i=>{if(i.dimensions&&Array.isArray(i.dimensions)){const o=i.dimensions.filter(e=>"typed"===e.dimensionType&&e.typedMemberValue);if(o.length>0){console.log(`πŸ“ [DynamicForm] Found ${o.length} typed dimensions in fact:`,{factName:i.name,typedDimensions:o.map(e=>({dimension:e.dimension,typedMemberValue:e.typedMemberValue}))});const r=this._findColumnWithTypedMembers(i,e,t);r?(console.log(`βœ… [DynamicForm] Found matching column: ${r.id}`),o.forEach(i=>{var o,n;const s=this._normalizeAxisId(i.dimension),a=null==(n=null==(o=r.dimensionData)?void 0:o.typedMembers)?void 0:n.find(e=>e.axisId===s||this._normalizeAxisId(e.axisId)===s);if(a){this._typedMemberData[r.id]||(this._typedMemberData[r.id]={});const o=a.axisId;this._typedMemberData[r.id][o]=i.typedMemberValue,console.log("βœ… [DynamicForm] Set typed member value:",{sectionId:t.id,conceptId:e.id,columnId:r.id,axisKey:o,typedMemberValue:i.typedMemberValue})}else console.warn(`⚠️ [DynamicForm] Typed member not found for axis: ${s}`)})):console.warn("⚠️ [DynamicForm] No matching column found for fact with typed dimensions")}}})),e.children&&e.children.length>0&&this._extractTypedMembersFromConcepts(e.children,t)})}_findColumnWithTypedMembers(e,t,i){var o;if(!t.fields||0===t.fields.length)return null;const r=i.columns||[];if(0===r.length)return null;for(const n of t.fields){const t=r.find(e=>e.id===n.columnId);if(t&&(null==(o=t.dimensionData)?void 0:o.hasTypedMembers)){const i=(e.dimensions||[]).filter(e=>"explicit"===e.dimensionType),o=t.dimensionData.combinations||[];if(0===i.length||i.length===o.length&&i.every(e=>o.some(t=>this._normalizeAxisId(e.dimension)===this._normalizeAxisId(t.axisId)&&this._normalizeMemberId(e.member)===this._normalizeMemberId(t.memberId))))return t}}return null}_findColumnForFactDimensions(e,t,i){if(!t.fields||0===t.fields.length)return console.log(`⚠️ [DynamicForm] No fields for concept: ${t.id}`),null;const o=i.columns||[];if(0===o.length)return console.log(`⚠️ [DynamicForm] No columns in section: ${i.id}`),null;for(const r of t.fields){const t=o.find(e=>e.id===r.columnId);if(t&&t.dimensionData){const i=e.dimensions||[],o=t.dimensionData.combinations||[];console.log(`πŸ” [DynamicForm] Checking column ${t.id}:`,{factDimensions:i.map(e=>({axis:e.dimension,member:e.member,type:e.dimensionType})),columnDimensions:o.map(e=>({axis:e.axisId,member:e.memberId}))});if(o.every(e=>i.some(t=>{const i=this._normalizeAxisId(t.dimension)===this._normalizeAxisId(e.axisId);if("explicit"===t.dimensionType){const o=this._normalizeMemberId(t.member)===this._normalizeMemberId(e.memberId);return i&&o}return"typed"===t.dimensionType&&i})))return t}}return null}_normalizeAxisId(e){return e?e.includes(":")?e.split(":").pop()||e:e.includes("_")&&e.split("_").pop()||e:""}_normalizeMemberId(e){return e?e.includes(":")?e.split(":").pop()||e:e.includes("_")&&e.split("_").pop()||e:""}_getDefaultSchema(){return{version:"1.0",formId:"default-form",title:"Dynamic Form",description:"Please provide form schema or XBRL input data",sections:[]}}_getDefaultColumns(){return[{id:"base",title:"Value",description:"Base values for concepts",type:"base",order:0,removable:!1}]}_initializePeriodPreferencesFromData(){var e,t,i;if(!(null==(i=null==(t=null==(e=this.xbrlInput)?void 0:e.presentation)?void 0:t[0])?void 0:i.roles))return;const o={...this._periodPreferences};this.xbrlInput.presentation[0].roles.forEach(e=>{if(!o[e.id]){const t=!0===e.showPreviousYear,i=void 0===e.instant||!0===e.instant,r=void 0===e.duration||!0===e.duration;o[e.id]={showDuration:r,showInstant:i,showPreviousYear:t}}}),this._periodPreferences=o}_applyAxisFilterToPeriodPreferences(){var e,t,i,o;if(!this.roleFilterAxes||0===this.roleFilterAxes.length)return;if(!(null==(i=null==(t=null==(e=this.xbrlInput)?void 0:e.hypercubes)?void 0:t[0])?void 0:i.roles))return;const r=this.xbrlInput.hypercubes[0].roles,n={...this._periodPreferences};for(const s of r){const e=s.roleId,t=n[e];if((null==t?void 0:t.dimensionSelections)&&t.dimensionSelections.length>0)continue;const i=[];for(const r of this.roleFilterAxes)for(const e of s.items||[]){if(null==(o=e.dimensions)?void 0:o.find(e=>e.id===r.id||r.conceptName&&e.conceptName===r.conceptName)){i.push({dimensionId:r.id,dimensionLabel:r.conceptName||r.id,selectedMemberIds:r.members.filter(e=>!0===e.available).map(e=>e.id)});break}}i.length>0&&(n[e]={showDuration:(null==t?void 0:t.showDuration)??!0,showInstant:(null==t?void 0:t.showInstant)??!0,showPreviousYear:(null==t?void 0:t.showPreviousYear)??!1,dimensionSelections:i})}this._periodPreferences=n}_applyDimensionShowPreviousYear(){var e,t;if("admin"!==this.mode)return;const i=!(!this.dynaformsFacts||!this.dynaformsMetadata),o=(null==(e=this._draftStorageService)?void 0:e.hasDraft())??!1;if(i||o)return;const r={...this._periodPreferences};let n=!1;for(const s of Object.keys(r)){const e=r[s];if(e.showPreviousYear)continue;((null==(t=e.dimensionSelections)?void 0:t.some(e=>e.selectedMemberIds&&e.selectedMemberIds.length>0))??!1)&&(r[s]={...e,showPreviousYear:!0},n=!0,console.log(`πŸ“… [JDF-010] Auto-enabled showPreviousYear for role "${s}" (has dimension members)`))}n&&(this._periodPreferences=r)}_getRoleIdsArray(){return Array.isArray(this._selectedRoleIds)&&0!==this._selectedRoleIds.length?"string"==typeof this._selectedRoleIds[0]?this._selectedRoleIds:this._selectedRoleIds.map(e=>e.roleId):[]}_applyRoleFilter(){if(!this._currentSchema||!this._allSections.length)return;const e=this._getRoleIdsArray();if(console.log(`πŸ” Applying role filter: ${e.length} selected out of ${this._allSections.length} total`),0===e.length)return console.log("πŸ“ No roles selected - showing empty form"),this._currentSchema={...this._currentSchema,sections:[]},void this.requestUpdate();this._preserveDataForHiddenSections();const t=this._allSections.filter(t=>e.includes(t.id)),i=this._sortSectionsByCustomOrder(t);console.log(`πŸ“Š Filtered sections: ${i.length}`),console.log("πŸ“‹ Custom order applied:",i.map(e=>e.title)),this._restoreDataForVisibleSections(i),this._currentSchema={...this._currentSchema,sections:i},console.log(`βœ… Schema updated with custom order. Current sections count: ${this._currentSchema.sections.length}`),this.requestUpdate()}_sortSectionsByCustomOrder(e){if(Array.isArray(this._selectedRoleIds)&&this._selectedRoleIds.length>0&&"object"==typeof this._selectedRoleIds[0]){const t=this._selectedRoleIds,i=new Map;return t.forEach(e=>{i.set(e.roleId,e.order)}),[...e].sort((e,t)=>(i.get(e.id)??999)-(i.get(t.id)??999))}return e}_filterRolesByAxisConfig(e){var t;if(!this.roleFilterAxes||0===this.roleFilterAxes.length)return e;if(!(null==(t=this.xbrlInput)?void 0:t.hypercubes)||0===this.xbrlInput.hypercubes.length)return e;const i=this.xbrlInput.hypercubes[0];return e.filter(e=>{var t;const o=null==(t=i.roles)?void 0:t.find(t=>t.roleId===e.id);if(!o||!o.items||0===o.items.length)return!0;for(const i of this.roleFilterAxes){const e=new Set(i.members.filter(e=>!0===e.available).map(e=>e.id));let t=!1,r=!1;for(const n of o.items){if(!n.dimensions||0===n.dimensions.length)continue;const o=n.dimensions.find(e=>e.id===i.id||i.conceptName&&e.conceptName===i.conceptName);if(o){if(t=!0,o.members)for(const t of o.members)if(e.has(t.id)){r=!0;break}if(r)break}}if(t&&!r)return!1}return!0})}_preserveDataForHiddenSections(){var e;const t=(null==(e=this._currentSchema)?void 0:e.sections.map(e=>e.id))||[],i=this._getRoleIdsArray();t.filter(e=>!i.includes(e)).forEach(e=>{const t=this._allSections.find(t=>t.id===e);t&&this._preserveSectionData(t)})}_restoreDataForVisibleSections(e){e.forEach(e=>{this._restoreSectionData(e)}),console.log(`πŸ”„ Restored data for ${e.length} visible sections`)}_preserveSectionData(e){e.concepts.forEach(e=>{this._preserveConceptData(e)})}_preserveConceptData(e){this._formData[e.id]&&(this._preservedFormData[e.id]={...this._formData[e.id]}),e.fields.forEach(t=>{this._typedMemberData[t.columnId]&&(this._preservedTypedMemberData[t.columnId]={...this._typedMemberData[t.columnId]});const i=`${e.id}__${t.columnId}`;this._typedMemberData[i]&&(this._preservedTypedMemberData[i]={...this._typedMemberData[i]})}),e.children&&e.children.forEach(e=>{this._preserveConceptData(e)})}_restoreSectionData(e){e.concepts.forEach(e=>{this._restoreConceptData(e)})}_restoreConceptData(e){this._preservedFormData[e.id]&&(this._formData[e.id]={...this._preservedFormData[e.id]}),e.fields.forEach(t=>{this._preservedTypedMemberData[t.columnId]&&(this._typedMemberData[t.columnId]={...this._preservedTypedMemberData[t.columnId]});const i=`${e.id}__${t.columnId}`;this._preservedTypedMemberData[i]&&(this._typedMemberData[i]={...this._preservedTypedMemberData[i]})}),e.children&&e.children.forEach(e=>{this._restoreConceptData(e)})}_shouldShowFilterButton(){return!0}_handleFilterRolesClick(){this._showFilterDialog=!0}_handleAdvancedFilterApply(e){this._showFactsOnly=e.detail.showFactsOnly,this._conceptSearchText=e.detail.conceptSearchText??"",this._showFilterDialog=!1}_handleFilterDialogCancel(){this._showFilterDialog=!1;const e=this._getRoleIdsArray().length;console.log(`🚫 Filter dialog cancelled. Current selection: ${e}/${this._allSections.length}`)}_handleRoleFilterApply(e){var t,i;const{selectedRoleIds:o,periodPreferences:r}=e.detail;console.log("🎯 Filter apply triggered"),console.log("πŸ“Š Old _selectedRoleIds:",this._selectedRoleIds),console.log("πŸ“Š New selectedRoleIds from dialog:",o),this._selectedRoleIds=o,this._periodPreferences=r,console.log("πŸ“Š Updated _selectedRoleIds:",this._selectedRoleIds),console.log("πŸ“Š New period preferences (including dimension selections):",this._periodPreferences),console.log("πŸ’Ύ Capturing current form data before reinitialization...");const n=this._generateSubmissionData(),s=this._draftStorageService.createMetadataSnapshot(this.periodStartDate,this.periodEndDate,this.language,this._selectedRoleIds,this._allSections,this._typedMemberData,this._periodPreferences,this._periodData,this._unitData,this.reportingLanguage,this._repeatCounts,this._decimalsData);this._draftStorageService.saveDraft(n,s),console.log("βœ… Current form data saved to draft storage with NEW preferences"),this.dynaformsFacts=n,this.dynaformsMetadata=s,this._skipPeriodPreferencesRestore=!0,this._skipDraftLoading=!0,console.log("πŸ”„ Reinitializing form with new filter settings..."),this._initializeForm(),this._skipDraftLoading=!1,this._skipPeriodPreferencesRestore=!1,console.log("πŸ“Š After _initializeForm, _currentSchema.sections.length:",null==(t=this._currentSchema)?void 0:t.sections.length),console.log("πŸ“Š Section IDs:",null==(i=this._currentSchema)?void 0:i.sections.map(e=>e.id)),console.log("πŸ“₯ Restoring form data from draft after reinitialization..."),this._loadDraftIfExists().then(()=>{console.log("βœ… Form data restored successfully after reinitialization")}).catch(e=>{console.error("❌ Error restoring form data after reinitialization:",e)}),this._showFilterDialog=!1;const a=Array.isArray(this._selectedRoleIds)&&this._selectedRoleIds.length>0?(this._selectedRoleIds[0],this._selectedRoleIds.length):0;console.log(`🎯 Applied role filter: ${a}/${this._allSections.length} roles selected`),console.log("πŸ“‹ Enhanced selectedRoleIds structure:",this._selectedRoleIds),this.dispatchEvent(new CustomEvent("roles-filter-changed",{detail:{selectedRoleIds:o,totalRoles:this._allSections.length,visibleRoles:a,periodPreferences:r},bubbles:!0}))}_haveDimensionSelectionsChanged(e){var t;const i=new Set([...Object.keys(this._periodPreferences||{}),...Object.keys(e||{})]);for(const o of i){const i=null==(t=this._periodPreferences)?void 0:t[o],r=null==e?void 0:e[o],n=(null==i?void 0:i.dimensionSelections)||[],s=(null==r?void 0:r.dimensionSelections)||[];if(JSON.stringify(n.sort((e,t)=>e.dimensionId.localeCompare(t.dimensionId)))!==JSON.stringify(s.sort((e,t)=>e.dimensionId.localeCompare(t.dimensionId))))return console.log(`πŸ” Dimension selection changed for role: ${o}`),console.log(" Old:",n),console.log(" New:",s),!0}return!1}_validateForm(){var e;const t=[],i=this._currentSchema;if(i){for(const o of i.sections)for(const i of o.concepts)for(const o of i.fields){const r=null==(e=this._formData[i.id])?void 0:e[o.columnId],n=C.validateField(o.id,i.id,o.columnId,r,o.type,o.validation||[]);t.push(...n)}this._errors=t,this._valid=0===t.filter(e=>"error"===e.severity).length}}_handleFieldChange(e){const{fieldId:t,conceptId:i,columnId:o,value:r}=e.detail;console.log(`πŸ“ Field change: conceptId=${i}, columnId=${o}, value=${r}, fieldId=${t}`);const n={...this._formData};n[i]||(n[i]={});const s=n[i][o];n[i]={...n[i],[o]:r},this._formData=n,console.log(`πŸ’Ύ Updated formData[${i}]:`,this._formData[i]),this._touched.add(`${i}-${o}`),this._dirty=!0,this._validateForm(),this.requestUpdate(),this.dispatchEvent(new CustomEvent("field-change",{detail:{fieldId:t,conceptId:i,columnId:o,value:r,oldValue:s},bubbles:!0}))}_handlePeriodChange(e){console.log("🎯 [DynamicForm] _handlePeriodChange called with event:",e),console.log("🎯 [DynamicForm] Event detail:",e.detail);const{conceptId:t,columnId:i,periodType:o,periodStartDate:r,periodEndDate:n,periodInstantDate:s,unit:a}=e.detail;console.log(`πŸ“… Period change received: conceptId=${t}, columnId=${i}, periodType=${o}, startDate=${r}, endDate=${n}, instantDate=${s}, unit=${a}`);const l={...this._periodData};l[t]||(l[t]={}),l[t]={...l[t],[i]:{startDate:r,endDate:n,instantDate:s}},this._periodData=l,console.log(`πŸ’Ύ Period data stored for [${t}][${i}]:`,this._periodData[t][i]),console.log("πŸ“¦ Full period data state:",JSON.stringify(this._periodData,null,2)),a&&this._storeUnit(t,i,a),this._dirty=!0,this.requestUpdate()}_handleUnitChange(e){console.log("🏷️ [DynamicForm] _handleUnitChange called with event:",e),console.log("🏷️ [DynamicForm] Event detail:",e.detail);const{conceptId:t,columnId:i,unit:o}=e.detail;console.log(`🏷️ Unit change received: conceptId=${t}, columnId=${i}, unit=${o}`),this._storeUnit(t,i,o),this._dirty=!0,this.requestUpdate()}_storeUnit(e,t,i){console.log(`πŸ”§ [_storeUnit] Called with conceptId=${e}, columnId=${t}, unit=${i}`),console.log("πŸ”§ [_storeUnit] Current _unitData before update:",JSON.stringify(this._unitData,null,2));const o={...this._unitData};o[e]||(console.log(`πŸ”§ [_storeUnit] Creating new entry for conceptId: ${e}`),o[e]={}),o[e]={...o[e],[t]:i},this._unitData=o,console.log(`πŸ’Ύ [_storeUnit] Unit data stored for [${e}][${t}]:`,this._unitData[e][t]),console.log("πŸ“¦ [_storeUnit] Full unit data state after update:",JSON.stringify(this._unitData,null,2))}_handleDecimalsChange(e){const{conceptId:t,columnId:i,decimals:o}=e.detail;t&&i&&(this._storeDecimals(t,i,o),this._dirty=!0,this.requestUpdate())}_computeEffectiveMasterData(){const e="rj-i_DocumentIntendedRoundingLevel";if("INF"!==this.decimals){const t=parseFloat(this.decimals);if(!isNaN(t))return void(this._effectiveMasterData={...this.masterData||{},[e]:String(-t)})}this._effectiveMasterData=this.masterData?{...this.masterData}:void 0}_initializeGlobalDecimalsFromRoundingData(){if(this._hasValidGlobalDecimals())return;const e=this._findRoundingLevelFactValue(this._allSections)??this._findRoundingLevelValueInFormData(this._formData);if(null==e||""===e)return;const t=parseFloat(String(e));isNaN(t)||(this.decimals=String(Math.abs(t)))}_findRoundingLevelValueInFormData(e){if(e)for(const t of Object.keys(e)){if(!this._isRoundingLevelConcept(t))continue;const i=e[t]||{};for(const e of Object.keys(i)){const t=i[e];if(null!=t&&""!==t)return t}}}_findRoundingLevelFactValue(e){for(const t of e){const e=this._findRoundingLevelFactValueInConcepts(t.concepts||[]);if(null!=e&&""!==e)return e}}_findRoundingLevelFactValueInConcepts(e){for(const t of e){const e=t.originalConceptId||t.id;if(this._isRoundingLevelConcept(e)){const e=t.facts||[];for(const t of e)if(void 0!==(null==t?void 0:t.value)&&null!==(null==t?void 0:t.value)&&""!==(null==t?void 0:t.value))return t.value}if(t.children&&t.children.length>0){const e=this._findRoundingLevelFactValueInConcepts(t.children);if(null!=e&&""!==e)return e}}}_hasValidGlobalDecimals(){if(void 0===this.decimals||null===this.decimals)return!1;if("INF"===this.decimals)return!1;const e=parseFloat(this.decimals);return!isNaN(e)}_isRoundingLevelConcept(e){return!!e&&("rj-i_DocumentIntendedRoundingLevel"===e||e.includes("DocumentIntendedRoundingLevel"))}_findFactValueForField(e,t,i){var o,r;if(!e.facts||0===e.facts.length)return;const n=this._findColumnByIdInSection(t.columnId,i),s=null==(o=this._periodData[e.id])?void 0:o[t.columnId],a=(null==s?void 0:s.startDate)||(null==n?void 0:n.periodStartDate)||t.periodStartDate||this.periodStartDate,l=(null==s?void 0:s.endDate)||(null==n?void 0:n.periodEndDate)||t.periodEndDate||this.periodEndDate,d=(null==s?void 0:s.instantDate)||t.periodInstantDate||l||a,c=null==(r=this._unitData[e.id])?void 0:r[t.columnId],p={conceptId:e.originalConceptId||t.conceptId||e.id,columnId:t.columnId,periodStartDate:a,periodEndDate:l,periodInstantDate:d,periodType:t.periodType,unit:c,dimensionData:null==n?void 0:n.dimensionData},h=E.findMatchingFact(e.facts,p);return null==h?void 0:h.value}_storeDecimals(e,t,i){const o={...this._decimalsData};o[e]||(o[e]={}),o[e]={...o[e],[t]:i??""},this._decimalsData=o}_generateUniqueConceptKey(e,t){return`${e}::${t}`}_extractOriginalConceptId(e){const t=e.split("::");return t.length>1?t[1]:e}_handleAddConceptRepeat(e){const{conceptId:t}=e.detail;this._repeatCounts={...this._repeatCounts,[t]:(this._repeatCounts[t]||0)+1},this._dirty=!0}_handleRemoveConceptRepeat(e){const{conceptId:t}=e.detail,i=t.match(/^(.+)__repeat_(\d+)$/),o=i?i[1]:t,r=i?parseInt(i[2]):this._repeatCounts[t]||0,n=this._repeatCounts[o]||0;if(n<=0||r<1||r>n)return;const s={...this._formData},a={...this._typedMemberData},l={...this._unitData},d={...this._periodData};for(let h=r;h<n;h++){const e=`${o}__repeat_${h+1}`,t=`${o}__repeat_${h}`;void 0!==s[e]?s[t]=s[e]:delete s[t];const i=`${t}__`,r=`${e}__`,n=Object.keys(a).filter(e=>e.startsWith(r));Object.keys(a).filter(e=>e.startsWith(i)).forEach(e=>delete a[e]),n.forEach(e=>{a[`${t}__${e.slice(r.length)}`]=a[e]}),n.forEach(e=>delete a[e]),void 0!==l[e]?l[t]=l[e]:delete l[t],void 0!==d[e]?d[t]=d[e]:delete d[t]}const c=`${o}__repeat_${n}`;delete s[c],delete l[c],delete d[c];const p=`${c}__`;Object.keys(a).filter(e=>e.startsWith(p)).forEach(e=>delete a[e]),this._formData=s,this._typedMemberData=a,this._unitData=l,this._periodData=d,this._repeatCounts={...this._repeatCounts,[o]:n-1},this._dirty=!0}_handleTypedMemberChange(e){const{columnId:t,axisId:i,value:o,conceptId:r}=e.detail,n=r?`${r}__${t}`:t;console.log(`πŸ” [DynamicForm] Typed member change: storageKey=${n}, axisId=${i}, value=${o}`);const s={...this._typedMemberData};s[n]||(s[n]={}),s[n]={...s[n],[i]:o},this._typedMemberData=s,this._dirty=!0,this.requestUpdate(),this.dispatchEvent(new CustomEvent("typed-member-change",{detail:{columnId:t,axisId:i,value:o},bubbles:!0}))}_handleFieldBlur(e){var t;console.log("🟧 [DynamicForm] _handleFieldBlur received event:",e),console.log("🟧 [DynamicForm] Event detail:",e.detail);const{fieldId:i,conceptId:o,columnId:r,xbrlValidationErrors:n}=e.detail;console.log(`🟧 [DynamicForm] Extracted - fieldId: ${i}, conceptId: ${o}, columnId: ${r}`),console.log("🟧 [DynamicForm] xbrlValidationErrors:",n);let s="";const a=e.composedPath();console.log(`🟧 [DynamicForm] Event path length: ${a.length}`);for(const l of a){const e=l;if("JUPITER-FORM-SECTION"===e.tagName){s=e.getAttribute("section-id")||"",console.log(`🟧 [DynamicForm] Found section element with id: ${s}`);break}}if(console.log(`🟧 [DynamicForm] Found sectionId: ${s}`),console.log(`🟧 [DynamicForm] Processing errors - has errors: ${n&&n.length>0}`),n&&n.length>0){console.log(`🟧 [DynamicForm] Adding/updating error for fieldId: ${i}, sectionId: ${s}`);const e=(null==(t=this._formData[o])?void 0:t[r])||"",a=this._xbrlFormErrors.findIndex(e=>e.fieldId===i&&e.sectionId===s),l={sectionId:s,fieldId:i,conceptId:o,columnId:r,value:e,errors:n};console.log("🟧 [DynamicForm] New error object:",l),console.log(`🟧 [DynamicForm] Existing index: ${a}`),a>=0?(this._xbrlFormErrors=[...this._xbrlFormErrors.slice(0,a),l,...this._xbrlFormErrors.slice(a+1)],console.log(`🟧 [DynamicForm] Updated existing error at index ${a}`)):(this._xbrlFormErrors=[...this._xbrlFormErrors,l],console.log("🟧 [DynamicForm] Added new error"))}else{console.log(`🟧 [DynamicForm] Removing error (if exists) for fieldId: ${i}, sectionId: ${s}`);const e=this._xbrlFormErrors.length;this._xbrlFormErrors=this._xbrlFormErrors.filter(e=>!(e.fieldId===i&&e.sectionId===s)),console.log(`🟧 [DynamicForm] Removed ${e-this._xbrlFormErrors.length} errors`)}console.log(`πŸ” [Validation] Total errors: ${this._xbrlFormErrors.length}`,this._xbrlFormErrors)}_getSectionTitle(e){console.log(`πŸ” [_getSectionTitle] Looking for sectionId: "${e}"`),console.log("πŸ” [_getSectionTitle] Available sections:",this._allSections.map(e=>({id:e.id,title:e.title})));const t=this._allSections.find(t=>t.id===e),i=(null==t?void 0:t.title)||e||"(Unknown Section)";return console.log(`πŸ” [_getSectionTitle] Result: "${i}"`),i}_roleHasErrors(e){return this._xbrlFormErrors.some(t=>t.sectionId===e)}async _handleErrorFieldClick(e,t,i){var o,r,n,s;console.log(`🎯 [Error Click] Attempting to focus field: ${e}__${t} in section: ${i}`),this._showErrorPopup=!1,this.requestUpdate(),await this.updateComplete,"sidePanel"===this.display&&this._activeSidePanelRoleId!==i&&(console.log(`πŸ”€ Switching to section: ${i} (currently on: ${this._activeSidePanelRoleId})`),this._activeSidePanelRoleId=i,this.requestUpdate(),await this.updateComplete,await new Promise(e=>setTimeout(e,500)));const a=null==(o=this.shadowRoot)?void 0:o.querySelectorAll("jupiter-form-section");let l=null;if(null==a||a.forEach(e=>{var t;(null==(t=e.section)?void 0:t.id)===i&&(l=e)}),!l)return void console.warn(`⚠️ Section not found: ${i}`);if(console.log("βœ… Found section element:",l),(null==(r=l.section)?void 0:r.collapsed)?(console.log("πŸ“‚ Expanding collapsed section"),l.section.collapsed=!1,l.requestUpdate(),await l.updateComplete,await new Promise(e=>setTimeout(e,500))):(await l.updateComplete,await new Promise(e=>setTimeout(e,100))),console.log(`πŸ” Section shadow DOM exists: ${!!l.shadowRoot}`),l.shadowRoot){console.log(`πŸ” Shadow DOM innerHTML length: ${(null==(n=l.shadowRoot.innerHTML)?void 0:n.length)||0}`);const e=l.shadowRoot.querySelectorAll("*");console.log(`πŸ” Total elements in shadow DOM: ${e.length}`);const t=Array.from(e).filter(e=>{const t=e;return!(!t.tagName||!t.tagName.includes("-"))});console.log("πŸ” Custom elements found:",t.map(e=>e.tagName).join(", "))}const d=`${e}_${t}_field`;console.log(`πŸ” Looking for input with fieldId: ${d}`),console.log(`πŸ” Looking for field with conceptId: ${e} AND columnId: ${t}`);const c=null==(s=l.shadowRoot)?void 0:s.querySelectorAll("jupiter-concept-tree");let p=null;if(console.log(`πŸ” Found ${(null==c?void 0:c.length)||0} concept-tree elements`),c&&c.forEach((i,o)=>{var r;if(p)return;const n=null==(r=i.shadowRoot)?void 0:r.querySelectorAll("jupiter-form-field");console.log(`πŸ” Concept tree ${o}: Found ${(null==n?void 0:n.length)||0} form-field elements`),null==n||n.forEach((i,o)=>{var r;if(!p&&(console.log(` Field ${o}: conceptId=${i.conceptId}, columnId=${i.columnId}`),i.conceptId===e&&i.columnId===t)){const e=null==(r=i.shadowRoot)?void 0:r.querySelector("input, textarea");console.log(` -> Matched! Input element found: ${!!e}`),e&&(p=e,console.log("βœ… Found input element in form-field"))}})}),!p)return void console.warn(`⚠️ Input field not found for: ${d}`);const h=p;l.scrollIntoView({behavior:"smooth",block:"start"}),await new Promise(e=>setTimeout(e,300)),h.focus(),"INPUT"!==h.tagName&&"TEXTAREA"!==h.tagName||h.select(),h.style.boxShadow="0 0 0 3px rgba(220, 38, 38, 0.5)",setTimeout(()=>{h.style.boxShadow=""},2e3),console.log(`βœ… Successfully focused field: ${e}__${t}`)}_handleSectionExpand(e){this.dispatchEvent(new CustomEvent("section-expand",{detail:e.detail,bubbles:!0}))}_handleConceptExpand(e){this.dispatchEvent(new CustomEvent("concept-expand",{detail:e.detail,bubbles:!0}))}_handleColumnRemove(e){const{columnId:t,sectionId:i}=e.detail;if(this._currentSchema&&i){const e=this._currentSchema.sections.find(e=>e.id===i);e&&e.columns&&(e.columns=e.columns.filter(e=>e.id!==t))}else this._columns=this._columns.filter(e=>e.id!==t),this._currentSchema&&this._currentSchema.sections.forEach(e=>{e.columns&&(e.columns=e.columns.filter(e=>e.id!==t))});this._removeColumnData(t,i),this._dirty=!0,this._validateForm(),this.requestUpdate(),this.dispatchEvent(new CustomEvent("column-remove",{detail:{columnId:t,sectionId:i},bubbles:!0}))}_handleColumnAddRequest(e){const{sectionId:t,columnRequest:i,insertAfterColumnId:o}=e.detail;this._addColumnFromRequest(i,t,o)}_getAvailableDimensionsForSection(e){var t,i,o;if(!(null==(i=null==(t=this.xbrlInput)?void 0:t.hypercubes)?void 0:i[0]))return[];const r=this.xbrlInput.hypercubes[0].roles.find(t=>t.roleId===e);if(!(null==(o=null==r?void 0:r.items)?void 0:o.length))return console.log(`❌ No hypercube items found for role: ${e}`),[];const n=[],s=this.language||"en",a=(e,t)=>{var i;return(null==(i=(null==e?void 0:e.find(e=>e.lang===s&&"http://www.xbrl.org/2003/role/label"===e.role))||(null==e?void 0:e.find(e=>"en"===e.lang&&"http://www.xbrl.org/2003/role/label"===e.role))||(null==e?void 0:e.find(e=>"http://www.xbrl.org/2003/role/label"===e.role)))?void 0:i.label)||t};return r.items.forEach(e=>{e.dimensions&&e.dimensions.length>0&&e.dimensions.forEach(e=>{if(!n.find(t=>t.id===e.id)){const t=a(e.labels,e.conceptName),i={id:e.id,conceptName:e.conceptName,axisLabel:t};e.members&&e.members.length>0&&(i.members=e.members.map(e=>({id:e.id,label:a(e.labels,e.conceptName||e.id)}))),e.typedMember&&(i.typedMember={id:e.typedMember.id,dataType:"string"}),n.push(i)}})}),n}_formatPeriodDisplay(e,t){if(!e||!t)return`${e||""} / ${t||""}`;const i=e.substring(0,4);return i===t.substring(0,4)?i:`${e} / ${t}`}_resolveInstantDate(e,t,i,o){if(null==e?void 0:e.includes("periodStartLabel")){const e=i||"2025-01-01";try{const t=new Date(e);return t.setDate(t.getDate()-1),t.toISOString().split("T")[0]}catch{return e}}return t||o||i||"2025-01-01"}_addColumnFromRequest(e,t,i){var o,r,n,s,a;const l=`col-${Date.now()}`;let d="",c="";"instant"===e.periodType?(d=e.instantDate||"",c=""):"duration"!==e.periodType&&"mixed"!==e.periodType||(d=this._formatPeriodDisplay(e.startDate,e.endDate),c="");let p={dimensionId:"period",memberValue:"instant"===e.periodType?`instant-${e.instantDate}`:`duration-${e.startDate}-${e.endDate}`,memberLabel:d};if(e.selectedDimensions&&e.selectedDimensions.length>0){const t=[],i=[];for(const o of e.selectedDimensions)o.isTyped&&o.typedValue?(t.push(`${o.axisLabel}: ${o.typedValue}`),i.push(`${o.axisId}|${o.typedValue}`)):o.memberId&&o.memberLabel&&(t.push(o.memberLabel),i.push(`${o.axisId}|${o.memberId}`));t.length>0&&(d=t.join(" | "),c="instant"===e.periodType?e.instantDate||"":this._formatPeriodDisplay(e.startDate,e.endDate),p={dimensionId:l,memberValue:t.join(" | "),memberLabel:t.join(" | "),memberKey:t.join(" | "),dimensionIdKey:i.join("::"),selectedDimensions:e.selectedDimensions},console.log(`πŸ“Š Applied selected dimensions to new column: ${p.memberKey}`))}else if(null==(r=null==(o=this.xbrlInput)?void 0:o.hypercubes)?void 0:r[0]){const i=this.xbrlInput.hypercubes[0].roles.find(e=>e.roleId===t);if(1===(null==(n=null==i?void 0:i.items)?void 0:n.length)){const t=i.items[0];if(1===t.dimensions.length){const i=t.dimensions[0];if(i.members&&i.members.length>0){const t=(null==(s=i.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:s.label)||i.conceptName,o=i.members[0],r=(null==(a=o.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:a.label)||o.conceptName;d=r,c="instant"===e.periodType?e.instantDate||"":this._formatPeriodDisplay(e.startDate,e.endDate),p={dimensionId:l,axisId:i.id,memberId:o.id,memberValue:r,memberLabel:r,axis:t,axisLabel:t,memberKey:`${t} | ${r}`,dimensionIdKey:`${i.id} | ${o.id}`},console.log(`πŸ“Š Applied hypercube dimension to new column: ${p.memberKey}`)}}}}const h={id:l,title:d,description:c,type:(p.memberKey,"dimension"),order:this._columns.length,removable:!0,dimensionData:p,periodStartDate:"instant"===e.periodType?e.instantDate:e.startDate,periodEndDate:"instant"===e.periodType?e.instantDate:e.endDate};if(e.selectedDimensions&&e.selectedDimensions.length>0){const t={};let i=!1;for(const o of e.selectedDimensions)o.isTyped&&(t[o.axisId]=o.typedValue||"",i=!0);i&&(this._typedMemberData[l]=t,h.dimensionData&&(h.dimensionData.hasTypedMembers=!0,h.dimensionData.typedMembers=e.selectedDimensions.filter(e=>e.isTyped).map(e=>({axisId:e.axisId,axisLabel:e.axisLabel,typedMemberId:e.axisId,memberLabel:e.axisLabel}))))}if(this._currentSchema){const e=this._currentSchema.sections.find(e=>e.id===t);if(e)if(e.columns||(e.columns=[...this._columns]),i){const t=e.columns.findIndex(e=>e.id===i);e.columns=-1!==t?[...e.columns.slice(0,t+1),h,...e.columns.slice(t+1)]:[...e.columns,h]}else e.columns=[...e.columns,h]}this._replicateFieldsForNewColumn(l,e,t),this._dirty=!0,this.requestUpdate(),this.dispatchEvent(new CustomEvent("column-add",{detail:{column:h},bubbles:!0}))}_removeColumnData(e,t){if(this._currentSchema)if(t){const i=this._currentSchema.sections.find(e=>e.id===t);i&&this._removeColumnDataFromConcepts(i.concepts,e)}else for(const i in this._formData)void 0!==this._formData[i][e]&&delete this._formData[i][e]}_removeColumnDataFromConcepts(e,t){e.forEach(e=>{this._formData[e.id]&&void 0!==this._formData[e.id][t]&&delete this._formData[e.id][t],e.fields&&(e.fields=e.fields.filter(e=>e.columnId!==t)),e.children&&this._removeColumnDataFromConcepts(e.children,t)})}_shouldCreateFieldForConcept(e,t){if(e.abstract)return!1;if(!(t.selectedDimensions&&t.selectedDimensions.length>0)&&e.periodType){if("instant"===t.periodType&&"instant"!==e.periodType)return!1;if("duration"===t.periodType&&"duration"!==e.periodType)return!1}return!0}_replicateFieldsForNewColumn(e,t,i){if(!this._currentSchema)return;const o=new F,r=this._currentSchema.sections.find(e=>e.id===i);r&&this._replicateFieldsForSection(r.concepts,e,t,o)}_replicateFieldsForSection(e,t,i,o){e.forEach(e=>{var r;if(this._shouldCreateFieldForConcept(e,i)){const o=null==(r=e.fields)?void 0:r[0];let n;const s="instant"===i.periodType?i.instantDate:i.startDate,a="instant"===i.periodType?i.instantDate:i.endDate,l=this._resolveInstantDate(e.preferredLabel,i.instantDate,s,a);n=o?{id:`${e.id}_${t}`,conceptId:e.id,columnId:t,type:o.type,label:o.label,placeholder:o.placeholder,required:o.required,disabled:o.disabled,validation:o.validation,defaultValue:o.defaultValue,periodType:e.periodType,conceptType:e.type,periodStartDate:s,periodEndDate:a,periodInstantDate:"instant"===e.periodType?l:void 0}:{id:`${e.id}_${t}`,conceptId:e.id,columnId:t,type:"text",label:e.label||e.name,placeholder:`Enter ${e.name}`,required:!1,disabled:!1,validation:[],defaultValue:"",periodType:e.periodType,conceptType:e.type,periodStartDate:s,periodEndDate:a,periodInstantDate:"instant"===e.periodType?l:void 0},e.fields||(e.fields=[]),e.fields.push(n)}e.children&&this._replicateFieldsForSection(e.children,t,i,o)})}_addColumn(){const e={id:`dim-${Date.now()}`,title:`Dimension ${this._columns.length}`,description:"Additional dimension column",type:"dimension",order:this._columns.length,removable:!0,dimensionData:{dimensionId:"custom",memberValue:"default",memberLabel:"Default Member"}};this._columns=[...this._columns,e],this.requestUpdate(),this.dispatchEvent(new CustomEvent("column-add",{detail:{column:e},bubbles:!0}))}_handleSubmit(){if(console.log("πŸ“ Form submission started..."),this._submitted=!0,this._submitDisabled=!0,"admin"===this.mode)return this._handleSaveDraft(),this._handleAdminModeSubmit(),void(this._submitDisabled=!1);if(console.log("πŸ”΅ [Submit] Checking for errors..."),console.log(`πŸ”΅ [Submit] _xbrlFormErrors.length: ${this._xbrlFormErrors.length}`),console.log("πŸ”΅ [Submit] _xbrlFormErrors:",this._xbrlFormErrors),this._xbrlFormErrors.length>0)return console.log("❌ [Submit] Cannot submit - validation errors present:",this._xbrlFormErrors),this._showErrorPopup=!0,this._submitDisabled=!1,void this.requestUpdate();if(console.log("βœ… [Submit] No validation errors, proceeding with submission..."),this._validateForm(),!this._valid)return console.log("❌ [Submit] Cannot submit - form validation errors present:",this._errors),this._showErrorPopup=!0,this._submitDisabled=!1,void this.requestUpdate();const e=this._generateSubmissionData();console.log("πŸ“Š Form Submission Data:",JSON.stringify(e,null,2)),console.log("πŸ“Š Submission Data Summary:"),e.forEach((e,t)=>{console.log(` [${t}] conceptId: ${e.conceptId}, columnId: ${e.columnId}, value: ${e.value}, unit: ${e.unit||"none"}`)}),this.dispatchEvent(new CustomEvent("form-submit",{detail:{data:this._formData,submissionData:e,valid:this._valid,errors:this._errors,reportingLanguage:this.reportingLanguage},bubbles:!0})),console.log("βœ… Form submit event dispatched"),setTimeout(()=>{this._submitDisabled=!1},1e3)}_handleSaveDraft(e="manual"){if(console.log("πŸ”΅ [Save Draft] Checking for errors..."),console.log(`πŸ”΅ [Save Draft] _xbrlFormErrors.length: ${this._xbrlFormErrors.length}`),console.log("πŸ”΅ [Save Draft] _xbrlFormErrors:",this._xbrlFormErrors),this._xbrlFormErrors.length>0)return console.log("❌ [Save Draft] Cannot save - validation errors present:",this._xbrlFormErrors),this._showErrorPopup=!0,void this.requestUpdate();console.log("βœ… [Save Draft] No validation errors, proceeding with save..."),console.log("πŸ’Ύ Raw form data before submission generation:",this._formData),console.log("🏷️ Unit data before submission generation:",this._unitData),console.log("πŸ“‹ Enhanced selectedRoleIds with roleURI and order:",this._selectedRoleIds);const t=this._generateSubmissionData();console.log("πŸ“€ Generated submission data:",t),console.log("πŸ“Š Submission data breakdown:"),t.forEach((e,t)=>{console.log(` [${t}] conceptId: ${e.conceptId}, columnId: ${e.columnId}, value: ${e.value}, unit: ${e.unit||"none"}`)});const i=this._roleCompletedStates.size>0?Object.fromEntries(this._roleCompletedStates):void 0,o=this._draftStorageService.createMetadataSnapshot(this.periodStartDate,this.periodEndDate,this.language,this._selectedRoleIds,this._allSections,this._typedMemberData,this._periodPreferences,this._periodData,this._unitData,this.reportingLanguage,this._repeatCounts,this._decimalsData,i),r=JSON.stringify({draftData:t,metadata:o});if(r===this._lastSavedDraftSnapshot)return void console.log(`ℹ️ [Save Draft] No draft content change detected (${e}); skipping event emit.`);this._lastSavedDraftSnapshot=r;const n=this._draftStorageService.saveDraft(t,o);console.log("πŸ’Ύ [Save Draft] Metadata saved with enhanced selectedRoleIds:",o.selectedRoleIds),this.dynaformsFacts=t,this.dynaformsMetadata=o,this.dispatchEvent(new CustomEvent("form-save-draft",{detail:{data:this._formData,draftData:t,metadata:o,saved:n,valid:this._valid,errors:this._errors,dynaformsFacts:t,dynaformsMetadata:o,reportingLanguage:this.reportingLanguage,source:"auto"==e?"auto":"manual"},bubbles:!0,composed:!0}));const s=this._getRoleIdsArray().length;console.log("πŸ’Ύ Draft saved - localStorage + event emitted",{entries:t.length,saved:n,roles:s,customColumns:o.customColumns.length,eventEmitted:!0,enhancedRoleStructure:Array.isArray(this._selectedRoleIds)&&this._selectedRoleIds.length>0&&"object"==typeof this._selectedRoleIds[0]})}async _loadDraftIfExists(){if(console.log("πŸ“‹ Checking for saved draft..."),this.dynaformsFacts&&this.dynaformsMetadata){console.log("πŸ“¦ Using external draft data from properties");const e={formData:this.dynaformsFacts,metadata:this.dynaformsMetadata};return await this._restoreFromDraft(e),this._draftLoaded=!0,this._draftLoadedAt=this.dynaformsMetadata.savedAt||(new Date).toISOString(),this.dispatchEvent(new CustomEvent("form-draft-loaded",{detail:{draft:e,source:"external",compatible:!0,warnings:[]},bubbles:!0,composed:!0})),void console.log("πŸ“₯ External draft loaded successfully")}if(!this._draftStorageService.hasDraft())return void console.log("ℹ️ No saved draft found");const e=this._draftStorageService.loadDraft();if(!e)return void console.warn("⚠️ Failed to load draft");const{compatible:t,warnings:i}=this._draftStorageService.validateDraftCompatibility(e,this.periodStartDate,this.periodEndDate);i.length>0&&console.warn("⚠️ Draft compatibility warnings:",i),await this._restoreFromDraft(e),this.dispatchEvent(new CustomEvent("form-draft-loaded",{detail:{draft:e,compatible:t,warnings:i},bubbles:!0,composed:!0})),console.log("πŸ“₯ Draft loaded successfully",{entries:e.formData.length,savedAt:e.metadata.savedAt,age:this._draftStorageService.getDraftAge()})}async _restoreFromDraft(e){var t;const{formData:i,metadata:o}=e;o.selectedRoleIds&&o.selectedRoleIds.length>0&&(this._selectedRoleIds=o.selectedRoleIds,console.log(`πŸ”„ Restored ${this._selectedRoleIds.length} selected roles`)),o.typedMemberData&&(this._typedMemberData=o.typedMemberData,this._preservedTypedMemberData={},console.log("πŸ”„ Restored typed member data")),o.repeatCounts&&(this._repeatCounts=o.repeatCounts,console.log("πŸ”„ Restored repeat counts:",this._repeatCounts)),o.periodData&&(this._periodData=o.periodData,console.log("πŸ”„ Restored custom field-level period data:",Object.keys(this._periodData).length,"concepts")),o.unitData&&(this._unitData=o.unitData,console.log("πŸ”„ Restored custom field-level unit data:",Object.keys(this._unitData).length,"concepts")),o.decimalsData&&(this._decimalsData=o.decimalsData,console.log("πŸ”„ Restored per-fact decimals data:",Object.keys(this._decimalsData).length,"concepts")),o.roleCompletedStates&&(this._roleCompletedStates=new Map(Object.entries(o.roleCompletedStates)),console.log("πŸ”„ Restored role completed states:",Object.keys(o.roleCompletedStates).length,"roles")),o.periodPreferences?this._skipPeriodPreferencesRestore?console.log("⏭️ Skipping period preferences restoration - using new filter selections"):(this._periodPreferences=o.periodPreferences,console.log("πŸ”„ Restored period preferences (including previous year settings):",this._periodPreferences),this.xbrlInput&&(console.log("πŸ”„ Rebuilding schema with restored period preferences..."),this._currentSchema=F.buildFormSchema(this.xbrlInput,this.periodStartDate,this.periodEndDate,this.language,this._periodPreferences),this._allSections=[...this._currentSchema.sections],console.log("βœ… Schema rebuilt with restored period preferences"),console.log("πŸ”„ Applying custom period data to schema fields..."),this._applyCustomPeriodDataToFields(),o.customColumns&&o.customColumns.length>0&&(this._mergeAdditionalCustomColumns(o.customColumns),console.log(`πŸ”„ Merged ${o.customColumns.length} additional custom columns`)))):o.customColumns&&o.customColumns.length>0&&(this._restoreCustomColumns(o.customColumns),console.log(`πŸ”„ Restored ${o.customColumns.length} custom columns`));const r={},n={},s={};i.forEach(e=>{let{conceptId:t,draftInstanceId:i,value:o,columnId:a,period:l,unit:d}=e;if(!a&&l&&(a=this._inferColumnIdFromPeriod(l,t),!a))return void console.warn(`⚠️ Could not infer columnId for concept ${t}, skipping...`);const c=i||t,p=c.includes("__repeat_")?c.split("__repeat_")[0]:c,h=this._findActualConceptId(p),u=c.includes("__repeat_")?`${h||p}__repeat_${c.split("__repeat_")[1]}`:h||c;r[u]||(r[u]={}),r[u][a]=o,console.log(`πŸ“¦ Restored: ${u}[${a}] = ${o}${c!==t?" (repeat instance)":""}`),l&&(n[u]||(n[u]={}),"instant"===l.type?(n[u][a]={instantDate:l.date},console.log(`πŸ“… [Restore Period] Extracted instant date for ${u}/${a}: ${l.date}`)):"duration"===l.type&&(n[u][a]={startDate:l.startDate,endDate:l.endDate},console.log(`πŸ“… [Restore Period] Extracted duration dates for ${u}/${a}: ${l.startDate} - ${l.endDate}`))),d&&(s[u]||(s[u]={}),s[u][a]=d,console.log(`🏷️ [Restore Unit] Extracted unit for ${u}/${a}: ${d}`))}),this._formData={...this._formData,...r},console.log(`πŸ”„ Restored ${Object.keys(r).length} concepts with data`),this._initializeGlobalDecimalsFromRoundingData(),this._periodData={...this._periodData,...o.periodData||{},...n},console.log(`πŸ“… [Period Restore] Merged period data: ${Object.keys(this._periodData).length} concepts with custom periods`),console.log("πŸ“… [Period Restore] Full _periodData after merge:",JSON.stringify(this._periodData,null,2)),this._unitData={...this._unitData,...o.unitData||{},...s},console.log(`🏷️ [Unit Restore] Merged unit data: ${Object.keys(this._unitData).length} concepts with custom units`),console.log("🏷️ [Unit Restore] Full _unitData after merge:",JSON.stringify(this._unitData,null,2)),this._selectedRoleIds.length>0&&this._applyRoleFilter(),this._dirty=!0,this._touched.clear(),this._validateForm(),this._allSections=[...this._allSections],this.requestUpdate(),await this.updateComplete,await new Promise(e=>setTimeout(e,100));const a=(null==(t=this.shadowRoot)?void 0:t.querySelectorAll("input, textarea, select").length)||0;console.log(`πŸ” Found ${a} fields in DOM after update`),a>0?this._populateFieldValues(r):console.error("❌ No fields found in DOM even after updateComplete"),console.log("βœ… Draft restoration completed")}_findActualConceptId(e){for(const t of this._allSections){const i=this._findActualConceptIdInTree(t.concepts,e);if(i)return i}return null}_findActualConceptIdInTree(e,t){for(const i of e){if(i.originalConceptId===t||i.id===t)return i.id;if(i.children){const e=this._findActualConceptIdInTree(i.children,t);if(e)return e}}return null}_inferColumnIdFromPeriod(e,t){for(const i of this._allSections){if(this._findConceptInSection(i.concepts,t)&&i.columns){for(const o of i.columns){const i="instant"===e.type,r="duration"===e.type;if(i&&e.date){if(o.periodStartDate===e.date||o.periodStartDate===o.periodEndDate&&o.periodStartDate===e.date)return console.log(`βœ“ Inferred columnId: ${o.id} for concept ${t}`),o.id}else if(r&&e.startDate&&e.endDate&&o.periodStartDate===e.startDate&&o.periodEndDate===e.endDate)return console.log(`βœ“ Inferred columnId: ${o.id} for concept ${t}`),o.id}if("instant"===e.type){const e=i.columns.find(e=>"instant"===e.id);if(e)return e.id}else{const e=i.columns.find(e=>"duration"===e.id);if(e)return e.id}}}return null}_findConceptInSection(e,t){for(const i of e){if(i.id===t||i.originalConceptId===t)return i;if(i.children){const e=this._findConceptInSection(i.children,t);if(e)return e}}return null}_populateFieldValues(e){let t=0,i=0;console.log("πŸ” Starting field population..."),console.log("πŸ“¦ Form data to populate:",e),Object.keys(e).forEach(o=>{const r=e[o];Object.keys(r).forEach(e=>{var n,s;const a=r[e],l=`${o}__${e}`;console.log(`πŸ” Looking for field: ${l}`);const d=null==(n=this.shadowRoot)?void 0:n.querySelector(`#${CSS.escape(l)}`);d?(d instanceof HTMLInputElement||d instanceof HTMLTextAreaElement||d instanceof HTMLSelectElement)&&("checkbox"===d.type?d.checked=Boolean(a):d.value=null!=a?String(a):"",console.log(` βœ… Populated field ${l} with value:`,a),t++):(console.warn(` ❌ Field element NOT FOUND: ${l}`),console.warn(" Available fields in DOM:",Array.from((null==(s=this.shadowRoot)?void 0:s.querySelectorAll("input, textarea, select"))||[]).map(e=>e.id).filter(e=>e.includes(o.split("__")[0]))),i++)})}),console.log(`βœ… Field population complete: ${t} populated, ${i} not found`)}_restoreCustomColumns(e){const t=new Map;e.forEach(e=>{t.has(e.sectionId)||t.set(e.sectionId,[]),t.get(e.sectionId).push(e)}),this._allSections.forEach(e=>{var i;const o=t.get(e.id);if(o){if(e.columns=o.map(e=>{const t={id:e.columnId,title:e.label,description:e.description,type:e.dimensionData?"dimension":"base",periodStartDate:e.startDate||e.date,periodEndDate:e.endDate||e.date,dimensionData:e.dimensionData,order:0,removable:"duration"!==e.columnId&&"instant"!==e.columnId,periodType:e.periodType};return console.log(`πŸ“… [Draft Restore] Restoring column ${e.columnId}: title=${t.title}, description=${t.description}, startDate=${t.periodStartDate}, endDate=${t.periodEndDate}, periodType=${t.periodType}`),t}),(null==(i=this.xbrlInput)?void 0:i.datatypes)&&!e.datatypes){const t=Array.isArray(this.xbrlInput.datatypes)?this.xbrlInput.datatypes:this.xbrlInput.datatypes.concepts||[];e.datatypes=t,console.log(`βœ… [Draft Restore] Attached ${t.length} datatypes to section ${e.id}`)}else e.datatypes?console.log(`ℹ️ [Draft Restore] Section ${e.id} already has ${e.datatypes.length} datatypes`):console.warn(`⚠️ [Draft Restore] No datatypes available for section ${e.id}`);this._regenerateFieldsForSection(e),console.log(` └─ Restored ${o.length} columns for section ${e.id}`)}}),this._currentSchema&&(this._currentSchema={...this._currentSchema,sections:this._allSections})}_mergeAdditionalCustomColumns(e){const t=new Map;e.forEach(e=>{e.columnId.startsWith("col-")&&(t.has(e.sectionId)||t.set(e.sectionId,[]),t.get(e.sectionId).push(e))}),this._allSections.forEach(e=>{var i;const o=t.get(e.id);if(o&&o.length>0){if(e.columns||(e.columns=[]),(null==(i=this.xbrlInput)?void 0:i.datatypes)&&!e.datatypes){const t=Array.isArray(this.xbrlInput.datatypes)?this.xbrlInput.datatypes:this.xbrlInput.datatypes.concepts||[];e.datatypes=t,console.log(`βœ… [Merge Custom] Attached ${t.length} datatypes to section ${e.id}`)}else e.datatypes?console.log(`ℹ️ [Merge Custom] Section ${e.id} already has ${e.datatypes.length} datatypes`):console.warn(`⚠️ [Merge Custom] No datatypes available for section ${e.id}`);o.forEach(t=>{console.log(`πŸ“… [Merge Custom Column] Column ${t.columnId}: col.startDate=${t.startDate}, col.endDate=${t.endDate}, col.date=${t.date}, col.periodType=${t.periodType}`);if(!e.columns.find(e=>e.id===t.columnId)){const i={id:t.columnId,title:t.label,description:t.description,type:t.dimensionData?"dimension":"base",periodStartDate:t.startDate||t.date,periodEndDate:t.endDate||t.date,dimensionData:t.dimensionData,order:e.columns.length,removable:!0,periodType:t.periodType};console.log(`πŸ“… [New Column Created] Column ${i.id}: title=${i.title}, description=${i.description}, periodStartDate=${i.periodStartDate}, periodEndDate=${i.periodEndDate}, periodType=${i.periodType}`),e.columns.push(i),console.log(` └─ Added custom column ${t.columnId} to section ${e.id}`)}}),this._regenerateFieldsForSection(e)}}),this._currentSchema&&(this._currentSchema={...this._currentSchema,sections:this._allSections})}_applyCustomPeriodDataToFields(){if(!this._periodData||0===Object.keys(this._periodData).length)return void console.log("ℹ️ No custom period data to apply");let e=0;const t=i=>{i.forEach(i=>{if(this._periodData[i.id]){const t=this._periodData[i.id];i.fields&&i.fields.forEach(o=>{const r=t[o.columnId];r&&(r.startDate&&(o.periodStartDate=r.startDate),r.endDate&&(o.periodEndDate=r.endDate),r.instantDate&&(o.periodInstantDate=r.instantDate),e++,console.log(`βœ… [Apply Period] Updated field ${i.id}/${o.columnId}: start=${o.periodStartDate}, end=${o.periodEndDate}, instant=${o.periodInstantDate}`))})}i.children&&i.children.length>0&&t(i.children)})};this._allSections.forEach(e=>{e.concepts&&e.concepts.length>0&&t(e.concepts)}),console.log(`πŸ“… [Apply Period] Applied custom period data to ${e} fields`)}_regenerateFieldsForSection(e){if(!e.columns)return;const t=this._periodPreferences[e.id]||{showDuration:!0,showInstant:!0,showPreviousYear:!1},i=o=>{o.forEach(o=>{o.fields=[];this._shouldShowConceptBasedOnPeriodPreferences(o,t)&&e.columns.forEach(t=>{var i;const r=o.periodType,n=this._inferColumnPeriodType(t);if(o.abstract)return;const s=t.id.startsWith("col-"),a=t.id.startsWith("duration_")||t.id.startsWith("instant_")||t.id.startsWith("typed-"),l=!0===e.showPeriodControl;if(!(!n||"duration"===t.id||"default"===t.id||s&&l||a)&&r&&n&&r!==n)return void console.log(`⏭️ [Field Regeneration] Skipping field for ${o.id} in column ${t.id}: conceptPeriodType=${r}, columnPeriodType=${n}`);const d={id:`${o.id}_${t.id}`,conceptId:o.id,columnId:t.id,type:this._mapConceptTypeToFieldType(o.type),label:o.label,periodType:r,conceptType:o.type,periodStartDate:t.periodStartDate,periodEndDate:t.periodEndDate,periodInstantDate:"instant"===r?t.periodEndDate||t.periodStartDate:void 0};if(null==(i=this._periodData[o.id])?void 0:i[t.id]){const e=this._periodData[o.id][t.id];e.startDate&&(d.periodStartDate=e.startDate),e.endDate&&(d.periodEndDate=e.endDate),e.instantDate&&(d.periodInstantDate=e.instantDate),console.log(`βœ… [Field Regeneration] Applied custom period data to ${o.id}/${t.id}:`,e),console.log(`βœ… [Field Regeneration] Field properties after apply: periodStartDate=${d.periodStartDate}, periodEndDate=${d.periodEndDate}, periodInstantDate=${d.periodInstantDate}`)}else console.log(`ℹ️ [Field Regeneration] No custom period data for ${o.id}/${t.id}. Checking _periodData:`,this._periodData[o.id]);(o.id.includes("DescriptionLocationNL")||t.id.startsWith("col-"))&&console.log(`πŸ“… [Field Regeneration] Concept ${o.id}, Column ${t.id}: field.periodStartDate=${d.periodStartDate}, field.periodEndDate=${d.periodEndDate}, column.periodStartDate=${t.periodStartDate}`),o.fields.push(d)}),o.children&&i(o.children)})};i(e.concepts)}_shouldShowConceptBasedOnPeriodPreferences(e,t){return!!e.abstract||(!e.periodType||!("duration"===e.periodType&&!t.showDuration)&&!("instant"===e.periodType&&!t.showInstant))}_inferColumnPeriodType(e){return e.periodType?e.periodType:e.periodStartDate&&e.periodEndDate?e.periodStartDate===e.periodEndDate?"instant":"duration":e.periodStartDate&&!e.periodEndDate?"instant":void 0}_mapConceptTypeToFieldType(e){return e?e.includes("monetary")||e.includes("Monetary")?"number":e.includes("date")||e.includes("Date")?"date":e.includes("boolean")||e.includes("Boolean")?"boolean":e.includes("integer")||e.includes("Integer")||e.includes("decimal")||e.includes("Decimal")?"number":"text":"text"}_generateSubmissionData(){const e=[];if(!this._currentSchema)return e;this._currentSchema.sections.forEach(t=>{this._processConceptsForSubmission(t.concepts,e,t)}),this._includePreservedDataInSubmission(e);return this._removeDuplicateSubmissions(e)}_includePreservedDataInSubmission(e){Object.keys(this._preservedFormData).forEach(t=>{const i=this._preservedFormData[t];i&&Object.keys(i).forEach(o=>{const r=i[o];if(null!=r&&""!==r){const i=this._findConceptInAllSections(t);if(i){const n=this._findSectionForConcept(t);this._addConceptDataToSubmission(i,o,r,e,n||void 0)}}})}),console.log(`πŸ“€ Included preserved data in submission. Total entries: ${e.length}`)}_findConceptInAllSections(e){for(const t of this._allSections){const i=this._findConceptInSection(t.concepts,e);if(i)return i}return null}_findSectionForConcept(e){for(const t of this._allSections){if(this._findConceptInSection(t.concepts,e))return t}return null}_addConceptDataToSubmission(e,t,i,o,r){var n,s,a,l,d;const c=e.fields.find(e=>e.columnId===t);if(!c)return;const p="instant"===e.periodType,h=null==(n=this._periodData[e.id])?void 0:n[t],u=null==(s=this._unitData[e.id])?void 0:s[t],m=this._findColumnByIdInAllSections(t);console.log(`πŸ” [Submission] Concept: ${e.id}, Column: ${t}, Field Period: ${h?JSON.stringify(h):"none"}, Unit: ${u||"none"}, Column Period: ${(null==m?void 0:m.periodStartDate)||"none"} - ${(null==m?void 0:m.periodEndDate)||"none"}`);const f=(null==h?void 0:h.startDate)||(null==m?void 0:m.periodStartDate)||c.periodStartDate||this.periodStartDate,b=(null==h?void 0:h.endDate)||(null==m?void 0:m.periodEndDate)||c.periodEndDate||this.periodEndDate,g=(null==h?void 0:h.instantDate)||c.periodInstantDate||b||f,v={conceptId:e.originalConceptId||e.id,columnId:t,value:i,period:{type:e.periodType||"duration",...p?{date:g}:{startDate:f,endDate:b}}};u&&(v.unit=u,console.log(`βœ… [Submission] Adding unit to entry: ${u} for ${e.id}/${t}`));const y=null==(a=e.type)?void 0:a.toLowerCase().includes("monetary"),x=(null==(l=this._decimalsData[e.id])?void 0:l[t])||("INF"!==this.decimals?this.decimals:void 0);if(y&&x){const e=parseFloat(x);v.decimals=isNaN(e)?x:String(-Math.abs(e))}(null==(d=null==m?void 0:m.dimensionData)?void 0:d.memberLabel)&&(v.dimension=m.dimensionData.memberLabel),console.log("πŸ“€ [Submission Entry] Created entry:",JSON.stringify(v,null,2)),o.push(v)}_findColumnByIdInAllSections(e){for(const t of this._allSections)if(t.columns){const i=t.columns.find(t=>t.id===e);if(i)return i}}_removeDuplicateSubmissions(e){const t=new Map;return e.forEach(e=>{const i="instant"===e.period.type?e.period.date:`${e.period.startDate}_${e.period.endDate}`,o=`${e.conceptId}_${e.value}_${e.dimension||"no-dimension"}_${i}`;t.has(o)||t.set(o,e)}),Array.from(t.values())}_findColumnById(e){if(this._currentSchema)for(const t of this._currentSchema.sections)if(t.columns){const i=t.columns.find(t=>t.id===e);if(i)return i}}_findColumnByIdInSection(e,t){if(null==t?void 0:t.columns)return t.columns.find(t=>t.id===e)}_getTypedMemberNameForAxis(e,t){var i,o,r,n;if(!(null==(o=null==(i=this.xbrlInput)?void 0:i.hypercubes)?void 0:o[0]))return null;const s=null==t?void 0:t.id;if(!s)return null;const a=null==(r=this.xbrlInput.hypercubes[0].roles)?void 0:r.find(e=>e.roleId===s);if(!(null==a?void 0:a.items))return null;for(const l of a.items)if(l.dimensions){const t=l.dimensions.find(t=>t.id===e);if(null==(n=null==t?void 0:t.typedMember)?void 0:n.id)return t.typedMember.id}return null}_doesConceptApplyToTypedDimension(e,t,i){var o,r,n;if(!(null==(r=null==(o=this.xbrlInput)?void 0:o.hypercubes)?void 0:r[0]))return!1;const s=null==t?void 0:t.id;if(!s)return!1;const a=this.xbrlInput.hypercubes[0].roles.find(e=>e.roleId===s);if(!(null==(n=null==a?void 0:a.items)?void 0:n.length))return!1;for(const l of a.items){const t=e.originalConceptId||e.id;if(l.conceptIds&&l.conceptIds.includes(t)){const e=l.dimensions.some(e=>e.typedMember);return console.log(`πŸ” [DynamicForm] Concept ${t} found in hypercube item. Has typed dimensions:`,e),e}}return console.log(`πŸ” [DynamicForm] Concept ${e.originalConceptId||e.id} not found in any hypercube items for role ${s}`),!1}_getApplicableTypedDimensions(e,t){var i,o,r;if(!(null==(o=null==(i=this.xbrlInput)?void 0:i.hypercubes)?void 0:o[0])||!(null==t?void 0:t.id))return[];const n=this.xbrlInput.hypercubes[0].roles.find(e=>e.roleId===t.id);if(!(null==(r=null==n?void 0:n.items)?void 0:r.length))return[];const s=e.originalConceptId||e.id;for(const a of n.items)if(a.conceptIds&&a.conceptIds.includes(s)){const e=a.dimensions.filter(e=>e.typedMember).map(e=>e.id);return console.log(`πŸ” [DynamicForm] Found applicable typed dimensions for concept ${s}:`,e),e}return[]}_processConceptsForSubmission(e,t,i){const o="Toelichting op de geconsolideerde jaarrekening - FinanciΓ«le vaste activa: Deelnemingen: Volledig geconsolideerd: Specificatie",r=(null==i?void 0:i.title)||"Unknown";e.forEach(e=>{if(r===o&&(console.warn(`[DUPLICATE DEBUG] Processing concept ${e.originalConceptId||e.id} in target role`),e.fields&&(console.warn(`[DUPLICATE DEBUG] Concept has ${e.fields.length} fields`),e.fields.forEach((t,i)=>{var o;console.warn(`[DUPLICATE DEBUG] Field ${i}: columnId=${t.columnId}, current value=${null==(o=this._formData[e.id])?void 0:o[t.columnId]}`)}))),e.fields&&e.fields.length>1&&e.fields.forEach((e,t)=>{}),e.fields&&e.fields.length>0){e.fields.forEach(n=>{var s,a,l,d,c,p,h,u;const m=this._formData[e.id];let f=null==m?void 0:m[n.columnId];const b=n.conceptId||e.id.split("__").slice(0,-1).join("__")||e.id;if((null==f||""===f)&&this._isRoundingLevelConcept(b)&&!this._hasValidGlobalDecimals()){const t=this._findFactValueForField(e,n,i);null!=t&&""!==t&&(f=t)}if((null==f||""===f)&&this._effectiveMasterData){const e=null==(s=this._effectiveMasterData)?void 0:s[b];null!=e&&""!==e&&(f=e,console.warn(` πŸ“¦ [Submission] Using masterData for: ${b} [${n.columnId}] = ${JSON.stringify(f)}`))}if(null!=f&&""!==f){const s=this._findColumnByIdInSection(n.columnId,i),m=null==(a=this._periodData[e.id])?void 0:a[n.columnId],b={conceptId:e.id,draftInstanceId:e.id,columnId:n.columnId,value:f,period:{type:e.periodType||"duration"}};if("instant"===e.periodType){const e=(null==m?void 0:m.instantDate)||(null==m?void 0:m.endDate)||(null==s?void 0:s.periodEndDate)||n.periodInstantDate||n.periodEndDate||n.periodStartDate||this.periodStartDate;b.period.date=e}else{const e=(null==m?void 0:m.startDate)||(null==s?void 0:s.periodStartDate)||n.periodStartDate||this.periodStartDate,t=(null==m?void 0:m.endDate)||(null==s?void 0:s.periodEndDate)||n.periodEndDate||this.periodEndDate;b.period.startDate=e,b.period.endDate=t}console.log(`πŸ” [Submission] Concept: ${e.id}, Column: ${n.columnId}, Field Period: ${m?JSON.stringify(m):"none"}, Column Period: ${(null==s?void 0:s.periodStartDate)||"none"} - ${(null==s?void 0:s.periodEndDate)||"none"}, Used Period: ${"instant"===b.period.type?b.period.date:`${b.period.startDate} - ${b.period.endDate}`}`);const g=null==(l=this._unitData[e.id])?void 0:l[n.columnId];g?(b.unit=g,console.log(`βœ… [Submission] Adding unit to entry: ${g} for ${e.id}/${n.columnId}`)):console.log(`⚠️ [Submission] No unit found in _unitData for ${e.id}/${n.columnId}. _unitData state:`,JSON.stringify(this._unitData,null,2));const v=null==(d=e.type)?void 0:d.toLowerCase().includes("monetary"),y=(null==(c=this._decimalsData[e.id])?void 0:c[n.columnId])||("INF"!==this.decimals?this.decimals:void 0);if(v&&y){const e=parseFloat(y);b.decimals=isNaN(e)?y:String(-Math.abs(e))}if("dimension"===(null==s?void 0:s.type)&&(null==(p=s.dimensionData)?void 0:p.dimensionIdKey)?(b.dimension=s.dimensionData.dimensionIdKey,console.log(`πŸ” [DynamicForm] Using dimension key from field's column (${n.columnId}):`,s.dimensionData.dimensionIdKey)):console.log(`πŸ” [DynamicForm] No dimension data found for field column ${n.columnId}. Column type: ${null==s?void 0:s.type}, has dimensionData: ${!!(null==s?void 0:s.dimensionData)}`),this._typedMemberData[n.columnId]){const t=this._getApplicableTypedDimensions(e,i);if(console.log(`πŸ” [DynamicForm] Concept ${e.id} applicable typed dimensions:`,t),t.length>0){const e={},o=this._typedMemberData[n.columnId];t.forEach(t=>{if(o[t]){const r=this._getTypedMemberNameForAxis(t,i);e[t]={value:o[t],memberName:r||"Unknown"}}}),Object.keys(e).length>0?(b.typedMembers=e,console.log("πŸ” [DynamicForm] Adding filtered typed members to submission:",e)):console.log("πŸ” [DynamicForm] No typed member values found for applicable dimensions:",t)}else console.log(`πŸ” [DynamicForm] Skipping typed members for concept ${e.id} - not applicable to this hypercube`)}else console.log(`πŸ” [DynamicForm] No typed member data found for column ${n.columnId}. Available columns:`,Object.keys(this._typedMemberData)),s&&console.log("πŸ” [DynamicForm] Column details:",{id:s.id,type:s.type,hasTypedMembers:null==(h=s.dimensionData)?void 0:h.hasTypedMembers,dimensionData:s.dimensionData});if(!b.typedMembers&&(null==(u=n.crossRoleTypedMembers)?void 0:u.length)){const t=`${e.id}__${n.columnId}`,i=this._typedMemberData[t];if(i){const t={};n.crossRoleTypedMembers.forEach(e=>{const o=i[e.axisId];null!=o&&""!==o&&(t[e.axisId]={value:o,memberName:e.typedMemberId})}),Object.keys(t).length>0&&(b.typedMembers=t,console.log(`πŸ” [Submission] Adding cross-role typed members for ${e.id}/${n.columnId}:`,t))}}r===o&&console.warn("[DUPLICATE DEBUG] Final submission entry:",b),t.push(b)}});const n=this._repeatCounts[e.id]||0;if(n>0&&e.fields.some(e=>{var t;return null==(t=e.crossRoleTypedMembers)?void 0:t.length}))for(let o=1;o<=n;o++){const r=`${e.id}__repeat_${o}`;e.fields.forEach(o=>{var n,s,a,l,d;const c=null==(n=this._formData[r])?void 0:n[o.columnId];if(null==c||""===c)return;const p=this._findColumnByIdInSection(o.columnId,i),h=null==(s=this._periodData[r])?void 0:s[o.columnId],u={conceptId:e.id,draftInstanceId:r,columnId:o.columnId,value:c,period:{type:e.periodType||"duration"}};"instant"===e.periodType?u.period.date=(null==h?void 0:h.instantDate)||(null==h?void 0:h.endDate)||(null==p?void 0:p.periodEndDate)||o.periodInstantDate||o.periodEndDate||o.periodStartDate||this.periodStartDate:(u.period.startDate=(null==h?void 0:h.startDate)||(null==p?void 0:p.periodStartDate)||o.periodStartDate||this.periodStartDate,u.period.endDate=(null==h?void 0:h.endDate)||(null==p?void 0:p.periodEndDate)||o.periodEndDate||this.periodEndDate);const m=null==(a=this._unitData[r])?void 0:a[o.columnId];if(m&&(u.unit=m),"dimension"===(null==p?void 0:p.type)&&(null==(l=p.dimensionData)?void 0:l.dimensionIdKey)&&(u.dimension=p.dimensionData.dimensionIdKey),null==(d=o.crossRoleTypedMembers)?void 0:d.length){const e=`${r}__${o.columnId}`,t=this._typedMemberData[e];if(t){const e={};o.crossRoleTypedMembers.forEach(i=>{const o=t[i.axisId];null!=o&&""!==o&&(e[i.axisId]={value:o,memberName:i.typedMemberId})}),Object.keys(e).length>0&&(u.typedMembers=e)}}t.push(u)})}}e.children&&this._processConceptsForSubmission(e.children,t,i)})}_handleReset(){this._formData={...this.initialData},this._touched.clear(),this._dirty=!1,this._submitted=!1,this._preservedFormData={},this._preservedTypedMemberData={},console.log("πŸ”„ Form reset - all data and preserved data cleared"),this._validateForm(),this.requestUpdate(),this.dispatchEvent(new CustomEvent("form-reset",{detail:{},bubbles:!0}))}_getFormState(){return{data:this._formData,errors:this._errors,touched:this._touched,dirty:this._dirty,valid:this._valid,submitted:this._submitted}}_analyzeAllVisibleRoles(){if(this._currentSchema&&this._currentSchema.sections&&0!==this._currentSchema.sections.length){console.log(`πŸ” Analyzing ${this._currentSchema.sections.length} visible roles for initial border status...`);for(const e of this._currentSchema.sections)this._analyzeAndLogRole(e.id);console.log("βœ… Initial border status analysis complete for all visible roles")}else console.log("⏭️ No sections to analyze for initial border status")}_handleRoleContextMenu(e,t,i){e.preventDefault(),e.stopPropagation(),this._contextMenuX=e.clientX,this._contextMenuY=e.clientY,this._contextMenuRoleId=t,this._showRoleContextMenu=!0,console.log(`πŸ–±οΈ Context menu opened for role: ${i} (ID: ${t})`),this.requestUpdate()}_closeRoleContextMenu(){this._showRoleContextMenu=!1,this._contextMenuRoleId=null,this.requestUpdate()}_handleRemoveRole(){if(!this._contextMenuRoleId)return void this._closeRoleContextMenu();const e=this._allSections.find(e=>e.id===this._contextMenuRoleId),t=(null==e?void 0:e.title)||"Unknown";if(console.log("πŸ—‘οΈ Removing role from side panel:"),console.log(` - Role ID: ${this._contextMenuRoleId}`),console.log(` - Role Title: ${t}`),Array.isArray(this._selectedRoleIds)&&(this._selectedRoleIds.length>0&&"object"==typeof this._selectedRoleIds[0]?this._selectedRoleIds=this._selectedRoleIds.filter(e=>e.roleId!==this._contextMenuRoleId):this._selectedRoleIds=this._selectedRoleIds.filter(e=>e!==this._contextMenuRoleId)),console.log(`βœ… Role removed from _selectedRoleIds. Remaining roles: ${this._selectedRoleIds.length}`),this._activeSidePanelRoleId===this._contextMenuRoleId){const e=this._getRoleIdsArray();this._activeSidePanelRoleId=e.length>0?e[0]:null,console.log(`πŸ“Œ Active role changed to: ${this._activeSidePanelRoleId||"None"}`)}this._applyRoleFilter(),this.dispatchEvent(new CustomEvent("role-removed",{detail:{roleId:this._contextMenuRoleId,roleTitle:t,remainingRolesCount:this._selectedRoleIds.length},bubbles:!0,composed:!0})),console.log(`βœ… Role "${t}" successfully removed from side panel`),console.log("ℹ️ User can re-add this role using the Filter Roles dialog"),this._closeRoleContextMenu()}_handleRoleCompletedChange(e,t){t?this._roleCompletedStates.set(e,!0):this._roleCompletedStates.delete(e),this._roleCompletedStates=new Map(this._roleCompletedStates),this._handleSaveDraft("auto")}_handleSidePanelRoleClick(e){this._activeSidePanelRoleId&&this._activeSidePanelRoleId!==e&&this._analyzeAndLogRole(this._activeSidePanelRoleId),this._activeSidePanelRoleId=e}_analyzeAndLogRole(e){const t=this._allSections.find(t=>t.id===e);if(!t)return void console.warn(`⚠️ Section not found for roleId: ${e}`);console.warn("\n========================================"),console.warn(`πŸ” ANALYZING ROLE: "${t.title}"`),console.warn("========================================"),this.masterData?console.warn("πŸ“¦ masterData keys:",Object.keys(this.masterData)):console.warn("πŸ“¦ masterData: NOT PROVIDED");const i=[];this._collectAllFields(t.concepts||[],new Set((t.columns||[]).map(e=>e.id)),t.columns||[],i);const o=this._roleHasErrors(e),r=i.filter(e=>e.isEmpty).length,n=i.filter(e=>!e.isEmpty).length;let s;console.warn("\nπŸ“ˆ SUMMARY:"),console.warn(` Total Fields: ${i.length}`),console.warn(` Filled: ${n}`),console.warn(` Empty: ${r}`),console.warn(` Has Errors: ${o}`),o?(s="INVALID",console.warn("\nπŸ”΄ RESULT: INVALID (contains validation errors)")):0===n?(s="UNTOUCHED",console.warn("\n⬜ RESULT: UNTOUCHED (no data entered)")):r>0?(s="INCOMPLETE",console.warn(`\n🟠 RESULT: INCOMPLETE (${r} field(s) blank)`)):(s="COMPLETE",console.warn("\n🟒 RESULT: COMPLETE (all fields filled)")),console.warn("========================================\n"),"INVALID"===s||("UNTOUCHED"===s?(this._roleBorderStatuses.set(e,"untouched"),this._roleBorderStatuses=new Map(this._roleBorderStatuses)):"INCOMPLETE"===s?(this._roleBorderStatuses.set(e,"incomplete"),this._roleBorderStatuses=new Map(this._roleBorderStatuses)):(this._roleBorderStatuses.set(e,"complete"),this._roleBorderStatuses=new Map(this._roleBorderStatuses)))}_collectAllFields(e,t,i,o){var r,n,s;for(const a of e)if(a.abstract)a.children&&a.children.length>0&&this._collectAllFields(a.children,t,i,o);else{if(a.fields&&a.fields.length>0){const e=a.fields.filter(e=>t.has(e.columnId));for(const t of e){const e=a.id,l=t.conceptId;let d=null==(r=this._formData[e])?void 0:r[t.columnId];void 0===d&&e!==l&&(d=null==(n=this._formData[l])?void 0:n[t.columnId]);const c=null==(s=this._effectiveMasterData)?void 0:s[l];(null==d||"string"==typeof d&&""===d.trim())&&void 0!==c&&(d=c,console.warn(` πŸ“¦ Using masterData value for: ${l} [${t.columnId}] = ${JSON.stringify(d)}`));let p=null==d||"string"==typeof d&&""===d.trim();if(p&&a.facts&&a.facts.length>0){const e=i.find(e=>e.id===t.columnId),o={conceptId:l,columnId:t.columnId,periodStartDate:t.periodStartDate||(null==e?void 0:e.periodStartDate),periodEndDate:t.periodEndDate||(null==e?void 0:e.periodEndDate),periodInstantDate:t.periodInstantDate||("instant"===t.periodType?t.periodEndDate||t.periodStartDate:void 0),periodType:t.periodType,dimensionData:null==e?void 0:e.dimensionData},r=E.findMatchingFact(a.facts,o);r&&null!==r.value&&void 0!==r.value&&""!==r.value&&(d=r.value,p=!1)}o.push({conceptId:l,columnId:t.columnId,value:d,isEmpty:p})}}a.children&&a.children.length>0&&this._collectAllFields(a.children,t,i,o)}}_handleSidePanelSearchInput(e){const t=e.target;this._sidePanelSearchQuery=t.value}_clearSidePanelSearch(){var e;this._sidePanelSearchQuery="";const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".side-panel-search-input");t&&(t.value="",t.focus())}_toggleSidePanelCollapse(){this._sidePanelCollapsed=!this._sidePanelCollapsed}_isSectionBlank(e){const t=e.columns||this._columns,i=e=>{var o;for(const r of e){if(!r.abstract)for(const e of t){const t=null==(o=this._formData[r.id])?void 0:o[e.id];if(null!=t&&""!==t)return!0}if(r.children&&r.children.length>0&&i(r.children))return!0}return!1};return!i(e.concepts)}_getConceptSearchMatchIds(e){var t,i,o;const r=new Set;if(!e.trim()||!(null==(i=null==(t=this.xbrlInput)?void 0:t.presentation)?void 0:i.length))return r;const n=e.toLowerCase().trim(),s=e=>{var t,i,o;for(const a of e){let e=(null==(t=a.conceptName)?void 0:t.toLowerCase().includes(n))||(null==(i=a.id)?void 0:i.toLowerCase().includes(n));!e&&Array.isArray(a.labels)&&(e=a.labels.some(e=>{var t;return null==(t=e.label)?void 0:t.toLowerCase().includes(n)})),e&&r.add(a.id),(null==(o=a.children)?void 0:o.length)&&s(a.children)}};for(const a of this.xbrlInput.presentation)for(const e of a.roles||[])s((null==(o=e.presentationLinkbase)?void 0:o.concepts)||[]);return r}_isSectionConceptSearchMatch(e,t){if(0===t.size)return!1;const i=e=>{var o;for(const r of e){if(t.has(r.originalConceptId))return!0;if((null==(o=r.children)?void 0:o.length)&&i(r.children))return!0}return!1};return i(e.concepts)}_filterSidePanelSections(e){if(!this._sidePanelSearchQuery.trim())return e;const t=this._sidePanelSearchQuery.toLowerCase().trim();return e.filter(e=>{var i,o,r;const n=e.title.toLowerCase().includes(t),s=e.id.toLowerCase().includes(t),a=(null==(i=e.description)?void 0:i.toLowerCase().includes(t))||!1,l=(null==(r=null==(o=e.metadata)?void 0:o.roleURI)?void 0:r.toLowerCase().includes(t))||!1;return n||s||a||l})}_renderAdminModeContent(t){var i,o;if(!t)return e.html`
2899
2899
  <div class="admin-mode-container">
2900
2900
  <p>No role selected</p>
2901
2901
  </div>