jupiter-dynamic-forms 1.13.0 → 1.14.1

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.
package/dist/index.js CHANGED
@@ -14,50 +14,50 @@
14
14
  * Copyright 2017 Google LLC
15
15
  * SPDX-License-Identifier: BSD-3-Clause
16
16
  */
17
- const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,i)=>{const{kind:o,metadata:r}=i;let n=globalThis.litPropertyMetadata.get(r);if(void 0===n&&globalThis.litPropertyMetadata.set(r,n=new Map),"setter"===o&&((e=Object.create(e)).wrapped=!0),n.set(i.name,e),"accessor"===o){const{name:o}=i;return{set(i){const r=t.get.call(this);t.set.call(this,i),this.requestUpdate(o,r,e)},init(t){return void 0!==t&&this.C(o,void 0,e,t),t}}}if("setter"===o){const{name:o}=i;return function(i){const r=this[o];t.call(this,i),this.requestUpdate(o,r,e)}}throw Error("Unsupported decorator location: "+o)};function I(e){return(t,i)=>"object"==typeof i?S(e,t,i):((e,t,i)=>{const o=t.hasOwnProperty(i);return t.constructor.createProperty(i,e),o?Object.getOwnPropertyDescriptor(t,i):void 0})(e,t,i)}
17
+ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},I=(e=$,t,i)=>{const{kind:o,metadata:r}=i;let n=globalThis.litPropertyMetadata.get(r);if(void 0===n&&globalThis.litPropertyMetadata.set(r,n=new Map),"setter"===o&&((e=Object.create(e)).wrapped=!0),n.set(i.name,e),"accessor"===o){const{name:o}=i;return{set(i){const r=t.get.call(this);t.set.call(this,i),this.requestUpdate(o,r,e)},init(t){return void 0!==t&&this.C(o,void 0,e,t),t}}}if("setter"===o){const{name:o}=i;return function(i){const r=this[o];t.call(this,i),this.requestUpdate(o,r,e)}}throw Error("Unsupported decorator location: "+o)};function S(e){return(t,i)=>"object"==typeof i?I(e,t,i):((e,t,i)=>{const o=t.hasOwnProperty(i);return t.constructor.createProperty(i,e),o?Object.getOwnPropertyDescriptor(t,i):void 0})(e,t,i)}
18
18
  /**
19
19
  * @license
20
20
  * Copyright 2017 Google LLC
21
21
  * SPDX-License-Identifier: BSD-3-Clause
22
- */function w(e){return I({...e,state:!0,attribute:!1})}class C{static validateField(e,t,i,o,r,n=[]){const s=[];for(const a of n){const n=this.validateRule(e,t,i,o,r,a);n&&s.push(n)}return s}static validateRule(e,t,i,o,r,n){const s=null==o||""===o;switch(n.type){case"required":if(s)return this.createError(e,t,i,n);break;case"min":if(!s&&"number"==typeof o&&o<n.value)return this.createError(e,t,i,n);break;case"max":if(!s&&"number"==typeof o&&o>n.value)return this.createError(e,t,i,n);break;case"minLength":if(!s&&"string"==typeof o&&o.length<n.value)return this.createError(e,t,i,n);break;case"maxLength":if(!s&&"string"==typeof o&&o.length>n.value)return this.createError(e,t,i,n);break;case"pattern":if(!s&&"string"==typeof o){if(!new RegExp(n.value).test(o))return this.createError(e,t,i,n)}break;case"email":if(!s&&"string"==typeof o){if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o))return this.createError(e,t,i,n)}break;case"url":if(!s&&"string"==typeof o)try{new URL(o)}catch{return this.createError(e,t,i,n)}break;case"custom":break;default:console.warn(`Unknown validation rule type: ${n.type}`)}return null}static createError(e,t,i,o){return{fieldId:e,conceptId:t,columnId:i,message:o.message,severity:o.severity||"error",rule:o}}static validateDataType(e,t){if(null==e||""===e)return{valid:!0,convertedValue:e};switch(t){case"number":case"decimal":case"currency":case"percentage":{const t=Number(e);return isNaN(t)?{valid:!1,error:"Invalid number format"}:{valid:!0,convertedValue:t}}case"date":{const t=new Date(e);return isNaN(t.getTime())?{valid:!1,error:"Invalid date format"}:{valid:!0,convertedValue:t.toISOString().split("T")[0]}}case"datetime":{const t=new Date(e);return isNaN(t.getTime())?{valid:!1,error:"Invalid datetime format"}:{valid:!0,convertedValue:t.toISOString()}}case"boolean":if("boolean"==typeof e)return{valid:!0,convertedValue:e};if("string"==typeof e){const t=e.toLowerCase();if("true"===t||"1"===t)return{valid:!0,convertedValue:!0};if("false"===t||"0"===t)return{valid:!0,convertedValue:!1}}return{valid:!1,error:"Invalid boolean format"};case"text":case"textarea":case"email":case"url":case"tel":return{valid:!0,convertedValue:String(e)};default:return{valid:!0,convertedValue:e}}}static formatValue(e,t,i="en-US"){if(null==e)return"";switch(t){case"number":return new Intl.NumberFormat(i).format(Number(e));case"decimal":return new Intl.NumberFormat(i,{minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(e));case"currency":return new Intl.NumberFormat(i,{style:"currency",currency:"USD"}).format(Number(e));case"percentage":return new Intl.NumberFormat(i,{style:"percent",minimumFractionDigits:2}).format(Number(e)/100);case"date":return new Date(e).toLocaleDateString(i);case"datetime":return new Date(e).toLocaleString(i);default:return String(e)}}}class T{static formatPeriodDisplay(e,t){if(!e||!t)return`${e} / ${t}`;const i=e.substring(0,4);return i===t.substring(0,4)?i:`${e} / ${t}`}static createUniqueConceptId(e,t){let i=e.id;if(e.preferredLabel&&""!==e.preferredLabel.trim()){const t=e.preferredLabel.match(/\/([^\/]+)$/),o=t?t[1]:e.preferredLabel.replace(/[^a-zA-Z0-9]/g,"_");i=`${e.id}_${o}`}if(t){return`${i}__${this.createSectionHash(t)}`}return i}static createSectionHash(e){let t=0;for(let i=0;i<e.length;i++){t=(t<<5)-t+e.charCodeAt(i),t&=t}return Math.abs(t).toString(36).substr(0,6)}static buildFormSchema(e,t,i,o="en",r){var n;if(!e.presentation||0===e.presentation.length)throw new Error("XBRL presentation data is required");const s=e.presentation[0],a=null==(n=e.hypercubes)?void 0:n[0],l=[];return[...s.roles].sort((e,t)=>e.role.localeCompare(t.role)).forEach(e=>{const n=this.buildSectionFromRole(e,t,i,a,o,r);this.assignFieldColumnIds(n),l.push(n)}),{formId:`xbrl-form-${Date.now()}`,title:`XBRL Form - ${this.extractEntityName(s.entrypoint)}`,description:"Dynamic form generated from XBRL taxonomy data",version:"1.0.0",sections:l}}static buildSectionFromRole(e,t,i,o,r="en",n){var s;const a=this.extractRoleTitle(e.role),l=this.getAllNonAbstractConcepts(e),d=new Set(l.filter(e=>e.periodType).map(e=>e.periodType)),c=null==o?void 0:o.roles.find(t=>t.roleId===e.id),p=null==n?void 0:n[e.id],h=this.generateDefaultColumnsForRole(e,t||"2025-01-01",i||"2025-12-31",c,l,d,p),u={periodTypes:d,availableColumnIds:h.map(e=>e.id)},m=[];return(null==(s=e.presentationLinkbase)?void 0:s.concepts)&&e.presentationLinkbase.concepts.forEach(o=>{const n=this.buildConceptTree(o,0,t,i,u,e.id,r);n&&m.push(n)}),{id:e.id,title:a,description:e.description||`Section for ${a}`,concepts:m,columns:h,expanded:!1,metadata:{roleURI:e.roleURI,originalRole:e.role},showPeriodControl:d.size>1,showPreviousYear:!0===e.showPreviousYear,instant:!0===e.instant,duration:!0===e.duration}}static buildConceptTree(e,t,i,o,r,n,s="en"){const a=this.getPreferredLabel(e.labels,s),l=[];if(!e.elementAbstract){let t=[];t=(null==r?void 0:r.availableColumnIds)&&r.availableColumnIds.length>0?r.availableColumnIds:["duration"],t.forEach(t=>{const r=this.createFieldFromConcept(e,i,o,t);r&&l.push(r)})}const d=[];e.children&&e.children.length>0&&e.children.forEach(e=>{const a=this.buildConceptTree(e,t+1,i,o,r,n,s);a&&d.push(a)});return l.length>0||d.length>0?{id:this.createUniqueConceptId(e,n),originalConceptId:e.id,name:e.conceptName,label:a,description:`${e.conceptName} (${e.type})`,type:e.type,level:t,children:d,fields:l,collapsed:t>0,abstract:e.elementAbstract,periodType:e.periodType}:null}static createFieldFromConcept(e,t,i,o){const r=this.mapXBRLTypeToFieldType(e.type),n=this.getPreferredLabel(e.labels);let s;s=o||"duration";const a={id:`${e.id}_${s}_field`,conceptId:e.id,columnId:s,type:r,label:n,placeholder:`Enter ${n.toLowerCase()}`,required:!1,disabled:e.elementAbstract,defaultValue:null,periodType:"instant"===e.periodType||"duration"===e.periodType?e.periodType:void 0,periodStartDate:t||"2025-01-01",periodEndDate:i||"2025-12-31",periodInstantDate:"instant"===e.periodType?i||t||"2025-01-01":void 0};return"nl-cd_DescriptionLocationNL__a64trl"===e.id&&console.log(`đŸ—ī¸ [Field Creation] Concept: ${e.id}, periodType from concept: ${e.periodType}, Field periodType: ${a.periodType}, ColumnId: ${s}`),a}static mapXBRLTypeToFieldType(e){return{"xbrli:stringItemType":"text","xbrli:monetaryItemType":"currency","xbrli:integerItemType":"number","xbrli:decimalItemType":"decimal","xbrli:percentItemType":"percentage","xbrli:dateItemType":"date","xbrli:booleanItemType":"boolean","dtr-types:domainItemType":"select","bw2-titel9:chamberOfCommerceRegistrationNumberItemType":"text"}[e]||"text"}static getPreferredLabel(e,t="en"){if(!e||0===e.length)return"Unnamed Concept";const i=e.filter(e=>e.lang===t),o=i.length>0?i:e,r=o.find(e=>e.preferredLabel);if(r)return r.label;const n=o.find(e=>"http://www.xbrl.org/2003/role/label"===e.role);if(n)return n.label;const s=o.find(e=>"http://www.xbrl.org/2003/role/terseLabel"===e.role);return s?s.label:o.length>0?o[0].label:e[0].label}static assignFieldColumnIds(e){if(!e.columns||0===e.columns.length)return;const t=e.columns.map(e=>e.id);e.concepts.forEach(e=>{this.assignColumnIdsToConceptFields(e,t)})}static assignColumnIdsToConceptFields(e,t){e.fields=e.fields.filter(e=>t.includes(e.columnId)),e.children&&e.children.forEach(e=>{this.assignColumnIdsToConceptFields(e,t)})}static countFieldsInTree(e){let t=e.fields.length;return e.children&&e.children.forEach(e=>{t+=this.countFieldsInTree(e)}),t}static getAllNonAbstractConcepts(e){var t;const i=[];return(null==(t=e.presentationLinkbase)?void 0:t.concepts)&&e.presentationLinkbase.concepts.forEach(e=>{this.collectNonAbstractConcepts(e,i)}),i}static collectNonAbstractConcepts(e,t){e.elementAbstract||t.push(e),e.children&&e.children.length>0&&e.children.forEach(e=>{this.collectNonAbstractConcepts(e,t)})}static generateDefaultColumnsForRole(e,t,i,o,r,n,s){var a,l;const d=r||this.getAllNonAbstractConcepts(e),c=n||new Set(d.filter(e=>e.periodType).map(e=>e.periodType));if(0===d.length)return[{id:"default",title:"Value",description:"Default value column",type:"base",order:0,removable:!1}];let p=[];if(1===(null==(a=null==o?void 0:o.items)?void 0:a.length)){const e=o.items[0];1===e.dimensions.length?p=this.generateSingleDimensionColumns(e.dimensions[0],t,i,c):e.dimensions.length>1&&(p=this.generateMultiDimensionColumns(e.dimensions,t,i,c)),s&&(p=this.filterColumnsByPeriodPreferences(p,s))}else(null==(l=null==o?void 0:o.items)?void 0:l.length)&&o.items.length;const h=[];p.length>0?h.push(...p):0===c.size?h.push({id:"default",title:this.formatPeriodDisplay(t,i),description:"",type:"base",order:0,removable:!1,periodStartDate:t,periodEndDate:i}):h.push({id:"duration",title:this.formatPeriodDisplay(t,i),description:"",type:"base",order:0,removable:!1,periodStartDate:t,periodEndDate:i});let u=h;if(s&&(u=this.filterColumnsByPeriodPreferences(h,s)),null==s?void 0:s.showPreviousYear){const e=this.generatePreviousYearColumns(u,t,i);u=[...u,...e]}return u}static getPreviousYearDate(e){try{const t=new Date(e);return t.setFullYear(t.getFullYear()-1),t.toISOString().split("T")[0]}catch(t){return console.error(`Error calculating previous year for date ${e}:`,t),e}}static generatePreviousYearColumns(e,t,i){const o=[],r=this.getPreviousYearDate(t),n=this.getPreviousYearDate(i);return e.forEach((e,t)=>{let i=e.title,s="",a="";e.dimensionData?(i=e.title,s=this.formatPeriodDisplay(r,n),a=`${e.id}_prev`):(i=this.formatPeriodDisplay(r,n),s="",a=`duration_prev_${t}`),o.push({...e,id:a,title:i,description:s,order:e.order+100,removable:!1,periodStartDate:r,periodEndDate:n,dimensionData:e.dimensionData?{...e.dimensionData,dimensionId:`${e.dimensionData.dimensionId}_prev`}:void 0})}),o}static filterColumnsByPeriodPreferences(e,t){return e.filter(e=>{var i,o,r,n;const s=e.id.includes("duration")||(null==(o=null==(i=e.dimensionData)?void 0:i.dimensionId)?void 0:o.includes("duration")),a=e.id.includes("instant")||(null==(n=null==(r=e.dimensionData)?void 0:r.dimensionId)?void 0:n.includes("instant"));return!s&&!a||!(s&&!t.showDuration)&&!(a&&!t.showInstant)})}static generateSingleDimensionColumns(e,t,i,o){var r,n,s;if(e.typedMember&&(!e.members||0===e.members.length)){const n=(null==(r=e.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:r.label)||e.conceptName,s={axisId:e.id,axisLabel:n,typedMemberId:e.typedMember.id,dimensionKey:`${n} | [Typed Input]`,dimensionIdKey:`${e.id}|[typed]`},a=[];return 0===o.size?a.push({id:"typed-default",title:n,description:"Typed dimension input column",type:"dimension",dimensionData:{dimensionId:"typed-default",axisId:s.axisId,memberId:"[typed]",memberValue:"Typed Input",memberLabel:"Typed Input",axis:s.axisLabel,axisLabel:s.axisLabel,memberKey:s.dimensionKey,dimensionIdKey:s.dimensionIdKey,hasTypedMembers:!0,typedMemberId:s.typedMemberId,typedMembers:[{axisId:s.axisId,axisLabel:s.axisLabel,typedMemberId:s.typedMemberId,memberLabel:s.axisLabel}]},order:0,removable:!1,periodStartDate:t,periodEndDate:i}):1===o.size&&o.has("instant")?a.push({id:"typed-instant",title:`${n} [Typed Input Available]`,description:i,type:"dimension",dimensionData:{dimensionId:"typed-instant",axisId:s.axisId,memberId:"[typed]",memberValue:"Typed Input",memberLabel:"Typed Input",axis:s.axisLabel,axisLabel:s.axisLabel,memberKey:s.dimensionKey,dimensionIdKey:s.dimensionIdKey,hasTypedMembers:!0,typedMemberId:s.typedMemberId,typedMembers:[{axisId:s.axisId,axisLabel:s.axisLabel,typedMemberId:s.typedMemberId,memberLabel:s.axisLabel}]},order:0,removable:!1,periodStartDate:i,periodEndDate:i}):(1===o.size&&o.has("duration"),a.push({id:"typed-duration",title:`${n} [Typed Input Available]`,description:this.formatPeriodDisplay(t,i),type:"dimension",dimensionData:{dimensionId:"typed-duration",axisId:s.axisId,memberId:"[typed]",memberValue:"Typed Input",memberLabel:"Typed Input",axis:s.axisLabel,axisLabel:s.axisLabel,memberKey:s.dimensionKey,dimensionIdKey:s.dimensionIdKey,hasTypedMembers:!0,typedMemberId:s.typedMemberId,typedMembers:[{axisId:s.axisId,axisLabel:s.axisLabel,typedMemberId:s.typedMemberId,memberLabel:s.axisLabel}]},order:0,removable:!1,periodStartDate:t,periodEndDate:i})),a}if(!e.members||!Array.isArray(e.members))return[];if(0===e.members.length)return[];const a=(null==(n=e.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:n.label)||e.conceptName,l=e.members[0],d=(null==(s=l.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:s.label)||l.conceptName,c={axisId:e.id,axisLabel:a,memberId:l.id,memberLabel:d,dimensionKey:`${a} | ${d}`,dimensionIdKey:`${e.id} | ${l.id}`},p=[];return 0===o.size?p.push({id:"default",title:c.memberLabel,description:"Default value column",type:"dimension",dimensionData:{dimensionId:"default",axisId:c.axisId,memberId:c.memberId,memberValue:c.memberLabel,memberLabel:c.memberLabel,axis:c.axisLabel,axisLabel:c.axisLabel,memberKey:c.dimensionKey,dimensionIdKey:c.dimensionIdKey},order:0,removable:!1,periodStartDate:t,periodEndDate:i}):1===o.size&&o.has("instant")?p.push({id:"instant",title:`${c.memberLabel}`,description:i,type:"dimension",dimensionData:{dimensionId:"instant",axisId:c.axisId,memberId:c.memberId,memberValue:c.memberLabel,memberLabel:c.memberLabel,axis:c.axisLabel,axisLabel:c.axisLabel,memberKey:c.dimensionKey,dimensionIdKey:c.dimensionIdKey},order:0,removable:!1,periodStartDate:i,periodEndDate:i}):1===o.size&&o.has("duration")?p.push({id:"duration",title:`${c.memberLabel}`,description:`${t} / ${i}`,type:"dimension",dimensionData:{dimensionId:"duration",axisId:c.axisId,memberId:c.memberId,memberValue:c.memberLabel,memberLabel:c.memberLabel,axis:c.axisLabel,axisLabel:c.axisLabel,memberKey:c.dimensionKey,dimensionIdKey:c.dimensionIdKey},order:0,removable:!1,periodStartDate:t,periodEndDate:i}):p.push({id:"duration",title:`${c.memberLabel}`,description:this.formatPeriodDisplay(t,i),type:"dimension",dimensionData:{dimensionId:"duration",axisId:c.axisId,memberId:c.memberId,memberValue:c.memberLabel,memberLabel:c.memberLabel,axis:c.axisLabel,axisLabel:c.axisLabel,memberKey:c.dimensionKey,dimensionIdKey:c.dimensionIdKey},order:0,removable:!1,periodStartDate:t,periodEndDate:i}),p}static generateMultiDimensionColumns(e,t,i,o){e.some(e=>e.typedMember);const r=e.filter(e=>!!e.typedMember||!!(e.members&&Array.isArray(e.members)&&e.members.length>0));if(0===r.length)return[];const n=r.map(e=>{var t;const i=(null==(t=e.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:t.label)||e.conceptName;if(e.typedMember)return{id:e.id,axisLabel:i,isTyped:!0,typedMemberId:e.typedMember.id,members:[{id:"[typed]",label:`${i} [Typed Input Available]`}]};const o=this.getAllDimensionMembers(e.members);return{id:e.id,axisLabel:i,isTyped:!1,members:o.map(e=>{var t;return{id:e.id,label:(null==(t=e.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:t.label)||e.conceptName}})}}),s=this.generateDimensionCombinations(n),a=[];return s.forEach((e,o)=>{const r=e.map(e=>e.memberLabel).join(" | "),n=e.filter(e=>e.isTyped),s=e.filter(e=>!e.isTyped),l={dimensionId:`multi_${o}`,memberValue:r,memberLabel:r,combinations:s.map(e=>({axisId:e.axisId,axisLabel:e.axisLabel,memberId:e.memberId,memberLabel:e.memberLabel})),typedMembers:n.map(e=>({axisId:e.axisId,axisLabel:e.axisLabel,typedMemberId:e.typedMemberId,memberLabel:e.memberLabel})),hasTypedMembers:n.length>0,memberKey:r,dimensionIdKey:[...s.map(e=>`${e.axisId}|${e.memberId}`),...n.map(e=>`${e.axisId}|[typed]`)].join("::")};a.push({id:`duration_${o}`,title:`${r}`,description:this.formatPeriodDisplay(t,i),type:"dimension",dimensionData:{...l,dimensionId:`duration_${o}`},order:o,removable:!1,periodStartDate:t,periodEndDate:i})}),a}static getAllDimensionMembers(e){if(!e||!Array.isArray(e))return[];const t=[];return e.forEach(e=>{t.push(e),e.children&&e.children.length>0&&t.push(...this.getAllDimensionMembers(e.children))}),t}static generateDimensionCombinations(e){if(0===e.length)return[];if(1===e.length)return e[0].members.map(t=>[{axisId:e[0].id,axisLabel:e[0].axisLabel,memberId:t.id,memberLabel:t.label,isTyped:e[0].isTyped||!1,typedMemberId:e[0].typedMemberId}]);const[t,...i]=e,o=this.generateDimensionCombinations(i),r=[];return t.members.forEach(e=>{0===o.length?r.push([{axisId:t.id,axisLabel:t.axisLabel,memberId:e.id,memberLabel:e.label,isTyped:t.isTyped||!1,typedMemberId:t.typedMemberId}]):o.forEach(i=>{r.push([{axisId:t.id,axisLabel:t.axisLabel,memberId:e.id,memberLabel:e.label,isTyped:t.isTyped||!1,typedMemberId:t.typedMemberId},...i])})}),r}static formatDateForDisplay(e){try{return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch{return e}}static extractEntityName(e){try{const t=new URL(e).pathname.split("/");return t[t.length-1].replace(".xsd","").replace(/[^a-zA-Z0-9]/g," ").trim()||"Entity"}catch{return"Entity"}}static extractRoleTitle(e){const t=e.match(/^\[[\d]+\]\s*(.+)$/);return t?t[1].trim():e}static extractRoleOrder(e){const t=e.match(/^\[([\d]+)\]/);return t?parseInt(t[1],10):0}static buildColumnsFromHypercubes(){return[{id:"default",label:"Values",type:"data"}]}}const F={en:{form:{loading:"Loading form...",submit:"Submit",saveDraft:"Save Draft",errors:"Errors",modified:"Modified",valid:"Valid",yes:"Yes",no:"No",noRoleSelected:"No Role Selected",pleaseSelectRole:"Please select a role from the list on the left.",expandPanel:"Expand side panel",collapsePanel:"Collapse side panel"},filter:{selectRoles:"Select Roles",filterRoles:"Filter Roles",title:"Filter Roles",description:"Select the roles you want to display in the form. You can search and choose specific roles to focus on or manage all available roles.",searchPlaceholder:"Search..",clearSearch:"Clear search",showingResults:"Showing",of:"of",roles:"roles",matching:"matching",selectAll:"Select All",selectNone:"Select None",selectFiltered:"Select Filtered",deselectFiltered:"Deselect Filtered",deselectAll:"Deselect All",reset:"Reset",noRolesFound:"No roles found matching",tryDifferentSearch:"Try a different search term or clear the search.",noRolesAvailable:"No roles available.",cancel:"Cancel",applyFilter:"Apply Filter",showPeriodColumn:"Show Period Column:",additionalOptions:"Additional Options:",showPreviousYear:"Show previous year",duration:"Duration",instant:"Instant",uri:"URI"},column:{addColumn:"Add Column",columnOptions:"Column Options",columnType:"Column Type",instantSingleDate:"Instant (single date)",durationDates:"Duration (start and end dates)",instantDate:"Instant Date",startPeriodDate:"Start Period Date",endPeriodDate:"End Period Date",availableDimensions:"Available Dimensions",dimensionsDescription:"Select dimensions to include in the column. Domain members can be selected here, while typed dimension values will be entered directly in the column header.",enterValue:"Enter value for",enterValuePlaceholder:"Enter value...",selectMember:"Select member:",noMembersAvailable:"No members available for this dimension",cancel:"Cancel",removeColumn:"Remove column",required:"required"},section:{enterPlaceholder:"Enter"},admin:{title:"Configure Roles",description:"Select which roles should display the 'Show Previous Year' checkbox and configure period type columns."},validation:{summary:"Please fix the following errors before submitting:",errorsFound:"errors found"}},nl:{form:{loading:"Formulier laden...",submit:"Indienen",saveDraft:"Concept opslaan",errors:"Fouten",modified:"Gewijzigd",valid:"Geldig",yes:"Ja",no:"Nee",noRoleSelected:"Geen rol geselecteerd",pleaseSelectRole:"Selecteer een rol uit de lijst aan de linkerkant.",expandPanel:"Zijpaneel uitvouwen",collapsePanel:"Zijpaneel inklappen"},filter:{selectRoles:"Rollen selecteren",filterRoles:"Rollen filteren",title:"Rollen filteren",description:"Selecteer de rollen die u in het formulier wilt weergeven. U kunt zoeken en specifieke rollen kiezen om op te focussen of alle beschikbare rollen beheren.",searchPlaceholder:"Zoek rollen op naam, ID of URI...",clearSearch:"Zoekopdracht wissen",showingResults:"Weergeven",of:"van",roles:"rollen",matching:"overeenkomend met",selectAll:"Alles selecteren",selectNone:"Niets selecteren",selectFiltered:"Gefilterd selecteren",deselectFiltered:"Gefilterd deselecteren",deselectAll:"Alles deselecteren",reset:"Resetten",noRolesFound:"Geen rollen gevonden die overeenkomen met",tryDifferentSearch:"Probeer een andere zoekterm of wis de zoekopdracht.",noRolesAvailable:"Geen rollen beschikbaar.",cancel:"Annuleren",applyFilter:"Filter toepassen",showPeriodColumn:"Periodekolom weergeven:",additionalOptions:"Aanvullende opties:",showPreviousYear:"Vorig jaar weergeven",duration:"Duur",instant:"Moment",uri:"URI"},column:{addColumn:"Kolom toevoegen",columnOptions:"Kolomopties",columnType:"Kolomtype",instantSingleDate:"Moment (enkele datum)",durationDates:"Duur (begin- en einddatum)",instantDate:"Momentdatum",startPeriodDate:"Startdatum periode",endPeriodDate:"Einddatum periode",availableDimensions:"Beschikbare dimensies",dimensionsDescription:"Selecteer dimensies om in de kolom op te nemen. Domeinleden kunnen hier worden geselecteerd, terwijl getypte dimensiewaarden direct in de kolomkop worden ingevoerd.",enterValue:"Voer waarde in voor",enterValuePlaceholder:"Voer waarde in...",selectMember:"Selecteer lid:",noMembersAvailable:"Geen leden beschikbaar voor deze dimensie",cancel:"Annuleren",removeColumn:"Kolom verwijderen",required:"verplicht"},section:{enterPlaceholder:"Invoeren"},admin:{title:"Rollen configureren",description:"Selecteer welke rollen het selectievakje 'Vorig jaar weergeven' moeten weergeven en configureer periodetype kolommen."},validation:{summary:"Corrigeer de volgende fouten voordat u indient:",errorsFound:"fouten gevonden"}}};class E{static setLanguage(e){F[e]?this.currentLanguage=e:(console.warn(`Language '${e}' not supported, falling back to 'en'`),this.currentLanguage="en")}static getLanguage(){return this.currentLanguage}static t(e,t){const i=e.split(".");let o=F[this.currentLanguage];for(const r of i){if(!o||"object"!=typeof o||!(r in o))return console.warn(`Translation key '${e}' not found for language '${this.currentLanguage}'`),e;o=o[r]}return t&&"string"==typeof o?this.interpolate(o,t):o}static interpolate(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,i)=>i in t?String(t[i]):e)}static has(e){const t=e.split(".");let i=F[this.currentLanguage];for(const o of t){if(!i||"object"!=typeof i||!(o in i))return!1;i=i[o]}return void 0!==i}static getAvailableLanguages(){return Object.keys(F)}}E.currentLanguage="en";class k{constructor(e=!1){this.DRAFT_DATA_KEY="jupiter-form-draft-data",this.DRAFT_METADATA_KEY="jupiter-form-draft-metadata",this.STORAGE_VERSION="1.0",this._storage=e?sessionStorage:localStorage,console.log(`💾 DraftStorageService initialized (using ${e?"sessionStorage":"localStorage"})`)}saveDraft(e,t){try{const i={formData:e,metadata:{...t,savedAt:(new Date).toISOString()},version:this.STORAGE_VERSION};return this._storage.setItem(this.DRAFT_DATA_KEY,JSON.stringify(i.formData)),this._storage.setItem(this.DRAFT_METADATA_KEY,JSON.stringify(i.metadata)),console.log("✅ Draft saved successfully",{entries:e.length,timestamp:i.metadata.savedAt,roles:t.selectedRoleIds.length,customColumns:t.customColumns.length}),!0}catch(i){return console.error("❌ Failed to save draft:",i),!1}}loadDraft(){try{const e=this._storage.getItem(this.DRAFT_DATA_KEY),t=this._storage.getItem(this.DRAFT_METADATA_KEY);if(!e||!t)return console.log("â„šī¸ No saved draft found"),null;const i=JSON.parse(e),o=JSON.parse(t);return console.log("✅ Draft loaded successfully",{entries:i.length,savedAt:o.savedAt,roles:o.selectedRoleIds.length,customColumns:o.customColumns.length}),{formData:i,metadata:o,version:this.STORAGE_VERSION}}catch(e){return console.error("❌ Failed to load draft:",e),null}}hasDraft(){return null!==this._storage.getItem(this.DRAFT_DATA_KEY)&&null!==this._storage.getItem(this.DRAFT_METADATA_KEY)}getDraftMetadata(){try{const e=this._storage.getItem(this.DRAFT_METADATA_KEY);return e?JSON.parse(e):null}catch(e){return console.error("❌ Failed to load draft metadata:",e),null}}clearDraft(){try{return this._storage.removeItem(this.DRAFT_DATA_KEY),this._storage.removeItem(this.DRAFT_METADATA_KEY),console.log("đŸ—‘ī¸ Draft cleared successfully"),!0}catch(e){return console.error("❌ Failed to clear draft:",e),!1}}getDraftAge(){const e=this.getDraftMetadata();if(!e)return null;const t=new Date(e.savedAt);return(new Date).getTime()-t.getTime()}isDraftStale(e){const t=this.getDraftAge();return null!==t&&t>e}extractCustomColumns(e){const t=[];return e.forEach(e=>{e.columns&&Array.isArray(e.columns)&&e.columns.forEach(i=>{t.push({sectionId:e.id,columnId:i.id,label:i.title,periodType:this._inferPeriodTypeFromColumn(i),date:i.periodStartDate,startDate:i.periodStartDate,endDate:i.periodEndDate,dimensionData:i.dimensionData})})}),t}_inferPeriodTypeFromColumn(e){return e.periodStartDate&&e.periodEndDate?"duration":"instant"}createMetadataSnapshot(e,t,i,o,r,n,s,a){return{periodStartDate:e,periodEndDate:t,language:i,selectedRoleIds:o,customColumns:this.extractCustomColumns(r),typedMemberData:n,periodPreferences:s,periodData:a,schemaVersion:this.STORAGE_VERSION}}validateDraftCompatibility(e,t,i){const o=[];e.metadata.periodStartDate!==t&&o.push(`Draft period start (${e.metadata.periodStartDate}) differs from current (${t})`),e.metadata.periodEndDate!==i&&o.push(`Draft period end (${e.metadata.periodEndDate}) differs from current (${i})`);const r=this.getDraftAge();r&&r>6048e5&&o.push(`Draft is ${Math.floor(r/864e5)} days old`);return{compatible:0===o.length,warnings:o}}}const P={"nl-types:formattedExplanationItemType":{fieldType:"textarea",placeholder:"Enter detailed explanation..."},"nl-types:monetaryNoDecimals20ItemType":{fieldType:"number",htmlInputType:"number",allowDecimals:!1,step:1,placeholder:"Enter amount (no decimals)"},"xbrli:monetaryItemType":{fieldType:"currency",htmlInputType:"number",allowDecimals:!0,step:.01,placeholder:"0.00"},"xbrli:stringItemType":{fieldType:"text",htmlInputType:"text",placeholder:"Enter text"},"xbrli:dateItemType":{fieldType:"date",htmlInputType:"date"},"xbrli:dateTimeItemType":{fieldType:"datetime",htmlInputType:"datetime-local"},"xbrli:integerItemType":{fieldType:"integer",htmlInputType:"number",allowDecimals:!1,step:1,placeholder:"Enter whole number"},"xbrli:nonNegativeIntegerItemType":{fieldType:"integer",htmlInputType:"number",allowDecimals:!1,min:0,step:1,placeholder:"Enter positive number"},"xbrli:positiveIntegerItemType":{fieldType:"integer",htmlInputType:"number",allowDecimals:!1,min:1,step:1,placeholder:"Enter positive number"},"xbrli:decimalItemType":{fieldType:"decimal",htmlInputType:"number",allowDecimals:!0,step:"any",placeholder:"Enter decimal value"},"xbrli:sharesItemType":{fieldType:"number",htmlInputType:"number",allowDecimals:!0,min:0,step:.01,placeholder:"Enter number of shares"},"xbrli:shares":{fieldType:"number",htmlInputType:"number",allowDecimals:!0,min:0,step:.01,placeholder:"Enter number of shares"},"xbrli:gYearItemType":{fieldType:"number",htmlInputType:"number",allowDecimals:!1,min:1900,max:2100,step:1,placeholder:"YYYY"},"xbrli:booleanItemType":{fieldType:"boolean"},"xbrli:pureItemType":{fieldType:"percentage",htmlInputType:"number",allowDecimals:!0,step:.01,placeholder:"Enter percentage"},"xbrli:percentItemType":{fieldType:"percentage",htmlInputType:"number",allowDecimals:!0,step:.01,placeholder:"Enter percentage"},"xbrli:emailItemType":{fieldType:"email",htmlInputType:"email",placeholder:"email@example.com"},"xbrli:urlItemType":{fieldType:"url",htmlInputType:"url",placeholder:"https://example.com"},"xbrli:telephoneItemType":{fieldType:"tel",htmlInputType:"tel",placeholder:"+1 (555) 000-0000"}};function A(e){if(!e)return{fieldType:"text",htmlInputType:"text",placeholder:"Enter value"};if(P[e])return P[e];const t=e.toLowerCase();if(t.includes("monetary"))return t.includes("nodecimals")||t.includes("no-decimals")?{fieldType:"number",htmlInputType:"number",allowDecimals:!1,step:1,placeholder:"Enter amount (no decimals)"}:{fieldType:"currency",htmlInputType:"number",allowDecimals:!0,step:.01,placeholder:"0.00"};if(t.includes("explanation")||t.includes("description")||t.includes("notes")||t.includes("formatted"))return{fieldType:"textarea",placeholder:"Enter detailed information..."};if(t.includes("date"))return t.includes("time")?{fieldType:"datetime",htmlInputType:"datetime-local"}:{fieldType:"date",htmlInputType:"date"};if(t.includes("boolean")||t.includes("bool"))return{fieldType:"boolean"};if(t.includes("integer")||t.includes("int")){const e=t.includes("nonnegative")||t.includes("non-negative");return{fieldType:"integer",htmlInputType:"number",allowDecimals:!1,min:t.includes("positive")?1:e?0:void 0,step:1,placeholder:"Enter whole number"}}return t.includes("decimal")||t.includes("numeric")||t.includes("number")?{fieldType:"decimal",htmlInputType:"number",allowDecimals:!0,step:"any",placeholder:"Enter decimal value"}:t.includes("percent")||t.includes("pure")?{fieldType:"percentage",htmlInputType:"number",allowDecimals:!0,step:.01,placeholder:"Enter percentage"}:{fieldType:"text",htmlInputType:"text",placeholder:"Enter value"}}function j(e){return"textarea"===e}function R(e){return"boolean"===e}function L(e){return["number","decimal","integer","currency","percentage"].includes(e)}var M=Object.defineProperty,z=Object.getOwnPropertyDescriptor,J=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?z(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&&M(t,i,n),n};exports.JupiterFormField=class extends e.LitElement{constructor(){super(...arguments),this.value=null,this.disabled=!1,this.locale="en-US",this.hideLabel=!1,this._errors=[],this._touched=!1,this._showPeriodPopup=!1}willUpdate(e){(e.has("value")||e.has("field"))&&this._validateField(),e.has("field")&&this.field&&(this.conceptId.includes("DescriptionLocationNL")||this.columnId.startsWith("col-"))&&console.log(`📅 [FormField willUpdate] Concept ${this.conceptId}, Column ${this.columnId}: field.periodType=${this.field.periodType}, field.periodStartDate=${this.field.periodStartDate}, field.periodEndDate=${this.field.periodEndDate}, field.periodInstantDate=${this.field.periodInstantDate}`)}_validateField(){var e;(null==(e=this.field)?void 0:e.validation)&&(this._errors=C.validateField(this.field.id,this.conceptId,this.columnId,this.value,this.field.type,this.field.validation))}_handleInput(e){const t=e.target;let i=t.value;"number"===this.field.type||"decimal"===this.field.type?i=""===i?null:Number(i):"boolean"===this.field.type&&(i=t.checked),this.value=i,this._touched=!0,this.dispatchEvent(new CustomEvent("field-change",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId,value:i,oldValue:this.value},bubbles:!0}))}_handleFocus(){this.dispatchEvent(new CustomEvent("field-focus",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId},bubbles:!0}))}_handleBlur(){this._touched=!0,this.dispatchEvent(new CustomEvent("field-blur",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId},bubbles:!0}))}_handlePeriodIconClick(){this._showPeriodPopup=!0}_closePeriodPopup(){this._showPeriodPopup=!1}_handlePopupOverlayClick(e){e.target===e.currentTarget&&this._closePeriodPopup()}_handlePeriodChange(e,t){const i=e.target.value;console.log(`📅 [FormField] Period change detected: type=${t}, value=${i}, conceptId=${this.conceptId}, columnId=${this.columnId}`),"instant"===t?this.periodInstantDate=i:"start"===t?this.periodStartDate=i:"end"===t&&(this.periodEndDate=i),console.log(`📅 [FormField] Updated local period values: startDate=${this.periodStartDate}, endDate=${this.periodEndDate}, instantDate=${this.periodInstantDate}`),this.dispatchEvent(new CustomEvent("period-change",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId,periodType:this.field.periodType,periodStartDate:this.periodStartDate,periodEndDate:this.periodEndDate,periodInstantDate:this.periodInstantDate},bubbles:!0,composed:!0})),console.log("🚀 [FormField] Dispatched period-change event with detail:",{conceptId:this.conceptId,columnId:this.columnId,periodType:this.field.periodType})}_renderInput(){var t;const i=this._errors.some(e=>"error"===e.severity),o=this._errors.some(e=>"warning"===e.severity),r="field-input "+(i?"error":o?"warning":""),n=`${this.conceptId}__${this.columnId}`,s=`data[${this.conceptId}][${this.columnId}]`,a=A(this.conceptType);this.conceptType;const l=a.fieldType||this.field.type||"text";if("textarea"===l||j(l))return e.html`
22
+ */function w(e){return S({...e,state:!0,attribute:!1})}class C{static validateField(e,t,i,o,r,n=[]){const s=[];for(const a of n){const n=this.validateRule(e,t,i,o,r,a);n&&s.push(n)}return s}static validateRule(e,t,i,o,r,n){const s=null==o||""===o;switch(n.type){case"required":if(s)return this.createError(e,t,i,n);break;case"min":if(!s&&"number"==typeof o&&o<n.value)return this.createError(e,t,i,n);break;case"max":if(!s&&"number"==typeof o&&o>n.value)return this.createError(e,t,i,n);break;case"minLength":if(!s&&"string"==typeof o&&o.length<n.value)return this.createError(e,t,i,n);break;case"maxLength":if(!s&&"string"==typeof o&&o.length>n.value)return this.createError(e,t,i,n);break;case"pattern":if(!s&&"string"==typeof o){if(!new RegExp(n.value).test(o))return this.createError(e,t,i,n)}break;case"email":if(!s&&"string"==typeof o){if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o))return this.createError(e,t,i,n)}break;case"url":if(!s&&"string"==typeof o)try{new URL(o)}catch{return this.createError(e,t,i,n)}break;case"custom":break;default:console.warn(`Unknown validation rule type: ${n.type}`)}return null}static createError(e,t,i,o){return{fieldId:e,conceptId:t,columnId:i,message:o.message,severity:o.severity||"error",rule:o}}static validateDataType(e,t){if(null==e||""===e)return{valid:!0,convertedValue:e};switch(t){case"number":case"decimal":case"currency":case"percentage":{const t=Number(e);return isNaN(t)?{valid:!1,error:"Invalid number format"}:{valid:!0,convertedValue:t}}case"date":{const t=new Date(e);return isNaN(t.getTime())?{valid:!1,error:"Invalid date format"}:{valid:!0,convertedValue:t.toISOString().split("T")[0]}}case"datetime":{const t=new Date(e);return isNaN(t.getTime())?{valid:!1,error:"Invalid datetime format"}:{valid:!0,convertedValue:t.toISOString()}}case"boolean":if("boolean"==typeof e)return{valid:!0,convertedValue:e};if("string"==typeof e){const t=e.toLowerCase();if("true"===t||"1"===t)return{valid:!0,convertedValue:!0};if("false"===t||"0"===t)return{valid:!0,convertedValue:!1}}return{valid:!1,error:"Invalid boolean format"};case"text":case"textarea":case"email":case"url":case"tel":return{valid:!0,convertedValue:String(e)};default:return{valid:!0,convertedValue:e}}}static formatValue(e,t,i="en-US"){if(null==e)return"";switch(t){case"number":return new Intl.NumberFormat(i).format(Number(e));case"decimal":return new Intl.NumberFormat(i,{minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(e));case"currency":return new Intl.NumberFormat(i,{style:"currency",currency:"USD"}).format(Number(e));case"percentage":return new Intl.NumberFormat(i,{style:"percent",minimumFractionDigits:2}).format(Number(e)/100);case"date":return new Date(e).toLocaleDateString(i);case"datetime":return new Date(e).toLocaleString(i);default:return String(e)}}}class F{static formatPeriodDisplay(e,t){if(!e||!t)return`${e} / ${t}`;const i=e.substring(0,4);return i===t.substring(0,4)?i:`${e} / ${t}`}static createUniqueConceptId(e,t){let i=e.id;if(e.preferredLabel&&""!==e.preferredLabel.trim()){const t=e.preferredLabel.match(/\/([^\/]+)$/),o=t?t[1]:e.preferredLabel.replace(/[^a-zA-Z0-9]/g,"_");i=`${e.id}_${o}`}if(t){return`${i}__${this.createSectionHash(t)}`}return i}static createSectionHash(e){let t=0;for(let i=0;i<e.length;i++){t=(t<<5)-t+e.charCodeAt(i),t&=t}return Math.abs(t).toString(36).substr(0,6)}static buildFormSchema(e,t,i,o="en",r){var n,s;if(!e.presentation||0===e.presentation.length)throw new Error("XBRL presentation data is required");const a=e.presentation[0],l=null==(n=e.hypercubes)?void 0:n[0],d=Array.isArray(e.datatypes)?e.datatypes:(null==(s=e.datatypes)?void 0:s.concepts)||[],c=[];return[...a.roles].sort((e,t)=>e.role.localeCompare(t.role)).forEach(e=>{const n=this.buildSectionFromRole(e,t,i,l,o,r);d&&d.length>0?(n.datatypes=d,console.log(`✅ [buildFormSchema] Attached ${d.length} datatypes to section ${n.id}`)):console.warn(`âš ī¸ [buildFormSchema] No datatypes available for section ${n.id}`),this.assignFieldColumnIds(n),c.push(n)}),{formId:`xbrl-form-${Date.now()}`,title:`XBRL Form - ${this.extractEntityName(a.entrypoint)}`,description:"Dynamic form generated from XBRL taxonomy data",version:"1.0.0",sections:c}}static buildSectionFromRole(e,t,i,o,r="en",n){var s;const a=this.extractRoleTitle(e.role),l=this.getAllNonAbstractConcepts(e),d=new Set(l.filter(e=>e.periodType).map(e=>e.periodType)),c=null==o?void 0:o.roles.find(t=>t.roleId===e.id),p=null==n?void 0:n[e.id],h=this.generateDefaultColumnsForRole(e,t||"2025-01-01",i||"2025-12-31",c,l,d,p),u={periodTypes:d,availableColumnIds:h.map(e=>e.id)},m=[];return(null==(s=e.presentationLinkbase)?void 0:s.concepts)&&e.presentationLinkbase.concepts.forEach(o=>{const n=this.buildConceptTree(o,0,t,i,u,e.id,r);n&&m.push(n)}),{id:e.id,title:a,description:e.description||`Section for ${a}`,concepts:m,columns:h,expanded:!1,metadata:{roleURI:e.roleURI,originalRole:e.role},showPeriodControl:d.size>1,showPreviousYear:!0===e.showPreviousYear,instant:!0===e.instant,duration:!0===e.duration}}static buildConceptTree(e,t,i,o,r,n,s="en"){const a=this.getPreferredLabel(e.labels,s),l=[];if(!e.elementAbstract){let t=[];t=(null==r?void 0:r.availableColumnIds)&&r.availableColumnIds.length>0?r.availableColumnIds:["duration"],t.forEach(t=>{const r=this.createFieldFromConcept(e,i,o,t);r&&l.push(r)})}const d=[];e.children&&e.children.length>0&&e.children.forEach(e=>{const a=this.buildConceptTree(e,t+1,i,o,r,n,s);a&&d.push(a)});return l.length>0||d.length>0?{id:this.createUniqueConceptId(e,n),originalConceptId:e.id,name:e.conceptName,label:a,description:`${e.conceptName} (${e.type})`,type:e.type,level:t,children:d,fields:l,collapsed:t>0,abstract:e.elementAbstract,periodType:e.periodType}:null}static createFieldFromConcept(e,t,i,o){const r=this.mapXBRLTypeToFieldType(e.type),n=this.getPreferredLabel(e.labels);let s;s=o||"duration";const a={id:`${e.id}_${s}_field`,conceptId:e.id,columnId:s,type:r,label:n,placeholder:`Enter ${n.toLowerCase()}`,required:!1,disabled:e.elementAbstract,defaultValue:null,periodType:"instant"===e.periodType||"duration"===e.periodType?e.periodType:void 0,periodStartDate:t||"2025-01-01",periodEndDate:i||"2025-12-31",periodInstantDate:"instant"===e.periodType?i||t||"2025-01-01":void 0};return"nl-cd_DescriptionLocationNL__a64trl"===e.id&&console.log(`đŸ—ī¸ [Field Creation] Concept: ${e.id}, periodType from concept: ${e.periodType}, Field periodType: ${a.periodType}, ColumnId: ${s}`),a}static mapXBRLTypeToFieldType(e){return{"xbrli:stringItemType":"text","xbrli:monetaryItemType":"currency","xbrli:integerItemType":"number","xbrli:decimalItemType":"decimal","xbrli:percentItemType":"percentage","xbrli:dateItemType":"date","xbrli:booleanItemType":"boolean","dtr-types:domainItemType":"select","bw2-titel9:chamberOfCommerceRegistrationNumberItemType":"text"}[e]||"text"}static getPreferredLabel(e,t="en"){if(!e||0===e.length)return"Unnamed Concept";const i=e.filter(e=>e.lang===t),o=i.length>0?i:e,r=o.find(e=>e.preferredLabel);if(r)return r.label;const n=o.find(e=>"http://www.xbrl.org/2003/role/label"===e.role);if(n)return n.label;const s=o.find(e=>"http://www.xbrl.org/2003/role/terseLabel"===e.role);return s?s.label:o.length>0?o[0].label:e[0].label}static assignFieldColumnIds(e){if(!e.columns||0===e.columns.length)return;const t=e.columns.map(e=>e.id);e.concepts.forEach(e=>{this.assignColumnIdsToConceptFields(e,t)})}static assignColumnIdsToConceptFields(e,t){e.fields=e.fields.filter(e=>t.includes(e.columnId)),e.children&&e.children.forEach(e=>{this.assignColumnIdsToConceptFields(e,t)})}static countFieldsInTree(e){let t=e.fields.length;return e.children&&e.children.forEach(e=>{t+=this.countFieldsInTree(e)}),t}static getAllNonAbstractConcepts(e){var t;const i=[];return(null==(t=e.presentationLinkbase)?void 0:t.concepts)&&e.presentationLinkbase.concepts.forEach(e=>{this.collectNonAbstractConcepts(e,i)}),i}static collectNonAbstractConcepts(e,t){e.elementAbstract||t.push(e),e.children&&e.children.length>0&&e.children.forEach(e=>{this.collectNonAbstractConcepts(e,t)})}static generateDefaultColumnsForRole(e,t,i,o,r,n,s){var a,l;const d=r||this.getAllNonAbstractConcepts(e),c=n||new Set(d.filter(e=>e.periodType).map(e=>e.periodType));if(0===d.length)return[{id:"default",title:"Value",description:"Default value column",type:"base",order:0,removable:!1}];let p=[];if(1===(null==(a=null==o?void 0:o.items)?void 0:a.length)){const e=o.items[0];1===e.dimensions.length?p=this.generateSingleDimensionColumns(e.dimensions[0],t,i,c):e.dimensions.length>1&&(p=this.generateMultiDimensionColumns(e.dimensions,t,i,c)),s&&(p=this.filterColumnsByPeriodPreferences(p,s))}else(null==(l=null==o?void 0:o.items)?void 0:l.length)&&o.items.length;const h=[];p.length>0?h.push(...p):0===c.size?h.push({id:"default",title:this.formatPeriodDisplay(t,i),description:"",type:"base",order:0,removable:!1,periodStartDate:t,periodEndDate:i}):h.push({id:"duration",title:this.formatPeriodDisplay(t,i),description:"",type:"base",order:0,removable:!1,periodStartDate:t,periodEndDate:i});let u=h;if(s&&(u=this.filterColumnsByPeriodPreferences(h,s)),null==s?void 0:s.showPreviousYear){const e=this.generatePreviousYearColumns(u,t,i);u=[...u,...e]}return u}static getPreviousYearDate(e){try{const t=new Date(e);return t.setFullYear(t.getFullYear()-1),t.toISOString().split("T")[0]}catch(t){return console.error(`Error calculating previous year for date ${e}:`,t),e}}static generatePreviousYearColumns(e,t,i){const o=[],r=this.getPreviousYearDate(t),n=this.getPreviousYearDate(i);return e.forEach((e,t)=>{let i=e.title,s="",a="";e.dimensionData?(i=e.title,s=this.formatPeriodDisplay(r,n),a=`${e.id}_prev`):(i=this.formatPeriodDisplay(r,n),s="",a=`duration_prev_${t}`),o.push({...e,id:a,title:i,description:s,order:e.order+100,removable:!1,periodStartDate:r,periodEndDate:n,dimensionData:e.dimensionData?{...e.dimensionData,dimensionId:`${e.dimensionData.dimensionId}_prev`}:void 0})}),o}static filterColumnsByPeriodPreferences(e,t){return e.filter(e=>{var i,o,r,n;const s=e.id.includes("duration")||(null==(o=null==(i=e.dimensionData)?void 0:i.dimensionId)?void 0:o.includes("duration")),a=e.id.includes("instant")||(null==(n=null==(r=e.dimensionData)?void 0:r.dimensionId)?void 0:n.includes("instant"));return!s&&!a||!(s&&!t.showDuration)&&!(a&&!t.showInstant)})}static generateSingleDimensionColumns(e,t,i,o){var r,n,s;if(e.typedMember&&(!e.members||0===e.members.length)){const n=(null==(r=e.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:r.label)||e.conceptName,s={axisId:e.id,axisLabel:n,typedMemberId:e.typedMember.id,dimensionKey:`${n} | [Typed Input]`,dimensionIdKey:`${e.id}|[typed]`},a=[];return 0===o.size?a.push({id:"typed-default",title:n,description:"Typed dimension input column",type:"dimension",dimensionData:{dimensionId:"typed-default",axisId:s.axisId,memberId:"[typed]",memberValue:"Typed Input",memberLabel:"Typed Input",axis:s.axisLabel,axisLabel:s.axisLabel,memberKey:s.dimensionKey,dimensionIdKey:s.dimensionIdKey,hasTypedMembers:!0,typedMemberId:s.typedMemberId,typedMembers:[{axisId:s.axisId,axisLabel:s.axisLabel,typedMemberId:s.typedMemberId,memberLabel:s.axisLabel}]},order:0,removable:!1,periodStartDate:t,periodEndDate:i}):1===o.size&&o.has("instant")?a.push({id:"typed-instant",title:`${n} [Typed Input Available]`,description:i,type:"dimension",dimensionData:{dimensionId:"typed-instant",axisId:s.axisId,memberId:"[typed]",memberValue:"Typed Input",memberLabel:"Typed Input",axis:s.axisLabel,axisLabel:s.axisLabel,memberKey:s.dimensionKey,dimensionIdKey:s.dimensionIdKey,hasTypedMembers:!0,typedMemberId:s.typedMemberId,typedMembers:[{axisId:s.axisId,axisLabel:s.axisLabel,typedMemberId:s.typedMemberId,memberLabel:s.axisLabel}]},order:0,removable:!1,periodStartDate:i,periodEndDate:i}):(1===o.size&&o.has("duration"),a.push({id:"typed-duration",title:`${n} [Typed Input Available]`,description:this.formatPeriodDisplay(t,i),type:"dimension",dimensionData:{dimensionId:"typed-duration",axisId:s.axisId,memberId:"[typed]",memberValue:"Typed Input",memberLabel:"Typed Input",axis:s.axisLabel,axisLabel:s.axisLabel,memberKey:s.dimensionKey,dimensionIdKey:s.dimensionIdKey,hasTypedMembers:!0,typedMemberId:s.typedMemberId,typedMembers:[{axisId:s.axisId,axisLabel:s.axisLabel,typedMemberId:s.typedMemberId,memberLabel:s.axisLabel}]},order:0,removable:!1,periodStartDate:t,periodEndDate:i})),a}if(!e.members||!Array.isArray(e.members))return[];if(0===e.members.length)return[];const a=(null==(n=e.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:n.label)||e.conceptName,l=e.members[0],d=(null==(s=l.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:s.label)||l.conceptName,c={axisId:e.id,axisLabel:a,memberId:l.id,memberLabel:d,dimensionKey:`${a} | ${d}`,dimensionIdKey:`${e.id} | ${l.id}`},p=[];return 0===o.size?p.push({id:"default",title:c.memberLabel,description:"Default value column",type:"dimension",dimensionData:{dimensionId:"default",axisId:c.axisId,memberId:c.memberId,memberValue:c.memberLabel,memberLabel:c.memberLabel,axis:c.axisLabel,axisLabel:c.axisLabel,memberKey:c.dimensionKey,dimensionIdKey:c.dimensionIdKey},order:0,removable:!1,periodStartDate:t,periodEndDate:i}):1===o.size&&o.has("instant")?p.push({id:"instant",title:`${c.memberLabel}`,description:i,type:"dimension",dimensionData:{dimensionId:"instant",axisId:c.axisId,memberId:c.memberId,memberValue:c.memberLabel,memberLabel:c.memberLabel,axis:c.axisLabel,axisLabel:c.axisLabel,memberKey:c.dimensionKey,dimensionIdKey:c.dimensionIdKey},order:0,removable:!1,periodStartDate:i,periodEndDate:i}):1===o.size&&o.has("duration")?p.push({id:"duration",title:`${c.memberLabel}`,description:`${t} / ${i}`,type:"dimension",dimensionData:{dimensionId:"duration",axisId:c.axisId,memberId:c.memberId,memberValue:c.memberLabel,memberLabel:c.memberLabel,axis:c.axisLabel,axisLabel:c.axisLabel,memberKey:c.dimensionKey,dimensionIdKey:c.dimensionIdKey},order:0,removable:!1,periodStartDate:t,periodEndDate:i}):p.push({id:"duration",title:`${c.memberLabel}`,description:this.formatPeriodDisplay(t,i),type:"dimension",dimensionData:{dimensionId:"duration",axisId:c.axisId,memberId:c.memberId,memberValue:c.memberLabel,memberLabel:c.memberLabel,axis:c.axisLabel,axisLabel:c.axisLabel,memberKey:c.dimensionKey,dimensionIdKey:c.dimensionIdKey},order:0,removable:!1,periodStartDate:t,periodEndDate:i}),p}static generateMultiDimensionColumns(e,t,i,o){e.some(e=>e.typedMember);const r=e.filter(e=>!!e.typedMember||!!(e.members&&Array.isArray(e.members)&&e.members.length>0));if(0===r.length)return[];const n=r.map(e=>{var t;const i=(null==(t=e.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:t.label)||e.conceptName;if(e.typedMember)return{id:e.id,axisLabel:i,isTyped:!0,typedMemberId:e.typedMember.id,members:[{id:"[typed]",label:`${i} [Typed Input Available]`}]};const o=this.getAllDimensionMembers(e.members);return{id:e.id,axisLabel:i,isTyped:!1,members:o.map(e=>{var t;return{id:e.id,label:(null==(t=e.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:t.label)||e.conceptName}})}}),s=this.generateDimensionCombinations(n),a=[];return s.forEach((e,o)=>{const r=e.map(e=>e.memberLabel).join(" | "),n=e.filter(e=>e.isTyped),s=e.filter(e=>!e.isTyped),l={dimensionId:`multi_${o}`,memberValue:r,memberLabel:r,combinations:s.map(e=>({axisId:e.axisId,axisLabel:e.axisLabel,memberId:e.memberId,memberLabel:e.memberLabel})),typedMembers:n.map(e=>({axisId:e.axisId,axisLabel:e.axisLabel,typedMemberId:e.typedMemberId,memberLabel:e.memberLabel})),hasTypedMembers:n.length>0,memberKey:r,dimensionIdKey:[...s.map(e=>`${e.axisId}|${e.memberId}`),...n.map(e=>`${e.axisId}|[typed]`)].join("::")};a.push({id:`duration_${o}`,title:`${r}`,description:this.formatPeriodDisplay(t,i),type:"dimension",dimensionData:{...l,dimensionId:`duration_${o}`},order:o,removable:!1,periodStartDate:t,periodEndDate:i})}),a}static getAllDimensionMembers(e){if(!e||!Array.isArray(e))return[];const t=[];return e.forEach(e=>{t.push(e),e.children&&e.children.length>0&&t.push(...this.getAllDimensionMembers(e.children))}),t}static generateDimensionCombinations(e){if(0===e.length)return[];if(1===e.length)return e[0].members.map(t=>[{axisId:e[0].id,axisLabel:e[0].axisLabel,memberId:t.id,memberLabel:t.label,isTyped:e[0].isTyped||!1,typedMemberId:e[0].typedMemberId}]);const[t,...i]=e,o=this.generateDimensionCombinations(i),r=[];return t.members.forEach(e=>{0===o.length?r.push([{axisId:t.id,axisLabel:t.axisLabel,memberId:e.id,memberLabel:e.label,isTyped:t.isTyped||!1,typedMemberId:t.typedMemberId}]):o.forEach(i=>{r.push([{axisId:t.id,axisLabel:t.axisLabel,memberId:e.id,memberLabel:e.label,isTyped:t.isTyped||!1,typedMemberId:t.typedMemberId},...i])})}),r}static formatDateForDisplay(e){try{return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch{return e}}static extractEntityName(e){try{const t=new URL(e).pathname.split("/");return t[t.length-1].replace(".xsd","").replace(/[^a-zA-Z0-9]/g," ").trim()||"Entity"}catch{return"Entity"}}static extractRoleTitle(e){const t=e.match(/^\[[\d]+\]\s*(.+)$/);return t?t[1].trim():e}static extractRoleOrder(e){const t=e.match(/^\[([\d]+)\]/);return t?parseInt(t[1],10):0}static buildColumnsFromHypercubes(){return[{id:"default",label:"Values",type:"data"}]}}const T={en:{form:{loading:"Loading form...",submit:"Submit",saveDraft:"Save Draft",errors:"Errors",modified:"Modified",valid:"Valid",yes:"Yes",no:"No",noRoleSelected:"No Role Selected",pleaseSelectRole:"Please select a role from the list on the left.",expandPanel:"Expand side panel",collapsePanel:"Collapse side panel"},filter:{selectRoles:"Select Roles",filterRoles:"Filter Roles",title:"Filter Roles",description:"Select the roles you want to display in the form. You can search and choose specific roles to focus on or manage all available roles.",searchPlaceholder:"Search..",clearSearch:"Clear search",showingResults:"Showing",of:"of",roles:"roles",matching:"matching",selectAll:"Select All",selectNone:"Select None",selectFiltered:"Select Filtered",deselectFiltered:"Deselect Filtered",deselectAll:"Deselect All",reset:"Reset",noRolesFound:"No roles found matching",tryDifferentSearch:"Try a different search term or clear the search.",noRolesAvailable:"No roles available.",cancel:"Cancel",applyFilter:"Apply Filter",showPeriodColumn:"Show Period Column:",additionalOptions:"Additional Options:",showPreviousYear:"Show previous year",duration:"Duration",instant:"Instant",uri:"URI"},column:{addColumn:"Add Column",columnOptions:"Column Options",columnType:"Column Type",instantSingleDate:"Instant (single date)",durationDates:"Duration (start and end dates)",instantDate:"Instant Date",startPeriodDate:"Start Period Date",endPeriodDate:"End Period Date",availableDimensions:"Available Dimensions",dimensionsDescription:"Select dimensions to include in the column. Domain members can be selected here, while typed dimension values will be entered directly in the column header.",enterValue:"Enter value for",enterValuePlaceholder:"Enter value...",selectMember:"Select member:",noMembersAvailable:"No members available for this dimension",cancel:"Cancel",removeColumn:"Remove column",required:"required"},section:{enterPlaceholder:"Enter"},field:{selectOption:"Select an option...",select:"Select...",enterDetailedExplanation:"Enter detailed explanation...",enterAmountNoDecimals:"Enter amount (no decimals)",enterCurrency:"0.00",enterText:"Enter text",enterWholeNumber:"Enter whole number",enterPositiveNumber:"Enter positive number",enterDecimalValue:"Enter decimal value",enterNumberOfShares:"Enter number of shares",yearFormat:"YYYY",enterPercentage:"Enter percentage",emailPlaceholder:"email@example.com",urlPlaceholder:"https://example.com",phonePlaceholder:"+1 (555) 000-0000",enterValue:"Enter value",enterDetailedInformation:"Enter detailed information..."},admin:{title:"Configure Roles",description:"Select which roles should display the 'Show Previous Year' checkbox and configure period type columns."},validation:{summary:"Please fix the following errors before submitting:",errorsFound:"errors found"},error:{popup:{title:"Validation Errors",message:"Please fix the following validation errors before saving:",field:"Field:",value:"Value:",errors:"Errors:",clickToFocus:"Click to focus this field",ok:"OK"}}},nl:{form:{loading:"Formulier laden...",submit:"Indienen",saveDraft:"Concept opslaan",errors:"Fouten",modified:"Gewijzigd",valid:"Geldig",yes:"Ja",no:"Nee",noRoleSelected:"Geen rol geselecteerd",pleaseSelectRole:"Selecteer een rol uit de lijst aan de linkerkant.",expandPanel:"Zijpaneel uitvouwen",collapsePanel:"Zijpaneel inklappen"},filter:{selectRoles:"Rollen selecteren",filterRoles:"Rollen filteren",title:"Rollen filteren",description:"Selecteer de rollen die u in het formulier wilt weergeven. U kunt zoeken en specifieke rollen kiezen om op te focussen of alle beschikbare rollen beheren.",searchPlaceholder:"Zoek rollen op naam, ID of URI...",clearSearch:"Zoekopdracht wissen",showingResults:"Weergeven",of:"van",roles:"rollen",matching:"overeenkomend met",selectAll:"Alles selecteren",selectNone:"Niets selecteren",selectFiltered:"Gefilterd selecteren",deselectFiltered:"Gefilterd deselecteren",deselectAll:"Alles deselecteren",reset:"Resetten",noRolesFound:"Geen rollen gevonden die overeenkomen met",tryDifferentSearch:"Probeer een andere zoekterm of wis de zoekopdracht.",noRolesAvailable:"Geen rollen beschikbaar.",cancel:"Annuleren",applyFilter:"Filter toepassen",showPeriodColumn:"Periodekolom weergeven:",additionalOptions:"Aanvullende opties:",showPreviousYear:"Vorig jaar weergeven",duration:"Duur",instant:"Moment",uri:"URI"},column:{addColumn:"Kolom toevoegen",columnOptions:"Kolomopties",columnType:"Kolomtype",instantSingleDate:"Moment (enkele datum)",durationDates:"Duur (begin- en einddatum)",instantDate:"Momentdatum",startPeriodDate:"Startdatum periode",endPeriodDate:"Einddatum periode",availableDimensions:"Beschikbare dimensies",dimensionsDescription:"Selecteer dimensies om in de kolom op te nemen. Domeinleden kunnen hier worden geselecteerd, terwijl getypte dimensiewaarden direct in de kolomkop worden ingevoerd.",enterValue:"Voer waarde in voor",enterValuePlaceholder:"Voer waarde in...",selectMember:"Selecteer lid:",noMembersAvailable:"Geen leden beschikbaar voor deze dimensie",cancel:"Annuleren",removeColumn:"Kolom verwijderen",required:"verplicht"},section:{enterPlaceholder:"Invoeren"},field:{selectOption:"Selecteer een optie...",select:"Selecteer...",enterDetailedExplanation:"Voer gedetailleerde uitleg in...",enterAmountNoDecimals:"Voer bedrag in (geen decimalen)",enterCurrency:"0,00",enterText:"Voer tekst in",enterWholeNumber:"Voer geheel getal in",enterPositiveNumber:"Voer positief getal in",enterDecimalValue:"Voer decimale waarde in",enterNumberOfShares:"Voer aantal aandelen in",yearFormat:"JJJJ",enterPercentage:"Voer percentage in",emailPlaceholder:"email@voorbeeld.nl",urlPlaceholder:"https://voorbeeld.nl",phonePlaceholder:"+31 (0)20 123 4567",enterValue:"Voer waarde in",enterDetailedInformation:"Voer gedetailleerde informatie in..."},admin:{title:"Rollen configureren",description:"Selecteer welke rollen het selectievakje 'Vorig jaar weergeven' moeten weergeven en configureer periodetype kolommen."},validation:{summary:"Corrigeer de volgende fouten voordat u indient:",errorsFound:"fouten gevonden"},error:{popup:{title:"Validatiefouten",message:"Corrigeer de volgende validatiefouten voordat u opslaat:",field:"Veld:",value:"Waarde:",errors:"Fouten:",clickToFocus:"Klik om dit veld te focussen",ok:"OK"}}}};class E{static setLanguage(e){T[e]?this.currentLanguage=e:(console.warn(`Language '${e}' not supported, falling back to 'en'`),this.currentLanguage="en")}static getLanguage(){return this.currentLanguage}static t(e,t){const i=e.split(".");let o=T[this.currentLanguage];for(const r of i){if(!o||"object"!=typeof o||!(r in o))return console.warn(`Translation key '${e}' not found for language '${this.currentLanguage}'`),e;o=o[r]}return t&&"string"==typeof o?this.interpolate(o,t):o}static interpolate(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,i)=>i in t?String(t[i]):e)}static has(e){const t=e.split(".");let i=T[this.currentLanguage];for(const o of t){if(!i||"object"!=typeof i||!(o in i))return!1;i=i[o]}return void 0!==i}static getAvailableLanguages(){return Object.keys(T)}}E.currentLanguage="en";class k{constructor(e=!1){this.DRAFT_DATA_KEY="jupiter-form-draft-data",this.DRAFT_METADATA_KEY="jupiter-form-draft-metadata",this.STORAGE_VERSION="1.0",this._storage=e?sessionStorage:localStorage,console.log(`💾 DraftStorageService initialized (using ${e?"sessionStorage":"localStorage"})`)}saveDraft(e,t){try{const i={formData:e,metadata:{...t,savedAt:(new Date).toISOString()},version:this.STORAGE_VERSION};return this._storage.setItem(this.DRAFT_DATA_KEY,JSON.stringify(i.formData)),this._storage.setItem(this.DRAFT_METADATA_KEY,JSON.stringify(i.metadata)),console.log("✅ Draft saved successfully",{entries:e.length,timestamp:i.metadata.savedAt,roles:t.selectedRoleIds.length,customColumns:t.customColumns.length}),!0}catch(i){return console.error("❌ Failed to save draft:",i),!1}}loadDraft(){try{const e=this._storage.getItem(this.DRAFT_DATA_KEY),t=this._storage.getItem(this.DRAFT_METADATA_KEY);if(!e||!t)return console.log("â„šī¸ No saved draft found"),null;const i=JSON.parse(e),o=JSON.parse(t);return console.log("✅ Draft loaded successfully",{entries:i.length,savedAt:o.savedAt,roles:o.selectedRoleIds.length,customColumns:o.customColumns.length}),{formData:i,metadata:o,version:this.STORAGE_VERSION}}catch(e){return console.error("❌ Failed to load draft:",e),null}}hasDraft(){return null!==this._storage.getItem(this.DRAFT_DATA_KEY)&&null!==this._storage.getItem(this.DRAFT_METADATA_KEY)}getDraftMetadata(){try{const e=this._storage.getItem(this.DRAFT_METADATA_KEY);return e?JSON.parse(e):null}catch(e){return console.error("❌ Failed to load draft metadata:",e),null}}clearDraft(){try{return this._storage.removeItem(this.DRAFT_DATA_KEY),this._storage.removeItem(this.DRAFT_METADATA_KEY),console.log("đŸ—‘ī¸ Draft cleared successfully"),!0}catch(e){return console.error("❌ Failed to clear draft:",e),!1}}getDraftAge(){const e=this.getDraftMetadata();if(!e)return null;const t=new Date(e.savedAt);return(new Date).getTime()-t.getTime()}isDraftStale(e){const t=this.getDraftAge();return null!==t&&t>e}extractCustomColumns(e){const t=[];return e.forEach(e=>{e.columns&&Array.isArray(e.columns)&&e.columns.forEach(i=>{t.push({sectionId:e.id,columnId:i.id,label:i.title,periodType:this._inferPeriodTypeFromColumn(i),date:i.periodStartDate,startDate:i.periodStartDate,endDate:i.periodEndDate,dimensionData:i.dimensionData})})}),t}_inferPeriodTypeFromColumn(e){return e.periodStartDate&&e.periodEndDate?"duration":"instant"}createMetadataSnapshot(e,t,i,o,r,n,s,a,l){return{periodStartDate:e,periodEndDate:t,language:i,selectedRoleIds:o,customColumns:this.extractCustomColumns(r),typedMemberData:n,periodPreferences:s,periodData:a,unitData:l,schemaVersion:this.STORAGE_VERSION}}validateDraftCompatibility(e,t,i){const o=[];e.metadata.periodStartDate!==t&&o.push(`Draft period start (${e.metadata.periodStartDate}) differs from current (${t})`),e.metadata.periodEndDate!==i&&o.push(`Draft period end (${e.metadata.periodEndDate}) differs from current (${i})`);const r=this.getDraftAge();r&&r>6048e5&&o.push(`Draft is ${Math.floor(r/864e5)} days old`);return{compatible:0===o.length,warnings:o}}}class R{static validateConceptValue(e,t,i){const o=[];if(null==t||""===t)return{valid:!0,errors:[]};if(!e||!i||0===i.length)return{valid:!0,errors:[]};const r=this.findDatatype(e,i);if(!r||!r.validation)return{valid:!0,errors:[]};const n=r.validation,s=String(t);if(n.pattern){const e=this.validatePattern(s,n.pattern);e&&o.push(e)}if(void 0!==n.length){const e=this.validateExactLength(s,n.length);e&&o.push(e)}if(void 0!==n.minLength){const e=this.validateMinLength(s,n.minLength);e&&o.push(e)}if(void 0!==n.maxLength){const e=this.validateMaxLength(s,n.maxLength);e&&o.push(e)}if(void 0!==n.totalDigits){const e=this.validateTotalDigits(s,n.totalDigits);e&&o.push(e)}return{valid:0===o.length,errors:o}}static findDatatype(e,t){let i=t.find(t=>t.type===e);if(i)return i;const o=new Set;let r=e;for(;r&&!o.has(r)&&(o.add(r),i=t.find(e=>e.type===r),i);){if(i.validation)return i;r=i.basetype}}static validatePattern(e,t){try{if(!new RegExp(`^${t}$`).test(e))return{type:"pattern",message:`Value does not match required pattern: ${t}`,expectedValue:t,actualValue:e}}catch(i){return console.error(`Invalid regex pattern: ${t}`,i),{type:"pattern",message:`Invalid pattern configuration: ${t}`,expectedValue:t,actualValue:e}}return null}static validateExactLength(e,t){return e.length!==t?{type:"length",message:`Value must be exactly ${t} characters (current: ${e.length})`,expectedValue:t,actualValue:e.length}:null}static validateMinLength(e,t){return e.length<t?{type:"minLength",message:`Value must be at least ${t} characters (current: ${e.length})`,expectedValue:t,actualValue:e.length}:null}static validateMaxLength(e,t){return e.length>t?{type:"maxLength",message:`Value must not exceed ${t} characters (current: ${e.length})`,expectedValue:t,actualValue:e.length}:null}static validateTotalDigits(e,t){const i=e.replace(/[^\d]/g,"");return i.length>t?{type:"totalDigits",message:`Value must not exceed ${t} total digits (current: ${i.length})`,expectedValue:t,actualValue:i.length}:null}static getValidationRulesSummary(e,t){if(!e||!t)return[];const i=this.findDatatype(e,t);if(!i||!i.validation)return[];const o=i.validation,r=[];return o.pattern&&r.push(`Must match pattern: ${o.pattern}`),void 0!==o.length&&r.push(`Must be exactly ${o.length} characters`),void 0!==o.minLength&&r.push(`Minimum ${o.minLength} characters`),void 0!==o.maxLength&&r.push(`Maximum ${o.maxLength} characters`),void 0!==o.totalDigits&&r.push(`Maximum ${o.totalDigits} total digits`),r}}const P={"nl-types:formattedExplanationItemType":{fieldType:"textarea",placeholder:E.t("field.enterDetailedExplanation")},"nl-types:monetaryNoDecimals20ItemType":{fieldType:"number",htmlInputType:"number",allowDecimals:!1,step:1,placeholder:E.t("field.enterAmountNoDecimals")},"xbrli:monetaryItemType":{fieldType:"currency",htmlInputType:"number",allowDecimals:!0,step:.01,placeholder:E.t("field.enterCurrency")},"xbrli:stringItemType":{fieldType:"text",htmlInputType:"text",placeholder:E.t("field.enterText")},"xbrli:dateItemType":{fieldType:"date",htmlInputType:"date"},"xbrli:dateTimeItemType":{fieldType:"datetime",htmlInputType:"datetime-local"},"xbrli:integerItemType":{fieldType:"integer",htmlInputType:"number",allowDecimals:!1,step:1,placeholder:E.t("field.enterWholeNumber")},"xbrli:nonNegativeIntegerItemType":{fieldType:"integer",htmlInputType:"number",allowDecimals:!1,min:0,step:1,placeholder:E.t("field.enterPositiveNumber")},"xbrli:positiveIntegerItemType":{fieldType:"integer",htmlInputType:"number",allowDecimals:!1,min:1,step:1,placeholder:E.t("field.enterPositiveNumber")},"xbrli:decimalItemType":{fieldType:"decimal",htmlInputType:"number",allowDecimals:!0,step:"any",placeholder:E.t("field.enterDecimalValue")},"xbrli:sharesItemType":{fieldType:"number",htmlInputType:"number",allowDecimals:!0,min:0,step:.01,placeholder:E.t("field.enterNumberOfShares")},"xbrli:shares":{fieldType:"number",htmlInputType:"number",allowDecimals:!0,min:0,step:.01,placeholder:E.t("field.enterNumberOfShares")},"xbrli:gYearItemType":{fieldType:"number",htmlInputType:"number",allowDecimals:!1,min:1900,max:2100,step:1,placeholder:E.t("field.yearFormat")},"xbrli:booleanItemType":{fieldType:"boolean"},"xbrli:pureItemType":{fieldType:"percentage",htmlInputType:"number",allowDecimals:!0,step:.01,placeholder:E.t("field.enterPercentage")},"xbrli:percentItemType":{fieldType:"percentage",htmlInputType:"number",allowDecimals:!0,step:.01,placeholder:E.t("field.enterPercentage")},"xbrli:emailItemType":{fieldType:"email",htmlInputType:"email",placeholder:E.t("field.emailPlaceholder")},"xbrli:urlItemType":{fieldType:"url",htmlInputType:"url",placeholder:E.t("field.urlPlaceholder")},"xbrli:telephoneItemType":{fieldType:"tel",htmlInputType:"tel",placeholder:E.t("field.phonePlaceholder")}};function A(e,t){if(!e)return{fieldType:"text",htmlInputType:"text",placeholder:E.t("field.enterValue")};if(t&&t.length>0){const i=U(e,t);if(i.length>0){const o=J(i,t);return console.log(`🔍 [Type Resolution] ${e} → Chain:`,i,"→ Type:",o.fieldType,o.enumerations?`(${o.enumerations.length} options)`:""),o}}if(console.log(`âš ī¸ [Type Resolution Fallback] Using pattern matching for: ${e}`),P[e])return P[e];const i=e.toLowerCase();if(i.includes("monetary"))return i.includes("nodecimals")||i.includes("no-decimals")?{fieldType:"number",htmlInputType:"number",allowDecimals:!1,step:1,placeholder:E.t("field.enterAmountNoDecimals")}:{fieldType:"currency",htmlInputType:"number",allowDecimals:!0,step:.01,placeholder:E.t("field.enterCurrency")};if(i.includes("explanation")||i.includes("description")||i.includes("notes")||i.includes("formatted"))return{fieldType:"textarea",placeholder:E.t("field.enterDetailedInformation")};if(i.includes("date"))return i.includes("time")?{fieldType:"datetime",htmlInputType:"datetime-local"}:{fieldType:"date",htmlInputType:"date"};if(i.includes("boolean")||i.includes("bool"))return{fieldType:"boolean"};if(i.includes("integer")||i.includes("int")){const e=i.includes("nonnegative")||i.includes("non-negative");return{fieldType:"integer",htmlInputType:"number",allowDecimals:!1,min:i.includes("positive")?1:e?0:void 0,step:1,placeholder:E.t("field.enterWholeNumber")}}return i.includes("decimal")||i.includes("numeric")||i.includes("number")?{fieldType:"decimal",htmlInputType:"number",allowDecimals:!0,step:"any",placeholder:E.t("field.enterDecimalValue")}:i.includes("percent")||i.includes("pure")?{fieldType:"percentage",htmlInputType:"number",allowDecimals:!0,step:.01,placeholder:E.t("field.enterPercentage")}:{fieldType:"text",htmlInputType:"text",placeholder:E.t("field.enterValue")}}function j(e){return"textarea"===e}function L(e){return"boolean"===e}function M(e){return["number","decimal","integer","currency","percentage"].includes(e)}function U(e,t){const i=[];if(!e)return i;if(!t||0===t.length)return i.push(e),i;let o=e;const r=new Set;for(;o;){if(i.push(o),r.has(o)){console.warn(`Circular reference detected in datatype hierarchy for type: ${o}`);break}r.add(o);const e=t.find(e=>e.type===o);if(!e||!e.basetype||""===e.basetype.trim())break;o=e.basetype}return i}function O(e,t){if(e&&0!==e.length&&t&&0!==t.length)for(const i of e){const e=t.find(e=>e.type===i);if(e&&e.enumerations&&e.enumerations.length>0)return e.enumerations.map(e=>({id:e.id||e.value,value:e.value,label:e.value}))}}function J(e,t){if(!e||0===e.length)return{fieldType:"text",htmlInputType:"text",placeholder:E.t("field.enterValue")};if(t&&t.length>0){const i=O(e,t);if(i&&i.length>0)return{fieldType:"select",enumerations:i,placeholder:E.t("field.selectOption")}}const i=e.map(e=>e.toLowerCase()),o=i.join("|");if(e.some(e=>"nl-types:formattedExplanationItemType"===e)||o.includes("formattedexplanation")||o.includes("formatted")&&o.includes("explanation"))return{fieldType:"textarea",placeholder:E.t("field.enterDetailedExplanation")};if(i.some(e=>e.includes("date")))return o.includes("datetime")||o.includes("time")?{fieldType:"datetime",htmlInputType:"datetime-local"}:{fieldType:"date",htmlInputType:"date"};if(i.some(e=>e.includes("boolean")||e.includes("bool")))return{fieldType:"boolean"};if(i.some(e=>e.includes("integer")||"integer"===e)){const e=o.includes("nonnegative")||o.includes("non-negative");return{fieldType:"integer",htmlInputType:"number",allowDecimals:!1,min:o.includes("positive")?1:e?0:void 0,step:1,placeholder:E.t("field.enterWholeNumber")}}return i.some(e=>e.includes("decimal")||"decimal"===e)?o.includes("monetary")||o.includes("currency")?o.includes("nodecimals")||o.includes("no-decimals")||o.includes("nodecimals20")?{fieldType:"number",htmlInputType:"number",allowDecimals:!1,step:1,placeholder:E.t("field.enterAmountNoDecimals")}:{fieldType:"currency",htmlInputType:"number",allowDecimals:!0,step:.01,placeholder:E.t("field.enterCurrency")}:{fieldType:"decimal",htmlInputType:"number",allowDecimals:!0,step:"any",placeholder:E.t("field.enterDecimalValue")}:e.some(e=>"xbrli:stringItemType"===e)||i.some(e=>"string"===e||e.includes("stringitem"))?{fieldType:"text",htmlInputType:"text",placeholder:E.t("field.enterText")}:{fieldType:"text",htmlInputType:"text",placeholder:E.t("field.enterValue")}}var N=Object.defineProperty,z=Object.getOwnPropertyDescriptor,V=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?z(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&&N(t,i,n),n};exports.JupiterFormField=class extends e.LitElement{constructor(){super(...arguments),this.defaultUnits=[],this.value=null,this.disabled=!1,this.locale="en-US",this.hideLabel=!1,this._errors=[],this._xbrlErrors=[],this._touched=!1,this._showPeriodPopup=!1,this._availableUnits=[]}willUpdate(e){var t;(e.has("value")||e.has("field"))&&this._validateField(),e.has("unit")&&this.unit&&(console.log(`đŸˇī¸ [FormField willUpdate] Unit property changed to: ${this.unit}, conceptId: ${this.conceptId}, columnId: ${this.columnId}`),this.dispatchEvent(new CustomEvent("unit-change",{detail:{fieldId:null==(t=this.field)?void 0:t.id,conceptId:this.conceptId,columnId:this.columnId,unit:this.unit},bubbles:!0,composed:!0}))),e.has("field")&&this.field&&(this.conceptId.includes("DescriptionLocationNL")||this.columnId.startsWith("col-"))&&console.log(`📅 [FormField willUpdate] Concept ${this.conceptId}, Column ${this.columnId}: field.periodType=${this.field.periodType}, field.periodStartDate=${this.field.periodStartDate}, field.periodEndDate=${this.field.periodEndDate}, field.periodInstantDate=${this.field.periodInstantDate}`)}_validateField(){var e;(null==(e=this.field)?void 0:e.validation)&&(this._errors=C.validateField(this.field.id,this.conceptId,this.columnId,this.value,this.field.type,this.field.validation))}_handleInput(e){const t=e.target;let i=t.value;"number"===this.field.type||"decimal"===this.field.type?i=""===i?null:Number(i):"boolean"===this.field.type&&(i=t.checked),this.value=i,this._touched=!0,this.dispatchEvent(new CustomEvent("field-change",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId,value:i,oldValue:this.value},bubbles:!0}))}_handleFocus(){this.dispatchEvent(new CustomEvent("field-focus",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId},bubbles:!0}))}_handleBlur(){this._touched=!0,this._validateXBRLDatatype(),console.log(`đŸŸĻ [FormField] Blur event - fieldId: ${this.field.id}, conceptId: ${this.conceptId}, columnId: ${this.columnId}`),console.log("đŸŸĻ [FormField] Current _xbrlErrors:",this._xbrlErrors),console.log("đŸŸĻ [FormField] Current value:",this.value),this.dispatchEvent(new CustomEvent("field-blur",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId,xbrlValidationErrors:this._xbrlErrors},bubbles:!0,composed:!0})),console.log(`đŸŸĻ [FormField] Dispatched field-blur event with ${this._xbrlErrors.length} errors`)}_validateXBRLDatatype(){if(this._xbrlErrors=[],null===this.value||void 0===this.value||""===this.value)return;if(!this.conceptType||!this.datatypes||0===this.datatypes.length)return;const e=R.validateConceptValue(this.conceptType,this.value,this.datatypes);e.valid?console.log(`✅ [FormField] XBRL Validation passed for ${this.conceptId}`):(this._xbrlErrors=e.errors,console.log(`❌ [FormField] XBRL Validation failed for ${this.conceptId}:`,{conceptType:this.conceptType,value:this.value,errors:this._xbrlErrors}))}_handlePeriodIconClick(){if(this._availableUnits=this._collectUnitsForConceptType(),console.log(`📊 [FormField] Collected ${this._availableUnits.length} units for concept ${this.conceptId}:`,this._availableUnits),console.log(`📊 [FormField] Current unit value: ${this.unit}`),console.log(`📊 [FormField] ConceptId: ${this.conceptId}, ColumnId: ${this.columnId}`),!this.unit&&this._availableUnits.length>0){let e=null;const t=this._availableUnits.find(e=>!0===e.isDefault);t?(e=t.id,console.log(`đŸŽ¯ [FormField] Auto-selecting default unit: ${t.id} (${t.label})`)):1===this._availableUnits.length&&(e=this._availableUnits[0].id,console.log(`đŸŽ¯ [FormField] Auto-selecting single available unit: ${e}`)),e&&(this.unit=e,this.dispatchEvent(new CustomEvent("unit-change",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId,unit:this.unit},bubbles:!0,composed:!0})))}else this.unit&&(console.log(`📊 [FormField] Unit already set, dispatching unit-change to ensure parent stores it: ${this.unit}`),this.dispatchEvent(new CustomEvent("unit-change",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId,unit:this.unit},bubbles:!0,composed:!0})));this._showPeriodPopup=!0}_collectUnitsForConceptType(){if(!this.conceptType||!this.datatypes)return[];const e=U(this.conceptType,this.datatypes);console.log(`🔍 [Unit Resolution] Concept: ${this.conceptId}, Type: ${this.conceptType}, BaseType Chain:`,e);for(const t of e){const e=this.datatypes.find(e=>e.type===t);if(e&&e.units&&Array.isArray(e.units)&&e.units.length>0)return console.log(`✅ [Unit Resolution] Found ${e.units.length} units in type: ${t}`),e.units}return console.log(`â„šī¸ [Unit Resolution] No units found for concept ${this.conceptId}`),[]}_closePeriodPopup(){this._showPeriodPopup=!1}_handleUnitChange(e){const t=e.target.value;console.log(`đŸˇī¸ [FormField] Unit change detected: value=${t}, conceptId=${this.conceptId}, columnId=${this.columnId}`),console.log(`đŸˇī¸ [FormField] Previous unit value: ${this.unit}`),this.unit=t,console.log(`đŸˇī¸ [FormField] Updated unit value to: ${this.unit}`);const i={fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId,unit:this.unit};console.log("đŸˇī¸ [FormField] Dispatching unit-change event with detail:",i),this.dispatchEvent(new CustomEvent("unit-change",{detail:i,bubbles:!0,composed:!0})),console.log("đŸˇī¸ [FormField] unit-change event dispatched")}_handlePopupOverlayClick(e){e.target===e.currentTarget&&this._closePeriodPopup()}_handlePeriodChange(e,t){const i=e.target.value;console.log(`📅 [FormField] Period change detected: type=${t}, value=${i}, conceptId=${this.conceptId}, columnId=${this.columnId}`),"instant"===t?this.periodInstantDate=i:"start"===t?this.periodStartDate=i:"end"===t&&(this.periodEndDate=i),console.log(`📅 [FormField] Updated local period values: startDate=${this.periodStartDate}, endDate=${this.periodEndDate}, instantDate=${this.periodInstantDate}`),this.dispatchEvent(new CustomEvent("period-change",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId,periodType:this.field.periodType,periodStartDate:this.periodStartDate,periodEndDate:this.periodEndDate,periodInstantDate:this.periodInstantDate,unit:this.unit},bubbles:!0,composed:!0})),console.log("🚀 [FormField] Dispatched period-change event with detail:",{conceptId:this.conceptId,columnId:this.columnId,periodType:this.field.periodType})}_renderInput(){const t=this._errors.some(e=>"error"===e.severity),i=this._errors.some(e=>"warning"===e.severity),o="field-input "+(t?"error":i?"warning":""),r=`${this.conceptId}__${this.columnId}`,n=`data[${this.conceptId}][${this.columnId}]`,s=A(this.conceptType,this.datatypes);this.conceptType;const a=s.fieldType||this.field.type||"text";if("textarea"===a||j(a))return e.html`
23
23
  <textarea
24
- id="${n}"
25
- name="${s}"
26
- class="${r}"
24
+ id="${r}"
25
+ name="${n}"
26
+ class="${o}"
27
27
  .value="${this.value||""}"
28
28
  ?disabled="${this.disabled||this.field.disabled}"
29
- placeholder="${a.placeholder||this.field.placeholder||""}"
29
+ placeholder="${s.placeholder||this.field.placeholder||""}"
30
30
  @input="${this._handleInput}"
31
31
  @focus="${this._handleFocus}"
32
32
  @blur="${this._handleBlur}"
33
33
  ></textarea>
34
- `;if("select"===l||"select"===this.field.type)return e.html`
34
+ `;if("select"===a||"select"===this.field.type){const t=s.enumerations||this.field.options||[];return e.html`
35
35
  <select
36
- id="${n}"
37
- name="${s}"
38
- class="${r}"
36
+ id="${r}"
37
+ name="${n}"
38
+ class="${o}"
39
39
  .value="${this.value||""}"
40
40
  ?disabled="${this.disabled||this.field.disabled}"
41
41
  @change="${this._handleInput}"
42
42
  @focus="${this._handleFocus}"
43
43
  @blur="${this._handleBlur}"
44
44
  >
45
- <option value="">Select...</option>
46
- ${null==(t=this.field.options)?void 0:t.map(t=>e.html`
47
- <option
48
- value="${t.value}"
49
- ?disabled="${t.disabled}"
50
- ?selected="${this.value===t.value}"
51
- >
52
- ${t.label}
53
- </option>
54
- `)}
45
+ <option value="">${s.placeholder||E.t("field.select")}</option>
46
+ ${t.map(t=>{const i=t.value,o=t.label||t.value,r=t.disabled||!1;return e.html`
47
+ <option
48
+ value="${i}"
49
+ ?disabled="${r}"
50
+ ?selected="${this.value===i}"
51
+ >
52
+ ${o}
53
+ </option>
54
+ `})}
55
55
  </select>
56
- `;if("boolean"===l||R(l))return e.html`
56
+ `}if("boolean"===a||L(a))return e.html`
57
57
  <div class="checkbox-container">
58
58
  <input
59
- id="${n}"
60
- name="${s}"
59
+ id="${r}"
60
+ name="${n}"
61
61
  type="checkbox"
62
62
  class="field-input"
63
63
  .checked="${Boolean(this.value)}"
@@ -68,18 +68,18 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
68
68
  />
69
69
  <span>${this.field.label}</span>
70
70
  </div>
71
- `;const d=a.htmlInputType||this._getInputType(),c=void 0!==a.step?a.step:L(l)?"any":void 0,p=a.min,h=a.max;return e.html`
71
+ `;const l=s.htmlInputType||this._getInputType(),d=void 0!==s.step?s.step:M(a)?"any":void 0,c=s.min,p=s.max;return e.html`
72
72
  <input
73
- id="${n}"
74
- name="${s}"
75
- type="${d}"
76
- class="${r}"
73
+ id="${r}"
74
+ name="${n}"
75
+ type="${l}"
76
+ class="${o}"
77
77
  .value="${this.value||""}"
78
78
  ?disabled="${this.disabled||this.field.disabled}"
79
- placeholder="${a.placeholder||this.field.placeholder||""}"
80
- step="${void 0!==c?c:""}"
81
- min="${void 0!==p?p:""}"
82
- max="${void 0!==h?h:""}"
79
+ placeholder="${s.placeholder||this.field.placeholder||""}"
80
+ step="${void 0!==d?d:""}"
81
+ min="${void 0!==c?c:""}"
82
+ max="${void 0!==p?p:""}"
83
83
  @input="${this._handleInput}"
84
84
  @focus="${this._handleFocus}"
85
85
  @blur="${this._handleBlur}"
@@ -152,6 +152,25 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
152
152
  />
153
153
  </div>
154
154
  `}
155
+
156
+ ${this._availableUnits.length>0?e.html`
157
+ <div class="period-controls">
158
+ <label>Unit:</label>
159
+ <select
160
+ .value="${this.unit||""}"
161
+ @change="${this._handleUnitChange}"
162
+ ?disabled="${this.disabled}"
163
+ class="unit-select"
164
+ >
165
+ <option value="">Select Unit</option>
166
+ ${this._availableUnits.map(t=>e.html`
167
+ <option value="${t.id}" ?selected="${this.unit===t.id}">
168
+ ${t.label||t.id}
169
+ </option>
170
+ `)}
171
+ </select>
172
+ </div>
173
+ `:""}
155
174
  </div>
156
175
  </div>
157
176
  </div>
@@ -187,6 +206,16 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
187
206
  `)}
188
207
  </div>
189
208
  `:""}
209
+
210
+ ${this._xbrlErrors.length>0&&this._touched?e.html`
211
+ <div class="field-errors">
212
+ ${this._xbrlErrors.map(t=>e.html`
213
+ <span class="field-error error">
214
+ ${t.message}
215
+ </span>
216
+ `)}
217
+ </div>
218
+ `:""}
190
219
  </div>
191
220
 
192
221
  ${this._showPeriodPopup?this._renderPeriodPopup():""}
@@ -330,6 +359,28 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
330
359
  box-shadow: 0 0 0 2px var(--jupiter-primary-color-light, rgba(25, 118, 210, 0.2));
331
360
  }
332
361
 
362
+ .period-popup-content .period-controls .unit-select {
363
+ padding: 8px 10px;
364
+ font-size: 14px;
365
+ border: 1px solid var(--jupiter-border-color, #ddd);
366
+ border-radius: 4px;
367
+ background: var(--jupiter-input-background, #fff);
368
+ color: var(--jupiter-text-primary, #333);
369
+ cursor: pointer;
370
+ }
371
+
372
+ .period-popup-content .period-controls .unit-select:focus {
373
+ outline: none;
374
+ border-color: var(--jupiter-primary-color, #1976d2);
375
+ box-shadow: 0 0 0 2px var(--jupiter-primary-color-light, rgba(25, 118, 210, 0.2));
376
+ }
377
+
378
+ .period-popup-content .period-controls .unit-select:disabled {
379
+ background: var(--jupiter-disabled-background, #f5f5f5);
380
+ color: var(--jupiter-disabled-text, #999);
381
+ cursor: not-allowed;
382
+ }
383
+
333
384
  .field-input {
334
385
  width: 100%;
335
386
  padding: 6px 8px; /* Reduced padding for table cells */
@@ -436,7 +487,7 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
436
487
  outline: none;
437
488
  border-color: var(--jupiter-primary-color, #1976d2);
438
489
  }
439
- `,J([I({type:Object})],exports.JupiterFormField.prototype,"field",2),J([I({type:String})],exports.JupiterFormField.prototype,"conceptId",2),J([I({type:String})],exports.JupiterFormField.prototype,"conceptType",2),J([I({type:String})],exports.JupiterFormField.prototype,"columnId",2),J([I()],exports.JupiterFormField.prototype,"value",2),J([I({type:Boolean})],exports.JupiterFormField.prototype,"disabled",2),J([I({type:String})],exports.JupiterFormField.prototype,"locale",2),J([I({type:Boolean})],exports.JupiterFormField.prototype,"hideLabel",2),J([I({type:String})],exports.JupiterFormField.prototype,"periodStartDate",2),J([I({type:String})],exports.JupiterFormField.prototype,"periodEndDate",2),J([I({type:String})],exports.JupiterFormField.prototype,"periodInstantDate",2),J([w()],exports.JupiterFormField.prototype,"_errors",2),J([w()],exports.JupiterFormField.prototype,"_touched",2),J([w()],exports.JupiterFormField.prototype,"_showPeriodPopup",2),exports.JupiterFormField=J([t("jupiter-form-field")],exports.JupiterFormField);var O=Object.defineProperty,N=Object.getOwnPropertyDescriptor,U=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?N(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&&O(t,i,n),n};exports.JupiterConceptTree=class extends e.LitElement{constructor(){super(...arguments),this.columns=[],this.formData={},this.disabled=!1,this.locale="en-US",this.expandedConcepts=new Set,this._expanded=!0}connectedCallback(){super.connectedCallback(),this._expanded=this.expandedConcepts.has(this.concept.id)}willUpdate(e){super.willUpdate(e),e.has("expandedConcepts")&&(this._expanded=this.expandedConcepts.has(this.concept.id))}_toggleExpanded(){this._expanded=!this._expanded,this.dispatchEvent(new CustomEvent("concept-expand",{detail:{conceptId:this.concept.id,expanded:this._expanded},bubbles:!0}))}_getFieldForColumn(e){var t;return null==(t=this.concept.fields)?void 0:t.find(t=>t.columnId===e)}_getFieldValue(e){var t;return null==(t=this.formData[this.concept.id])?void 0:t[e.columnId]}_handleFieldChange(e){e.stopPropagation(),this.dispatchEvent(new CustomEvent("field-change",{detail:e.detail,bubbles:!0}))}_handlePeriodChange(e){console.log("🌲 [ConceptTree] Received period-change event:",e.detail),e.stopPropagation(),this.dispatchEvent(new CustomEvent("period-change",{detail:e.detail,bubbles:!0,composed:!0})),console.log("🌲 [ConceptTree] Forwarded period-change event to form-section")}render(){const t=this.concept.children&&this.concept.children.length>0,i=this.concept.level||0,o=this.concept.abstract||!1;return e.html`
490
+ `,V([S({type:Object})],exports.JupiterFormField.prototype,"field",2),V([S({type:String})],exports.JupiterFormField.prototype,"conceptId",2),V([S({type:String})],exports.JupiterFormField.prototype,"conceptType",2),V([S({type:Array})],exports.JupiterFormField.prototype,"datatypes",2),V([S({type:Array})],exports.JupiterFormField.prototype,"defaultUnits",2),V([S({type:String})],exports.JupiterFormField.prototype,"columnId",2),V([S()],exports.JupiterFormField.prototype,"value",2),V([S({type:Boolean})],exports.JupiterFormField.prototype,"disabled",2),V([S({type:String})],exports.JupiterFormField.prototype,"locale",2),V([S({type:Boolean})],exports.JupiterFormField.prototype,"hideLabel",2),V([S({type:String})],exports.JupiterFormField.prototype,"periodStartDate",2),V([S({type:String})],exports.JupiterFormField.prototype,"periodEndDate",2),V([S({type:String})],exports.JupiterFormField.prototype,"periodInstantDate",2),V([S({type:String})],exports.JupiterFormField.prototype,"unit",2),V([w()],exports.JupiterFormField.prototype,"_errors",2),V([w()],exports.JupiterFormField.prototype,"_xbrlErrors",2),V([w()],exports.JupiterFormField.prototype,"_touched",2),V([w()],exports.JupiterFormField.prototype,"_showPeriodPopup",2),V([w()],exports.JupiterFormField.prototype,"_availableUnits",2),exports.JupiterFormField=V([t("jupiter-form-field")],exports.JupiterFormField);var q=Object.defineProperty,B=Object.getOwnPropertyDescriptor,K=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?B(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&&q(t,i,n),n};exports.JupiterConceptTree=class extends e.LitElement{constructor(){super(...arguments),this.columns=[],this.formData={},this.periodData={},this.unitData={},this.defaultUnits=[],this.disabled=!1,this.locale="en-US",this.expandedConcepts=new Set,this._expanded=!0}connectedCallback(){super.connectedCallback(),this._expanded=this.expandedConcepts.has(this.concept.id)}willUpdate(e){super.willUpdate(e),e.has("expandedConcepts")&&(this._expanded=this.expandedConcepts.has(this.concept.id))}_toggleExpanded(){this._expanded=!this._expanded,this.dispatchEvent(new CustomEvent("concept-expand",{detail:{conceptId:this.concept.id,expanded:this._expanded},bubbles:!0}))}_getFieldForColumn(e){var t;return null==(t=this.concept.fields)?void 0:t.find(t=>t.columnId===e)}_getFieldValue(e){var t;return null==(t=this.formData[this.concept.id])?void 0:t[e.columnId]}_handleFieldChange(e){e.stopPropagation(),this.dispatchEvent(new CustomEvent("field-change",{detail:e.detail,bubbles:!0}))}_handlePeriodChange(e){console.log("🌲 [ConceptTree] Received period-change event:",e.detail),e.stopPropagation(),this.dispatchEvent(new CustomEvent("period-change",{detail:e.detail,bubbles:!0,composed:!0})),console.log("🌲 [ConceptTree] Forwarded period-change event to form-section")}render(){const t=this.concept.children&&this.concept.children.length>0,i=this.concept.level||0,o=this.concept.abstract||!1;return e.html`
440
491
  <!-- Concept Name Cell (Left Column) -->
441
492
  <td class="concept-name-cell ${o?"abstract":t?"":"leaf"}">
442
493
  <div class="concept-content" style="--level: ${i}">
@@ -454,18 +505,21 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
454
505
  </td>
455
506
 
456
507
  <!-- Input Field Cells (Period Columns) - Only for non-abstract concepts -->
457
- ${this.columns.map(t=>{const i=this._getFieldForColumn(t.id),r=!o&&i;return e.html`
458
- <td class="field-cell ${r?"":"empty"} ${o?"abstract-row":""}">
459
- ${r?e.html`
508
+ ${this.columns.map(t=>{var i,r;const n=this._getFieldForColumn(t.id),s=!o&&n,a=null==(r=null==(i=this.unitData)?void 0:i[this.concept.id])?void 0:r[t.id];return e.html`
509
+ <td class="field-cell ${s?"":"empty"} ${o?"abstract-row":""}">
510
+ ${s?e.html`
460
511
  <jupiter-form-field
461
- .field="${i}"
512
+ .field="${n}"
462
513
  .conceptId="${this.concept.id}"
463
514
  .conceptType="${this.concept.type}"
515
+ .datatypes="${this.datatypes}"
516
+ .defaultUnits="${this.defaultUnits}"
464
517
  .columnId="${t.id}"
465
- .value="${this._getFieldValue(i)}"
466
- .periodStartDate="${i.periodStartDate||t.periodStartDate}"
467
- .periodEndDate="${i.periodEndDate||t.periodEndDate}"
468
- .periodInstantDate="${i.periodInstantDate||("instant"===i.periodType?i.periodEndDate||i.periodStartDate:void 0)}"
518
+ .value="${this._getFieldValue(n)}"
519
+ .unit="${a||""}"
520
+ .periodStartDate="${n.periodStartDate||t.periodStartDate}"
521
+ .periodEndDate="${n.periodEndDate||t.periodEndDate}"
522
+ .periodInstantDate="${n.periodInstantDate||("instant"===n.periodType?n.periodEndDate||n.periodStartDate:void 0)}"
469
523
  .disabled="${this.disabled}"
470
524
  .locale="${this.locale}"
471
525
  .hideLabel="${!0}"
@@ -577,7 +631,7 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
577
631
  }
578
632
 
579
633
 
580
- `,U([I({type:Object})],exports.JupiterConceptTree.prototype,"concept",2),U([I({type:Array})],exports.JupiterConceptTree.prototype,"columns",2),U([I({type:Object})],exports.JupiterConceptTree.prototype,"formData",2),U([I({type:Boolean})],exports.JupiterConceptTree.prototype,"disabled",2),U([I({type:String})],exports.JupiterConceptTree.prototype,"locale",2),U([I({type:Set})],exports.JupiterConceptTree.prototype,"expandedConcepts",2),U([w()],exports.JupiterConceptTree.prototype,"_expanded",2),exports.JupiterConceptTree=U([t("jupiter-concept-tree")],exports.JupiterConceptTree);var V=Object.defineProperty,q=Object.getOwnPropertyDescriptor,B=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?q(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&&V(t,i,n),n};exports.JupiterAddColumnDialog=class extends e.LitElement{constructor(){super(...arguments),this.periodType="duration",this.open=!1,this.availableDimensions=[],this._startDate="",this._endDate="",this._instantDate="",this._selectedType="duration",this._selectedDimensions=new Map}updated(e){e.has("open")&&this.open&&this._resetForm(),e.has("availableDimensions")}connectedCallback(){super.connectedCallback(),this._resetForm()}willUpdate(e){super.willUpdate(e),e.has("open")&&this.open&&this._resetForm()}_handleCancel(){this.open=!1,this.dispatchEvent(new CustomEvent("dialog-cancel",{bubbles:!0}))}_handleConfirm(){if(!this._isFormValid())return;const e={periodType:"mixed"===this.periodType?this._selectedType:this.periodType};"instant"===this.periodType||"mixed"===this.periodType&&"instant"===this._selectedType?e.instantDate=this._instantDate:(e.startDate=this._startDate,e.endDate=this._endDate),this._selectedDimensions.size>0&&(e.selectedDimensions=Array.from(this._selectedDimensions.values())),this.dispatchEvent(new CustomEvent("column-add",{detail:e,bubbles:!0}))}_isFormValid(){return"mixed"===this.periodType?"instant"===this._selectedType?!!this._instantDate:!!this._startDate&&!!this._endDate&&this._startDate<=this._endDate:"duration"===this.periodType?!!this._startDate&&!!this._endDate&&this._startDate<=this._endDate:"instant"===this.periodType&&!!this._instantDate}_handleStartDateChange(e){this._startDate=e.target.value}_handleEndDateChange(e){this._endDate=e.target.value}_handleSelectedTypeChange(e){this._selectedType=e.target.value}_handleInstantDateChange(e){this._instantDate=e.target.value}_handleDimensionToggle(e,t){if(t.target.checked){const t=this.availableDimensions.find(t=>t.id===e);if(t){const i={axisId:t.id,axisLabel:t.axisLabel,isTyped:!(!t.typedMember||t.members&&0!==t.members.length)};this._selectedDimensions.set(e,i)}}else this._selectedDimensions.delete(e);this.requestUpdate()}_handleMemberSelection(e,t,i){const o=this._selectedDimensions.get(e);o&&(o.memberId=t,o.memberLabel=i,this._selectedDimensions.set(e,o),this.requestUpdate())}_handleTypedValueChange(e,t){const i=t.target,o=this._selectedDimensions.get(e);o&&(o.typedValue=i.value,this._selectedDimensions.set(e,o))}_resetForm(){const e=(new Date).toISOString().split("T")[0];this._startDate=e,this._endDate=e,this._instantDate=e,this._selectedType="instant"===this.periodType?"instant":"duration",this._selectedDimensions.clear(),this._autoSelectSingleMemberDimensions(),this.requestUpdate()}_autoSelectSingleMemberDimensions(){this.availableDimensions.forEach(e=>{if(e.members&&1===e.members.length){const t=e.members[0],i={axisId:e.id,axisLabel:e.axisLabel,memberId:t.id,memberLabel:t.label,isTyped:!1};this._selectedDimensions.set(e.id,i)}else if(e.typedMember&&(!e.members||0===e.members.length)){const t={axisId:e.id,axisLabel:e.axisLabel,isTyped:!0};this._selectedDimensions.set(e.id,t)}})}render(){if(!this.open)return e.html``;const t=this._isFormValid();return e.html`
634
+ `,K([S({type:Object})],exports.JupiterConceptTree.prototype,"concept",2),K([S({type:Array})],exports.JupiterConceptTree.prototype,"columns",2),K([S({type:Object})],exports.JupiterConceptTree.prototype,"formData",2),K([S({type:Object})],exports.JupiterConceptTree.prototype,"periodData",2),K([S({type:Object})],exports.JupiterConceptTree.prototype,"unitData",2),K([S({type:Array})],exports.JupiterConceptTree.prototype,"defaultUnits",2),K([S({type:Boolean})],exports.JupiterConceptTree.prototype,"disabled",2),K([S({type:String})],exports.JupiterConceptTree.prototype,"locale",2),K([S({type:Set})],exports.JupiterConceptTree.prototype,"expandedConcepts",2),K([S({type:Array})],exports.JupiterConceptTree.prototype,"datatypes",2),K([w()],exports.JupiterConceptTree.prototype,"_expanded",2),exports.JupiterConceptTree=K([t("jupiter-concept-tree")],exports.JupiterConceptTree);var Y=Object.defineProperty,Q=Object.getOwnPropertyDescriptor,H=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?Q(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&&Y(t,i,n),n};exports.JupiterAddColumnDialog=class extends e.LitElement{constructor(){super(...arguments),this.periodType="duration",this.open=!1,this.availableDimensions=[],this._startDate="",this._endDate="",this._instantDate="",this._selectedType="duration",this._selectedDimensions=new Map}updated(e){e.has("open")&&this.open&&this._resetForm(),e.has("availableDimensions")}connectedCallback(){super.connectedCallback(),this._resetForm()}willUpdate(e){super.willUpdate(e),e.has("open")&&this.open&&this._resetForm()}_handleCancel(){this.open=!1,this.dispatchEvent(new CustomEvent("dialog-cancel",{bubbles:!0}))}_handleConfirm(){if(!this._isFormValid())return;const e={periodType:"mixed"===this.periodType?"duration":this.periodType};"instant"===this.periodType?e.instantDate=this._instantDate:(e.startDate=this._startDate,e.endDate=this._endDate),this._selectedDimensions.size>0&&(e.selectedDimensions=Array.from(this._selectedDimensions.values())),this.dispatchEvent(new CustomEvent("column-add",{detail:e,bubbles:!0}))}_isFormValid(){return"mixed"===this.periodType||"duration"===this.periodType?!!this._startDate&&!!this._endDate&&this._startDate<=this._endDate:"instant"===this.periodType&&!!this._instantDate}_handleStartDateChange(e){this._startDate=e.target.value}_handleEndDateChange(e){this._endDate=e.target.value}_handleSelectedTypeChange(e){this._selectedType=e.target.value}_handleInstantDateChange(e){this._instantDate=e.target.value}_handleDimensionToggle(e,t){if(t.target.checked){const t=this.availableDimensions.find(t=>t.id===e);if(t){const i={axisId:t.id,axisLabel:t.axisLabel,isTyped:!(!t.typedMember||t.members&&0!==t.members.length)};this._selectedDimensions.set(e,i)}}else this._selectedDimensions.delete(e);this.requestUpdate()}_handleMemberSelection(e,t,i){const o=this._selectedDimensions.get(e);o&&(o.memberId=t,o.memberLabel=i,this._selectedDimensions.set(e,o),this.requestUpdate())}_handleTypedValueChange(e,t){const i=t.target,o=this._selectedDimensions.get(e);o&&(o.typedValue=i.value,this._selectedDimensions.set(e,o))}_resetForm(){const e=(new Date).toISOString().split("T")[0];this._startDate=e,this._endDate=e,this._instantDate=e,this._selectedType="instant"===this.periodType?"instant":"duration",this._selectedDimensions.clear(),this._autoSelectSingleMemberDimensions(),this.requestUpdate()}_autoSelectSingleMemberDimensions(){this.availableDimensions.forEach(e=>{if(e.members&&1===e.members.length){const t=e.members[0],i={axisId:e.id,axisLabel:e.axisLabel,memberId:t.id,memberLabel:t.label,isTyped:!1};this._selectedDimensions.set(e.id,i)}else if(e.typedMember&&(!e.members||0===e.members.length)){const t={axisId:e.id,axisLabel:e.axisLabel,isTyped:!0};this._selectedDimensions.set(e.id,t)}})}render(){if(!this.open)return e.html``;const t=this._isFormValid();return e.html`
581
635
  <div class="dialog" @click="${e=>e.stopPropagation()}">
582
636
  <div class="dialog-header">
583
637
  <h2 class="dialog-title">${E.t("column.addColumn")}</h2>
@@ -585,22 +639,7 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
585
639
  </div>
586
640
 
587
641
  <div class="dialog-content">
588
- ${"mixed"===this.periodType?e.html`
589
- <div class="form-group">
590
- <label class="form-label required">${E.t("column.columnType")}</label>
591
- <select
592
- class="form-input"
593
- .value="${this._selectedType}"
594
- @change="${this._handleSelectedTypeChange}"
595
- required
596
- >
597
- <option value="instant">${E.t("column.instantSingleDate")}</option>
598
- <option value="duration">${E.t("column.durationDates")}</option>
599
- </select>
600
- </div>
601
- `:""}
602
-
603
- ${"instant"===this.periodType||"mixed"===this.periodType&&"instant"===this._selectedType?e.html`
642
+ ${"instant"===this.periodType?e.html`
604
643
  <div class="form-group">
605
644
  <label class="form-label required">${E.t("column.instantDate")}</label>
606
645
  <input
@@ -975,7 +1014,7 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
975
1014
  margin: 0 0 12px 0;
976
1015
  line-height: 1.4;
977
1016
  }
978
- `,B([I({type:String})],exports.JupiterAddColumnDialog.prototype,"periodType",2),B([I({type:Boolean})],exports.JupiterAddColumnDialog.prototype,"open",2),B([I({type:Array})],exports.JupiterAddColumnDialog.prototype,"availableDimensions",2),B([w()],exports.JupiterAddColumnDialog.prototype,"_startDate",2),B([w()],exports.JupiterAddColumnDialog.prototype,"_endDate",2),B([w()],exports.JupiterAddColumnDialog.prototype,"_instantDate",2),B([w()],exports.JupiterAddColumnDialog.prototype,"_selectedType",2),B([w()],exports.JupiterAddColumnDialog.prototype,"_selectedDimensions",2),exports.JupiterAddColumnDialog=B([t("jupiter-add-column-dialog")],exports.JupiterAddColumnDialog);var K=Object.defineProperty,Y=Object.getOwnPropertyDescriptor,H=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?Y(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&&K(t,i,n),n};exports.JupiterFormSection=class extends e.LitElement{constructor(){super(...arguments),this.columns=[],this.formData={},this.typedMemberData={},this.disabled=!1,this.collapsible=!0,this.locale="en-US",this.isFirstSection=!1,this.availableDimensions=[],this.hideHeader=!1,this._expanded=!0,this._showAddColumnDialog=!1,this._sectionPeriodType="duration",this._openMenuColumnId=null,this._insertAfterColumnId=null,this._expandedConcepts=new Set,this._allTreeExpanded=!1}connectedCallback(){super.connectedCallback(),this._expanded=!1!==this.section.expanded,this._determinePeriodType(),this._checkAndExpandFirstSection(),document.addEventListener("click",()=>this._closeColumnMenu())}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",()=>this._closeColumnMenu())}updated(e){super.updated(e),(e.has("isFirstSection")||e.has("section"))&&this._checkAndExpandFirstSection()}_checkAndExpandFirstSection(){this.isFirstSection&&this.section&&this.section.concepts&&(this._expanded=!0,setTimeout(()=>{this._expandAllTrees(),console.log("đŸŽ¯ First section detected - expanded section and tree by default")},0))}_determinePeriodType(){const e=this._getAllNonAbstractConcepts(this.section.concepts);if(0===e.length)return this._sectionPeriodType="duration",void console.log(`📊 Section ${this.section.id}: No concepts, defaulting to duration`);const t=new Set(e.map(e=>e.periodType).filter(Boolean));if(0===t.size)this._sectionPeriodType="duration";else if(1===t.size){const e=Array.from(t)[0];this._sectionPeriodType="instant"===e?"instant":"duration"}else this._sectionPeriodType="mixed"}_getAllNonAbstractConcepts(e){const t=[];for(const i of e)i.abstract||t.push(i),i.children&&t.push(...this._getAllNonAbstractConcepts(i.children));return t}_toggleExpanded(){this.collapsible&&(this._expanded=!this._expanded,this._expanded&&this._expandAllTrees(),this.dispatchEvent(new CustomEvent("section-expand",{detail:{sectionId:this.section.id,expanded:this._expanded},bubbles:!0})))}_handleRemoveColumn(e){this._openMenuColumnId=null,this.dispatchEvent(new CustomEvent("column-remove",{detail:{columnId:e,sectionId:this.section.id},bubbles:!0}))}_toggleColumnMenu(e,t){t.stopPropagation(),this._openMenuColumnId=this._openMenuColumnId===e?null:e}_closeColumnMenu(){this._openMenuColumnId=null}_handleAddColumnFromMenu(e,t){t.stopPropagation(),this._openMenuColumnId=null,this._insertAfterColumnId=e,this._handleAddColumn()}_handleAddColumn(){const e=this._determineButtonPeriodType();this._sectionPeriodType=e,this._showAddColumnDialog=!0}_determineButtonPeriodType(){const e=this._getAllNonAbstractConcepts(this.section.concepts);if(0===e.length)return"duration";const t=new Set(e.map(e=>e.periodType).filter(e=>null!=e));if(0===t.size)return"duration";if(1===t.size){return"instant"===Array.from(t)[0]?"instant":"duration"}return"mixed"}_getConceptsWithFields(e){const t=[];for(const i of e)!i.abstract&&i.fields&&i.fields.length>0&&t.push(i),i.children&&t.push(...this._getConceptsWithFields(i.children));return t}_handleDialogCancel(){this._showAddColumnDialog=!1}_handleColumnAdd(e){e.stopPropagation(),this._showAddColumnDialog=!1,this.dispatchEvent(new CustomEvent("column-add-request",{detail:{sectionId:this.section.id,columnRequest:e.detail,insertAfterColumnId:this._insertAfterColumnId},bubbles:!0})),this._insertAfterColumnId=null}_handleFieldChange(e){e.stopPropagation(),this.dispatchEvent(new CustomEvent("field-change",{detail:e.detail,bubbles:!0,composed:!0}))}_handlePeriodChange(e){console.log("📋 [FormSection] Received period-change event:",e.detail),e.stopPropagation(),this.dispatchEvent(new CustomEvent("period-change",{detail:e.detail,bubbles:!0,composed:!0})),console.log("📋 [FormSection] Forwarded period-change event to dynamic-form")}_flattenConcepts(e,t=new Set){const i=[];for(const o of e)if(i.push(o),o.children&&o.children.length>0&&t.has(o.id)){const e=this._flattenConcepts(o.children,t);i.push(...e)}return i}_getAllConceptIds(e){const t=[];for(const i of e)i.children&&i.children.length>0&&(t.push(i.id),t.push(...this._getAllConceptIds(i.children)));return t}_expandAllTrees(){this._getAllConceptIds(this.section.concepts||[]).forEach(e=>this._expandedConcepts.add(e)),this._allTreeExpanded=!0,this.requestUpdate()}_collapseAllTrees(){this._expandedConcepts.clear(),this._allTreeExpanded=!1,this.requestUpdate()}_handleConceptExpand(e){e.stopPropagation();const{conceptId:t,expanded:i}=e.detail;i?this._expandedConcepts.add(t):this._expandedConcepts.delete(t);const o=this._getAllConceptIds(this.section.concepts||[]);this._allTreeExpanded=o.length>0&&o.every(e=>this._expandedConcepts.has(e)),this.requestUpdate(),this.dispatchEvent(new CustomEvent("concept-expand",{detail:e.detail,bubbles:!0}))}_getTypedMemberHeaderValue(e,t){var i;return(null==(i=this.typedMemberData[e])?void 0:i[t])||""}_handleTypedMemberHeaderChange(e,t,i){const o=e.target.value;console.log(`🔍 [FormSection] Typed member header change: columnId=${t}, axisId=${i}, value=${o}`),this.dispatchEvent(new CustomEvent("typed-member-change",{detail:{columnId:t,axisId:i,value:o},bubbles:!0}))}render(){return this.section.concepts&&0!==this.section.concepts.length?e.html`
1017
+ `,H([S({type:String})],exports.JupiterAddColumnDialog.prototype,"periodType",2),H([S({type:Boolean})],exports.JupiterAddColumnDialog.prototype,"open",2),H([S({type:Array})],exports.JupiterAddColumnDialog.prototype,"availableDimensions",2),H([w()],exports.JupiterAddColumnDialog.prototype,"_startDate",2),H([w()],exports.JupiterAddColumnDialog.prototype,"_endDate",2),H([w()],exports.JupiterAddColumnDialog.prototype,"_instantDate",2),H([w()],exports.JupiterAddColumnDialog.prototype,"_selectedType",2),H([w()],exports.JupiterAddColumnDialog.prototype,"_selectedDimensions",2),exports.JupiterAddColumnDialog=H([t("jupiter-add-column-dialog")],exports.JupiterAddColumnDialog);var G=Object.defineProperty,W=Object.getOwnPropertyDescriptor,X=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?W(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&&G(t,i,n),n};exports.JupiterFormSection=class extends e.LitElement{constructor(){super(...arguments),this.columns=[],this.formData={},this.periodData={},this.unitData={},this.typedMemberData={},this.defaultUnits=[],this.disabled=!1,this.collapsible=!0,this.locale="en-US",this.isFirstSection=!1,this.availableDimensions=[],this.hideHeader=!1,this._expanded=!0,this._showAddColumnDialog=!1,this._sectionPeriodType="duration",this._openMenuColumnId=null,this._insertAfterColumnId=null,this._expandedConcepts=new Set,this._allTreeExpanded=!1}connectedCallback(){super.connectedCallback(),this._expanded=!1!==this.section.expanded,this._determinePeriodType(),this._checkAndExpandFirstSection(),document.addEventListener("click",()=>this._closeColumnMenu())}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",()=>this._closeColumnMenu())}updated(e){super.updated(e),(e.has("isFirstSection")||e.has("section"))&&this._checkAndExpandFirstSection()}_checkAndExpandFirstSection(){this.isFirstSection&&this.section&&this.section.concepts&&(this._expanded=!0,setTimeout(()=>{this._expandAllTrees(),console.log("đŸŽ¯ First section detected - expanded section and tree by default")},0))}_determinePeriodType(){const e=this._getAllNonAbstractConcepts(this.section.concepts);if(0===e.length)return this._sectionPeriodType="duration",void console.log(`📊 Section ${this.section.id}: No concepts, defaulting to duration`);const t=new Set(e.map(e=>e.periodType).filter(Boolean));if(0===t.size)this._sectionPeriodType="duration";else if(1===t.size){const e=Array.from(t)[0];this._sectionPeriodType="instant"===e?"instant":"duration"}else this._sectionPeriodType="mixed"}_getAllNonAbstractConcepts(e){const t=[];for(const i of e)i.abstract||t.push(i),i.children&&t.push(...this._getAllNonAbstractConcepts(i.children));return t}_toggleExpanded(){this.collapsible&&(this._expanded=!this._expanded,this._expanded&&this._expandAllTrees(),this.dispatchEvent(new CustomEvent("section-expand",{detail:{sectionId:this.section.id,expanded:this._expanded},bubbles:!0})))}_handleRemoveColumn(e){this._openMenuColumnId=null,this.dispatchEvent(new CustomEvent("column-remove",{detail:{columnId:e,sectionId:this.section.id},bubbles:!0}))}_toggleColumnMenu(e,t){t.stopPropagation(),this._openMenuColumnId=this._openMenuColumnId===e?null:e}_closeColumnMenu(){this._openMenuColumnId=null}_handleAddColumnFromMenu(e,t){t.stopPropagation(),this._openMenuColumnId=null,this._insertAfterColumnId=e,this._handleAddColumn()}_handleAddColumn(){const e=this._determineButtonPeriodType();this._sectionPeriodType=e,this._showAddColumnDialog=!0}_determineButtonPeriodType(){const e=this._getAllNonAbstractConcepts(this.section.concepts);if(0===e.length)return"duration";const t=new Set(e.map(e=>e.periodType).filter(e=>null!=e));if(0===t.size)return"duration";if(1===t.size){return"instant"===Array.from(t)[0]?"instant":"duration"}return"mixed"}_getConceptsWithFields(e){const t=[];for(const i of e)!i.abstract&&i.fields&&i.fields.length>0&&t.push(i),i.children&&t.push(...this._getConceptsWithFields(i.children));return t}_handleDialogCancel(){this._showAddColumnDialog=!1}_handleColumnAdd(e){e.stopPropagation(),this._showAddColumnDialog=!1,this.dispatchEvent(new CustomEvent("column-add-request",{detail:{sectionId:this.section.id,columnRequest:e.detail,insertAfterColumnId:this._insertAfterColumnId},bubbles:!0})),this._insertAfterColumnId=null}_handleFieldChange(e){e.stopPropagation(),this.dispatchEvent(new CustomEvent("field-change",{detail:e.detail,bubbles:!0,composed:!0}))}_handlePeriodChange(e){console.log("📋 [FormSection] Received period-change event:",e.detail),e.stopPropagation(),this.dispatchEvent(new CustomEvent("period-change",{detail:e.detail,bubbles:!0,composed:!0})),console.log("📋 [FormSection] Forwarded period-change event to dynamic-form")}_flattenConcepts(e,t=new Set){const i=[];for(const o of e)if(i.push(o),o.children&&o.children.length>0&&t.has(o.id)){const e=this._flattenConcepts(o.children,t);i.push(...e)}return i}_getAllConceptIds(e){const t=[];for(const i of e)i.children&&i.children.length>0&&(t.push(i.id),t.push(...this._getAllConceptIds(i.children)));return t}_expandAllTrees(){this._getAllConceptIds(this.section.concepts||[]).forEach(e=>this._expandedConcepts.add(e)),this._allTreeExpanded=!0,this.requestUpdate()}_collapseAllTrees(){this._expandedConcepts.clear(),this._allTreeExpanded=!1,this.requestUpdate()}_handleConceptExpand(e){e.stopPropagation();const{conceptId:t,expanded:i}=e.detail;i?this._expandedConcepts.add(t):this._expandedConcepts.delete(t);const o=this._getAllConceptIds(this.section.concepts||[]);this._allTreeExpanded=o.length>0&&o.every(e=>this._expandedConcepts.has(e)),this.requestUpdate(),this.dispatchEvent(new CustomEvent("concept-expand",{detail:e.detail,bubbles:!0}))}_getTypedMemberHeaderValue(e,t){var i;return(null==(i=this.typedMemberData[e])?void 0:i[t])||""}_handleTypedMemberHeaderChange(e,t,i){const o=e.target.value;console.log(`🔍 [FormSection] Typed member header change: columnId=${t}, axisId=${i}, value=${o}`),this.dispatchEvent(new CustomEvent("typed-member-change",{detail:{columnId:t,axisId:i,value:o},bubbles:!0}))}render(){return this.section.concepts&&0!==this.section.concepts.length?e.html`
979
1018
  ${this.hideHeader?"":e.html`
980
1019
  <div class="section-header ${this.collapsible?"":"not-collapsible"}"
981
1020
  @click="${this._toggleExpanded}">
@@ -1061,7 +1100,11 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
1061
1100
  <jupiter-concept-tree
1062
1101
  .concept="${t}"
1063
1102
  .columns="${this.columns}"
1103
+ .datatypes="${this.datatypes}"
1064
1104
  .formData="${this.formData}"
1105
+ .periodData="${this.periodData}"
1106
+ .unitData="${this.unitData}"
1107
+ .defaultUnits="${this.defaultUnits}"
1065
1108
  .disabled="${this.disabled}"
1066
1109
  .locale="${this.locale}"
1067
1110
  .expandedConcepts="${this._expandedConcepts}"
@@ -1363,7 +1406,7 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
1363
1406
  color: var(--jupiter-text-secondary, #666);
1364
1407
  font-style: italic;
1365
1408
  }
1366
- `,H([I({type:Object})],exports.JupiterFormSection.prototype,"section",2),H([I({type:Array})],exports.JupiterFormSection.prototype,"columns",2),H([I({type:Object})],exports.JupiterFormSection.prototype,"formData",2),H([I({type:Object})],exports.JupiterFormSection.prototype,"typedMemberData",2),H([I({type:Boolean})],exports.JupiterFormSection.prototype,"disabled",2),H([I({type:Boolean})],exports.JupiterFormSection.prototype,"collapsible",2),H([I({type:String})],exports.JupiterFormSection.prototype,"locale",2),H([I({type:Boolean})],exports.JupiterFormSection.prototype,"isFirstSection",2),H([I({type:Array})],exports.JupiterFormSection.prototype,"availableDimensions",2),H([I({type:Boolean})],exports.JupiterFormSection.prototype,"hideHeader",2),H([w()],exports.JupiterFormSection.prototype,"_expanded",2),H([w()],exports.JupiterFormSection.prototype,"_showAddColumnDialog",2),H([w()],exports.JupiterFormSection.prototype,"_sectionPeriodType",2),H([w()],exports.JupiterFormSection.prototype,"_openMenuColumnId",2),H([w()],exports.JupiterFormSection.prototype,"_insertAfterColumnId",2),H([w()],exports.JupiterFormSection.prototype,"_expandedConcepts",2),H([w()],exports.JupiterFormSection.prototype,"_allTreeExpanded",2),exports.JupiterFormSection=H([t("jupiter-form-section")],exports.JupiterFormSection);var G=Object.defineProperty,Q=Object.getOwnPropertyDescriptor,W=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?Q(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&&G(t,i,n),n};exports.JupiterFilterRolesDialog=class extends e.LitElement{constructor(){super(...arguments),this.open=!1,this.availableRoles=[],this.selectedRoleIds=[],this.periodPreferences={},this._tempSelectedRoles=new Set,this._searchQuery="",this._filteredRoles=[],this._tempPeriodPreferences={}}connectedCallback(){super.connectedCallback(),this._initializeTempSelection(),this._initializePeriodPreferences()}updated(e){(e.has("selectedRoleIds")||e.has("open"))&&this._initializeTempSelection(),(e.has("availableRoles")||e.has("_searchQuery"))&&this._updateFilteredRoles(),(e.has("availableRoles")||e.has("periodPreferences")||e.has("open"))&&this._initializePeriodPreferences()}_updateFilteredRoles(){if(!this._searchQuery.trim())return void(this._filteredRoles=[...this.availableRoles].sort((e,t)=>e.title.localeCompare(t.title)));const e=this._searchQuery.toLowerCase().trim(),t=this.availableRoles.filter(t=>{var i;const o=t.title.toLowerCase().includes(e),r=t.id.toLowerCase().includes(e),n=(null==(i=t.description)?void 0:i.toLowerCase().includes(e))||!1,s=this._searchInRoleURI(t,e);return o||r||n||s});this._filteredRoles=t.sort((e,t)=>e.title.localeCompare(t.title))}_searchInRoleURI(e,t){var i;if(null==(i=e.metadata)?void 0:i.roleURI)return e.metadata.roleURI.toLowerCase().includes(t);const o=/https?:\/\/[^\s]+/i,r=o.test(e.title),n=o.test(e.id);return r||n?e.title.toLowerCase().includes(t)||e.id.toLowerCase().includes(t):!!(e.id.includes(".")||e.id.includes("/")||e.id.includes(":"))&&e.id.toLowerCase().includes(t)}_handleSearchInput(e){const t=e.target;this._searchQuery=t.value}_clearSearch(){var e;this._searchQuery="";const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".search-input");t&&(t.value="",t.focus())}_highlightSearchTerm(e){if(!this._searchQuery.trim())return e;const t=this._searchQuery.trim(),i=new RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return e.replace(i,"<mark>$1</mark>")}_renderHighlightedText(e){return e}_getSelectedFilteredCount(){return this._filteredRoles.filter(e=>this._tempSelectedRoles.has(e.id)).length}_initializeTempSelection(){this._tempSelectedRoles=new Set(this.selectedRoleIds)}_initializePeriodPreferences(){const e={};this.availableRoles.forEach(t=>{const i=this.periodPreferences[t.id];if(i)e[t.id]={...i};else{const i=!0===t.showPeriodControl;let o,r;void 0!==t.duration||void 0!==t.instant?(o=!0===t.duration,r=!0===t.instant):(o=i||this._hasConceptsWithPeriodType(t,"duration"),r=i||this._hasConceptsWithPeriodType(t,"instant")),e[t.id]={showDuration:o,showInstant:r,showPreviousYear:!0===t.showPreviousYear}}}),this._tempPeriodPreferences=e}_hasConceptsWithPeriodType(e,t){const i=e=>e.some(e=>!e.abstract&&e.periodType===t||!!e.children&&i(e.children));return i(e.concepts)}_handlePeriodCheckboxChange(e,t,i){e.stopPropagation();const o=e.target,r={...this._tempPeriodPreferences};r[t]||(r[t]={showDuration:!0,showInstant:!0,showPreviousYear:!1}),"duration"===i?r[t].showDuration=o.checked:"instant"===i?r[t].showInstant=o.checked:"previousYear"===i&&(r[t].showPreviousYear=o.checked),this._tempPeriodPreferences=r,this.requestUpdate()}_handleCheckboxChange(e,t){const i=e.target,o=new Set(this._tempSelectedRoles);i.checked?o.add(t):o.delete(t),this._tempSelectedRoles=o,this.requestUpdate()}_selectAll(){const e=new Set(this._tempSelectedRoles);this._filteredRoles.forEach(t=>e.add(t.id)),this._tempSelectedRoles=e,this.requestUpdate()}_selectNone(){const e=new Set(this._tempSelectedRoles);this._filteredRoles.forEach(t=>e.delete(t.id)),this._tempSelectedRoles=e,this.requestUpdate()}_selectAllGlobal(){this._tempSelectedRoles=new Set(this.availableRoles.map(e=>e.id)),this.requestUpdate()}_selectNoneGlobal(){this._tempSelectedRoles=new Set,this.requestUpdate()}_resetToOriginal(){this._tempSelectedRoles=new Set(this.selectedRoleIds),this.requestUpdate()}_handleCancel(){this._initializeTempSelection(),this.dispatchEvent(new CustomEvent("dialog-cancel",{bubbles:!0}))}_handleApply(){const e=Array.from(this._tempSelectedRoles);this.dispatchEvent(new CustomEvent("roles-filter-apply",{detail:{selectedRoleIds:e,periodPreferences:this._tempPeriodPreferences},bubbles:!0}))}_handleBackdropClick(e){e.target===this&&this._handleCancel()}render(){const t=this._tempSelectedRoles.size,i=this.availableRoles.length,o=this._filteredRoles.length,r=this._searchQuery.trim().length>0;return e.html`
1409
+ `,X([S({type:Object})],exports.JupiterFormSection.prototype,"section",2),X([S({type:Array})],exports.JupiterFormSection.prototype,"columns",2),X([S({type:Array})],exports.JupiterFormSection.prototype,"datatypes",2),X([S({type:Object})],exports.JupiterFormSection.prototype,"formData",2),X([S({type:Object})],exports.JupiterFormSection.prototype,"periodData",2),X([S({type:Object})],exports.JupiterFormSection.prototype,"unitData",2),X([S({type:Object})],exports.JupiterFormSection.prototype,"typedMemberData",2),X([S({type:Array})],exports.JupiterFormSection.prototype,"defaultUnits",2),X([S({type:Boolean})],exports.JupiterFormSection.prototype,"disabled",2),X([S({type:Boolean})],exports.JupiterFormSection.prototype,"collapsible",2),X([S({type:String})],exports.JupiterFormSection.prototype,"locale",2),X([S({type:Boolean})],exports.JupiterFormSection.prototype,"isFirstSection",2),X([S({type:Array})],exports.JupiterFormSection.prototype,"availableDimensions",2),X([S({type:Boolean})],exports.JupiterFormSection.prototype,"hideHeader",2),X([w()],exports.JupiterFormSection.prototype,"_expanded",2),X([w()],exports.JupiterFormSection.prototype,"_showAddColumnDialog",2),X([w()],exports.JupiterFormSection.prototype,"_sectionPeriodType",2),X([w()],exports.JupiterFormSection.prototype,"_openMenuColumnId",2),X([w()],exports.JupiterFormSection.prototype,"_insertAfterColumnId",2),X([w()],exports.JupiterFormSection.prototype,"_expandedConcepts",2),X([w()],exports.JupiterFormSection.prototype,"_allTreeExpanded",2),exports.JupiterFormSection=X([t("jupiter-form-section")],exports.JupiterFormSection);var Z=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,te=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?ee(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&&Z(t,i,n),n};exports.JupiterFilterRolesDialog=class extends e.LitElement{constructor(){super(...arguments),this.open=!1,this.availableRoles=[],this.selectedRoleIds=[],this.periodPreferences={},this.mode="user",this._tempSelectedRoles=new Set,this._searchQuery="",this._filteredRoles=[],this._tempPeriodPreferences={},this._selectedAvailableRole=null,this._selectedChosenRole=null,this._chosenSearchQuery="",this._draggedRoleId=null,this._dragOverRoleId=null,this._chosenRoleOrder=[]}connectedCallback(){super.connectedCallback(),this._initializeTempSelection(),this._initializePeriodPreferences()}updated(e){(e.has("selectedRoleIds")||e.has("open"))&&this._initializeTempSelection(),(e.has("availableRoles")||e.has("_searchQuery"))&&this._updateFilteredRoles(),(e.has("availableRoles")||e.has("periodPreferences")||e.has("open"))&&this._initializePeriodPreferences()}_updateFilteredRoles(){if(!this._searchQuery.trim())return void(this._filteredRoles=[...this.availableRoles].sort((e,t)=>e.title.localeCompare(t.title)));const e=this._searchQuery.toLowerCase().trim(),t=this.availableRoles.filter(t=>{var i;const o=t.title.toLowerCase().includes(e),r=t.id.toLowerCase().includes(e),n=(null==(i=t.description)?void 0:i.toLowerCase().includes(e))||!1,s=this._searchInRoleURI(t,e);return o||r||n||s});this._filteredRoles=t.sort((e,t)=>e.title.localeCompare(t.title))}_searchInRoleURI(e,t){var i;if(null==(i=e.metadata)?void 0:i.roleURI)return e.metadata.roleURI.toLowerCase().includes(t);const o=/https?:\/\/[^\s]+/i,r=o.test(e.title),n=o.test(e.id);return r||n?e.title.toLowerCase().includes(t)||e.id.toLowerCase().includes(t):!!(e.id.includes(".")||e.id.includes("/")||e.id.includes(":"))&&e.id.toLowerCase().includes(t)}_handleSearchInput(e){const t=e.target;this._searchQuery=t.value}_clearSearch(){var e;this._searchQuery="";const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".search-input");t&&(t.value="",t.focus())}_handleChosenSearchInput(e){const t=e.target;this._chosenSearchQuery=t.value}_clearChosenSearch(){var e;this._chosenSearchQuery="";const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".chosen-search-input");t&&(t.value="",t.focus())}_highlightSearchTerm(e){if(!this._searchQuery.trim())return e;const t=this._searchQuery.trim(),i=new RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi");return e.replace(i,"<mark>$1</mark>")}_renderHighlightedText(e){return e}_getSelectedFilteredCount(){return this._filteredRoles.filter(e=>this._tempSelectedRoles.has(e.id)).length}_initializeTempSelection(){this._tempSelectedRoles=new Set(this.selectedRoleIds),this._chosenRoleOrder=[...this.selectedRoleIds]}_initializePeriodPreferences(){const e={};this.availableRoles.forEach(t=>{const i=this.periodPreferences[t.id];if(i)e[t.id]={...i};else{const i=!0===t.showPeriodControl;let o,r;void 0!==t.duration||void 0!==t.instant?(o=!0===t.duration,r=!0===t.instant):(o=i||this._hasConceptsWithPeriodType(t,"duration"),r=i||this._hasConceptsWithPeriodType(t,"instant")),e[t.id]={showDuration:o,showInstant:r,showPreviousYear:!0===t.showPreviousYear}}}),this._tempPeriodPreferences=e}_hasConceptsWithPeriodType(e,t){const i=e=>e.some(e=>!e.abstract&&e.periodType===t||!!e.children&&i(e.children));return i(e.concepts)}_handlePeriodCheckboxChange(e,t,i){e.stopPropagation();const o=e.target,r={...this._tempPeriodPreferences};r[t]||(r[t]={showDuration:!0,showInstant:!0,showPreviousYear:!1}),"duration"===i?r[t].showDuration=o.checked:"instant"===i?r[t].showInstant=o.checked:"previousYear"===i&&(r[t].showPreviousYear=o.checked),this._tempPeriodPreferences=r,this.requestUpdate()}_handleCheckboxChange(e,t){const i=e.target,o=new Set(this._tempSelectedRoles);i.checked?o.add(t):o.delete(t),this._tempSelectedRoles=o,this.requestUpdate()}_selectAll(){const e=new Set(this._tempSelectedRoles);this._filteredRoles.forEach(t=>e.add(t.id)),this._tempSelectedRoles=e,this.requestUpdate()}_selectNone(){const e=new Set(this._tempSelectedRoles);this._filteredRoles.forEach(t=>e.delete(t.id)),this._tempSelectedRoles=e,this.requestUpdate()}_selectAllGlobal(){this._tempSelectedRoles=new Set(this.availableRoles.map(e=>e.id)),this.requestUpdate()}_selectNoneGlobal(){this._tempSelectedRoles=new Set,this.requestUpdate()}_resetToOriginal(){this._tempSelectedRoles=new Set(this.selectedRoleIds),this.requestUpdate()}_handleCancel(){this._initializeTempSelection(),this.dispatchEvent(new CustomEvent("dialog-cancel",{bubbles:!0}))}_handleApply(){const e=this._chosenRoleOrder.map((e,t)=>{var i;const o=this.availableRoles.find(t=>t.id===e);return{roleId:e,roleURI:(null==(i=null==o?void 0:o.metadata)?void 0:i.roleURI)||"",order:t}});console.log("✅ Apply Filter - Enhanced structure being emitted:",e),console.log("📋 Order array:",this._chosenRoleOrder),this.dispatchEvent(new CustomEvent("roles-filter-apply",{detail:{selectedRoleIds:e,periodPreferences:this._tempPeriodPreferences},bubbles:!0}))}_handleBackdropClick(e){e.target===this&&this._handleCancel()}_handleAvailableRoleClick(e){this._selectedAvailableRole=e,this._selectedChosenRole=null,this.requestUpdate()}_handleChosenRoleClick(e){this._selectedChosenRole=e,this._selectedAvailableRole=null,this.requestUpdate()}_moveToChosen(){if(!this._selectedAvailableRole)return;const e=new Set(this._tempSelectedRoles);e.add(this._selectedAvailableRole),this._tempSelectedRoles=e,this._chosenRoleOrder.includes(this._selectedAvailableRole)||(this._chosenRoleOrder=[...this._chosenRoleOrder,this._selectedAvailableRole]),this._selectedAvailableRole=null,this.requestUpdate()}_moveToAvailable(){if(!this._selectedChosenRole)return;const e=new Set(this._tempSelectedRoles);e.delete(this._selectedChosenRole),this._tempSelectedRoles=e,this._chosenRoleOrder=this._chosenRoleOrder.filter(e=>e!==this._selectedChosenRole),this._selectedChosenRole=null,this.requestUpdate()}_moveAllToChosen(){const e=new Set(this._tempSelectedRoles);this._filteredRoles.forEach(t=>{e.add(t.id),this._chosenRoleOrder.includes(t.id)||this._chosenRoleOrder.push(t.id)}),this._tempSelectedRoles=e,this._selectedAvailableRole=null,this.requestUpdate()}_moveAllToAvailable(){this._tempSelectedRoles=new Set,this._chosenRoleOrder=[],this._selectedChosenRole=null,this.requestUpdate()}_getAvailableRoles(){return this._filteredRoles.filter(e=>!this._tempSelectedRoles.has(e.id))}_getChosenRoles(){const e=this.availableRoles.filter(e=>this._tempSelectedRoles.has(e.id)),t=[...this._chosenRoleOrder.map(t=>e.find(e=>e.id===t)).filter(e=>void 0!==e),...e.filter(e=>!this._chosenRoleOrder.includes(e.id))];if(!this._chosenSearchQuery.trim())return t;const i=this._chosenSearchQuery.toLowerCase().trim();return t.filter(e=>{var t;const o=e.title.toLowerCase().includes(i),r=e.id.toLowerCase().includes(i),n=(null==(t=e.description)?void 0:t.toLowerCase().includes(i))||!1,s=this._searchInRoleURI(e,i);return o||r||n||s})}_handleDragStart(e,t){this._draggedRoleId=t,e.dataTransfer&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",t)),this.requestUpdate()}_handleDragOver(e,t){e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move"),this._draggedRoleId&&this._draggedRoleId!==t&&(this._dragOverRoleId=t,this.requestUpdate())}_handleDragLeave(e){this._dragOverRoleId=null,this.requestUpdate()}_handleDrop(e,t){if(e.preventDefault(),!this._draggedRoleId||this._draggedRoleId===t)return this._draggedRoleId=null,this._dragOverRoleId=null,void this.requestUpdate();const i=[...this._chosenRoleOrder],o=i.indexOf(this._draggedRoleId),r=i.indexOf(t);if(-1!==o&&-1!==r){i.splice(o,1);const e=o<r?r-1:r;i.splice(e,0,this._draggedRoleId),this._chosenRoleOrder=i,console.log("🔄 Reordered roles:",this._chosenRoleOrder)}this._draggedRoleId=null,this._dragOverRoleId=null,this.requestUpdate()}_handleDragEnd(e){this._draggedRoleId=null,this._dragOverRoleId=null,this.requestUpdate()}render(){const t=this._tempSelectedRoles.size,i=this.availableRoles.length,o=this._filteredRoles.length,r=this._searchQuery.trim().length>0;return e.html`
1367
1410
  <div class="dialog" @click="${e=>e.stopPropagation()}">
1368
1411
  <!-- Dialog Header -->
1369
1412
  <div class="dialog-header">
@@ -1376,6 +1419,140 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
1376
1419
 
1377
1420
  <!-- Dialog Content -->
1378
1421
  <div class="dialog-content">
1422
+ ${"admin"===this.mode?e.html`
1423
+ <!-- Admin Mode: Picklist Layout -->
1424
+ <div class="picklist-container">
1425
+ <!-- Available Roles Panel -->
1426
+ <div class="picklist-panel">
1427
+ <div class="picklist-header">
1428
+ Available Roles (${this._getAvailableRoles().length})
1429
+ </div>
1430
+ <div class="picklist-search">
1431
+ <div class="search-container">
1432
+ <input
1433
+ type="text"
1434
+ class="search-input"
1435
+ placeholder="${E.t("filter.searchPlaceholder")}"
1436
+ .value="${this._searchQuery}"
1437
+ @input="${this._handleSearchInput}"
1438
+ />
1439
+ ${this._searchQuery?e.html`
1440
+ <button class="clear-search" @click="${this._clearSearch}" title="${E.t("filter.clearSearch")}">
1441
+ ×
1442
+ </button>
1443
+ `:e.html`
1444
+ <svg class="search-icon" viewBox="0 0 24 24">
1445
+ <path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
1446
+ </svg>
1447
+ `}
1448
+ </div>
1449
+ </div>
1450
+ <div class="picklist-list">
1451
+ ${this._getAvailableRoles().map(t=>{var i;return e.html`
1452
+ <div
1453
+ class="picklist-item ${this._selectedAvailableRole===t.id?"selected":""}"
1454
+ @click="${()=>this._handleAvailableRoleClick(t.id)}"
1455
+ @dblclick="${()=>{this._handleAvailableRoleClick(t.id),this._moveToChosen()}}"
1456
+ >
1457
+ <div class="picklist-item-label">${t.title}</div>
1458
+ ${(null==(i=t.metadata)?void 0:i.roleURI)?e.html`
1459
+ <div class="picklist-item-value">${t.metadata.roleURI}</div>
1460
+ `:""}
1461
+ </div>
1462
+ `})}
1463
+ </div>
1464
+ <div class="picklist-count">
1465
+ ${this._getAvailableRoles().length} role(s)
1466
+ </div>
1467
+ </div>
1468
+
1469
+ <!-- Control Buttons -->
1470
+ <div class="picklist-controls">
1471
+ <button
1472
+ class="picklist-button"
1473
+ @click="${this._moveToChosen}"
1474
+ ?disabled="${!this._selectedAvailableRole}"
1475
+ title="Add selected role"
1476
+ >
1477
+ â€ē
1478
+ </button>
1479
+ <button
1480
+ class="picklist-button"
1481
+ @click="${this._moveAllToChosen}"
1482
+ ?disabled="${0===this._getAvailableRoles().length}"
1483
+ title="Add all roles"
1484
+ >
1485
+ Âģ
1486
+ </button>
1487
+ <button
1488
+ class="picklist-button"
1489
+ @click="${this._moveToAvailable}"
1490
+ ?disabled="${!this._selectedChosenRole}"
1491
+ title="Remove selected role"
1492
+ >
1493
+ ‹
1494
+ </button>
1495
+ <button
1496
+ class="picklist-button"
1497
+ @click="${this._moveAllToAvailable}"
1498
+ ?disabled="${0===this._tempSelectedRoles.size}"
1499
+ title="Remove all roles"
1500
+ >
1501
+ ÂĢ
1502
+ </button>
1503
+ </div>
1504
+
1505
+ <!-- Chosen Roles Panel -->
1506
+ <div class="picklist-panel">
1507
+ <div class="picklist-header">
1508
+ Chosen Roles (${this._tempSelectedRoles.size})
1509
+ </div>
1510
+ <div class="picklist-search">
1511
+ <div class="search-container">
1512
+ <input
1513
+ type="text"
1514
+ class="search-input chosen-search-input"
1515
+ placeholder="${E.t("filter.searchPlaceholder")}"
1516
+ .value="${this._chosenSearchQuery}"
1517
+ @input="${this._handleChosenSearchInput}"
1518
+ />
1519
+ ${this._chosenSearchQuery?e.html`
1520
+ <button class="clear-search" @click="${this._clearChosenSearch}" title="${E.t("filter.clearSearch")}">
1521
+ ×
1522
+ </button>
1523
+ `:e.html`
1524
+ <svg class="search-icon" viewBox="0 0 24 24">
1525
+ <path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
1526
+ </svg>
1527
+ `}
1528
+ </div>
1529
+ </div>
1530
+ <div class="picklist-list">
1531
+ ${this._getChosenRoles().map(t=>{var i;return e.html`
1532
+ <div
1533
+ class="picklist-item ${this._selectedChosenRole===t.id?"selected":""} ${this._draggedRoleId===t.id?"dragging":""} ${this._dragOverRoleId===t.id?"drag-over":""}"
1534
+ draggable="true"
1535
+ @click="${()=>this._handleChosenRoleClick(t.id)}"
1536
+ @dblclick="${()=>{this._handleChosenRoleClick(t.id),this._moveToAvailable()}}"
1537
+ @dragstart="${e=>this._handleDragStart(e,t.id)}"
1538
+ @dragover="${e=>this._handleDragOver(e,t.id)}"
1539
+ @dragleave="${e=>this._handleDragLeave(e)}"
1540
+ @drop="${e=>this._handleDrop(e,t.id)}"
1541
+ @dragend="${e=>this._handleDragEnd(e)}"
1542
+ >
1543
+ <div class="picklist-item-label">${t.title}</div>
1544
+ ${(null==(i=t.metadata)?void 0:i.roleURI)?e.html`
1545
+ <div class="picklist-item-value">${t.metadata.roleURI}</div>
1546
+ `:""}
1547
+ </div>
1548
+ `})}
1549
+ </div>
1550
+ <div class="picklist-count">
1551
+ ${this._tempSelectedRoles.size} role(s) selected
1552
+ </div>
1553
+ </div>
1554
+ </div>
1555
+ `:e.html`
1379
1556
  <p class="description">
1380
1557
  ${E.t("filter.description")}
1381
1558
  </p>
@@ -1481,8 +1658,7 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
1481
1658
  `})}
1482
1659
  `}
1483
1660
  </div>
1484
-
1485
-
1661
+ `}
1486
1662
  </div>
1487
1663
 
1488
1664
  <!-- Dialog Actions -->
@@ -1824,11 +2000,131 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
1824
2000
  opacity: 0.6;
1825
2001
  cursor: not-allowed;
1826
2002
  }
1827
- `,W([I({type:Boolean,reflect:!0})],exports.JupiterFilterRolesDialog.prototype,"open",2),W([I({type:Array})],exports.JupiterFilterRolesDialog.prototype,"availableRoles",2),W([I({type:Array})],exports.JupiterFilterRolesDialog.prototype,"selectedRoleIds",2),W([I({type:Object})],exports.JupiterFilterRolesDialog.prototype,"periodPreferences",2),W([w()],exports.JupiterFilterRolesDialog.prototype,"_tempSelectedRoles",2),W([w()],exports.JupiterFilterRolesDialog.prototype,"_searchQuery",2),W([w()],exports.JupiterFilterRolesDialog.prototype,"_filteredRoles",2),W([w()],exports.JupiterFilterRolesDialog.prototype,"_tempPeriodPreferences",2),exports.JupiterFilterRolesDialog=W([t("jupiter-filter-roles-dialog")],exports.JupiterFilterRolesDialog);var X=Object.defineProperty,Z=Object.getOwnPropertyDescriptor,ee=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?Z(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&&X(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.display="accordion",this.mode="inputForm",this.financialStatementsTypeAxis=[],this._formData={},this._draftLoaded=!1,this._preservedFormData={},this._periodData={},this._preservedPeriodData={},this._typedMemberData={},this._preservedTypedMemberData={},this._columns=[],this._errors=[],this._touched=new Set,this._dirty=!1,this._valid=!0,this._submitted=!1,this._allSections=[],this._selectedRoleIds=[],this._showFilterDialog=!1,this._periodPreferences={},this._activeSidePanelRoleId=null,this._sidePanelSearchQuery="",this._sidePanelCollapsed=!1,this._adminRoleConfigs={},this._skipDraftLoading=!1}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._initializeForm()}updated(e){e.has("language")&&E.setLanguage(this.language),e.has("financialStatementsTypeAxis")&&console.log("🔄 financialStatementsTypeAxis changed:",this.financialStatementsTypeAxis),(e.has("xbrlInput")||e.has("schema")||e.has("language")||e.has("periodStartDate")||e.has("periodEndDate")||e.has("financialStatementsTypeAxis"))&&this._initializeForm()}_initializeForm(){var e;if(this._draftStorageService||(this._draftStorageService=new k(!1)),this.xbrlInput)try{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(),console.log("âš™ī¸ Using period preferences:",this._periodPreferences),this._currentSchema=T.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],this.financialStatementsTypeAxis&&this.financialStatementsTypeAxis.length>0&&(console.log("🔍 Applying financialStatementsTypeAxis filter:",this.financialStatementsTypeAxis),console.log("📊 Sections before filter:",this._allSections.length),this._allSections=this._filterRolesByFinancialStatementsType(this._allSections),console.log("📊 Sections after filter:",this._allSections.length)),0===this._selectedRoleIds.length&&(this._selectedRoleIds=this._allSections.map(e=>e.id),console.log("✅ Auto-selected all roles:",this._selectedRoleIds.length)),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._skipDraftLoading?console.log("â­ī¸ Skipping draft loading during preference update"):this._loadDraftIfExists(),this._validateForm()}_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}_applyRoleFilter(){if(!this._currentSchema||!this._allSections.length)return;if(console.log(`🔍 Applying role filter: ${this._selectedRoleIds.length} selected out of ${this._allSections.length} total`),0===this._selectedRoleIds.length)return console.log("📝 No roles selected - showing empty form"),this._currentSchema={...this._currentSchema,sections:[]},void this.requestUpdate();this._preserveDataForHiddenSections();const e=this._allSections.filter(e=>this._selectedRoleIds.includes(e.id));console.log(`📊 Filtered sections: ${e.length} (IDs: ${e.map(e=>e.id).join(", ")})`),this._restoreDataForVisibleSections(e),this._currentSchema={...this._currentSchema,sections:e},console.log(`✅ Schema updated. Current sections count: ${this._currentSchema.sections.length}`),this.requestUpdate()}_filterRolesByFinancialStatementsType(e){var t;if(!this.financialStatementsTypeAxis||0===this.financialStatementsTypeAxis.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 console.log("🔍 Filter values:",this.financialStatementsTypeAxis),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 console.log(`✅ ${e.title}: No hypercube entry - INCLUDED`),!0;let r=!1,n=!1;for(const i of o.items){if(!i.dimensions||0===i.dimensions.length)continue;const e=i.dimensions.find(e=>{var t;return"bw2-titel9_FinancialStatementsTypeAxis"===e.id||(null==(t=e.conceptName)?void 0:t.includes("FinancialStatementsTypeAxis"))});if(e&&(r=!0,e.members&&e.members.length>0)){if(e.members.some(e=>{if(e.conceptName){const t=e.conceptName.split(":"),i=t.length>1?t[1]:e.conceptName;return this.financialStatementsTypeAxis.some(e=>{const t=e.split(":"),o=t.length>1?t[1]:e;return i===o})}return this.financialStatementsTypeAxis.includes(e.id)})){n=!0;break}}}return!r||n})}_preserveDataForHiddenSections(){var e;((null==(e=this._currentSchema)?void 0:e.sections.map(e=>e.id))||[]).filter(e=>!this._selectedRoleIds.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(e=>{this._typedMemberData[e.columnId]&&(this._preservedTypedMemberData[e.columnId]={...this._typedMemberData[e.columnId]})}),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(e=>{this._preservedTypedMemberData[e.columnId]&&(this._typedMemberData[e.columnId]={...this._preservedTypedMemberData[e.columnId]})}),e.children&&e.children.forEach(e=>{this._restoreConceptData(e)})}_shouldShowFilterButton(){return!0}_handleFilterRolesClick(){this._showFilterDialog=!0}_handleFilterDialogCancel(){this._showFilterDialog=!1,console.log(`đŸšĢ Filter dialog cancelled. Current selection: ${this._selectedRoleIds.length}/${this._allSections.length}`)}_handleRoleFilterApply(e){const{selectedRoleIds:t,periodPreferences:i}=e.detail;this._selectedRoleIds=t;if(JSON.stringify(this._periodPreferences)!==JSON.stringify(i)){this._periodPreferences=i,console.log("📊 Period preferences updated:",this._periodPreferences),console.log("💾 Capturing current form data before reinitialization...");const e=this._generateSubmissionData(),t=this._draftStorageService.createMetadataSnapshot(this.periodStartDate,this.periodEndDate,this.language,this._selectedRoleIds,this._allSections,this._typedMemberData,this._periodPreferences);this._draftStorageService.saveDraft(e,t),console.log("✅ Current form data saved to draft storage"),this._skipDraftLoading=!0,this._initializeForm(),this._skipDraftLoading=!1,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)})}else this._applyRoleFilter();this._showFilterDialog=!1,console.log(`đŸŽ¯ Applied role filter: ${t.length}/${this._allSections.length} roles selected`),this.dispatchEvent(new CustomEvent("roles-filter-changed",{detail:{selectedRoleIds:t,totalRoles:this._allSections.length,visibleRoles:t.length,periodPreferences:i},bubbles:!0}))}_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}=e.detail;console.log(`📅 Period change received: conceptId=${t}, columnId=${i}, periodType=${o}, startDate=${r}, endDate=${n}, instantDate=${s}`);const a={...this._periodData};a[t]||(a[t]={}),a[t]={...a[t],[i]:{startDate:r,endDate:n,instantDate:s}},this._periodData=a,console.log(`💾 Period data stored for [${t}][${i}]:`,this._periodData[t][i]),console.log("đŸ“Ļ Full period data state:",JSON.stringify(this._periodData,null,2)),this._dirty=!0,this.requestUpdate()}_generateUniqueConceptKey(e,t){return`${e}::${t}`}_extractOriginalConceptId(e){const t=e.split("::");return t.length>1?t[1]:e}_handleTypedMemberChange(e){const{columnId:t,axisId:i,value:o}=e.detail;console.log(`🔍 [DynamicForm] Typed member change: columnId=${t}, axisId=${i}, value=${o}`);const r={...this._typedMemberData};r[t]||(r[t]={}),r[t]={...r[t],[i]:o},this._typedMemberData=r,this._dirty=!0,this.requestUpdate(),this.dispatchEvent(new CustomEvent("typed-member-change",{detail:{columnId:t,axisId:i,value:o},bubbles:!0}))}_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=[];return r.items.forEach(e=>{e.dimensions&&e.dimensions.length>0&&e.dimensions.forEach(e=>{var t;if(!n.find(t=>t.id===e.id)){const i=(null==(t=e.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:t.label)||e.conceptName,o={id:e.id,conceptName:e.conceptName,axisLabel:i};e.members&&e.members.length>0&&(o.members=e.members.map(e=>{var t,i;return{id:e.id,label:(null==(i=null==(t=e.labels)?void 0:t.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:i.label)||e.conceptName||e.id}})),e.typedMember&&(o.typedMember={id:e.typedMember.id,dataType:"string"}),n.push(o)}})}),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}`}_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 r of e.selectedDimensions)r.isTyped&&r.typedValue?(t.push(`${r.axisLabel}: ${r.typedValue}`),i.push(`${r.axisId}|${r.typedValue}`)):r.memberId&&r.memberLabel&&(t.push(r.memberLabel),i.push(`${r.axisId}|${r.memberId}`));const o="instant"===e.periodType?`(${e.instantDate})`:`(${this._formatPeriodDisplay(e.startDate,e.endDate)})`;t.length>0&&(d=`${t.join(" | ")} ${o}`,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} ${"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(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 T,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;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,periodStartDate:"instant"===i.periodType?i.instantDate:i.startDate,periodEndDate:"instant"===i.periodType?i.instantDate:i.endDate,periodInstantDate:"instant"===e.periodType?i.instantDate||i.startDate: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,periodStartDate:"instant"===i.periodType?i.instantDate:i.startDate,periodEndDate:"instant"===i.periodType?i.instantDate:i.endDate,periodInstantDate:"instant"===e.periodType?i.instantDate||i.startDate: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,"admin"===this.mode)return void this._handleAdminModeSubmit();this._validateForm();const e=this._generateSubmissionData();console.log("📊 Form Submission Data:",JSON.stringify(e,null,2)),this.dispatchEvent(new CustomEvent("form-submit",{detail:{data:this._formData,submissionData:e,valid:this._valid,errors:this._errors},bubbles:!0})),console.log("✅ Form submit event dispatched")}_handleSaveDraft(){console.log("💾 Raw form data before submission generation:",this._formData);const e=this._generateSubmissionData();console.log("📤 Generated submission data:",e),console.log("📊 Submission data breakdown:"),e.forEach((e,t)=>{console.log(` [${t}] conceptId: ${e.conceptId}, columnId: ${e.columnId}, value: ${e.value}`)});const t=this._draftStorageService.createMetadataSnapshot(this.periodStartDate,this.periodEndDate,this.language,this._selectedRoleIds,this._allSections,this._typedMemberData,this._periodPreferences,this._periodData),i=this._draftStorageService.saveDraft(e,t);this.dynaformsFacts=e,this.dynaformsMetadata=t,this.dispatchEvent(new CustomEvent("form-save-draft",{detail:{data:this._formData,draftData:e,metadata:t,saved:i,valid:this._valid,errors:this._errors,dynaformsFacts:e,dynaformsMetadata:t},bubbles:!0,composed:!0})),console.log("💾 Draft saved - localStorage + event emitted",{entries:e.length,saved:i,roles:this._selectedRoleIds.length,customColumns:t.customColumns.length,eventEmitted:!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.periodData&&(this._periodData=o.periodData,console.log("🔄 Restored custom field-level period data:",Object.keys(this._periodData).length,"concepts")),o.periodPreferences?(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=T.buildFormSchema(this.xbrlInput,this.periodStartDate,this.periodEndDate,this.language,this._periodPreferences),this._allSections=[...this._currentSchema.sections],this.financialStatementsTypeAxis&&this.financialStatementsTypeAxis.length>0&&(this._allSections=this._filterRolesByFinancialStatementsType(this._allSections)),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={};i.forEach(e=>{let{conceptId:t,value:i,columnId:o,period:s}=e;if(!o&&s&&(o=this._inferColumnIdFromPeriod(s,t),!o))return void console.warn(`âš ī¸ Could not infer columnId for concept ${t}, skipping...`);const a=this._findActualConceptId(t)||t;r[a]||(r[a]={}),r[a][o]=i,console.log(`đŸ“Ļ Restored: ${a}[${o}] = ${i}`),s&&(n[a]||(n[a]={}),"instant"===s.type?(n[a][o]={instantDate:s.date},console.log(`📅 [Restore Period] Extracted instant date for ${a}/${o}: ${s.date}`)):"duration"===s.type&&(n[a][o]={startDate:s.startDate,endDate:s.endDate},console.log(`📅 [Restore Period] Extracted duration dates for ${a}/${o}: ${s.startDate} - ${s.endDate}`)))}),this._formData={...this._formData,...r},console.log(`🔄 Restored ${Object.keys(r).length} concepts with data`),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._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 s=(null==(t=this.shadowRoot)?void 0:t.querySelectorAll("input, textarea, select").length)||0;console.log(`🔍 Found ${s} fields in DOM after update`),s>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=>{const i=t.get(e.id);i&&(e.columns=i.map(e=>{const t={id:e.columnId,title:e.label,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};return console.log(`📅 [Draft Restore] Restoring column ${e.columnId}: startDate=${t.periodStartDate}, endDate=${t.periodEndDate}`),t}),this._regenerateFieldsForSection(e),console.log(` └─ Restored ${i.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=>{const i=t.get(e.id);i&&i.length>0&&(e.columns||(e.columns=[]),i.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,type:t.dimensionData?"dimension":"base",periodStartDate:t.startDate||t.date,periodEndDate:t.endDate||t.date,dimensionData:t.dimensionData,order:e.columns.length,removable:!0};console.log(`📅 [New Column Created] Column ${i.id}: periodStartDate=${i.periodStartDate}, periodEndDate=${i.periodEndDate}`),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(e=>{var t;const i=o.periodType,r=this._inferColumnPeriodType(e);if(o.abstract)return;if(!(!r||"duration"===e.id||"default"===e.id)&&i&&r&&i!==r)return void console.log(`â­ī¸ [Field Regeneration] Skipping field for ${o.id} in column ${e.id}: conceptPeriodType=${i}, columnPeriodType=${r}`);const n={id:`${o.id}_${e.id}`,conceptId:o.id,columnId:e.id,type:this._mapConceptTypeToFieldType(o.type),label:o.label,periodType:i,periodStartDate:e.periodStartDate,periodEndDate:e.periodEndDate,periodInstantDate:"instant"===i?e.periodEndDate||e.periodStartDate:void 0};if(null==(t=this._periodData[o.id])?void 0:t[e.id]){const t=this._periodData[o.id][e.id];t.startDate&&(n.periodStartDate=t.startDate),t.endDate&&(n.periodEndDate=t.endDate),t.instantDate&&(n.periodInstantDate=t.instantDate),console.log(`✅ [Field Regeneration] Applied custom period data to ${o.id}/${e.id}:`,t),console.log(`✅ [Field Regeneration] Field properties after apply: periodStartDate=${n.periodStartDate}, periodEndDate=${n.periodEndDate}, periodInstantDate=${n.periodInstantDate}`)}else console.log(`â„šī¸ [Field Regeneration] No custom period data for ${o.id}/${e.id}. Checking _periodData:`,this._periodData[o.id]);(o.id.includes("DescriptionLocationNL")||e.id.startsWith("col-"))&&console.log(`📅 [Field Regeneration] Concept ${o.id}, Column ${e.id}: field.periodStartDate=${n.periodStartDate}, field.periodEndDate=${n.periodEndDate}, column.periodStartDate=${e.periodStartDate}`),o.fields.push(n)}),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.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;const a=e.fields.find(e=>e.columnId===t);if(!a)return;const l="instant"===e.periodType,d=null==(n=this._periodData[e.id])?void 0:n[t],c=this._findColumnByIdInAllSections(t);console.log(`🔍 [Submission] Concept: ${e.id}, Column: ${t}, Field Period: ${d?JSON.stringify(d):"none"}, Column Period: ${(null==c?void 0:c.periodStartDate)||"none"} - ${(null==c?void 0:c.periodEndDate)||"none"}`);const p=(null==d?void 0:d.startDate)||(null==c?void 0:c.periodStartDate)||a.periodStartDate||this.periodStartDate,h=(null==d?void 0:d.endDate)||(null==c?void 0:c.periodEndDate)||a.periodEndDate||this.periodEndDate,u=(null==d?void 0:d.instantDate)||a.periodInstantDate||h||p,m={conceptId:e.originalConceptId||e.id,columnId:t,value:i,period:{type:e.periodType||"duration",...l?{date:u}:{startDate:p,endDate:h}}};(null==(s=null==c?void 0:c.dimensionData)?void 0:s.memberLabel)&&(m.dimension=c.dimensionData.memberLabel),o.push(m)}_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=>{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;const d=this._formData[e.id],c=null==d?void 0:d[n.columnId];if(null!=c&&""!==c){const d=this._findColumnByIdInSection(n.columnId,i),p=null==(s=this._periodData[e.id])?void 0:s[n.columnId],h={conceptId:e.id,columnId:n.columnId,value:c,period:{type:e.periodType||"duration"}};if("instant"===e.periodType){const e=(null==p?void 0:p.instantDate)||(null==p?void 0:p.endDate)||(null==d?void 0:d.periodEndDate)||n.periodInstantDate||n.periodEndDate||n.periodStartDate||this.periodStartDate;h.period.date=e}else{const e=(null==p?void 0:p.startDate)||(null==d?void 0:d.periodStartDate)||n.periodStartDate||this.periodStartDate,t=(null==p?void 0:p.endDate)||(null==d?void 0:d.periodEndDate)||n.periodEndDate||this.periodEndDate;h.period.startDate=e,h.period.endDate=t}if(console.log(`🔍 [Submission] Concept: ${e.id}, Column: ${n.columnId}, Field Period: ${p?JSON.stringify(p):"none"}, Column Period: ${(null==d?void 0:d.periodStartDate)||"none"} - ${(null==d?void 0:d.periodEndDate)||"none"}, Used Period: ${"instant"===h.period.type?h.period.date:`${h.period.startDate} - ${h.period.endDate}`}`),"dimension"===(null==d?void 0:d.type)&&(null==(a=d.dimensionData)?void 0:a.dimensionIdKey)?(h.dimension=d.dimensionData.dimensionIdKey,console.log(`🔍 [DynamicForm] Using dimension key from field's column (${n.columnId}):`,d.dimensionData.dimensionIdKey)):console.log(`🔍 [DynamicForm] No dimension data found for field column ${n.columnId}. Column type: ${null==d?void 0:d.type}, has dimensionData: ${!!(null==d?void 0:d.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?(h.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)),d&&console.log("🔍 [DynamicForm] Column details:",{id:d.id,type:d.type,hasTypedMembers:null==(l=d.dimensionData)?void 0:l.hasTypedMembers,dimensionData:d.dimensionData});r===o&&console.warn("[DUPLICATE DEBUG] Final submission entry:",h),t.push(h)}}),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}}_handleSidePanelRoleClick(e){this._activeSidePanelRoleId=e}_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}_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,r;if(!t)return e.html`
2003
+
2004
+ /* Picklist Styles for Admin Mode */
2005
+ .picklist-container {
2006
+ display: flex;
2007
+ gap: 16px;
2008
+ height: 500px;
2009
+ }
2010
+
2011
+ .picklist-panel {
2012
+ flex: 1;
2013
+ display: flex;
2014
+ flex-direction: column;
2015
+ border: 1px solid var(--jupiter-border-color, #ddd);
2016
+ border-radius: 4px;
2017
+ overflow: hidden;
2018
+ }
2019
+
2020
+ .picklist-header {
2021
+ padding: 12px;
2022
+ background: var(--jupiter-background-light, #f8f9fa);
2023
+ border-bottom: 1px solid var(--jupiter-border-color, #ddd);
2024
+ font-weight: 600;
2025
+ color: var(--jupiter-text-primary, #333);
2026
+ font-size: 14px;
2027
+ }
2028
+
2029
+ .picklist-search {
2030
+ padding: 12px;
2031
+ border-bottom: 1px solid var(--jupiter-border-color, #ddd);
2032
+ }
2033
+
2034
+ .picklist-list {
2035
+ flex: 1;
2036
+ overflow-y: auto;
2037
+ padding: 8px;
2038
+ }
2039
+
2040
+ .picklist-item {
2041
+ padding: 10px 12px;
2042
+ margin-bottom: 4px;
2043
+ border: 1px solid var(--jupiter-border-color, #ddd);
2044
+ border-radius: 4px;
2045
+ cursor: pointer;
2046
+ transition: all 0.2s ease;
2047
+ background: var(--jupiter-background, #fff);
2048
+ }
2049
+
2050
+ .picklist-item:hover {
2051
+ background: var(--jupiter-hover-background, #f5f5f5);
2052
+ border-color: var(--jupiter-primary-color, #1976d2);
2053
+ }
2054
+
2055
+ .picklist-item.selected {
2056
+ background: var(--jupiter-primary-color, #1976d2);
2057
+ color: white;
2058
+ border-color: var(--jupiter-primary-color, #1976d2);
2059
+ }
2060
+
2061
+ .picklist-item.dragging {
2062
+ opacity: 0.5;
2063
+ cursor: move;
2064
+ }
2065
+
2066
+ .picklist-item.drag-over {
2067
+ border-top: 3px solid var(--jupiter-primary-color, #1976d2);
2068
+ margin-top: 3px;
2069
+ }
2070
+
2071
+ .picklist-item[draggable="true"] {
2072
+ cursor: move;
2073
+ }
2074
+
2075
+ .picklist-item-label {
2076
+ font-weight: 500;
2077
+ font-size: 14px;
2078
+ margin-bottom: 4px;
2079
+ }
2080
+
2081
+ .picklist-item-value {
2082
+ font-size: 11px;
2083
+ opacity: 0.8;
2084
+ word-break: break-all;
2085
+ }
2086
+
2087
+ .picklist-controls {
2088
+ display: flex;
2089
+ flex-direction: column;
2090
+ justify-content: center;
2091
+ gap: 8px;
2092
+ padding: 0 8px;
2093
+ }
2094
+
2095
+ .picklist-button {
2096
+ background: var(--jupiter-primary-color, #1976d2);
2097
+ color: white;
2098
+ border: none;
2099
+ padding: 8px 16px;
2100
+ border-radius: 4px;
2101
+ cursor: pointer;
2102
+ font-size: 14px;
2103
+ transition: background-color 0.2s ease;
2104
+ }
2105
+
2106
+ .picklist-button:hover:not(:disabled) {
2107
+ background: var(--jupiter-primary-color-dark, #1565c0);
2108
+ }
2109
+
2110
+ .picklist-button:disabled {
2111
+ opacity: 0.4;
2112
+ cursor: not-allowed;
2113
+ }
2114
+
2115
+ .picklist-count {
2116
+ padding: 8px 12px;
2117
+ font-size: 12px;
2118
+ color: var(--jupiter-text-secondary, #666);
2119
+ background: var(--jupiter-background-light, #f8f9fa);
2120
+ border-top: 1px solid var(--jupiter-border-color, #ddd);
2121
+ text-align: center;
2122
+ }
2123
+ `,te([S({type:Boolean,reflect:!0})],exports.JupiterFilterRolesDialog.prototype,"open",2),te([S({type:Array})],exports.JupiterFilterRolesDialog.prototype,"availableRoles",2),te([S({type:Array})],exports.JupiterFilterRolesDialog.prototype,"selectedRoleIds",2),te([S({type:Object})],exports.JupiterFilterRolesDialog.prototype,"periodPreferences",2),te([S({type:String})],exports.JupiterFilterRolesDialog.prototype,"mode",2),te([w()],exports.JupiterFilterRolesDialog.prototype,"_tempSelectedRoles",2),te([w()],exports.JupiterFilterRolesDialog.prototype,"_searchQuery",2),te([w()],exports.JupiterFilterRolesDialog.prototype,"_filteredRoles",2),te([w()],exports.JupiterFilterRolesDialog.prototype,"_tempPeriodPreferences",2),te([w()],exports.JupiterFilterRolesDialog.prototype,"_selectedAvailableRole",2),te([w()],exports.JupiterFilterRolesDialog.prototype,"_selectedChosenRole",2),te([w()],exports.JupiterFilterRolesDialog.prototype,"_chosenSearchQuery",2),te([w()],exports.JupiterFilterRolesDialog.prototype,"_draggedRoleId",2),te([w()],exports.JupiterFilterRolesDialog.prototype,"_dragOverRoleId",2),te([w()],exports.JupiterFilterRolesDialog.prototype,"_chosenRoleOrder",2),exports.JupiterFilterRolesDialog=te([t("jupiter-filter-roles-dialog")],exports.JupiterFilterRolesDialog);var ie=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,re=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?oe(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&&ie(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.display="accordion",this.mode="inputForm",this.financialStatementsTypeAxis=[],this.defaultUnits=[],this._formData={},this._draftLoaded=!1,this._preservedFormData={},this._periodData={},this._preservedPeriodData={},this._unitData={},this._preservedUnitData={},this._typedMemberData={},this._preservedTypedMemberData={},this._columns=[],this._errors=[],this._touched=new Set,this._dirty=!1,this._valid=!0,this._submitted=!1,this._xbrlFormErrors=[],this._showErrorPopup=!1,this._allSections=[],this._selectedRoleIds=[],this._showFilterDialog=!1,this._periodPreferences={},this._activeSidePanelRoleId=null,this._sidePanelSearchQuery="",this._sidePanelCollapsed=!1,this._adminRoleConfigs={},this._skipDraftLoading=!1}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("field-blur",e=>{console.log("🚨 [DynamicForm] field-blur event listener triggered!",e);const t=e;this._handleFieldBlur(t)}),this._initializeForm()}updated(e){e.has("language")&&E.setLanguage(this.language),e.has("financialStatementsTypeAxis")&&console.log("🔄 financialStatementsTypeAxis changed:",this.financialStatementsTypeAxis),(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("financialStatementsTypeAxis"))&&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{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(),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],this.financialStatementsTypeAxis&&this.financialStatementsTypeAxis.length>0&&(console.log("🔍 Applying financialStatementsTypeAxis filter:",this.financialStatementsTypeAxis),console.log("📊 Sections before filter:",this._allSections.length),this._allSections=this._filterRolesByFinancialStatementsType(this._allSections),console.log("📊 Sections after filter:",this._allSections.length)),0===this._selectedRoleIds.length&&(this._selectedRoleIds=this._allSections.map(e=>e.id),console.log("✅ Auto-selected all roles:",this._selectedRoleIds.length)),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._skipDraftLoading?console.log("â­ī¸ Skipping draft loading during preference update"):this._loadDraftIfExists(),this._validateForm()}_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}_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}_filterRolesByFinancialStatementsType(e){var t;if(!this.financialStatementsTypeAxis||0===this.financialStatementsTypeAxis.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 console.log("🔍 Filter values:",this.financialStatementsTypeAxis),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 console.log(`✅ ${e.title}: No hypercube entry - INCLUDED`),!0;let r=!1,n=!1;for(const i of o.items){if(!i.dimensions||0===i.dimensions.length)continue;const e=i.dimensions.find(e=>{var t;return"bw2-titel9_FinancialStatementsTypeAxis"===e.id||(null==(t=e.conceptName)?void 0:t.includes("FinancialStatementsTypeAxis"))});if(e&&(r=!0,e.members&&e.members.length>0)){if(e.members.some(e=>{if(e.conceptName){const t=e.conceptName.split(":"),i=t.length>1?t[1]:e.conceptName;return this.financialStatementsTypeAxis.some(e=>{const t=e.split(":"),o=t.length>1?t[1]:e;return i===o})}return this.financialStatementsTypeAxis.includes(e.id)})){n=!0;break}}}return!r||n})}_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(e=>{this._typedMemberData[e.columnId]&&(this._preservedTypedMemberData[e.columnId]={...this._typedMemberData[e.columnId]})}),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(e=>{this._preservedTypedMemberData[e.columnId]&&(this._typedMemberData[e.columnId]={...this._preservedTypedMemberData[e.columnId]})}),e.children&&e.children.forEach(e=>{this._restoreConceptData(e)})}_shouldShowFilterButton(){return!0}_handleFilterRolesClick(){this._showFilterDialog=!0}_handleFilterDialogCancel(){this._showFilterDialog=!1;const e=this._getRoleIdsArray().length;console.log(`đŸšĢ Filter dialog cancelled. Current selection: ${e}/${this._allSections.length}`)}_handleRoleFilterApply(e){const{selectedRoleIds:t,periodPreferences:i}=e.detail;this._selectedRoleIds=t;if(JSON.stringify(this._periodPreferences)!==JSON.stringify(i)){this._periodPreferences=i,console.log("📊 Period preferences updated:",this._periodPreferences),console.log("💾 Capturing current form data before reinitialization...");const e=this._generateSubmissionData(),t=this._draftStorageService.createMetadataSnapshot(this.periodStartDate,this.periodEndDate,this.language,this._selectedRoleIds,this._allSections,this._typedMemberData,this._periodPreferences,this._periodData,this._unitData);this._draftStorageService.saveDraft(e,t),console.log("✅ Current form data saved to draft storage"),this._skipDraftLoading=!0,this._initializeForm(),this._skipDraftLoading=!1,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)})}else this._applyRoleFilter();this._showFilterDialog=!1;const o=Array.isArray(this._selectedRoleIds)&&this._selectedRoleIds.length>0?(this._selectedRoleIds[0],this._selectedRoleIds.length):0;console.log(`đŸŽ¯ Applied role filter: ${o}/${this._allSections.length} roles selected`),console.log("📋 Enhanced selectedRoleIds structure:",this._selectedRoleIds),this.dispatchEvent(new CustomEvent("roles-filter-changed",{detail:{selectedRoleIds:t,totalRoles:this._allSections.length,visibleRoles:o,periodPreferences:i},bubbles:!0}))}_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))}_generateUniqueConceptKey(e,t){return`${e}::${t}`}_extractOriginalConceptId(e){const t=e.split("::");return t.length>1?t[1]:e}_handleTypedMemberChange(e){const{columnId:t,axisId:i,value:o}=e.detail;console.log(`🔍 [DynamicForm] Typed member change: columnId=${t}, axisId=${i}, value=${o}`);const r={...this._typedMemberData};r[t]||(r[t]={}),r[t]={...r[t],[i]:o},this._typedMemberData=r,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}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=[];return r.items.forEach(e=>{e.dimensions&&e.dimensions.length>0&&e.dimensions.forEach(e=>{var t;if(!n.find(t=>t.id===e.id)){const i=(null==(t=e.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:t.label)||e.conceptName,o={id:e.id,conceptName:e.conceptName,axisLabel:i};e.members&&e.members.length>0&&(o.members=e.members.map(e=>{var t,i;return{id:e.id,label:(null==(i=null==(t=e.labels)?void 0:t.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:i.label)||e.conceptName||e.id}})),e.typedMember&&(o.typedMember={id:e.typedMember.id,dataType:"string"}),n.push(o)}})}),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}`}_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 r of e.selectedDimensions)r.isTyped&&r.typedValue?(t.push(`${r.axisLabel}: ${r.typedValue}`),i.push(`${r.axisId}|${r.typedValue}`)):r.memberId&&r.memberLabel&&(t.push(r.memberLabel),i.push(`${r.axisId}|${r.memberId}`));const o="instant"===e.periodType?`(${e.instantDate})`:`(${this._formatPeriodDisplay(e.startDate,e.endDate)})`;t.length>0&&(d=`${t.join(" | ")} ${o}`,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} ${"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;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:"instant"===i.periodType?i.instantDate:i.startDate,periodEndDate:"instant"===i.periodType?i.instantDate:i.endDate,periodInstantDate:"instant"===e.periodType?i.instantDate||i.startDate: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:"instant"===i.periodType?i.instantDate:i.startDate,periodEndDate:"instant"===i.periodType?i.instantDate:i.endDate,periodInstantDate:"instant"===e.periodType?i.instantDate||i.startDate: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,"admin"===this.mode)return void this._handleAdminModeSubmit();this._validateForm();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},bubbles:!0})),console.log("✅ Form submit event dispatched")}_handleSaveDraft(){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 e=this._generateSubmissionData();console.log("📤 Generated submission data:",e),console.log("📊 Submission data breakdown:"),e.forEach((e,t)=>{console.log(` [${t}] conceptId: ${e.conceptId}, columnId: ${e.columnId}, value: ${e.value}, unit: ${e.unit||"none"}`)});const t=this._draftStorageService.createMetadataSnapshot(this.periodStartDate,this.periodEndDate,this.language,this._selectedRoleIds,this._allSections,this._typedMemberData,this._periodPreferences,this._periodData,this._unitData),i=this._draftStorageService.saveDraft(e,t);console.log("💾 [Save Draft] Metadata saved with enhanced selectedRoleIds:",t.selectedRoleIds),this.dynaformsFacts=e,this.dynaformsMetadata=t,this.dispatchEvent(new CustomEvent("form-save-draft",{detail:{data:this._formData,draftData:e,metadata:t,saved:i,valid:this._valid,errors:this._errors,dynaformsFacts:e,dynaformsMetadata:t},bubbles:!0,composed:!0}));const o=this._getRoleIdsArray().length;console.log("💾 Draft saved - localStorage + event emitted",{entries:e.length,saved:i,roles:o,customColumns:t.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.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.periodPreferences?(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],this.financialStatementsTypeAxis&&this.financialStatementsTypeAxis.length>0&&(this._allSections=this._filterRolesByFinancialStatementsType(this._allSections)),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,value:i,columnId:o,period:a,unit:l}=e;if(!o&&a&&(o=this._inferColumnIdFromPeriod(a,t),!o))return void console.warn(`âš ī¸ Could not infer columnId for concept ${t}, skipping...`);const d=this._findActualConceptId(t)||t;r[d]||(r[d]={}),r[d][o]=i,console.log(`đŸ“Ļ Restored: ${d}[${o}] = ${i}`),a&&(n[d]||(n[d]={}),"instant"===a.type?(n[d][o]={instantDate:a.date},console.log(`📅 [Restore Period] Extracted instant date for ${d}/${o}: ${a.date}`)):"duration"===a.type&&(n[d][o]={startDate:a.startDate,endDate:a.endDate},console.log(`📅 [Restore Period] Extracted duration dates for ${d}/${o}: ${a.startDate} - ${a.endDate}`))),l&&(s[d]||(s[d]={}),s[d][o]=l,console.log(`đŸˇī¸ [Restore Unit] Extracted unit for ${d}/${o}: ${l}`))}),this._formData={...this._formData,...r},console.log(`🔄 Restored ${Object.keys(r).length} concepts with data`),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,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}: 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,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}: 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_"),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;const l=e.fields.find(e=>e.columnId===t);if(!l)return;const d="instant"===e.periodType,c=null==(n=this._periodData[e.id])?void 0:n[t],p=null==(s=this._unitData[e.id])?void 0:s[t],h=this._findColumnByIdInAllSections(t);console.log(`🔍 [Submission] Concept: ${e.id}, Column: ${t}, Field Period: ${c?JSON.stringify(c):"none"}, Unit: ${p||"none"}, Column Period: ${(null==h?void 0:h.periodStartDate)||"none"} - ${(null==h?void 0:h.periodEndDate)||"none"}`);const u=(null==c?void 0:c.startDate)||(null==h?void 0:h.periodStartDate)||l.periodStartDate||this.periodStartDate,m=(null==c?void 0:c.endDate)||(null==h?void 0:h.periodEndDate)||l.periodEndDate||this.periodEndDate,f=(null==c?void 0:c.instantDate)||l.periodInstantDate||m||u,b={conceptId:e.originalConceptId||e.id,columnId:t,value:i,period:{type:e.periodType||"duration",...d?{date:f}:{startDate:u,endDate:m}}};p&&(b.unit=p,console.log(`✅ [Submission] Adding unit to entry: ${p} for ${e.id}/${t}`)),(null==(a=null==h?void 0:h.dimensionData)?void 0:a.memberLabel)&&(b.dimension=h.dimensionData.memberLabel),console.log("📤 [Submission Entry] Created entry:",JSON.stringify(b,null,2)),o.push(b)}_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=>{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;const c=this._formData[e.id],p=null==c?void 0:c[n.columnId];if(null!=p&&""!==p){const c=this._findColumnByIdInSection(n.columnId,i),h=null==(s=this._periodData[e.id])?void 0:s[n.columnId],u={conceptId:e.id,columnId:n.columnId,value:p,period:{type:e.periodType||"duration"}};if("instant"===e.periodType){const e=(null==h?void 0:h.instantDate)||(null==h?void 0:h.endDate)||(null==c?void 0:c.periodEndDate)||n.periodInstantDate||n.periodEndDate||n.periodStartDate||this.periodStartDate;u.period.date=e}else{const e=(null==h?void 0:h.startDate)||(null==c?void 0:c.periodStartDate)||n.periodStartDate||this.periodStartDate,t=(null==h?void 0:h.endDate)||(null==c?void 0:c.periodEndDate)||n.periodEndDate||this.periodEndDate;u.period.startDate=e,u.period.endDate=t}console.log(`🔍 [Submission] Concept: ${e.id}, Column: ${n.columnId}, Field Period: ${h?JSON.stringify(h):"none"}, Column Period: ${(null==c?void 0:c.periodStartDate)||"none"} - ${(null==c?void 0:c.periodEndDate)||"none"}, Used Period: ${"instant"===u.period.type?u.period.date:`${u.period.startDate} - ${u.period.endDate}`}`);const m=null==(a=this._unitData[e.id])?void 0:a[n.columnId];if(m?(u.unit=m,console.log(`✅ [Submission] Adding unit to entry: ${m} 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)),"dimension"===(null==c?void 0:c.type)&&(null==(l=c.dimensionData)?void 0:l.dimensionIdKey)?(u.dimension=c.dimensionData.dimensionIdKey,console.log(`🔍 [DynamicForm] Using dimension key from field's column (${n.columnId}):`,c.dimensionData.dimensionIdKey)):console.log(`🔍 [DynamicForm] No dimension data found for field column ${n.columnId}. Column type: ${null==c?void 0:c.type}, has dimensionData: ${!!(null==c?void 0:c.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?(u.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)),c&&console.log("🔍 [DynamicForm] Column details:",{id:c.id,type:c.type,hasTypedMembers:null==(d=c.dimensionData)?void 0:d.hasTypedMembers,dimensionData:c.dimensionData});r===o&&console.warn("[DUPLICATE DEBUG] Final submission entry:",u),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}}_handleSidePanelRoleClick(e){this._activeSidePanelRoleId=e}_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}_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;if(!t)return e.html`
1828
2124
  <div class="admin-mode-container">
1829
2125
  <p>No role selected</p>
1830
2126
  </div>
1831
- `;const n=(null==(i=this._adminRoleConfigs[t.id])?void 0:i.showPreviousYear)??t.showPreviousYear??!1,s=(null==(o=this._adminRoleConfigs[t.id])?void 0:o.instant)??t.instant??!1,a=(null==(r=this._adminRoleConfigs[t.id])?void 0:r.duration)??t.duration??!1,l=!0===t.showPeriodControl;return e.html`
2127
+ `;const o=(null==(i=this._periodPreferences[t.id])?void 0:i.showPreviousYear)??t.showPreviousYear??!1;return e.html`
1832
2128
  <div class="admin-mode-container">
1833
2129
  <h2 class="admin-mode-title">Role Configuration: ${t.title}</h2>
1834
2130
  <div class="admin-roles-list">
@@ -1837,41 +2133,15 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
1837
2133
  <input
1838
2134
  type="checkbox"
1839
2135
  id="admin-prev-year-${t.id}"
1840
- .checked="${n}"
2136
+ .checked="${o}"
1841
2137
  @change="${e=>this._handleAdminCheckboxChange(t.id,"showPreviousYear",e.target.checked)}"
1842
2138
  />
1843
2139
  <label for="admin-prev-year-${t.id}">Show Previous Year Column</label>
1844
2140
  </div>
1845
2141
  </div>
1846
-
1847
- ${l?e.html`
1848
- <div class="admin-role-item">
1849
- <div class="admin-role-checkbox">
1850
- <input
1851
- type="checkbox"
1852
- id="admin-instant-${t.id}"
1853
- .checked="${s}"
1854
- @change="${e=>this._handleAdminCheckboxChange(t.id,"instant",e.target.checked)}"
1855
- />
1856
- <label for="admin-instant-${t.id}">Show Instant Column</label>
1857
- </div>
1858
- </div>
1859
-
1860
- <div class="admin-role-item">
1861
- <div class="admin-role-checkbox">
1862
- <input
1863
- type="checkbox"
1864
- id="admin-duration-${t.id}"
1865
- .checked="${a}"
1866
- @change="${e=>this._handleAdminCheckboxChange(t.id,"duration",e.target.checked)}"
1867
- />
1868
- <label for="admin-duration-${t.id}">Show Duration Column</label>
1869
- </div>
1870
- </div>
1871
- `:""}
1872
2142
  </div>
1873
2143
  </div>
1874
- `}_handleAdminCheckboxChange(e,t,i){const o=this._adminRoleConfigs[e]||{showPreviousYear:!1};this._adminRoleConfigs={...this._adminRoleConfigs,[e]:{...o,[t]:i}}}_handleAdminModeSubmit(){var e,t,i,o;if(!(null==(i=null==(t=null==(e=this.xbrlInput)?void 0:e.presentation)?void 0:t[0])?void 0:i.roles))return void console.error("No presentation data available");const r=JSON.parse(JSON.stringify(this.xbrlInput.presentation[0])),n=new Set((null==(o=this._currentSchema)?void 0:o.sections.map(e=>e.id))||[]);r.roles=r.roles.map(e=>{const t=n.has(e.id),i=this._adminRoleConfigs[e.id],o={...e,display:t?"yes":"no"};return void 0!==i&&t&&(o.showPreviousYear=i.showPreviousYear,void 0!==i.instant&&(o.instant=i.instant),void 0!==i.duration&&(o.duration=i.duration)),o}),this.dispatchEvent(new CustomEvent("admin-config-updated",{detail:{presentationData:r,roleConfigs:this._adminRoleConfigs},bubbles:!0,composed:!0})),console.log("✅ Admin configuration saved successfully")}_renderAccordionLayout(t,i,o,r){return e.html`
2144
+ `}_handleAdminCheckboxChange(e,t,i){const o=this._adminRoleConfigs[e]||{showPreviousYear:!1};this._adminRoleConfigs={...this._adminRoleConfigs,[e]:{...o,[t]:i}};const r=this._periodPreferences[e]||{showDuration:!0,showInstant:!0,showPreviousYear:!1};this._periodPreferences={...this._periodPreferences,[e]:{...r,[t]:i}},console.log(`✅ [Admin Mode] Updated ${t} = ${i} for role ${e}`),console.log("📋 [Admin Mode] _periodPreferences now includes:",this._periodPreferences[e])}_handleAdminModeSubmit(){var e,t,i,o;if(!(null==(i=null==(t=null==(e=this.xbrlInput)?void 0:e.presentation)?void 0:t[0])?void 0:i.roles))return void console.error("No presentation data available");const r=JSON.parse(JSON.stringify(this.xbrlInput.presentation[0])),n=new Set((null==(o=this._currentSchema)?void 0:o.sections.map(e=>e.id))||[]);r.roles=r.roles.map(e=>{const t=n.has(e.id),i=this._adminRoleConfigs[e.id],o={...e,display:t?"yes":"no"};return void 0!==i&&t&&(o.showPreviousYear=i.showPreviousYear),o}),this.dispatchEvent(new CustomEvent("admin-config-updated",{detail:{presentationData:r,roleConfigs:this._adminRoleConfigs},bubbles:!0,composed:!0})),console.log("✅ Admin configuration saved successfully")}_renderAccordionLayout(t,i,o,r){return e.html`
1875
2145
  <div class="form-sections">
1876
2146
  <!-- Validation Summary -->
1877
2147
  ${o?e.html`
@@ -1896,12 +2166,17 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
1896
2166
  <p>${E.t("filter.selectRoles")}</p>
1897
2167
  <p>${E.t("filter.roles")}: ${this._allSections.length}</p>
1898
2168
  </div>
1899
- `:t.sections.map((t,o)=>e.html`
2169
+ `:t.sections.map((t,o)=>{var r;return e.html`
1900
2170
  <jupiter-form-section
2171
+ section-id="${t.id}"
1901
2172
  .section="${t}"
1902
2173
  .columns="${t.columns||this._columns}"
2174
+ .datatypes="${t.datatypes||(null==(r=this.xbrlInput)?void 0:r.datatypes)}"
1903
2175
  .formData="${this._formData}"
2176
+ .periodData="${this._periodData}"
2177
+ .unitData="${this._unitData}"
1904
2178
  .typedMemberData="${this._typedMemberData}"
2179
+ .defaultUnits="${this.defaultUnits}"
1905
2180
  .disabled="${this.disabled||this.readonly}"
1906
2181
  .collapsible="${!1!==i.collapsibleSections}"
1907
2182
  .locale="${i.locale||"en-US"}"
@@ -1915,9 +2190,9 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
1915
2190
  @column-remove="${this._handleColumnRemove}"
1916
2191
  @column-add-request="${this._handleColumnAddRequest}"
1917
2192
  ></jupiter-form-section>
1918
- `)}
2193
+ `})}
1919
2194
  </div>
1920
- `}_renderSidePanelLayout(t,i,o,r){const n=t.sections,s=this._filterSidePanelSections(n);this._activeSidePanelRoleId&&s.find(e=>e.id===this._activeSidePanelRoleId)||(this._activeSidePanelRoleId=s.length>0?s[0].id:null);const a=n.find(e=>e.id===this._activeSidePanelRoleId);return e.html`
2195
+ `}_renderSidePanelLayout(t,i,o,r){var n;const s=t.sections,a=this._filterSidePanelSections(s);this._activeSidePanelRoleId&&a.find(e=>e.id===this._activeSidePanelRoleId)||(this._activeSidePanelRoleId=a.length>0?a[0].id:null);const l=s.find(e=>e.id===this._activeSidePanelRoleId);return e.html`
1921
2196
  <div class="side-panel-layout">
1922
2197
  <!-- Left: Roles List (filtered) -->
1923
2198
  <div class="side-panel-roles-list ${this._sidePanelCollapsed?"collapsed":""}">
@@ -1954,20 +2229,20 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
1954
2229
  </div>
1955
2230
 
1956
2231
  <!-- Search Results Info -->
1957
- ${this._sidePanelSearchQuery.trim()&&s.length!==n.length?e.html`
2232
+ ${this._sidePanelSearchQuery.trim()&&a.length!==s.length?e.html`
1958
2233
  <div class="side-panel-search-results-info">
1959
- ${s.length} ${E.t("filter.of")} ${n.length} ${E.t("filter.roles")}
2234
+ ${a.length} ${E.t("filter.of")} ${s.length} ${E.t("filter.roles")}
1960
2235
  </div>
1961
2236
  `:""}
1962
2237
 
1963
2238
  <!-- Roles List -->
1964
- ${0===s.length?e.html`
2239
+ ${0===a.length?e.html`
1965
2240
  <div class="side-panel-no-results">
1966
2241
  ${E.t("filter.noRolesFound")} "${this._sidePanelSearchQuery}"<br>
1967
2242
  ${E.t("filter.tryDifferentSearch")}
1968
2243
  </div>
1969
2244
  `:e.html`
1970
- ${s.map(t=>e.html`
2245
+ ${a.map(t=>e.html`
1971
2246
  <div
1972
2247
  class="side-panel-role-item ${t.id===this._activeSidePanelRoleId?"active":""}"
1973
2248
  @click="${()=>this._handleSidePanelRoleClick(t.id)}"
@@ -1997,20 +2272,25 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
1997
2272
  <!-- Active Section (hidden in admin mode) -->
1998
2273
  ${"admin"===this.mode?e.html`
1999
2274
  <div class="admin-mode-placeholder">
2000
- ${this._renderAdminModeContent(a)}
2275
+ ${this._renderAdminModeContent(l)}
2001
2276
  </div>
2002
- `:a?e.html`
2277
+ `:l?e.html`
2003
2278
  <jupiter-form-section
2004
- .section="${a}"
2005
- .columns="${a.columns||this._columns}"
2279
+ section-id="${l.id}"
2280
+ .section="${l}"
2281
+ .columns="${l.columns||this._columns}"
2282
+ .datatypes="${l.datatypes||(null==(n=this.xbrlInput)?void 0:n.datatypes)}"
2006
2283
  .formData="${this._formData}"
2284
+ .periodData="${this._periodData}"
2285
+ .unitData="${this._unitData}"
2007
2286
  .typedMemberData="${this._typedMemberData}"
2287
+ .defaultUnits="${this.defaultUnits}"
2008
2288
  .disabled="${this.disabled||this.readonly}"
2009
2289
  .collapsible="${!1}"
2010
2290
  .hideHeader="${!0}"
2011
2291
  .locale="${i.locale||"en-US"}"
2012
2292
  .isFirstSection="${!0}"
2013
- .availableDimensions="${this._getAvailableDimensionsForSection(a.id)}"
2293
+ .availableDimensions="${this._getAvailableDimensionsForSection(l.id)}"
2014
2294
  @field-change="${this._handleFieldChange}"
2015
2295
  @typed-member-change="${this._handleTypedMemberChange}"
2016
2296
  @section-expand="${this._handleSectionExpand}"
@@ -2075,11 +2355,7 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
2075
2355
  ${E.t("form.submit")}
2076
2356
  </button>
2077
2357
 
2078
- <div class="form-meta">
2079
- <span>${E.t("form.errors")}: ${t}</span>
2080
- <span>${E.t("form.modified")}: ${this._dirty?E.t("form.yes"):E.t("form.no")}</span>
2081
- <span>${E.t("form.valid")}: ${this._valid?E.t("form.yes"):E.t("form.no")}</span>
2082
- </div>
2358
+
2083
2359
  </div>
2084
2360
 
2085
2361
  <!-- Filter Roles Dialog -->
@@ -2087,13 +2363,52 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
2087
2363
  <jupiter-filter-roles-dialog
2088
2364
  ?open="${this._showFilterDialog}"
2089
2365
  .availableRoles="${this._allSections}"
2090
- .selectedRoleIds="${this._selectedRoleIds}"
2366
+ .selectedRoleIds="${this._getRoleIdsArray()}"
2091
2367
  .periodPreferences="${this._periodPreferences}"
2368
+ .mode="${this.mode}"
2092
2369
  @dialog-cancel="${this._handleFilterDialogCancel}"
2093
2370
  @roles-filter-apply="${this._handleRoleFilterApply}"
2094
2371
  @click="${this._handleFilterDialogCancel}"
2095
2372
  ></jupiter-filter-roles-dialog>
2096
2373
  `:""}
2374
+
2375
+ <!-- Validation Error Popup -->
2376
+ ${this._showErrorPopup?e.html`
2377
+ <div class="error-popup-overlay" @click="${()=>{this._showErrorPopup=!1,this.requestUpdate()}}">
2378
+ <div class="error-popup" @click="${e=>e.stopPropagation()}">
2379
+ <div class="error-popup-header">
2380
+ <h3>âš ī¸ ${E.t("error.popup.title")}</h3>
2381
+ <button class="error-popup-close" @click="${()=>{this._showErrorPopup=!1,this.requestUpdate()}}">×</button>
2382
+ </div>
2383
+ <div class="error-popup-content">
2384
+ <p>${E.t("error.popup.message")}</p>
2385
+ <ul class="error-list">
2386
+ ${this._xbrlFormErrors.map(t=>e.html`
2387
+ <li>
2388
+ <strong>${E.t("error.popup.field")}</strong>
2389
+ <a
2390
+ href="javascript:void(0)"
2391
+ class="error-field-link"
2392
+ @click="${()=>this._handleErrorFieldClick(t.conceptId,t.columnId,t.sectionId)}"
2393
+ title="${E.t("error.popup.clickToFocus")}"
2394
+ >
2395
+ ${t.conceptId}__${t.columnId}
2396
+ </a><br>
2397
+ <strong>${E.t("error.popup.value")}</strong> ${t.value}<br>
2398
+ <strong>${E.t("error.popup.errors")}</strong>
2399
+ <ul>
2400
+ ${t.errors.map(t=>e.html`<li>${t.message}</li>`)}
2401
+ </ul>
2402
+ </li>
2403
+ `)}
2404
+ </ul>
2405
+ </div>
2406
+ <div class="error-popup-footer">
2407
+ <button class="btn-primary" @click="${()=>{this._showErrorPopup=!1,this.requestUpdate()}}">${E.t("error.popup.ok")}</button>
2408
+ </div>
2409
+ </div>
2410
+ </div>
2411
+ `:""}
2097
2412
  </div>
2098
2413
  `:e.html`<div>${E.t("form.loading")}</div>`}},exports.JupiterDynamicForm.styles=e.css`
2099
2414
  :host {
@@ -2524,5 +2839,127 @@ const $={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:x},S=(e=$,t,
2524
2839
  cursor: pointer;
2525
2840
  user-select: none;
2526
2841
  }
2527
- `,ee([I({type:Object})],exports.JupiterDynamicForm.prototype,"schema",2),ee([I({type:Object})],exports.JupiterDynamicForm.prototype,"xbrlInput",2),ee([I({type:Object})],exports.JupiterDynamicForm.prototype,"config",2),ee([I({type:Object})],exports.JupiterDynamicForm.prototype,"initialData",2),ee([I({type:Boolean})],exports.JupiterDynamicForm.prototype,"disabled",2),ee([I({type:Boolean})],exports.JupiterDynamicForm.prototype,"readonly",2),ee([I({type:String})],exports.JupiterDynamicForm.prototype,"periodStartDate",2),ee([I({type:String})],exports.JupiterDynamicForm.prototype,"periodEndDate",2),ee([I({type:String})],exports.JupiterDynamicForm.prototype,"language",2),ee([I({type:String})],exports.JupiterDynamicForm.prototype,"display",2),ee([I({type:String})],exports.JupiterDynamicForm.prototype,"mode",2),ee([I({type:Array})],exports.JupiterDynamicForm.prototype,"financialStatementsTypeAxis",2),ee([I({type:Object,attribute:"dynaforms-metadata"})],exports.JupiterDynamicForm.prototype,"dynaformsMetadata",2),ee([I({type:Object,attribute:"dynaforms-facts"})],exports.JupiterDynamicForm.prototype,"dynaformsFacts",2),ee([w()],exports.JupiterDynamicForm.prototype,"_formData",2),ee([w()],exports.JupiterDynamicForm.prototype,"_draftLoaded",2),ee([w()],exports.JupiterDynamicForm.prototype,"_draftLoadedAt",2),ee([w()],exports.JupiterDynamicForm.prototype,"_preservedFormData",2),ee([w()],exports.JupiterDynamicForm.prototype,"_periodData",2),ee([w()],exports.JupiterDynamicForm.prototype,"_preservedPeriodData",2),ee([w()],exports.JupiterDynamicForm.prototype,"_typedMemberData",2),ee([w()],exports.JupiterDynamicForm.prototype,"_preservedTypedMemberData",2),ee([w()],exports.JupiterDynamicForm.prototype,"_columns",2),ee([w()],exports.JupiterDynamicForm.prototype,"_errors",2),ee([w()],exports.JupiterDynamicForm.prototype,"_touched",2),ee([w()],exports.JupiterDynamicForm.prototype,"_dirty",2),ee([w()],exports.JupiterDynamicForm.prototype,"_valid",2),ee([w()],exports.JupiterDynamicForm.prototype,"_submitted",2),ee([w()],exports.JupiterDynamicForm.prototype,"_currentSchema",2),ee([w()],exports.JupiterDynamicForm.prototype,"_allSections",2),ee([w()],exports.JupiterDynamicForm.prototype,"_selectedRoleIds",2),ee([w()],exports.JupiterDynamicForm.prototype,"_showFilterDialog",2),ee([w()],exports.JupiterDynamicForm.prototype,"_periodPreferences",2),ee([w()],exports.JupiterDynamicForm.prototype,"_activeSidePanelRoleId",2),ee([w()],exports.JupiterDynamicForm.prototype,"_sidePanelSearchQuery",2),ee([w()],exports.JupiterDynamicForm.prototype,"_sidePanelCollapsed",2),ee([w()],exports.JupiterDynamicForm.prototype,"_adminRoleConfigs",2),exports.JupiterDynamicForm=ee([t("jupiter-dynamic-form")],exports.JupiterDynamicForm);exports.FormValidator=C,exports.TYPE_INPUT_MAP=P,exports.getInputTypeForConceptType=A,exports.isCheckboxType=R,exports.isNumericType=L,exports.isSelectType=function(e){return"select"===e},exports.isTextareaType=j,exports.version="1.5.0";
2842
+
2843
+ /* Error Popup Styles */
2844
+ .error-popup-overlay {
2845
+ position: fixed;
2846
+ top: 0;
2847
+ left: 0;
2848
+ right: 0;
2849
+ bottom: 0;
2850
+ background: rgba(0, 0, 0, 0.5);
2851
+ display: flex;
2852
+ align-items: center;
2853
+ justify-content: center;
2854
+ z-index: 10000;
2855
+ }
2856
+
2857
+ .error-popup {
2858
+ background: white;
2859
+ border-radius: 8px;
2860
+ max-width: 600px;
2861
+ width: 90%;
2862
+ max-height: 80vh;
2863
+ overflow: hidden;
2864
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
2865
+ display: flex;
2866
+ flex-direction: column;
2867
+ }
2868
+
2869
+ .error-popup-header {
2870
+ display: flex;
2871
+ justify-content: space-between;
2872
+ align-items: center;
2873
+ padding: 20px 24px;
2874
+ border-bottom: 1px solid var(--jupiter-border-color, #ddd);
2875
+ background: var(--jupiter-section-header-background, #f0f2f5);
2876
+ }
2877
+
2878
+ .error-popup-header h3 {
2879
+ margin: 0;
2880
+ font-size: 18px;
2881
+ font-weight: 600;
2882
+ color: var(--jupiter-error-color, #d32f2f);
2883
+ }
2884
+
2885
+ .error-popup-close {
2886
+ background: transparent;
2887
+ border: none;
2888
+ font-size: 28px;
2889
+ cursor: pointer;
2890
+ padding: 0;
2891
+ width: 32px;
2892
+ height: 32px;
2893
+ display: flex;
2894
+ align-items: center;
2895
+ justify-content: center;
2896
+ border-radius: 4px;
2897
+ color: var(--jupiter-text-color, #333);
2898
+ transition: background-color 0.2s;
2899
+ }
2900
+
2901
+ .error-popup-close:hover {
2902
+ background-color: rgba(0, 0, 0, 0.05);
2903
+ }
2904
+
2905
+ .error-popup-content {
2906
+ padding: 24px;
2907
+ overflow-y: auto;
2908
+ flex: 1;
2909
+ }
2910
+
2911
+ .error-popup-content p {
2912
+ margin: 0 0 16px 0;
2913
+ color: var(--jupiter-text-primary, #333);
2914
+ }
2915
+
2916
+ .error-list {
2917
+ list-style: none;
2918
+ padding: 0;
2919
+ margin: 0;
2920
+ }
2921
+
2922
+ .error-list > li {
2923
+ padding: 12px;
2924
+ background: #f8f9fa;
2925
+ border: 1px solid #dee2e6;
2926
+ border-radius: 4px;
2927
+ margin-bottom: 12px;
2928
+ }
2929
+
2930
+ .error-list > li strong {
2931
+ color: var(--jupiter-text-primary, #333);
2932
+ font-weight: 600;
2933
+ }
2934
+
2935
+ .error-list ul {
2936
+ margin: 8px 0 0 0;
2937
+ padding-left: 20px;
2938
+ }
2939
+
2940
+ .error-list ul li {
2941
+ color: var(--jupiter-error-color, #d32f2f);
2942
+ margin: 4px 0;
2943
+ }
2944
+
2945
+ .error-popup-footer {
2946
+ padding: 16px 24px;
2947
+ border-top: 1px solid var(--jupiter-border-color, #ddd);
2948
+ display: flex;
2949
+ justify-content: flex-end;
2950
+ gap: 12px;
2951
+ }
2952
+
2953
+ .error-field-link {
2954
+ color: #0066cc;
2955
+ text-decoration: underline;
2956
+ cursor: pointer;
2957
+ font-family: monospace;
2958
+ }
2959
+
2960
+ .error-field-link:hover {
2961
+ color: #0052a3;
2962
+ text-decoration: none;
2963
+ }
2964
+ `,re([S({type:Object})],exports.JupiterDynamicForm.prototype,"schema",2),re([S({type:Object})],exports.JupiterDynamicForm.prototype,"xbrlInput",2),re([S({type:Object})],exports.JupiterDynamicForm.prototype,"config",2),re([S({type:Object})],exports.JupiterDynamicForm.prototype,"initialData",2),re([S({type:Boolean})],exports.JupiterDynamicForm.prototype,"disabled",2),re([S({type:Boolean})],exports.JupiterDynamicForm.prototype,"readonly",2),re([S({type:String})],exports.JupiterDynamicForm.prototype,"periodStartDate",2),re([S({type:String})],exports.JupiterDynamicForm.prototype,"periodEndDate",2),re([S({type:String})],exports.JupiterDynamicForm.prototype,"language",2),re([S({type:String})],exports.JupiterDynamicForm.prototype,"display",2),re([S({type:String})],exports.JupiterDynamicForm.prototype,"mode",2),re([S({type:Array})],exports.JupiterDynamicForm.prototype,"financialStatementsTypeAxis",2),re([S({type:Array})],exports.JupiterDynamicForm.prototype,"defaultUnits",2),re([S({type:Object,attribute:"dynaforms-metadata"})],exports.JupiterDynamicForm.prototype,"dynaformsMetadata",2),re([S({type:Object,attribute:"dynaforms-facts"})],exports.JupiterDynamicForm.prototype,"dynaformsFacts",2),re([w()],exports.JupiterDynamicForm.prototype,"_formData",2),re([w()],exports.JupiterDynamicForm.prototype,"_draftLoaded",2),re([w()],exports.JupiterDynamicForm.prototype,"_draftLoadedAt",2),re([w()],exports.JupiterDynamicForm.prototype,"_preservedFormData",2),re([w()],exports.JupiterDynamicForm.prototype,"_periodData",2),re([w()],exports.JupiterDynamicForm.prototype,"_preservedPeriodData",2),re([w()],exports.JupiterDynamicForm.prototype,"_unitData",2),re([w()],exports.JupiterDynamicForm.prototype,"_preservedUnitData",2),re([w()],exports.JupiterDynamicForm.prototype,"_typedMemberData",2),re([w()],exports.JupiterDynamicForm.prototype,"_preservedTypedMemberData",2),re([w()],exports.JupiterDynamicForm.prototype,"_columns",2),re([w()],exports.JupiterDynamicForm.prototype,"_errors",2),re([w()],exports.JupiterDynamicForm.prototype,"_touched",2),re([w()],exports.JupiterDynamicForm.prototype,"_dirty",2),re([w()],exports.JupiterDynamicForm.prototype,"_valid",2),re([w()],exports.JupiterDynamicForm.prototype,"_submitted",2),re([w()],exports.JupiterDynamicForm.prototype,"_xbrlFormErrors",2),re([w()],exports.JupiterDynamicForm.prototype,"_showErrorPopup",2),re([w()],exports.JupiterDynamicForm.prototype,"_currentSchema",2),re([w()],exports.JupiterDynamicForm.prototype,"_allSections",2),re([w()],exports.JupiterDynamicForm.prototype,"_selectedRoleIds",2),re([w()],exports.JupiterDynamicForm.prototype,"_showFilterDialog",2),re([w()],exports.JupiterDynamicForm.prototype,"_periodPreferences",2),re([w()],exports.JupiterDynamicForm.prototype,"_activeSidePanelRoleId",2),re([w()],exports.JupiterDynamicForm.prototype,"_sidePanelSearchQuery",2),re([w()],exports.JupiterDynamicForm.prototype,"_sidePanelCollapsed",2),re([w()],exports.JupiterDynamicForm.prototype,"_adminRoleConfigs",2),exports.JupiterDynamicForm=re([t("jupiter-dynamic-form")],exports.JupiterDynamicForm);exports.FormValidator=C,exports.TYPE_INPUT_MAP=P,exports.XBRLValidator=R,exports.collectEnumerationsFromChain=O,exports.determineInputTypeFromBaseChain=J,exports.getInputTypeForConceptType=A,exports.isCheckboxType=L,exports.isNumericType=M,exports.isSelectType=function(e){return"select"===e},exports.isTextareaType=j,exports.resolveBaseTypeChain=U,exports.version="1.5.0";
2528
2965
  //# sourceMappingURL=index.js.map