jupiter-dynamic-forms 1.20.2 → 1.20.4
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/core/concept-tree.d.ts.map +1 -1
- package/dist/core/dynamic-form.d.ts +49 -1
- package/dist/core/dynamic-form.d.ts.map +1 -1
- package/dist/core/form-field.d.ts.map +1 -1
- package/dist/core/form-section.d.ts +4 -0
- package/dist/core/form-section.d.ts.map +1 -1
- package/dist/core/formula-validation-dialog.d.ts +32 -0
- package/dist/core/formula-validation-dialog.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +484 -183
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1846 -282
- package/dist/index.mjs.map +1 -1
- package/dist/schema/types.d.ts +33 -0
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/schema/xbrl-types.d.ts +67 -0
- package/dist/schema/xbrl-types.d.ts.map +1 -1
- package/dist/utils/formula-constants.d.ts +7 -0
- package/dist/utils/formula-constants.d.ts.map +1 -0
- package/dist/utils/formula-expression-evaluator.d.ts +64 -0
- package/dist/utils/formula-expression-evaluator.d.ts.map +1 -0
- package/dist/utils/formula-precondition-evaluator.d.ts +33 -0
- package/dist/utils/formula-precondition-evaluator.d.ts.map +1 -0
- package/dist/utils/formula-resolution-context.d.ts +53 -0
- package/dist/utils/formula-resolution-context.d.ts.map +1 -0
- package/dist/utils/formula-variable-resolver.d.ts +48 -0
- package/dist/utils/formula-variable-resolver.d.ts.map +1 -0
- package/dist/utils/total-group-resolver.d.ts +68 -0
- package/dist/utils/total-group-resolver.d.ts.map +1 -0
- package/dist/utils/total-label.d.ts +9 -0
- package/dist/utils/total-label.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,23 +3,23 @@
|
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google LLC
|
|
5
5
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
-
*/let
|
|
6
|
+
*/let a=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==r)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(o&&void 0===e){const i=void 0!==t&&1===t.length;i&&(e=n.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&n.set(t,e))}return e}toString(){return this.cssText}};const s=o?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return(e=>new a("string"==typeof e?e:e+"",void 0,r))(t)})(e):e,{is:l,defineProperty:d,getOwnPropertyDescriptor:c,getOwnPropertyNames:p,getOwnPropertySymbols:u,getPrototypeOf:h}=Object,m=globalThis,f=m.trustedTypes,g=f?f.emptyScript:"",b=m.reactiveElementPolyfillSupport,v=(e,t)=>e,y={toAttribute(e,t){switch(t){case Boolean:e=e?g:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=null!==e;break;case Number:i=null===e?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch(o){i=null}}return i}},x=(e,t)=>!l(e,t),_={attribute:!0,type:String,converter:y,reflect:!1,useDefault:!1,hasChanged:x};
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
9
9
|
* Copyright 2017 Google LLC
|
|
10
10
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
-
*/Symbol.metadata??(Symbol.metadata=Symbol("metadata")),m.litPropertyMetadata??(m.litPropertyMetadata=new WeakMap);class D extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=_){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),o=this.getPropertyDescriptor(e,i,t);void 0!==o&&d(this.prototype,e,o)}}static getPropertyDescriptor(e,t,i){const{get:o,set:r}=c(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:o,set(t){const n=null==o?void 0:o.call(this);null==r||r.call(this,t),this.requestUpdate(e,n,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??_}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const e=
|
|
11
|
+
*/Symbol.metadata??(Symbol.metadata=Symbol("metadata")),m.litPropertyMetadata??(m.litPropertyMetadata=new WeakMap);class D extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=_){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),o=this.getPropertyDescriptor(e,i,t);void 0!==o&&d(this.prototype,e,o)}}static getPropertyDescriptor(e,t,i){const{get:o,set:r}=c(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:o,set(t){const n=null==o?void 0:o.call(this);null==r||r.call(this,t),this.requestUpdate(e,n,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??_}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const e=h(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const e=this.properties,t=[...p(e),...u(e)];for(const i of t)this.createProperty(i,e[i])}const e=this[Symbol.metadata];if(null!==e){const t=litPropertyMetadata.get(e);if(void 0!==t)for(const[e,i]of t)this.elementProperties.set(e,i)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const e=this._$Eu(t,i);void 0!==e&&this._$Eh.set(e,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const e of i)t.unshift(s(e))}else void 0!==e&&t.push(s(e));return t}static _$Eu(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),null==(e=this.constructor.l)||e.forEach(e=>e(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),void 0!==this.renderRoot&&this.isConnected&&(null==(t=e.hostConnected)||t.call(e))}removeController(e){var t;null==(t=this._$EO)||t.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{if(o)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const o of t){const t=document.createElement("style"),r=i.litNonce;void 0!==r&&t.setAttribute("nonce",r),t.textContent=o.cssText,e.appendChild(t)}})(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null==(e=this._$EO)||e.forEach(e=>{var t;return null==(t=e.hostConnected)?void 0:t.call(e)})}enableUpdating(e){}disconnectedCallback(){var e;null==(e=this._$EO)||e.forEach(e=>{var t;return null==(t=e.hostDisconnected)?void 0:t.call(e)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){var i;const o=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,o);if(void 0!==r&&!0===o.reflect){const n=(void 0!==(null==(i=o.converter)?void 0:i.toAttribute)?o.converter:y).toAttribute(t,o.type);this._$Em=e,null==n?this.removeAttribute(r):this.setAttribute(r,n),this._$Em=null}}_$AK(e,t){var i,o;const r=this.constructor,n=r._$Eh.get(e);if(void 0!==n&&this._$Em!==n){const e=r.getPropertyOptions(n),a="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==(null==(i=e.converter)?void 0:i.fromAttribute)?e.converter:y;this._$Em=n;const s=a.fromAttribute(t,e.type);this[n]=s??(null==(o=this._$Ej)?void 0:o.get(n))??s,this._$Em=null}}requestUpdate(e,t,i){var o;if(void 0!==e){const r=this.constructor,n=this[e];if(i??(i=r.getPropertyOptions(e)),!((i.hasChanged??x)(n,t)||i.useDefault&&i.reflect&&n===(null==(o=this._$Ej)?void 0:o.get(e))&&!this.hasAttribute(r._$Eu(e,i))))return;this.C(e,t,i)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:o,wrapped:r},n){i&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,n??t??this[e]),!0!==r||void 0!==n)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),!0===o&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}const e=this.constructor.elementProperties;if(e.size>0)for(const[t,i]of e){const{wrapped:e}=i,o=this[t];!0!==e||this._$AL.has(t)||void 0===o||this.C(t,void 0,i,o)}}let t=!1;const i=this._$AL;try{t=this.shouldUpdate(i),t?(this.willUpdate(i),null==(e=this._$EO)||e.forEach(e=>{var t;return null==(t=e.hostUpdate)?void 0:t.call(e)}),this.update(i)):this._$EM()}catch(o){throw t=!1,this._$EM(),o}t&&this._$AE(i)}willUpdate(e){}_$AE(e){var t;null==(t=this._$EO)||t.forEach(e=>{var t;return null==(t=e.hostUpdated)?void 0:t.call(e)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(e=>this._$ET(e,this[e]))),this._$EM()}updated(e){}firstUpdated(e){}}D.elementStyles=[],D.shadowRootOptions={mode:"open"},D[v("elementProperties")]=new Map,D[v("finalized")]=new Map,null==b||b({ReactiveElement:D}),(m.reactiveElementVersions??(m.reactiveElementVersions=[])).push("2.1.1");
|
|
12
12
|
/**
|
|
13
13
|
* @license
|
|
14
14
|
* Copyright 2017 Google LLC
|
|
15
15
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
16
|
*/
|
|
17
|
-
const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,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
|
|
17
|
+
const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,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 w(e){return(t,i)=>"object"==typeof 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 S({...e,state:!0,attribute:!1})}class C{static validateField(e,t,i,o,r,n=[]){const s=[];for(const l of n){const n=this.validateRule(e,t,i,o,r,l);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 _extractDocumentationLabels(e){const t={};return e.filter(e=>"http://www.xbrl.org/2003/role/documentation"===e.role).forEach(e=>{t[e.lang]=e.label}),t}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 l=e.presentation[0],a=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 l.roles.forEach(e=>{const n=this.buildSectionFromRole(e,t,i,a,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(l.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,l;let a;if(e.labels&&e.labels.length>0){const t=e.labels.find(e=>e.lang===r),i=e.labels.find(e=>"en"===e.lang)||e.labels[0];a=(t||i).label}else a=this.extractRoleTitle(e.role||e.id||"Unknown Role");const d=this.getAllNonAbstractConcepts(e),c=new Set(d.filter(e=>e.periodType).map(e=>e.periodType));let p=null==o?void 0:o.roles.find(t=>t.roleId===e.id);const h=null==n?void 0:n[e.id];p&&(null==h?void 0:h.dimensionSelections)&&h.dimensionSelections.length>0&&(console.log(`🔍 Filtering dimensions for role ${e.id} based on user selections`),p=this.filterHypercubeDimensionsBySelection(p,h.dimensionSelections));const u=this.generateDefaultColumnsForRole(e,t||"2025-01-01",i||"2025-12-31",p,d,c,h,r),m={periodTypes:c,availableColumnIds:u.map(e=>e.id),availableColumns:u},f=[],b=new Map;return(null==(s=e.presentationLinkbase)?void 0:s.concepts)&&e.presentationLinkbase.concepts.forEach(o=>{const n=this.buildConceptTree(o,0,t,i,m,e.id,r,b);n&&f.push(n)}),p&&(null==(l=p.items)?void 0:l.length)||!o||f.forEach(t=>this.applyCrossRoleDimensions(t,e.id,o,r)),{id:e.id,title:a,description:e.description||`Section for ${a}`,concepts:f,columns:u,expanded:!1,metadata:{roleURI:e.roleURI,originalRole:e.role},showPeriodControl:c.size>1,showPreviousYear:!0===e.showPreviousYear,instant:!0===e.instant,duration:!0===e.duration}}static buildConceptTree(e,t,i,o,r,n,s="en",l,a){var d,c;const p=this.getPreferredLabel(e.labels,s,e.preferredLabel),h=(null==(d=e.preferredLabel)?void 0:d.includes("periodStartLabel"))?"start":(null==(c=e.preferredLabel)?void 0:c.includes("periodEndLabel"))?"end":a,u="start"===h?"periodStartLabel":"end"===h?"periodEndLabel":void 0,m=[];if(!e.elementAbstract){let t=[];t=(null==r?void 0:r.availableColumnIds)&&r.availableColumnIds.length>0?r.availableColumnIds:["duration"],t.forEach(t=>{var n;const l=null==(n=null==r?void 0:r.availableColumns)?void 0:n.find(e=>e.id===t),d=(null==l?void 0:l.periodStartDate)||i,c=(null==l?void 0:l.periodEndDate)||o,p=this.createFieldFromConcept(e,d,c,t,a,s);p&&m.push(p)})}const f=[];e.children&&e.children.length>0&&e.children.forEach(e=>{const a=this.buildConceptTree(e,t+1,i,o,r,n,s,l,h);a&&f.push(a)});if(!(m.length>0||f.length>0))return null;let b=this.createUniqueConceptId(e,n);if(l){const e=l.get(b)??0;l.set(b,e+1),e>0&&(b=`${b}__occ${e+1}`)}const g={conceptName:e.conceptName,type:e.type,substitutionGroup:e.substitutionGroup,periodType:e.periodType,balance:e.balance,documentationLabels:this._extractDocumentationLabels(e.labels)};return{id:b,originalConceptId:e.id,name:e.conceptName,label:p,description:`${e.conceptName} (${e.type})`,type:e.type,level:t,children:f,fields:m,conceptMetadata:g,facts:e.facts||[],collapsed:t>0,abstract:e.elementAbstract,periodType:e.periodType,balance:e.balance,preferredLabel:e.preferredLabel,effectivePeriodRole:u}}static createFieldFromConcept(e,t,i,o,r,n="en"){var s;const l=this.mapXBRLTypeToFieldType(e.type),a=this.getPreferredLabel(e.labels,n,e.preferredLabel);let d;d=o||"duration";const c={id:`${e.id}_${d}_field`,conceptId:e.id,columnId:d,type:l,label:a,placeholder:`Enter ${a.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?(null==(s=e.preferredLabel)?void 0:s.includes("periodStartLabel"))||"start"===r?this.subtractOneDay(t||"2025-01-01"):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: ${c.periodType}, ColumnId: ${d}`),c}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",i){if(!e||0===e.length)return"Unnamed Concept";const o=e.filter(e=>e.lang===t),r=o.length>0?o:e;if(i){const t=o.find(e=>e.role===i);if(t)return t.label;const r=e.find(e=>e.role===i);if(r)return r.label}const n=r.find(e=>e.preferredLabel);if(n)return n.label;const s=r.find(e=>"http://www.xbrl.org/2003/role/label"===e.role);if(s)return s.label;const l=r.find(e=>"http://www.xbrl.org/2003/role/terseLabel"===e.role);return l?l.label:r.length>0?r[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 filterHypercubeDimensionsBySelection(e,t){const i=JSON.parse(JSON.stringify(e));return i.items&&0!==i.items.length?(i.items.forEach(e=>{e.dimensions&&(e.dimensions=e.dimensions.map(e=>{var i,o;const r=t.find(t=>t.dimensionId===e.id);if(!r||!r.selectedMemberIds||0===r.selectedMemberIds.length)return e;const n={...e};return n.members=this.filterMembersBySelection(e.members,r.selectedMemberIds),console.log(` ✅ Filtered dimension ${e.id}: ${(null==(i=e.members)?void 0:i.length)||0} → ${(null==(o=n.members)?void 0:o.length)||0} members`),n}))}),i):i}static filterMembersBySelection(e,t){if(!e||!Array.isArray(e))return[];const i=[];return e.forEach(e=>{if(t.includes(e.id)&&i.push({...e,children:[]}),e.children&&e.children.length>0){const o=this.filterMembersBySelection(e.children,t);i.push(...o)}}),i}static findCrossRoleDimensions(e,t,i,o="en"){var r,n;const s=[];for(const d of i.roles)if(d.roleId!==t)for(const t of d.items)if((null==(r=t.conceptIds)?void 0:r.includes(e))&&(null==(n=t.dimensions)?void 0:n.some(e=>e.typedMember))){s.push(d);break}if(1!==s.length)return null;const l=s[0].items.find(t=>{var i;return null==(i=t.conceptIds)?void 0:i.includes(e)});if(!l)return null;const a=[];for(const d of l.dimensions){if(!d.typedMember)continue;const e=d.labels.find(e=>e.lang===o)||d.labels.find(e=>"en"===e.lang)||d.labels[0],t=(null==e?void 0:e.label)||d.id;a.push({axisId:d.id,axisLabel:t,typedMemberId:d.typedMember.id,memberLabel:t})}return a.length>0?a:null}static applyCrossRoleDimensions(e,t,i,o){var r;if(!e.abstract&&e.fields&&e.fields.length>0){const r=this.findCrossRoleDimensions(e.originalConceptId,t,i,o);r&&e.fields.forEach(e=>{e.crossRoleTypedMembers=r})}null==(r=e.children)||r.forEach(e=>this.applyCrossRoleDimensions(e,t,i,o))}static generateDefaultColumnsForRole(e,t,i,o,r,n,s,l="en"){var a,d;const c=r||this.getAllNonAbstractConcepts(e),p=n||new Set(c.filter(e=>e.periodType).map(e=>e.periodType));if(0===c.length)return[{id:"default",title:"Value",description:"Default value column",type:"base",order:0,removable:!1}];let h=[];if(1===(null==(a=null==o?void 0:o.items)?void 0:a.length)){const e=o.items[0];1===e.dimensions.length?h=this.generateSingleDimensionColumns(e.dimensions[0],t,i,p,l):e.dimensions.length>1&&(h=this.generateMultiDimensionColumns(e.dimensions,t,i,p,l)),s&&(h=this.filterColumnsByPeriodPreferences(h,s))}else(null==(d=null==o?void 0:o.items)?void 0:d.length)&&o.items.length;const u=[];h.length>0?u.push(...h):0===p.size?u.push({id:"default",title:this.formatPeriodDisplay(t,i),description:"",type:"base",order:0,removable:!1,periodStartDate:t,periodEndDate:i}):u.push({id:"duration",title:this.formatPeriodDisplay(t,i),description:"",type:"base",order:0,removable:!1,periodStartDate:t,periodEndDate:i});let m=u;if(s&&(m=this.filterColumnsByPeriodPreferences(u,s)),null==s?void 0:s.showPreviousYear){const e=this.generatePreviousYearColumns(m,t,i);m=[...m,...e]}return m}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 subtractOneDay(e){try{const t=new Date(e);return t.setDate(t.getDate()-1),t.toISOString().split("T")[0]}catch(t){return console.error(`Error subtracting one day from 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="",l="";e.dimensionData?(i=e.title,s=this.formatPeriodDisplay(r,n),l=`${e.id}_prev`):(i=this.formatPeriodDisplay(r,n),s="",l=`duration_prev_${t}`),o.push({...e,id:l,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")),l=e.id.includes("instant")||(null==(n=null==(r=e.dimensionData)?void 0:r.dimensionId)?void 0:n.includes("instant"));return!s&&!l||!(s&&!t.showDuration)&&!(l&&!t.showInstant)})}static generateSingleDimensionColumns(e,t,i,o,r="en"){if(e.typedMember&&(!e.members||0===e.members.length)){const n=this.getPreferredLabel(e.labels,r)||e.conceptName,s={axisId:e.id,axisLabel:n,typedMemberId:e.typedMember.id,dimensionKey:`${n} | [Typed Input]`,dimensionIdKey:`${e.id}|[typed]`},l=[];return 0===o.size?l.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")?l.push({id:"typed-instant",title:`${n} `,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"),l.push({id:"typed-duration",title:`${n} `,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})),l}if(!e.members||!Array.isArray(e.members))return[];if(0===e.members.length)return[];const n=this.getPreferredLabel(e.labels,r)||e.conceptName,s=e.members[0],l=this.getPreferredLabel(s.labels,r)||s.conceptName,a={axisId:e.id,axisLabel:n,memberId:s.id,memberLabel:l,dimensionKey:`${n} | ${l}`,dimensionIdKey:`${e.id} | ${s.id}`},d=[];return 0===o.size?d.push({id:"default",title:a.memberLabel,description:"Default value column",type:"dimension",dimensionData:{dimensionId:"default",axisId:a.axisId,memberId:a.memberId,memberValue:a.memberLabel,memberLabel:a.memberLabel,axis:a.axisLabel,axisLabel:a.axisLabel,memberKey:a.dimensionKey,dimensionIdKey:a.dimensionIdKey},order:0,removable:!1,periodStartDate:t,periodEndDate:i}):1===o.size&&o.has("instant")?d.push({id:"instant",title:`${a.memberLabel}`,description:i,type:"dimension",dimensionData:{dimensionId:"instant",axisId:a.axisId,memberId:a.memberId,memberValue:a.memberLabel,memberLabel:a.memberLabel,axis:a.axisLabel,axisLabel:a.axisLabel,memberKey:a.dimensionKey,dimensionIdKey:a.dimensionIdKey},order:0,removable:!1,periodStartDate:i,periodEndDate:i}):1===o.size&&o.has("duration")?d.push({id:"duration",title:`${a.memberLabel}`,description:`${t} / ${i}`,type:"dimension",dimensionData:{dimensionId:"duration",axisId:a.axisId,memberId:a.memberId,memberValue:a.memberLabel,memberLabel:a.memberLabel,axis:a.axisLabel,axisLabel:a.axisLabel,memberKey:a.dimensionKey,dimensionIdKey:a.dimensionIdKey},order:0,removable:!1,periodStartDate:t,periodEndDate:i}):d.push({id:"duration",title:`${a.memberLabel}`,description:this.formatPeriodDisplay(t,i),type:"dimension",dimensionData:{dimensionId:"duration",axisId:a.axisId,memberId:a.memberId,memberValue:a.memberLabel,memberLabel:a.memberLabel,axis:a.axisLabel,axisLabel:a.axisLabel,memberKey:a.dimensionKey,dimensionIdKey:a.dimensionIdKey},order:0,removable:!1,periodStartDate:t,periodEndDate:i}),d}static generateMultiDimensionColumns(e,t,i,o,r="en"){e.some(e=>e.typedMember);const n=e.filter(e=>!!e.typedMember||!!(e.members&&Array.isArray(e.members)&&e.members.length>0));if(0===n.length)return[];const s=n.map(e=>{const t=this.getPreferredLabel(e.labels,r)||e.conceptName;if(e.typedMember)return{id:e.id,axisLabel:t,isTyped:!0,typedMemberId:e.typedMember.id,members:[{id:"[typed]",label:`${t}`}]};const i=this.getAllDimensionMembers(e.members);return{id:e.id,axisLabel:t,isTyped:!1,members:i.map(e=>({id:e.id,label:this.getPreferredLabel(e.labels,r)||e.conceptName}))}}),l=this.generateDimensionCombinations(s),a=[];return l.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){if(!e)return"Unnamed Section";const t=e.match(/^\[[\d]+\]\s*(.+)$/);if(t)return t[1].trim();if(e.match(/^[a-z]+:[^:]*$/i)||e.match(/^urn:[^:]+:[^:]+/i)){const t=e.split(/[:\-]/);return t[t.length-1].replace(/[_\-]/g," ").replace(/\b\w/g,e=>e.toUpperCase())}return e.trim()||"Unnamed Section"}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:{conceptInfo:{title:"Concept Information",conceptName:"Concept name",type:"Type",substitutionGroup:"Substitution group",periodType:"Period type",balance:"Balance",documentation:"Documentation",instant:"Instant",duration:"Duration",close:"Close"},form:{markAsComplete:"Mark as Complete",loading:"Loading form...",submit:"Validate",save:"Save",saveDraft:"Save Draft",savingDraft:"Saving 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",validate:"Validate",preview:"Preview",download:"Download",cancelValidation:"Cancel Validation",lastValidationResults:"Last Validation Results",validationInProgress:"Validation In Progress"},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",dimensionMemberSelection:"Dimension Member Selection",selectAllMembers:"Select All",clearMembers:"Clear",availableRoles:"Available Roles",chosenRoles:"Chosen Roles",roleCount:"role(s)",rolesSelected:"role(s) selected",addSelectedRole:"Add selected role",addAllRoles:"Add all roles",removeSelectedRole:"Remove selected role",removeAllRoles:"Remove all roles",advancedFilter:"Advanced Filter",backToFilterRoles:"← Back",showFactsOnly:"Show facts only",showFactsOnlyDescription:"Hide all blank rows and sections. Only roles and rows with at least one filled value will be shown.",searchByConcept:"Search by concept",searchByConceptDescription:"Type concept name or label to filter roles and rows. Press Apply Filter to apply.",searchByConceptPlaceholder:"Type concept name or label and press Apply Filter...",clearFilters:"Clear Filters",resetFilter:"Reset"},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",hideColumn:"Hide column",showColumn:"Double-click to show 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:"e.g. 0.25 for 25% or 0.2550 for 25.50%",emailPlaceholder:"email@example.com",urlPlaceholder:"https://example.com",phonePlaceholder:"+1 (555) 000-0000",enterValue:"Enter value",enterDetailedInformation:"Enter detailed information...",scale:"Scale",addText:"Add text",editText:"Edit",save:"Save",cancel:"Cancel",characters:"characters",editPeriod:"Edit Period",from:"From",to:"To",date:"Date",unit:"Unit",selectUnit:"Select Unit",leaveBlankForInf:"Leave blank for INF"},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",unitRequired:"Unit is required. Please select a unit via the period icon."},xbrlValidation:{patternMismatch:"Value does not match required pattern: {{pattern}}",invalidPattern:"Invalid pattern configuration: {{pattern}}",exactLength:"Value must be exactly {{required}} characters (current: {{current}})",minLength:"Value must be at least {{required}} characters (current: {{current}})",maxLength:"Value must not exceed {{required}} characters (current: {{current}})",totalDigits:"Value must not exceed {{required}} total digits (current: {{current}})",ruleSummaryPattern:"Must match pattern: {{pattern}}",ruleSummaryExactLength:"Must be exactly {{required}} characters",ruleSummaryMinLength:"Minimum {{required}} characters",ruleSummaryMaxLength:"Maximum {{required}} characters",ruleSummaryTotalDigits:"Maximum {{required}} total digits"},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"}},calculationWarning:{title:"Calculation warning",summaryLine:'Total "{{label}}" should equal {{calculated}}, but you entered {{entered}}.',childrenPrefix:"Children:",childAdded:"{{label}} = {{value}} (added)",childSubtracted:"{{label}} = {{value}} (subtracted, opposite balance)",added:"Added",subtracted:"Subtracted (opposite balance)"}},nl:{conceptInfo:{title:"Conceptinformatie",conceptName:"Conceptnaam",type:"Type",substitutionGroup:"Substitutiegroep",periodType:"Periodetype",balance:"Saldo",documentation:"Documentatie",instant:"Moment",duration:"Periode",close:"Sluiten"},form:{markAsComplete:"Markeren als volledig behandeld",loading:"Formulier laden...",submit:"Valideren",save:"Opslaan",saveDraft:"Concept opslaan",savingDraft:"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",validate:"Valideren",preview:"Voorbeeld",download:"Downloaden",cancelValidation:"Validatie annuleren",lastValidationResults:"Laatste validatieresultaten",validationInProgress:"Validatie bezig"},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",dimensionMemberSelection:"Dimensieleden selectie",selectAllMembers:"Alles selecteren",clearMembers:"Wissen",availableRoles:"Beschikbare rollen",chosenRoles:"Gekozen rollen",roleCount:"rol(len)",rolesSelected:"rol(len) geselecteerd",addSelectedRole:"Geselecteerde rol toevoegen",addAllRoles:"Alle rollen toevoegen",removeSelectedRole:"Geselecteerde rol verwijderen",removeAllRoles:"Alle rollen verwijderen",advancedFilter:"Geavanceerd filter",backToFilterRoles:"← Terug",showFactsOnly:"Alleen feiten weergeven",showFactsOnlyDescription:"Verberg alle lege rijen en secties. Alleen rollen en rijen met minimaal één ingevulde waarde worden weergegeven.",searchByConcept:"Zoeken op concept",searchByConceptDescription:"Typ een conceptnaam of label om rollen en rijen te filteren. Druk op Filter toepassen om te activeren.",searchByConceptPlaceholder:"Typ conceptnaam of label en druk op Filter toepassen...",clearFilters:"Filters wissen",resetFilter:"Resetten"},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",hideColumn:"Kolom verbergen",showColumn:"Dubbelklik om kolom te tonen",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:"bijv. 0,25 voor 25% of 0,2550 voor 25,50%",emailPlaceholder:"email@voorbeeld.nl",urlPlaceholder:"https://voorbeeld.nl",phonePlaceholder:"+31 (0)20 123 4567",enterValue:"Voer waarde in",enterDetailedInformation:"Voer gedetailleerde informatie in...",scale:"Schaal",addText:"Tekst toevoegen",editText:"Bewerken",save:"Opslaan",cancel:"Annuleren",characters:"tekens",editPeriod:"Periode bewerken",from:"Van",to:"Tot",date:"Datum",unit:"Eenheid",selectUnit:"Selecteer eenheid",leaveBlankForInf:"Leeg laten voor INF"},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",unitRequired:"Eenheid is verplicht. Selecteer een eenheid via het periodeicoon."},xbrlValidation:{patternMismatch:"Waarde voldoet niet aan het vereiste patroon: {{pattern}}",invalidPattern:"Ongeldige patternconfiguratie: {{pattern}}",exactLength:"Waarde moet exact {{required}} tekens bevatten (huidig: {{current}})",minLength:"Waarde moet minimaal {{required}} tekens bevatten (huidig: {{current}})",maxLength:"Waarde mag niet meer dan {{required}} tekens bevatten (huidig: {{current}})",totalDigits:"Waarde mag niet meer dan {{required}} cijfers bevatten (huidig: {{current}})",ruleSummaryPattern:"Moet overeenkomen met patroon: {{pattern}}",ruleSummaryExactLength:"Moet exact {{required}} tekens bevatten",ruleSummaryMinLength:"Minimaal {{required}} tekens",ruleSummaryMaxLength:"Maximaal {{required}} tekens",ruleSummaryTotalDigits:"Maximaal {{required}} cijfers"},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"}},calculationWarning:{title:"Berekeningswaarschuwing",summaryLine:'Totaal "{{label}}" zou {{calculated}} moeten zijn, maar u heeft {{entered}} ingevoerd.',childrenPrefix:"Onderdelen:",childAdded:"{{label}} = {{value}} (opgeteld)",childSubtracted:"{{label}} = {{value}} (afgetrokken, tegengestelde balans)",added:"Opgeteld",subtracted:"Afgetrokken (tegengestelde balans)"}}};class k{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)}}k.currentLanguage="en";class R{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,description:i.description,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,l,a,d="en",c,p,h,u){return{periodStartDate:e,periodEndDate:t,language:i,reportingLanguage:d,selectedRoleIds:o,customColumns:this.extractCustomColumns(r),typedMemberData:n,periodPreferences:s,periodData:l,unitData:a,decimalsData:p,repeatCounts:c,roleCompletedStates:h,hiddenColumns:u,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 E{static findMatchingFact(e,t){if(!e||0===e.length)return null;const i=e.filter(e=>this.matchesPeriod(e,t));if(0===i.length)return null;const o=i.filter(e=>this.matchesDimensions(e,t));if(0===o.length)return null;if(o.length>1&&t.unit){const e=o.find(e=>this.matchesUnit(e,t));if(e)return e}return o[0]}static matchesPeriod(e,t){const i=this.parsePeriod(e.period);return"instant"===t.periodType&&t.periodInstantDate?i.isInstant&&i.instantDate===t.periodInstantDate:"duration"===t.periodType&&t.periodStartDate&&t.periodEndDate?!i.isInstant&&i.startDate===t.periodStartDate&&i.endDate===t.periodEndDate:t.periodInstantDate?i.isInstant&&i.instantDate===t.periodInstantDate:!t.periodStartDate||!t.periodEndDate||!i.isInstant&&i.startDate===t.periodStartDate&&i.endDate===t.periodEndDate}static matchesDimensions(e,t){const i=e.dimensions||[],o=this.extractDimensionsFromContext(t);if(0===o.length)return 0===i.length;if(0===i.length&&o.length>0)return!1;if(i.length!==o.length)return!1;return o.every(e=>i.some(t=>{if(!(this.normalizeAxisId(t.dimension)===this.normalizeAxisId(e.axisId)))return!1;if("explicit"===t.dimensionType&&e.memberId){return this.normalizeMemberId(t.member||"")===this.normalizeMemberId(e.memberId)}return!("typed"!==t.dimensionType||!e.isTyped)}))}static matchesUnit(e,t){if(!t.unit||!e.unitMeasure)return!0;return this.normalizeUnit(e.unitMeasure)===this.normalizeUnit(t.unit)}static parsePeriod(e){if(e.includes(" / ")){const[t,i]=e.split(" / ").map(e=>e.trim());return{isInstant:!1,startDate:t,endDate:i}}return{isInstant:!0,instantDate:e.trim()}}static extractDimensionsFromContext(e){if(!e.dimensionData)return[];const t=[];return e.dimensionData.combinations&&e.dimensionData.combinations.length>0&&e.dimensionData.combinations.forEach(e=>{t.push({axisId:e.axisId,memberId:e.memberId})}),e.dimensionData.typedMembers&&e.dimensionData.typedMembers.length>0&&e.dimensionData.typedMembers.forEach(e=>{t.push({axisId:e.axisId,memberId:"[typed]",isTyped:!0})}),t}static normalizeAxisId(e){if(!e)return"";if(e.includes(":")){const t=e.split(":");return t[1]||t[0]}if(e.includes("_")){e.split("_");const t=e.lastIndexOf("_");if(t>0)return e.substring(t+1)}return e}static normalizeMemberId(e){if(!e)return"";if(e.includes(":")){const t=e.split(":");return t[1]||t[0]}if(e.includes("_")){const t=e.lastIndexOf("_");if(t>0)return e.substring(t+1)}return e}static normalizeUnit(e){if(!e)return"";const t=e.split(":");return t.length>1?t[1]:t[0]}static extractTypedValues(e,t){const i={};if(!e||0===e.length)return i;return e.filter(e=>this.matchesPeriod(e,t)&&this.matchesDimensions(e,t)).forEach(e=>{e.dimensions&&e.dimensions.forEach(e=>{if("typed"===e.dimensionType&&e.typedMemberValue){const t=this.normalizeAxisId(e.dimension);i[t]=e.typedMemberValue}})}),i}static debugMatch(e,t){console.log("🔍 [FactMatcher] Debug Match"),console.log(" Context:",{conceptId:t.conceptId,columnId:t.columnId,period:"instant"===t.periodType?t.periodInstantDate:`${t.periodStartDate} / ${t.periodEndDate}`,dimensions:this.extractDimensionsFromContext(t)}),console.log(" Facts:",e.map(e=>{var t;return{value:e.value,period:e.period,dimensions:null==(t=e.dimensions)?void 0:t.map(e=>`${e.dimension}:${e.member}`)}}));const i=this.findMatchingFact(e,t);console.log(" Match Result:",i?i.value:"No match")}}class M{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:k.t("xbrlValidation.patternMismatch",{pattern:t}),expectedValue:t,actualValue:e}}catch(i){return console.error(`Invalid regex pattern: ${t}`,i),{type:"pattern",message:k.t("xbrlValidation.invalidPattern",{pattern:t}),expectedValue:t,actualValue:e}}return null}static validateExactLength(e,t){return e.length!==t?{type:"length",message:k.t("xbrlValidation.exactLength",{required:t,current:e.length}),expectedValue:t,actualValue:e.length}:null}static validateMinLength(e,t){return e.length<t?{type:"minLength",message:k.t("xbrlValidation.minLength",{required:t,current:e.length}),expectedValue:t,actualValue:e.length}:null}static validateMaxLength(e,t){return e.length>t?{type:"maxLength",message:k.t("xbrlValidation.maxLength",{required:t,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:k.t("xbrlValidation.totalDigits",{required:t,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(k.t("xbrlValidation.ruleSummaryPattern",{pattern:o.pattern})),void 0!==o.length&&r.push(k.t("xbrlValidation.ruleSummaryExactLength",{required:o.length})),void 0!==o.minLength&&r.push(k.t("xbrlValidation.ruleSummaryMinLength",{required:o.minLength})),void 0!==o.maxLength&&r.push(k.t("xbrlValidation.ruleSummaryMaxLength",{required:o.maxLength})),void 0!==o.totalDigits&&r.push(k.t("xbrlValidation.ruleSummaryTotalDigits",{required:o.totalDigits})),r}}const j={"nl-types:formattedExplanationItemType":{fieldType:"textarea",placeholder:k.t("field.enterDetailedExplanation")},"nl-types:monetaryNoDecimals20ItemType":{fieldType:"number",htmlInputType:"text",inputMode:"decimal",allowDecimals:!1,step:1,placeholder:k.t("field.enterAmountNoDecimals")},"xbrli:monetaryItemType":{fieldType:"currency",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:.01,placeholder:k.t("field.enterCurrency")},"xbrli:stringItemType":{fieldType:"text",htmlInputType:"text",placeholder:k.t("field.enterText")},"xbrli:dateItemType":{fieldType:"date",htmlInputType:"date"},"xbrli:dateTimeItemType":{fieldType:"datetime",htmlInputType:"datetime-local"},"xbrli:integerItemType":{fieldType:"integer",htmlInputType:"text",inputMode:"numeric",allowDecimals:!1,step:1,placeholder:k.t("field.enterWholeNumber")},"xbrli:nonNegativeIntegerItemType":{fieldType:"integer",htmlInputType:"text",inputMode:"numeric",allowDecimals:!1,min:0,step:1,placeholder:k.t("field.enterPositiveNumber")},"xbrli:positiveIntegerItemType":{fieldType:"integer",htmlInputType:"text",inputMode:"numeric",allowDecimals:!1,min:1,step:1,placeholder:k.t("field.enterPositiveNumber")},"xbrli:decimalItemType":{fieldType:"decimal",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:"any",placeholder:k.t("field.enterDecimalValue")},"xbrli:sharesItemType":{fieldType:"number",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,min:0,step:.01,placeholder:k.t("field.enterNumberOfShares")},"xbrli:shares":{fieldType:"number",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,min:0,step:.01,placeholder:k.t("field.enterNumberOfShares")},"xbrli:gYearItemType":{fieldType:"number",htmlInputType:"text",inputMode:"numeric",allowDecimals:!1,min:1900,max:2100,step:1,placeholder:k.t("field.yearFormat")},"xbrli:booleanItemType":{fieldType:"boolean"},"xbrli:pureItemType":{fieldType:"percentage",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:.01,placeholder:k.t("field.enterPercentage")},"xbrli:percentItemType":{fieldType:"percentage",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:.01,placeholder:k.t("field.enterPercentage")},"xbrli:emailItemType":{fieldType:"email",htmlInputType:"email",placeholder:k.t("field.emailPlaceholder")},"xbrli:urlItemType":{fieldType:"url",htmlInputType:"url",placeholder:k.t("field.urlPlaceholder")},"xbrli:telephoneItemType":{fieldType:"tel",htmlInputType:"tel",placeholder:k.t("field.phonePlaceholder")}};function A(e,t){if(!e)return{fieldType:"text",htmlInputType:"text",placeholder:k.t("field.enterValue")};if(t&&t.length>0){const i=N(e,t);if(i.length>0){return V(i,t)}}if(console.log(`⚠️ [Type Resolution Fallback] Using pattern matching for: ${e}`),j[e])return j[e];const i=e.toLowerCase();if(i.includes("monetary"))return i.includes("nodecimals")||i.includes("no-decimals")?{fieldType:"number",htmlInputType:"text",inputMode:"decimal",allowDecimals:!1,step:1,placeholder:k.t("field.enterAmountNoDecimals")}:{fieldType:"currency",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:.01,placeholder:k.t("field.enterCurrency")};if(i.includes("explanation")||i.includes("description")||i.includes("notes")||i.includes("formatted"))return{fieldType:"textarea",placeholder:k.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:"text",inputMode:"numeric",allowDecimals:!1,min:i.includes("positive")?1:e?0:void 0,step:1,placeholder:k.t("field.enterWholeNumber")}}return i.includes("decimal")||i.includes("numeric")||i.includes("number")?{fieldType:"decimal",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:"any",placeholder:k.t("field.enterDecimalValue")}:i.includes("percent")||i.includes("pure")?{fieldType:"percentage",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:.01,placeholder:k.t("field.enterPercentage")}:{fieldType:"text",htmlInputType:"text",placeholder:k.t("field.enterValue")}}function P(e){return"textarea"===e}function L(e){return"boolean"===e}function O(e){return["number","decimal","integer","currency","percentage"].includes(e)}function N(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 z(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 V(e,t){if(!e||0===e.length)return{fieldType:"text",htmlInputType:"text",placeholder:k.t("field.enterValue")};if(t&&t.length>0){const i=z(e,t);if(i&&i.length>0)return{fieldType:"select",enumerations:i,placeholder:k.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:k.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:"text",inputMode:"numeric",allowDecimals:!1,min:o.includes("positive")?1:e?0:void 0,step:1,placeholder:k.t("field.enterWholeNumber")}}return i.some(e=>e.includes("percent")||e.includes("pure"))?{fieldType:"percentage",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:.01,placeholder:k.t("field.enterPercentage")}: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:"text",inputMode:"decimal",allowDecimals:!1,step:1,placeholder:k.t("field.enterAmountNoDecimals")}:{fieldType:"currency",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:.01,placeholder:k.t("field.enterCurrency")}:{fieldType:"decimal",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:"any",placeholder:k.t("field.enterDecimalValue")}:e.some(e=>"xbrli:stringItemType"===e)||i.some(e=>"string"===e||e.includes("stringitem"))?{fieldType:"text",htmlInputType:"text",placeholder:k.t("field.enterText")}:{fieldType:"text",htmlInputType:"text",placeholder:k.t("field.enterValue")}}var U=Object.defineProperty,J=Object.getOwnPropertyDescriptor,B=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?J(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&&U(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.mode="inputForm",this.globalDecimals="INF",this.typedMemberValues={},this._errors=[],this._xbrlErrors=[],this._touched=!1,this._showPeriodPopup=!1,this._availableUnits=[],this._numericDraftValue=null}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))}_isRoundingLevelConcept(){return!!this.conceptId&&this.conceptId.includes("DocumentIntendedRoundingLevel")}_isNumericField(){var e;return O(A(this.conceptType,this.datatypes).fieldType||(null==(e=this.field)?void 0:e.type)||"text")||"number"===this._getInputType()}_isIntermediateNumericValue(e){return"-"===e||"."===e||"-."===e}_handleInput(e){const t=e.target,i=this.value;let o=t.value;if(this._isNumericField()){const e=t.value;if(this._numericDraftValue=e,""===e||this._isIntermediateNumericValue(e))o=null;else{const t=Number(e);o=Number.isNaN(t)?null:t}}else"boolean"===this.field.type?(o=t.checked,this._numericDraftValue=null):this._numericDraftValue=null;this.value=o,this._touched=!0,this.dispatchEvent(new CustomEvent("field-change",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId,value:o,oldValue:i},bubbles:!0}))}_handleFocus(){this.dispatchEvent(new CustomEvent("field-focus",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId},bubbles:!0}))}_handleBlur(){let e=!1;if(this._isNumericField()&&null!==this._numericDraftValue){e=!0;const t=this._numericDraftValue;if(""===t||this._isIntermediateNumericValue(t))this.value=null;else{const e=Number(t);this.value=Number.isNaN(e)?null:e}this._numericDraftValue=null}if(this._isPercentItemType()&&e&&null!==this.value&&void 0!==this.value){const e=Number(this.value);if(!isNaN(e)&&Math.abs(e)>1){this.value=e/100;const t=e;this.dispatchEvent(new CustomEvent("field-change",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId,value:this.value,oldValue:t},bubbles:!0}))}}this._touched=!0,this._validateXBRLDatatype(),this._validateUnitSelection(),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`)}_isMonetaryType(){if(!this.conceptType||!this.datatypes)return!1;if(this.conceptType.includes("monetary")||this.conceptType.includes("Monetary"))return!0;return N(this.conceptType,this.datatypes).some(e=>e.includes("monetary")||e.includes("Monetary"))}_isPercentItemType(){if(!this.conceptType)return!1;if(this.conceptType.toLowerCase().includes("percent"))return!0;if(!this.datatypes)return!1;return N(this.conceptType,this.datatypes).some(e=>e.toLowerCase().includes("percent"))}_handleKeyDown(e){const t=e.target;if(!this._isNumericField())return;if(["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(e.key))return;if(e.ctrlKey||e.metaKey)return;const i=A(this.conceptType,this.datatypes),o=void 0===i.min||i.min<0;("-"!==e.key||!o||t.value.includes("-")||0!==t.selectionStart&&0!==t.value.length)&&("."!==e.key||!1===i.allowDecimals||t.value.includes("."))&&(e.key>="0"&&e.key<="9"||e.preventDefault())}_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=M.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}))}_validateUnitSelection(){if(null===this.value||void 0===this.value||""===this.value)return;const e=this._collectUnitsForConceptType();if(0===e.length)return;if(this.unit)return;const t=e.find(e=>!0===e.isDefault)??(1===e.length?e[0]:null);if(t)return this.unit=t.id,this.dispatchEvent(new CustomEvent("unit-change",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId,unit:this.unit},bubbles:!0,composed:!0})),void console.log(`🎯 [FormField] Auto-selected default unit on blur: ${this.unit} for ${this.conceptId}`);this._xbrlErrors=[...this._xbrlErrors,{type:"unit",message:k.t("validation.unitRequired"),expectedValue:e.map(e=>e.label).join(", "),actualValue:""}],console.log(`❌ [FormField] Unit validation failed for ${this.conceptId}: unit is required but not selected`)}_handlePeriodIconClick(){if(!this._isRoundingLevelConcept()){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=N(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")}_handleDecimalsChange(e){const t=e.target.value.trim(),i=parseFloat(t),o=t&&!isNaN(i)?String(Math.abs(i)):""===t?"":t;this.decimals=o||void 0,this.dispatchEvent(new CustomEvent("decimals-change",{detail:{conceptId:this.conceptId,columnId:this.columnId,decimals:this.decimals},bubbles:!0,composed:!0}))}_handlePopupOverlayClick(e){e.target===e.currentTarget&&this._closePeriodPopup()}_ensureTextDialogStyles(){if(document.getElementById("jdf-text-dialog-styles"))return;const e=document.createElement("style");e.id="jdf-text-dialog-styles",e.textContent="\n dialog.jdf-text-entry-dialog {\n border: none; border-radius: 8px; padding: 0;\n max-width: 600px; width: 90vw;\n box-shadow: 0 8px 32px rgba(0,0,0,0.2); overflow: hidden;\n font-family: inherit;\n }\n dialog.jdf-text-entry-dialog::backdrop { background: rgba(0,0,0,0.35); }\n .jdf-text-dialog-header {\n background: #f0f2f5; padding: 14px 20px;\n display: flex; align-items: center; justify-content: space-between;\n border-bottom: 1px solid #ddd;\n }\n .jdf-text-dialog-title {\n font-size: 15px; font-weight: 600; color: #333; margin: 0;\n font-family: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;\n }\n .jdf-text-dialog-close {\n flex-shrink: 0; width: 28px; height: 28px; border: none; background: transparent;\n font-size: 20px; line-height: 1; cursor: pointer; color: #666;\n border-radius: 4px; display: flex; align-items: center; justify-content: center;\n padding: 0; font-family: inherit; margin-left: 8px;\n }\n .jdf-text-dialog-close:hover { background: #ddd; color: #333; }\n .jdf-text-dialog-body { padding: 20px 20px 12px; }\n .jdf-text-dialog-textarea {\n width: 100%; min-height: 200px; max-height: 50vh;\n padding: 10px 12px; font-size: 14px; font-family: inherit;\n border: 1px solid #ddd; border-radius: 4px;\n box-sizing: border-box; resize: vertical; line-height: 1.5;\n color: #333; background: #fff;\n }\n .jdf-text-dialog-textarea:focus {\n outline: none; border-color: #1976d2;\n box-shadow: 0 0 0 2px rgba(25,118,210,0.2);\n }\n .jdf-text-dialog-char-count {\n margin-top: 4px; font-size: 12px; color: #888; text-align: right;\n font-family: inherit;\n }\n .jdf-text-dialog-actions {\n display: flex; justify-content: flex-end; gap: 8px;\n padding: 12px 20px 16px; border-top: 1px solid #eee;\n }\n .jdf-text-dialog-cancel {\n padding: 7px 18px; border: 1px solid #ddd; border-radius: 4px;\n background: transparent; color: #555; font-size: 14px;\n cursor: pointer; font-family: inherit;\n }\n .jdf-text-dialog-cancel:hover { background: #f5f5f5; }\n .jdf-text-dialog-save {\n padding: 7px 18px; border: none; border-radius: 4px;\n background: #1976d2; color: #fff; font-size: 14px;\n cursor: pointer; font-family: inherit; font-weight: 500;\n }\n .jdf-text-dialog-save:hover { background: #1565c0; }\n ",document.head.appendChild(e)}_openTextDialog(e,t){var i;this._ensureTextDialogStyles(),null==(i=document.getElementById("jdf-text-entry-dialog"))||i.remove();const o=document.createElement("dialog");o.id="jdf-text-entry-dialog",o.className="jdf-text-entry-dialog",o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),o.setAttribute("aria-labelledby","jdf-text-dialog-title"),o.innerHTML='\n <div class="jdf-text-dialog-header">\n <h3 class="jdf-text-dialog-title" id="jdf-text-dialog-title"></h3>\n <button class="jdf-text-dialog-close" type="button" aria-label="Close">×</button>\n </div>\n <div class="jdf-text-dialog-body">\n <textarea class="jdf-text-dialog-textarea" spellcheck="true"></textarea>\n <div class="jdf-text-dialog-char-count"></div>\n </div>\n <div class="jdf-text-dialog-actions">\n <button class="jdf-text-dialog-cancel" type="button"></button>\n <button class="jdf-text-dialog-save" type="button"></button>\n </div>\n ';const r=t;o.querySelector(".jdf-text-dialog-title").textContent=r||t,o.querySelector(".jdf-text-dialog-cancel").textContent=k.t("field.cancel"),o.querySelector(".jdf-text-dialog-save").textContent=k.t("field.save");const n=o.querySelector(".jdf-text-dialog-textarea"),s=o.querySelector(".jdf-text-dialog-char-count");n.value=e,s.textContent=`${e.length} ${k.t("field.characters")}`,n.addEventListener("input",()=>{s.textContent=`${n.value.length} ${k.t("field.characters")}`}),o.querySelector(".jdf-text-dialog-close").addEventListener("click",()=>o.close()),o.querySelector(".jdf-text-dialog-cancel").addEventListener("click",()=>o.close()),o.querySelector(".jdf-text-dialog-save").addEventListener("click",()=>{const e=n.value,t=this.value;this.value=e,this._touched=!0,this.dispatchEvent(new CustomEvent("field-change",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId,value:e,oldValue:t},bubbles:!0})),o.close()}),o.addEventListener("click",e=>{const t=o.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&o.close()}),o.addEventListener("close",()=>o.remove()),document.body.appendChild(o),o.showModal(),n.focus()}_renderTextDialogTrigger(t,i){const o=null!=t&&""!==String(t).trim(),r=o?String(t):"";return i?e.html`
|
|
22
|
+
*/function S(e){return w({...e,state:!0,attribute:!1})}class C{static validateField(e,t,i,o,r,n=[]){const a=[];for(const s of n){const n=this.validateRule(e,t,i,o,r,s);n&&a.push(n)}return a}static validateRule(e,t,i,o,r,n){const a=null==o||""===o;switch(n.type){case"required":if(a)return this.createError(e,t,i,n);break;case"min":if(!a&&"number"==typeof o&&o<n.value)return this.createError(e,t,i,n);break;case"max":if(!a&&"number"==typeof o&&o>n.value)return this.createError(e,t,i,n);break;case"minLength":if(!a&&"string"==typeof o&&o.length<n.value)return this.createError(e,t,i,n);break;case"maxLength":if(!a&&"string"==typeof o&&o.length>n.value)return this.createError(e,t,i,n);break;case"pattern":if(!a&&"string"==typeof o){if(!new RegExp(n.value).test(o))return this.createError(e,t,i,n)}break;case"email":if(!a&&"string"==typeof o){if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o))return this.createError(e,t,i,n)}break;case"url":if(!a&&"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 _extractDocumentationLabels(e){const t={};return e.filter(e=>"http://www.xbrl.org/2003/role/documentation"===e.role).forEach(e=>{t[e.lang]=e.label}),t}static buildFormSchema(e,t,i,o="en",r){var n,a;if(!e.presentation||0===e.presentation.length)throw new Error("XBRL presentation data is required");const s=e.presentation[0],l=null==(n=e.hypercubes)?void 0:n[0],d=Array.isArray(e.datatypes)?e.datatypes:(null==(a=e.datatypes)?void 0:a.concepts)||[],c=[];return s.roles.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(s.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 a,s;let l;if(e.labels&&e.labels.length>0){const t=e.labels.find(e=>e.lang===r),i=e.labels.find(e=>"en"===e.lang)||e.labels[0];l=(t||i).label}else l=this.extractRoleTitle(e.role||e.id||"Unknown Role");const d=this.getAllNonAbstractConcepts(e),c=new Set(d.filter(e=>e.periodType).map(e=>e.periodType));let p=null==o?void 0:o.roles.find(t=>t.roleId===e.id);const u=null==n?void 0:n[e.id];p&&(null==u?void 0:u.dimensionSelections)&&u.dimensionSelections.length>0&&(console.log(`🔍 Filtering dimensions for role ${e.id} based on user selections`),p=this.filterHypercubeDimensionsBySelection(p,u.dimensionSelections));const h=this.generateDefaultColumnsForRole(e,t||"2025-01-01",i||"2025-12-31",p,d,c,u,r),m={periodTypes:c,availableColumnIds:h.map(e=>e.id),availableColumns:h},f=[],g=new Map;return(null==(a=e.presentationLinkbase)?void 0:a.concepts)&&e.presentationLinkbase.concepts.forEach(o=>{const n=this.buildConceptTree(o,0,t,i,m,e.id,r,g);n&&f.push(n)}),p&&(null==(s=p.items)?void 0:s.length)||!o||f.forEach(t=>this.applyCrossRoleDimensions(t,e.id,o,r)),{id:e.id,title:l,description:e.description||`Section for ${l}`,concepts:f,columns:h,expanded:!1,metadata:{roleURI:e.roleURI,originalRole:e.role},showPeriodControl:c.size>1,showPreviousYear:!0===e.showPreviousYear,instant:!0===e.instant,duration:!0===e.duration}}static buildConceptTree(e,t,i,o,r,n,a="en",s,l){var d,c;const p=this.getPreferredLabel(e.labels,a,e.preferredLabel),u=(null==(d=e.preferredLabel)?void 0:d.includes("periodStartLabel"))?"start":(null==(c=e.preferredLabel)?void 0:c.includes("periodEndLabel"))?"end":l,h="start"===u?"periodStartLabel":"end"===u?"periodEndLabel":void 0,m=[];if(!e.elementAbstract){let t=[];t=(null==r?void 0:r.availableColumnIds)&&r.availableColumnIds.length>0?r.availableColumnIds:["duration"],t.forEach(t=>{var n;const s=null==(n=null==r?void 0:r.availableColumns)?void 0:n.find(e=>e.id===t),d=(null==s?void 0:s.periodStartDate)||i,c=(null==s?void 0:s.periodEndDate)||o,p=this.createFieldFromConcept(e,d,c,t,l,a);p&&m.push(p)})}const f=[];e.children&&e.children.length>0&&e.children.forEach(e=>{const l=this.buildConceptTree(e,t+1,i,o,r,n,a,s,u);l&&f.push(l)});if(!(m.length>0||f.length>0))return null;let g=this.createUniqueConceptId(e,n);if(s){const e=s.get(g)??0;s.set(g,e+1),e>0&&(g=`${g}__occ${e+1}`)}const b={conceptName:e.conceptName,type:e.type,substitutionGroup:e.substitutionGroup,periodType:e.periodType,balance:e.balance,documentationLabels:this._extractDocumentationLabels(e.labels)};return{id:g,originalConceptId:e.id,name:e.conceptName,label:p,description:`${e.conceptName} (${e.type})`,type:e.type,level:t,children:f,fields:m,conceptMetadata:b,facts:e.facts||[],collapsed:t>0,abstract:e.elementAbstract,periodType:e.periodType,balance:e.balance,preferredLabel:e.preferredLabel,effectivePeriodRole:h}}static createFieldFromConcept(e,t,i,o,r,n="en"){var a;const s=this.mapXBRLTypeToFieldType(e.type),l=this.getPreferredLabel(e.labels,n,e.preferredLabel);let d;d=o||"duration";const c={id:`${e.id}_${d}_field`,conceptId:e.id,columnId:d,type:s,label:l,placeholder:`Enter ${l.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?(null==(a=e.preferredLabel)?void 0:a.includes("periodStartLabel"))||"start"===r?this.subtractOneDay(t||"2025-01-01"):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: ${c.periodType}, ColumnId: ${d}`),c}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",i){if(!e||0===e.length)return"Unnamed Concept";const o=e.filter(e=>e.lang===t),r=o.length>0?o:e;if(i){const t=o.find(e=>e.role===i);if(t)return t.label;const r=e.find(e=>e.role===i);if(r)return r.label}const n=r.find(e=>e.preferredLabel);if(n)return n.label;const a=r.find(e=>"http://www.xbrl.org/2003/role/label"===e.role);if(a)return a.label;const s=r.find(e=>"http://www.xbrl.org/2003/role/terseLabel"===e.role);return s?s.label:r.length>0?r[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 filterHypercubeDimensionsBySelection(e,t){const i=JSON.parse(JSON.stringify(e));return i.items&&0!==i.items.length?(i.items.forEach(e=>{e.dimensions&&(e.dimensions=e.dimensions.map(e=>{var i,o;const r=t.find(t=>t.dimensionId===e.id);if(!r||!r.selectedMemberIds||0===r.selectedMemberIds.length)return e;const n={...e};return n.members=this.filterMembersBySelection(e.members,r.selectedMemberIds),console.log(` ✅ Filtered dimension ${e.id}: ${(null==(i=e.members)?void 0:i.length)||0} → ${(null==(o=n.members)?void 0:o.length)||0} members`),n}))}),i):i}static filterMembersBySelection(e,t){if(!e||!Array.isArray(e))return[];const i=[];return e.forEach(e=>{if(t.includes(e.id)&&i.push({...e,children:[]}),e.children&&e.children.length>0){const o=this.filterMembersBySelection(e.children,t);i.push(...o)}}),i}static findCrossRoleDimensions(e,t,i,o="en"){var r,n;const a=[];for(const d of i.roles)if(d.roleId!==t)for(const t of d.items)if((null==(r=t.conceptIds)?void 0:r.includes(e))&&(null==(n=t.dimensions)?void 0:n.some(e=>e.typedMember))){a.push(d);break}if(1!==a.length)return null;const s=a[0].items.find(t=>{var i;return null==(i=t.conceptIds)?void 0:i.includes(e)});if(!s)return null;const l=[];for(const d of s.dimensions){if(!d.typedMember)continue;const e=d.labels.find(e=>e.lang===o)||d.labels.find(e=>"en"===e.lang)||d.labels[0],t=(null==e?void 0:e.label)||d.id;l.push({axisId:d.id,axisLabel:t,typedMemberId:d.typedMember.id,memberLabel:t})}return l.length>0?l:null}static applyCrossRoleDimensions(e,t,i,o){var r;if(!e.abstract&&e.fields&&e.fields.length>0){const r=this.findCrossRoleDimensions(e.originalConceptId,t,i,o);r&&e.fields.forEach(e=>{e.crossRoleTypedMembers=r})}null==(r=e.children)||r.forEach(e=>this.applyCrossRoleDimensions(e,t,i,o))}static generateDefaultColumnsForRole(e,t,i,o,r,n,a,s="en"){var l,d;const c=r||this.getAllNonAbstractConcepts(e),p=n||new Set(c.filter(e=>e.periodType).map(e=>e.periodType));if(0===c.length)return[{id:"default",title:"Value",description:"Default value column",type:"base",order:0,removable:!1}];let u=[];if(1===(null==(l=null==o?void 0:o.items)?void 0:l.length)){const e=o.items[0];1===e.dimensions.length?u=this.generateSingleDimensionColumns(e.dimensions[0],t,i,p,s):e.dimensions.length>1&&(u=this.generateMultiDimensionColumns(e.dimensions,t,i,p,s)),a&&(u=this.filterColumnsByPeriodPreferences(u,a))}else(null==(d=null==o?void 0:o.items)?void 0:d.length)&&o.items.length;const h=[];u.length>0?h.push(...u):0===p.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 m=h;if(a&&(m=this.filterColumnsByPeriodPreferences(h,a)),null==a?void 0:a.showPreviousYear){const e=this.generatePreviousYearColumns(m,t,i);m=[...m,...e]}return m}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 subtractOneDay(e){try{const t=new Date(e);return t.setDate(t.getDate()-1),t.toISOString().split("T")[0]}catch(t){return console.error(`Error subtracting one day from 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,a="",s="";e.dimensionData?(i=e.title,a=this.formatPeriodDisplay(r,n),s=`${e.id}_prev`):(i=this.formatPeriodDisplay(r,n),a="",s=`duration_prev_${t}`),o.push({...e,id:s,title:i,description:a,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 a=e.id.includes("duration")||(null==(o=null==(i=e.dimensionData)?void 0:i.dimensionId)?void 0:o.includes("duration")),s=e.id.includes("instant")||(null==(n=null==(r=e.dimensionData)?void 0:r.dimensionId)?void 0:n.includes("instant"));return!a&&!s||!(a&&!t.showDuration)&&!(s&&!t.showInstant)})}static generateSingleDimensionColumns(e,t,i,o,r="en"){if(e.typedMember&&(!e.members||0===e.members.length)){const n=this.getPreferredLabel(e.labels,r)||e.conceptName,a={axisId:e.id,axisLabel:n,typedMemberId:e.typedMember.id,dimensionKey:`${n} | [Typed Input]`,dimensionIdKey:`${e.id}|[typed]`},s=[];return 0===o.size?s.push({id:"typed-default",title:n,description:"Typed dimension input column",type:"dimension",dimensionData:{dimensionId:"typed-default",axisId:a.axisId,memberId:"[typed]",memberValue:"Typed Input",memberLabel:"Typed Input",axis:a.axisLabel,axisLabel:a.axisLabel,memberKey:a.dimensionKey,dimensionIdKey:a.dimensionIdKey,hasTypedMembers:!0,typedMemberId:a.typedMemberId,typedMembers:[{axisId:a.axisId,axisLabel:a.axisLabel,typedMemberId:a.typedMemberId,memberLabel:a.axisLabel}]},order:0,removable:!1,periodStartDate:t,periodEndDate:i}):1===o.size&&o.has("instant")?s.push({id:"typed-instant",title:`${n} `,description:i,type:"dimension",dimensionData:{dimensionId:"typed-instant",axisId:a.axisId,memberId:"[typed]",memberValue:"Typed Input",memberLabel:"Typed Input",axis:a.axisLabel,axisLabel:a.axisLabel,memberKey:a.dimensionKey,dimensionIdKey:a.dimensionIdKey,hasTypedMembers:!0,typedMemberId:a.typedMemberId,typedMembers:[{axisId:a.axisId,axisLabel:a.axisLabel,typedMemberId:a.typedMemberId,memberLabel:a.axisLabel}]},order:0,removable:!1,periodStartDate:i,periodEndDate:i}):(1===o.size&&o.has("duration"),s.push({id:"typed-duration",title:`${n} `,description:this.formatPeriodDisplay(t,i),type:"dimension",dimensionData:{dimensionId:"typed-duration",axisId:a.axisId,memberId:"[typed]",memberValue:"Typed Input",memberLabel:"Typed Input",axis:a.axisLabel,axisLabel:a.axisLabel,memberKey:a.dimensionKey,dimensionIdKey:a.dimensionIdKey,hasTypedMembers:!0,typedMemberId:a.typedMemberId,typedMembers:[{axisId:a.axisId,axisLabel:a.axisLabel,typedMemberId:a.typedMemberId,memberLabel:a.axisLabel}]},order:0,removable:!1,periodStartDate:t,periodEndDate:i})),s}if(!e.members||!Array.isArray(e.members))return[];if(0===e.members.length)return[];const n=this.getPreferredLabel(e.labels,r)||e.conceptName,a=e.members[0],s=this.getPreferredLabel(a.labels,r)||a.conceptName,l={axisId:e.id,axisLabel:n,memberId:a.id,memberLabel:s,dimensionKey:`${n} | ${s}`,dimensionIdKey:`${e.id} | ${a.id}`},d=[];return 0===o.size?d.push({id:"default",title:l.memberLabel,description:"Default value column",type:"dimension",dimensionData:{dimensionId:"default",axisId:l.axisId,memberId:l.memberId,memberValue:l.memberLabel,memberLabel:l.memberLabel,axis:l.axisLabel,axisLabel:l.axisLabel,memberKey:l.dimensionKey,dimensionIdKey:l.dimensionIdKey},order:0,removable:!1,periodStartDate:t,periodEndDate:i}):1===o.size&&o.has("instant")?d.push({id:"instant",title:`${l.memberLabel}`,description:i,type:"dimension",dimensionData:{dimensionId:"instant",axisId:l.axisId,memberId:l.memberId,memberValue:l.memberLabel,memberLabel:l.memberLabel,axis:l.axisLabel,axisLabel:l.axisLabel,memberKey:l.dimensionKey,dimensionIdKey:l.dimensionIdKey},order:0,removable:!1,periodStartDate:i,periodEndDate:i}):1===o.size&&o.has("duration")?d.push({id:"duration",title:`${l.memberLabel}`,description:`${t} / ${i}`,type:"dimension",dimensionData:{dimensionId:"duration",axisId:l.axisId,memberId:l.memberId,memberValue:l.memberLabel,memberLabel:l.memberLabel,axis:l.axisLabel,axisLabel:l.axisLabel,memberKey:l.dimensionKey,dimensionIdKey:l.dimensionIdKey},order:0,removable:!1,periodStartDate:t,periodEndDate:i}):d.push({id:"duration",title:`${l.memberLabel}`,description:this.formatPeriodDisplay(t,i),type:"dimension",dimensionData:{dimensionId:"duration",axisId:l.axisId,memberId:l.memberId,memberValue:l.memberLabel,memberLabel:l.memberLabel,axis:l.axisLabel,axisLabel:l.axisLabel,memberKey:l.dimensionKey,dimensionIdKey:l.dimensionIdKey},order:0,removable:!1,periodStartDate:t,periodEndDate:i}),d}static generateMultiDimensionColumns(e,t,i,o,r="en"){e.some(e=>e.typedMember);const n=e.filter(e=>!!e.typedMember||!!(e.members&&Array.isArray(e.members)&&e.members.length>0));if(0===n.length)return[];const a=n.map(e=>{const t=this.getPreferredLabel(e.labels,r)||e.conceptName;if(e.typedMember)return{id:e.id,axisLabel:t,isTyped:!0,typedMemberId:e.typedMember.id,members:[{id:"[typed]",label:`${t}`}]};const i=this.getAllDimensionMembers(e.members);return{id:e.id,axisLabel:t,isTyped:!1,members:i.map(e=>({id:e.id,label:this.getPreferredLabel(e.labels,r)||e.conceptName}))}}),s=this.generateDimensionCombinations(a),l=[];return s.forEach((e,o)=>{const r=e.map(e=>e.memberLabel).join(" | "),n=e.filter(e=>e.isTyped),a=e.filter(e=>!e.isTyped),s={dimensionId:`multi_${o}`,memberValue:r,memberLabel:r,combinations:a.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:[...a.map(e=>`${e.axisId}|${e.memberId}`),...n.map(e=>`${e.axisId}|[typed]`)].join("::")};l.push({id:`duration_${o}`,title:`${r}`,description:this.formatPeriodDisplay(t,i),type:"dimension",dimensionData:{...s,dimensionId:`duration_${o}`},order:o,removable:!1,periodStartDate:t,periodEndDate:i})}),l}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){if(!e)return"Unnamed Section";const t=e.match(/^\[[\d]+\]\s*(.+)$/);if(t)return t[1].trim();if(e.match(/^[a-z]+:[^:]*$/i)||e.match(/^urn:[^:]+:[^:]+/i)){const t=e.split(/[:\-]/);return t[t.length-1].replace(/[_\-]/g," ").replace(/\b\w/g,e=>e.toUpperCase())}return e.trim()||"Unnamed Section"}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 k={en:{conceptInfo:{title:"Concept Information",conceptName:"Concept name",type:"Type",substitutionGroup:"Substitution group",periodType:"Period type",balance:"Balance",documentation:"Documentation",instant:"Instant",duration:"Duration",close:"Close"},form:{markAsComplete:"Mark as Complete",loading:"Loading form...",submit:"Validate",save:"Save",saveDraft:"Save Draft",savingDraft:"Saving 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",validate:"Validate",preview:"Preview",download:"Download",cancelValidation:"Cancel Validation",lastValidationResults:"Last Validation Results",validationInProgress:"Validation In Progress",quickValidate:"Quick Validate"},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",dimensionMemberSelection:"Dimension Member Selection",selectAllMembers:"Select All",clearMembers:"Clear",availableRoles:"Available Roles",chosenRoles:"Chosen Roles",roleCount:"role(s)",rolesSelected:"role(s) selected",addSelectedRole:"Add selected role",addAllRoles:"Add all roles",removeSelectedRole:"Remove selected role",removeAllRoles:"Remove all roles",advancedFilter:"Advanced Filter",backToFilterRoles:"← Back",showFactsOnly:"Show facts only",showFactsOnlyDescription:"Hide all blank rows and sections. Only roles and rows with at least one filled value will be shown.",searchByConcept:"Search by concept",searchByConceptDescription:"Type concept name or label to filter roles and rows. Press Apply Filter to apply.",searchByConceptPlaceholder:"Type concept name or label and press Apply Filter...",clearFilters:"Clear Filters",resetFilter:"Reset"},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",hideColumn:"Hide column",showColumn:"Double-click to show 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:"e.g. 0.25 for 25% or 0.2550 for 25.50%",emailPlaceholder:"email@example.com",urlPlaceholder:"https://example.com",phonePlaceholder:"+1 (555) 000-0000",enterValue:"Enter value",enterDetailedInformation:"Enter detailed information...",scale:"Scale",addText:"Add text",editText:"Edit",save:"Save",cancel:"Cancel",characters:"characters",editPeriod:"Edit Period",from:"From",to:"To",date:"Date",unit:"Unit",selectUnit:"Select Unit",leaveBlankForInf:"Leave blank for INF"},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",unitRequired:"Unit is required. Please select a unit via the period icon."},xbrlValidation:{patternMismatch:"Value does not match required pattern: {{pattern}}",invalidPattern:"Invalid pattern configuration: {{pattern}}",exactLength:"Value must be exactly {{required}} characters (current: {{current}})",minLength:"Value must be at least {{required}} characters (current: {{current}})",maxLength:"Value must not exceed {{required}} characters (current: {{current}})",totalDigits:"Value must not exceed {{required}} total digits (current: {{current}})",ruleSummaryPattern:"Must match pattern: {{pattern}}",ruleSummaryExactLength:"Must be exactly {{required}} characters",ruleSummaryMinLength:"Minimum {{required}} characters",ruleSummaryMaxLength:"Maximum {{required}} characters",ruleSummaryTotalDigits:"Maximum {{required}} total digits"},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"}},calculationWarning:{title:"Calculation warning",summaryLine:'Total "{{label}}" should equal {{calculated}}, but you entered {{entered}}.',childrenPrefix:"Children:",childAdded:"{{label}} = {{value}} (added)",childSubtracted:"{{label}} = {{value}} (subtracted, opposite balance)",added:"Added",subtracted:"Subtracted (opposite balance)"},formulaValidation:{dialogTitle:"Formula check results",allPassed:"All formula checks passed",summaryCount:"{{failed}} of {{total}} checks failed",summaryCountBreakdown:"{{warnings}} warnings, {{errors}} errors",severityWarning:"Warning",severityError:"Error",close:"Close"}},nl:{conceptInfo:{title:"Conceptinformatie",conceptName:"Conceptnaam",type:"Type",substitutionGroup:"Substitutiegroep",periodType:"Periodetype",balance:"Saldo",documentation:"Documentatie",instant:"Moment",duration:"Periode",close:"Sluiten"},form:{markAsComplete:"Markeren als volledig behandeld",loading:"Formulier laden...",submit:"Valideren",save:"Opslaan",saveDraft:"Concept opslaan",savingDraft:"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",validate:"Valideren",preview:"Voorbeeld",download:"Downloaden",cancelValidation:"Validatie annuleren",lastValidationResults:"Laatste validatieresultaten",validationInProgress:"Validatie bezig",quickValidate:"Snel valideren"},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",dimensionMemberSelection:"Dimensieleden selectie",selectAllMembers:"Alles selecteren",clearMembers:"Wissen",availableRoles:"Beschikbare rollen",chosenRoles:"Gekozen rollen",roleCount:"rol(len)",rolesSelected:"rol(len) geselecteerd",addSelectedRole:"Geselecteerde rol toevoegen",addAllRoles:"Alle rollen toevoegen",removeSelectedRole:"Geselecteerde rol verwijderen",removeAllRoles:"Alle rollen verwijderen",advancedFilter:"Geavanceerd filter",backToFilterRoles:"← Terug",showFactsOnly:"Alleen feiten weergeven",showFactsOnlyDescription:"Verberg alle lege rijen en secties. Alleen rollen en rijen met minimaal één ingevulde waarde worden weergegeven.",searchByConcept:"Zoeken op concept",searchByConceptDescription:"Typ een conceptnaam of label om rollen en rijen te filteren. Druk op Filter toepassen om te activeren.",searchByConceptPlaceholder:"Typ conceptnaam of label en druk op Filter toepassen...",clearFilters:"Filters wissen",resetFilter:"Resetten"},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",hideColumn:"Kolom verbergen",showColumn:"Dubbelklik om kolom te tonen",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:"bijv. 0,25 voor 25% of 0,2550 voor 25,50%",emailPlaceholder:"email@voorbeeld.nl",urlPlaceholder:"https://voorbeeld.nl",phonePlaceholder:"+31 (0)20 123 4567",enterValue:"Voer waarde in",enterDetailedInformation:"Voer gedetailleerde informatie in...",scale:"Schaal",addText:"Tekst toevoegen",editText:"Bewerken",save:"Opslaan",cancel:"Annuleren",characters:"tekens",editPeriod:"Periode bewerken",from:"Van",to:"Tot",date:"Datum",unit:"Eenheid",selectUnit:"Selecteer eenheid",leaveBlankForInf:"Leeg laten voor INF"},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",unitRequired:"Eenheid is verplicht. Selecteer een eenheid via het periodeicoon."},xbrlValidation:{patternMismatch:"Waarde voldoet niet aan het vereiste patroon: {{pattern}}",invalidPattern:"Ongeldige patternconfiguratie: {{pattern}}",exactLength:"Waarde moet exact {{required}} tekens bevatten (huidig: {{current}})",minLength:"Waarde moet minimaal {{required}} tekens bevatten (huidig: {{current}})",maxLength:"Waarde mag niet meer dan {{required}} tekens bevatten (huidig: {{current}})",totalDigits:"Waarde mag niet meer dan {{required}} cijfers bevatten (huidig: {{current}})",ruleSummaryPattern:"Moet overeenkomen met patroon: {{pattern}}",ruleSummaryExactLength:"Moet exact {{required}} tekens bevatten",ruleSummaryMinLength:"Minimaal {{required}} tekens",ruleSummaryMaxLength:"Maximaal {{required}} tekens",ruleSummaryTotalDigits:"Maximaal {{required}} cijfers"},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"}},calculationWarning:{title:"Berekeningswaarschuwing",summaryLine:'Totaal "{{label}}" zou {{calculated}} moeten zijn, maar u heeft {{entered}} ingevoerd.',childrenPrefix:"Onderdelen:",childAdded:"{{label}} = {{value}} (opgeteld)",childSubtracted:"{{label}} = {{value}} (afgetrokken, tegengestelde balans)",added:"Opgeteld",subtracted:"Afgetrokken (tegengestelde balans)"},formulaValidation:{dialogTitle:"Resultaten formulecontrole",allPassed:"Alle formulecontroles geslaagd",summaryCount:"{{failed}} van {{total}} controles mislukt",summaryCountBreakdown:"{{warnings}} waarschuwingen, {{errors}} fouten",severityWarning:"Waarschuwing",severityError:"Fout",close:"Sluiten"}}};class T{static setLanguage(e){k[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=k[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=k[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(k)}}function E(e){return!!(null==e?void 0:e.toLowerCase().includes("totallabel"))}T.currentLanguage="en";class R{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,description:i.description,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,a,s,l,d="en",c,p,u,h,m){return{periodStartDate:e,periodEndDate:t,language:i,reportingLanguage:d,selectedRoleIds:o,customColumns:this.extractCustomColumns(r),typedMemberData:n,periodPreferences:a,periodData:s,unitData:l,decimalsData:p,repeatCounts:c,roleCompletedStates:u,hiddenColumns:h,totalManuallyEditedData:m,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 M extends Error{constructor(e,t,i="unsupported-syntax"){super(e),this.test=t,this.reason=i,this.name="FormulaExpressionError"}}const A=/\s*(?:(\$[A-Za-z_][\w-]*)|(-?\d+(?:\.\d+)?)|([A-Za-z][\w:-]*)|('[^']*')|(\()|(\))|(\+)|(-)|(=))/y;class j{constructor(e,t){this.tokens=e,this.test=t,this.pos=0}peek(){return this.tokens[this.pos]}next(){return this.tokens[this.pos++]}expect(e){const t=this.next();if(t.type!==e)throw new M(`Expected ${e} but got ${t.type} ("${t.value}")`,this.test,"parse-error");return t}parseBoolExpr(){const e=this.parseOrExpr();if("EOF"!==this.peek().type)throw new M(`Unexpected trailing token "${this.peek().value}"`,this.test,"unsupported-syntax");return e}parseOrExpr(){const e=[this.parseAndExpr()];for(;"IDENT"===this.peek().type&&"or"===this.peek().value;)this.next(),e.push(this.parseAndExpr());return 1===e.length?e[0]:{kind:"or",terms:e}}parseAndExpr(){const e=[this.parseBoolTerm()];for(;"IDENT"===this.peek().type&&"and"===this.peek().value;)this.next(),e.push(this.parseBoolTerm());return 1===e.length?e[0]:{kind:"and",terms:e}}parseBoolTerm(){const e=this.peek();if("IDENT"===e.type&&"not"===e.value){this.next(),this.expect("LPAREN");const e=this.parseOrExpr();return this.expect("RPAREN"),{kind:"not",arg:e}}if("IDENT"===e.type&&"empty"===e.value){this.next(),this.expect("LPAREN");const e=this.expect("VARIABLE").value;return this.expect("RPAREN"),{kind:"empty",variable:e}}if("IDENT"===e.type&&"xff:has-fallback-value"===e.value){this.next(),this.expect("LPAREN");const e=this.next();if("IDENT"!==e.type||"xs:QName"!==e.value)throw new M(`Expected xs:QName(...) inside xff:has-fallback-value(...), got "${e.value}"`,this.test,"unsupported-syntax");this.expect("LPAREN");const t=this.expect("STRING").value;return this.expect("RPAREN"),this.expect("RPAREN"),{kind:"hasFallbackValue",variableName:t}}const t=this.parseValueExpr(),i=this.peek();if("EQUALS"===i.type)return this.next(),{kind:"comparison",op:"=",left:t,right:this.parseValueExpr()};if("IDENT"===i.type&&"eq"===i.value)return this.next(),{kind:"comparison",op:"eq",left:t,right:this.parseValueExpr()};throw new M(`Expected a comparison operator ("=" or "eq") after value expression, got "${i.value}"`,this.test,"unsupported-syntax")}parseValueExpr(){const e=[];let t=1;for("PLUS"===this.peek().type?this.next():"MINUS"===this.peek().type&&(this.next(),t=-1),e.push({sign:t,term:this.parseValueTerm()});"PLUS"===this.peek().type||"MINUS"===this.peek().type;){const t="PLUS"===this.next().type?1:-1;e.push({sign:t,term:this.parseValueTerm()})}return 1===e.length&&1===e[0].sign?e[0].term:{kind:"additive",terms:e}}parseValueTerm(){const e=this.peek();if("NUMBER"===e.type)return this.next(),{kind:"number",value:Number(e.value)};if("VARIABLE"===e.type)return this.next(),{kind:"variable",name:e.value};if("IDENT"===e.type&&"sum"===e.value){this.next(),this.expect("LPAREN");const e=this.expect("VARIABLE").value;return this.expect("RPAREN"),{kind:"sum",variable:e}}if("LPAREN"===e.type){this.next();const e=this.parseValueExpr();return this.expect("RPAREN"),e}throw new M(`Expected a number, variable, sum(...), or parenthesized expression, got "${e.value}"`,this.test,"unsupported-syntax")}}function P(e,t){return e.get(t)}function L(e,t,i){switch(e.kind){case"number":return e.value;case"sum":return function(e,t){const i=P(t,e);return void 0===i?0:Array.isArray(i)?i.reduce((e,t)=>e+t,0):i}(e.variable,t);case"variable":{const o=P(t,e.name);if(void 0===o)throw new M(`Variable "$${e.name}" has no bound fact and cannot be evaluated directly (only sum()/empty() tolerate an unbound variable)`,i,"unbound-variable");if(Array.isArray(o))throw new M(`Variable "$${e.name}" is a sequence and must be wrapped in sum(...) to be used in arithmetic`,i,"unsupported-syntax");return o}case"additive":return e.terms.reduce((e,{sign:o,term:r})=>e+o*L(r,t,i),0)}}function N(e,t,i,o){switch(e.kind){case"or":return e.terms.some(e=>N(e,t,i,o));case"and":return e.terms.every(e=>N(e,t,i,o));case"not":return!N(e.arg,t,i,o);case"empty":{const i=P(t,e.variable);return void 0===i||Array.isArray(i)&&0===i.length}case"hasFallbackValue":{const t=o.get(e.variableName);if(void 0===t)throw new M(`xff:has-fallback-value(xs:QName('${e.variableName}')) could not be evaluated — no fallback-usage tracked for this variable (either not one of this assertion's FACT_VARIABLEs, or it matched zero facts with no fallbackValue declared)`,i,"unbound-variable");return t}case"comparison":{const o=L(e.left,t,i),r=L(e.right,t,i);return Math.abs(o-r)<.01}}}function V(e,t,i=new Map){const o=function(e){const t=[];A.lastIndex=0;let i=0;for(;i<e.length;){A.lastIndex=i;const o=A.exec(e);if(!o||o.index!==i){if(/^\s*$/.test(e.slice(i)))break;throw new M(`Unrecognized token at position ${i}: "${e.slice(i,i+10)}..."`,e,"unsupported-syntax")}const[r,n,a,s,l,d,c,p,u,h]=o;n?t.push({type:"VARIABLE",value:n.slice(1)}):a?t.push({type:"NUMBER",value:a}):s?t.push({type:"IDENT",value:s}):l?t.push({type:"STRING",value:l.slice(1,-1)}):d?t.push({type:"LPAREN",value:d}):c?t.push({type:"RPAREN",value:c}):p?t.push({type:"PLUS",value:p}):u?t.push({type:"MINUS",value:u}):h&&t.push({type:"EQUALS",value:h}),i+=r.length}return t.push({type:"EOF",value:""}),t}(e);return N(new j(o,e).parseBoolExpr(),t,e,i)}const O=/^\.\s*(eq|ne|gt|lt|ge|le)\s+(-?\d+(?:\.\d+)?)$/;function z(e){return!!(null==e?void 0:e.toLowerCase().includes("totallabel"))}function U(e){return!!(null==e?void 0:e.toLowerCase().includes("negatedtotallabel"))}function J(e,t,i=0){if(!t.isAbstract(e))return e;if(i>5)return null;const o=t.getChildren(e).find(e=>z(t.getPreferredLabel(e)));return o?J(o,t,i+1):null}function B(e,t,i,o,r){if(i<0)return o;const n=e[t];if(U(r.getPreferredLabel(n)))return o.length>0?o:[e[i]];if(o.length>0)return[e[i],...o];if(U(r.getPreferredLabel(e[i]))){let t=-1;for(let o=i-1;o>=0;o--)if(z(r.getPreferredLabel(e[o]))){t=o;break}return t>=0?[e[t],e[i]]:[e[i]]}return[e[i]]}function q(e){return null!=e&&""!==e}function H(e){const t=[];for(const i of Object.keys(e)){const o=e[i]||{};for(const e of Object.keys(o))q(o[e])&&t.push({conceptId:i,columnId:e})}return t}function Y(e,t,i,o,r,n){const a={conceptId:e.id,qname:e.name,balance:e.balance};i.set(e.id,a),(t.get(e.name)??t.set(e.name,[]).get(e.name)).push(a);const s=e.children||[],l=s.length>0,d=!0===r.get(e.name);(!o.has(e.name)||l&&!d)&&(o.set(e.name,e.id),r.set(e.name,l)),n.set(e.id,s.map(e=>e.id)),s.forEach(e=>Y(e,t,i,o,r,n))}function K(e,t){t.has(e.conceptName)||t.set(e.conceptName,e.id),(e.children||[]).forEach(e=>K(e,t))}const W={getId:e=>e.id,getPreferredLabel:e=>e.preferredLabel,isAbstract:e=>!0===e.abstract,getChildren:e=>e.children||[]};function G(e,t,i,o,r,n){const a=new Map,s=new Map,l=new Map,d=new Map,c=new Map;i.forEach(e=>{const t=new Map,i=new Map,o=new Map;e.concepts.forEach(e=>Y(e,a,s,i,o,t)),d.set(e.roleURI,t),l.set(e.roleURI,i),c.set(e.roleURI,function(e,t){const i=new Map;function o(e,o){const r=[];for(const i of o){const e=J(i,t);e&&r.push(t.getId(e))}0!==r.length&&i.set(t.getId(e),r)}return function e(i){for(let r=0;r<i.length;r++){const n=i[r];if(z(t.getPreferredLabel(n))&&0===t.getChildren(n).length){let e=-1;for(let o=r-1;o>=0;o--)if(z(t.getPreferredLabel(i[o]))){e=o;break}const a=i.slice(e+1,r),s=B(i,r,e,a,t);s.length>0&&o(n,s)}const a=t.getChildren(n);a.length>0&&e(a)}}(e),i}(e.concepts,W))});const p=new Map,u=new Map;return(o||[]).forEach(e=>{e.items.forEach(e=>{e.dimensions.forEach(e=>{p.has(e.conceptName)||p.set(e.conceptName,e.id),(e.members||[]).forEach(e=>K(e,u))})})}),{formData:e,columns:t,periodStartDate:r,periodEndDate:n,conceptByQName:a,conceptById:s,conceptIdByQNamePerRole:l,childrenByRole:d,totalGroupChildrenByRole:c,dimensionQNameToId:p,memberQNameToId:u,allCandidates:H(e)}}function Q(e){return`${e.conceptId}::${e.columnId}`}function X(e,t){return ie(e.filters.map(e=>te(e,t.allCandidates,t)))}function Z(e,t){return e.columns.find(e=>e.id===t)}function ee(e,t,i){var o,r;switch(e.type){case"CONCEPT_NAME":{const o=e.attributes["concept.qname"],r=o?i.conceptByQName.get(o):void 0;if(!r||0===r.length)return[];const n=new Set(r.map(e=>e.conceptId));return t.filter(e=>n.has(e.conceptId))}case"CONCEPT_BALANCE":{const o=e.attributes.balance;return t.filter(e=>{var t;return(null==(t=i.conceptById.get(e.conceptId))?void 0:t.balance)===o})}case"CONCEPT_RELATION":{const n=e.attributes.qname,a=e.attributes.linkrole,s=e.attributes.axis,l=n&&a?null==(o=i.conceptIdByQNamePerRole.get(a))?void 0:o.get(n):void 0,d=a?i.childrenByRole.get(a):void 0;if(!l||!d)return[];let c;if("descendant"===s)c=function(e,t){const i=[],o=[...e.get(t)||[]],r=new Set;for(;o.length>0;){const t=o.pop();r.has(t)||(r.add(t),i.push(t),o.push(...e.get(t)||[]))}return i}(d,l);else{const e=d.get(l)||[];c=e.length>0?e:(null==(r=i.totalGroupChildrenByRole.get(a??""))?void 0:r.get(l))||[]}const p=new Set(c);return t.filter(e=>p.has(e.conceptId))}case"EXPLICIT_DIMENSION":{const o=e.attributes["dimension.qname"],r=e.attributes["member.qname"],n=o?i.dimensionQNameToId.get(o):void 0,a=r?i.memberQNameToId.get(r):void 0;return n?t.filter(e=>function(e,t,i){return!!(null==e?void 0:e.dimensionData)&&(!(e.dimensionData.axisId!==t||void 0!==i&&e.dimensionData.memberId!==i)||(e.dimensionData.combinations||[]).some(e=>e.axisId===t&&(void 0===i||e.memberId===i)))}(Z(i,e.columnId),n,a)):[]}case"TYPED_DIMENSION":{const o=e.attributes["dimension.qname"],r=o?i.dimensionQNameToId.get(o):void 0;return r?t.filter(e=>function(e,t){return!!(null==e?void 0:e.dimensionData)&&(void 0!==e.dimensionData.typedMemberId&&e.dimensionData.axisId===t||(e.dimensionData.typedMembers||[]).some(e=>e.axisId===t))}(Z(i,e.columnId),r)):[]}case"PERIOD_INSTANT":case"PERIOD_END":{const o=e.attributes.date;return t.filter(e=>function(e,t,i){const o=function(e){if(e)return e.startsWith("$")?e.slice(1):e}(t);if(!o)return!1;const r=function(e,t){const i=e.includes("StartDate"),o=e.includes("EndDate")||"FinancialReportingPeriodCurrentEndDateParam"===e;if(e.startsWith("FinancialReportingPeriodCurrent"))return i?{start:t.periodStartDate}:o?{end:t.periodEndDate}:void 0;if(e.startsWith("FinancialReportingPeriodPrePrevious")||e.startsWith("FinancialReportingPeriodPrevious")){const e=function(e){return e.columns.find(t=>void 0!==t.periodEndDate&&t.periodEndDate<e.periodEndDate)}(t);if(!e)return;return i?{start:e.periodStartDate}:o?{end:e.periodEndDate}:void 0}}(o,i);if(!r)return!1;const n=function(e,t){return{start:(null==e?void 0:e.periodStartDate)??t.periodStartDate,end:(null==e?void 0:e.periodEndDate)??t.periodEndDate}}(e,i),a=r.end??r.start;return n.end===a}(Z(i,e.columnId),o,i))}case"OR_FILTER":return function(e){const t=new Map;return e.forEach(e=>e.forEach(e=>t.set(Q(e),e))),Array.from(t.values())}(e.children.map(e=>te(e,t,i)));case"ASPECT_COVER":return t;default:return[]}}function te(e,t,i){const o=ee(e,t,i);if(!e.complement)return o;const r=new Set(o.map(Q));return t.filter(e=>!r.has(Q(e)))}function ie(e){return 0===e.length?[]:e.reduce((e,t)=>{const i=new Set(t.map(Q));return e.filter(e=>i.has(Q(e)))})}function oe(e,t){const i=X(e,t).map(e=>{var i;return parseFloat(null==(i=t.formData[e.conceptId])?void 0:i[e.columnId])}).filter(e=>!Number.isNaN(e));if(e.bindAsSequence){if(0===i.length&&"()"===e.fallbackValue)return[];if(0===i.length)return;return i}if(0!==i.length)return i.length>1&&console.warn(`[formula-variable-resolver] Variable "${e.name}" is scalar (bindAsSequence: false) but matched ${i.length} facts; using the first match by column order. This can legitimately happen when filters under-constrain the candidate set.`),i[0]}function re(e,t){return X(e,t).length}function ne(e,t){return!(re(e,t)>0)&&(void 0!==e.fallbackValue||void 0)}function ae(e){const t=[];for(const i of e)if("CONCEPT_NAME"===i.type){const e=i.attributes["concept.qname"];e&&t.push(e)}else"OR_FILTER"===i.type&&t.push(...ae(i.children));return t}function se(e){return ae(e.filters)}function le(e,t,i){const o=i.columns.map(e=>({conceptId:t,columnId:e.id}));return ie(e.filters.map(e=>te(e,o,i))).map(e=>e.columnId)}class de{evaluate(e,t,i){var o;const r=null==(o=e.formula)?void 0:o[0];if(!r)return[];const n=[];for(const a of r.roles)for(const e of a.assertions)n.push(this._evaluateAssertion(e,a,t,i));return n}summarize(e){const t={totalAssertions:e.length,evaluated:0,skipped:0,passed:0,failed:0,failedWarnings:0,failedErrors:0};for(const i of e)i.skipped?t.skipped+=1:(t.evaluated+=1,i.satisfied?t.passed+=1:(t.failed+=1,"ERROR"===i.severity?t.failedErrors+=1:t.failedWarnings+=1));return t}_evaluateAssertion(e,t,i,o){try{const r=function(e,t){const i=new Map;for(const o of e.variables)i.set(o.name,oe(o,t));return i}(e,i),n=function(e,t){var i;if(!(null==(i=e.test)?void 0:i.includes("has-fallback-value"))&&!e.preconditions.some(e=>e.test.includes("has-fallback-value")))return new Map;const o=new Map;for(const r of e.variables){const e=ne(r,t);void 0!==e&&o.set(r.name,e)}return o}(e,i),a=function(e,t,i=new Map){if(0===e.length)return{satisfied:!0};for(const r of e){let e;try{e=V(r.test,t,i)}catch(o){if(o instanceof M)return{satisfied:!1,skipReason:"unresolvable"};throw o}if(!e)return{satisfied:!1,skipReason:"precondition"}}return{satisfied:!0}}(e.preconditions,r,n);if(!a.satisfied)return this._skippedResult(e,t,a.skipReason??"unresolvable");if("EXISTENCE_ASSERTION"===e.type){const r=re(e.variables[0],i),n=function(e,t){const i=(e??"").trim();return""===i?t>0:i.split(/\bor\b/).some(e=>{const o=O.exec(e.trim());if(!o)throw new M(`Unsupported existence-assertion test shape: "${e.trim()}"`,i,"unsupported-syntax");const[,r,n]=o;return function(e,t,i){switch(e){case"eq":return t===i;case"ne":return t!==i;case"gt":return t>i;case"lt":return t<i;case"ge":return t>=i;case"le":return t<=i}}(r,t,Number(n))})}(e.test,r);return this._evaluatedResult(e,t,i,n,o,r)}const s=V(e.test,r,n);return this._evaluatedResult(e,t,i,s,o)}catch(r){if(r instanceof M)return console.warn(`[FormulaValidationService] Assertion "${e.id}" could not be evaluated (${r.reason}): ${r.message}`),this._skippedResult(e,t,"unresolvable");throw r}}_skippedResult(e,t,i){return{assertionId:e.id,roleURI:t.roleURI,roleLabel:t.role,type:e.type,severity:e.severity,satisfied:!1,skipped:!0,skipReason:i}}_evaluatedResult(e,t,i,o,r,n){const a=o?void 0:this._pickMessage(e,r);return{assertionId:e.id,roleURI:t.roleURI,roleLabel:t.role,type:e.type,severity:e.severity,satisfied:o,skipped:!1,message:a,matchedFactCount:n,conceptLinks:a?this._buildConceptLinks(e,t.roleURI,i,a):void 0}}_pickMessage(e,t){const i=e.messages;if(0===i.length)return;const o=i.find(e=>e.xmlLang===t)??i.find(e=>"en"===e.xmlLang)??i[0];return this._stripTechnicalDetail(o.text)}_stripTechnicalDetail(e){const t=e.indexOf("{");return-1===t?e.trim():e.slice(0,t).replace(/\|\s*$/,"").trim()}_buildConceptLinks(e,t,i,o){var r,n,a;const s=[],l=new Set;for(const d of e.variables)for(const e of se(d)){const c=(null==(r=i.conceptIdByQNamePerRole.get(t))?void 0:r.get(e))??(null==(a=null==(n=i.conceptByQName.get(e))?void 0:n[0])?void 0:a.conceptId);if(!c)continue;const p=e.includes(":")?e.split(":").pop():e;if(l.has(p))continue;if(!new RegExp("`"+this._escapeRegExp(p)+"`").test(o))continue;const u=le(d,c,i);s.push({label:p,conceptQName:e,conceptId:c,columnId:u[0]}),l.add(p)}return s}_escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}class ce{static findMatchingFact(e,t){if(!e||0===e.length)return null;const i=e.filter(e=>this.matchesPeriod(e,t));if(0===i.length)return null;const o=i.filter(e=>this.matchesDimensions(e,t));if(0===o.length)return null;if(o.length>1&&t.unit){const e=o.find(e=>this.matchesUnit(e,t));if(e)return e}return o[0]}static matchesPeriod(e,t){const i=this.parsePeriod(e.period);return"instant"===t.periodType&&t.periodInstantDate?i.isInstant&&i.instantDate===t.periodInstantDate:"duration"===t.periodType&&t.periodStartDate&&t.periodEndDate?!i.isInstant&&i.startDate===t.periodStartDate&&i.endDate===t.periodEndDate:t.periodInstantDate?i.isInstant&&i.instantDate===t.periodInstantDate:!t.periodStartDate||!t.periodEndDate||!i.isInstant&&i.startDate===t.periodStartDate&&i.endDate===t.periodEndDate}static matchesDimensions(e,t){const i=e.dimensions||[],o=this.extractDimensionsFromContext(t);if(0===o.length)return 0===i.length;if(0===i.length&&o.length>0)return!1;if(i.length!==o.length)return!1;return o.every(e=>i.some(t=>{if(!(this.normalizeAxisId(t.dimension)===this.normalizeAxisId(e.axisId)))return!1;if("explicit"===t.dimensionType&&e.memberId){return this.normalizeMemberId(t.member||"")===this.normalizeMemberId(e.memberId)}return!("typed"!==t.dimensionType||!e.isTyped)}))}static matchesUnit(e,t){if(!t.unit||!e.unitMeasure)return!0;return this.normalizeUnit(e.unitMeasure)===this.normalizeUnit(t.unit)}static parsePeriod(e){if(e.includes(" / ")){const[t,i]=e.split(" / ").map(e=>e.trim());return{isInstant:!1,startDate:t,endDate:i}}return{isInstant:!0,instantDate:e.trim()}}static extractDimensionsFromContext(e){if(!e.dimensionData)return[];const t=[];return e.dimensionData.combinations&&e.dimensionData.combinations.length>0&&e.dimensionData.combinations.forEach(e=>{t.push({axisId:e.axisId,memberId:e.memberId})}),e.dimensionData.typedMembers&&e.dimensionData.typedMembers.length>0&&e.dimensionData.typedMembers.forEach(e=>{t.push({axisId:e.axisId,memberId:"[typed]",isTyped:!0})}),t}static normalizeAxisId(e){if(!e)return"";if(e.includes(":")){const t=e.split(":");return t[1]||t[0]}if(e.includes("_")){e.split("_");const t=e.lastIndexOf("_");if(t>0)return e.substring(t+1)}return e}static normalizeMemberId(e){if(!e)return"";if(e.includes(":")){const t=e.split(":");return t[1]||t[0]}if(e.includes("_")){const t=e.lastIndexOf("_");if(t>0)return e.substring(t+1)}return e}static normalizeUnit(e){if(!e)return"";const t=e.split(":");return t.length>1?t[1]:t[0]}static extractTypedValues(e,t){const i={};if(!e||0===e.length)return i;return e.filter(e=>this.matchesPeriod(e,t)&&this.matchesDimensions(e,t)).forEach(e=>{e.dimensions&&e.dimensions.forEach(e=>{if("typed"===e.dimensionType&&e.typedMemberValue){const t=this.normalizeAxisId(e.dimension);i[t]=e.typedMemberValue}})}),i}static debugMatch(e,t){console.log("🔍 [FactMatcher] Debug Match"),console.log(" Context:",{conceptId:t.conceptId,columnId:t.columnId,period:"instant"===t.periodType?t.periodInstantDate:`${t.periodStartDate} / ${t.periodEndDate}`,dimensions:this.extractDimensionsFromContext(t)}),console.log(" Facts:",e.map(e=>{var t;return{value:e.value,period:e.period,dimensions:null==(t=e.dimensions)?void 0:t.map(e=>`${e.dimension}:${e.member}`)}}));const i=this.findMatchingFact(e,t);console.log(" Match Result:",i?i.value:"No match")}}class pe{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,a=String(t);if(n.pattern){const e=this.validatePattern(a,n.pattern);e&&o.push(e)}if(void 0!==n.length){const e=this.validateExactLength(a,n.length);e&&o.push(e)}if(void 0!==n.minLength){const e=this.validateMinLength(a,n.minLength);e&&o.push(e)}if(void 0!==n.maxLength){const e=this.validateMaxLength(a,n.maxLength);e&&o.push(e)}if(void 0!==n.totalDigits){const e=this.validateTotalDigits(a,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:T.t("xbrlValidation.patternMismatch",{pattern:t}),expectedValue:t,actualValue:e}}catch(i){return console.error(`Invalid regex pattern: ${t}`,i),{type:"pattern",message:T.t("xbrlValidation.invalidPattern",{pattern:t}),expectedValue:t,actualValue:e}}return null}static validateExactLength(e,t){return e.length!==t?{type:"length",message:T.t("xbrlValidation.exactLength",{required:t,current:e.length}),expectedValue:t,actualValue:e.length}:null}static validateMinLength(e,t){return e.length<t?{type:"minLength",message:T.t("xbrlValidation.minLength",{required:t,current:e.length}),expectedValue:t,actualValue:e.length}:null}static validateMaxLength(e,t){return e.length>t?{type:"maxLength",message:T.t("xbrlValidation.maxLength",{required:t,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:T.t("xbrlValidation.totalDigits",{required:t,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(T.t("xbrlValidation.ruleSummaryPattern",{pattern:o.pattern})),void 0!==o.length&&r.push(T.t("xbrlValidation.ruleSummaryExactLength",{required:o.length})),void 0!==o.minLength&&r.push(T.t("xbrlValidation.ruleSummaryMinLength",{required:o.minLength})),void 0!==o.maxLength&&r.push(T.t("xbrlValidation.ruleSummaryMaxLength",{required:o.maxLength})),void 0!==o.totalDigits&&r.push(T.t("xbrlValidation.ruleSummaryTotalDigits",{required:o.totalDigits})),r}}const ue={"nl-types:formattedExplanationItemType":{fieldType:"textarea",placeholder:T.t("field.enterDetailedExplanation")},"nl-types:monetaryNoDecimals20ItemType":{fieldType:"number",htmlInputType:"text",inputMode:"decimal",allowDecimals:!1,step:1,placeholder:T.t("field.enterAmountNoDecimals")},"xbrli:monetaryItemType":{fieldType:"currency",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:.01,placeholder:T.t("field.enterCurrency")},"xbrli:stringItemType":{fieldType:"text",htmlInputType:"text",placeholder:T.t("field.enterText")},"xbrli:dateItemType":{fieldType:"date",htmlInputType:"date"},"xbrli:dateTimeItemType":{fieldType:"datetime",htmlInputType:"datetime-local"},"xbrli:integerItemType":{fieldType:"integer",htmlInputType:"text",inputMode:"numeric",allowDecimals:!1,step:1,placeholder:T.t("field.enterWholeNumber")},"xbrli:nonNegativeIntegerItemType":{fieldType:"integer",htmlInputType:"text",inputMode:"numeric",allowDecimals:!1,min:0,step:1,placeholder:T.t("field.enterPositiveNumber")},"xbrli:positiveIntegerItemType":{fieldType:"integer",htmlInputType:"text",inputMode:"numeric",allowDecimals:!1,min:1,step:1,placeholder:T.t("field.enterPositiveNumber")},"xbrli:decimalItemType":{fieldType:"decimal",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:"any",placeholder:T.t("field.enterDecimalValue")},"xbrli:sharesItemType":{fieldType:"number",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,min:0,step:.01,placeholder:T.t("field.enterNumberOfShares")},"xbrli:shares":{fieldType:"number",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,min:0,step:.01,placeholder:T.t("field.enterNumberOfShares")},"xbrli:gYearItemType":{fieldType:"number",htmlInputType:"text",inputMode:"numeric",allowDecimals:!1,min:1900,max:2100,step:1,placeholder:T.t("field.yearFormat")},"xbrli:booleanItemType":{fieldType:"boolean"},"xbrli:pureItemType":{fieldType:"percentage",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:.01,placeholder:T.t("field.enterPercentage")},"xbrli:percentItemType":{fieldType:"percentage",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:.01,placeholder:T.t("field.enterPercentage")},"xbrli:emailItemType":{fieldType:"email",htmlInputType:"email",placeholder:T.t("field.emailPlaceholder")},"xbrli:urlItemType":{fieldType:"url",htmlInputType:"url",placeholder:T.t("field.urlPlaceholder")},"xbrli:telephoneItemType":{fieldType:"tel",htmlInputType:"tel",placeholder:T.t("field.phonePlaceholder")}};function he(e,t){if(!e)return{fieldType:"text",htmlInputType:"text",placeholder:T.t("field.enterValue")};if(t&&t.length>0){const i=be(e,t);if(i.length>0){return ye(i,t)}}if(console.log(`⚠️ [Type Resolution Fallback] Using pattern matching for: ${e}`),ue[e])return ue[e];const i=e.toLowerCase();if(i.includes("monetary"))return i.includes("nodecimals")||i.includes("no-decimals")?{fieldType:"number",htmlInputType:"text",inputMode:"decimal",allowDecimals:!1,step:1,placeholder:T.t("field.enterAmountNoDecimals")}:{fieldType:"currency",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:.01,placeholder:T.t("field.enterCurrency")};if(i.includes("explanation")||i.includes("description")||i.includes("notes")||i.includes("formatted"))return{fieldType:"textarea",placeholder:T.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:"text",inputMode:"numeric",allowDecimals:!1,min:i.includes("positive")?1:e?0:void 0,step:1,placeholder:T.t("field.enterWholeNumber")}}return i.includes("decimal")||i.includes("numeric")||i.includes("number")?{fieldType:"decimal",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:"any",placeholder:T.t("field.enterDecimalValue")}:i.includes("percent")||i.includes("pure")?{fieldType:"percentage",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:.01,placeholder:T.t("field.enterPercentage")}:{fieldType:"text",htmlInputType:"text",placeholder:T.t("field.enterValue")}}function me(e){return"textarea"===e}function fe(e){return"boolean"===e}function ge(e){return["number","decimal","integer","currency","percentage"].includes(e)}function be(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 ve(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 ye(e,t){if(!e||0===e.length)return{fieldType:"text",htmlInputType:"text",placeholder:T.t("field.enterValue")};if(t&&t.length>0){const i=ve(e,t);if(i&&i.length>0)return{fieldType:"select",enumerations:i,placeholder:T.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:T.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:"text",inputMode:"numeric",allowDecimals:!1,min:o.includes("positive")?1:e?0:void 0,step:1,placeholder:T.t("field.enterWholeNumber")}}return i.some(e=>e.includes("percent")||e.includes("pure"))?{fieldType:"percentage",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:.01,placeholder:T.t("field.enterPercentage")}: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:"text",inputMode:"decimal",allowDecimals:!1,step:1,placeholder:T.t("field.enterAmountNoDecimals")}:{fieldType:"currency",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:.01,placeholder:T.t("field.enterCurrency")}:{fieldType:"decimal",htmlInputType:"text",inputMode:"decimal",allowDecimals:!0,step:"any",placeholder:T.t("field.enterDecimalValue")}:e.some(e=>"xbrli:stringItemType"===e)||i.some(e=>"string"===e||e.includes("stringitem"))?{fieldType:"text",htmlInputType:"text",placeholder:T.t("field.enterText")}:{fieldType:"text",htmlInputType:"text",placeholder:T.t("field.enterValue")}}var xe=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,De=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?_e(t,i):t,a=e.length-1;a>=0;a--)(r=e[a])&&(n=(o?r(t,i,n):r(n))||n);return o&&n&&xe(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.mode="inputForm",this.globalDecimals="INF",this.typedMemberValues={},this._errors=[],this._xbrlErrors=[],this._touched=!1,this._showPeriodPopup=!1,this._availableUnits=[],this._numericDraftValue=null}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))}_isRoundingLevelConcept(){return!!this.conceptId&&this.conceptId.includes("DocumentIntendedRoundingLevel")}_isNumericField(){var e;return ge(he(this.conceptType,this.datatypes).fieldType||(null==(e=this.field)?void 0:e.type)||"text")||"number"===this._getInputType()}_isIntermediateNumericValue(e){return"-"===e||"."===e||"-."===e}_handleInput(e){const t=e.target,i=this.value;let o=t.value;if(this._isNumericField()){const e=t.value;if(this._numericDraftValue=e,""===e||this._isIntermediateNumericValue(e))o=null;else{const t=Number(e);o=Number.isNaN(t)?null:t}}else"boolean"===this.field.type?(o=t.checked,this._numericDraftValue=null):this._numericDraftValue=null;this.value=o,this._touched=!0,this.dispatchEvent(new CustomEvent("field-change",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId,value:o,oldValue:i},bubbles:!0}))}_handleFocus(){this.dispatchEvent(new CustomEvent("field-focus",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId},bubbles:!0}))}_handleBlur(){let e=!1;if(this._isNumericField()&&null!==this._numericDraftValue){e=!0;const t=this._numericDraftValue;if(""===t||this._isIntermediateNumericValue(t))this.value=null;else{const e=Number(t);this.value=Number.isNaN(e)?null:e}this._numericDraftValue=null}if(this._isPercentItemType()&&e&&null!==this.value&&void 0!==this.value){const e=Number(this.value);if(!isNaN(e)&&Math.abs(e)>1){this.value=e/100;const t=e;this.dispatchEvent(new CustomEvent("field-change",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId,value:this.value,oldValue:t},bubbles:!0}))}}this._touched=!0,this._validateXBRLDatatype(),this._validateUnitSelection(),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`)}_isMonetaryType(){if(!this.conceptType||!this.datatypes)return!1;if(this.conceptType.includes("monetary")||this.conceptType.includes("Monetary"))return!0;return be(this.conceptType,this.datatypes).some(e=>e.includes("monetary")||e.includes("Monetary"))}_isPercentItemType(){if(!this.conceptType)return!1;if(this.conceptType.toLowerCase().includes("percent"))return!0;if(!this.datatypes)return!1;return be(this.conceptType,this.datatypes).some(e=>e.toLowerCase().includes("percent"))}_handleKeyDown(e){const t=e.target;if(!this._isNumericField())return;if(["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(e.key))return;if(e.ctrlKey||e.metaKey)return;const i=he(this.conceptType,this.datatypes),o=void 0===i.min||i.min<0;("-"!==e.key||!o||t.value.includes("-")||0!==t.selectionStart&&0!==t.value.length)&&("."!==e.key||!1===i.allowDecimals||t.value.includes("."))&&(e.key>="0"&&e.key<="9"||e.preventDefault())}_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=pe.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}))}_validateUnitSelection(){if(null===this.value||void 0===this.value||""===this.value)return;const e=this._collectUnitsForConceptType();if(0===e.length)return;if(this.unit)return;const t=e.find(e=>!0===e.isDefault)??(1===e.length?e[0]:null);if(t)return this.unit=t.id,this.dispatchEvent(new CustomEvent("unit-change",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId,unit:this.unit},bubbles:!0,composed:!0})),void console.log(`🎯 [FormField] Auto-selected default unit on blur: ${this.unit} for ${this.conceptId}`);this._xbrlErrors=[...this._xbrlErrors,{type:"unit",message:T.t("validation.unitRequired"),expectedValue:e.map(e=>e.label).join(", "),actualValue:""}],console.log(`❌ [FormField] Unit validation failed for ${this.conceptId}: unit is required but not selected`)}_handlePeriodIconClick(){if(!this._isRoundingLevelConcept()){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=be(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")}_handleDecimalsChange(e){const t=e.target.value.trim(),i=parseFloat(t),o=t&&!isNaN(i)?String(Math.abs(i)):""===t?"":t;this.decimals=o||void 0,this.dispatchEvent(new CustomEvent("decimals-change",{detail:{conceptId:this.conceptId,columnId:this.columnId,decimals:this.decimals},bubbles:!0,composed:!0}))}_handlePopupOverlayClick(e){e.target===e.currentTarget&&this._closePeriodPopup()}_ensureTextDialogStyles(){if(document.getElementById("jdf-text-dialog-styles"))return;const e=document.createElement("style");e.id="jdf-text-dialog-styles",e.textContent="\n dialog.jdf-text-entry-dialog {\n border: none; border-radius: 8px; padding: 0;\n max-width: 600px; width: 90vw;\n box-shadow: 0 8px 32px rgba(0,0,0,0.2); overflow: hidden;\n font-family: inherit;\n }\n dialog.jdf-text-entry-dialog::backdrop { background: rgba(0,0,0,0.35); }\n .jdf-text-dialog-header {\n background: #f0f2f5; padding: 14px 20px;\n display: flex; align-items: center; justify-content: space-between;\n border-bottom: 1px solid #ddd;\n }\n .jdf-text-dialog-title {\n font-size: 15px; font-weight: 600; color: #333; margin: 0;\n font-family: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;\n }\n .jdf-text-dialog-close {\n flex-shrink: 0; width: 28px; height: 28px; border: none; background: transparent;\n font-size: 20px; line-height: 1; cursor: pointer; color: #666;\n border-radius: 4px; display: flex; align-items: center; justify-content: center;\n padding: 0; font-family: inherit; margin-left: 8px;\n }\n .jdf-text-dialog-close:hover { background: #ddd; color: #333; }\n .jdf-text-dialog-body { padding: 20px 20px 12px; }\n .jdf-text-dialog-textarea {\n width: 100%; min-height: 200px; max-height: 50vh;\n padding: 10px 12px; font-size: 14px; font-family: inherit;\n border: 1px solid #ddd; border-radius: 4px;\n box-sizing: border-box; resize: vertical; line-height: 1.5;\n color: #333; background: #fff;\n }\n .jdf-text-dialog-textarea:focus {\n outline: none; border-color: #1976d2;\n box-shadow: 0 0 0 2px rgba(25,118,210,0.2);\n }\n .jdf-text-dialog-char-count {\n margin-top: 4px; font-size: 12px; color: #888; text-align: right;\n font-family: inherit;\n }\n .jdf-text-dialog-actions {\n display: flex; justify-content: flex-end; gap: 8px;\n padding: 12px 20px 16px; border-top: 1px solid #eee;\n }\n .jdf-text-dialog-cancel {\n padding: 7px 18px; border: 1px solid #ddd; border-radius: 4px;\n background: transparent; color: #555; font-size: 14px;\n cursor: pointer; font-family: inherit;\n }\n .jdf-text-dialog-cancel:hover { background: #f5f5f5; }\n .jdf-text-dialog-save {\n padding: 7px 18px; border: none; border-radius: 4px;\n background: #1976d2; color: #fff; font-size: 14px;\n cursor: pointer; font-family: inherit; font-weight: 500;\n }\n .jdf-text-dialog-save:hover { background: #1565c0; }\n ",document.head.appendChild(e)}_openTextDialog(e,t){var i;this._ensureTextDialogStyles(),null==(i=document.getElementById("jdf-text-entry-dialog"))||i.remove();const o=document.createElement("dialog");o.id="jdf-text-entry-dialog",o.className="jdf-text-entry-dialog",o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),o.setAttribute("aria-labelledby","jdf-text-dialog-title"),o.innerHTML='\n <div class="jdf-text-dialog-header">\n <h3 class="jdf-text-dialog-title" id="jdf-text-dialog-title"></h3>\n <button class="jdf-text-dialog-close" type="button" aria-label="Close">×</button>\n </div>\n <div class="jdf-text-dialog-body">\n <textarea class="jdf-text-dialog-textarea" spellcheck="true"></textarea>\n <div class="jdf-text-dialog-char-count"></div>\n </div>\n <div class="jdf-text-dialog-actions">\n <button class="jdf-text-dialog-cancel" type="button"></button>\n <button class="jdf-text-dialog-save" type="button"></button>\n </div>\n ';const r=t;o.querySelector(".jdf-text-dialog-title").textContent=r||t,o.querySelector(".jdf-text-dialog-cancel").textContent=T.t("field.cancel"),o.querySelector(".jdf-text-dialog-save").textContent=T.t("field.save");const n=o.querySelector(".jdf-text-dialog-textarea"),a=o.querySelector(".jdf-text-dialog-char-count");n.value=e,a.textContent=`${e.length} ${T.t("field.characters")}`,n.addEventListener("input",()=>{a.textContent=`${n.value.length} ${T.t("field.characters")}`}),o.querySelector(".jdf-text-dialog-close").addEventListener("click",()=>o.close()),o.querySelector(".jdf-text-dialog-cancel").addEventListener("click",()=>o.close()),o.querySelector(".jdf-text-dialog-save").addEventListener("click",()=>{const e=n.value,t=this.value;this.value=e,this._touched=!0,this.dispatchEvent(new CustomEvent("field-change",{detail:{fieldId:this.field.id,conceptId:this.conceptId,columnId:this.columnId,value:e,oldValue:t},bubbles:!0})),o.close()}),o.addEventListener("click",e=>{const t=o.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&o.close()}),o.addEventListener("close",()=>o.remove()),document.body.appendChild(o),o.showModal(),n.focus()}_renderTextDialogTrigger(t,i){const o=null!=t&&""!==String(t).trim(),r=o?String(t):"";return i?e.html`
|
|
23
23
|
<span class="text-readonly-label ${o?"":"empty"}"
|
|
24
24
|
title="${r}">${o?r:"—"}</span>
|
|
25
25
|
`:o?e.html`
|
|
@@ -29,21 +29,21 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
29
29
|
${r}
|
|
30
30
|
</span>
|
|
31
31
|
<button class="text-edit-btn" type="button"
|
|
32
|
-
aria-label="${
|
|
32
|
+
aria-label="${T.t("field.editText")}"
|
|
33
33
|
@click="${()=>{var e;return this._openTextDialog(r,(null==(e=this.field)?void 0:e.label)||"")}}">
|
|
34
|
-
✎ ${
|
|
34
|
+
✎ ${T.t("field.editText")}
|
|
35
35
|
</button>
|
|
36
36
|
</div>
|
|
37
37
|
`:e.html`
|
|
38
38
|
<button class="text-trigger-btn" type="button"
|
|
39
|
-
aria-label="${
|
|
39
|
+
aria-label="${T.t("field.addText")}"
|
|
40
40
|
@click="${()=>{var e;return this._openTextDialog("",(null==(e=this.field)?void 0:e.label)||"")}}">
|
|
41
|
-
+ ${
|
|
41
|
+
+ ${T.t("field.addText")}
|
|
42
42
|
</button>
|
|
43
|
-
`}_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})}_handleCrossRoleTypedMemberChange(e,t){const i=e.target.value;this.typedMemberValues={...this.typedMemberValues,[t]:i},this.dispatchEvent(new CustomEvent("typed-member-change",{detail:{columnId:this.columnId,conceptId:this.conceptId,axisId:t,value:i},bubbles:!0,composed:!0}))}_renderReadonlyValue(t){const i=
|
|
43
|
+
`}_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})}_handleCrossRoleTypedMemberChange(e,t){const i=e.target.value;this.typedMemberValues={...this.typedMemberValues,[t]:i},this.dispatchEvent(new CustomEvent("typed-member-change",{detail:{columnId:this.columnId,conceptId:this.conceptId,axisId:t,value:i},bubbles:!0,composed:!0}))}_renderReadonlyValue(t){const i=he(this.conceptType,this.datatypes),o=i.fieldType||this.field.type||"text";let r;if("boolean"===o||fe(o))r=t?T.t("form.yes"):T.t("form.no");else if("select"===o||"select"===this.field.type){const e=(i.enumerations||this.field.options||[]).find(e=>e.value===t);r=e?e.label||e.value:t??""}else r=null!=t?String(t):"";const n=""===r||null==r,a=this._isMonetaryType();return e.html`<span class="readonly-value ${n?"empty":""} ${a?"monetary":""}">${n?"—":r}</span>`}_renderInput(t=this.value,i=this.disabled){if("readonly"===this.mode)return this._renderReadonlyValue(t);const o=this._errors.some(e=>"error"===e.severity),r=this._errors.some(e=>"warning"===e.severity),n=`field-input ${o?"error":r?"warning":""} ${this._isMonetaryType()?"monetary":""}`,a=`${this.conceptId}__${this.columnId}`,s=`data[${this.conceptId}][${this.columnId}]`,l=he(this.conceptType,this.datatypes);this.conceptType;const d=l.fieldType||this.field.type||"text";if("textarea"===d||me(d))return this._renderTextDialogTrigger(t,i||this.field.disabled||!1);if("select"===d||"select"===this.field.type){const o=l.enumerations||this.field.options||[];return e.html`
|
|
44
44
|
<select
|
|
45
|
-
id="${
|
|
46
|
-
name="${
|
|
45
|
+
id="${a}"
|
|
46
|
+
name="${s}"
|
|
47
47
|
class="${n}"
|
|
48
48
|
.value="${t??""}"
|
|
49
49
|
?disabled="${i||this.field.disabled}"
|
|
@@ -51,7 +51,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
51
51
|
@focus="${this._handleFocus}"
|
|
52
52
|
@blur="${this._handleBlur}"
|
|
53
53
|
>
|
|
54
|
-
<option value="">${
|
|
54
|
+
<option value="">${l.placeholder||T.t("field.select")}</option>
|
|
55
55
|
${o.map(i=>{const o=i.value,r=i.label||i.value,n=i.disabled||!1;return e.html`
|
|
56
56
|
<option
|
|
57
57
|
value="${o}"
|
|
@@ -62,11 +62,11 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
62
62
|
</option>
|
|
63
63
|
`})}
|
|
64
64
|
</select>
|
|
65
|
-
`}if("boolean"===d||
|
|
65
|
+
`}if("boolean"===d||fe(d))return e.html`
|
|
66
66
|
<div class="checkbox-container">
|
|
67
67
|
<input
|
|
68
|
-
id="${
|
|
69
|
-
name="${
|
|
68
|
+
id="${a}"
|
|
69
|
+
name="${s}"
|
|
70
70
|
type="checkbox"
|
|
71
71
|
class="field-input"
|
|
72
72
|
.checked="${Boolean(t)}"
|
|
@@ -77,19 +77,19 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
77
77
|
/>
|
|
78
78
|
<span>${this.field.label}</span>
|
|
79
79
|
</div>
|
|
80
|
-
`;const c=
|
|
80
|
+
`;const c=l.htmlInputType||this._getInputType(),p=void 0!==l.step?l.step:ge(d)?"any":void 0,u=l.min,h=l.max;let m;return m=this._isNumericField()&&null!==this._numericDraftValue?this._numericDraftValue:"percentage"===d&&null!=t&&""!==t?Number(t).toFixed(4):t??"",e.html`
|
|
81
81
|
<input
|
|
82
|
-
id="${
|
|
83
|
-
name="${
|
|
82
|
+
id="${a}"
|
|
83
|
+
name="${s}"
|
|
84
84
|
type="${c}"
|
|
85
|
-
inputmode="${
|
|
85
|
+
inputmode="${l.inputMode||""}"
|
|
86
86
|
class="${n}"
|
|
87
87
|
.value="${m}"
|
|
88
88
|
?disabled="${i||this.field.disabled}"
|
|
89
|
-
placeholder="${
|
|
89
|
+
placeholder="${l.placeholder||this.field.placeholder||""}"
|
|
90
90
|
step="${void 0!==p?p:""}"
|
|
91
|
-
min="${void 0!==
|
|
92
|
-
max="${void 0!==
|
|
91
|
+
min="${void 0!==u?u:""}"
|
|
92
|
+
max="${void 0!==h?h:""}"
|
|
93
93
|
@input="${this._handleInput}"
|
|
94
94
|
@focus="${this._handleFocus}"
|
|
95
95
|
@blur="${this._handleBlur}"
|
|
@@ -97,7 +97,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
97
97
|
/>
|
|
98
98
|
`}_getInputType(){switch(this.field.type){case"number":case"decimal":case"currency":case"percentage":default:return"text";case"date":return"date";case"datetime":return"datetime-local";case"email":return"email";case"url":return"url";case"tel":return"tel"}}_extractBaseConceptId(e){const t=e.split("__");return t.length>1?t.slice(0,-1).join("__"):e}_renderPeriodControls(){return"nl-cd_DescriptionLocationNL__a64trl"===this.conceptId&&console.log(`🔍 [FormField Render] Concept: ${this.conceptId}, ColumnId: ${this.columnId}, Field periodType: ${this.field.periodType}, Field periodStartDate: ${this.field.periodStartDate}, Field periodEndDate: ${this.field.periodEndDate}`),this.field.periodType?"instant"===this.field.periodType?e.html`
|
|
99
99
|
<div class="period-controls">
|
|
100
|
-
<label>${
|
|
100
|
+
<label>${T.t("field.date")}:</label>
|
|
101
101
|
<div class="date-wrapper">
|
|
102
102
|
<input
|
|
103
103
|
type="date"
|
|
@@ -114,7 +114,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
114
114
|
</div>
|
|
115
115
|
`:"duration"===this.field.periodType?e.html`
|
|
116
116
|
<div class="period-controls">
|
|
117
|
-
<label>${
|
|
117
|
+
<label>${T.t("field.from")}:</label>
|
|
118
118
|
<div class="date-wrapper">
|
|
119
119
|
<input
|
|
120
120
|
type="date"
|
|
@@ -128,7 +128,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
128
128
|
a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V9h14z"/>
|
|
129
129
|
</svg>
|
|
130
130
|
</div>
|
|
131
|
-
<label>${
|
|
131
|
+
<label>${T.t("field.to")}:</label>
|
|
132
132
|
<div class="date-wrapper">
|
|
133
133
|
<input
|
|
134
134
|
type="date"
|
|
@@ -147,7 +147,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
147
147
|
<div class="period-popup-overlay" @click="${this._handlePopupOverlayClick}">
|
|
148
148
|
<div class="period-popup" @click="${e=>e.stopPropagation()}">
|
|
149
149
|
<div class="period-popup-header">
|
|
150
|
-
<div class="period-popup-title">${
|
|
150
|
+
<div class="period-popup-title">${T.t("field.editPeriod")}</div>
|
|
151
151
|
<button class="period-popup-close" @click="${this._closePeriodPopup}">
|
|
152
152
|
×
|
|
153
153
|
</button>
|
|
@@ -156,7 +156,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
156
156
|
<div class="period-popup-content">
|
|
157
157
|
${"instant"===this.field.periodType?e.html`
|
|
158
158
|
<div class="period-controls">
|
|
159
|
-
<label>${
|
|
159
|
+
<label>${T.t("field.date")}:</label>
|
|
160
160
|
<div class="date-wrapper">
|
|
161
161
|
<input
|
|
162
162
|
type="date"
|
|
@@ -173,7 +173,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
173
173
|
</div>
|
|
174
174
|
`:e.html`
|
|
175
175
|
<div class="period-controls">
|
|
176
|
-
<label>${
|
|
176
|
+
<label>${T.t("field.from")}:</label>
|
|
177
177
|
<div class="date-wrapper">
|
|
178
178
|
<input
|
|
179
179
|
type="date"
|
|
@@ -191,7 +191,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
191
191
|
</div>
|
|
192
192
|
</div>
|
|
193
193
|
<div class="period-controls">
|
|
194
|
-
<label>${
|
|
194
|
+
<label>${T.t("field.to")}:</label>
|
|
195
195
|
<div class="date-wrapper">
|
|
196
196
|
<input
|
|
197
197
|
type="date"
|
|
@@ -210,14 +210,14 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
210
210
|
|
|
211
211
|
${this._availableUnits.length>0?e.html`
|
|
212
212
|
<div class="period-controls">
|
|
213
|
-
<label>${
|
|
213
|
+
<label>${T.t("field.unit")}:</label>
|
|
214
214
|
<select
|
|
215
215
|
.value="${this.unit||""}"
|
|
216
216
|
@change="${this._handleUnitChange}"
|
|
217
217
|
?disabled="${this.disabled}"
|
|
218
218
|
class="unit-select"
|
|
219
219
|
>
|
|
220
|
-
<option value="">${
|
|
220
|
+
<option value="">${T.t("field.selectUnit")}</option>
|
|
221
221
|
${this._availableUnits.map(t=>e.html`
|
|
222
222
|
<option value="${t.id}" ?selected="${this.unit===t.id}">
|
|
223
223
|
${t.label||t.id}
|
|
@@ -229,12 +229,12 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
229
229
|
|
|
230
230
|
${this._isMonetaryType()?e.html`
|
|
231
231
|
<div class="period-controls">
|
|
232
|
-
<label>${
|
|
232
|
+
<label>${T.t("field.scale")}:</label>
|
|
233
233
|
<input
|
|
234
234
|
type="number"
|
|
235
235
|
min="0"
|
|
236
236
|
class="typed-member-input"
|
|
237
|
-
placeholder="${
|
|
237
|
+
placeholder="${T.t("field.leaveBlankForInf")}"
|
|
238
238
|
.value="${void 0!==this.decimals&&null!==this.decimals&&""!==this.decimals?this.decimals:"INF"!==this.globalDecimals?this.globalDecimals:""}"
|
|
239
239
|
@input="${this._handleDecimalsChange}"
|
|
240
240
|
?disabled="${this.disabled}"
|
|
@@ -259,7 +259,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
259
259
|
</div>
|
|
260
260
|
</div>
|
|
261
261
|
</div>
|
|
262
|
-
`}render(){var t,i;if(!this.field)return console.error("[FormField] No field provided!",{conceptId:this.conceptId,columnId:this.columnId}),e.html`<div>Error: No field data</div>`;const o=!this.hideLabel&&"boolean"!==this.field.type,r=this.field.periodType&&("instant"===this.field.periodType||"duration"===this.field.periodType),n=this._extractBaseConceptId(this.conceptId),
|
|
262
|
+
`}render(){var t,i;if(!this.field)return console.error("[FormField] No field provided!",{conceptId:this.conceptId,columnId:this.columnId}),e.html`<div>Error: No field data</div>`;const o=!this.hideLabel&&"boolean"!==this.field.type,r=this.field.periodType&&("instant"===this.field.periodType||"duration"===this.field.periodType),n=this._extractBaseConceptId(this.conceptId),a="admin"!==this.mode&&this.masterData&&n in this.masterData,s=this._isRoundingLevelConcept();let l=null;if(this.facts&&this.facts.length>0&&!a){const e={conceptId:n,columnId:this.columnId,periodStartDate:this.periodStartDate||this.field.periodStartDate,periodEndDate:this.periodEndDate||this.field.periodEndDate,periodInstantDate:this.periodInstantDate||this.field.periodInstantDate,periodType:this.field.periodType,unit:this.unit,dimensionData:null==(t=this.column)?void 0:t.dimensionData},o=n.includes("BalanceSheet")||n.includes("CostsIncorporation")||n.includes("Assets");o&&this.facts.length>0&&console.log("🔍 [FormField] Attempting fact match for concept with dimensions:",{conceptId:n,columnId:this.columnId,factsCount:this.facts.length,cellContext:{period:"instant"===e.periodType?e.periodInstantDate:`${e.periodStartDate} / ${e.periodEndDate}`,dimensionData:e.dimensionData},facts:this.facts.map(e=>{var t;return{value:e.value,period:e.period,dimensions:null==(t=e.dimensions)?void 0:t.map(e=>`${e.dimension}:${e.member}`)}})});const r=ce.findMatchingFact(this.facts,e);r?(l=r.value,(o||n.includes("StreetName"))&&console.log("✅ [FormField] Fact matched:",{conceptId:n,columnId:this.columnId,factValue:r.value,period:r.period,dimensions:null==(i=r.dimensions)?void 0:i.map(e=>`${e.dimension}:${e.member}`)})):o&&this.facts.length>0&&console.log("❌ [FormField] No fact match found for:",{conceptId:n,columnId:this.columnId,factsAvailable:this.facts.length})}const d=null!==this.value&&void 0!==this.value,c=a?this.masterData[n]:d?this.value:l,p=a||s||this.disabled||"readonly"===this.mode;return e.html`
|
|
263
263
|
<div class="field-container">
|
|
264
264
|
${o?e.html`
|
|
265
265
|
<label class="field-label ${this.field.required?"required":""}">
|
|
@@ -270,10 +270,11 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
270
270
|
<div class="field-wrapper">
|
|
271
271
|
${this._renderInput(c,p)}
|
|
272
272
|
|
|
273
|
-
${r&&"readonly"!==this.mode&&!
|
|
273
|
+
${r&&"readonly"!==this.mode&&!s?e.html`
|
|
274
274
|
<button
|
|
275
275
|
class="period-icon-btn"
|
|
276
276
|
type="button"
|
|
277
|
+
tabindex="-1"
|
|
277
278
|
@click="${this._handlePeriodIconClick}"
|
|
278
279
|
title="Edit period"
|
|
279
280
|
>
|
|
@@ -766,7 +767,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
766
767
|
:host(.concept-highlight) {
|
|
767
768
|
animation: concept-highlight-pulse 10s ease-out forwards;
|
|
768
769
|
}
|
|
769
|
-
`,B([S({type:Object})],exports.JupiterFormField.prototype,"field",2),B([S({type:String})],exports.JupiterFormField.prototype,"conceptId",2),B([S({type:String})],exports.JupiterFormField.prototype,"conceptType",2),B([S({type:Array})],exports.JupiterFormField.prototype,"datatypes",2),B([S({type:Array})],exports.JupiterFormField.prototype,"defaultUnits",2),B([S({type:String})],exports.JupiterFormField.prototype,"columnId",2),B([S()],exports.JupiterFormField.prototype,"value",2),B([S({type:Boolean})],exports.JupiterFormField.prototype,"disabled",2),B([S({type:String})],exports.JupiterFormField.prototype,"locale",2),B([S({type:Boolean})],exports.JupiterFormField.prototype,"hideLabel",2),B([S({type:String})],exports.JupiterFormField.prototype,"mode",2),B([S({type:Object})],exports.JupiterFormField.prototype,"masterData",2),B([S({type:Array})],exports.JupiterFormField.prototype,"facts",2),B([S({type:Object})],exports.JupiterFormField.prototype,"column",2),B([S({type:String})],exports.JupiterFormField.prototype,"periodStartDate",2),B([S({type:String})],exports.JupiterFormField.prototype,"periodEndDate",2),B([S({type:String})],exports.JupiterFormField.prototype,"periodInstantDate",2),B([S({type:String})],exports.JupiterFormField.prototype,"unit",2),B([S({type:String})],exports.JupiterFormField.prototype,"decimals",2),B([S({type:String})],exports.JupiterFormField.prototype,"globalDecimals",2),B([S({type:Object})],exports.JupiterFormField.prototype,"typedMemberValues",2),B([w()],exports.JupiterFormField.prototype,"_errors",2),B([w()],exports.JupiterFormField.prototype,"_xbrlErrors",2),B([w()],exports.JupiterFormField.prototype,"_touched",2),B([w()],exports.JupiterFormField.prototype,"_showPeriodPopup",2),B([w()],exports.JupiterFormField.prototype,"_availableUnits",2),B([w()],exports.JupiterFormField.prototype,"_numericDraftValue",2),exports.JupiterFormField=B([t("jupiter-form-field")],exports.JupiterFormField);var q=Object.defineProperty,H=Object.getOwnPropertyDescriptor,Y=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?H(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.decimalsData={},this.globalDecimals="INF",this.defaultUnits=[],this.disabled=!1,this.locale="en-US",this.expandedConcepts=new Set,this.mode="inputForm",this.typedMemberData={},this.showAddButton=!1,this.showRemoveButton=!1,this.language="en",this.rowFocused=!1,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}))}_handleAddRepeat(){this.dispatchEvent(new CustomEvent("add-concept-repeat",{detail:{conceptId:this.concept.id},bubbles:!0,composed:!0}))}_handleRemoveRepeat(){this.dispatchEvent(new CustomEvent("remove-concept-repeat",{detail:{conceptId:this.concept.id},bubbles:!0,composed:!0}))}_handleFieldFocus(e){e.stopPropagation(),this.dispatchEvent(new CustomEvent("field-focus",{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")}_getDocLabel(){const e=this.concept.conceptMetadata;if(!e)return"";const t=this.language||this.locale.split("-")[0];return e.documentationLabels[t]||e.documentationLabels.en||e.documentationLabels.nl||""}_escapeHtml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}_ensureDialogStyles(){if(document.getElementById("jdf-concept-info-dialog-styles"))return;const e=document.createElement("style");e.id="jdf-concept-info-dialog-styles",e.textContent="\n dialog.jdf-concept-info-dialog {\n border: none; border-radius: 8px; padding: 0;\n max-width: 480px; width: 90vw;\n box-shadow: 0 8px 32px rgba(0,0,0,0.2); overflow: hidden;\n }\n dialog.jdf-concept-info-dialog::backdrop { background: rgba(0,0,0,0.35); }\n .jdf-dialog-header {\n background: #f0f2f5; padding: 14px 20px;\n display: flex; align-items: center; justify-content: space-between;\n border-bottom: 1px solid #ddd;\n }\n .jdf-dialog-title { font-size: 15px; font-weight: 600; color: #333; margin: 0; font-family: inherit; }\n .jdf-dialog-close-btn {\n width: 28px; height: 28px; border: none; background: transparent;\n font-size: 20px; line-height: 1; cursor: pointer; color: #666;\n border-radius: 4px; display: flex; align-items: center; justify-content: center;\n padding: 0; font-family: inherit;\n }\n .jdf-dialog-close-btn:hover { background: #ddd; color: #333; }\n .jdf-dialog-body { padding: 20px; }\n .jdf-info-table { width: 100%; border-collapse: collapse; font-size: 14px; font-family: inherit; }\n .jdf-info-table tr:not(:last-child) td { border-bottom: 1px solid #f0f0f0; }\n .jdf-info-table td { padding: 9px 4px; vertical-align: top; }\n .jdf-info-label { font-weight: 600; color: #666; width: 40%; white-space: nowrap; padding-right: 16px; }\n .jdf-info-value { color: #333; word-break: break-all; }\n .jdf-info-value.doc-text { font-style: italic; color: #555; line-height: 1.5; word-break: normal; }\n .jdf-period-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }\n .jdf-period-pill.instant { background: rgba(25,118,210,0.1); color: #1565c0; border: 1px solid rgba(25,118,210,0.3); }\n .jdf-period-pill.duration { background: rgba(56,142,60,0.1); color: #2e7d32; border: 1px solid rgba(56,142,60,0.3); }\n .jdf-balance-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; text-transform: capitalize; }\n .jdf-balance-pill.debit { background: rgba(211,47,47,0.1); color: #c62828; border: 1px solid rgba(211,47,47,0.3); }\n .jdf-balance-pill.credit { background: rgba(56,142,60,0.1); color: #2e7d32; border: 1px solid rgba(56,142,60,0.3); }\n ",document.head.appendChild(e)}_openInfoDialog(e){var t;e.stopPropagation(),this._ensureDialogStyles();const i=this.concept.conceptMetadata,o=this._getDocLabel(),r=(null==i?void 0:i.periodType)||this.concept.periodType,n=(null==i?void 0:i.balance)||this.concept.balance,s="instant"===r?k.t("conceptInfo.instant"):k.t("conceptInfo.duration"),l=[{label:k.t("conceptInfo.conceptName"),valueHtml:this._escapeHtml((null==i?void 0:i.conceptName)||this.concept.name)},{label:k.t("conceptInfo.type"),valueHtml:this._escapeHtml((null==i?void 0:i.type)||this.concept.type||"—")}];(null==i?void 0:i.substitutionGroup)&&l.push({label:k.t("conceptInfo.substitutionGroup"),valueHtml:this._escapeHtml(i.substitutionGroup)}),l.push({label:k.t("conceptInfo.periodType"),valueHtml:`<span class="jdf-period-pill ${r}">${this._escapeHtml(s)}</span>`}),n&&l.push({label:k.t("conceptInfo.balance"),valueHtml:`<span class="jdf-balance-pill ${n}">${this._escapeHtml(n)}</span>`}),o&&l.push({label:k.t("conceptInfo.documentation"),valueHtml:this._escapeHtml(o),isDoc:!0});const a=l.map(e=>`\n <tr>\n <td class="jdf-info-label">${this._escapeHtml(e.label)}</td>\n <td class="jdf-info-value${e.isDoc?" doc-text":""}">${e.valueHtml}</td>\n </tr>\n `).join(""),d=document.createElement("dialog");d.className="jdf-concept-info-dialog",d.innerHTML=`\n <div class="jdf-dialog-header">\n <h3 class="jdf-dialog-title">${this._escapeHtml(k.t("conceptInfo.title"))}</h3>\n <button class="jdf-dialog-close-btn" type="button" aria-label="${this._escapeHtml(k.t("conceptInfo.close"))}">×</button>\n </div>\n <div class="jdf-dialog-body">\n <table class="jdf-info-table">${a}</table>\n </div>\n `,document.body.appendChild(d),null==(t=d.querySelector(".jdf-dialog-close-btn"))||t.addEventListener("click",()=>d.close()),d.addEventListener("click",e=>{const t=d.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&d.close()}),d.addEventListener("close",()=>document.body.removeChild(d)),d.showModal()}_ensureCalcWarningDialogStyles(){if(document.getElementById("jdf-calc-warning-dialog-styles"))return;const e=document.createElement("style");e.id="jdf-calc-warning-dialog-styles",e.textContent="\n dialog.jdf-calc-warning-dialog {\n border: none; border-radius: 8px; padding: 0;\n max-width: 480px; width: 90vw;\n box-shadow: 0 8px 32px rgba(0,0,0,0.2); overflow: hidden;\n }\n dialog.jdf-calc-warning-dialog::backdrop { background: rgba(0,0,0,0.35); }\n .jdf-calc-warning-header {\n background: #fff3e0; padding: 14px 20px;\n display: flex; align-items: center; justify-content: space-between;\n border-bottom: 1px solid #ffcc80;\n }\n .jdf-calc-warning-title { font-size: 15px; font-weight: 600; color: #e65100; margin: 0; font-family: inherit; }\n .jdf-calc-warning-close-btn {\n width: 28px; height: 28px; border: none; background: transparent;\n font-size: 20px; line-height: 1; cursor: pointer; color: #666;\n border-radius: 4px; display: flex; align-items: center; justify-content: center;\n padding: 0; font-family: inherit;\n }\n .jdf-calc-warning-close-btn:hover { background: #ffe0b2; color: #e65100; }\n .jdf-calc-warning-body { padding: 20px; font-family: inherit; font-size: 13px; color: #333; }\n .jdf-calc-warning-summary { margin: 0 0 12px 0; font-weight: 600; }\n .jdf-calc-warning-table { width: 100%; border-collapse: collapse; font-size: 13px; font-family: inherit; }\n .jdf-calc-warning-table tr:not(:last-child) td { border-bottom: 1px solid #f0f0f0; }\n .jdf-calc-warning-table td { padding: 6px 4px; vertical-align: top; }\n .jdf-calc-warning-sign { font-weight: 600; white-space: nowrap; }\n .jdf-calc-warning-sign.added { color: #2e7d32; }\n .jdf-calc-warning-sign.subtracted { color: #c62828; }\n ",document.head.appendChild(e)}_openCalculationWarningDialog(e,t){var i;e.stopPropagation(),this._ensureCalcWarningDialogStyles();const o=t.children.map(e=>`\n <tr>\n <td>${this._escapeHtml(e.label)}</td>\n <td>${this._escapeHtml(String(e.value))}</td>\n <td>${this._escapeHtml(e.balance||"—")}</td>\n <td class="jdf-calc-warning-sign ${1===e.weight?"added":"subtracted"}">\n ${this._escapeHtml(1===e.weight?k.t("calculationWarning.added"):k.t("calculationWarning.subtracted"))}\n </td>\n </tr>\n `).join(""),r=document.createElement("dialog");r.className="jdf-calc-warning-dialog",r.innerHTML=`\n <div class="jdf-calc-warning-header">\n <h3 class="jdf-calc-warning-title">⚠️ ${this._escapeHtml(k.t("calculationWarning.title"))}</h3>\n <button class="jdf-calc-warning-close-btn" type="button" aria-label="${this._escapeHtml(k.t("conceptInfo.close"))}">×</button>\n </div>\n <div class="jdf-calc-warning-body">\n <p class="jdf-calc-warning-summary">${this._escapeHtml(t.message)}</p>\n <table class="jdf-calc-warning-table">${o}</table>\n </div>\n `,document.body.appendChild(r),null==(i=r.querySelector(".jdf-calc-warning-close-btn"))||i.addEventListener("click",()=>r.close()),r.addEventListener("click",e=>{const t=r.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&r.close()}),r.addEventListener("close",()=>document.body.removeChild(r)),r.showModal()}render(){const t=this.concept.children&&this.concept.children.length>0,i=this.concept.level||0,o=this.concept.abstract||!1;return e.html`
|
|
770
|
+
`,De([w({type:Object})],exports.JupiterFormField.prototype,"field",2),De([w({type:String})],exports.JupiterFormField.prototype,"conceptId",2),De([w({type:String})],exports.JupiterFormField.prototype,"conceptType",2),De([w({type:Array})],exports.JupiterFormField.prototype,"datatypes",2),De([w({type:Array})],exports.JupiterFormField.prototype,"defaultUnits",2),De([w({type:String})],exports.JupiterFormField.prototype,"columnId",2),De([w()],exports.JupiterFormField.prototype,"value",2),De([w({type:Boolean})],exports.JupiterFormField.prototype,"disabled",2),De([w({type:String})],exports.JupiterFormField.prototype,"locale",2),De([w({type:Boolean})],exports.JupiterFormField.prototype,"hideLabel",2),De([w({type:String})],exports.JupiterFormField.prototype,"mode",2),De([w({type:Object})],exports.JupiterFormField.prototype,"masterData",2),De([w({type:Array})],exports.JupiterFormField.prototype,"facts",2),De([w({type:Object})],exports.JupiterFormField.prototype,"column",2),De([w({type:String})],exports.JupiterFormField.prototype,"periodStartDate",2),De([w({type:String})],exports.JupiterFormField.prototype,"periodEndDate",2),De([w({type:String})],exports.JupiterFormField.prototype,"periodInstantDate",2),De([w({type:String})],exports.JupiterFormField.prototype,"unit",2),De([w({type:String})],exports.JupiterFormField.prototype,"decimals",2),De([w({type:String})],exports.JupiterFormField.prototype,"globalDecimals",2),De([w({type:Object})],exports.JupiterFormField.prototype,"typedMemberValues",2),De([S()],exports.JupiterFormField.prototype,"_errors",2),De([S()],exports.JupiterFormField.prototype,"_xbrlErrors",2),De([S()],exports.JupiterFormField.prototype,"_touched",2),De([S()],exports.JupiterFormField.prototype,"_showPeriodPopup",2),De([S()],exports.JupiterFormField.prototype,"_availableUnits",2),De([S()],exports.JupiterFormField.prototype,"_numericDraftValue",2),exports.JupiterFormField=De([t("jupiter-form-field")],exports.JupiterFormField);var Ie=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,we=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?$e(t,i):t,a=e.length-1;a>=0;a--)(r=e[a])&&(n=(o?r(t,i,n):r(n))||n);return o&&n&&Ie(t,i,n),n};exports.JupiterConceptTree=class extends e.LitElement{constructor(){super(...arguments),this.columns=[],this.formData={},this.periodData={},this.unitData={},this.decimalsData={},this.globalDecimals="INF",this.defaultUnits=[],this.disabled=!1,this.locale="en-US",this.expandedConcepts=new Set,this.mode="inputForm",this.typedMemberData={},this.showAddButton=!1,this.showRemoveButton=!1,this.language="en",this.rowFocused=!1,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}))}_handleAddRepeat(){this.dispatchEvent(new CustomEvent("add-concept-repeat",{detail:{conceptId:this.concept.id},bubbles:!0,composed:!0}))}_handleRemoveRepeat(){this.dispatchEvent(new CustomEvent("remove-concept-repeat",{detail:{conceptId:this.concept.id},bubbles:!0,composed:!0}))}_handleFieldFocus(e){e.stopPropagation(),this.dispatchEvent(new CustomEvent("field-focus",{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")}_getDocLabel(){const e=this.concept.conceptMetadata;if(!e)return"";const t=this.language||this.locale.split("-")[0];return e.documentationLabels[t]||e.documentationLabels.en||e.documentationLabels.nl||""}_escapeHtml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}_ensureDialogStyles(){if(document.getElementById("jdf-concept-info-dialog-styles"))return;const e=document.createElement("style");e.id="jdf-concept-info-dialog-styles",e.textContent="\n dialog.jdf-concept-info-dialog {\n border: none; border-radius: 8px; padding: 0;\n max-width: 480px; width: 90vw;\n box-shadow: 0 8px 32px rgba(0,0,0,0.2); overflow: hidden;\n }\n dialog.jdf-concept-info-dialog::backdrop { background: rgba(0,0,0,0.35); }\n .jdf-dialog-header {\n background: #f0f2f5; padding: 14px 20px;\n display: flex; align-items: center; justify-content: space-between;\n border-bottom: 1px solid #ddd;\n }\n .jdf-dialog-title { font-size: 15px; font-weight: 600; color: #333; margin: 0; font-family: inherit; }\n .jdf-dialog-close-btn {\n width: 28px; height: 28px; border: none; background: transparent;\n font-size: 20px; line-height: 1; cursor: pointer; color: #666;\n border-radius: 4px; display: flex; align-items: center; justify-content: center;\n padding: 0; font-family: inherit;\n }\n .jdf-dialog-close-btn:hover { background: #ddd; color: #333; }\n .jdf-dialog-body { padding: 20px; }\n .jdf-info-table { width: 100%; border-collapse: collapse; font-size: 14px; font-family: inherit; }\n .jdf-info-table tr:not(:last-child) td { border-bottom: 1px solid #f0f0f0; }\n .jdf-info-table td { padding: 9px 4px; vertical-align: top; }\n .jdf-info-label { font-weight: 600; color: #666; width: 40%; white-space: nowrap; padding-right: 16px; }\n .jdf-info-value { color: #333; word-break: break-all; }\n .jdf-info-value.doc-text { font-style: italic; color: #555; line-height: 1.5; word-break: normal; }\n .jdf-period-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }\n .jdf-period-pill.instant { background: rgba(25,118,210,0.1); color: #1565c0; border: 1px solid rgba(25,118,210,0.3); }\n .jdf-period-pill.duration { background: rgba(56,142,60,0.1); color: #2e7d32; border: 1px solid rgba(56,142,60,0.3); }\n .jdf-balance-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; text-transform: capitalize; }\n .jdf-balance-pill.debit { background: rgba(211,47,47,0.1); color: #c62828; border: 1px solid rgba(211,47,47,0.3); }\n .jdf-balance-pill.credit { background: rgba(56,142,60,0.1); color: #2e7d32; border: 1px solid rgba(56,142,60,0.3); }\n ",document.head.appendChild(e)}_openInfoDialog(e){var t;e.stopPropagation(),this._ensureDialogStyles();const i=this.concept.conceptMetadata,o=this._getDocLabel(),r=(null==i?void 0:i.periodType)||this.concept.periodType,n=(null==i?void 0:i.balance)||this.concept.balance,a="instant"===r?T.t("conceptInfo.instant"):T.t("conceptInfo.duration"),s=[{label:T.t("conceptInfo.conceptName"),valueHtml:this._escapeHtml((null==i?void 0:i.conceptName)||this.concept.name)},{label:T.t("conceptInfo.type"),valueHtml:this._escapeHtml((null==i?void 0:i.type)||this.concept.type||"—")}];(null==i?void 0:i.substitutionGroup)&&s.push({label:T.t("conceptInfo.substitutionGroup"),valueHtml:this._escapeHtml(i.substitutionGroup)}),s.push({label:T.t("conceptInfo.periodType"),valueHtml:`<span class="jdf-period-pill ${r}">${this._escapeHtml(a)}</span>`}),n&&s.push({label:T.t("conceptInfo.balance"),valueHtml:`<span class="jdf-balance-pill ${n}">${this._escapeHtml(n)}</span>`}),o&&s.push({label:T.t("conceptInfo.documentation"),valueHtml:this._escapeHtml(o),isDoc:!0});const l=s.map(e=>`\n <tr>\n <td class="jdf-info-label">${this._escapeHtml(e.label)}</td>\n <td class="jdf-info-value${e.isDoc?" doc-text":""}">${e.valueHtml}</td>\n </tr>\n `).join(""),d=document.createElement("dialog");d.className="jdf-concept-info-dialog",d.innerHTML=`\n <div class="jdf-dialog-header">\n <h3 class="jdf-dialog-title">${this._escapeHtml(T.t("conceptInfo.title"))}</h3>\n <button class="jdf-dialog-close-btn" type="button" aria-label="${this._escapeHtml(T.t("conceptInfo.close"))}">×</button>\n </div>\n <div class="jdf-dialog-body">\n <table class="jdf-info-table">${l}</table>\n </div>\n `,document.body.appendChild(d),null==(t=d.querySelector(".jdf-dialog-close-btn"))||t.addEventListener("click",()=>d.close()),d.addEventListener("click",e=>{const t=d.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&d.close()}),d.addEventListener("close",()=>document.body.removeChild(d)),d.showModal()}_ensureCalcWarningDialogStyles(){if(document.getElementById("jdf-calc-warning-dialog-styles"))return;const e=document.createElement("style");e.id="jdf-calc-warning-dialog-styles",e.textContent="\n dialog.jdf-calc-warning-dialog {\n border: none; border-radius: 8px; padding: 0;\n max-width: 480px; width: 90vw;\n box-shadow: 0 8px 32px rgba(0,0,0,0.2); overflow: hidden;\n }\n dialog.jdf-calc-warning-dialog::backdrop { background: rgba(0,0,0,0.35); }\n .jdf-calc-warning-header {\n background: #fff3e0; padding: 14px 20px;\n display: flex; align-items: center; justify-content: space-between;\n border-bottom: 1px solid #ffcc80;\n }\n .jdf-calc-warning-title { font-size: 15px; font-weight: 600; color: #e65100; margin: 0; font-family: inherit; }\n .jdf-calc-warning-close-btn {\n width: 28px; height: 28px; border: none; background: transparent;\n font-size: 20px; line-height: 1; cursor: pointer; color: #666;\n border-radius: 4px; display: flex; align-items: center; justify-content: center;\n padding: 0; font-family: inherit;\n }\n .jdf-calc-warning-close-btn:hover { background: #ffe0b2; color: #e65100; }\n .jdf-calc-warning-body { padding: 20px; font-family: inherit; font-size: 13px; color: #333; }\n .jdf-calc-warning-summary { margin: 0 0 12px 0; font-weight: 600; }\n .jdf-calc-warning-table { width: 100%; border-collapse: collapse; font-size: 13px; font-family: inherit; }\n .jdf-calc-warning-table tr:not(:last-child) td { border-bottom: 1px solid #f0f0f0; }\n .jdf-calc-warning-table td { padding: 6px 4px; vertical-align: top; }\n .jdf-calc-warning-sign { font-weight: 600; white-space: nowrap; }\n .jdf-calc-warning-sign.added { color: #2e7d32; }\n .jdf-calc-warning-sign.subtracted { color: #c62828; }\n ",document.head.appendChild(e)}_openCalculationWarningDialog(e,t){var i;e.stopPropagation(),this._ensureCalcWarningDialogStyles();const o=t.children.map(e=>`\n <tr>\n <td>${this._escapeHtml(e.label)}</td>\n <td>${this._escapeHtml(String(e.value))}</td>\n <td>${this._escapeHtml(e.balance||"—")}</td>\n <td class="jdf-calc-warning-sign ${1===e.weight?"added":"subtracted"}">\n ${this._escapeHtml(1===e.weight?T.t("calculationWarning.added"):T.t("calculationWarning.subtracted"))}\n </td>\n </tr>\n `).join(""),r=document.createElement("dialog");r.className="jdf-calc-warning-dialog",r.innerHTML=`\n <div class="jdf-calc-warning-header">\n <h3 class="jdf-calc-warning-title">⚠️ ${this._escapeHtml(T.t("calculationWarning.title"))}</h3>\n <button class="jdf-calc-warning-close-btn" type="button" aria-label="${this._escapeHtml(T.t("conceptInfo.close"))}">×</button>\n </div>\n <div class="jdf-calc-warning-body">\n <p class="jdf-calc-warning-summary">${this._escapeHtml(t.message)}</p>\n <table class="jdf-calc-warning-table">${o}</table>\n </div>\n `,document.body.appendChild(r),null==(i=r.querySelector(".jdf-calc-warning-close-btn"))||i.addEventListener("click",()=>r.close()),r.addEventListener("click",e=>{const t=r.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&r.close()}),r.addEventListener("close",()=>document.body.removeChild(r)),r.showModal()}render(){const t=this.concept.children&&this.concept.children.length>0,i=this.concept.level||0,o=this.concept.abstract||!1,r=E(this.concept.preferredLabel);return e.html`
|
|
770
771
|
<!-- Concept Name Cell (Left Column) -->
|
|
771
772
|
<td class="concept-name-cell ${o?"abstract":t?"":"leaf"} ${this.rowFocused?"row-focused":""}">
|
|
772
773
|
<div class="concept-content" style="--level: ${i}">
|
|
@@ -775,7 +776,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
775
776
|
@click="${this._toggleExpanded}">
|
|
776
777
|
${t?"▶":""}
|
|
777
778
|
</div>
|
|
778
|
-
<div class="concept-label"
|
|
779
|
+
<div class="concept-label ${r?"total-concept-label":""}"
|
|
779
780
|
@click="${this._toggleExpanded}"
|
|
780
781
|
title="${this.concept.id}${this.concept.description?" - "+this.concept.description:""}">
|
|
781
782
|
${this.concept.label}
|
|
@@ -783,45 +784,46 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
783
784
|
${this.concept.balance?e.html`
|
|
784
785
|
<div class="concept-balance ${this.concept.balance}">${this.concept.balance}</div>
|
|
785
786
|
`:""}
|
|
786
|
-
<button class="concept-info-btn" type="button" title="${
|
|
787
|
+
<button class="concept-info-btn" type="button" tabindex="-1" title="${T.t("conceptInfo.title")}"
|
|
787
788
|
@click="${this._openInfoDialog}">ℹ</button>
|
|
788
789
|
${this.showAddButton?e.html`
|
|
789
|
-
<button class="repeat-btn" type="button" title="Add row"
|
|
790
|
+
<button class="repeat-btn" type="button" tabindex="-1" title="Add row"
|
|
790
791
|
@click="${this._handleAddRepeat}">+</button>
|
|
791
792
|
`:""}
|
|
792
793
|
${this.showRemoveButton?e.html`
|
|
793
|
-
<button class="repeat-btn remove" type="button" title="Remove row"
|
|
794
|
+
<button class="repeat-btn remove" type="button" tabindex="-1" title="Remove row"
|
|
794
795
|
@click="${this._handleRemoveRepeat}">−</button>
|
|
795
796
|
`:""}
|
|
796
797
|
</div>
|
|
797
798
|
</td>
|
|
798
799
|
|
|
799
800
|
<!-- Input Field Cells (Period Columns) - Only for non-abstract concepts -->
|
|
800
|
-
${this.columns.map(t=>{var i,
|
|
801
|
-
<td class="field-cell ${
|
|
801
|
+
${this.columns.map(t=>{var i,n,a,s,l;if(t.hidden)return e.html`<td class="field-cell hidden-column"></td>`;const d=this._getFieldForColumn(t.id),c=!o&&d,p=null==(n=null==(i=this.unitData)?void 0:i[this.concept.id])?void 0:n[t.id],u=null==(s=null==(a=this.decimalsData)?void 0:a[this.concept.id])?void 0:s[t.id],h="readonly"!==this.mode?null==(l=this.calculationMismatches)?void 0:l.get(`${this.concept.id}__${t.id}`):void 0;return e.html`
|
|
802
|
+
<td class="field-cell ${c?"":"empty"} ${o?"abstract-row":""} ${r?"total-row":""} ${this.highlightType&&t.id===this.highlightColumnId?"highlight-"+this.highlightType:""} ${h?"calc-warning":""} ${this.rowFocused?"row-focused":""}">
|
|
802
803
|
${h?e.html`
|
|
803
804
|
<button
|
|
804
805
|
class="calc-warning-badge"
|
|
805
806
|
type="button"
|
|
807
|
+
tabindex="-1"
|
|
806
808
|
title="${h.message}"
|
|
807
809
|
@click="${e=>this._openCalculationWarningDialog(e,h)}"
|
|
808
810
|
>!</button>
|
|
809
811
|
`:""}
|
|
810
|
-
${
|
|
812
|
+
${c?e.html`
|
|
811
813
|
<jupiter-form-field
|
|
812
|
-
.field="${
|
|
814
|
+
.field="${d}"
|
|
813
815
|
.conceptId="${this.concept.id}"
|
|
814
816
|
.conceptType="${this.concept.type}"
|
|
815
817
|
.datatypes="${this.datatypes}"
|
|
816
818
|
.defaultUnits="${this.defaultUnits}"
|
|
817
819
|
.columnId="${t.id}"
|
|
818
|
-
.value="${this._getFieldValue(
|
|
819
|
-
.unit="${
|
|
820
|
-
.decimals="${
|
|
820
|
+
.value="${this._getFieldValue(d)}"
|
|
821
|
+
.unit="${p||""}"
|
|
822
|
+
.decimals="${u}"
|
|
821
823
|
.globalDecimals="${this.globalDecimals}"
|
|
822
|
-
.periodStartDate="${
|
|
823
|
-
.periodEndDate="${
|
|
824
|
-
.periodInstantDate="${
|
|
824
|
+
.periodStartDate="${d.periodStartDate||t.periodStartDate}"
|
|
825
|
+
.periodEndDate="${d.periodEndDate||t.periodEndDate}"
|
|
826
|
+
.periodInstantDate="${d.periodInstantDate||("instant"===d.periodType?d.periodEndDate||d.periodStartDate:void 0)}"
|
|
825
827
|
.disabled="${this.disabled}"
|
|
826
828
|
.locale="${this.locale}"
|
|
827
829
|
.hideLabel="${!0}"
|
|
@@ -915,6 +917,10 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
915
917
|
min-width: 0; /* Allows flex item to shrink below content size */
|
|
916
918
|
}
|
|
917
919
|
|
|
920
|
+
.concept-label.total-concept-label {
|
|
921
|
+
font-weight: 700;
|
|
922
|
+
}
|
|
923
|
+
|
|
918
924
|
.concept-balance {
|
|
919
925
|
margin-left: 8px;
|
|
920
926
|
font-size: 11px;
|
|
@@ -1006,6 +1012,10 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
1006
1012
|
color: #fff;
|
|
1007
1013
|
}
|
|
1008
1014
|
|
|
1015
|
+
.field-cell.total-row {
|
|
1016
|
+
background: var(--jupiter-total-cell-background, rgba(0, 0, 0, 0.045));
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1009
1019
|
.field-cell.highlight-total {
|
|
1010
1020
|
background: rgba(25, 118, 210, 0.15);
|
|
1011
1021
|
}
|
|
@@ -1110,17 +1120,17 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
1110
1120
|
animation: concept-row-highlight-pulse 10s ease-out forwards;
|
|
1111
1121
|
}
|
|
1112
1122
|
|
|
1113
|
-
`,
|
|
1123
|
+
`,we([w({type:Object})],exports.JupiterConceptTree.prototype,"concept",2),we([w({type:Array})],exports.JupiterConceptTree.prototype,"columns",2),we([w({type:Object})],exports.JupiterConceptTree.prototype,"formData",2),we([w({type:Object})],exports.JupiterConceptTree.prototype,"periodData",2),we([w({type:Object})],exports.JupiterConceptTree.prototype,"unitData",2),we([w({type:Object})],exports.JupiterConceptTree.prototype,"decimalsData",2),we([w({type:String})],exports.JupiterConceptTree.prototype,"globalDecimals",2),we([w({type:Array})],exports.JupiterConceptTree.prototype,"defaultUnits",2),we([w({type:Boolean})],exports.JupiterConceptTree.prototype,"disabled",2),we([w({type:String})],exports.JupiterConceptTree.prototype,"locale",2),we([w({type:Set})],exports.JupiterConceptTree.prototype,"expandedConcepts",2),we([w({type:Array})],exports.JupiterConceptTree.prototype,"datatypes",2),we([w({type:String})],exports.JupiterConceptTree.prototype,"mode",2),we([w({type:Object})],exports.JupiterConceptTree.prototype,"masterData",2),we([w({type:Array})],exports.JupiterConceptTree.prototype,"facts",2),we([w({type:Object})],exports.JupiterConceptTree.prototype,"typedMemberData",2),we([w({type:Boolean})],exports.JupiterConceptTree.prototype,"showAddButton",2),we([w({type:Boolean})],exports.JupiterConceptTree.prototype,"showRemoveButton",2),we([w({type:String})],exports.JupiterConceptTree.prototype,"highlightType",2),we([w({type:String})],exports.JupiterConceptTree.prototype,"highlightColumnId",2),we([w({type:Object})],exports.JupiterConceptTree.prototype,"calculationMismatches",2),we([w({type:String})],exports.JupiterConceptTree.prototype,"language",2),we([w({type:Boolean})],exports.JupiterConceptTree.prototype,"rowFocused",2),we([S()],exports.JupiterConceptTree.prototype,"_expanded",2),exports.JupiterConceptTree=we([t("jupiter-concept-tree")],exports.JupiterConceptTree);var Se=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,Fe=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?Ce(t,i):t,a=e.length-1;a>=0;a--)(r=e[a])&&(n=(o?r(t,i,n):r(n))||n);return o&&n&&Se(t,i,n),n};exports.JupiterAddColumnDialog=class extends e.LitElement{constructor(){super(...arguments),this.periodType="duration",this.open=!1,this.availableDimensions=[],this.periodStartDate="",this.periodEndDate="",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(){this._startDate=this.periodStartDate||"",this._endDate=this.periodEndDate||"",this._instantDate=this.periodEndDate||this.periodStartDate||"",this._selectedType="instant"===this.periodType?"instant":"duration",this._selectedDimensions.clear(),this._autoSelectSingleMemberDimensions(),this.requestUpdate()}_autoSelectSingleMemberDimensions(){this.availableDimensions.forEach(e=>{if(e.members&&e.members.length>0){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),console.log(`🎯 Auto-selected default member: ${e.axisLabel} -> ${t.label}`)}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),console.log(`🎯 Auto-selected typed dimension: ${e.axisLabel} (value will be entered in column header)`)}})}render(){if(!this.open)return e.html``;const t=this._isFormValid();return e.html`
|
|
1114
1124
|
<div class="dialog" @click="${e=>e.stopPropagation()}">
|
|
1115
1125
|
<div class="dialog-header">
|
|
1116
|
-
<h2 class="dialog-title">${
|
|
1126
|
+
<h2 class="dialog-title">${T.t("column.addColumn")}</h2>
|
|
1117
1127
|
|
|
1118
1128
|
</div>
|
|
1119
1129
|
|
|
1120
1130
|
<div class="dialog-content">
|
|
1121
1131
|
${"instant"===this.periodType?e.html`
|
|
1122
1132
|
<div class="form-group">
|
|
1123
|
-
<label class="form-label required">${
|
|
1133
|
+
<label class="form-label required">${T.t("column.instantDate")}</label>
|
|
1124
1134
|
<div class="date-wrapper">
|
|
1125
1135
|
<input
|
|
1126
1136
|
type="date"
|
|
@@ -1139,7 +1149,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
1139
1149
|
`:e.html`
|
|
1140
1150
|
<div class="form-group date-row">
|
|
1141
1151
|
<div class="date-field">
|
|
1142
|
-
<label class="form-label required">${
|
|
1152
|
+
<label class="form-label required">${T.t("column.startPeriodDate")}</label>
|
|
1143
1153
|
<div class="date-wrapper">
|
|
1144
1154
|
<input
|
|
1145
1155
|
type="date"
|
|
@@ -1156,7 +1166,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
1156
1166
|
</div>
|
|
1157
1167
|
</div>
|
|
1158
1168
|
<div class="date-field">
|
|
1159
|
-
<label class="form-label required">${
|
|
1169
|
+
<label class="form-label required">${T.t("column.endPeriodDate")}</label>
|
|
1160
1170
|
<div class="date-wrapper">
|
|
1161
1171
|
<input
|
|
1162
1172
|
type="date"
|
|
@@ -1178,8 +1188,8 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
1178
1188
|
<!-- Dimensions Section -->
|
|
1179
1189
|
${this.availableDimensions.length>0?e.html`
|
|
1180
1190
|
<div class="dimensions-section">
|
|
1181
|
-
<h3>${
|
|
1182
|
-
<p class="form-description">${
|
|
1191
|
+
<h3>${T.t("column.availableDimensions")}</h3>
|
|
1192
|
+
<p class="form-description">${T.t("column.dimensionsDescription")}</p>
|
|
1183
1193
|
|
|
1184
1194
|
${this.availableDimensions.map(t=>{const i=this._selectedDimensions.has(t.id),o=this._selectedDimensions.get(t.id),r=!(!t.typedMember||t.members&&0!==t.members.length);return e.html`
|
|
1185
1195
|
<div class="dimension-item">
|
|
@@ -1201,20 +1211,20 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
1201
1211
|
${r?e.html`
|
|
1202
1212
|
<!-- Typed Dimension Input -->
|
|
1203
1213
|
<div class="member-selection">
|
|
1204
|
-
<label>${
|
|
1214
|
+
<label>${T.t("column.enterValue")} ${t.conceptName}:</label>
|
|
1205
1215
|
<input
|
|
1206
1216
|
type="text"
|
|
1207
1217
|
class="typed-input"
|
|
1208
1218
|
.value="${(null==o?void 0:o.typedValue)||""}"
|
|
1209
1219
|
@input="${e=>this._handleTypedValueChange(t.id,e)}"
|
|
1210
|
-
placeholder="${
|
|
1220
|
+
placeholder="${T.t("column.enterValuePlaceholder")}"
|
|
1211
1221
|
/>
|
|
1212
1222
|
</div>
|
|
1213
1223
|
`:e.html`
|
|
1214
1224
|
<!-- Domain Members Selection -->
|
|
1215
1225
|
${t.members&&t.members.length>0?e.html`
|
|
1216
1226
|
<div class="member-selection">
|
|
1217
|
-
<label>${
|
|
1227
|
+
<label>${T.t("column.selectMember")}</label>
|
|
1218
1228
|
<div class="member-list">
|
|
1219
1229
|
${t.members.map(i=>e.html`
|
|
1220
1230
|
<div class="member-option">
|
|
@@ -1233,7 +1243,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
1233
1243
|
</div>
|
|
1234
1244
|
</div>
|
|
1235
1245
|
`:e.html`
|
|
1236
|
-
<p class="form-description">${
|
|
1246
|
+
<p class="form-description">${T.t("column.noMembersAvailable")}</p>
|
|
1237
1247
|
`}
|
|
1238
1248
|
`}
|
|
1239
1249
|
</div>
|
|
@@ -1246,14 +1256,14 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
1246
1256
|
|
|
1247
1257
|
<div class="dialog-actions">
|
|
1248
1258
|
<button class="btn btn-cancel" @click="${this._handleCancel}">
|
|
1249
|
-
${
|
|
1259
|
+
${T.t("column.cancel")}
|
|
1250
1260
|
</button>
|
|
1251
1261
|
<button
|
|
1252
1262
|
class="btn btn-primary"
|
|
1253
1263
|
?disabled="${!t}"
|
|
1254
1264
|
@click="${this._handleConfirm}"
|
|
1255
1265
|
>
|
|
1256
|
-
${
|
|
1266
|
+
${T.t("column.addColumn")}
|
|
1257
1267
|
</button>
|
|
1258
1268
|
</div>
|
|
1259
1269
|
</div>
|
|
@@ -1560,7 +1570,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
1560
1570
|
margin: 0 0 12px 0;
|
|
1561
1571
|
line-height: 1.4;
|
|
1562
1572
|
}
|
|
1563
|
-
`,G([S({type:String})],exports.JupiterAddColumnDialog.prototype,"periodType",2),G([S({type:Boolean})],exports.JupiterAddColumnDialog.prototype,"open",2),G([S({type:Array})],exports.JupiterAddColumnDialog.prototype,"availableDimensions",2),G([S({type:String})],exports.JupiterAddColumnDialog.prototype,"periodStartDate",2),G([S({type:String})],exports.JupiterAddColumnDialog.prototype,"periodEndDate",2),G([w()],exports.JupiterAddColumnDialog.prototype,"_startDate",2),G([w()],exports.JupiterAddColumnDialog.prototype,"_endDate",2),G([w()],exports.JupiterAddColumnDialog.prototype,"_instantDate",2),G([w()],exports.JupiterAddColumnDialog.prototype,"_selectedType",2),G([w()],exports.JupiterAddColumnDialog.prototype,"_selectedDimensions",2),exports.JupiterAddColumnDialog=G([t("jupiter-add-column-dialog")],exports.JupiterAddColumnDialog);var Q=Object.defineProperty,X=Object.getOwnPropertyDescriptor,Z=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?X(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.JupiterFormSection=class extends e.LitElement{constructor(){super(...arguments),this.columns=[],this.formData={},this.periodData={},this.unitData={},this.decimalsData={},this.globalDecimals="INF",this.typedMemberData={},this.repeatCounts={},this.defaultUnits=[],this.disabled=!1,this.collapsible=!0,this.locale="en-US",this.isFirstSection=!1,this.availableDimensions=[],this.hideHeader=!1,this.mode="inputForm",this.showFactsOnly=!1,this.periodStartDate="",this.periodEndDate="",this.language="en",this.calculationEnabled=!1,this._expanded=!0,this._showAddColumnDialog=!1,this._sectionPeriodType="duration",this._openMenuColumnId=null,this._insertAfterColumnId=null,this._boundFieldBlur=e=>{if(this._clearHighlights(),this._focusedConceptId=null,"readonly"===this.mode||!this.calculationEnabled)return;const t=e.detail;(null==t?void 0:t.conceptId)&&(null==t?void 0:t.columnId)&&this._runCalculationCheck(t.conceptId,t.columnId)},this._expandedConcepts=new Set,this._allTreeExpanded=!1,this._highlightMap=new Map,this._focusedConceptId=null,this._calculationMismatches=new Map,this._totalChildrenMap=new Map,this._memberParentMap=new Map,this._totalConceptMap=new Map,this._totalChildConceptsMap=new Map}connectedCallback(){super.connectedCallback(),this._expanded=!1!==this.section.expanded,this._determinePeriodType(),this._checkAndExpandFirstSection(),document.addEventListener("click",()=>this._closeColumnMenu()),this.addEventListener("field-blur",this._boundFieldBlur)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",()=>this._closeColumnMenu()),this.removeEventListener("field-blur",this._boundFieldBlur)}updated(e){var t;super.updated(e),(e.has("isFirstSection")||e.has("section"))&&this._checkAndExpandFirstSection(),(e.has("section")||e.has("calculationEnabled"))&&(this.calculationEnabled&&(null==(t=this.section)?void 0:t.concepts)?this._buildTotalMaps(this.section.concepts):this._clearCalculationState())}_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}))}_handleHideColumn(e){this._openMenuColumnId=null,this.dispatchEvent(new CustomEvent("column-hide",{detail:{columnId:e,sectionId:this.section.id},bubbles:!0}))}_handleShowColumn(e){this.dispatchEvent(new CustomEvent("column-show",{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}_isConceptRowBlank(e){var t;for(const i of this.columns){const o=null==(t=this.formData[e.id])?void 0:t[i.id];if(null!=o&&""!==o)return!1}return!0}_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(){const e=this._getAllConceptIds(this.section.concepts||[]);this._expandedConcepts=new Set([...this._expandedConcepts,...e]),this._allTreeExpanded=!0}_collapseAllTrees(){this._expandedConcepts=new Set,this._allTreeExpanded=!1}_handleConceptExpand(e){e.stopPropagation();const{conceptId:t,expanded:i}=e.detail,o=new Set(this._expandedConcepts);i?o.add(t):o.delete(t),this._expandedConcepts=o;const r=this._getAllConceptIds(this.section.concepts||[]);this._allTreeExpanded=r.length>0&&r.every(e=>o.has(e)),this.dispatchEvent(new CustomEvent("concept-expand",{detail:e.detail,bubbles:!0}))}_buildTotalMaps(e){this._totalChildrenMap.clear(),this._memberParentMap.clear(),this._totalConceptMap.clear(),this._totalChildConceptsMap.clear(),this._traverseTotalGroups(e)}_clearCalculationState(){this._totalChildrenMap.clear(),this._memberParentMap.clear(),this._totalConceptMap.clear(),this._totalChildConceptsMap.clear();for(const e of Array.from(this._calculationMismatches.keys()))this._clearCalculationMismatch(e)}static _isTotalLabel(e){return!!(null==e?void 0:e.toLowerCase().includes("totallabel"))}static _isNegatedTotalLabel(e){return!!(null==e?void 0:e.toLowerCase().includes("negatedtotallabel"))}static _resolveValueConcept(e,t=0){var i;if(!e.abstract)return e;if(t>5||!(null==(i=e.children)?void 0:i.length))return null;const o=e.children.find(e=>exports.JupiterFormSection._isTotalLabel(e.preferredLabel));return o?exports.JupiterFormSection._resolveValueConcept(o,t+1):null}_registerTotalGroup(e,t){const i=t.map(e=>exports.JupiterFormSection._resolveValueConcept(e)).filter(e=>null!==e);if(0===i.length)return;const o=i.map(e=>e.id);this._totalChildrenMap.set(e.id,o),this._totalConceptMap.set(e.id,e),this._totalChildConceptsMap.set(e.id,i);for(const r of o)this._memberParentMap.set(r,e.id)}_resolveTotalGroupMembers(e,t,i,o){if(i<0)return o;const r=e[t];if(exports.JupiterFormSection._isNegatedTotalLabel(r.preferredLabel))return o.length>0?o:[e[i]];if(o.length>0)return[e[i],...o];if(exports.JupiterFormSection._isNegatedTotalLabel(e[i].preferredLabel)){let t=-1;for(let o=i-1;o>=0;o--)if(exports.JupiterFormSection._isTotalLabel(e[o].preferredLabel)){t=o;break}return t>=0?[e[t],e[i]]:[e[i]]}return[e[i]]}_traverseTotalGroups(e){var t,i;for(let o=0;o<e.length;o++){const r=e[o];if(exports.JupiterFormSection._isTotalLabel(r.preferredLabel))if(null==(t=r.children)?void 0:t.length)this._registerTotalGroup(r,r.children);else{let t=-1;for(let r=o-1;r>=0;r--)if(exports.JupiterFormSection._isTotalLabel(e[r].preferredLabel)){t=r;break}const i=e.slice(t+1,o),n=this._resolveTotalGroupMembers(e,o,t,i);n.length>0&&this._registerTotalGroup(r,n)}(null==(i=r.children)?void 0:i.length)&&this._traverseTotalGroups(r.children)}}_runCalculationCheck(e,t){const i=new Set;this._totalConceptMap.has(e)&&i.add(e);const o=this._memberParentMap.get(e);o&&i.add(o);for(const r of i)this._evaluateTotal(r,t)}_evaluateTotal(e,t){var i;const o=this._totalConceptMap.get(e),r=null==(i=this.formData[e])?void 0:i[t],n=`${e}__${t}`;if(null==r||""===r)return void this._clearCalculationMismatch(n);const s=parseFloat(r);if(isNaN(s))return void this._clearCalculationMismatch(n);const l=this._totalChildConceptsMap.get(e)||[],{calculatedSum:a,hasAnyValue:d,breakdown:c}=this._buildCalculationBreakdown(l,this.formData,t,o.balance);if(!d||exports.JupiterFormSection._checkTotal(s,a))return void this._clearCalculationMismatch(n);const p={totalConceptId:e,totalLabel:o.label,columnId:t,sectionId:this.section.id,enteredTotal:s,calculatedSum:a,children:c},h={...p,message:exports.JupiterFormSection._buildMismatchMessage(p)},u=new Map(this._calculationMismatches);u.set(n,h),this._calculationMismatches=u,this._dispatchCalculationMismatchChanged(n,h)}_clearCalculationMismatch(e){if(!this._calculationMismatches.has(e))return;const t=new Map(this._calculationMismatches);t.delete(e),this._calculationMismatches=t,this._dispatchCalculationMismatchChanged(e,null)}_dispatchCalculationMismatchChanged(e,t){this.dispatchEvent(new CustomEvent("calculation-mismatch-changed",{detail:{key:e,mismatch:t},bubbles:!0,composed:!0}))}static _resolveWeight(e,t){return e&&t&&e!==t?-1:1}_resolveMemberContributions(e,t,i,o,r,n=0){var s;const l=parseFloat(null==(s=i[e.id])?void 0:s[o]);if(!isNaN(l))return[{conceptId:e.id,label:e.label,value:l,balance:e.balance,weight:t}];if(n>=5||r.has(e.id))return[];const a=this._totalChildConceptsMap.get(e.id);if(!a)return[];const d=new Set(r).add(e.id),c=[];for(const p of a){const r=t*exports.JupiterFormSection._resolveWeight(e.balance,p.balance);c.push(...this._resolveMemberContributions(p,r,i,o,d,n+1))}return c}_buildCalculationBreakdown(e,t,i,o){let r=0,n=!1;const s=[];for(const l of e){const e=exports.JupiterFormSection._resolveWeight(o,l.balance),a=this._resolveMemberContributions(l,e,t,i,new Set);for(const t of a)r+=t.weight*t.value,n=!0,s.push(t)}return{calculatedSum:r,hasAnyValue:n,breakdown:s}}static _checkTotal(e,t){return Math.abs(t-e)<.01}static _formatNumber(e){return Number.isInteger(e)?String(e):e.toFixed(2)}static _buildMismatchMessage(e){const t=k.t("calculationWarning.summaryLine",{label:e.totalLabel,calculated:exports.JupiterFormSection._formatNumber(e.calculatedSum),entered:exports.JupiterFormSection._formatNumber(e.enteredTotal)});if(0===e.children.length)return t;const i=e.children.map(e=>k.t(1===e.weight?"calculationWarning.childAdded":"calculationWarning.childSubtracted",{label:e.label,value:exports.JupiterFormSection._formatNumber(e.value)}));return`${t} ${k.t("calculationWarning.childrenPrefix")} ${i.join("; ")}`}_handleFieldFocusForHighlight(e){var t,i;const o=null==(t=e.detail)?void 0:t.conceptId,r=null==(i=e.detail)?void 0:i.columnId;if(!o||!r)return;this._focusedConceptId=o;const n=new Map;if(this._totalChildrenMap.has(o)){n.set(o,{type:"total",columnId:r});for(const e of this._totalChildrenMap.get(o))n.set(e,{type:"member",columnId:r})}else{const e=this._memberParentMap.get(o);if(e){n.set(e,{type:"total",columnId:r});for(const t of this._totalChildrenMap.get(e))n.set(t,{type:"member",columnId:r})}}this._highlightMap=n}_clearHighlights(){this._highlightMap.size>0&&(this._highlightMap=new Map)}_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}))}_handleAddRepeat(e){e.stopPropagation(),this.dispatchEvent(new CustomEvent("add-concept-repeat",{detail:e.detail,bubbles:!0}))}_handleRemoveRepeat(e){e.stopPropagation(),this.dispatchEvent(new CustomEvent("remove-concept-repeat",{detail:e.detail,bubbles:!0}))}_renderConceptRows(t){var i;const o="readonly"!==this.mode&&!t.abstract&&(null==(i=t.fields)?void 0:i.some(e=>{var t;return(null==(t=e.crossRoleTypedMembers)?void 0:t.length)>0})),r=o&&this.repeatCounts[t.id]||0,n=(t,i)=>{var o,r;return e.html`
|
|
1573
|
+
`,Fe([w({type:String})],exports.JupiterAddColumnDialog.prototype,"periodType",2),Fe([w({type:Boolean})],exports.JupiterAddColumnDialog.prototype,"open",2),Fe([w({type:Array})],exports.JupiterAddColumnDialog.prototype,"availableDimensions",2),Fe([w({type:String})],exports.JupiterAddColumnDialog.prototype,"periodStartDate",2),Fe([w({type:String})],exports.JupiterAddColumnDialog.prototype,"periodEndDate",2),Fe([S()],exports.JupiterAddColumnDialog.prototype,"_startDate",2),Fe([S()],exports.JupiterAddColumnDialog.prototype,"_endDate",2),Fe([S()],exports.JupiterAddColumnDialog.prototype,"_instantDate",2),Fe([S()],exports.JupiterAddColumnDialog.prototype,"_selectedType",2),Fe([S()],exports.JupiterAddColumnDialog.prototype,"_selectedDimensions",2),exports.JupiterAddColumnDialog=Fe([t("jupiter-add-column-dialog")],exports.JupiterAddColumnDialog);var ke=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,Ee=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?Te(t,i):t,a=e.length-1;a>=0;a--)(r=e[a])&&(n=(o?r(t,i,n):r(n))||n);return o&&n&&ke(t,i,n),n};exports.JupiterFormSection=class extends e.LitElement{constructor(){super(...arguments),this.columns=[],this.formData={},this.periodData={},this.unitData={},this.decimalsData={},this.globalDecimals="INF",this.typedMemberData={},this.repeatCounts={},this.defaultUnits=[],this.disabled=!1,this.collapsible=!0,this.locale="en-US",this.isFirstSection=!1,this.availableDimensions=[],this.hideHeader=!1,this.mode="inputForm",this.showFactsOnly=!1,this.periodStartDate="",this.periodEndDate="",this.language="en",this.calculationEnabled=!1,this.totalManuallyEditedData={},this._expanded=!0,this._showAddColumnDialog=!1,this._sectionPeriodType="duration",this._openMenuColumnId=null,this._insertAfterColumnId=null,this._boundFieldBlur=e=>{if(this._clearHighlights(),this._focusedConceptId=null,"readonly"===this.mode||!this.calculationEnabled)return;const t=e.detail;(null==t?void 0:t.conceptId)&&(null==t?void 0:t.columnId)&&this._runCalculationCheck(t.conceptId,t.columnId)},this._expandedConcepts=new Set,this._allTreeExpanded=!1,this._highlightMap=new Map,this._focusedConceptId=null,this._calculationMismatches=new Map,this._totalChildrenMap=new Map,this._memberParentMap=new Map,this._totalConceptMap=new Map,this._totalChildConceptsMap=new Map,this._sessionManuallyEditedTotals=new Set}connectedCallback(){super.connectedCallback(),this._expanded=!1!==this.section.expanded,this._determinePeriodType(),this._checkAndExpandFirstSection(),document.addEventListener("click",()=>this._closeColumnMenu()),this.addEventListener("field-blur",this._boundFieldBlur)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",()=>this._closeColumnMenu()),this.removeEventListener("field-blur",this._boundFieldBlur)}updated(e){var t;super.updated(e),(e.has("isFirstSection")||e.has("section"))&&this._checkAndExpandFirstSection(),(e.has("section")||e.has("calculationEnabled"))&&(this.calculationEnabled&&(null==(t=this.section)?void 0:t.concepts)?this._buildTotalMaps(this.section.concepts):this._clearCalculationState()),e.has("totalManuallyEditedData")&&this._sessionManuallyEditedTotals.clear()}_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}))}_handleHideColumn(e){this._openMenuColumnId=null,this.dispatchEvent(new CustomEvent("column-hide",{detail:{columnId:e,sectionId:this.section.id},bubbles:!0}))}_handleShowColumn(e){this.dispatchEvent(new CustomEvent("column-show",{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();const{conceptId:t,columnId:i}=e.detail||{};t&&i&&this._totalConceptMap.has(t)&&(this._sessionManuallyEditedTotals.add(`${t}__${i}`),this.dispatchEvent(new CustomEvent("total-manually-edited",{detail:{conceptId:t,columnId:i},bubbles:!0,composed:!0}))),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}_isTotalManuallyEdited(e,t){var i,o;const r=`${e}__${t}`;return!!this._sessionManuallyEditedTotals.has(r)||!0===(null==(o=null==(i=this.totalManuallyEditedData)?void 0:i[e])?void 0:o[t])}_isConceptRowBlank(e){var t;for(const i of this.columns){const o=null==(t=this.formData[e.id])?void 0:t[i.id];if(null!=o&&""!==o)return!1}return!0}_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(){const e=this._getAllConceptIds(this.section.concepts||[]);this._expandedConcepts=new Set([...this._expandedConcepts,...e]),this._allTreeExpanded=!0}_collapseAllTrees(){this._expandedConcepts=new Set,this._allTreeExpanded=!1}_handleConceptExpand(e){e.stopPropagation();const{conceptId:t,expanded:i}=e.detail,o=new Set(this._expandedConcepts);i?o.add(t):o.delete(t),this._expandedConcepts=o;const r=this._getAllConceptIds(this.section.concepts||[]);this._allTreeExpanded=r.length>0&&r.every(e=>o.has(e)),this.dispatchEvent(new CustomEvent("concept-expand",{detail:e.detail,bubbles:!0}))}_buildTotalMaps(e){this._totalChildrenMap.clear(),this._memberParentMap.clear(),this._totalConceptMap.clear(),this._totalChildConceptsMap.clear(),this._traverseTotalGroups(e)}_clearCalculationState(){this._totalChildrenMap.clear(),this._memberParentMap.clear(),this._totalConceptMap.clear(),this._totalChildConceptsMap.clear();for(const e of Array.from(this._calculationMismatches.keys()))this._clearCalculationMismatch(e)}static _isTotalLabel(e){return E(e)}static _isNegatedTotalLabel(e){return!!(null==e?void 0:e.toLowerCase().includes("negatedtotallabel"))}static _resolveValueConcept(e,t=0){var i;if(!e.abstract)return e;if(t>5||!(null==(i=e.children)?void 0:i.length))return null;const o=e.children.find(e=>exports.JupiterFormSection._isTotalLabel(e.preferredLabel));return o?exports.JupiterFormSection._resolveValueConcept(o,t+1):null}_registerTotalGroup(e,t){const i=t.map(e=>exports.JupiterFormSection._resolveValueConcept(e)).filter(e=>null!==e);if(0===i.length)return;const o=i.map(e=>e.id);this._totalChildrenMap.set(e.id,o),this._totalConceptMap.set(e.id,e),this._totalChildConceptsMap.set(e.id,i);for(const r of o)this._memberParentMap.set(r,e.id)}_resolveTotalGroupMembers(e,t,i,o){if(i<0)return o;const r=e[t];if(exports.JupiterFormSection._isNegatedTotalLabel(r.preferredLabel))return o.length>0?o:[e[i]];if(o.length>0)return[e[i],...o];if(exports.JupiterFormSection._isNegatedTotalLabel(e[i].preferredLabel)){let t=-1;for(let o=i-1;o>=0;o--)if(exports.JupiterFormSection._isTotalLabel(e[o].preferredLabel)){t=o;break}return t>=0?[e[t],e[i]]:[e[i]]}return[e[i]]}_traverseTotalGroups(e){var t,i;for(let o=0;o<e.length;o++){const r=e[o];if(exports.JupiterFormSection._isTotalLabel(r.preferredLabel))if(null==(t=r.children)?void 0:t.length)this._registerTotalGroup(r,r.children);else{let t=-1;for(let r=o-1;r>=0;r--)if(exports.JupiterFormSection._isTotalLabel(e[r].preferredLabel)){t=r;break}const i=e.slice(t+1,o),n=this._resolveTotalGroupMembers(e,o,t,i);n.length>0&&this._registerTotalGroup(r,n)}(null==(i=r.children)?void 0:i.length)&&this._traverseTotalGroups(r.children)}}_runCalculationCheck(e,t){const i=new Set;this._totalConceptMap.has(e)&&i.add(e);const o=this._memberParentMap.get(e);o&&i.add(o);for(const r of i)this._evaluateTotal(r,t)}_evaluateTotal(e,t){var i,o;const r=this._totalConceptMap.get(e),n=`${e}__${t}`,a=this._totalChildConceptsMap.get(e)||[],{calculatedSum:s,hasAnyValue:l,breakdown:d}=this._buildCalculationBreakdown(a,this.formData,t,r.balance);if(!this._isTotalManuallyEdited(e,t)){if(l){const o=null==(i=this.formData[e])?void 0:i[t],r=parseFloat(o);(null==o||""===o||isNaN(r)||!exports.JupiterFormSection._checkTotal(r,s))&&this._dispatchCalculationTotalAutoPopulated(e,t,s)}return void this._clearCalculationMismatch(n)}const c=null==(o=this.formData[e])?void 0:o[t];if(null==c||""===c)return void this._clearCalculationMismatch(n);const p=parseFloat(c);if(isNaN(p))return void this._clearCalculationMismatch(n);if(!l||exports.JupiterFormSection._checkTotal(p,s))return void this._clearCalculationMismatch(n);const u={totalConceptId:e,totalLabel:r.label,columnId:t,sectionId:this.section.id,enteredTotal:p,calculatedSum:s,children:d},h={...u,message:exports.JupiterFormSection._buildMismatchMessage(u)},m=new Map(this._calculationMismatches);m.set(n,h),this._calculationMismatches=m,this._dispatchCalculationMismatchChanged(n,h)}_dispatchCalculationTotalAutoPopulated(e,t,i){this.dispatchEvent(new CustomEvent("calculation-total-auto-populated",{detail:{conceptId:e,columnId:t,value:i,sectionId:this.section.id},bubbles:!0,composed:!0}))}_clearCalculationMismatch(e){if(!this._calculationMismatches.has(e))return;const t=new Map(this._calculationMismatches);t.delete(e),this._calculationMismatches=t,this._dispatchCalculationMismatchChanged(e,null)}_dispatchCalculationMismatchChanged(e,t){this.dispatchEvent(new CustomEvent("calculation-mismatch-changed",{detail:{key:e,mismatch:t},bubbles:!0,composed:!0}))}static _resolveWeight(e,t){return e&&t&&e!==t?-1:1}_resolveMemberContributions(e,t,i,o,r,n=0){var a;const s=parseFloat(null==(a=i[e.id])?void 0:a[o]);if(!isNaN(s))return[{conceptId:e.id,label:e.label,value:s,balance:e.balance,weight:t}];if(n>=5||r.has(e.id))return[];const l=this._totalChildConceptsMap.get(e.id);if(!l)return[];const d=new Set(r).add(e.id),c=[];for(const p of l){const r=t*exports.JupiterFormSection._resolveWeight(e.balance,p.balance);c.push(...this._resolveMemberContributions(p,r,i,o,d,n+1))}return c}_buildCalculationBreakdown(e,t,i,o){let r=0,n=!1;const a=[];for(const s of e){const e=exports.JupiterFormSection._resolveWeight(o,s.balance),l=this._resolveMemberContributions(s,e,t,i,new Set);for(const t of l)r+=t.weight*t.value,n=!0,a.push(t)}return{calculatedSum:r,hasAnyValue:n,breakdown:a}}static _checkTotal(e,t){return Math.abs(t-e)<.01}static _formatNumber(e){return Number.isInteger(e)?String(e):e.toFixed(2)}static _buildMismatchMessage(e){const t=T.t("calculationWarning.summaryLine",{label:e.totalLabel,calculated:exports.JupiterFormSection._formatNumber(e.calculatedSum),entered:exports.JupiterFormSection._formatNumber(e.enteredTotal)});if(0===e.children.length)return t;const i=e.children.map(e=>T.t(1===e.weight?"calculationWarning.childAdded":"calculationWarning.childSubtracted",{label:e.label,value:exports.JupiterFormSection._formatNumber(e.value)}));return`${t} ${T.t("calculationWarning.childrenPrefix")} ${i.join("; ")}`}_handleFieldFocusForHighlight(e){var t,i;const o=null==(t=e.detail)?void 0:t.conceptId,r=null==(i=e.detail)?void 0:i.columnId;if(!o||!r)return;this._focusedConceptId=o;const n=new Map;if(this._totalChildrenMap.has(o)){n.set(o,{type:"total",columnId:r});for(const e of this._totalChildrenMap.get(o))n.set(e,{type:"member",columnId:r})}else{const e=this._memberParentMap.get(o);if(e){n.set(e,{type:"total",columnId:r});for(const t of this._totalChildrenMap.get(e))n.set(t,{type:"member",columnId:r})}}this._highlightMap=n}_clearHighlights(){this._highlightMap.size>0&&(this._highlightMap=new Map)}_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}))}_handleAddRepeat(e){e.stopPropagation(),this.dispatchEvent(new CustomEvent("add-concept-repeat",{detail:e.detail,bubbles:!0}))}_handleRemoveRepeat(e){e.stopPropagation(),this.dispatchEvent(new CustomEvent("remove-concept-repeat",{detail:e.detail,bubbles:!0}))}_renderConceptRows(t){var i;const o="readonly"!==this.mode&&!t.abstract&&(null==(i=t.fields)?void 0:i.some(e=>{var t;return(null==(t=e.crossRoleTypedMembers)?void 0:t.length)>0})),r=o&&this.repeatCounts[t.id]||0,n=(t,i)=>{var o,r;return e.html`
|
|
1564
1574
|
<jupiter-concept-tree
|
|
1565
1575
|
.concept="${t}"
|
|
1566
1576
|
.columns="${this.columns}"
|
|
@@ -1592,11 +1602,11 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
1592
1602
|
@add-concept-repeat="${this._handleAddRepeat}"
|
|
1593
1603
|
@remove-concept-repeat="${this._handleRemoveRepeat}"
|
|
1594
1604
|
></jupiter-concept-tree>
|
|
1595
|
-
`},
|
|
1605
|
+
`},a=[e.html`
|
|
1596
1606
|
<tr>${n(t,{showAdd:o})}</tr>
|
|
1597
|
-
`];for(let
|
|
1607
|
+
`];for(let s=1;s<=r;s++){const i={...t,id:`${t.id}__repeat_${s}`,label:"",children:[],abstract:!1};a.push(e.html`
|
|
1598
1608
|
<tr>${n(i,{showRemove:!0})}</tr>
|
|
1599
|
-
`)}return
|
|
1609
|
+
`)}return a}render(){return this.section.concepts&&0!==this.section.concepts.length?e.html`
|
|
1600
1610
|
${this.hideHeader?"":e.html`
|
|
1601
1611
|
<div class="section-header ${this.collapsible?"":"not-collapsible"}"
|
|
1602
1612
|
@click="${this._toggleExpanded}">
|
|
@@ -1623,7 +1633,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
1623
1633
|
${this.columns.map(t=>{var i,o,r;return t.hidden?e.html`
|
|
1624
1634
|
<th
|
|
1625
1635
|
class="header-cell hidden-column"
|
|
1626
|
-
title="${
|
|
1636
|
+
title="${T.t("column.showColumn")}"
|
|
1627
1637
|
@dblclick="${()=>this._handleShowColumn(t.id)}"
|
|
1628
1638
|
></th>
|
|
1629
1639
|
`:e.html`
|
|
@@ -1647,7 +1657,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
1647
1657
|
<input
|
|
1648
1658
|
type="text"
|
|
1649
1659
|
class="typed-member-header-field"
|
|
1650
|
-
placeholder="${
|
|
1660
|
+
placeholder="${T.t("section.enterPlaceholder")} ${i.axisLabel}"
|
|
1651
1661
|
.value="${this._getTypedMemberHeaderValue(t.id,i.axisId)}"
|
|
1652
1662
|
@input="${e=>this._handleTypedMemberHeaderChange(e,t.id,i.axisId)}"
|
|
1653
1663
|
/>
|
|
@@ -1663,7 +1673,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
1663
1673
|
<div
|
|
1664
1674
|
class="column-menu-icon"
|
|
1665
1675
|
@click="${e=>this._toggleColumnMenu(t.id,e)}"
|
|
1666
|
-
title="${
|
|
1676
|
+
title="${T.t("column.columnOptions")}"
|
|
1667
1677
|
>⋮</div>
|
|
1668
1678
|
|
|
1669
1679
|
<!-- Context menu -->
|
|
@@ -1673,14 +1683,14 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
1673
1683
|
class="column-context-menu-item"
|
|
1674
1684
|
@click="${e=>this._handleAddColumnFromMenu(t.id,e)}"
|
|
1675
1685
|
>
|
|
1676
|
-
${
|
|
1686
|
+
${T.t("column.addColumn")}
|
|
1677
1687
|
</button>
|
|
1678
1688
|
${t.removable?e.html`
|
|
1679
1689
|
<button
|
|
1680
1690
|
class="column-context-menu-item remove"
|
|
1681
1691
|
@click="${e=>{e.stopPropagation(),this._handleRemoveColumn(t.id)}}"
|
|
1682
1692
|
>
|
|
1683
|
-
${
|
|
1693
|
+
${T.t("column.removeColumn")}
|
|
1684
1694
|
</button>
|
|
1685
1695
|
`:""}
|
|
1686
1696
|
${!t.removable&&this.columns.filter(e=>!e.hidden).length>1?e.html`
|
|
@@ -1688,7 +1698,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
1688
1698
|
class="column-context-menu-item remove"
|
|
1689
1699
|
@click="${e=>{e.stopPropagation(),this._handleHideColumn(t.id)}}"
|
|
1690
1700
|
>
|
|
1691
|
-
${
|
|
1701
|
+
${T.t("column.hideColumn")}
|
|
1692
1702
|
</button>
|
|
1693
1703
|
`:""}
|
|
1694
1704
|
</div>
|
|
@@ -2017,7 +2027,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2017
2027
|
color: var(--jupiter-text-secondary, #666);
|
|
2018
2028
|
font-style: italic;
|
|
2019
2029
|
}
|
|
2020
|
-
`,
|
|
2030
|
+
`,Ee([w({type:Object})],exports.JupiterFormSection.prototype,"section",2),Ee([w({type:Array})],exports.JupiterFormSection.prototype,"columns",2),Ee([w({type:Array})],exports.JupiterFormSection.prototype,"datatypes",2),Ee([w({type:Object})],exports.JupiterFormSection.prototype,"formData",2),Ee([w({type:Object})],exports.JupiterFormSection.prototype,"periodData",2),Ee([w({type:Object})],exports.JupiterFormSection.prototype,"unitData",2),Ee([w({type:Object})],exports.JupiterFormSection.prototype,"decimalsData",2),Ee([w({type:String})],exports.JupiterFormSection.prototype,"globalDecimals",2),Ee([w({type:Object})],exports.JupiterFormSection.prototype,"typedMemberData",2),Ee([w({type:Object})],exports.JupiterFormSection.prototype,"repeatCounts",2),Ee([w({type:Array})],exports.JupiterFormSection.prototype,"defaultUnits",2),Ee([w({type:Boolean})],exports.JupiterFormSection.prototype,"disabled",2),Ee([w({type:Boolean})],exports.JupiterFormSection.prototype,"collapsible",2),Ee([w({type:String})],exports.JupiterFormSection.prototype,"locale",2),Ee([w({type:Boolean})],exports.JupiterFormSection.prototype,"isFirstSection",2),Ee([w({type:Array})],exports.JupiterFormSection.prototype,"availableDimensions",2),Ee([w({type:Boolean})],exports.JupiterFormSection.prototype,"hideHeader",2),Ee([w({type:String})],exports.JupiterFormSection.prototype,"mode",2),Ee([w({type:Boolean})],exports.JupiterFormSection.prototype,"showFactsOnly",2),Ee([w({type:Object})],exports.JupiterFormSection.prototype,"conceptMatchIds",2),Ee([w({type:Object})],exports.JupiterFormSection.prototype,"masterData",2),Ee([w({type:String})],exports.JupiterFormSection.prototype,"periodStartDate",2),Ee([w({type:String})],exports.JupiterFormSection.prototype,"periodEndDate",2),Ee([w({type:String})],exports.JupiterFormSection.prototype,"language",2),Ee([w({type:Boolean})],exports.JupiterFormSection.prototype,"calculationEnabled",2),Ee([w({type:Object})],exports.JupiterFormSection.prototype,"totalManuallyEditedData",2),Ee([S()],exports.JupiterFormSection.prototype,"_expanded",2),Ee([S()],exports.JupiterFormSection.prototype,"_showAddColumnDialog",2),Ee([S()],exports.JupiterFormSection.prototype,"_sectionPeriodType",2),Ee([S()],exports.JupiterFormSection.prototype,"_openMenuColumnId",2),Ee([S()],exports.JupiterFormSection.prototype,"_insertAfterColumnId",2),Ee([S()],exports.JupiterFormSection.prototype,"_expandedConcepts",2),Ee([S()],exports.JupiterFormSection.prototype,"_allTreeExpanded",2),Ee([S()],exports.JupiterFormSection.prototype,"_highlightMap",2),Ee([S()],exports.JupiterFormSection.prototype,"_focusedConceptId",2),Ee([S()],exports.JupiterFormSection.prototype,"_calculationMismatches",2),exports.JupiterFormSection=Ee([t("jupiter-form-section")],exports.JupiterFormSection);var Re=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,Ae=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?Me(t,i):t,a=e.length-1;a>=0;a--)(r=e[a])&&(n=(o?r(t,i,n):r(n))||n);return o&&n&&Re(t,i,n),n};exports.JupiterAdvancedFilter=class extends e.LitElement{constructor(){super(...arguments),this.showFactsOnly=!1,this.conceptSearchText="",this._localConceptSearchText=""}updated(e){e.has("conceptSearchText")&&this.conceptSearchText!==this._localConceptSearchText&&(this._localConceptSearchText=this.conceptSearchText)}_handleShowFactsOnlyChange(e){const t=e.target.checked;this.dispatchEvent(new CustomEvent("filter-change",{detail:{showFactsOnly:t,conceptSearchText:this._localConceptSearchText},bubbles:!0,composed:!0}))}_sanitizeSearchText(e){return e.replace(/[''‚‛′‵]/g,"'").replace(/[""„‟″‶]/g,'"').replace(/[]/g,"").replace(/\s+/g," ").trim()}_handleConceptSearchInput(e){this._localConceptSearchText=this._sanitizeSearchText(e.target.value),this.dispatchEvent(new CustomEvent("filter-change",{detail:{showFactsOnly:this.showFactsOnly,conceptSearchText:this._localConceptSearchText},bubbles:!0,composed:!0}))}_clearConceptSearch(){var e;this._localConceptSearchText="";const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".concept-search-input");t&&(t.value="",t.focus()),this.dispatchEvent(new CustomEvent("filter-change",{detail:{showFactsOnly:this.showFactsOnly,conceptSearchText:""},bubbles:!0,composed:!0}))}render(){return e.html`
|
|
2021
2031
|
<div class="filter-options">
|
|
2022
2032
|
<label class="filter-option clickable">
|
|
2023
2033
|
<input
|
|
@@ -2026,20 +2036,20 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2026
2036
|
@change="${this._handleShowFactsOnlyChange}"
|
|
2027
2037
|
/>
|
|
2028
2038
|
<div class="filter-option-body">
|
|
2029
|
-
<div class="filter-option-label">${
|
|
2030
|
-
<p class="filter-option-description">${
|
|
2039
|
+
<div class="filter-option-label">${T.t("filter.showFactsOnly")}</div>
|
|
2040
|
+
<p class="filter-option-description">${T.t("filter.showFactsOnlyDescription")}</p>
|
|
2031
2041
|
</div>
|
|
2032
2042
|
</label>
|
|
2033
2043
|
|
|
2034
2044
|
<div class="filter-option">
|
|
2035
2045
|
<div class="filter-option-body">
|
|
2036
|
-
<div class="filter-option-label">${
|
|
2037
|
-
<p class="filter-option-description">${
|
|
2046
|
+
<div class="filter-option-label">${T.t("filter.searchByConcept")}</div>
|
|
2047
|
+
<p class="filter-option-description">${T.t("filter.searchByConceptDescription")}</p>
|
|
2038
2048
|
<div class="concept-search-input-wrapper">
|
|
2039
2049
|
<input
|
|
2040
2050
|
type="text"
|
|
2041
2051
|
class="concept-search-input"
|
|
2042
|
-
placeholder="${
|
|
2052
|
+
placeholder="${T.t("filter.searchByConceptPlaceholder")}"
|
|
2043
2053
|
.value="${this._localConceptSearchText}"
|
|
2044
2054
|
@input="${this._handleConceptSearchInput}"
|
|
2045
2055
|
/>
|
|
@@ -2047,7 +2057,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2047
2057
|
<button
|
|
2048
2058
|
class="concept-search-clear"
|
|
2049
2059
|
@click="${this._clearConceptSearch}"
|
|
2050
|
-
title="${
|
|
2060
|
+
title="${T.t("filter.clearSearch")}"
|
|
2051
2061
|
>×</button>
|
|
2052
2062
|
`:""}
|
|
2053
2063
|
</div>
|
|
@@ -2153,14 +2163,14 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2153
2163
|
.concept-search-clear:hover {
|
|
2154
2164
|
color: var(--primaryTextColor, var(--jupiter-text-primary, #333));
|
|
2155
2165
|
}
|
|
2156
|
-
`,ie([S({type:Boolean})],exports.JupiterAdvancedFilter.prototype,"showFactsOnly",2),ie([S({type:String})],exports.JupiterAdvancedFilter.prototype,"conceptSearchText",2),ie([w()],exports.JupiterAdvancedFilter.prototype,"_localConceptSearchText",2),exports.JupiterAdvancedFilter=ie([t("jupiter-advanced-filter")],exports.JupiterAdvancedFilter);var oe=Object.defineProperty,re=Object.getOwnPropertyDescriptor,ne=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?re(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&&oe(t,i,n),n};let se=!1;exports.JupiterFilterRolesDialog=class extends e.LitElement{constructor(){super(...arguments),this.open=!1,this.availableRoles=[],this.selectedRoleIds=[],this.periodPreferences={},this.mode="inputForm",this.hypercubeData=null,this.showFactsOnly=!1,this.conceptSearchText="",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=[],this._showAdvancedFilter=!1,this._showFactsOnly=!1,this._conceptSearchText="",this._collapsedRoles=new Set}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(),e.has("open")&&this.open&&(this._showAdvancedFilter=se,this._showFactsOnly=this.showFactsOnly,this._conceptSearchText=this.conceptSearchText)}_updateFilteredRoles(){if(!this._searchQuery.trim())return void(this._filteredRoles=[...this.availableRoles]);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}_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}}const o=this._getDimensionsForRole(t.id);o.length>0&&!(null==i?void 0:i.dimensionSelections)&&(e[t.id].dimensionSelections||(e[t.id].dimensionSelections=[]),o.forEach(i=>{var o,r;const n=this._getAllDimensionMembers(i.members);if(n.length>0){const s=(null==(r=null==(o=i.labels)?void 0:o.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:r.label)||i.conceptName,l=n.map(e=>e.id),a={dimensionId:i.id,dimensionLabel:s,selectedMemberIds:l};e[t.id].dimensionSelections.push(a),console.log(`✅ Auto-selected all ${l.length} members for dimension: ${s}`)}}))}),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()}_enforceSingleMemberSelectionsForRole(e,t){const i=this._getDimensionsForRole(e);if(0===i.length)return t;const o={...t},r=o[e]?{...o[e]}:{showDuration:!0,showInstant:!0,showPreviousYear:!1,dimensionSelections:[]},n=r.dimensionSelections?[...r.dimensionSelections]:[];return i.forEach(e=>{var t,i;if(!this._isSingleMemberDimension(e))return;const o=this._getAllDimensionMembers(e.members);if(1!==o.length)return;const r=o[0].id,s=(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,l=n.findIndex(t=>t.dimensionId===e.id);-1!==l?n[l]={...n[l],dimensionLabel:s,selectedMemberIds:[r]}:n.push({dimensionId:e.id,dimensionLabel:s,selectedMemberIds:[r]})}),r.dimensionSelections=n,o[e]=r,o}_enforceSingleMemberSelectionsForSelectedRoles(e,t=this._tempSelectedRoles){let i={...e};for(const o of t)i=this._enforceSingleMemberSelectionsForRole(o,i);return i}_handleCheckboxChange(e,t){const i=e.target,o=new Set(this._tempSelectedRoles);let r={...this._tempPeriodPreferences};i.checked?(o.add(t),r=this._enforceSingleMemberSelectionsForRole(t,r)):o.delete(t),this._tempSelectedRoles=o,this._tempPeriodPreferences=r,this.requestUpdate()}_selectAll(){const e=new Set(this._tempSelectedRoles);this._filteredRoles.forEach(t=>e.add(t.id)),this._tempSelectedRoles=e,this._tempPeriodPreferences=this._enforceSingleMemberSelectionsForSelectedRoles(this._tempPeriodPreferences,e),this.requestUpdate()}_selectNone(){const e=new Set(this._tempSelectedRoles);this._filteredRoles.forEach(t=>e.delete(t.id)),this._tempSelectedRoles=e,this.requestUpdate()}_selectAllGlobal(){const e=new Set(this.availableRoles.map(e=>e.id));this._tempSelectedRoles=e,this._tempPeriodPreferences=this._enforceSingleMemberSelectionsForSelectedRoles(this._tempPeriodPreferences,e),this.requestUpdate()}_selectNoneGlobal(){this._tempSelectedRoles=new Set,this.requestUpdate()}_resetToOriginal(){this._tempSelectedRoles=new Set(this.selectedRoleIds),this._tempPeriodPreferences=this._enforceSingleMemberSelectionsForSelectedRoles(this._tempPeriodPreferences,this._tempSelectedRoles),this.requestUpdate()}_handleCancel(){this._initializeTempSelection(),this.dispatchEvent(new CustomEvent("dialog-cancel",{bubbles:!0}))}_handleApply(){const e=this._enforceSingleMemberSelectionsForSelectedRoles(this._tempPeriodPreferences,this._tempSelectedRoles);this._tempPeriodPreferences=e;const t=this._chosenRoleOrder.filter(e=>this._tempSelectedRoles.has(e)),i=Array.from(this._tempSelectedRoles).filter(e=>!this._chosenRoleOrder.includes(e));this._chosenRoleOrder=[...t,...i];const o=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:",o),console.log("📋 Order array:",this._chosenRoleOrder),console.log("📊 Dimension preferences being emitted:",e),this.dispatchEvent(new CustomEvent("roles-filter-apply",{detail:{selectedRoleIds:o,periodPreferences:e},bubbles:!0}))}_getDimensionsForRole(e){var t,i;if(console.log("🔍 [getDimensionsForRole] Called with roleId:",e),console.log("🔍 [getDimensionsForRole] hypercubeData exists:",!!this.hypercubeData),console.log("🔍 [getDimensionsForRole] hypercubeData type:",typeof this.hypercubeData),console.log("🔍 [getDimensionsForRole] hypercubeData value:",this.hypercubeData),!this.hypercubeData)return console.error("❌ [getDimensionsForRole] CRITICAL: hypercubeData is null/undefined/false"),console.error("❌ Parent component must pass hypercubeData property to filter dialog!"),console.error('❌ Example: <jupiter-filter-roles-dialog .hypercubeData="${hypercubeData}">'),[];let o=this.hypercubeData;if(Array.isArray(this.hypercubeData)&&this.hypercubeData.length>0&&(console.log("📦 [getDimensionsForRole] Detected array-wrapped format, unwrapping..."),o=this.hypercubeData[0]),console.log("🔍 [getDimensionsForRole] hypercubeDataObj.roles exists:",!!(null==o?void 0:o.roles)),!(null==o?void 0:o.roles))return console.warn("⚠️ [getDimensionsForRole] No roles found in hypercube data structure"),console.warn("⚠️ Expected structure: { roles: [...] } or [{ roles: [...] }]"),[];console.log("🔍 [getDimensionsForRole] Available hypercube roles:",o.roles.map(e=>e.roleId));const r=o.roles.find(t=>t.roleId===e);if(console.log("🔍 [getDimensionsForRole] Found hypercube role:",!!r),!(null==(t=null==r?void 0:r.items)?void 0:t.length))return console.warn("⚠️ [getDimensionsForRole] No items found in hypercube role for:",e),[];console.log("🔍 [getDimensionsForRole] Items count:",r.items.length);const n=(null==(i=r.items[0])?void 0:i.dimensions)||[];console.log("🔍 [getDimensionsForRole] Total dimensions found:",n.length),console.log("🔍 [getDimensionsForRole] Dimension details:",n.map(e=>{var t;return{id:e.id,type:e.dimensionType,hasMembers:!!(e.members&&e.members.length>0),membersCount:(null==(t=e.members)?void 0:t.length)||0}}));const s=n.filter(e=>"explicit"===e.dimensionType&&e.members&&Array.isArray(e.members)&&e.members.length>0);return console.log("✅ [getDimensionsForRole] Filtered dimensions count:",s.length),console.log("✅ [getDimensionsForRole] Filtered dimension IDs:",s.map(e=>e.id)),s}_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}_isSingleMemberDimension(e){return 1===this._getAllDimensionMembers(e.members).length}_handleDimensionMemberChange(e,t,i,o){var r,n;e.stopPropagation();const s=e.target,l={...this._tempPeriodPreferences};l[t]||(l[t]={showDuration:!0,showInstant:!0,showPreviousYear:!1,dimensionSelections:[]}),l[t].dimensionSelections||(l[t].dimensionSelections=[]);let a=l[t].dimensionSelections.find(e=>e.dimensionId===i);if(!a){const e=this._getDimensionsForRole(t).find(e=>e.id===i),o=(null==(n=null==(r=null==e?void 0:e.labels)?void 0:r.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:n.label)||i;a={dimensionId:i,dimensionLabel:o,selectedMemberIds:[]},l[t].dimensionSelections.push(a)}s.checked?a.selectedMemberIds.includes(o)||a.selectedMemberIds.push(o):a.selectedMemberIds=a.selectedMemberIds.filter(e=>e!==o);const d=this._getDimensionsForRole(t).find(e=>e.id===i);if(d&&this._tempSelectedRoles.has(t)&&this._isSingleMemberDimension(d)){const e=this._getAllDimensionMembers(d.members);1===e.length&&(a.selectedMemberIds=[e[0].id],s.checked=!0)}this._tempPeriodPreferences=l,console.log("📊 Updated dimension selections:",l[t].dimensionSelections),this.requestUpdate()}_isDimensionMemberSelected(e,t,i){const o=this._tempPeriodPreferences[e];if(!(null==o?void 0:o.dimensionSelections))return!1;const r=o.dimensionSelections.find(e=>e.dimensionId===t);return(null==r?void 0:r.selectedMemberIds.includes(i))||!1}_selectAllDimensionMembers(e,t){var i,o;const r=this._getDimensionsForRole(e).find(e=>e.id===t);if(!r)return;const n=this._getAllDimensionMembers(r.members).map(e=>e.id),s={...this._tempPeriodPreferences};s[e]||(s[e]={showDuration:!0,showInstant:!0,showPreviousYear:!1,dimensionSelections:[]}),s[e].dimensionSelections||(s[e].dimensionSelections=[]);let l=s[e].dimensionSelections.find(e=>e.dimensionId===t);if(!l){const n=(null==(o=null==(i=r.labels)?void 0:i.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:o.label)||t;l={dimensionId:t,dimensionLabel:n,selectedMemberIds:[]},s[e].dimensionSelections.push(l)}l.selectedMemberIds=n,this._tempPeriodPreferences=s,this.requestUpdate()}_deselectAllDimensionMembers(e,t){var i;const o={...this._tempPeriodPreferences};if(!(null==(i=o[e])?void 0:i.dimensionSelections))return;const r=o[e].dimensionSelections.find(e=>e.dimensionId===t);r&&(r.selectedMemberIds=[]),this._tempPeriodPreferences=o,this.requestUpdate()}_toggleRoleCollapse(e){const t=new Set(this._collapsedRoles);t.has(e)?t.delete(e):t.add(e),this._collapsedRoles=t}_switchToAdvancedFilter(){se=!0,this._showAdvancedFilter=!0,this._searchQuery=""}_switchToFilterRoles(){se=!1,this._showAdvancedFilter=!1}_handleFilterChange(e){this._showFactsOnly=e.detail.showFactsOnly,this._conceptSearchText=e.detail.conceptSearchText??""}_handleAdvancedFilterApply(){this.dispatchEvent(new CustomEvent("advanced-filter-apply",{detail:{showFactsOnly:this._showFactsOnly,conceptSearchText:this._conceptSearchText},bubbles:!0}))}_handleAdvancedFilterReset(){this._showFactsOnly=!1,this._conceptSearchText="",this.dispatchEvent(new CustomEvent("advanced-filter-apply",{detail:{showFactsOnly:!1,conceptSearchText:""},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._tempPeriodPreferences=this._enforceSingleMemberSelectionsForRole(this._selectedAvailableRole,this._tempPeriodPreferences),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._tempPeriodPreferences=this._enforceSingleMemberSelectionsForSelectedRoles(this._tempPeriodPreferences,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`
|
|
2166
|
+
`,Ae([w({type:Boolean})],exports.JupiterAdvancedFilter.prototype,"showFactsOnly",2),Ae([w({type:String})],exports.JupiterAdvancedFilter.prototype,"conceptSearchText",2),Ae([S()],exports.JupiterAdvancedFilter.prototype,"_localConceptSearchText",2),exports.JupiterAdvancedFilter=Ae([t("jupiter-advanced-filter")],exports.JupiterAdvancedFilter);var je=Object.defineProperty,Pe=Object.getOwnPropertyDescriptor,Le=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?Pe(t,i):t,a=e.length-1;a>=0;a--)(r=e[a])&&(n=(o?r(t,i,n):r(n))||n);return o&&n&&je(t,i,n),n};let Ne=!1;exports.JupiterFilterRolesDialog=class extends e.LitElement{constructor(){super(...arguments),this.open=!1,this.availableRoles=[],this.selectedRoleIds=[],this.periodPreferences={},this.mode="inputForm",this.hypercubeData=null,this.showFactsOnly=!1,this.conceptSearchText="",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=[],this._showAdvancedFilter=!1,this._showFactsOnly=!1,this._conceptSearchText="",this._collapsedRoles=new Set}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(),e.has("open")&&this.open&&(this._showAdvancedFilter=Ne,this._showFactsOnly=this.showFactsOnly,this._conceptSearchText=this.conceptSearchText)}_updateFilteredRoles(){if(!this._searchQuery.trim())return void(this._filteredRoles=[...this.availableRoles]);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,a=this._searchInRoleURI(t,e);return o||r||n||a});this._filteredRoles=t}_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}}const o=this._getDimensionsForRole(t.id);o.length>0&&!(null==i?void 0:i.dimensionSelections)&&(e[t.id].dimensionSelections||(e[t.id].dimensionSelections=[]),o.forEach(i=>{var o,r;const n=this._getAllDimensionMembers(i.members);if(n.length>0){const a=(null==(r=null==(o=i.labels)?void 0:o.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:r.label)||i.conceptName,s=n.map(e=>e.id),l={dimensionId:i.id,dimensionLabel:a,selectedMemberIds:s};e[t.id].dimensionSelections.push(l),console.log(`✅ Auto-selected all ${s.length} members for dimension: ${a}`)}}))}),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()}_enforceSingleMemberSelectionsForRole(e,t){const i=this._getDimensionsForRole(e);if(0===i.length)return t;const o={...t},r=o[e]?{...o[e]}:{showDuration:!0,showInstant:!0,showPreviousYear:!1,dimensionSelections:[]},n=r.dimensionSelections?[...r.dimensionSelections]:[];return i.forEach(e=>{var t,i;if(!this._isSingleMemberDimension(e))return;const o=this._getAllDimensionMembers(e.members);if(1!==o.length)return;const r=o[0].id,a=(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,s=n.findIndex(t=>t.dimensionId===e.id);-1!==s?n[s]={...n[s],dimensionLabel:a,selectedMemberIds:[r]}:n.push({dimensionId:e.id,dimensionLabel:a,selectedMemberIds:[r]})}),r.dimensionSelections=n,o[e]=r,o}_enforceSingleMemberSelectionsForSelectedRoles(e,t=this._tempSelectedRoles){let i={...e};for(const o of t)i=this._enforceSingleMemberSelectionsForRole(o,i);return i}_handleCheckboxChange(e,t){const i=e.target,o=new Set(this._tempSelectedRoles);let r={...this._tempPeriodPreferences};i.checked?(o.add(t),r=this._enforceSingleMemberSelectionsForRole(t,r)):o.delete(t),this._tempSelectedRoles=o,this._tempPeriodPreferences=r,this.requestUpdate()}_selectAll(){const e=new Set(this._tempSelectedRoles);this._filteredRoles.forEach(t=>e.add(t.id)),this._tempSelectedRoles=e,this._tempPeriodPreferences=this._enforceSingleMemberSelectionsForSelectedRoles(this._tempPeriodPreferences,e),this.requestUpdate()}_selectNone(){const e=new Set(this._tempSelectedRoles);this._filteredRoles.forEach(t=>e.delete(t.id)),this._tempSelectedRoles=e,this.requestUpdate()}_selectAllGlobal(){const e=new Set(this.availableRoles.map(e=>e.id));this._tempSelectedRoles=e,this._tempPeriodPreferences=this._enforceSingleMemberSelectionsForSelectedRoles(this._tempPeriodPreferences,e),this.requestUpdate()}_selectNoneGlobal(){this._tempSelectedRoles=new Set,this.requestUpdate()}_resetToOriginal(){this._tempSelectedRoles=new Set(this.selectedRoleIds),this._tempPeriodPreferences=this._enforceSingleMemberSelectionsForSelectedRoles(this._tempPeriodPreferences,this._tempSelectedRoles),this.requestUpdate()}_handleCancel(){this._initializeTempSelection(),this.dispatchEvent(new CustomEvent("dialog-cancel",{bubbles:!0}))}_handleApply(){const e=this._enforceSingleMemberSelectionsForSelectedRoles(this._tempPeriodPreferences,this._tempSelectedRoles);this._tempPeriodPreferences=e;const t=this._chosenRoleOrder.filter(e=>this._tempSelectedRoles.has(e)),i=Array.from(this._tempSelectedRoles).filter(e=>!this._chosenRoleOrder.includes(e));this._chosenRoleOrder=[...t,...i];const o=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:",o),console.log("📋 Order array:",this._chosenRoleOrder),console.log("📊 Dimension preferences being emitted:",e),this.dispatchEvent(new CustomEvent("roles-filter-apply",{detail:{selectedRoleIds:o,periodPreferences:e},bubbles:!0}))}_getDimensionsForRole(e){var t,i;if(console.log("🔍 [getDimensionsForRole] Called with roleId:",e),console.log("🔍 [getDimensionsForRole] hypercubeData exists:",!!this.hypercubeData),console.log("🔍 [getDimensionsForRole] hypercubeData type:",typeof this.hypercubeData),console.log("🔍 [getDimensionsForRole] hypercubeData value:",this.hypercubeData),!this.hypercubeData)return console.error("❌ [getDimensionsForRole] CRITICAL: hypercubeData is null/undefined/false"),console.error("❌ Parent component must pass hypercubeData property to filter dialog!"),console.error('❌ Example: <jupiter-filter-roles-dialog .hypercubeData="${hypercubeData}">'),[];let o=this.hypercubeData;if(Array.isArray(this.hypercubeData)&&this.hypercubeData.length>0&&(console.log("📦 [getDimensionsForRole] Detected array-wrapped format, unwrapping..."),o=this.hypercubeData[0]),console.log("🔍 [getDimensionsForRole] hypercubeDataObj.roles exists:",!!(null==o?void 0:o.roles)),!(null==o?void 0:o.roles))return console.warn("⚠️ [getDimensionsForRole] No roles found in hypercube data structure"),console.warn("⚠️ Expected structure: { roles: [...] } or [{ roles: [...] }]"),[];console.log("🔍 [getDimensionsForRole] Available hypercube roles:",o.roles.map(e=>e.roleId));const r=o.roles.find(t=>t.roleId===e);if(console.log("🔍 [getDimensionsForRole] Found hypercube role:",!!r),!(null==(t=null==r?void 0:r.items)?void 0:t.length))return console.warn("⚠️ [getDimensionsForRole] No items found in hypercube role for:",e),[];console.log("🔍 [getDimensionsForRole] Items count:",r.items.length);const n=(null==(i=r.items[0])?void 0:i.dimensions)||[];console.log("🔍 [getDimensionsForRole] Total dimensions found:",n.length),console.log("🔍 [getDimensionsForRole] Dimension details:",n.map(e=>{var t;return{id:e.id,type:e.dimensionType,hasMembers:!!(e.members&&e.members.length>0),membersCount:(null==(t=e.members)?void 0:t.length)||0}}));const a=n.filter(e=>"explicit"===e.dimensionType&&e.members&&Array.isArray(e.members)&&e.members.length>0);return console.log("✅ [getDimensionsForRole] Filtered dimensions count:",a.length),console.log("✅ [getDimensionsForRole] Filtered dimension IDs:",a.map(e=>e.id)),a}_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}_isSingleMemberDimension(e){return 1===this._getAllDimensionMembers(e.members).length}_handleDimensionMemberChange(e,t,i,o){var r,n;e.stopPropagation();const a=e.target,s={...this._tempPeriodPreferences};s[t]||(s[t]={showDuration:!0,showInstant:!0,showPreviousYear:!1,dimensionSelections:[]}),s[t].dimensionSelections||(s[t].dimensionSelections=[]);let l=s[t].dimensionSelections.find(e=>e.dimensionId===i);if(!l){const e=this._getDimensionsForRole(t).find(e=>e.id===i),o=(null==(n=null==(r=null==e?void 0:e.labels)?void 0:r.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:n.label)||i;l={dimensionId:i,dimensionLabel:o,selectedMemberIds:[]},s[t].dimensionSelections.push(l)}a.checked?l.selectedMemberIds.includes(o)||l.selectedMemberIds.push(o):l.selectedMemberIds=l.selectedMemberIds.filter(e=>e!==o);const d=this._getDimensionsForRole(t).find(e=>e.id===i);if(d&&this._tempSelectedRoles.has(t)&&this._isSingleMemberDimension(d)){const e=this._getAllDimensionMembers(d.members);1===e.length&&(l.selectedMemberIds=[e[0].id],a.checked=!0)}this._tempPeriodPreferences=s,console.log("📊 Updated dimension selections:",s[t].dimensionSelections),this.requestUpdate()}_isDimensionMemberSelected(e,t,i){const o=this._tempPeriodPreferences[e];if(!(null==o?void 0:o.dimensionSelections))return!1;const r=o.dimensionSelections.find(e=>e.dimensionId===t);return(null==r?void 0:r.selectedMemberIds.includes(i))||!1}_selectAllDimensionMembers(e,t){var i,o;const r=this._getDimensionsForRole(e).find(e=>e.id===t);if(!r)return;const n=this._getAllDimensionMembers(r.members).map(e=>e.id),a={...this._tempPeriodPreferences};a[e]||(a[e]={showDuration:!0,showInstant:!0,showPreviousYear:!1,dimensionSelections:[]}),a[e].dimensionSelections||(a[e].dimensionSelections=[]);let s=a[e].dimensionSelections.find(e=>e.dimensionId===t);if(!s){const n=(null==(o=null==(i=r.labels)?void 0:i.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:o.label)||t;s={dimensionId:t,dimensionLabel:n,selectedMemberIds:[]},a[e].dimensionSelections.push(s)}s.selectedMemberIds=n,this._tempPeriodPreferences=a,this.requestUpdate()}_deselectAllDimensionMembers(e,t){var i;const o={...this._tempPeriodPreferences};if(!(null==(i=o[e])?void 0:i.dimensionSelections))return;const r=o[e].dimensionSelections.find(e=>e.dimensionId===t);r&&(r.selectedMemberIds=[]),this._tempPeriodPreferences=o,this.requestUpdate()}_toggleRoleCollapse(e){const t=new Set(this._collapsedRoles);t.has(e)?t.delete(e):t.add(e),this._collapsedRoles=t}_switchToAdvancedFilter(){Ne=!0,this._showAdvancedFilter=!0,this._searchQuery=""}_switchToFilterRoles(){Ne=!1,this._showAdvancedFilter=!1}_handleFilterChange(e){this._showFactsOnly=e.detail.showFactsOnly,this._conceptSearchText=e.detail.conceptSearchText??""}_handleAdvancedFilterApply(){this.dispatchEvent(new CustomEvent("advanced-filter-apply",{detail:{showFactsOnly:this._showFactsOnly,conceptSearchText:this._conceptSearchText},bubbles:!0}))}_handleAdvancedFilterReset(){this._showFactsOnly=!1,this._conceptSearchText="",this.dispatchEvent(new CustomEvent("advanced-filter-apply",{detail:{showFactsOnly:!1,conceptSearchText:""},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._tempPeriodPreferences=this._enforceSingleMemberSelectionsForRole(this._selectedAvailableRole,this._tempPeriodPreferences),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._tempPeriodPreferences=this._enforceSingleMemberSelectionsForSelectedRoles(this._tempPeriodPreferences,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,a=this._searchInRoleURI(e,i);return o||r||n||a})}_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`
|
|
2157
2167
|
<div class="dialog" @click="${e=>e.stopPropagation()}">
|
|
2158
2168
|
<!-- Dialog Header -->
|
|
2159
2169
|
<div class="dialog-header">
|
|
2160
2170
|
<svg class="filter-icon" viewBox="0 0 24 24">
|
|
2161
2171
|
<path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
|
|
2162
2172
|
</svg>
|
|
2163
|
-
<h2 class="dialog-title">${
|
|
2173
|
+
<h2 class="dialog-title">${T.t("filter.title")}</h2>
|
|
2164
2174
|
<button class="close-button" @click="${this._handleCancel}">×</button>
|
|
2165
2175
|
</div>
|
|
2166
2176
|
|
|
@@ -2172,19 +2182,19 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2172
2182
|
<!-- Available Roles Panel -->
|
|
2173
2183
|
<div class="picklist-panel">
|
|
2174
2184
|
<div class="picklist-header">
|
|
2175
|
-
${
|
|
2185
|
+
${T.t("filter.availableRoles")} (${this._getAvailableRoles().length})
|
|
2176
2186
|
</div>
|
|
2177
2187
|
<div class="picklist-search">
|
|
2178
2188
|
<div class="search-container">
|
|
2179
2189
|
<input
|
|
2180
2190
|
type="text"
|
|
2181
2191
|
class="search-input"
|
|
2182
|
-
placeholder="${
|
|
2192
|
+
placeholder="${T.t("filter.searchPlaceholder")}"
|
|
2183
2193
|
.value="${this._searchQuery}"
|
|
2184
2194
|
@input="${this._handleSearchInput}"
|
|
2185
2195
|
/>
|
|
2186
2196
|
${this._searchQuery?e.html`
|
|
2187
|
-
<button class="clear-search" @click="${this._clearSearch}" title="${
|
|
2197
|
+
<button class="clear-search" @click="${this._clearSearch}" title="${T.t("filter.clearSearch")}">
|
|
2188
2198
|
×
|
|
2189
2199
|
</button>
|
|
2190
2200
|
`:e.html`
|
|
@@ -2209,7 +2219,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2209
2219
|
`})}
|
|
2210
2220
|
</div>
|
|
2211
2221
|
<div class="picklist-count">
|
|
2212
|
-
${this._getAvailableRoles().length} ${
|
|
2222
|
+
${this._getAvailableRoles().length} ${T.t("filter.roleCount")}
|
|
2213
2223
|
</div>
|
|
2214
2224
|
</div>
|
|
2215
2225
|
|
|
@@ -2219,7 +2229,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2219
2229
|
class="picklist-button"
|
|
2220
2230
|
@click="${this._moveToChosen}"
|
|
2221
2231
|
?disabled="${!this._selectedAvailableRole}"
|
|
2222
|
-
title="${
|
|
2232
|
+
title="${T.t("filter.addSelectedRole")}"
|
|
2223
2233
|
>
|
|
2224
2234
|
›
|
|
2225
2235
|
</button>
|
|
@@ -2227,7 +2237,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2227
2237
|
class="picklist-button"
|
|
2228
2238
|
@click="${this._moveAllToChosen}"
|
|
2229
2239
|
?disabled="${0===this._getAvailableRoles().length}"
|
|
2230
|
-
title="${
|
|
2240
|
+
title="${T.t("filter.addAllRoles")}"
|
|
2231
2241
|
>
|
|
2232
2242
|
»
|
|
2233
2243
|
</button>
|
|
@@ -2235,7 +2245,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2235
2245
|
class="picklist-button"
|
|
2236
2246
|
@click="${this._moveToAvailable}"
|
|
2237
2247
|
?disabled="${!this._selectedChosenRole}"
|
|
2238
|
-
title="${
|
|
2248
|
+
title="${T.t("filter.removeSelectedRole")}"
|
|
2239
2249
|
>
|
|
2240
2250
|
‹
|
|
2241
2251
|
</button>
|
|
@@ -2243,7 +2253,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2243
2253
|
class="picklist-button"
|
|
2244
2254
|
@click="${this._moveAllToAvailable}"
|
|
2245
2255
|
?disabled="${0===this._tempSelectedRoles.size}"
|
|
2246
|
-
title="${
|
|
2256
|
+
title="${T.t("filter.removeAllRoles")}"
|
|
2247
2257
|
>
|
|
2248
2258
|
«
|
|
2249
2259
|
</button>
|
|
@@ -2252,19 +2262,19 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2252
2262
|
<!-- Chosen Roles Panel -->
|
|
2253
2263
|
<div class="picklist-panel">
|
|
2254
2264
|
<div class="picklist-header">
|
|
2255
|
-
${
|
|
2265
|
+
${T.t("filter.chosenRoles")} (${this._tempSelectedRoles.size})
|
|
2256
2266
|
</div>
|
|
2257
2267
|
<div class="picklist-search">
|
|
2258
2268
|
<div class="search-container">
|
|
2259
2269
|
<input
|
|
2260
2270
|
type="text"
|
|
2261
2271
|
class="search-input chosen-search-input"
|
|
2262
|
-
placeholder="${
|
|
2272
|
+
placeholder="${T.t("filter.searchPlaceholder")}"
|
|
2263
2273
|
.value="${this._chosenSearchQuery}"
|
|
2264
2274
|
@input="${this._handleChosenSearchInput}"
|
|
2265
2275
|
/>
|
|
2266
2276
|
${this._chosenSearchQuery?e.html`
|
|
2267
|
-
<button class="clear-search" @click="${this._clearChosenSearch}" title="${
|
|
2277
|
+
<button class="clear-search" @click="${this._clearChosenSearch}" title="${T.t("filter.clearSearch")}">
|
|
2268
2278
|
×
|
|
2269
2279
|
</button>
|
|
2270
2280
|
`:e.html`
|
|
@@ -2295,7 +2305,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2295
2305
|
`})}
|
|
2296
2306
|
</div>
|
|
2297
2307
|
<div class="picklist-count">
|
|
2298
|
-
${this._tempSelectedRoles.size} ${
|
|
2308
|
+
${this._tempSelectedRoles.size} ${T.t("filter.rolesSelected")}
|
|
2299
2309
|
</div>
|
|
2300
2310
|
</div>
|
|
2301
2311
|
</div>
|
|
@@ -2307,7 +2317,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2307
2317
|
></jupiter-advanced-filter>
|
|
2308
2318
|
`:e.html`
|
|
2309
2319
|
<p class="description">
|
|
2310
|
-
${
|
|
2320
|
+
${T.t("filter.description")}
|
|
2311
2321
|
</p>
|
|
2312
2322
|
|
|
2313
2323
|
<!-- Search Input -->
|
|
@@ -2315,12 +2325,12 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2315
2325
|
<input
|
|
2316
2326
|
type="text"
|
|
2317
2327
|
class="search-input"
|
|
2318
|
-
placeholder="${
|
|
2328
|
+
placeholder="${T.t("filter.searchPlaceholder")}"
|
|
2319
2329
|
.value="${this._searchQuery}"
|
|
2320
2330
|
@input="${this._handleSearchInput}"
|
|
2321
2331
|
/>
|
|
2322
2332
|
${this._searchQuery?e.html`
|
|
2323
|
-
<button class="clear-search" @click="${this._clearSearch}" title="${
|
|
2333
|
+
<button class="clear-search" @click="${this._clearSearch}" title="${T.t("filter.clearSearch")}">
|
|
2324
2334
|
×
|
|
2325
2335
|
</button>
|
|
2326
2336
|
`:e.html`
|
|
@@ -2333,8 +2343,8 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2333
2343
|
<!-- Search Results Info -->
|
|
2334
2344
|
${r?e.html`
|
|
2335
2345
|
<div class="search-results-info">
|
|
2336
|
-
${
|
|
2337
|
-
${o!==i?e.html`${
|
|
2346
|
+
${T.t("filter.showingResults")} ${o} ${T.t("filter.of")} ${i} ${T.t("filter.roles")}
|
|
2347
|
+
${o!==i?e.html`${T.t("filter.matching")} "${this._searchQuery}"`:""}
|
|
2338
2348
|
</div>
|
|
2339
2349
|
`:""}
|
|
2340
2350
|
|
|
@@ -2342,27 +2352,27 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2342
2352
|
<div class="selection-controls">
|
|
2343
2353
|
${r?e.html`
|
|
2344
2354
|
<button class="selection-control" @click="${this._selectAll}">
|
|
2345
|
-
${
|
|
2355
|
+
${T.t("filter.selectFiltered")} (${o})
|
|
2346
2356
|
</button>
|
|
2347
2357
|
<button class="selection-control" @click="${this._selectNone}">
|
|
2348
|
-
${
|
|
2358
|
+
${T.t("filter.deselectFiltered")}
|
|
2349
2359
|
</button>
|
|
2350
2360
|
<button class="selection-control" @click="${this._selectAllGlobal}">
|
|
2351
|
-
${
|
|
2361
|
+
${T.t("filter.selectAll")} (${i})
|
|
2352
2362
|
</button>
|
|
2353
2363
|
<button class="selection-control" @click="${this._selectNoneGlobal}">
|
|
2354
|
-
${
|
|
2364
|
+
${T.t("filter.deselectAll")}
|
|
2355
2365
|
</button>
|
|
2356
2366
|
`:e.html`
|
|
2357
2367
|
<button class="selection-control" @click="${this._selectAll}">
|
|
2358
|
-
${
|
|
2368
|
+
${T.t("filter.selectAll")}
|
|
2359
2369
|
</button>
|
|
2360
2370
|
<button class="selection-control" @click="${this._selectNone}">
|
|
2361
|
-
${
|
|
2371
|
+
${T.t("filter.selectNone")}
|
|
2362
2372
|
</button>
|
|
2363
2373
|
`}
|
|
2364
2374
|
<button class="selection-control" @click="${this._resetToOriginal}">
|
|
2365
|
-
${
|
|
2375
|
+
${T.t("filter.reset")}
|
|
2366
2376
|
</button>
|
|
2367
2377
|
</div>
|
|
2368
2378
|
|
|
@@ -2371,14 +2381,14 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2371
2381
|
${0===this._filteredRoles.length?e.html`
|
|
2372
2382
|
<div class="no-results">
|
|
2373
2383
|
${r?e.html`
|
|
2374
|
-
${
|
|
2375
|
-
${
|
|
2384
|
+
${T.t("filter.noRolesFound")} "${this._searchQuery}".<br>
|
|
2385
|
+
${T.t("filter.tryDifferentSearch")}
|
|
2376
2386
|
`:e.html`
|
|
2377
|
-
${
|
|
2387
|
+
${T.t("filter.noRolesAvailable")}
|
|
2378
2388
|
`}
|
|
2379
2389
|
</div>
|
|
2380
2390
|
`:e.html`
|
|
2381
|
-
${this._filteredRoles.map(t=>{const i=this._tempSelectedRoles.has(t.id),o=this._tempPeriodPreferences[t.id]||{showDuration:!0,showInstant:!0},r=this._getDimensionsForRole(t.id),n=r.length>0,
|
|
2391
|
+
${this._filteredRoles.map(t=>{const i=this._tempSelectedRoles.has(t.id),o=this._tempPeriodPreferences[t.id]||{showDuration:!0,showInstant:!0},r=this._getDimensionsForRole(t.id),n=r.length>0,a=this._collapsedRoles.has(t.id);return e.html`
|
|
2382
2392
|
<div class="role-item">
|
|
2383
2393
|
<div class="role-item-header" @click="${()=>this._toggleRoleCollapse(t.id)}">
|
|
2384
2394
|
<input
|
|
@@ -2389,17 +2399,17 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2389
2399
|
@click="${e=>e.stopPropagation()}"
|
|
2390
2400
|
/>
|
|
2391
2401
|
<h5 class="role-title">${t.title}</h5>
|
|
2392
|
-
<button class="role-collapse-btn" title="${
|
|
2393
|
-
<svg class="role-collapse-chevron ${
|
|
2402
|
+
<button class="role-collapse-btn" title="${a?"Expand":"Collapse"}">
|
|
2403
|
+
<svg class="role-collapse-chevron ${a?"collapsed":""}" viewBox="0 0 24 24">
|
|
2394
2404
|
<path d="M7 10l5 5 5-5z"/>
|
|
2395
2405
|
</svg>
|
|
2396
2406
|
</button>
|
|
2397
2407
|
</div>
|
|
2398
2408
|
|
|
2399
|
-
${
|
|
2409
|
+
${a?"":e.html`
|
|
2400
2410
|
<div class="role-item-body">
|
|
2401
2411
|
<div class="period-controls">
|
|
2402
|
-
<p class="period-controls-label">${
|
|
2412
|
+
<p class="period-controls-label">${T.t("filter.additionalOptions")}</p>
|
|
2403
2413
|
<div class="period-checkboxes">
|
|
2404
2414
|
<label class="period-checkbox-item">
|
|
2405
2415
|
<input
|
|
@@ -2408,27 +2418,27 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2408
2418
|
.checked="${o.showPreviousYear}"
|
|
2409
2419
|
@change="${e=>this._handlePeriodCheckboxChange(e,t.id,"previousYear")}"
|
|
2410
2420
|
/>
|
|
2411
|
-
<span class="period-checkbox-label">${
|
|
2421
|
+
<span class="period-checkbox-label">${T.t("filter.showPreviousYear")}</span>
|
|
2412
2422
|
</label>
|
|
2413
2423
|
</div>
|
|
2414
2424
|
</div>
|
|
2415
2425
|
|
|
2416
2426
|
${n?e.html`
|
|
2417
2427
|
<div class="dimension-section">
|
|
2418
|
-
<div class="dimension-header">📊 ${
|
|
2419
|
-
${r.map(i=>{var o,r;const n=this._getAllDimensionMembers(i.members);if(0===n.length)return e.html``;const
|
|
2428
|
+
<div class="dimension-header">📊 ${T.t("filter.dimensionMemberSelection")}</div>
|
|
2429
|
+
${r.map(i=>{var o,r;const n=this._getAllDimensionMembers(i.members);if(0===n.length)return e.html``;const a=(null==(r=null==(o=i.labels)?void 0:o.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:r.label)||i.conceptName;return e.html`
|
|
2420
2430
|
<div class="dimension-group">
|
|
2421
|
-
<div class="dimension-label">${
|
|
2431
|
+
<div class="dimension-label">${a}</div>
|
|
2422
2432
|
<div class="dimension-members">
|
|
2423
|
-
${n.map(o=>{var r,n;const
|
|
2433
|
+
${n.map(o=>{var r,n;const a=(null==(n=null==(r=o.labels)?void 0:r.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:n.label)||o.conceptName,s=this._isDimensionMemberSelected(t.id,i.id,o.id);return e.html`
|
|
2424
2434
|
<label class="member-checkbox-item">
|
|
2425
2435
|
<input
|
|
2426
2436
|
type="checkbox"
|
|
2427
2437
|
class="member-checkbox"
|
|
2428
|
-
.checked="${
|
|
2438
|
+
.checked="${s}"
|
|
2429
2439
|
@change="${e=>this._handleDimensionMemberChange(e,t.id,i.id,o.id)}"
|
|
2430
2440
|
/>
|
|
2431
|
-
<span class="member-checkbox-label">${
|
|
2441
|
+
<span class="member-checkbox-label">${a}</span>
|
|
2432
2442
|
</label>
|
|
2433
2443
|
`})}
|
|
2434
2444
|
</div>
|
|
@@ -2437,13 +2447,13 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2437
2447
|
class="member-select-btn"
|
|
2438
2448
|
@click="${()=>this._selectAllDimensionMembers(t.id,i.id)}"
|
|
2439
2449
|
>
|
|
2440
|
-
${
|
|
2450
|
+
${T.t("filter.selectAllMembers")}
|
|
2441
2451
|
</button>
|
|
2442
2452
|
<button
|
|
2443
2453
|
class="member-select-btn"
|
|
2444
2454
|
@click="${()=>this._deselectAllDimensionMembers(t.id,i.id)}"
|
|
2445
2455
|
>
|
|
2446
|
-
${
|
|
2456
|
+
${T.t("filter.clearMembers")}
|
|
2447
2457
|
</button>
|
|
2448
2458
|
</div>
|
|
2449
2459
|
</div>
|
|
@@ -2464,25 +2474,25 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2464
2474
|
${"admin"!==this.mode&&"readonly"!==this.mode?e.html`
|
|
2465
2475
|
${this._showAdvancedFilter?e.html`
|
|
2466
2476
|
<button class="btn-text" @click="${this._switchToFilterRoles}">
|
|
2467
|
-
${
|
|
2477
|
+
${T.t("filter.backToFilterRoles")}
|
|
2468
2478
|
</button>
|
|
2469
2479
|
${this._showFactsOnly||this._conceptSearchText.trim().length>0?e.html`
|
|
2470
2480
|
<button class="btn-text" @click="${this._handleAdvancedFilterReset}">
|
|
2471
|
-
${
|
|
2481
|
+
${T.t("filter.resetFilter")}
|
|
2472
2482
|
</button>
|
|
2473
2483
|
`:""}
|
|
2474
2484
|
`:e.html`
|
|
2475
2485
|
<button class="btn-text" @click="${this._switchToAdvancedFilter}">
|
|
2476
|
-
${
|
|
2486
|
+
${T.t("filter.advancedFilter")}
|
|
2477
2487
|
</button>
|
|
2478
2488
|
`}
|
|
2479
2489
|
`:""}
|
|
2480
2490
|
<button class="btn-secondary" @click="${this._handleCancel}">
|
|
2481
|
-
${
|
|
2491
|
+
${T.t("filter.cancel")}
|
|
2482
2492
|
</button>
|
|
2483
2493
|
${this._showAdvancedFilter?e.html`
|
|
2484
2494
|
<button class="btn-primary" @click="${this._handleAdvancedFilterApply}">
|
|
2485
|
-
${
|
|
2495
|
+
${T.t("filter.applyFilter")}
|
|
2486
2496
|
</button>
|
|
2487
2497
|
`:e.html`
|
|
2488
2498
|
<button
|
|
@@ -2490,7 +2500,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
2490
2500
|
@click="${this._handleApply}"
|
|
2491
2501
|
?disabled="${0===t}"
|
|
2492
2502
|
>
|
|
2493
|
-
${
|
|
2503
|
+
${T.t("filter.applyFilter")} (${t})
|
|
2494
2504
|
</button>
|
|
2495
2505
|
`}
|
|
2496
2506
|
</div>
|
|
@@ -3096,11 +3106,279 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3096
3106
|
.btn-text:hover {
|
|
3097
3107
|
background: var(--menuBgColorLighter, var(--jupiter-hover-background, #f5f5f5));
|
|
3098
3108
|
}
|
|
3099
|
-
`,ne([S({type:Boolean,reflect:!0})],exports.JupiterFilterRolesDialog.prototype,"open",2),ne([S({type:Array})],exports.JupiterFilterRolesDialog.prototype,"availableRoles",2),ne([S({type:Array})],exports.JupiterFilterRolesDialog.prototype,"selectedRoleIds",2),ne([S({type:Object})],exports.JupiterFilterRolesDialog.prototype,"periodPreferences",2),ne([S({type:String})],exports.JupiterFilterRolesDialog.prototype,"mode",2),ne([S({type:Object})],exports.JupiterFilterRolesDialog.prototype,"hypercubeData",2),ne([S({type:Boolean})],exports.JupiterFilterRolesDialog.prototype,"showFactsOnly",2),ne([S({type:String})],exports.JupiterFilterRolesDialog.prototype,"conceptSearchText",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_tempSelectedRoles",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_searchQuery",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_filteredRoles",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_tempPeriodPreferences",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_selectedAvailableRole",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_selectedChosenRole",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_chosenSearchQuery",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_draggedRoleId",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_dragOverRoleId",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_chosenRoleOrder",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_showAdvancedFilter",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_showFactsOnly",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_conceptSearchText",2),ne([w()],exports.JupiterFilterRolesDialog.prototype,"_collapsedRoles",2),exports.JupiterFilterRolesDialog=ne([t("jupiter-filter-roles-dialog")],exports.JupiterFilterRolesDialog);var le=Object.defineProperty,ae=Object.getOwnPropertyDescriptor,de=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?ae(t,i):t,s=e.length-1;s>=0;s--)(r=e[s])&&(n=(o?r(t,i,n):r(n))||n);return o&&n&&le(t,i,n),n};exports.JupiterDynamicForm=class extends e.LitElement{constructor(){super(...arguments),this.config={},this.initialData={},this.disabled=!1,this.readonly=!1,this.calculationEnabled=!1,this.periodStartDate="2025-01-01",this.periodEndDate="2025-12-31",this.language="en",this.reportingLanguage="en",this.display="accordion",this.mode="inputForm",this.roleFilterAxes=[],this.showLastValidationResultBtn=!1,this.isDraftSaving=!1,this.defaultUnits=[],this.decimals="INF",this._formData={},this._draftLoaded=!1,this._preservedFormData={},this._periodData={},this._preservedPeriodData={},this._unitData={},this._preservedUnitData={},this._decimalsData={},this._effectiveMasterData=void 0,this._typedMemberData={},this._preservedTypedMemberData={},this._repeatCounts={},this._hiddenColumnIds=new Map,this._columns=[],this._errors=[],this._touched=new Set,this._dirty=!1,this._valid=!0,this._submitted=!1,this._xbrlFormErrors=[],this._calculationWarnings=new Map,this._showErrorPopup=!1,this._submitDisabled=!1,this._allSections=[],this._selectedRoleIds=[],this._showFilterDialog=!1,this._showFactsOnly=!1,this._conceptSearchText="",this._periodPreferences={},this._activeSidePanelRoleId=null,this._sidePanelSearchQuery="",this._sidePanelCollapsed=!1,this._adminRoleConfigs={},this._roleBorderStatuses=new Map,this._roleCompletedStates=new Map,this._showRoleContextMenu=!1,this._contextMenuX=0,this._contextMenuY=0,this._contextMenuRoleId=null,this._validationStatus="idle",this._skipDraftLoading=!1,this._skipPeriodPreferencesRestore=!1,this._autoSaveTimer=null,this._lastAutoSaveSnapshot="",this._lastSavedDraftSnapshot=""}connectedCallback(){super.connectedCallback(),this.addEventListener("period-change",e=>{console.log("🌍 [GLOBAL DynamicForm] Caught period-change event on element:",e);const t=e;console.log("🌍 [GLOBAL DynamicForm] Event detail:",t.detail),this._handlePeriodChange(t)}),this.addEventListener("unit-change",e=>{console.log("🏷️ [GLOBAL DynamicForm] Caught unit-change event on element:",e);const t=e;console.log("🏷️ [GLOBAL DynamicForm] Event detail:",t.detail),this._handleUnitChange(t)}),this.addEventListener("decimals-change",e=>{this._handleDecimalsChange(e)}),this.addEventListener("field-blur",e=>{console.log("🚨 [DynamicForm] field-blur event listener triggered!",e);const t=e;this._handleFieldBlur(t)}),this.addEventListener("calculation-mismatch-changed",e=>{this._handleCalculationMismatchChanged(e)}),document.addEventListener("click",()=>{this._showRoleContextMenu&&(this._showRoleContextMenu=!1,this.requestUpdate())}),this._autoSaveTimer=setInterval(()=>{const e=JSON.stringify(this._formData);if(""===this._lastAutoSaveSnapshot)return this._lastAutoSaveSnapshot=e,void console.log("ℹ️ [Auto Save] Baseline initialized; no draft save emitted.");e!==this._lastAutoSaveSnapshot?(this._lastAutoSaveSnapshot=e,this._handleSaveDraft("auto")):console.log("ℹ️ [Auto Save] No form state change detected; skipping draft save emit.")},3e4),this._initializeForm()}disconnectedCallback(){super.disconnectedCallback(),null!==this._autoSaveTimer&&(clearInterval(this._autoSaveTimer),this._autoSaveTimer=null)}updated(e){(e.has("decimals")||e.has("masterData"))&&this._computeEffectiveMasterData(),e.has("language")&&k.setLanguage(this.language),(e.has("xbrlInput")||e.has("defaultUnits"))&&this.xbrlInput&&this.defaultUnits&&this.defaultUnits.length>0&&this._applyDefaultUnitsToDatatypes(),(e.has("xbrlInput")||e.has("schema")||e.has("language")||e.has("periodStartDate")||e.has("periodEndDate")||e.has("roleFilterAxes"))&&this._initializeForm()}_applyDefaultUnitsToDatatypes(){var e;if(!(null==(e=this.xbrlInput)?void 0:e.datatypes)||!this.defaultUnits||0===this.defaultUnits.length)return;console.log("🔧 [DynamicForm] Applying defaultUnits to datatypes:",this.defaultUnits);const t=Array.isArray(this.xbrlInput.datatypes)?this.xbrlInput.datatypes:this.xbrlInput.datatypes.concepts;t&&0!==t.length?this.defaultUnits.forEach(e=>{Object.entries(e).forEach(([e,i])=>{const o=t.find(t=>t.type===e||t.id===e);if(o&&o.units&&o.units.length>0){const t=o.units.find(e=>e.id===i);t?(o.units.forEach(e=>e.isDefault=!1),t.isDefault=!0,console.log(`✅ [DynamicForm] Set isDefault=true for unit "${i}" in datatype "${e}"`)):console.warn(`⚠️ [DynamicForm] Unit "${i}" not found in datatype "${e}"`)}else console.warn(`⚠️ [DynamicForm] Datatype "${e}" not found or has no units`)})}):console.warn("⚠️ [DynamicForm] No datatypes found to apply defaults to")}_initializeForm(){var e;if(this._draftStorageService||(this._draftStorageService=new R(!1)),this.xbrlInput)try{if(console.log("🔄 Initializing form from XBRL input:",this.xbrlInput),console.log("📅 Using period dates:",this.periodStartDate,"to",this.periodEndDate),console.log("🌐 Using language:",this.language),this._initializePeriodPreferencesFromData(),this._applyAxisFilterToPeriodPreferences(),this._applyDimensionShowPreviousYear(),console.log("⚙️ Using period preferences:",this._periodPreferences),this._currentSchema=F.buildFormSchema(this.xbrlInput,this.periodStartDate,this.periodEndDate,this.language,this._periodPreferences),console.log("✅ Generated schema with sections:",this._currentSchema.sections.length),this._allSections=[...this._currentSchema.sections],Array.isArray(this._selectedRoleIds)&&this._selectedRoleIds.length>0&&"object"==typeof this._selectedRoleIds[0]){console.log("🔄 Applying custom role order to _allSections from _selectedRoleIds");const e=this._selectedRoleIds,t=new Map;e.forEach(e=>{t.set(e.roleId,e.order)}),this._allSections=[...this._allSections].sort((e,i)=>(t.get(e.id)??999)-(t.get(i.id)??999)),console.log("✅ Custom order applied to _allSections:",this._allSections.map(e=>e.title))}if(0===this._selectedRoleIds.length){const e=this.roleFilterAxes&&this.roleFilterAxes.length>0?this._filterRolesByAxisConfig(this._allSections):this._allSections;this._selectedRoleIds=e.map(e=>e.id),console.log(`✅ Auto-selected ${this._selectedRoleIds.length} roles (of ${this._allSections.length} total)`)}this._applyRoleFilter(),this._columns=[{id:"base",title:"Value",description:"Base values for concepts",type:"base",order:0,removable:!1}]}catch(t){console.error("❌ Error building form from XBRL input:",t),this._currentSchema=this._getDefaultSchema(),this._allSections=[],this._selectedRoleIds=[],this._columns=this._getDefaultColumns()}else this.schema?(this._currentSchema=this.schema,this._allSections=[...this.schema.sections],this._selectedRoleIds=this._allSections.map(e=>e.id),this._columns=this._getDefaultColumns()):(this._currentSchema=this._getDefaultSchema(),this._allSections=[],this._selectedRoleIds=[],this._columns=this._getDefaultColumns());this._formData={...this.initialData},(null==(e=this.xbrlInput)?void 0:e.initialData)&&(this._formData={...this._formData,...this.xbrlInput.initialData}),this._initializeGlobalDecimalsFromRoundingData(),this._extractTypedMembersFromFacts(),this._skipDraftLoading?(console.log("⏭️ Skipping draft loading during preference update"),this._analyzeAllVisibleRoles()):this._loadDraftIfExists().then(()=>{this._analyzeAllVisibleRoles()}).catch(()=>{this._analyzeAllVisibleRoles()}),this._validateForm()}_extractTypedMembersFromFacts(){var e;(null==(e=this._currentSchema)?void 0:e.sections)&&(this._currentSchema.sections.forEach(e=>{this._extractTypedMembersFromConcepts(e.concepts||[],e)}),console.log("✅ [DynamicForm] Typed member data populated:",this._typedMemberData))}_extractTypedMembersFromConcepts(e,t){e.forEach(e=>{e.facts&&e.facts.length>0&&(console.log(`🔍 [DynamicForm] Checking concept ${e.id} with ${e.facts.length} facts`),e.facts.forEach(i=>{if(i.dimensions&&Array.isArray(i.dimensions)){const o=i.dimensions.filter(e=>"typed"===e.dimensionType&&e.typedMemberValue);if(o.length>0){console.log(`📝 [DynamicForm] Found ${o.length} typed dimensions in fact:`,{factName:i.name,typedDimensions:o.map(e=>({dimension:e.dimension,typedMemberValue:e.typedMemberValue}))});const r=this._findColumnWithTypedMembers(i,e,t);r?(console.log(`✅ [DynamicForm] Found matching column: ${r.id}`),o.forEach(i=>{var o,n;const s=this._normalizeAxisId(i.dimension),l=null==(n=null==(o=r.dimensionData)?void 0:o.typedMembers)?void 0:n.find(e=>e.axisId===s||this._normalizeAxisId(e.axisId)===s);if(l){this._typedMemberData[r.id]||(this._typedMemberData[r.id]={});const o=l.axisId;this._typedMemberData[r.id][o]=i.typedMemberValue,console.log("✅ [DynamicForm] Set typed member value:",{sectionId:t.id,conceptId:e.id,columnId:r.id,axisKey:o,typedMemberValue:i.typedMemberValue})}else console.warn(`⚠️ [DynamicForm] Typed member not found for axis: ${s}`)})):console.warn("⚠️ [DynamicForm] No matching column found for fact with typed dimensions")}}})),e.children&&e.children.length>0&&this._extractTypedMembersFromConcepts(e.children,t)})}_findColumnWithTypedMembers(e,t,i){var o;if(!t.fields||0===t.fields.length)return null;const r=i.columns||[];if(0===r.length)return null;for(const n of t.fields){const t=r.find(e=>e.id===n.columnId);if(t&&(null==(o=t.dimensionData)?void 0:o.hasTypedMembers)){const i=(e.dimensions||[]).filter(e=>"explicit"===e.dimensionType),o=t.dimensionData.combinations||[];if(0===i.length||i.length===o.length&&i.every(e=>o.some(t=>this._normalizeAxisId(e.dimension)===this._normalizeAxisId(t.axisId)&&this._normalizeMemberId(e.member)===this._normalizeMemberId(t.memberId))))return t}}return null}_findColumnForFactDimensions(e,t,i){if(!t.fields||0===t.fields.length)return console.log(`⚠️ [DynamicForm] No fields for concept: ${t.id}`),null;const o=i.columns||[];if(0===o.length)return console.log(`⚠️ [DynamicForm] No columns in section: ${i.id}`),null;for(const r of t.fields){const t=o.find(e=>e.id===r.columnId);if(t&&t.dimensionData){const i=e.dimensions||[],o=t.dimensionData.combinations||[];console.log(`🔍 [DynamicForm] Checking column ${t.id}:`,{factDimensions:i.map(e=>({axis:e.dimension,member:e.member,type:e.dimensionType})),columnDimensions:o.map(e=>({axis:e.axisId,member:e.memberId}))});if(o.every(e=>i.some(t=>{const i=this._normalizeAxisId(t.dimension)===this._normalizeAxisId(e.axisId);if("explicit"===t.dimensionType){const o=this._normalizeMemberId(t.member)===this._normalizeMemberId(e.memberId);return i&&o}return"typed"===t.dimensionType&&i})))return t}}return null}_normalizeAxisId(e){return e?e.includes(":")?e.split(":").pop()||e:e.includes("_")&&e.split("_").pop()||e:""}_normalizeMemberId(e){return e?e.includes(":")?e.split(":").pop()||e:e.includes("_")&&e.split("_").pop()||e:""}_getDefaultSchema(){return{version:"1.0",formId:"default-form",title:"Dynamic Form",description:"Please provide form schema or XBRL input data",sections:[]}}_getDefaultColumns(){return[{id:"base",title:"Value",description:"Base values for concepts",type:"base",order:0,removable:!1}]}_initializePeriodPreferencesFromData(){var e,t,i;if(!(null==(i=null==(t=null==(e=this.xbrlInput)?void 0:e.presentation)?void 0:t[0])?void 0:i.roles))return;const o={...this._periodPreferences};this.xbrlInput.presentation[0].roles.forEach(e=>{if(!o[e.id]){const t=!0===e.showPreviousYear,i=void 0===e.instant||!0===e.instant,r=void 0===e.duration||!0===e.duration;o[e.id]={showDuration:r,showInstant:i,showPreviousYear:t}}}),this._periodPreferences=o}_applyAxisFilterToPeriodPreferences(){var e,t,i,o;if(!this.roleFilterAxes||0===this.roleFilterAxes.length)return;if(!(null==(i=null==(t=null==(e=this.xbrlInput)?void 0:e.hypercubes)?void 0:t[0])?void 0:i.roles))return;const r=this.xbrlInput.hypercubes[0].roles,n={...this._periodPreferences};for(const s of r){const e=s.roleId,t=n[e];if((null==t?void 0:t.dimensionSelections)&&t.dimensionSelections.length>0)continue;const i=[];for(const r of this.roleFilterAxes)for(const e of s.items||[]){if(null==(o=e.dimensions)?void 0:o.find(e=>e.id===r.id||r.conceptName&&e.conceptName===r.conceptName)){i.push({dimensionId:r.id,dimensionLabel:r.conceptName||r.id,selectedMemberIds:r.members.filter(e=>!0===e.available).map(e=>e.id)});break}}i.length>0&&(n[e]={showDuration:(null==t?void 0:t.showDuration)??!0,showInstant:(null==t?void 0:t.showInstant)??!0,showPreviousYear:(null==t?void 0:t.showPreviousYear)??!1,dimensionSelections:i})}this._periodPreferences=n}_applyDimensionShowPreviousYear(){var e,t;if("admin"!==this.mode)return;const i=!(!this.dynaformsFacts||!this.dynaformsMetadata),o=(null==(e=this._draftStorageService)?void 0:e.hasDraft())??!1;if(i||o)return;const r={...this._periodPreferences};let n=!1;for(const s of Object.keys(r)){const e=r[s];if(e.showPreviousYear)continue;((null==(t=e.dimensionSelections)?void 0:t.some(e=>e.selectedMemberIds&&e.selectedMemberIds.length>0))??!1)&&(r[s]={...e,showPreviousYear:!0},n=!0,console.log(`📅 [JDF-010] Auto-enabled showPreviousYear for role "${s}" (has dimension members)`))}n&&(this._periodPreferences=r)}_getRoleIdsArray(){return Array.isArray(this._selectedRoleIds)&&0!==this._selectedRoleIds.length?"string"==typeof this._selectedRoleIds[0]?this._selectedRoleIds:this._selectedRoleIds.map(e=>e.roleId):[]}_applyRoleFilter(){if(!this._currentSchema||!this._allSections.length)return;const e=this._getRoleIdsArray();if(console.log(`🔍 Applying role filter: ${e.length} selected out of ${this._allSections.length} total`),0===e.length)return console.log("📝 No roles selected - showing empty form"),this._currentSchema={...this._currentSchema,sections:[]},void this.requestUpdate();this._preserveDataForHiddenSections();const t=this._allSections.filter(t=>e.includes(t.id)),i=this._sortSectionsByCustomOrder(t);console.log(`📊 Filtered sections: ${i.length}`),console.log("📋 Custom order applied:",i.map(e=>e.title)),this._restoreDataForVisibleSections(i),this._currentSchema={...this._currentSchema,sections:i},console.log(`✅ Schema updated with custom order. Current sections count: ${this._currentSchema.sections.length}`),this.requestUpdate()}_sortSectionsByCustomOrder(e){if(Array.isArray(this._selectedRoleIds)&&this._selectedRoleIds.length>0&&"object"==typeof this._selectedRoleIds[0]){const t=this._selectedRoleIds,i=new Map;return t.forEach(e=>{i.set(e.roleId,e.order)}),[...e].sort((e,t)=>(i.get(e.id)??999)-(i.get(t.id)??999))}return e}_filterRolesByAxisConfig(e){var t;if(!this.roleFilterAxes||0===this.roleFilterAxes.length)return e;if(!(null==(t=this.xbrlInput)?void 0:t.hypercubes)||0===this.xbrlInput.hypercubes.length)return e;const i=this.xbrlInput.hypercubes[0];return e.filter(e=>{var t;const o=null==(t=i.roles)?void 0:t.find(t=>t.roleId===e.id);if(!o||!o.items||0===o.items.length)return!0;for(const i of this.roleFilterAxes){const e=new Set(i.members.filter(e=>!0===e.available).map(e=>e.id));let t=!1,r=!1;for(const n of o.items){if(!n.dimensions||0===n.dimensions.length)continue;const o=n.dimensions.find(e=>e.id===i.id||i.conceptName&&e.conceptName===i.conceptName);if(o){if(t=!0,o.members)for(const t of o.members)if(e.has(t.id)){r=!0;break}if(r)break}}if(t&&!r)return!1}return!0})}_preserveDataForHiddenSections(){var e;const t=(null==(e=this._currentSchema)?void 0:e.sections.map(e=>e.id))||[],i=this._getRoleIdsArray();t.filter(e=>!i.includes(e)).forEach(e=>{const t=this._allSections.find(t=>t.id===e);t&&this._preserveSectionData(t)})}_restoreDataForVisibleSections(e){e.forEach(e=>{this._restoreSectionData(e)}),console.log(`🔄 Restored data for ${e.length} visible sections`)}_preserveSectionData(e){e.concepts.forEach(e=>{this._preserveConceptData(e)})}_preserveConceptData(e){this._formData[e.id]&&(this._preservedFormData[e.id]={...this._formData[e.id]}),e.fields.forEach(t=>{this._typedMemberData[t.columnId]&&(this._preservedTypedMemberData[t.columnId]={...this._typedMemberData[t.columnId]});const i=`${e.id}__${t.columnId}`;this._typedMemberData[i]&&(this._preservedTypedMemberData[i]={...this._typedMemberData[i]})}),e.children&&e.children.forEach(e=>{this._preserveConceptData(e)})}_restoreSectionData(e){e.concepts.forEach(e=>{this._restoreConceptData(e)})}_restoreConceptData(e){this._preservedFormData[e.id]&&(this._formData[e.id]={...this._preservedFormData[e.id]}),e.fields.forEach(t=>{this._preservedTypedMemberData[t.columnId]&&(this._typedMemberData[t.columnId]={...this._preservedTypedMemberData[t.columnId]});const i=`${e.id}__${t.columnId}`;this._preservedTypedMemberData[i]&&(this._typedMemberData[i]={...this._preservedTypedMemberData[i]})}),e.children&&e.children.forEach(e=>{this._restoreConceptData(e)})}_shouldShowFilterButton(){return!0}get _hasActiveAdvancedFilters(){return this._showFactsOnly||this._conceptSearchText.trim().length>0}_handleClearAdvancedFilters(){this._showFactsOnly=!1,this._conceptSearchText=""}_handleFilterRolesClick(){this._showFilterDialog=!0}_handleAdvancedFilterApply(e){this._showFactsOnly=e.detail.showFactsOnly,this._conceptSearchText=e.detail.conceptSearchText??"",this._showFilterDialog=!1}_handleFilterDialogCancel(){this._showFilterDialog=!1;const e=this._getRoleIdsArray().length;console.log(`🚫 Filter dialog cancelled. Current selection: ${e}/${this._allSections.length}`)}_handleRoleFilterApply(e){var t,i;const{selectedRoleIds:o,periodPreferences:r}=e.detail;console.log("🎯 Filter apply triggered"),console.log("📊 Old _selectedRoleIds:",this._selectedRoleIds),console.log("📊 New selectedRoleIds from dialog:",o),this._selectedRoleIds=o,this._periodPreferences=r,console.log("📊 Updated _selectedRoleIds:",this._selectedRoleIds),console.log("📊 New period preferences (including dimension selections):",this._periodPreferences),console.log("💾 Capturing current form data before reinitialization...");const n=this._generateSubmissionData(),s=this._draftStorageService.createMetadataSnapshot(this.periodStartDate,this.periodEndDate,this.language,this._selectedRoleIds,this._allSections,this._typedMemberData,this._periodPreferences,this._periodData,this._unitData,this.reportingLanguage,this._repeatCounts,this._decimalsData,void 0,this._getHiddenColumnsForMetadata());this._draftStorageService.saveDraft(n,s),console.log("✅ Current form data saved to draft storage with NEW preferences"),this.dynaformsFacts=n,this.dynaformsMetadata=s,this._skipPeriodPreferencesRestore=!0,this._skipDraftLoading=!0,console.log("🔄 Reinitializing form with new filter settings..."),this._initializeForm(),this._skipDraftLoading=!1,this._skipPeriodPreferencesRestore=!1,console.log("📊 After _initializeForm, _currentSchema.sections.length:",null==(t=this._currentSchema)?void 0:t.sections.length),console.log("📊 Section IDs:",null==(i=this._currentSchema)?void 0:i.sections.map(e=>e.id)),console.log("📥 Restoring form data from draft after reinitialization..."),this._loadDraftIfExists().then(()=>{console.log("✅ Form data restored successfully after reinitialization")}).catch(e=>{console.error("❌ Error restoring form data after reinitialization:",e)}),this._showFilterDialog=!1;const l=Array.isArray(this._selectedRoleIds)&&this._selectedRoleIds.length>0?(this._selectedRoleIds[0],this._selectedRoleIds.length):0;console.log(`🎯 Applied role filter: ${l}/${this._allSections.length} roles selected`),console.log("📋 Enhanced selectedRoleIds structure:",this._selectedRoleIds),this.dispatchEvent(new CustomEvent("roles-filter-changed",{detail:{selectedRoleIds:o,totalRoles:this._allSections.length,visibleRoles:l,periodPreferences:r},bubbles:!0}))}_haveDimensionSelectionsChanged(e){var t;const i=new Set([...Object.keys(this._periodPreferences||{}),...Object.keys(e||{})]);for(const o of i){const i=null==(t=this._periodPreferences)?void 0:t[o],r=null==e?void 0:e[o],n=(null==i?void 0:i.dimensionSelections)||[],s=(null==r?void 0:r.dimensionSelections)||[];if(JSON.stringify(n.sort((e,t)=>e.dimensionId.localeCompare(t.dimensionId)))!==JSON.stringify(s.sort((e,t)=>e.dimensionId.localeCompare(t.dimensionId))))return console.log(`🔍 Dimension selection changed for role: ${o}`),console.log(" Old:",n),console.log(" New:",s),!0}return!1}_validateForm(){var e;const t=[],i=this._currentSchema;if(i){for(const o of i.sections)for(const i of o.concepts)for(const o of i.fields){const r=null==(e=this._formData[i.id])?void 0:e[o.columnId],n=C.validateField(o.id,i.id,o.columnId,r,o.type,o.validation||[]);t.push(...n)}t.push(...Array.from(this._calculationWarnings.values())),this._errors=t,this._valid=0===t.filter(e=>"error"===e.severity).length}}_handleCalculationMismatchChanged(e){const{key:t,mismatch:i}=e.detail,o=new Map(this._calculationWarnings);i?o.set(t,{fieldId:`${i.totalConceptId}__${i.columnId}`,conceptId:i.totalConceptId,columnId:i.columnId,message:i.message,severity:"warning",rule:{type:"custom",message:i.message,severity:"warning"},details:i}):o.delete(t),this._calculationWarnings=o,this._validateForm()}_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:l}=e.detail;console.log(`📅 Period change received: conceptId=${t}, columnId=${i}, periodType=${o}, startDate=${r}, endDate=${n}, instantDate=${s}, unit=${l}`);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)),l&&this._storeUnit(t,i,l),this._dirty=!0,this.requestUpdate()}_handleUnitChange(e){console.log("🏷️ [DynamicForm] _handleUnitChange called with event:",e),console.log("🏷️ [DynamicForm] Event detail:",e.detail);const{conceptId:t,columnId:i,unit:o}=e.detail;console.log(`🏷️ Unit change received: conceptId=${t}, columnId=${i}, unit=${o}`),this._storeUnit(t,i,o),this._dirty=!0,this.requestUpdate()}_storeUnit(e,t,i){console.log(`🔧 [_storeUnit] Called with conceptId=${e}, columnId=${t}, unit=${i}`),console.log("🔧 [_storeUnit] Current _unitData before update:",JSON.stringify(this._unitData,null,2));const o={...this._unitData};o[e]||(console.log(`🔧 [_storeUnit] Creating new entry for conceptId: ${e}`),o[e]={}),o[e]={...o[e],[t]:i},this._unitData=o,console.log(`💾 [_storeUnit] Unit data stored for [${e}][${t}]:`,this._unitData[e][t]),console.log("📦 [_storeUnit] Full unit data state after update:",JSON.stringify(this._unitData,null,2))}_handleDecimalsChange(e){const{conceptId:t,columnId:i,decimals:o}=e.detail;t&&i&&(this._storeDecimals(t,i,o),this._dirty=!0,this.requestUpdate())}_computeEffectiveMasterData(){const e="rj-i_DocumentIntendedRoundingLevel";if("INF"!==this.decimals){const t=parseFloat(this.decimals);if(!isNaN(t))return void(this._effectiveMasterData={...this.masterData||{},[e]:String(-t)})}this._effectiveMasterData=this.masterData?{...this.masterData}:void 0}_initializeGlobalDecimalsFromRoundingData(){if(this._hasValidGlobalDecimals())return;const e=this._findRoundingLevelFactValue(this._allSections)??this._findRoundingLevelValueInFormData(this._formData);if(null==e||""===e)return;const t=parseFloat(String(e));isNaN(t)||(this.decimals=String(Math.abs(t)))}_findRoundingLevelValueInFormData(e){if(e)for(const t of Object.keys(e)){if(!this._isRoundingLevelConcept(t))continue;const i=e[t]||{};for(const e of Object.keys(i)){const t=i[e];if(null!=t&&""!==t)return t}}}_findRoundingLevelFactValue(e){for(const t of e){const e=this._findRoundingLevelFactValueInConcepts(t.concepts||[]);if(null!=e&&""!==e)return e}}_findRoundingLevelFactValueInConcepts(e){for(const t of e){const e=t.originalConceptId||t.id;if(this._isRoundingLevelConcept(e)){const e=t.facts||[];for(const t of e)if(void 0!==(null==t?void 0:t.value)&&null!==(null==t?void 0:t.value)&&""!==(null==t?void 0:t.value))return t.value}if(t.children&&t.children.length>0){const e=this._findRoundingLevelFactValueInConcepts(t.children);if(null!=e&&""!==e)return e}}}_hasValidGlobalDecimals(){if(void 0===this.decimals||null===this.decimals)return!1;if("INF"===this.decimals)return!1;const e=parseFloat(this.decimals);return!isNaN(e)}_isRoundingLevelConcept(e){return!!e&&("rj-i_DocumentIntendedRoundingLevel"===e||e.includes("DocumentIntendedRoundingLevel"))}_findFactValueForField(e,t,i){var o,r;if(!e.facts||0===e.facts.length)return;const n=this._findColumnByIdInSection(t.columnId,i),s=null==(o=this._periodData[e.id])?void 0:o[t.columnId],l=(null==s?void 0:s.startDate)||(null==n?void 0:n.periodStartDate)||t.periodStartDate||this.periodStartDate,a=(null==s?void 0:s.endDate)||(null==n?void 0:n.periodEndDate)||t.periodEndDate||this.periodEndDate,d=(null==s?void 0:s.instantDate)||t.periodInstantDate||a||l,c=null==(r=this._unitData[e.id])?void 0:r[t.columnId],p={conceptId:e.originalConceptId||t.conceptId||e.id,columnId:t.columnId,periodStartDate:l,periodEndDate:a,periodInstantDate:d,periodType:t.periodType,unit:c,dimensionData:null==n?void 0:n.dimensionData},h=E.findMatchingFact(e.facts,p);return null==h?void 0:h.value}_storeDecimals(e,t,i){const o={...this._decimalsData};o[e]||(o[e]={}),o[e]={...o[e],[t]:i??""},this._decimalsData=o}_generateUniqueConceptKey(e,t){return`${e}::${t}`}_extractOriginalConceptId(e){const t=e.split("::");return t.length>1?t[1]:e}_handleAddConceptRepeat(e){const{conceptId:t}=e.detail;this._repeatCounts={...this._repeatCounts,[t]:(this._repeatCounts[t]||0)+1},this._dirty=!0}_handleRemoveConceptRepeat(e){const{conceptId:t}=e.detail,i=t.match(/^(.+)__repeat_(\d+)$/),o=i?i[1]:t,r=i?parseInt(i[2]):this._repeatCounts[t]||0,n=this._repeatCounts[o]||0;if(n<=0||r<1||r>n)return;const s={...this._formData},l={...this._typedMemberData},a={...this._unitData},d={...this._periodData};for(let h=r;h<n;h++){const e=`${o}__repeat_${h+1}`,t=`${o}__repeat_${h}`;void 0!==s[e]?s[t]=s[e]:delete s[t];const i=`${t}__`,r=`${e}__`,n=Object.keys(l).filter(e=>e.startsWith(r));Object.keys(l).filter(e=>e.startsWith(i)).forEach(e=>delete l[e]),n.forEach(e=>{l[`${t}__${e.slice(r.length)}`]=l[e]}),n.forEach(e=>delete l[e]),void 0!==a[e]?a[t]=a[e]:delete a[t],void 0!==d[e]?d[t]=d[e]:delete d[t]}const c=`${o}__repeat_${n}`;delete s[c],delete a[c],delete d[c];const p=`${c}__`;Object.keys(l).filter(e=>e.startsWith(p)).forEach(e=>delete l[e]),this._formData=s,this._typedMemberData=l,this._unitData=a,this._periodData=d,this._repeatCounts={...this._repeatCounts,[o]:n-1},this._dirty=!0}_handleTypedMemberChange(e){const{columnId:t,axisId:i,value:o,conceptId:r}=e.detail,n=r?`${r}__${t}`:t;console.log(`🔍 [DynamicForm] Typed member change: storageKey=${n}, axisId=${i}, value=${o}`);const s={...this._typedMemberData};s[n]||(s[n]={}),s[n]={...s[n],[i]:o},this._typedMemberData=s,this._dirty=!0,this.requestUpdate(),this.dispatchEvent(new CustomEvent("typed-member-change",{detail:{columnId:t,axisId:i,value:o},bubbles:!0}))}_handleFieldBlur(e){var t;console.log("🟧 [DynamicForm] _handleFieldBlur received event:",e),console.log("🟧 [DynamicForm] Event detail:",e.detail);const{fieldId:i,conceptId:o,columnId:r,xbrlValidationErrors:n}=e.detail;console.log(`🟧 [DynamicForm] Extracted - fieldId: ${i}, conceptId: ${o}, columnId: ${r}`),console.log("🟧 [DynamicForm] xbrlValidationErrors:",n);let s="";const l=e.composedPath();console.log(`🟧 [DynamicForm] Event path length: ${l.length}`);for(const a of l){const e=a;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])||"",l=this._xbrlFormErrors.findIndex(e=>e.fieldId===i&&e.sectionId===s),a={sectionId:s,fieldId:i,conceptId:o,columnId:r,value:e,errors:n};console.log("🟧 [DynamicForm] New error object:",a),console.log(`🟧 [DynamicForm] Existing index: ${l}`),l>=0?(this._xbrlFormErrors=[...this._xbrlFormErrors.slice(0,l),a,...this._xbrlFormErrors.slice(l+1)],console.log(`🟧 [DynamicForm] Updated existing error at index ${l}`)):(this._xbrlFormErrors=[...this._xbrlFormErrors,a],console.log("🟧 [DynamicForm] Added new error"))}else{console.log(`🟧 [DynamicForm] Removing error (if exists) for fieldId: ${i}, sectionId: ${s}`);const e=this._xbrlFormErrors.length;this._xbrlFormErrors=this._xbrlFormErrors.filter(e=>!(e.fieldId===i&&e.sectionId===s)),console.log(`🟧 [DynamicForm] Removed ${e-this._xbrlFormErrors.length} errors`)}console.log(`🔍 [Validation] Total errors: ${this._xbrlFormErrors.length}`,this._xbrlFormErrors)}_getSectionTitle(e){console.log(`🔍 [_getSectionTitle] Looking for sectionId: "${e}"`),console.log("🔍 [_getSectionTitle] Available sections:",this._allSections.map(e=>({id:e.id,title:e.title})));const t=this._allSections.find(t=>t.id===e),i=(null==t?void 0:t.title)||e||"(Unknown Section)";return console.log(`🔍 [_getSectionTitle] Result: "${i}"`),i}_roleHasErrors(e){return this._xbrlFormErrors.some(t=>t.sectionId===e)}async _handleErrorFieldClick(e,t,i){var o,r,n,s;console.log(`🎯 [Error Click] Attempting to focus field: ${e}__${t} in section: ${i}`),this._showErrorPopup=!1,this.requestUpdate(),await this.updateComplete,"sidePanel"===this.display&&this._activeSidePanelRoleId!==i&&(console.log(`🔀 Switching to section: ${i} (currently on: ${this._activeSidePanelRoleId})`),this._activeSidePanelRoleId=i,this.requestUpdate(),await this.updateComplete,await new Promise(e=>setTimeout(e,500)));const l=null==(o=this.shadowRoot)?void 0:o.querySelectorAll("jupiter-form-section");let a=null;if(null==l||l.forEach(e=>{var t;(null==(t=e.section)?void 0:t.id)===i&&(a=e)}),!a)return void console.warn(`⚠️ Section not found: ${i}`);if(console.log("✅ Found section element:",a),(null==(r=a.section)?void 0:r.collapsed)?(console.log("📂 Expanding collapsed section"),a.section.collapsed=!1,a.requestUpdate(),await a.updateComplete,await new Promise(e=>setTimeout(e,500))):(await a.updateComplete,await new Promise(e=>setTimeout(e,100))),console.log(`🔍 Section shadow DOM exists: ${!!a.shadowRoot}`),a.shadowRoot){console.log(`🔍 Shadow DOM innerHTML length: ${(null==(n=a.shadowRoot.innerHTML)?void 0:n.length)||0}`);const e=a.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=a.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;a.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}))}_handleColumnHide(e){const{columnId:t,sectionId:i}=e.detail;i&&t&&(this._hiddenColumnIds.has(i)||this._hiddenColumnIds.set(i,new Set),this._hiddenColumnIds.get(i).add(t),this._dirty=!0,this.requestUpdate(),this.dispatchEvent(new CustomEvent("column-hide",{detail:{columnId:t,sectionId:i},bubbles:!0})))}_handleColumnShow(e){var t;const{columnId:i,sectionId:o}=e.detail;o&&i&&(null==(t=this._hiddenColumnIds.get(o))||t.delete(i),this._dirty=!0,this.requestUpdate(),this.dispatchEvent(new CustomEvent("column-show",{detail:{columnId:i,sectionId:o},bubbles:!0})))}_getColumnsWithHiddenFlags(e){const t=e.columns||this._columns,i=this._hiddenColumnIds.get(e.id);return i&&0!==i.size?t.map(e=>i.has(e.id)?{...e,hidden:!0}:e):t}_getHiddenColumnsForMetadata(){if(0===this._hiddenColumnIds.size)return;const e={};return this._hiddenColumnIds.forEach((t,i)=>{t.size>0&&(e[i]=Array.from(t))}),Object.keys(e).length>0?e:void 0}_handleColumnAddRequest(e){const{sectionId:t,columnRequest:i,insertAfterColumnId:o}=e.detail;this._addColumnFromRequest(i,t,o)}_getAvailableDimensionsForSection(e){var t,i,o;if(!(null==(i=null==(t=this.xbrlInput)?void 0:t.hypercubes)?void 0:i[0]))return[];const r=this.xbrlInput.hypercubes[0].roles.find(t=>t.roleId===e);if(!(null==(o=null==r?void 0:r.items)?void 0:o.length))return console.log(`❌ No hypercube items found for role: ${e}`),[];const n=[],s=this.language||"en",l=(e,t)=>{var i;return(null==(i=(null==e?void 0:e.find(e=>e.lang===s&&"http://www.xbrl.org/2003/role/label"===e.role))||(null==e?void 0:e.find(e=>"en"===e.lang&&"http://www.xbrl.org/2003/role/label"===e.role))||(null==e?void 0:e.find(e=>"http://www.xbrl.org/2003/role/label"===e.role)))?void 0:i.label)||t};return r.items.forEach(e=>{e.dimensions&&e.dimensions.length>0&&e.dimensions.forEach(e=>{if(!n.find(t=>t.id===e.id)){const t=l(e.labels,e.conceptName),i={id:e.id,conceptName:e.conceptName,axisLabel:t};e.members&&e.members.length>0&&(i.members=e.members.map(e=>({id:e.id,label:l(e.labels,e.conceptName||e.id)}))),e.typedMember&&(i.typedMember={id:e.typedMember.id,dataType:"string"}),n.push(i)}})}),n}_formatPeriodDisplay(e,t){if(!e||!t)return`${e||""} / ${t||""}`;const i=e.substring(0,4);return i===t.substring(0,4)?i:`${e} / ${t}`}_resolveSubmissionInstantDate(e,t,i,o){const r=this._getEffectivePeriodRole(e);if(null==r?void 0:r.includes("periodStartLabel")){const e=(null==i?void 0:i.startDate)||(null==o?void 0:o.periodStartDate)||t.periodStartDate||this.periodStartDate,n=(null==i?void 0:i.endDate)||(null==o?void 0:o.periodEndDate)||t.periodEndDate||this.periodEndDate;return this._resolveInstantDate(r,void 0,e,n)}return(null==i?void 0:i.instantDate)||(null==i?void 0:i.endDate)||t.periodInstantDate||(null==o?void 0:o.periodEndDate)||t.periodEndDate||t.periodStartDate||this.periodStartDate}_getEffectivePeriodRole(e){return e.effectivePeriodRole??e.preferredLabel}_resolveInstantDate(e,t,i,o){if(null==e?void 0:e.includes("periodStartLabel")){const e=i||"2025-01-01";try{const t=new Date(e);return t.setDate(t.getDate()-1),t.toISOString().split("T")[0]}catch{return e}}return t||o||i||"2025-01-01"}_correctLegacyPeriodStartInstantDates(){this._allSections.forEach(e=>{this._correctPeriodStartInstantDatesInConcepts(e.concepts,e)})}_correctPeriodStartInstantDatesInConcepts(e,t){e.forEach(e=>{var i,o;(null==(i=this._getEffectivePeriodRole(e))?void 0:i.includes("periodStartLabel"))&&"instant"===e.periodType&&(null==(o=e.fields)?void 0:o.length)&&e.fields.forEach(i=>{this._correctFieldPeriodStartInstantDate(e,i,e.id,t);const o=this._repeatCounts[e.id]||0;for(let r=1;r<=o;r++)this._correctFieldPeriodStartInstantDate(e,i,`${e.id}__repeat_${r}`,t)}),e.children&&this._correctPeriodStartInstantDatesInConcepts(e.children,t)})}_correctFieldPeriodStartInstantDate(e,t,i,o){var r;const n=this._findColumnByIdInSection(t.columnId,o),s=null==(r=this._periodData[i])?void 0:r[t.columnId],l=(null==s?void 0:s.startDate)||(null==n?void 0:n.periodStartDate)||t.periodStartDate||this.periodStartDate,a=(null==s?void 0:s.endDate)||(null==n?void 0:n.periodEndDate)||t.periodEndDate||this.periodEndDate,d=this._resolveInstantDate(this._getEffectivePeriodRole(e),void 0,l,a);s&&s.instantDate!==d&&(console.log(`🩹 [Legacy Period Correction] ${i}/${t.columnId}: instantDate ${s.instantDate} → ${d}`),s.instantDate=d),t.periodInstantDate!==d&&(console.log(`🩹 [Legacy Period Correction] field ${e.id}/${t.columnId}: periodInstantDate ${t.periodInstantDate} → ${d}`),t.periodInstantDate=d)}_addColumnFromRequest(e,t,i){var o,r,n,s,l;const a=`col-${Date.now()}`;let d="",c="";"instant"===e.periodType?(d=e.instantDate||"",c=""):"duration"!==e.periodType&&"mixed"!==e.periodType||(d=this._formatPeriodDisplay(e.startDate,e.endDate),c="");let p={dimensionId:"period",memberValue:"instant"===e.periodType?`instant-${e.instantDate}`:`duration-${e.startDate}-${e.endDate}`,memberLabel:d};if(e.selectedDimensions&&e.selectedDimensions.length>0){const t=[],i=[];for(const o of e.selectedDimensions)o.isTyped&&o.typedValue?(t.push(`${o.axisLabel}: ${o.typedValue}`),i.push(`${o.axisId}|${o.typedValue}`)):o.memberId&&o.memberLabel&&(t.push(o.memberLabel),i.push(`${o.axisId}|${o.memberId}`));t.length>0&&(d=t.join(" | "),c="instant"===e.periodType?e.instantDate||"":this._formatPeriodDisplay(e.startDate,e.endDate),p={dimensionId:a,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==(l=o.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:l.label)||o.conceptName;d=r,c="instant"===e.periodType?e.instantDate||"":this._formatPeriodDisplay(e.startDate,e.endDate),p={dimensionId:a,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:a,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[a]=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(a,e,t),this._dirty=!0,this.requestUpdate(),this.dispatchEvent(new CustomEvent("column-add",{detail:{column:h},bubbles:!0}))}_removeColumnData(e,t){if(this._currentSchema)if(t){const i=this._currentSchema.sections.find(e=>e.id===t);i&&this._removeColumnDataFromConcepts(i.concepts,e)}else for(const i in this._formData)void 0!==this._formData[i][e]&&delete this._formData[i][e]}_removeColumnDataFromConcepts(e,t){e.forEach(e=>{this._formData[e.id]&&void 0!==this._formData[e.id][t]&&delete this._formData[e.id][t],e.fields&&(e.fields=e.fields.filter(e=>e.columnId!==t)),e.children&&this._removeColumnDataFromConcepts(e.children,t)})}_shouldCreateFieldForConcept(e,t){if(e.abstract)return!1;if(!(t.selectedDimensions&&t.selectedDimensions.length>0)&&e.periodType){if("instant"===t.periodType&&"instant"!==e.periodType)return!1;if("duration"===t.periodType&&"duration"!==e.periodType)return!1}return!0}_replicateFieldsForNewColumn(e,t,i){if(!this._currentSchema)return;const o=new F,r=this._currentSchema.sections.find(e=>e.id===i);r&&this._replicateFieldsForSection(r.concepts,e,t,o)}_replicateFieldsForSection(e,t,i,o){e.forEach(e=>{var r;if(this._shouldCreateFieldForConcept(e,i)){const o=null==(r=e.fields)?void 0:r[0];let n;const s="instant"===i.periodType?i.instantDate:i.startDate,l="instant"===i.periodType?i.instantDate:i.endDate,a=this._resolveInstantDate(this._getEffectivePeriodRole(e),i.instantDate,s,l);n=o?{id:`${e.id}_${t}`,conceptId:e.id,columnId:t,type:o.type,label:o.label,placeholder:o.placeholder,required:o.required,disabled:o.disabled,validation:o.validation,defaultValue:o.defaultValue,periodType:e.periodType,conceptType:e.type,periodStartDate:s,periodEndDate:l,periodInstantDate:"instant"===e.periodType?a:void 0}:{id:`${e.id}_${t}`,conceptId:e.id,columnId:t,type:"text",label:e.label||e.name,placeholder:`Enter ${e.name}`,required:!1,disabled:!1,validation:[],defaultValue:"",periodType:e.periodType,conceptType:e.type,periodStartDate:s,periodEndDate:l,periodInstantDate:"instant"===e.periodType?a:void 0},e.fields||(e.fields=[]),e.fields.push(n)}e.children&&this._replicateFieldsForSection(e.children,t,i,o)})}_addColumn(){const e={id:`dim-${Date.now()}`,title:`Dimension ${this._columns.length}`,description:"Additional dimension column",type:"dimension",order:this._columns.length,removable:!0,dimensionData:{dimensionId:"custom",memberValue:"default",memberLabel:"Default Member"}};this._columns=[...this._columns,e],this.requestUpdate(),this.dispatchEvent(new CustomEvent("column-add",{detail:{column:e},bubbles:!0}))}_handleSubmit(){if(console.log("📝 Form submission started..."),this._submitted=!0,this._submitDisabled=!0,"admin"===this.mode)return this._handleSaveDraft(),this._handleAdminModeSubmit(),void(this._submitDisabled=!1);if(console.log("🔵 [Submit] Checking for errors..."),console.log(`🔵 [Submit] _xbrlFormErrors.length: ${this._xbrlFormErrors.length}`),console.log("🔵 [Submit] _xbrlFormErrors:",this._xbrlFormErrors),this._xbrlFormErrors.length>0)return console.log("❌ [Submit] Cannot submit - validation errors present:",this._xbrlFormErrors),this._showErrorPopup=!0,this._submitDisabled=!1,void this.requestUpdate();if(console.log("✅ [Submit] No validation errors, proceeding with submission..."),this._validateForm(),!this._valid)return console.log("❌ [Submit] Cannot submit - form validation errors present:",this._errors),this._showErrorPopup=!0,this._submitDisabled=!1,void this.requestUpdate();this._correctLegacyPeriodStartInstantDates();const e=this._generateSubmissionData();console.log("📊 Form Submission Data:",JSON.stringify(e,null,2)),console.log("📊 Submission Data Summary:"),e.forEach((e,t)=>{console.log(` [${t}] conceptId: ${e.conceptId}, columnId: ${e.columnId}, value: ${e.value}, unit: ${e.unit||"none"}`)}),this.dispatchEvent(new CustomEvent("form-submit",{detail:{data:this._formData,submissionData:e,valid:this._valid,errors:this._errors,reportingLanguage:this.reportingLanguage},bubbles:!0})),console.log("✅ Form submit event dispatched"),setTimeout(()=>{this._submitDisabled=!1},1e3)}_handleSaveDraft(e="manual"){if(console.log("🔵 [Save Draft] Checking for errors..."),console.log(`🔵 [Save Draft] _xbrlFormErrors.length: ${this._xbrlFormErrors.length}`),console.log("🔵 [Save Draft] _xbrlFormErrors:",this._xbrlFormErrors),this._xbrlFormErrors.length>0)return console.log("❌ [Save Draft] Cannot save - validation errors present:",this._xbrlFormErrors),this._showErrorPopup=!0,void this.requestUpdate();console.log("✅ [Save Draft] No validation errors, proceeding with save..."),console.log("💾 Raw form data before submission generation:",this._formData),console.log("🏷️ Unit data before submission generation:",this._unitData),console.log("📋 Enhanced selectedRoleIds with roleURI and order:",this._selectedRoleIds),this._correctLegacyPeriodStartInstantDates();const t=this._generateSubmissionData();console.log("📤 Generated submission data:",t),console.log("📊 Submission data breakdown:"),t.forEach((e,t)=>{console.log(` [${t}] conceptId: ${e.conceptId}, columnId: ${e.columnId}, value: ${e.value}, unit: ${e.unit||"none"}`)});const i=this._roleCompletedStates.size>0?Object.fromEntries(this._roleCompletedStates):void 0,o=this._draftStorageService.createMetadataSnapshot(this.periodStartDate,this.periodEndDate,this.language,this._selectedRoleIds,this._allSections,this._typedMemberData,this._periodPreferences,this._periodData,this._unitData,this.reportingLanguage,this._repeatCounts,this._decimalsData,i,this._getHiddenColumnsForMetadata()),r=JSON.stringify({draftData:t,metadata:o});if(r===this._lastSavedDraftSnapshot)return void console.log(`ℹ️ [Save Draft] No draft content change detected (${e}); skipping event emit.`);this._lastSavedDraftSnapshot=r;const n=this._draftStorageService.saveDraft(t,o);console.log("💾 [Save Draft] Metadata saved with enhanced selectedRoleIds:",o.selectedRoleIds),this.dynaformsFacts=t,this.dynaformsMetadata=o,this.dispatchEvent(new CustomEvent("form-save-draft",{detail:{data:this._formData,draftData:t,metadata:o,saved:n,valid:this._valid,errors:this._errors,dynaformsFacts:t,dynaformsMetadata:o,reportingLanguage:this.reportingLanguage,source:"auto"==e?"auto":"manual"},bubbles:!0,composed:!0}));const s=this._getRoleIdsArray().length;console.log("💾 Draft saved - localStorage + event emitted",{entries:t.length,saved:n,roles:s,customColumns:o.customColumns.length,eventEmitted:!0,enhancedRoleStructure:Array.isArray(this._selectedRoleIds)&&this._selectedRoleIds.length>0&&"object"==typeof this._selectedRoleIds[0]})}async _loadDraftIfExists(){if(console.log("📋 Checking for saved draft..."),this.dynaformsFacts&&this.dynaformsMetadata){console.log("📦 Using external draft data from properties");const e={formData:this.dynaformsFacts,metadata:this.dynaformsMetadata};return await this._restoreFromDraft(e),this._draftLoaded=!0,this._draftLoadedAt=this.dynaformsMetadata.savedAt||(new Date).toISOString(),this.dispatchEvent(new CustomEvent("form-draft-loaded",{detail:{draft:e,source:"external",compatible:!0,warnings:[]},bubbles:!0,composed:!0})),void console.log("📥 External draft loaded successfully")}if(!this._draftStorageService.hasDraft())return void console.log("ℹ️ No saved draft found");const e=this._draftStorageService.loadDraft();if(!e)return void console.warn("⚠️ Failed to load draft");const{compatible:t,warnings:i}=this._draftStorageService.validateDraftCompatibility(e,this.periodStartDate,this.periodEndDate);i.length>0&&console.warn("⚠️ Draft compatibility warnings:",i),await this._restoreFromDraft(e),this.dispatchEvent(new CustomEvent("form-draft-loaded",{detail:{draft:e,compatible:t,warnings:i},bubbles:!0,composed:!0})),console.log("📥 Draft loaded successfully",{entries:e.formData.length,savedAt:e.metadata.savedAt,age:this._draftStorageService.getDraftAge()})}async _restoreFromDraft(e){var t;const{formData:i,metadata:o}=e;o.selectedRoleIds&&o.selectedRoleIds.length>0&&(this._selectedRoleIds=o.selectedRoleIds,console.log(`🔄 Restored ${this._selectedRoleIds.length} selected roles`)),o.typedMemberData&&(this._typedMemberData=o.typedMemberData,this._preservedTypedMemberData={},console.log("🔄 Restored typed member data")),o.repeatCounts&&(this._repeatCounts=o.repeatCounts,console.log("🔄 Restored repeat counts:",this._repeatCounts)),o.periodData&&(this._periodData=o.periodData,console.log("🔄 Restored custom field-level period data:",Object.keys(this._periodData).length,"concepts")),o.unitData&&(this._unitData=o.unitData,console.log("🔄 Restored custom field-level unit data:",Object.keys(this._unitData).length,"concepts")),o.decimalsData&&(this._decimalsData=o.decimalsData,console.log("🔄 Restored per-fact decimals data:",Object.keys(this._decimalsData).length,"concepts")),o.roleCompletedStates&&(this._roleCompletedStates=new Map(Object.entries(o.roleCompletedStates)),console.log("🔄 Restored role completed states:",Object.keys(o.roleCompletedStates).length,"roles")),o.hiddenColumns&&(this._hiddenColumnIds=new Map(Object.entries(o.hiddenColumns).map(([e,t])=>[e,new Set(t)])),console.log("🔄 Restored hidden columns for",this._hiddenColumnIds.size,"sections")),o.periodPreferences?this._skipPeriodPreferencesRestore?console.log("⏭️ Skipping period preferences restoration - using new filter selections"):(this._periodPreferences=o.periodPreferences,console.log("🔄 Restored period preferences (including previous year settings):",this._periodPreferences),this.xbrlInput&&(console.log("🔄 Rebuilding schema with restored period preferences..."),this._currentSchema=F.buildFormSchema(this.xbrlInput,this.periodStartDate,this.periodEndDate,this.language,this._periodPreferences),this._allSections=[...this._currentSchema.sections],console.log("✅ Schema rebuilt with restored period preferences"),console.log("🔄 Applying custom period data to schema fields..."),this._applyCustomPeriodDataToFields(),o.customColumns&&o.customColumns.length>0&&(this._mergeAdditionalCustomColumns(o.customColumns),console.log(`🔄 Merged ${o.customColumns.length} additional custom columns`)))):o.customColumns&&o.customColumns.length>0&&(this._restoreCustomColumns(o.customColumns),console.log(`🔄 Restored ${o.customColumns.length} custom columns`));const r={},n={},s={};i.forEach(e=>{let{conceptId:t,draftInstanceId:i,value:o,columnId:l,period:a,unit:d}=e;if(!l&&a&&(l=this._inferColumnIdFromPeriod(a,t),!l))return void console.warn(`⚠️ Could not infer columnId for concept ${t}, skipping...`);const c=i||t,p=c.includes("__repeat_")?c.split("__repeat_")[0]:c,h=this._findActualConceptId(p),u=c.includes("__repeat_")?`${h||p}__repeat_${c.split("__repeat_")[1]}`:h||c;r[u]||(r[u]={}),r[u][l]=o,console.log(`📦 Restored: ${u}[${l}] = ${o}${c!==t?" (repeat instance)":""}`),a&&(n[u]||(n[u]={}),"instant"===a.type?(n[u][l]={instantDate:a.date},console.log(`📅 [Restore Period] Extracted instant date for ${u}/${l}: ${a.date}`)):"duration"===a.type&&(n[u][l]={startDate:a.startDate,endDate:a.endDate},console.log(`📅 [Restore Period] Extracted duration dates for ${u}/${l}: ${a.startDate} - ${a.endDate}`))),d&&(s[u]||(s[u]={}),s[u][l]=d,console.log(`🏷️ [Restore Unit] Extracted unit for ${u}/${l}: ${d}`))}),this._formData={...this._formData,...r},console.log(`🔄 Restored ${Object.keys(r).length} concepts with data`),this._initializeGlobalDecimalsFromRoundingData(),this._periodData={...this._periodData,...o.periodData||{},...n},console.log(`📅 [Period Restore] Merged period data: ${Object.keys(this._periodData).length} concepts with custom periods`),console.log("📅 [Period Restore] Full _periodData after merge:",JSON.stringify(this._periodData,null,2)),this._unitData={...this._unitData,...o.unitData||{},...s},console.log(`🏷️ [Unit Restore] Merged unit data: ${Object.keys(this._unitData).length} concepts with custom units`),console.log("🏷️ [Unit Restore] Full _unitData after merge:",JSON.stringify(this._unitData,null,2)),this._correctLegacyPeriodStartInstantDates(),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 l=(null==(t=this.shadowRoot)?void 0:t.querySelectorAll("input, textarea, select").length)||0;console.log(`🔍 Found ${l} fields in DOM after update`),l>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 l=r[e],a=`${o}__${e}`;console.log(`🔍 Looking for field: ${a}`);const d=null==(n=this.shadowRoot)?void 0:n.querySelector(`#${CSS.escape(a)}`);d?(d instanceof HTMLInputElement||d instanceof HTMLTextAreaElement||d instanceof HTMLSelectElement)&&("checkbox"===d.type?d.checked=Boolean(l):d.value=null!=l?String(l):"",console.log(` ✅ Populated field ${a} with value:`,l),t++):(console.warn(` ❌ Field element NOT FOUND: ${a}`),console.warn(" Available fields in DOM:",Array.from((null==(s=this.shadowRoot)?void 0:s.querySelectorAll("input, textarea, select"))||[]).map(e=>e.id).filter(e=>e.includes(o.split("__")[0]))),i++)})}),console.log(`✅ Field population complete: ${t} populated, ${i} not found`)}_restoreCustomColumns(e){const t=new Map;e.forEach(e=>{t.has(e.sectionId)||t.set(e.sectionId,[]),t.get(e.sectionId).push(e)}),this._allSections.forEach(e=>{var i;const o=t.get(e.id);if(o){if(e.columns=o.map(e=>{const t={id:e.columnId,title:e.label,description:e.description,type:e.dimensionData?"dimension":"base",periodStartDate:e.startDate||e.date,periodEndDate:e.endDate||e.date,dimensionData:e.dimensionData,order:0,removable:"duration"!==e.columnId&&"instant"!==e.columnId,periodType:e.periodType};return console.log(`📅 [Draft Restore] Restoring column ${e.columnId}: title=${t.title}, description=${t.description}, startDate=${t.periodStartDate}, endDate=${t.periodEndDate}, periodType=${t.periodType}`),t}),(null==(i=this.xbrlInput)?void 0:i.datatypes)&&!e.datatypes){const t=Array.isArray(this.xbrlInput.datatypes)?this.xbrlInput.datatypes:this.xbrlInput.datatypes.concepts||[];e.datatypes=t,console.log(`✅ [Draft Restore] Attached ${t.length} datatypes to section ${e.id}`)}else e.datatypes?console.log(`ℹ️ [Draft Restore] Section ${e.id} already has ${e.datatypes.length} datatypes`):console.warn(`⚠️ [Draft Restore] No datatypes available for section ${e.id}`);this._regenerateFieldsForSection(e),console.log(` └─ Restored ${o.length} columns for section ${e.id}`)}}),this._currentSchema&&(this._currentSchema={...this._currentSchema,sections:this._allSections})}_mergeAdditionalCustomColumns(e){const t=new Map;e.forEach(e=>{e.columnId.startsWith("col-")&&(t.has(e.sectionId)||t.set(e.sectionId,[]),t.get(e.sectionId).push(e))}),this._allSections.forEach(e=>{var i;const o=t.get(e.id);if(o&&o.length>0){if(e.columns||(e.columns=[]),(null==(i=this.xbrlInput)?void 0:i.datatypes)&&!e.datatypes){const t=Array.isArray(this.xbrlInput.datatypes)?this.xbrlInput.datatypes:this.xbrlInput.datatypes.concepts||[];e.datatypes=t,console.log(`✅ [Merge Custom] Attached ${t.length} datatypes to section ${e.id}`)}else e.datatypes?console.log(`ℹ️ [Merge Custom] Section ${e.id} already has ${e.datatypes.length} datatypes`):console.warn(`⚠️ [Merge Custom] No datatypes available for section ${e.id}`);o.forEach(t=>{console.log(`📅 [Merge Custom Column] Column ${t.columnId}: col.startDate=${t.startDate}, col.endDate=${t.endDate}, col.date=${t.date}, col.periodType=${t.periodType}`);if(!e.columns.find(e=>e.id===t.columnId)){const i={id:t.columnId,title:t.label,description:t.description,type:t.dimensionData?"dimension":"base",periodStartDate:t.startDate||t.date,periodEndDate:t.endDate||t.date,dimensionData:t.dimensionData,order:e.columns.length,removable:!0,periodType:t.periodType};console.log(`📅 [New Column Created] Column ${i.id}: title=${i.title}, description=${i.description}, periodStartDate=${i.periodStartDate}, periodEndDate=${i.periodEndDate}, periodType=${i.periodType}`),e.columns.push(i),console.log(` └─ Added custom column ${t.columnId} to section ${e.id}`)}}),this._regenerateFieldsForSection(e)}}),this._currentSchema&&(this._currentSchema={...this._currentSchema,sections:this._allSections})}_applyCustomPeriodDataToFields(){if(!this._periodData||0===Object.keys(this._periodData).length)return void console.log("ℹ️ No custom period data to apply");let e=0;const t=i=>{i.forEach(i=>{if(this._periodData[i.id]){const t=this._periodData[i.id];i.fields&&i.fields.forEach(o=>{const r=t[o.columnId];r&&(r.startDate&&(o.periodStartDate=r.startDate),r.endDate&&(o.periodEndDate=r.endDate),r.instantDate&&(o.periodInstantDate=r.instantDate),e++,console.log(`✅ [Apply Period] Updated field ${i.id}/${o.columnId}: start=${o.periodStartDate}, end=${o.periodEndDate}, instant=${o.periodInstantDate}`))})}i.children&&i.children.length>0&&t(i.children)})};this._allSections.forEach(e=>{e.concepts&&e.concepts.length>0&&t(e.concepts)}),console.log(`📅 [Apply Period] Applied custom period data to ${e} fields`)}_regenerateFieldsForSection(e){if(!e.columns)return;const t=this._periodPreferences[e.id]||{showDuration:!0,showInstant:!0,showPreviousYear:!1},i=o=>{o.forEach(o=>{o.fields=[];this._shouldShowConceptBasedOnPeriodPreferences(o,t)&&e.columns.forEach(t=>{var i;const r=o.periodType,n=this._inferColumnPeriodType(t);if(o.abstract)return;const s=t.id.startsWith("col-"),l=t.id.startsWith("duration_")||t.id.startsWith("instant_")||t.id.startsWith("typed-"),a=!0===e.showPeriodControl;if(!(!n||"duration"===t.id||"default"===t.id||s&&a||l)&&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?this._resolveInstantDate(this._getEffectivePeriodRole(o),void 0,t.periodStartDate,t.periodEndDate):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,l,a,d;const c=e.fields.find(e=>e.columnId===t);if(!c)return;const p="instant"===e.periodType,h=null==(n=this._periodData[e.id])?void 0:n[t],u=null==(s=this._unitData[e.id])?void 0:s[t],m=this._findColumnByIdInAllSections(t);console.log(`🔍 [Submission] Concept: ${e.id}, Column: ${t}, Field Period: ${h?JSON.stringify(h):"none"}, Unit: ${u||"none"}, Column Period: ${(null==m?void 0:m.periodStartDate)||"none"} - ${(null==m?void 0:m.periodEndDate)||"none"}`);const f=(null==h?void 0:h.startDate)||(null==m?void 0:m.periodStartDate)||c.periodStartDate||this.periodStartDate,b=(null==h?void 0:h.endDate)||(null==m?void 0:m.periodEndDate)||c.periodEndDate||this.periodEndDate,g=(null==h?void 0:h.instantDate)||c.periodInstantDate||b||f,v={conceptId:e.originalConceptId||e.id,columnId:t,value:i,period:{type:e.periodType||"duration",...p?{date:g}:{startDate:f,endDate:b}}};u&&(v.unit=u,console.log(`✅ [Submission] Adding unit to entry: ${u} for ${e.id}/${t}`));const y=null==(l=e.type)?void 0:l.toLowerCase().includes("monetary"),x=(null==(a=this._decimalsData[e.id])?void 0:a[t])||("INF"!==this.decimals?this.decimals:void 0);if(y&&x){const e=parseFloat(x);v.decimals=isNaN(e)?x:String(-Math.abs(e))}(null==(d=null==m?void 0:m.dimensionData)?void 0:d.memberLabel)&&(v.dimension=m.dimensionData.memberLabel),console.log("📤 [Submission Entry] Created entry:",JSON.stringify(v,null,2)),o.push(v)}_findColumnByIdInAllSections(e){for(const t of this._allSections)if(t.columns){const i=t.columns.find(t=>t.id===e);if(i)return i}}_removeDuplicateSubmissions(e){const t=new Map;return e.forEach(e=>{const i="instant"===e.period.type?e.period.date:`${e.period.startDate}_${e.period.endDate}`,o=`${e.conceptId}_${e.value}_${e.dimension||"no-dimension"}_${i}`;t.has(o)||t.set(o,e)}),Array.from(t.values())}_findColumnById(e){if(this._currentSchema)for(const t of this._currentSchema.sections)if(t.columns){const i=t.columns.find(t=>t.id===e);if(i)return i}}_findColumnByIdInSection(e,t){if(null==t?void 0:t.columns)return t.columns.find(t=>t.id===e)}_getTypedMemberNameForAxis(e,t){var i,o,r,n;if(!(null==(o=null==(i=this.xbrlInput)?void 0:i.hypercubes)?void 0:o[0]))return null;const s=null==t?void 0:t.id;if(!s)return null;const l=null==(r=this.xbrlInput.hypercubes[0].roles)?void 0:r.find(e=>e.roleId===s);if(!(null==l?void 0:l.items))return null;for(const a of l.items)if(a.dimensions){const t=a.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 l=this.xbrlInput.hypercubes[0].roles.find(e=>e.roleId===s);if(!(null==(n=null==l?void 0:l.items)?void 0:n.length))return!1;for(const a of l.items){const t=e.originalConceptId||e.id;if(a.conceptIds&&a.conceptIds.includes(t)){const e=a.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 l of n.items)if(l.conceptIds&&l.conceptIds.includes(s)){const e=l.dimensions.filter(e=>e.typedMember).map(e=>e.id);return console.log(`🔍 [DynamicForm] Found applicable typed dimensions for concept ${s}:`,e),e}return[]}_processConceptsForSubmission(e,t,i){const o="Toelichting op de geconsolideerde jaarrekening - Financiële vaste activa: Deelnemingen: Volledig geconsolideerd: Specificatie",r=(null==i?void 0:i.title)||"Unknown";e.forEach(e=>{if(r===o&&(console.warn(`[DUPLICATE DEBUG] Processing concept ${e.originalConceptId||e.id} in target role`),e.fields&&(console.warn(`[DUPLICATE DEBUG] Concept has ${e.fields.length} fields`),e.fields.forEach((t,i)=>{var o;console.warn(`[DUPLICATE DEBUG] Field ${i}: columnId=${t.columnId}, current value=${null==(o=this._formData[e.id])?void 0:o[t.columnId]}`)}))),e.fields&&e.fields.length>1&&e.fields.forEach((e,t)=>{}),e.fields&&e.fields.length>0){e.fields.forEach(n=>{var s,l,a,d,c,p,h,u;const m=this._formData[e.id];let f=null==m?void 0:m[n.columnId];const b=n.conceptId||e.id.split("__").slice(0,-1).join("__")||e.id;if((null==f||""===f)&&this._isRoundingLevelConcept(b)&&!this._hasValidGlobalDecimals()){const t=this._findFactValueForField(e,n,i);null!=t&&""!==t&&(f=t)}if((null==f||""===f)&&this._effectiveMasterData){const e=null==(s=this._effectiveMasterData)?void 0:s[b];null!=e&&""!==e&&(f=e,console.warn(` 📦 [Submission] Using masterData for: ${b} [${n.columnId}] = ${JSON.stringify(f)}`))}if(null!=f&&""!==f){const s=this._findColumnByIdInSection(n.columnId,i),m=null==(l=this._periodData[e.id])?void 0:l[n.columnId],b={conceptId:e.id,draftInstanceId:e.id,columnId:n.columnId,value:f,period:{type:e.periodType||"duration"}};if("instant"===e.periodType){const t=this._resolveSubmissionInstantDate(e,n,m,s);b.period.date=t}else{const e=(null==m?void 0:m.startDate)||(null==s?void 0:s.periodStartDate)||n.periodStartDate||this.periodStartDate,t=(null==m?void 0:m.endDate)||(null==s?void 0:s.periodEndDate)||n.periodEndDate||this.periodEndDate;b.period.startDate=e,b.period.endDate=t}console.log(`🔍 [Submission] Concept: ${e.id}, Column: ${n.columnId}, Field Period: ${m?JSON.stringify(m):"none"}, Column Period: ${(null==s?void 0:s.periodStartDate)||"none"} - ${(null==s?void 0:s.periodEndDate)||"none"}, Used Period: ${"instant"===b.period.type?b.period.date:`${b.period.startDate} - ${b.period.endDate}`}`);const g=null==(a=this._unitData[e.id])?void 0:a[n.columnId];g?(b.unit=g,console.log(`✅ [Submission] Adding unit to entry: ${g} for ${e.id}/${n.columnId}`)):console.log(`⚠️ [Submission] No unit found in _unitData for ${e.id}/${n.columnId}. _unitData state:`,JSON.stringify(this._unitData,null,2));const v=null==(d=e.type)?void 0:d.toLowerCase().includes("monetary"),y=(null==(c=this._decimalsData[e.id])?void 0:c[n.columnId])||("INF"!==this.decimals?this.decimals:void 0);if(v&&y){const e=parseFloat(y);b.decimals=isNaN(e)?y:String(-Math.abs(e))}if("dimension"===(null==s?void 0:s.type)&&(null==(p=s.dimensionData)?void 0:p.dimensionIdKey)?(b.dimension=s.dimensionData.dimensionIdKey,console.log(`🔍 [DynamicForm] Using dimension key from field's column (${n.columnId}):`,s.dimensionData.dimensionIdKey)):console.log(`🔍 [DynamicForm] No dimension data found for field column ${n.columnId}. Column type: ${null==s?void 0:s.type}, has dimensionData: ${!!(null==s?void 0:s.dimensionData)}`),this._typedMemberData[n.columnId]){const t=this._getApplicableTypedDimensions(e,i);if(console.log(`🔍 [DynamicForm] Concept ${e.id} applicable typed dimensions:`,t),t.length>0){const e={},o=this._typedMemberData[n.columnId];t.forEach(t=>{if(o[t]){const r=this._getTypedMemberNameForAxis(t,i);e[t]={value:o[t],memberName:r||"Unknown"}}}),Object.keys(e).length>0?(b.typedMembers=e,console.log("🔍 [DynamicForm] Adding filtered typed members to submission:",e)):console.log("🔍 [DynamicForm] No typed member values found for applicable dimensions:",t)}else console.log(`🔍 [DynamicForm] Skipping typed members for concept ${e.id} - not applicable to this hypercube`)}else console.log(`🔍 [DynamicForm] No typed member data found for column ${n.columnId}. Available columns:`,Object.keys(this._typedMemberData)),s&&console.log("🔍 [DynamicForm] Column details:",{id:s.id,type:s.type,hasTypedMembers:null==(h=s.dimensionData)?void 0:h.hasTypedMembers,dimensionData:s.dimensionData});if(!b.typedMembers&&(null==(u=n.crossRoleTypedMembers)?void 0:u.length)){const t=`${e.id}__${n.columnId}`,i=this._typedMemberData[t];if(i){const t={};n.crossRoleTypedMembers.forEach(e=>{const o=i[e.axisId];null!=o&&""!==o&&(t[e.axisId]={value:o,memberName:e.typedMemberId})}),Object.keys(t).length>0&&(b.typedMembers=t,console.log(`🔍 [Submission] Adding cross-role typed members for ${e.id}/${n.columnId}:`,t))}}r===o&&console.warn("[DUPLICATE DEBUG] Final submission entry:",b),t.push(b)}});const n=this._repeatCounts[e.id]||0;if(n>0&&e.fields.some(e=>{var t;return null==(t=e.crossRoleTypedMembers)?void 0:t.length}))for(let o=1;o<=n;o++){const r=`${e.id}__repeat_${o}`;e.fields.forEach(o=>{var n,s,l,a,d;const c=null==(n=this._formData[r])?void 0:n[o.columnId];if(null==c||""===c)return;const p=this._findColumnByIdInSection(o.columnId,i),h=null==(s=this._periodData[r])?void 0:s[o.columnId],u={conceptId:e.id,draftInstanceId:r,columnId:o.columnId,value:c,period:{type:e.periodType||"duration"}};"instant"===e.periodType?u.period.date=this._resolveSubmissionInstantDate(e,o,h,p):(u.period.startDate=(null==h?void 0:h.startDate)||(null==p?void 0:p.periodStartDate)||o.periodStartDate||this.periodStartDate,u.period.endDate=(null==h?void 0:h.endDate)||(null==p?void 0:p.periodEndDate)||o.periodEndDate||this.periodEndDate);const m=null==(l=this._unitData[r])?void 0:l[o.columnId];if(m&&(u.unit=m),"dimension"===(null==p?void 0:p.type)&&(null==(a=p.dimensionData)?void 0:a.dimensionIdKey)&&(u.dimension=p.dimensionData.dimensionIdKey),null==(d=o.crossRoleTypedMembers)?void 0:d.length){const e=`${r}__${o.columnId}`,t=this._typedMemberData[e];if(t){const e={};o.crossRoleTypedMembers.forEach(i=>{const o=t[i.axisId];null!=o&&""!==o&&(e[i.axisId]={value:o,memberName:i.typedMemberId})}),Object.keys(e).length>0&&(u.typedMembers=e)}}t.push(u)})}}e.children&&this._processConceptsForSubmission(e.children,t,i)})}_handleReset(){this._formData={...this.initialData},this._touched.clear(),this._dirty=!1,this._submitted=!1,this._preservedFormData={},this._preservedTypedMemberData={},console.log("🔄 Form reset - all data and preserved data cleared"),this._validateForm(),this.requestUpdate(),this.dispatchEvent(new CustomEvent("form-reset",{detail:{},bubbles:!0}))}_getFormState(){return{data:this._formData,errors:this._errors,touched:this._touched,dirty:this._dirty,valid:this._valid,submitted:this._submitted}}_analyzeAllVisibleRoles(){if(this._currentSchema&&this._currentSchema.sections&&0!==this._currentSchema.sections.length){console.log(`🔍 Analyzing ${this._currentSchema.sections.length} visible roles for initial border status...`);for(const e of this._currentSchema.sections)this._analyzeAndLogRole(e.id);console.log("✅ Initial border status analysis complete for all visible roles")}else console.log("⏭️ No sections to analyze for initial border status")}_handleRoleContextMenu(e,t,i){e.preventDefault(),e.stopPropagation(),this._contextMenuX=e.clientX,this._contextMenuY=e.clientY,this._contextMenuRoleId=t,this._showRoleContextMenu=!0,console.log(`🖱️ Context menu opened for role: ${i} (ID: ${t})`),this.requestUpdate()}_closeRoleContextMenu(){this._showRoleContextMenu=!1,this._contextMenuRoleId=null,this.requestUpdate()}_handleRemoveRole(){if(!this._contextMenuRoleId)return void this._closeRoleContextMenu();const e=this._allSections.find(e=>e.id===this._contextMenuRoleId),t=(null==e?void 0:e.title)||"Unknown";if(console.log("🗑️ Removing role from side panel:"),console.log(` - Role ID: ${this._contextMenuRoleId}`),console.log(` - Role Title: ${t}`),Array.isArray(this._selectedRoleIds)&&(this._selectedRoleIds.length>0&&"object"==typeof this._selectedRoleIds[0]?this._selectedRoleIds=this._selectedRoleIds.filter(e=>e.roleId!==this._contextMenuRoleId):this._selectedRoleIds=this._selectedRoleIds.filter(e=>e!==this._contextMenuRoleId)),console.log(`✅ Role removed from _selectedRoleIds. Remaining roles: ${this._selectedRoleIds.length}`),this._activeSidePanelRoleId===this._contextMenuRoleId){const e=this._getRoleIdsArray();this._activeSidePanelRoleId=e.length>0?e[0]:null,console.log(`📌 Active role changed to: ${this._activeSidePanelRoleId||"None"}`)}this._applyRoleFilter(),this.dispatchEvent(new CustomEvent("role-removed",{detail:{roleId:this._contextMenuRoleId,roleTitle:t,remainingRolesCount:this._selectedRoleIds.length},bubbles:!0,composed:!0})),console.log(`✅ Role "${t}" successfully removed from side panel`),console.log("ℹ️ User can re-add this role using the Filter Roles dialog"),this._closeRoleContextMenu()}_handleRoleCompletedChange(e,t){t?this._roleCompletedStates.set(e,!0):this._roleCompletedStates.delete(e),this._roleCompletedStates=new Map(this._roleCompletedStates),this._handleSaveDraft("auto")}_handleSidePanelRoleClick(e){this._activeSidePanelRoleId&&this._activeSidePanelRoleId!==e&&this._analyzeAndLogRole(this._activeSidePanelRoleId),this._activeSidePanelRoleId=e}_analyzeAndLogRole(e){const t=this._allSections.find(t=>t.id===e);if(!t)return void console.warn(`⚠️ Section not found for roleId: ${e}`);console.warn("\n========================================"),console.warn(`🔍 ANALYZING ROLE: "${t.title}"`),console.warn("========================================"),this.masterData?console.warn("📦 masterData keys:",Object.keys(this.masterData)):console.warn("📦 masterData: NOT PROVIDED");const i=[];this._collectAllFields(t.concepts||[],new Set((t.columns||[]).map(e=>e.id)),t.columns||[],i);const o=this._roleHasErrors(e),r=i.filter(e=>e.isEmpty).length,n=i.filter(e=>!e.isEmpty).length;let s;console.warn("\n📈 SUMMARY:"),console.warn(` Total Fields: ${i.length}`),console.warn(` Filled: ${n}`),console.warn(` Empty: ${r}`),console.warn(` Has Errors: ${o}`),o?(s="INVALID",console.warn("\n🔴 RESULT: INVALID (contains validation errors)")):0===n?(s="UNTOUCHED",console.warn("\n⬜ RESULT: UNTOUCHED (no data entered)")):r>0?(s="INCOMPLETE",console.warn(`\n🟠 RESULT: INCOMPLETE (${r} field(s) blank)`)):(s="COMPLETE",console.warn("\n🟢 RESULT: COMPLETE (all fields filled)")),console.warn("========================================\n"),"INVALID"===s||("UNTOUCHED"===s?(this._roleBorderStatuses.set(e,"untouched"),this._roleBorderStatuses=new Map(this._roleBorderStatuses)):"INCOMPLETE"===s?(this._roleBorderStatuses.set(e,"incomplete"),this._roleBorderStatuses=new Map(this._roleBorderStatuses)):(this._roleBorderStatuses.set(e,"complete"),this._roleBorderStatuses=new Map(this._roleBorderStatuses)))}_collectAllFields(e,t,i,o){var r,n,s;for(const l of e)if(l.abstract)l.children&&l.children.length>0&&this._collectAllFields(l.children,t,i,o);else{if(l.fields&&l.fields.length>0){const e=l.fields.filter(e=>t.has(e.columnId));for(const t of e){const e=l.id,a=t.conceptId;let d=null==(r=this._formData[e])?void 0:r[t.columnId];void 0===d&&e!==a&&(d=null==(n=this._formData[a])?void 0:n[t.columnId]);const c=null==(s=this._effectiveMasterData)?void 0:s[a];(null==d||"string"==typeof d&&""===d.trim())&&void 0!==c&&(d=c,console.warn(` 📦 Using masterData value for: ${a} [${t.columnId}] = ${JSON.stringify(d)}`));let p=null==d||"string"==typeof d&&""===d.trim();if(p&&l.facts&&l.facts.length>0){const e=i.find(e=>e.id===t.columnId),o={conceptId:a,columnId:t.columnId,periodStartDate:t.periodStartDate||(null==e?void 0:e.periodStartDate),periodEndDate:t.periodEndDate||(null==e?void 0:e.periodEndDate),periodInstantDate:t.periodInstantDate||("instant"===t.periodType?t.periodEndDate||t.periodStartDate:void 0),periodType:t.periodType,dimensionData:null==e?void 0:e.dimensionData},r=E.findMatchingFact(l.facts,o);r&&null!==r.value&&void 0!==r.value&&""!==r.value&&(d=r.value,p=!1)}o.push({conceptId:a,columnId:t.columnId,value:d,isEmpty:p})}}l.children&&l.children.length>0&&this._collectAllFields(l.children,t,i,o)}}_handleSidePanelSearchInput(e){const t=e.target;this._sidePanelSearchQuery=t.value}_clearSidePanelSearch(){var e;this._sidePanelSearchQuery="";const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".side-panel-search-input");t&&(t.value="",t.focus())}_toggleSidePanelCollapse(){this._sidePanelCollapsed=!this._sidePanelCollapsed}_isSectionBlank(e){const t=e.columns||this._columns,i=e=>{var o;for(const r of e){if(!r.abstract)for(const e of t){const t=null==(o=this._formData[r.id])?void 0:o[e.id];if(null!=t&&""!==t)return!0}if(r.children&&r.children.length>0&&i(r.children))return!0}return!1};return!i(e.concepts)}_getConceptSearchMatchIds(e){var t,i,o;const r=new Set;if(!e.trim()||!(null==(i=null==(t=this.xbrlInput)?void 0:t.presentation)?void 0:i.length))return r;const n=e.toLowerCase().trim(),s=e=>{var t;for(const i of e)r.add(i.id),(null==(t=i.children)?void 0:t.length)&&s(i.children)},l=e=>{var t,i,o,a;for(const d of e){let e=(null==(t=d.conceptName)?void 0:t.toLowerCase().includes(n))||(null==(i=d.id)?void 0:i.toLowerCase().includes(n));!e&&Array.isArray(d.labels)&&(e=d.labels.some(e=>{var t;return null==(t=e.label)?void 0:t.toLowerCase().includes(n)})),e?(r.add(d.id),(null==(o=d.children)?void 0:o.length)&&s(d.children)):(null==(a=d.children)?void 0:a.length)&&l(d.children)}};for(const a of this.xbrlInput.presentation)for(const e of a.roles||[])l((null==(o=e.presentationLinkbase)?void 0:o.concepts)||[]);return r}_isSectionConceptSearchMatch(e,t){if(0===t.size)return!1;const i=e=>{var o;for(const r of e){if(t.has(r.originalConceptId))return!0;if((null==(o=r.children)?void 0:o.length)&&i(r.children))return!0}return!1};return i(e.concepts)}_filterSidePanelSections(e){if(!this._sidePanelSearchQuery.trim())return e;const t=this._sidePanelSearchQuery.toLowerCase().trim();return e.filter(e=>{var i,o,r;const n=e.title.toLowerCase().includes(t),s=e.id.toLowerCase().includes(t),l=(null==(i=e.description)?void 0:i.toLowerCase().includes(t))||!1,a=(null==(r=null==(o=e.metadata)?void 0:o.roleURI)?void 0:r.toLowerCase().includes(t))||!1;return n||s||l||a})}_renderAdminModeContent(t){var i,o;if(!t)return e.html`
|
|
3109
|
+
`,Le([w({type:Boolean,reflect:!0})],exports.JupiterFilterRolesDialog.prototype,"open",2),Le([w({type:Array})],exports.JupiterFilterRolesDialog.prototype,"availableRoles",2),Le([w({type:Array})],exports.JupiterFilterRolesDialog.prototype,"selectedRoleIds",2),Le([w({type:Object})],exports.JupiterFilterRolesDialog.prototype,"periodPreferences",2),Le([w({type:String})],exports.JupiterFilterRolesDialog.prototype,"mode",2),Le([w({type:Object})],exports.JupiterFilterRolesDialog.prototype,"hypercubeData",2),Le([w({type:Boolean})],exports.JupiterFilterRolesDialog.prototype,"showFactsOnly",2),Le([w({type:String})],exports.JupiterFilterRolesDialog.prototype,"conceptSearchText",2),Le([S()],exports.JupiterFilterRolesDialog.prototype,"_tempSelectedRoles",2),Le([S()],exports.JupiterFilterRolesDialog.prototype,"_searchQuery",2),Le([S()],exports.JupiterFilterRolesDialog.prototype,"_filteredRoles",2),Le([S()],exports.JupiterFilterRolesDialog.prototype,"_tempPeriodPreferences",2),Le([S()],exports.JupiterFilterRolesDialog.prototype,"_selectedAvailableRole",2),Le([S()],exports.JupiterFilterRolesDialog.prototype,"_selectedChosenRole",2),Le([S()],exports.JupiterFilterRolesDialog.prototype,"_chosenSearchQuery",2),Le([S()],exports.JupiterFilterRolesDialog.prototype,"_draggedRoleId",2),Le([S()],exports.JupiterFilterRolesDialog.prototype,"_dragOverRoleId",2),Le([S()],exports.JupiterFilterRolesDialog.prototype,"_chosenRoleOrder",2),Le([S()],exports.JupiterFilterRolesDialog.prototype,"_showAdvancedFilter",2),Le([S()],exports.JupiterFilterRolesDialog.prototype,"_showFactsOnly",2),Le([S()],exports.JupiterFilterRolesDialog.prototype,"_conceptSearchText",2),Le([S()],exports.JupiterFilterRolesDialog.prototype,"_collapsedRoles",2),exports.JupiterFilterRolesDialog=Le([t("jupiter-filter-roles-dialog")],exports.JupiterFilterRolesDialog);var Ve=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,ze=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?Oe(t,i):t,a=e.length-1;a>=0;a--)(r=e[a])&&(n=(o?r(t,i,n):r(n))||n);return o&&n&&Ve(t,i,n),n};exports.JupiterFormulaValidationDialog=class extends e.LitElement{constructor(){super(...arguments),this.results=[],this.open=!1,this._collapsedGroups=new Set,this._boundHandleKeydown=this._handleKeydown.bind(this)}connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",this._boundHandleKeydown)}disconnectedCallback(){window.removeEventListener("keydown",this._boundHandleKeydown),super.disconnectedCallback()}_handleKeydown(e){this.open&&"Escape"===e.key&&this._handleClose()}_handleClose(){this.open=!1,this.dispatchEvent(new CustomEvent("dialog-cancel",{bubbles:!0}))}_toggleGroup(e){this._collapsedGroups.has(e)?this._collapsedGroups.delete(e):this._collapsedGroups.add(e),this.requestUpdate()}_handleConceptLinkClick(e){this.dispatchEvent(new CustomEvent("formula-concept-click",{detail:{conceptId:e.conceptId,conceptQName:e.conceptQName,columnId:e.columnId},bubbles:!0,composed:!0}))}_renderMessage(t){const i=t.message??"",o=new Map((t.conceptLinks??[]).map(e=>[e.label,e])),r=i.split(/(`[^`]+`)/g);return e.html`${r.map(t=>{const i=/^`([^`]+)`$/.exec(t);if(!i)return t;const r=o.get(i[1]);return r?e.html`<button type="button" class="concept-link" @click="${()=>this._handleConceptLinkClick(r)}">${i[1]}</button>`:i[1]})}`}_groupByRole(e){const t=e.reduce((e,t)=>{var i;return(e[i=t.roleLabel]??(e[i]=[])).push(t),e},{});return Object.entries(t)}render(){if(!this.open)return e.html``;const t=this.results.filter(e=>!e.skipped&&!e.satisfied),i=this._groupByRole(t),o=this.summary;return e.html`
|
|
3110
|
+
<div class="dialog" @click="${e=>e.stopPropagation()}">
|
|
3111
|
+
<div class="dialog-header">
|
|
3112
|
+
<h2 class="dialog-title">${T.t("formulaValidation.dialogTitle")}</h2>
|
|
3113
|
+
${o?e.html`
|
|
3114
|
+
<p class="dialog-summary">
|
|
3115
|
+
${T.t("formulaValidation.summaryCount",{failed:o.failed,total:o.totalAssertions})}
|
|
3116
|
+
${o.failed>0?e.html`— ${T.t("formulaValidation.summaryCountBreakdown",{warnings:o.failedWarnings,errors:o.failedErrors})}`:""}
|
|
3117
|
+
</p>
|
|
3118
|
+
`:""}
|
|
3119
|
+
</div>
|
|
3120
|
+
|
|
3121
|
+
<div class="dialog-content">
|
|
3122
|
+
${0===t.length?e.html`
|
|
3123
|
+
<div class="all-passed">
|
|
3124
|
+
<div class="all-passed-icon">✓</div>
|
|
3125
|
+
<div class="all-passed-text">${T.t("formulaValidation.allPassed")}</div>
|
|
3126
|
+
</div>
|
|
3127
|
+
`:i.map(([t,i])=>{const o=this._collapsedGroups.has(t);return e.html`
|
|
3128
|
+
<div class="role-group">
|
|
3129
|
+
<div class="role-group-header" @click="${()=>this._toggleGroup(t)}">
|
|
3130
|
+
<span class="role-group-title">${t}</span>
|
|
3131
|
+
<span class="role-group-count">${i.length}</span>
|
|
3132
|
+
<button class="role-group-toggle" type="button">${o?"▸":"▾"}</button>
|
|
3133
|
+
</div>
|
|
3134
|
+
${o?"":e.html`
|
|
3135
|
+
<div class="role-group-rows">
|
|
3136
|
+
${i.map(t=>e.html`
|
|
3137
|
+
<div class="assertion-row">
|
|
3138
|
+
<span class="severity-badge ${"ERROR"===t.severity?"error":"warning"}">
|
|
3139
|
+
${"ERROR"===t.severity?T.t("formulaValidation.severityError"):T.t("formulaValidation.severityWarning")}
|
|
3140
|
+
</span>
|
|
3141
|
+
<span class="assertion-message">${this._renderMessage(t)}</span>
|
|
3142
|
+
</div>
|
|
3143
|
+
`)}
|
|
3144
|
+
</div>
|
|
3145
|
+
`}
|
|
3146
|
+
</div>
|
|
3147
|
+
`})}
|
|
3148
|
+
</div>
|
|
3149
|
+
|
|
3150
|
+
<div class="dialog-actions">
|
|
3151
|
+
<button class="btn btn-primary" @click="${this._handleClose}">
|
|
3152
|
+
${T.t("formulaValidation.close")}
|
|
3153
|
+
</button>
|
|
3154
|
+
</div>
|
|
3155
|
+
</div>
|
|
3156
|
+
`}},exports.JupiterFormulaValidationDialog.styles=e.css`
|
|
3157
|
+
:host {
|
|
3158
|
+
position: fixed;
|
|
3159
|
+
top: 0;
|
|
3160
|
+
left: 0;
|
|
3161
|
+
width: 100%;
|
|
3162
|
+
height: 100%;
|
|
3163
|
+
background: rgba(0, 0, 0, 0.5);
|
|
3164
|
+
z-index: 1100;
|
|
3165
|
+
display: flex;
|
|
3166
|
+
align-items: center;
|
|
3167
|
+
justify-content: center;
|
|
3168
|
+
opacity: 0;
|
|
3169
|
+
visibility: hidden;
|
|
3170
|
+
transition: opacity 0.3s ease, visibility 0.3s ease;
|
|
3171
|
+
}
|
|
3172
|
+
|
|
3173
|
+
:host([open]) {
|
|
3174
|
+
opacity: 1;
|
|
3175
|
+
visibility: visible;
|
|
3176
|
+
}
|
|
3177
|
+
|
|
3178
|
+
.dialog {
|
|
3179
|
+
background: var(--bg-color-2, var(--jupiter-card-background, #fff));
|
|
3180
|
+
border-radius: 8px;
|
|
3181
|
+
padding: 24px;
|
|
3182
|
+
min-width: 420px;
|
|
3183
|
+
max-width: 640px;
|
|
3184
|
+
width: 90vw;
|
|
3185
|
+
max-height: 90vh;
|
|
3186
|
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
|
|
3187
|
+
transform: scale(0.9);
|
|
3188
|
+
transition: transform 0.3s ease;
|
|
3189
|
+
display: flex;
|
|
3190
|
+
flex-direction: column;
|
|
3191
|
+
}
|
|
3192
|
+
|
|
3193
|
+
:host([open]) .dialog {
|
|
3194
|
+
transform: scale(1);
|
|
3195
|
+
}
|
|
3196
|
+
|
|
3197
|
+
.dialog-header {
|
|
3198
|
+
margin-bottom: 16px;
|
|
3199
|
+
flex-shrink: 0;
|
|
3200
|
+
}
|
|
3201
|
+
|
|
3202
|
+
.dialog-title {
|
|
3203
|
+
font-size: 20px;
|
|
3204
|
+
font-weight: 600;
|
|
3205
|
+
color: var(--primaryTextColor, var(--jupiter-text-primary, #333));
|
|
3206
|
+
margin: 0 0 8px 0;
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3209
|
+
.dialog-summary {
|
|
3210
|
+
font-size: 14px;
|
|
3211
|
+
color: var(--jupiter-text-secondary, #666);
|
|
3212
|
+
margin: 0;
|
|
3213
|
+
}
|
|
3214
|
+
|
|
3215
|
+
/* JDF-035 dialog-overflow fix: min-height: 0 is required on a flex-column scrollable child,
|
|
3216
|
+
otherwise the browser lets it grow past the dialog's max-height instead of scrolling. */
|
|
3217
|
+
.dialog-content {
|
|
3218
|
+
margin-bottom: 20px;
|
|
3219
|
+
flex: 1;
|
|
3220
|
+
overflow-y: auto;
|
|
3221
|
+
min-height: 0;
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
.all-passed {
|
|
3225
|
+
display: flex;
|
|
3226
|
+
flex-direction: column;
|
|
3227
|
+
align-items: center;
|
|
3228
|
+
gap: 12px;
|
|
3229
|
+
padding: 32px 16px;
|
|
3230
|
+
color: var(--jupiter-text-primary, #333);
|
|
3231
|
+
}
|
|
3232
|
+
|
|
3233
|
+
.all-passed-icon {
|
|
3234
|
+
width: 40px;
|
|
3235
|
+
height: 40px;
|
|
3236
|
+
border-radius: 50%;
|
|
3237
|
+
background: var(--jupiter-success-color, #4caf50);
|
|
3238
|
+
color: #fff;
|
|
3239
|
+
display: flex;
|
|
3240
|
+
align-items: center;
|
|
3241
|
+
justify-content: center;
|
|
3242
|
+
font-size: 22px;
|
|
3243
|
+
font-weight: 700;
|
|
3244
|
+
}
|
|
3245
|
+
|
|
3246
|
+
.all-passed-text {
|
|
3247
|
+
font-size: 15px;
|
|
3248
|
+
font-weight: 500;
|
|
3249
|
+
}
|
|
3250
|
+
|
|
3251
|
+
.role-group {
|
|
3252
|
+
border: 1px solid var(--jupiter-border-color, #ddd);
|
|
3253
|
+
border-radius: 4px;
|
|
3254
|
+
margin-bottom: 12px;
|
|
3255
|
+
overflow: hidden;
|
|
3256
|
+
}
|
|
3257
|
+
|
|
3258
|
+
.role-group-header {
|
|
3259
|
+
display: flex;
|
|
3260
|
+
align-items: center;
|
|
3261
|
+
justify-content: space-between;
|
|
3262
|
+
gap: 8px;
|
|
3263
|
+
padding: 10px 12px;
|
|
3264
|
+
background: var(--jupiter-card-background, #fafafa);
|
|
3265
|
+
cursor: pointer;
|
|
3266
|
+
user-select: none;
|
|
3267
|
+
}
|
|
3268
|
+
|
|
3269
|
+
.role-group-title {
|
|
3270
|
+
font-weight: 600;
|
|
3271
|
+
font-size: 14px;
|
|
3272
|
+
color: var(--primaryTextColor, var(--jupiter-text-primary, #333));
|
|
3273
|
+
}
|
|
3274
|
+
|
|
3275
|
+
.role-group-count {
|
|
3276
|
+
font-size: 12px;
|
|
3277
|
+
color: var(--jupiter-text-secondary, #666);
|
|
3278
|
+
}
|
|
3279
|
+
|
|
3280
|
+
.role-group-toggle {
|
|
3281
|
+
background: none;
|
|
3282
|
+
border: none;
|
|
3283
|
+
cursor: pointer;
|
|
3284
|
+
font-size: 12px;
|
|
3285
|
+
color: var(--jupiter-text-secondary, #666);
|
|
3286
|
+
padding: 0 4px;
|
|
3287
|
+
}
|
|
3288
|
+
|
|
3289
|
+
.role-group-rows {
|
|
3290
|
+
padding: 4px 12px 8px 12px;
|
|
3291
|
+
}
|
|
3292
|
+
|
|
3293
|
+
.assertion-row {
|
|
3294
|
+
display: flex;
|
|
3295
|
+
align-items: flex-start;
|
|
3296
|
+
gap: 8px;
|
|
3297
|
+
padding: 8px 0;
|
|
3298
|
+
border-top: 1px solid var(--jupiter-border-color, #eee);
|
|
3299
|
+
}
|
|
3300
|
+
|
|
3301
|
+
.assertion-row:first-child {
|
|
3302
|
+
border-top: none;
|
|
3303
|
+
}
|
|
3304
|
+
|
|
3305
|
+
.severity-badge {
|
|
3306
|
+
flex-shrink: 0;
|
|
3307
|
+
display: inline-flex;
|
|
3308
|
+
align-items: center;
|
|
3309
|
+
gap: 4px;
|
|
3310
|
+
padding: 2px 8px;
|
|
3311
|
+
border-radius: 10px;
|
|
3312
|
+
font-size: 11px;
|
|
3313
|
+
font-weight: 700;
|
|
3314
|
+
color: #fff;
|
|
3315
|
+
white-space: nowrap;
|
|
3316
|
+
}
|
|
3317
|
+
|
|
3318
|
+
.severity-badge.warning {
|
|
3319
|
+
background: var(--jupiter-warning-color, #ff9800);
|
|
3320
|
+
}
|
|
3321
|
+
|
|
3322
|
+
.severity-badge.error {
|
|
3323
|
+
background: var(--jupiter-error-color, #d32f2f);
|
|
3324
|
+
}
|
|
3325
|
+
|
|
3326
|
+
.assertion-message {
|
|
3327
|
+
font-size: 13px;
|
|
3328
|
+
color: var(--primaryTextColor, var(--jupiter-text-primary, #333));
|
|
3329
|
+
line-height: 1.4;
|
|
3330
|
+
}
|
|
3331
|
+
|
|
3332
|
+
.concept-link {
|
|
3333
|
+
font: inherit;
|
|
3334
|
+
font-weight: 600;
|
|
3335
|
+
color: var(--buttonBgColor, var(--jupiter-primary-color, #1976d2));
|
|
3336
|
+
background: none;
|
|
3337
|
+
border: none;
|
|
3338
|
+
padding: 0;
|
|
3339
|
+
margin: 0;
|
|
3340
|
+
cursor: pointer;
|
|
3341
|
+
text-decoration: underline;
|
|
3342
|
+
text-underline-offset: 2px;
|
|
3343
|
+
}
|
|
3344
|
+
|
|
3345
|
+
.concept-link:hover {
|
|
3346
|
+
opacity: 0.8;
|
|
3347
|
+
}
|
|
3348
|
+
|
|
3349
|
+
.dialog-actions {
|
|
3350
|
+
display: flex;
|
|
3351
|
+
gap: 12px;
|
|
3352
|
+
justify-content: flex-end;
|
|
3353
|
+
flex-shrink: 0;
|
|
3354
|
+
border-top: 1px solid var(--jupiter-border-color, #ddd);
|
|
3355
|
+
padding-top: 16px;
|
|
3356
|
+
margin-top: 16px;
|
|
3357
|
+
}
|
|
3358
|
+
|
|
3359
|
+
.btn {
|
|
3360
|
+
padding: 10px 20px;
|
|
3361
|
+
border: none;
|
|
3362
|
+
border-radius: 4px;
|
|
3363
|
+
font-size: 14px;
|
|
3364
|
+
font-weight: 500;
|
|
3365
|
+
cursor: pointer;
|
|
3366
|
+
transition: background-color 0.2s ease;
|
|
3367
|
+
}
|
|
3368
|
+
|
|
3369
|
+
.btn-primary {
|
|
3370
|
+
background: var(--buttonBgColor, var(--jupiter-primary-color, #1976d2));
|
|
3371
|
+
color: var(--buttonTextColor, white);
|
|
3372
|
+
}
|
|
3373
|
+
|
|
3374
|
+
.btn-primary:hover {
|
|
3375
|
+
opacity: 0.9;
|
|
3376
|
+
}
|
|
3377
|
+
`,ze([w({type:Array})],exports.JupiterFormulaValidationDialog.prototype,"results",2),ze([w({type:Object})],exports.JupiterFormulaValidationDialog.prototype,"summary",2),ze([w({type:Boolean,reflect:!0})],exports.JupiterFormulaValidationDialog.prototype,"open",2),ze([S()],exports.JupiterFormulaValidationDialog.prototype,"_collapsedGroups",2),exports.JupiterFormulaValidationDialog=ze([t("jupiter-formula-validation-dialog")],exports.JupiterFormulaValidationDialog);var Ue=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Be=(e,t,i,o)=>{for(var r,n=o>1?void 0:o?Je(t,i):t,a=e.length-1;a>=0;a--)(r=e[a])&&(n=(o?r(t,i,n):r(n))||n);return o&&n&&Ue(t,i,n),n};exports.JupiterDynamicForm=class extends e.LitElement{constructor(){super(...arguments),this.config={},this.initialData={},this.disabled=!1,this.readonly=!1,this.calculationEnabled=!1,this.formulaEnabled=!1,this.periodStartDate="2025-01-01",this.periodEndDate="2025-12-31",this.language="en",this.reportingLanguage="en",this.display="accordion",this.mode="inputForm",this.roleFilterAxes=[],this.showLastValidationResultBtn=!1,this.isDraftSaving=!1,this.defaultUnits=[],this.decimals="INF",this._formData={},this._draftLoaded=!1,this._preservedFormData={},this._periodData={},this._preservedPeriodData={},this._unitData={},this._preservedUnitData={},this._decimalsData={},this._totalManuallyEditedData={},this._effectiveMasterData=void 0,this._typedMemberData={},this._preservedTypedMemberData={},this._repeatCounts={},this._hiddenColumnIds=new Map,this._columns=[],this._errors=[],this._touched=new Set,this._dirty=!1,this._valid=!0,this._submitted=!1,this._xbrlFormErrors=[],this._calculationWarnings=new Map,this._showErrorPopup=!1,this._submitDisabled=!1,this._allSections=[],this._selectedRoleIds=[],this._showFilterDialog=!1,this._showFactsOnly=!1,this._conceptSearchText="",this._periodPreferences={},this._activeSidePanelRoleId=null,this._sidePanelSearchQuery="",this._sidePanelCollapsed=!1,this._adminRoleConfigs={},this._roleBorderStatuses=new Map,this._roleCompletedStates=new Map,this._showRoleContextMenu=!1,this._contextMenuX=0,this._contextMenuY=0,this._contextMenuRoleId=null,this._validationStatus="idle",this._formulaValidationResults=[],this._showFormulaValidationDialog=!1,this._formulaValidationService=new de,this._skipDraftLoading=!1,this._skipPeriodPreferencesRestore=!1,this._autoSaveTimer=null,this._lastAutoSaveSnapshot="",this._lastSavedDraftSnapshot=""}connectedCallback(){super.connectedCallback(),this.addEventListener("period-change",e=>{console.log("🌍 [GLOBAL DynamicForm] Caught period-change event on element:",e);const t=e;console.log("🌍 [GLOBAL DynamicForm] Event detail:",t.detail),this._handlePeriodChange(t)}),this.addEventListener("unit-change",e=>{console.log("🏷️ [GLOBAL DynamicForm] Caught unit-change event on element:",e);const t=e;console.log("🏷️ [GLOBAL DynamicForm] Event detail:",t.detail),this._handleUnitChange(t)}),this.addEventListener("decimals-change",e=>{this._handleDecimalsChange(e)}),this.addEventListener("field-blur",e=>{console.log("🚨 [DynamicForm] field-blur event listener triggered!",e);const t=e;this._handleFieldBlur(t)}),this.addEventListener("calculation-mismatch-changed",e=>{this._handleCalculationMismatchChanged(e)}),this.addEventListener("total-manually-edited",e=>{const{conceptId:t,columnId:i}=e.detail,o={...this._totalManuallyEditedData};o[t]={...o[t],[i]:!0},this._totalManuallyEditedData=o}),this.addEventListener("calculation-total-auto-populated",e=>{const{conceptId:t,columnId:i,value:o}=e.detail,r=this._writeFormDataValue(t,i,o);this._touched.add(`${t}-${i}`),this._dirty=!0,this._validateForm(),this.requestUpdate(),this.dispatchEvent(new CustomEvent("field-change",{detail:{fieldId:t,conceptId:t,columnId:i,value:o,oldValue:r,source:"auto-calculated"},bubbles:!0}))}),document.addEventListener("click",()=>{this._showRoleContextMenu&&(this._showRoleContextMenu=!1,this.requestUpdate())}),this._autoSaveTimer=setInterval(()=>{const e=JSON.stringify(this._formData);if(""===this._lastAutoSaveSnapshot)return this._lastAutoSaveSnapshot=e,void console.log("ℹ️ [Auto Save] Baseline initialized; no draft save emitted.");e!==this._lastAutoSaveSnapshot?(this._lastAutoSaveSnapshot=e,this._handleSaveDraft("auto")):console.log("ℹ️ [Auto Save] No form state change detected; skipping draft save emit.")},3e4),this._initializeForm()}disconnectedCallback(){super.disconnectedCallback(),null!==this._autoSaveTimer&&(clearInterval(this._autoSaveTimer),this._autoSaveTimer=null)}updated(e){(e.has("decimals")||e.has("masterData"))&&this._computeEffectiveMasterData(),e.has("language")&&T.setLanguage(this.language),(e.has("xbrlInput")||e.has("defaultUnits"))&&this.xbrlInput&&this.defaultUnits&&this.defaultUnits.length>0&&this._applyDefaultUnitsToDatatypes(),(e.has("xbrlInput")||e.has("schema")||e.has("language")||e.has("periodStartDate")||e.has("periodEndDate")||e.has("roleFilterAxes"))&&this._initializeForm()}_applyDefaultUnitsToDatatypes(){var e;if(!(null==(e=this.xbrlInput)?void 0:e.datatypes)||!this.defaultUnits||0===this.defaultUnits.length)return;console.log("🔧 [DynamicForm] Applying defaultUnits to datatypes:",this.defaultUnits);const t=Array.isArray(this.xbrlInput.datatypes)?this.xbrlInput.datatypes:this.xbrlInput.datatypes.concepts;t&&0!==t.length?this.defaultUnits.forEach(e=>{Object.entries(e).forEach(([e,i])=>{const o=t.find(t=>t.type===e||t.id===e);if(o&&o.units&&o.units.length>0){const t=o.units.find(e=>e.id===i);t?(o.units.forEach(e=>e.isDefault=!1),t.isDefault=!0,console.log(`✅ [DynamicForm] Set isDefault=true for unit "${i}" in datatype "${e}"`)):console.warn(`⚠️ [DynamicForm] Unit "${i}" not found in datatype "${e}"`)}else console.warn(`⚠️ [DynamicForm] Datatype "${e}" not found or has no units`)})}):console.warn("⚠️ [DynamicForm] No datatypes found to apply defaults to")}_initializeForm(){var e;if(this._draftStorageService||(this._draftStorageService=new R(!1)),this.xbrlInput)try{if(console.log("🔄 Initializing form from XBRL input:",this.xbrlInput),console.log("📅 Using period dates:",this.periodStartDate,"to",this.periodEndDate),console.log("🌐 Using language:",this.language),this._initializePeriodPreferencesFromData(),this._applyAxisFilterToPeriodPreferences(),this._applyDimensionShowPreviousYear(),console.log("⚙️ Using period preferences:",this._periodPreferences),this._currentSchema=F.buildFormSchema(this.xbrlInput,this.periodStartDate,this.periodEndDate,this.language,this._periodPreferences),console.log("✅ Generated schema with sections:",this._currentSchema.sections.length),this._allSections=[...this._currentSchema.sections],Array.isArray(this._selectedRoleIds)&&this._selectedRoleIds.length>0&&"object"==typeof this._selectedRoleIds[0]){console.log("🔄 Applying custom role order to _allSections from _selectedRoleIds");const e=this._selectedRoleIds,t=new Map;e.forEach(e=>{t.set(e.roleId,e.order)}),this._allSections=[...this._allSections].sort((e,i)=>(t.get(e.id)??999)-(t.get(i.id)??999)),console.log("✅ Custom order applied to _allSections:",this._allSections.map(e=>e.title))}if(0===this._selectedRoleIds.length){const e=this.roleFilterAxes&&this.roleFilterAxes.length>0?this._filterRolesByAxisConfig(this._allSections):this._allSections;this._selectedRoleIds=e.map(e=>e.id),console.log(`✅ Auto-selected ${this._selectedRoleIds.length} roles (of ${this._allSections.length} total)`)}this._applyRoleFilter(),this._columns=[{id:"base",title:"Value",description:"Base values for concepts",type:"base",order:0,removable:!1}]}catch(t){console.error("❌ Error building form from XBRL input:",t),this._currentSchema=this._getDefaultSchema(),this._allSections=[],this._selectedRoleIds=[],this._columns=this._getDefaultColumns()}else this.schema?(this._currentSchema=this.schema,this._allSections=[...this.schema.sections],this._selectedRoleIds=this._allSections.map(e=>e.id),this._columns=this._getDefaultColumns()):(this._currentSchema=this._getDefaultSchema(),this._allSections=[],this._selectedRoleIds=[],this._columns=this._getDefaultColumns());this._formData={...this.initialData},(null==(e=this.xbrlInput)?void 0:e.initialData)&&(this._formData={...this._formData,...this.xbrlInput.initialData}),this._initializeGlobalDecimalsFromRoundingData(),this._extractTypedMembersFromFacts(),this._skipDraftLoading?(console.log("⏭️ Skipping draft loading during preference update"),this._analyzeAllVisibleRoles()):this._loadDraftIfExists().then(()=>{this._analyzeAllVisibleRoles()}).catch(()=>{this._analyzeAllVisibleRoles()}),this._validateForm()}_extractTypedMembersFromFacts(){var e;(null==(e=this._currentSchema)?void 0:e.sections)&&(this._currentSchema.sections.forEach(e=>{this._extractTypedMembersFromConcepts(e.concepts||[],e)}),console.log("✅ [DynamicForm] Typed member data populated:",this._typedMemberData))}_extractTypedMembersFromConcepts(e,t){e.forEach(e=>{e.facts&&e.facts.length>0&&(console.log(`🔍 [DynamicForm] Checking concept ${e.id} with ${e.facts.length} facts`),e.facts.forEach(i=>{if(i.dimensions&&Array.isArray(i.dimensions)){const o=i.dimensions.filter(e=>"typed"===e.dimensionType&&e.typedMemberValue);if(o.length>0){console.log(`📝 [DynamicForm] Found ${o.length} typed dimensions in fact:`,{factName:i.name,typedDimensions:o.map(e=>({dimension:e.dimension,typedMemberValue:e.typedMemberValue}))});const r=this._findColumnWithTypedMembers(i,e,t);r?(console.log(`✅ [DynamicForm] Found matching column: ${r.id}`),o.forEach(i=>{var o,n;const a=this._normalizeAxisId(i.dimension),s=null==(n=null==(o=r.dimensionData)?void 0:o.typedMembers)?void 0:n.find(e=>e.axisId===a||this._normalizeAxisId(e.axisId)===a);if(s){this._typedMemberData[r.id]||(this._typedMemberData[r.id]={});const o=s.axisId;this._typedMemberData[r.id][o]=i.typedMemberValue,console.log("✅ [DynamicForm] Set typed member value:",{sectionId:t.id,conceptId:e.id,columnId:r.id,axisKey:o,typedMemberValue:i.typedMemberValue})}else console.warn(`⚠️ [DynamicForm] Typed member not found for axis: ${a}`)})):console.warn("⚠️ [DynamicForm] No matching column found for fact with typed dimensions")}}})),e.children&&e.children.length>0&&this._extractTypedMembersFromConcepts(e.children,t)})}_findColumnWithTypedMembers(e,t,i){var o;if(!t.fields||0===t.fields.length)return null;const r=i.columns||[];if(0===r.length)return null;for(const n of t.fields){const t=r.find(e=>e.id===n.columnId);if(t&&(null==(o=t.dimensionData)?void 0:o.hasTypedMembers)){const i=(e.dimensions||[]).filter(e=>"explicit"===e.dimensionType),o=t.dimensionData.combinations||[];if(0===i.length||i.length===o.length&&i.every(e=>o.some(t=>this._normalizeAxisId(e.dimension)===this._normalizeAxisId(t.axisId)&&this._normalizeMemberId(e.member)===this._normalizeMemberId(t.memberId))))return t}}return null}_findColumnForFactDimensions(e,t,i){if(!t.fields||0===t.fields.length)return console.log(`⚠️ [DynamicForm] No fields for concept: ${t.id}`),null;const o=i.columns||[];if(0===o.length)return console.log(`⚠️ [DynamicForm] No columns in section: ${i.id}`),null;for(const r of t.fields){const t=o.find(e=>e.id===r.columnId);if(t&&t.dimensionData){const i=e.dimensions||[],o=t.dimensionData.combinations||[];console.log(`🔍 [DynamicForm] Checking column ${t.id}:`,{factDimensions:i.map(e=>({axis:e.dimension,member:e.member,type:e.dimensionType})),columnDimensions:o.map(e=>({axis:e.axisId,member:e.memberId}))});if(o.every(e=>i.some(t=>{const i=this._normalizeAxisId(t.dimension)===this._normalizeAxisId(e.axisId);if("explicit"===t.dimensionType){const o=this._normalizeMemberId(t.member)===this._normalizeMemberId(e.memberId);return i&&o}return"typed"===t.dimensionType&&i})))return t}}return null}_normalizeAxisId(e){return e?e.includes(":")?e.split(":").pop()||e:e.includes("_")&&e.split("_").pop()||e:""}_normalizeMemberId(e){return e?e.includes(":")?e.split(":").pop()||e:e.includes("_")&&e.split("_").pop()||e:""}_getDefaultSchema(){return{version:"1.0",formId:"default-form",title:"Dynamic Form",description:"Please provide form schema or XBRL input data",sections:[]}}_getDefaultColumns(){return[{id:"base",title:"Value",description:"Base values for concepts",type:"base",order:0,removable:!1}]}_initializePeriodPreferencesFromData(){var e,t,i;if(!(null==(i=null==(t=null==(e=this.xbrlInput)?void 0:e.presentation)?void 0:t[0])?void 0:i.roles))return;const o={...this._periodPreferences};this.xbrlInput.presentation[0].roles.forEach(e=>{if(!o[e.id]){const t=!0===e.showPreviousYear,i=void 0===e.instant||!0===e.instant,r=void 0===e.duration||!0===e.duration;o[e.id]={showDuration:r,showInstant:i,showPreviousYear:t}}}),this._periodPreferences=o}_applyAxisFilterToPeriodPreferences(){var e,t,i,o;if(!this.roleFilterAxes||0===this.roleFilterAxes.length)return;if(!(null==(i=null==(t=null==(e=this.xbrlInput)?void 0:e.hypercubes)?void 0:t[0])?void 0:i.roles))return;const r=this.xbrlInput.hypercubes[0].roles,n={...this._periodPreferences};for(const a of r){const e=a.roleId,t=n[e];if((null==t?void 0:t.dimensionSelections)&&t.dimensionSelections.length>0)continue;const i=[];for(const r of this.roleFilterAxes)for(const e of a.items||[]){if(null==(o=e.dimensions)?void 0:o.find(e=>e.id===r.id||r.conceptName&&e.conceptName===r.conceptName)){i.push({dimensionId:r.id,dimensionLabel:r.conceptName||r.id,selectedMemberIds:r.members.filter(e=>!0===e.available).map(e=>e.id)});break}}i.length>0&&(n[e]={showDuration:(null==t?void 0:t.showDuration)??!0,showInstant:(null==t?void 0:t.showInstant)??!0,showPreviousYear:(null==t?void 0:t.showPreviousYear)??!1,dimensionSelections:i})}this._periodPreferences=n}_applyDimensionShowPreviousYear(){var e,t;if("admin"!==this.mode)return;const i=!(!this.dynaformsFacts||!this.dynaformsMetadata),o=(null==(e=this._draftStorageService)?void 0:e.hasDraft())??!1;if(i||o)return;const r={...this._periodPreferences};let n=!1;for(const a of Object.keys(r)){const e=r[a];if(e.showPreviousYear)continue;((null==(t=e.dimensionSelections)?void 0:t.some(e=>e.selectedMemberIds&&e.selectedMemberIds.length>0))??!1)&&(r[a]={...e,showPreviousYear:!0},n=!0,console.log(`📅 [JDF-010] Auto-enabled showPreviousYear for role "${a}" (has dimension members)`))}n&&(this._periodPreferences=r)}_getRoleIdsArray(){return Array.isArray(this._selectedRoleIds)&&0!==this._selectedRoleIds.length?"string"==typeof this._selectedRoleIds[0]?this._selectedRoleIds:this._selectedRoleIds.map(e=>e.roleId):[]}_applyRoleFilter(){if(!this._currentSchema||!this._allSections.length)return;const e=this._getRoleIdsArray();if(console.log(`🔍 Applying role filter: ${e.length} selected out of ${this._allSections.length} total`),0===e.length)return console.log("📝 No roles selected - showing empty form"),this._currentSchema={...this._currentSchema,sections:[]},void this.requestUpdate();this._preserveDataForHiddenSections();const t=this._allSections.filter(t=>e.includes(t.id)),i=this._sortSectionsByCustomOrder(t);console.log(`📊 Filtered sections: ${i.length}`),console.log("📋 Custom order applied:",i.map(e=>e.title)),this._restoreDataForVisibleSections(i),this._currentSchema={...this._currentSchema,sections:i},console.log(`✅ Schema updated with custom order. Current sections count: ${this._currentSchema.sections.length}`),this.requestUpdate()}_sortSectionsByCustomOrder(e){if(Array.isArray(this._selectedRoleIds)&&this._selectedRoleIds.length>0&&"object"==typeof this._selectedRoleIds[0]){const t=this._selectedRoleIds,i=new Map;return t.forEach(e=>{i.set(e.roleId,e.order)}),[...e].sort((e,t)=>(i.get(e.id)??999)-(i.get(t.id)??999))}return e}_filterRolesByAxisConfig(e){var t;if(!this.roleFilterAxes||0===this.roleFilterAxes.length)return e;if(!(null==(t=this.xbrlInput)?void 0:t.hypercubes)||0===this.xbrlInput.hypercubes.length)return e;const i=this.xbrlInput.hypercubes[0];return e.filter(e=>{var t;const o=null==(t=i.roles)?void 0:t.find(t=>t.roleId===e.id);if(!o||!o.items||0===o.items.length)return!0;for(const i of this.roleFilterAxes){const e=new Set(i.members.filter(e=>!0===e.available).map(e=>e.id));let t=!1,r=!1;for(const n of o.items){if(!n.dimensions||0===n.dimensions.length)continue;const o=n.dimensions.find(e=>e.id===i.id||i.conceptName&&e.conceptName===i.conceptName);if(o){if(t=!0,o.members)for(const t of o.members)if(e.has(t.id)){r=!0;break}if(r)break}}if(t&&!r)return!1}return!0})}_preserveDataForHiddenSections(){var e;const t=(null==(e=this._currentSchema)?void 0:e.sections.map(e=>e.id))||[],i=this._getRoleIdsArray();t.filter(e=>!i.includes(e)).forEach(e=>{const t=this._allSections.find(t=>t.id===e);t&&this._preserveSectionData(t)})}_restoreDataForVisibleSections(e){e.forEach(e=>{this._restoreSectionData(e)}),console.log(`🔄 Restored data for ${e.length} visible sections`)}_preserveSectionData(e){e.concepts.forEach(e=>{this._preserveConceptData(e)})}_preserveConceptData(e){this._formData[e.id]&&(this._preservedFormData[e.id]={...this._formData[e.id]}),e.fields.forEach(t=>{this._typedMemberData[t.columnId]&&(this._preservedTypedMemberData[t.columnId]={...this._typedMemberData[t.columnId]});const i=`${e.id}__${t.columnId}`;this._typedMemberData[i]&&(this._preservedTypedMemberData[i]={...this._typedMemberData[i]})}),e.children&&e.children.forEach(e=>{this._preserveConceptData(e)})}_restoreSectionData(e){e.concepts.forEach(e=>{this._restoreConceptData(e)})}_restoreConceptData(e){this._preservedFormData[e.id]&&(this._formData[e.id]={...this._preservedFormData[e.id]}),e.fields.forEach(t=>{this._preservedTypedMemberData[t.columnId]&&(this._typedMemberData[t.columnId]={...this._preservedTypedMemberData[t.columnId]});const i=`${e.id}__${t.columnId}`;this._preservedTypedMemberData[i]&&(this._typedMemberData[i]={...this._preservedTypedMemberData[i]})}),e.children&&e.children.forEach(e=>{this._restoreConceptData(e)})}_shouldShowFilterButton(){return!0}get _hasActiveAdvancedFilters(){return this._showFactsOnly||this._conceptSearchText.trim().length>0}_handleClearAdvancedFilters(){this._showFactsOnly=!1,this._conceptSearchText=""}_handleFilterRolesClick(){this._showFilterDialog=!0}_handleAdvancedFilterApply(e){this._showFactsOnly=e.detail.showFactsOnly,this._conceptSearchText=e.detail.conceptSearchText??"",this._showFilterDialog=!1}_handleFilterDialogCancel(){this._showFilterDialog=!1;const e=this._getRoleIdsArray().length;console.log(`🚫 Filter dialog cancelled. Current selection: ${e}/${this._allSections.length}`)}_handleFormulaValidationDialogCancel(){this._showFormulaValidationDialog=!1}_handleFormulaConceptClick(e){this._showFormulaValidationDialog=!1,this.scrollToConcept(e.detail.conceptQName,void 0,void 0,e.detail.columnId)}_handleRoleFilterApply(e){var t,i;const{selectedRoleIds:o,periodPreferences:r}=e.detail;console.log("🎯 Filter apply triggered"),console.log("📊 Old _selectedRoleIds:",this._selectedRoleIds),console.log("📊 New selectedRoleIds from dialog:",o),this._selectedRoleIds=o,this._periodPreferences=r,console.log("📊 Updated _selectedRoleIds:",this._selectedRoleIds),console.log("📊 New period preferences (including dimension selections):",this._periodPreferences),console.log("💾 Capturing current form data before reinitialization...");const n=this._generateSubmissionData(),a=this._draftStorageService.createMetadataSnapshot(this.periodStartDate,this.periodEndDate,this.language,this._selectedRoleIds,this._allSections,this._typedMemberData,this._periodPreferences,this._periodData,this._unitData,this.reportingLanguage,this._repeatCounts,this._decimalsData,void 0,this._getHiddenColumnsForMetadata(),this._totalManuallyEditedData);this._draftStorageService.saveDraft(n,a),console.log("✅ Current form data saved to draft storage with NEW preferences"),this.dynaformsFacts=n,this.dynaformsMetadata=a,this._skipPeriodPreferencesRestore=!0,this._skipDraftLoading=!0,console.log("🔄 Reinitializing form with new filter settings..."),this._initializeForm(),this._skipDraftLoading=!1,this._skipPeriodPreferencesRestore=!1,console.log("📊 After _initializeForm, _currentSchema.sections.length:",null==(t=this._currentSchema)?void 0:t.sections.length),console.log("📊 Section IDs:",null==(i=this._currentSchema)?void 0:i.sections.map(e=>e.id)),console.log("📥 Restoring form data from draft after reinitialization..."),this._loadDraftIfExists().then(()=>{console.log("✅ Form data restored successfully after reinitialization")}).catch(e=>{console.error("❌ Error restoring form data after reinitialization:",e)}),this._showFilterDialog=!1;const s=Array.isArray(this._selectedRoleIds)&&this._selectedRoleIds.length>0?(this._selectedRoleIds[0],this._selectedRoleIds.length):0;console.log(`🎯 Applied role filter: ${s}/${this._allSections.length} roles selected`),console.log("📋 Enhanced selectedRoleIds structure:",this._selectedRoleIds),this.dispatchEvent(new CustomEvent("roles-filter-changed",{detail:{selectedRoleIds:o,totalRoles:this._allSections.length,visibleRoles:s,periodPreferences:r},bubbles:!0}))}_haveDimensionSelectionsChanged(e){var t;const i=new Set([...Object.keys(this._periodPreferences||{}),...Object.keys(e||{})]);for(const o of i){const i=null==(t=this._periodPreferences)?void 0:t[o],r=null==e?void 0:e[o],n=(null==i?void 0:i.dimensionSelections)||[],a=(null==r?void 0:r.dimensionSelections)||[];if(JSON.stringify(n.sort((e,t)=>e.dimensionId.localeCompare(t.dimensionId)))!==JSON.stringify(a.sort((e,t)=>e.dimensionId.localeCompare(t.dimensionId))))return console.log(`🔍 Dimension selection changed for role: ${o}`),console.log(" Old:",n),console.log(" New:",a),!0}return!1}_validateForm(){var e;const t=[],i=this._currentSchema;if(i){for(const o of i.sections)for(const i of o.concepts)for(const o of i.fields){const r=null==(e=this._formData[i.id])?void 0:e[o.columnId],n=C.validateField(o.id,i.id,o.columnId,r,o.type,o.validation||[]);t.push(...n)}t.push(...Array.from(this._calculationWarnings.values())),this._errors=t,this._valid=0===t.filter(e=>"error"===e.severity).length}}_handleCalculationMismatchChanged(e){const{key:t,mismatch:i}=e.detail,o=new Map(this._calculationWarnings);i?o.set(t,{fieldId:`${i.totalConceptId}__${i.columnId}`,conceptId:i.totalConceptId,columnId:i.columnId,message:i.message,severity:"warning",rule:{type:"custom",message:i.message,severity:"warning"},details:i}):o.delete(t),this._calculationWarnings=o,this._validateForm()}_writeFormDataValue(e,t,i){const o={...this._formData};o[e]||(o[e]={});const r=o[e][t];return o[e]={...o[e],[t]:i},this._formData=o,r}_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._writeFormDataValue(i,o,r);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:n},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:a,unit:s}=e.detail;console.log(`📅 Period change received: conceptId=${t}, columnId=${i}, periodType=${o}, startDate=${r}, endDate=${n}, instantDate=${a}, unit=${s}`);const l={...this._periodData};l[t]||(l[t]={}),l[t]={...l[t],[i]:{startDate:r,endDate:n,instantDate:a}},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)),s&&this._storeUnit(t,i,s),this._dirty=!0,this.requestUpdate()}_handleUnitChange(e){console.log("🏷️ [DynamicForm] _handleUnitChange called with event:",e),console.log("🏷️ [DynamicForm] Event detail:",e.detail);const{conceptId:t,columnId:i,unit:o}=e.detail;console.log(`🏷️ Unit change received: conceptId=${t}, columnId=${i}, unit=${o}`),this._storeUnit(t,i,o),this._dirty=!0,this.requestUpdate()}_storeUnit(e,t,i){console.log(`🔧 [_storeUnit] Called with conceptId=${e}, columnId=${t}, unit=${i}`),console.log("🔧 [_storeUnit] Current _unitData before update:",JSON.stringify(this._unitData,null,2));const o={...this._unitData};o[e]||(console.log(`🔧 [_storeUnit] Creating new entry for conceptId: ${e}`),o[e]={}),o[e]={...o[e],[t]:i},this._unitData=o,console.log(`💾 [_storeUnit] Unit data stored for [${e}][${t}]:`,this._unitData[e][t]),console.log("📦 [_storeUnit] Full unit data state after update:",JSON.stringify(this._unitData,null,2))}_handleDecimalsChange(e){const{conceptId:t,columnId:i,decimals:o}=e.detail;t&&i&&(this._storeDecimals(t,i,o),this._dirty=!0,this.requestUpdate())}_computeEffectiveMasterData(){const e="rj-i_DocumentIntendedRoundingLevel";if("INF"!==this.decimals){const t=parseFloat(this.decimals);if(!isNaN(t))return void(this._effectiveMasterData={...this.masterData||{},[e]:String(-t)})}this._effectiveMasterData=this.masterData?{...this.masterData}:void 0}_initializeGlobalDecimalsFromRoundingData(){if(this._hasValidGlobalDecimals())return;const e=this._findRoundingLevelFactValue(this._allSections)??this._findRoundingLevelValueInFormData(this._formData);if(null==e||""===e)return;const t=parseFloat(String(e));isNaN(t)||(this.decimals=String(Math.abs(t)))}_findRoundingLevelValueInFormData(e){if(e)for(const t of Object.keys(e)){if(!this._isRoundingLevelConcept(t))continue;const i=e[t]||{};for(const e of Object.keys(i)){const t=i[e];if(null!=t&&""!==t)return t}}}_findRoundingLevelFactValue(e){for(const t of e){const e=this._findRoundingLevelFactValueInConcepts(t.concepts||[]);if(null!=e&&""!==e)return e}}_findRoundingLevelFactValueInConcepts(e){for(const t of e){const e=t.originalConceptId||t.id;if(this._isRoundingLevelConcept(e)){const e=t.facts||[];for(const t of e)if(void 0!==(null==t?void 0:t.value)&&null!==(null==t?void 0:t.value)&&""!==(null==t?void 0:t.value))return t.value}if(t.children&&t.children.length>0){const e=this._findRoundingLevelFactValueInConcepts(t.children);if(null!=e&&""!==e)return e}}}_hasValidGlobalDecimals(){if(void 0===this.decimals||null===this.decimals)return!1;if("INF"===this.decimals)return!1;const e=parseFloat(this.decimals);return!isNaN(e)}_isRoundingLevelConcept(e){return!!e&&("rj-i_DocumentIntendedRoundingLevel"===e||e.includes("DocumentIntendedRoundingLevel"))}_findFactValueForField(e,t,i){var o,r;if(!e.facts||0===e.facts.length)return;const n=this._findColumnByIdInSection(t.columnId,i),a=null==(o=this._periodData[e.id])?void 0:o[t.columnId],s=(null==a?void 0:a.startDate)||(null==n?void 0:n.periodStartDate)||t.periodStartDate||this.periodStartDate,l=(null==a?void 0:a.endDate)||(null==n?void 0:n.periodEndDate)||t.periodEndDate||this.periodEndDate,d=(null==a?void 0:a.instantDate)||t.periodInstantDate||l||s,c=null==(r=this._unitData[e.id])?void 0:r[t.columnId],p={conceptId:e.originalConceptId||t.conceptId||e.id,columnId:t.columnId,periodStartDate:s,periodEndDate:l,periodInstantDate:d,periodType:t.periodType,unit:c,dimensionData:null==n?void 0:n.dimensionData},u=ce.findMatchingFact(e.facts,p);return null==u?void 0:u.value}_storeDecimals(e,t,i){const o={...this._decimalsData};o[e]||(o[e]={}),o[e]={...o[e],[t]:i??""},this._decimalsData=o}_generateUniqueConceptKey(e,t){return`${e}::${t}`}_extractOriginalConceptId(e){const t=e.split("::");return t.length>1?t[1]:e}_handleAddConceptRepeat(e){const{conceptId:t}=e.detail;this._repeatCounts={...this._repeatCounts,[t]:(this._repeatCounts[t]||0)+1},this._dirty=!0}_handleRemoveConceptRepeat(e){const{conceptId:t}=e.detail,i=t.match(/^(.+)__repeat_(\d+)$/),o=i?i[1]:t,r=i?parseInt(i[2]):this._repeatCounts[t]||0,n=this._repeatCounts[o]||0;if(n<=0||r<1||r>n)return;const a={...this._formData},s={...this._typedMemberData},l={...this._unitData},d={...this._periodData};for(let u=r;u<n;u++){const e=`${o}__repeat_${u+1}`,t=`${o}__repeat_${u}`;void 0!==a[e]?a[t]=a[e]:delete a[t];const i=`${t}__`,r=`${e}__`,n=Object.keys(s).filter(e=>e.startsWith(r));Object.keys(s).filter(e=>e.startsWith(i)).forEach(e=>delete s[e]),n.forEach(e=>{s[`${t}__${e.slice(r.length)}`]=s[e]}),n.forEach(e=>delete s[e]),void 0!==l[e]?l[t]=l[e]:delete l[t],void 0!==d[e]?d[t]=d[e]:delete d[t]}const c=`${o}__repeat_${n}`;delete a[c],delete l[c],delete d[c];const p=`${c}__`;Object.keys(s).filter(e=>e.startsWith(p)).forEach(e=>delete s[e]),this._formData=a,this._typedMemberData=s,this._unitData=l,this._periodData=d,this._repeatCounts={...this._repeatCounts,[o]:n-1},this._dirty=!0}_handleTypedMemberChange(e){const{columnId:t,axisId:i,value:o,conceptId:r}=e.detail,n=r?`${r}__${t}`:t;console.log(`🔍 [DynamicForm] Typed member change: storageKey=${n}, axisId=${i}, value=${o}`);const a={...this._typedMemberData};a[n]||(a[n]={}),a[n]={...a[n],[i]:o},this._typedMemberData=a,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 a="";const s=e.composedPath();console.log(`🟧 [DynamicForm] Event path length: ${s.length}`);for(const l of s){const e=l;if("JUPITER-FORM-SECTION"===e.tagName){a=e.getAttribute("section-id")||"",console.log(`🟧 [DynamicForm] Found section element with id: ${a}`);break}}if(console.log(`🟧 [DynamicForm] Found sectionId: ${a}`),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: ${a}`);const e=(null==(t=this._formData[o])?void 0:t[r])||"",s=this._xbrlFormErrors.findIndex(e=>e.fieldId===i&&e.sectionId===a),l={sectionId:a,fieldId:i,conceptId:o,columnId:r,value:e,errors:n};console.log("🟧 [DynamicForm] New error object:",l),console.log(`🟧 [DynamicForm] Existing index: ${s}`),s>=0?(this._xbrlFormErrors=[...this._xbrlFormErrors.slice(0,s),l,...this._xbrlFormErrors.slice(s+1)],console.log(`🟧 [DynamicForm] Updated existing error at index ${s}`)):(this._xbrlFormErrors=[...this._xbrlFormErrors,l],console.log("🟧 [DynamicForm] Added new error"))}else{console.log(`🟧 [DynamicForm] Removing error (if exists) for fieldId: ${i}, sectionId: ${a}`);const e=this._xbrlFormErrors.length;this._xbrlFormErrors=this._xbrlFormErrors.filter(e=>!(e.fieldId===i&&e.sectionId===a)),console.log(`🟧 [DynamicForm] Removed ${e-this._xbrlFormErrors.length} errors`)}console.log(`🔍 [Validation] Total errors: ${this._xbrlFormErrors.length}`,this._xbrlFormErrors)}_getSectionTitle(e){console.log(`🔍 [_getSectionTitle] Looking for sectionId: "${e}"`),console.log("🔍 [_getSectionTitle] Available sections:",this._allSections.map(e=>({id:e.id,title:e.title})));const t=this._allSections.find(t=>t.id===e),i=(null==t?void 0:t.title)||e||"(Unknown Section)";return console.log(`🔍 [_getSectionTitle] Result: "${i}"`),i}_roleHasErrors(e){return this._xbrlFormErrors.some(t=>t.sectionId===e)}async _handleErrorFieldClick(e,t,i){var o,r,n,a;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 s=null==(o=this.shadowRoot)?void 0:o.querySelectorAll("jupiter-form-section");let l=null;if(null==s||s.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==(a=l.shadowRoot)?void 0:a.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 u=p;l.scrollIntoView({behavior:"smooth",block:"start"}),await new Promise(e=>setTimeout(e,300)),u.focus(),"INPUT"!==u.tagName&&"TEXTAREA"!==u.tagName||u.select(),u.style.boxShadow="0 0 0 3px rgba(220, 38, 38, 0.5)",setTimeout(()=>{u.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}))}_handleColumnHide(e){const{columnId:t,sectionId:i}=e.detail;i&&t&&(this._hiddenColumnIds.has(i)||this._hiddenColumnIds.set(i,new Set),this._hiddenColumnIds.get(i).add(t),this._dirty=!0,this.requestUpdate(),this.dispatchEvent(new CustomEvent("column-hide",{detail:{columnId:t,sectionId:i},bubbles:!0})))}_handleColumnShow(e){var t;const{columnId:i,sectionId:o}=e.detail;o&&i&&(null==(t=this._hiddenColumnIds.get(o))||t.delete(i),this._dirty=!0,this.requestUpdate(),this.dispatchEvent(new CustomEvent("column-show",{detail:{columnId:i,sectionId:o},bubbles:!0})))}_getColumnsWithHiddenFlags(e){const t=e.columns||this._columns,i=this._hiddenColumnIds.get(e.id);return i&&0!==i.size?t.map(e=>i.has(e.id)?{...e,hidden:!0}:e):t}_getHiddenColumnsForMetadata(){if(0===this._hiddenColumnIds.size)return;const e={};return this._hiddenColumnIds.forEach((t,i)=>{t.size>0&&(e[i]=Array.from(t))}),Object.keys(e).length>0?e:void 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=[],a=this.language||"en",s=(e,t)=>{var i;return(null==(i=(null==e?void 0:e.find(e=>e.lang===a&&"http://www.xbrl.org/2003/role/label"===e.role))||(null==e?void 0:e.find(e=>"en"===e.lang&&"http://www.xbrl.org/2003/role/label"===e.role))||(null==e?void 0:e.find(e=>"http://www.xbrl.org/2003/role/label"===e.role)))?void 0:i.label)||t};return r.items.forEach(e=>{e.dimensions&&e.dimensions.length>0&&e.dimensions.forEach(e=>{if(!n.find(t=>t.id===e.id)){const t=s(e.labels,e.conceptName),i={id:e.id,conceptName:e.conceptName,axisLabel:t};e.members&&e.members.length>0&&(i.members=e.members.map(e=>({id:e.id,label:s(e.labels,e.conceptName||e.id)}))),e.typedMember&&(i.typedMember={id:e.typedMember.id,dataType:"string"}),n.push(i)}})}),n}_formatPeriodDisplay(e,t){if(!e||!t)return`${e||""} / ${t||""}`;const i=e.substring(0,4);return i===t.substring(0,4)?i:`${e} / ${t}`}_resolveSubmissionInstantDate(e,t,i,o){const r=this._getEffectivePeriodRole(e);if(null==r?void 0:r.includes("periodStartLabel")){const e=(null==i?void 0:i.startDate)||(null==o?void 0:o.periodStartDate)||t.periodStartDate||this.periodStartDate,n=(null==i?void 0:i.endDate)||(null==o?void 0:o.periodEndDate)||t.periodEndDate||this.periodEndDate;return this._resolveInstantDate(r,void 0,e,n)}return(null==i?void 0:i.instantDate)||(null==i?void 0:i.endDate)||t.periodInstantDate||(null==o?void 0:o.periodEndDate)||t.periodEndDate||t.periodStartDate||this.periodStartDate}_getEffectivePeriodRole(e){return e.effectivePeriodRole??e.preferredLabel}_resolveInstantDate(e,t,i,o){if(null==e?void 0:e.includes("periodStartLabel")){const e=i||"2025-01-01";try{const t=new Date(e);return t.setDate(t.getDate()-1),t.toISOString().split("T")[0]}catch{return e}}return t||o||i||"2025-01-01"}_correctLegacyPeriodStartInstantDates(){this._allSections.forEach(e=>{this._correctPeriodStartInstantDatesInConcepts(e.concepts,e)})}_correctPeriodStartInstantDatesInConcepts(e,t){e.forEach(e=>{var i,o;(null==(i=this._getEffectivePeriodRole(e))?void 0:i.includes("periodStartLabel"))&&"instant"===e.periodType&&(null==(o=e.fields)?void 0:o.length)&&e.fields.forEach(i=>{this._correctFieldPeriodStartInstantDate(e,i,e.id,t);const o=this._repeatCounts[e.id]||0;for(let r=1;r<=o;r++)this._correctFieldPeriodStartInstantDate(e,i,`${e.id}__repeat_${r}`,t)}),e.children&&this._correctPeriodStartInstantDatesInConcepts(e.children,t)})}_correctFieldPeriodStartInstantDate(e,t,i,o){var r;const n=this._findColumnByIdInSection(t.columnId,o),a=null==(r=this._periodData[i])?void 0:r[t.columnId],s=(null==a?void 0:a.startDate)||(null==n?void 0:n.periodStartDate)||t.periodStartDate||this.periodStartDate,l=(null==a?void 0:a.endDate)||(null==n?void 0:n.periodEndDate)||t.periodEndDate||this.periodEndDate,d=this._resolveInstantDate(this._getEffectivePeriodRole(e),void 0,s,l);a&&a.instantDate!==d&&(console.log(`🩹 [Legacy Period Correction] ${i}/${t.columnId}: instantDate ${a.instantDate} → ${d}`),a.instantDate=d),t.periodInstantDate!==d&&(console.log(`🩹 [Legacy Period Correction] field ${e.id}/${t.columnId}: periodInstantDate ${t.periodInstantDate} → ${d}`),t.periodInstantDate=d)}_addColumnFromRequest(e,t,i){var o,r,n,a,s;const l=`col-${Date.now()}`;let d="",c="";"instant"===e.periodType?(d=e.instantDate||"",c=""):"duration"!==e.periodType&&"mixed"!==e.periodType||(d=this._formatPeriodDisplay(e.startDate,e.endDate),c="");let p={dimensionId:"period",memberValue:"instant"===e.periodType?`instant-${e.instantDate}`:`duration-${e.startDate}-${e.endDate}`,memberLabel:d};if(e.selectedDimensions&&e.selectedDimensions.length>0){const t=[],i=[];for(const o of e.selectedDimensions)o.isTyped&&o.typedValue?(t.push(`${o.axisLabel}: ${o.typedValue}`),i.push(`${o.axisId}|${o.typedValue}`)):o.memberId&&o.memberLabel&&(t.push(o.memberLabel),i.push(`${o.axisId}|${o.memberId}`));t.length>0&&(d=t.join(" | "),c="instant"===e.periodType?e.instantDate||"":this._formatPeriodDisplay(e.startDate,e.endDate),p={dimensionId:l,memberValue:t.join(" | "),memberLabel:t.join(" | "),memberKey:t.join(" | "),dimensionIdKey:i.join("::"),selectedDimensions:e.selectedDimensions},console.log(`📊 Applied selected dimensions to new column: ${p.memberKey}`))}else if(null==(r=null==(o=this.xbrlInput)?void 0:o.hypercubes)?void 0:r[0]){const i=this.xbrlInput.hypercubes[0].roles.find(e=>e.roleId===t);if(1===(null==(n=null==i?void 0:i.items)?void 0:n.length)){const t=i.items[0];if(1===t.dimensions.length){const i=t.dimensions[0];if(i.members&&i.members.length>0){const t=(null==(a=i.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:a.label)||i.conceptName,o=i.members[0],r=(null==(s=o.labels.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:s.label)||o.conceptName;d=r,c="instant"===e.periodType?e.instantDate||"":this._formatPeriodDisplay(e.startDate,e.endDate),p={dimensionId:l,axisId:i.id,memberId:o.id,memberValue:r,memberLabel:r,axis:t,axisLabel:t,memberKey:`${t} | ${r}`,dimensionIdKey:`${i.id} | ${o.id}`},console.log(`📊 Applied hypercube dimension to new column: ${p.memberKey}`)}}}}const u={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,u.dimensionData&&(u.dimensionData.hasTypedMembers=!0,u.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),u,...e.columns.slice(t+1)]:[...e.columns,u]}else e.columns=[...e.columns,u]}this._replicateFieldsForNewColumn(l,e,t),this._dirty=!0,this.requestUpdate(),this.dispatchEvent(new CustomEvent("column-add",{detail:{column:u},bubbles:!0}))}_removeColumnData(e,t){if(this._currentSchema)if(t){const i=this._currentSchema.sections.find(e=>e.id===t);i&&this._removeColumnDataFromConcepts(i.concepts,e)}else for(const i in this._formData)void 0!==this._formData[i][e]&&delete this._formData[i][e]}_removeColumnDataFromConcepts(e,t){e.forEach(e=>{this._formData[e.id]&&void 0!==this._formData[e.id][t]&&delete this._formData[e.id][t],e.fields&&(e.fields=e.fields.filter(e=>e.columnId!==t)),e.children&&this._removeColumnDataFromConcepts(e.children,t)})}_shouldCreateFieldForConcept(e,t){if(e.abstract)return!1;if(!(t.selectedDimensions&&t.selectedDimensions.length>0)&&e.periodType){if("instant"===t.periodType&&"instant"!==e.periodType)return!1;if("duration"===t.periodType&&"duration"!==e.periodType)return!1}return!0}_replicateFieldsForNewColumn(e,t,i){if(!this._currentSchema)return;const o=new F,r=this._currentSchema.sections.find(e=>e.id===i);r&&this._replicateFieldsForSection(r.concepts,e,t,o)}_replicateFieldsForSection(e,t,i,o){e.forEach(e=>{var r;if(this._shouldCreateFieldForConcept(e,i)){const o=null==(r=e.fields)?void 0:r[0];let n;const a="instant"===i.periodType?i.instantDate:i.startDate,s="instant"===i.periodType?i.instantDate:i.endDate,l=this._resolveInstantDate(this._getEffectivePeriodRole(e),i.instantDate,a,s);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:a,periodEndDate:s,periodInstantDate:"instant"===e.periodType?l:void 0}:{id:`${e.id}_${t}`,conceptId:e.id,columnId:t,type:"text",label:e.label||e.name,placeholder:`Enter ${e.name}`,required:!1,disabled:!1,validation:[],defaultValue:"",periodType:e.periodType,conceptType:e.type,periodStartDate:a,periodEndDate:s,periodInstantDate:"instant"===e.periodType?l:void 0},e.fields||(e.fields=[]),e.fields.push(n)}e.children&&this._replicateFieldsForSection(e.children,t,i,o)})}_addColumn(){const e={id:`dim-${Date.now()}`,title:`Dimension ${this._columns.length}`,description:"Additional dimension column",type:"dimension",order:this._columns.length,removable:!0,dimensionData:{dimensionId:"custom",memberValue:"default",memberLabel:"Default Member"}};this._columns=[...this._columns,e],this.requestUpdate(),this.dispatchEvent(new CustomEvent("column-add",{detail:{column:e},bubbles:!0}))}_handleSubmit(){if(console.log("📝 Form submission started..."),this._submitted=!0,this._submitDisabled=!0,"admin"===this.mode)return this._handleSaveDraft(),this._handleAdminModeSubmit(),void(this._submitDisabled=!1);if(console.log("🔵 [Submit] Checking for errors..."),console.log(`🔵 [Submit] _xbrlFormErrors.length: ${this._xbrlFormErrors.length}`),console.log("🔵 [Submit] _xbrlFormErrors:",this._xbrlFormErrors),this._xbrlFormErrors.length>0)return console.log("❌ [Submit] Cannot submit - validation errors present:",this._xbrlFormErrors),this._showErrorPopup=!0,this._submitDisabled=!1,void this.requestUpdate();if(console.log("✅ [Submit] No validation errors, proceeding with submission..."),this._validateForm(),!this._valid)return console.log("❌ [Submit] Cannot submit - form validation errors present:",this._errors),this._showErrorPopup=!0,this._submitDisabled=!1,void this.requestUpdate();this._correctLegacyPeriodStartInstantDates();const e=this._generateSubmissionData();console.log("📊 Form Submission Data:",JSON.stringify(e,null,2)),console.log("📊 Submission Data Summary:"),e.forEach((e,t)=>{console.log(` [${t}] conceptId: ${e.conceptId}, columnId: ${e.columnId}, value: ${e.value}, unit: ${e.unit||"none"}`)}),this.dispatchEvent(new CustomEvent("form-submit",{detail:{data:this._formData,submissionData:e,valid:this._valid,errors:this._errors,reportingLanguage:this.reportingLanguage},bubbles:!0})),console.log("✅ Form submit event dispatched"),setTimeout(()=>{this._submitDisabled=!1},1e3)}_handleQuickValidate(){"admin"!==this.mode&&this._runFormulaValidationPreflight()}_runFormulaValidationPreflight(){var e,t,i,o,r,n,a,s;if(!this.formulaEnabled)return;const l=null==(i=null==(t=null==(e=this.xbrlInput)?void 0:e.formula)?void 0:t[0])?void 0:i.roles;if(!l||0===l.length)return;const d=(null==(r=null==(o=this._currentSchema)?void 0:o.sections)?void 0:r.length)?this._currentSchema.sections:this._allSections;if(!d||0===d.length)return;const c=new Set(d.map(e=>{var t;return(null==(t=e.metadata)?void 0:t.roleURI)||e.id})),p=l.filter(e=>c.has(e.roleURI));if(0===p.length)return;const u=d.map(e=>{var t;return{roleURI:(null==(t=e.metadata)?void 0:t.roleURI)||e.id,concepts:e.concepts}}),h=G(this._formData,this._mergeAllSectionColumns(),u,null==(s=null==(a=null==(n=this.xbrlInput)?void 0:n.hypercubes)?void 0:a[0])?void 0:s.roles,this.periodStartDate,this.periodEndDate),m={...this.xbrlInput,formula:[{...this.xbrlInput.formula[0],roles:p}]},f=this._formulaValidationService.evaluate(m,h,this.language),g=this._formulaValidationService.summarize(f);this._formulaValidationResults=f,this._formulaValidationSummary=g;f.some(e=>!e.skipped&&!e.satisfied)&&(this._showFormulaValidationDialog=!0),this.dispatchEvent(new CustomEvent("formula-validation-complete",{detail:{results:f,summary:g},bubbles:!0,composed:!0}))}_mergeAllSectionColumns(){const e=new Map;return this._columns.forEach(t=>e.set(t.id,t)),this._allSections.forEach(t=>{(t.columns||[]).forEach(t=>e.set(t.id,t))}),Array.from(e.values())}_handleSaveDraft(e="manual"){if(console.log("🔵 [Save Draft] Checking for errors..."),console.log(`🔵 [Save Draft] _xbrlFormErrors.length: ${this._xbrlFormErrors.length}`),console.log("🔵 [Save Draft] _xbrlFormErrors:",this._xbrlFormErrors),this._xbrlFormErrors.length>0)return console.log("❌ [Save Draft] Cannot save - validation errors present:",this._xbrlFormErrors),this._showErrorPopup=!0,void this.requestUpdate();console.log("✅ [Save Draft] No validation errors, proceeding with save..."),console.log("💾 Raw form data before submission generation:",this._formData),console.log("🏷️ Unit data before submission generation:",this._unitData),console.log("📋 Enhanced selectedRoleIds with roleURI and order:",this._selectedRoleIds),this._correctLegacyPeriodStartInstantDates();const t=this._generateSubmissionData();console.log("📤 Generated submission data:",t),console.log("📊 Submission data breakdown:"),t.forEach((e,t)=>{console.log(` [${t}] conceptId: ${e.conceptId}, columnId: ${e.columnId}, value: ${e.value}, unit: ${e.unit||"none"}`)});const i=this._roleCompletedStates.size>0?Object.fromEntries(this._roleCompletedStates):void 0,o=this._draftStorageService.createMetadataSnapshot(this.periodStartDate,this.periodEndDate,this.language,this._selectedRoleIds,this._allSections,this._typedMemberData,this._periodPreferences,this._periodData,this._unitData,this.reportingLanguage,this._repeatCounts,this._decimalsData,i,this._getHiddenColumnsForMetadata(),this._totalManuallyEditedData),r=JSON.stringify({draftData:t,metadata:o});if(r===this._lastSavedDraftSnapshot)return void console.log(`ℹ️ [Save Draft] No draft content change detected (${e}); skipping event emit.`);this._lastSavedDraftSnapshot=r;const n=this._draftStorageService.saveDraft(t,o);console.log("💾 [Save Draft] Metadata saved with enhanced selectedRoleIds:",o.selectedRoleIds),this.dynaformsFacts=t,this.dynaformsMetadata=o,this.dispatchEvent(new CustomEvent("form-save-draft",{detail:{data:this._formData,draftData:t,metadata:o,saved:n,valid:this._valid,errors:this._errors,dynaformsFacts:t,dynaformsMetadata:o,reportingLanguage:this.reportingLanguage,source:"auto"==e?"auto":"manual"},bubbles:!0,composed:!0}));const a=this._getRoleIdsArray().length;console.log("💾 Draft saved - localStorage + event emitted",{entries:t.length,saved:n,roles:a,customColumns:o.customColumns.length,eventEmitted:!0,enhancedRoleStructure:Array.isArray(this._selectedRoleIds)&&this._selectedRoleIds.length>0&&"object"==typeof this._selectedRoleIds[0]})}async _loadDraftIfExists(){if(console.log("📋 Checking for saved draft..."),this.dynaformsFacts&&this.dynaformsMetadata){console.log("📦 Using external draft data from properties");const e={formData:this.dynaformsFacts,metadata:this.dynaformsMetadata};return await this._restoreFromDraft(e),this._draftLoaded=!0,this._draftLoadedAt=this.dynaformsMetadata.savedAt||(new Date).toISOString(),this.dispatchEvent(new CustomEvent("form-draft-loaded",{detail:{draft:e,source:"external",compatible:!0,warnings:[]},bubbles:!0,composed:!0})),void console.log("📥 External draft loaded successfully")}if(!this._draftStorageService.hasDraft())return void console.log("ℹ️ No saved draft found");const e=this._draftStorageService.loadDraft();if(!e)return void console.warn("⚠️ Failed to load draft");const{compatible:t,warnings:i}=this._draftStorageService.validateDraftCompatibility(e,this.periodStartDate,this.periodEndDate);i.length>0&&console.warn("⚠️ Draft compatibility warnings:",i),await this._restoreFromDraft(e),this.dispatchEvent(new CustomEvent("form-draft-loaded",{detail:{draft:e,compatible:t,warnings:i},bubbles:!0,composed:!0})),console.log("📥 Draft loaded successfully",{entries:e.formData.length,savedAt:e.metadata.savedAt,age:this._draftStorageService.getDraftAge()})}async _restoreFromDraft(e){var t;const{formData:i,metadata:o}=e;o.selectedRoleIds&&o.selectedRoleIds.length>0&&(this._selectedRoleIds=o.selectedRoleIds,console.log(`🔄 Restored ${this._selectedRoleIds.length} selected roles`)),o.typedMemberData&&(this._typedMemberData=o.typedMemberData,this._preservedTypedMemberData={},console.log("🔄 Restored typed member data")),o.repeatCounts&&(this._repeatCounts=o.repeatCounts,console.log("🔄 Restored repeat counts:",this._repeatCounts)),o.periodData&&(this._periodData=o.periodData,console.log("🔄 Restored custom field-level period data:",Object.keys(this._periodData).length,"concepts")),o.unitData&&(this._unitData=o.unitData,console.log("🔄 Restored custom field-level unit data:",Object.keys(this._unitData).length,"concepts")),o.decimalsData&&(this._decimalsData=o.decimalsData,console.log("🔄 Restored per-fact decimals data:",Object.keys(this._decimalsData).length,"concepts")),o.roleCompletedStates&&(this._roleCompletedStates=new Map(Object.entries(o.roleCompletedStates)),console.log("🔄 Restored role completed states:",Object.keys(o.roleCompletedStates).length,"roles")),o.hiddenColumns&&(this._hiddenColumnIds=new Map(Object.entries(o.hiddenColumns).map(([e,t])=>[e,new Set(t)])),console.log("🔄 Restored hidden columns for",this._hiddenColumnIds.size,"sections")),o.totalManuallyEditedData&&(this._totalManuallyEditedData=o.totalManuallyEditedData,console.log("🔄 Restored total manually-edited data:",Object.keys(this._totalManuallyEditedData).length,"concepts")),o.periodPreferences?this._skipPeriodPreferencesRestore?console.log("⏭️ Skipping period preferences restoration - using new filter selections"):(this._periodPreferences=o.periodPreferences,console.log("🔄 Restored period preferences (including previous year settings):",this._periodPreferences),this.xbrlInput&&(console.log("🔄 Rebuilding schema with restored period preferences..."),this._currentSchema=F.buildFormSchema(this.xbrlInput,this.periodStartDate,this.periodEndDate,this.language,this._periodPreferences),this._allSections=[...this._currentSchema.sections],console.log("✅ Schema rebuilt with restored period preferences"),console.log("🔄 Applying custom period data to schema fields..."),this._applyCustomPeriodDataToFields(),o.customColumns&&o.customColumns.length>0&&(this._mergeAdditionalCustomColumns(o.customColumns),console.log(`🔄 Merged ${o.customColumns.length} additional custom columns`)))):o.customColumns&&o.customColumns.length>0&&(this._restoreCustomColumns(o.customColumns),console.log(`🔄 Restored ${o.customColumns.length} custom columns`));const r={},n={},a={};i.forEach(e=>{let{conceptId:t,draftInstanceId:i,value:o,columnId:s,period:l,unit:d}=e;if(!s&&l&&(s=this._inferColumnIdFromPeriod(l,t),!s))return void console.warn(`⚠️ Could not infer columnId for concept ${t}, skipping...`);const c=i||t,p=c.includes("__repeat_")?c.split("__repeat_")[0]:c,u=this._findActualConceptId(p),h=c.includes("__repeat_")?`${u||p}__repeat_${c.split("__repeat_")[1]}`:u||c;r[h]||(r[h]={}),r[h][s]=o,console.log(`📦 Restored: ${h}[${s}] = ${o}${c!==t?" (repeat instance)":""}`),l&&(n[h]||(n[h]={}),"instant"===l.type?(n[h][s]={instantDate:l.date},console.log(`📅 [Restore Period] Extracted instant date for ${h}/${s}: ${l.date}`)):"duration"===l.type&&(n[h][s]={startDate:l.startDate,endDate:l.endDate},console.log(`📅 [Restore Period] Extracted duration dates for ${h}/${s}: ${l.startDate} - ${l.endDate}`))),d&&(a[h]||(a[h]={}),a[h][s]=d,console.log(`🏷️ [Restore Unit] Extracted unit for ${h}/${s}: ${d}`))}),this._formData={...this._formData,...r},console.log(`🔄 Restored ${Object.keys(r).length} concepts with data`),this._seedLegacyManuallyEditedTotals(r),this._initializeGlobalDecimalsFromRoundingData(),this._periodData={...this._periodData,...o.periodData||{},...n},console.log(`📅 [Period Restore] Merged period data: ${Object.keys(this._periodData).length} concepts with custom periods`),console.log("📅 [Period Restore] Full _periodData after merge:",JSON.stringify(this._periodData,null,2)),this._unitData={...this._unitData,...o.unitData||{},...a},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._correctLegacyPeriodStartInstantDates(),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,a;const s=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(s):d.value=null!=s?String(s):"",console.log(` ✅ Populated field ${l} with value:`,s),t++):(console.warn(` ❌ Field element NOT FOUND: ${l}`),console.warn(" Available fields in DOM:",Array.from((null==(a=this.shadowRoot)?void 0:a.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`)}_seedLegacyManuallyEditedTotals(e){const t={...this._totalManuallyEditedData};let i=!1;const o=r=>{var n;for(const a of r){if(E(a.preferredLabel)){const o=e[a.id];if(o)for(const e of Object.keys(o)){const r=o[e];null==r||""===r||void 0!==(null==(n=t[a.id])?void 0:n[e])||(t[a.id]={...t[a.id]||{},[e]:!0},i=!0)}}a.children&&a.children.length>0&&o(a.children)}};for(const r of this._allSections)o(r.concepts||[]);i&&(this._totalManuallyEditedData=t,console.log("🔒 [JDF-058] Seeded manual-edit protection for pre-existing total values in legacy draft"))}_restoreCustomColumns(e){const t=new Map;e.forEach(e=>{t.has(e.sectionId)||t.set(e.sectionId,[]),t.get(e.sectionId).push(e)}),this._allSections.forEach(e=>{var i;const o=t.get(e.id);if(o){if(e.columns=o.map(e=>{const t={id:e.columnId,title:e.label,description:e.description,type:e.dimensionData?"dimension":"base",periodStartDate:e.startDate||e.date,periodEndDate:e.endDate||e.date,dimensionData:e.dimensionData,order:0,removable:"duration"!==e.columnId&&"instant"!==e.columnId,periodType:e.periodType};return console.log(`📅 [Draft Restore] Restoring column ${e.columnId}: title=${t.title}, description=${t.description}, startDate=${t.periodStartDate}, endDate=${t.periodEndDate}, periodType=${t.periodType}`),t}),(null==(i=this.xbrlInput)?void 0:i.datatypes)&&!e.datatypes){const t=Array.isArray(this.xbrlInput.datatypes)?this.xbrlInput.datatypes:this.xbrlInput.datatypes.concepts||[];e.datatypes=t,console.log(`✅ [Draft Restore] Attached ${t.length} datatypes to section ${e.id}`)}else e.datatypes?console.log(`ℹ️ [Draft Restore] Section ${e.id} already has ${e.datatypes.length} datatypes`):console.warn(`⚠️ [Draft Restore] No datatypes available for section ${e.id}`);this._regenerateFieldsForSection(e),console.log(` └─ Restored ${o.length} columns for section ${e.id}`)}}),this._currentSchema&&(this._currentSchema={...this._currentSchema,sections:this._allSections})}_mergeAdditionalCustomColumns(e){const t=new Map;e.forEach(e=>{e.columnId.startsWith("col-")&&(t.has(e.sectionId)||t.set(e.sectionId,[]),t.get(e.sectionId).push(e))}),this._allSections.forEach(e=>{var i;const o=t.get(e.id);if(o&&o.length>0){if(e.columns||(e.columns=[]),(null==(i=this.xbrlInput)?void 0:i.datatypes)&&!e.datatypes){const t=Array.isArray(this.xbrlInput.datatypes)?this.xbrlInput.datatypes:this.xbrlInput.datatypes.concepts||[];e.datatypes=t,console.log(`✅ [Merge Custom] Attached ${t.length} datatypes to section ${e.id}`)}else e.datatypes?console.log(`ℹ️ [Merge Custom] Section ${e.id} already has ${e.datatypes.length} datatypes`):console.warn(`⚠️ [Merge Custom] No datatypes available for section ${e.id}`);o.forEach(t=>{console.log(`📅 [Merge Custom Column] Column ${t.columnId}: col.startDate=${t.startDate}, col.endDate=${t.endDate}, col.date=${t.date}, col.periodType=${t.periodType}`);if(!e.columns.find(e=>e.id===t.columnId)){const i={id:t.columnId,title:t.label,description:t.description,type:t.dimensionData?"dimension":"base",periodStartDate:t.startDate||t.date,periodEndDate:t.endDate||t.date,dimensionData:t.dimensionData,order:e.columns.length,removable:!0,periodType:t.periodType};console.log(`📅 [New Column Created] Column ${i.id}: title=${i.title}, description=${i.description}, periodStartDate=${i.periodStartDate}, periodEndDate=${i.periodEndDate}, periodType=${i.periodType}`),e.columns.push(i),console.log(` └─ Added custom column ${t.columnId} to section ${e.id}`)}}),this._regenerateFieldsForSection(e)}}),this._currentSchema&&(this._currentSchema={...this._currentSchema,sections:this._allSections})}_applyCustomPeriodDataToFields(){if(!this._periodData||0===Object.keys(this._periodData).length)return void console.log("ℹ️ No custom period data to apply");let e=0;const t=i=>{i.forEach(i=>{if(this._periodData[i.id]){const t=this._periodData[i.id];i.fields&&i.fields.forEach(o=>{const r=t[o.columnId];r&&(r.startDate&&(o.periodStartDate=r.startDate),r.endDate&&(o.periodEndDate=r.endDate),r.instantDate&&(o.periodInstantDate=r.instantDate),e++,console.log(`✅ [Apply Period] Updated field ${i.id}/${o.columnId}: start=${o.periodStartDate}, end=${o.periodEndDate}, instant=${o.periodInstantDate}`))})}i.children&&i.children.length>0&&t(i.children)})};this._allSections.forEach(e=>{e.concepts&&e.concepts.length>0&&t(e.concepts)}),console.log(`📅 [Apply Period] Applied custom period data to ${e} fields`)}_regenerateFieldsForSection(e){if(!e.columns)return;const t=this._periodPreferences[e.id]||{showDuration:!0,showInstant:!0,showPreviousYear:!1},i=o=>{o.forEach(o=>{o.fields=[];this._shouldShowConceptBasedOnPeriodPreferences(o,t)&&e.columns.forEach(t=>{var i;const r=o.periodType,n=this._inferColumnPeriodType(t);if(o.abstract)return;const a=t.id.startsWith("col-"),s=t.id.startsWith("duration_")||t.id.startsWith("instant_")||t.id.startsWith("typed-"),l=!0===e.showPeriodControl;if(!(!n||"duration"===t.id||"default"===t.id||a&&l||s)&&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?this._resolveInstantDate(this._getEffectivePeriodRole(o),void 0,t.periodStartDate,t.periodEndDate):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,a,s,l,d;const c=e.fields.find(e=>e.columnId===t);if(!c)return;const p="instant"===e.periodType,u=null==(n=this._periodData[e.id])?void 0:n[t],h=null==(a=this._unitData[e.id])?void 0:a[t],m=this._findColumnByIdInAllSections(t);console.log(`🔍 [Submission] Concept: ${e.id}, Column: ${t}, Field Period: ${u?JSON.stringify(u):"none"}, Unit: ${h||"none"}, Column Period: ${(null==m?void 0:m.periodStartDate)||"none"} - ${(null==m?void 0:m.periodEndDate)||"none"}`);const f=(null==u?void 0:u.startDate)||(null==m?void 0:m.periodStartDate)||c.periodStartDate||this.periodStartDate,g=(null==u?void 0:u.endDate)||(null==m?void 0:m.periodEndDate)||c.periodEndDate||this.periodEndDate,b=(null==u?void 0:u.instantDate)||c.periodInstantDate||g||f,v={conceptId:e.originalConceptId||e.id,columnId:t,value:i,period:{type:e.periodType||"duration",...p?{date:b}:{startDate:f,endDate:g}}};h&&(v.unit=h,console.log(`✅ [Submission] Adding unit to entry: ${h} for ${e.id}/${t}`));const y=null==(s=e.type)?void 0:s.toLowerCase().includes("monetary"),x=(null==(l=this._decimalsData[e.id])?void 0:l[t])||("INF"!==this.decimals?this.decimals:void 0);if(y&&x){const e=parseFloat(x);v.decimals=isNaN(e)?x:String(-Math.abs(e))}(null==(d=null==m?void 0:m.dimensionData)?void 0:d.memberLabel)&&(v.dimension=m.dimensionData.memberLabel),console.log("📤 [Submission Entry] Created entry:",JSON.stringify(v,null,2)),o.push(v)}_findColumnByIdInAllSections(e){for(const t of this._allSections)if(t.columns){const i=t.columns.find(t=>t.id===e);if(i)return i}}_removeDuplicateSubmissions(e){const t=new Map;return e.forEach(e=>{const i="instant"===e.period.type?e.period.date:`${e.period.startDate}_${e.period.endDate}`,o=`${e.conceptId}_${e.value}_${e.dimension||"no-dimension"}_${i}`;t.has(o)||t.set(o,e)}),Array.from(t.values())}_findColumnById(e){if(this._currentSchema)for(const t of this._currentSchema.sections)if(t.columns){const i=t.columns.find(t=>t.id===e);if(i)return i}}_findColumnByIdInSection(e,t){if(null==t?void 0:t.columns)return t.columns.find(t=>t.id===e)}_getTypedMemberNameForAxis(e,t){var i,o,r,n;if(!(null==(o=null==(i=this.xbrlInput)?void 0:i.hypercubes)?void 0:o[0]))return null;const a=null==t?void 0:t.id;if(!a)return null;const s=null==(r=this.xbrlInput.hypercubes[0].roles)?void 0:r.find(e=>e.roleId===a);if(!(null==s?void 0:s.items))return null;for(const l of s.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 a=null==t?void 0:t.id;if(!a)return!1;const s=this.xbrlInput.hypercubes[0].roles.find(e=>e.roleId===a);if(!(null==(n=null==s?void 0:s.items)?void 0:n.length))return!1;for(const l of s.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 ${a}`),!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 a=e.originalConceptId||e.id;for(const s of n.items)if(s.conceptIds&&s.conceptIds.includes(a)){const e=s.dimensions.filter(e=>e.typedMember).map(e=>e.id);return console.log(`🔍 [DynamicForm] Found applicable typed dimensions for concept ${a}:`,e),e}return[]}_processConceptsForSubmission(e,t,i){const o="Toelichting op de geconsolideerde jaarrekening - Financiële vaste activa: Deelnemingen: Volledig geconsolideerd: Specificatie",r=(null==i?void 0:i.title)||"Unknown";e.forEach(e=>{if(r===o&&(console.warn(`[DUPLICATE DEBUG] Processing concept ${e.originalConceptId||e.id} in target role`),e.fields&&(console.warn(`[DUPLICATE DEBUG] Concept has ${e.fields.length} fields`),e.fields.forEach((t,i)=>{var o;console.warn(`[DUPLICATE DEBUG] Field ${i}: columnId=${t.columnId}, current value=${null==(o=this._formData[e.id])?void 0:o[t.columnId]}`)}))),e.fields&&e.fields.length>1&&e.fields.forEach((e,t)=>{}),e.fields&&e.fields.length>0){e.fields.forEach(n=>{var a,s,l,d,c,p,u,h;const m=this._formData[e.id];let f=null==m?void 0:m[n.columnId];const g=n.conceptId||e.id.split("__").slice(0,-1).join("__")||e.id;if((null==f||""===f)&&this._isRoundingLevelConcept(g)&&!this._hasValidGlobalDecimals()){const t=this._findFactValueForField(e,n,i);null!=t&&""!==t&&(f=t)}if((null==f||""===f)&&this._effectiveMasterData){const e=null==(a=this._effectiveMasterData)?void 0:a[g];null!=e&&""!==e&&(f=e,console.warn(` 📦 [Submission] Using masterData for: ${g} [${n.columnId}] = ${JSON.stringify(f)}`))}if(null!=f&&""!==f){const a=this._findColumnByIdInSection(n.columnId,i),m=null==(s=this._periodData[e.id])?void 0:s[n.columnId],g={conceptId:e.id,draftInstanceId:e.id,columnId:n.columnId,value:f,period:{type:e.periodType||"duration"}};if("instant"===e.periodType){const t=this._resolveSubmissionInstantDate(e,n,m,a);g.period.date=t}else{const e=(null==m?void 0:m.startDate)||(null==a?void 0:a.periodStartDate)||n.periodStartDate||this.periodStartDate,t=(null==m?void 0:m.endDate)||(null==a?void 0:a.periodEndDate)||n.periodEndDate||this.periodEndDate;g.period.startDate=e,g.period.endDate=t}console.log(`🔍 [Submission] Concept: ${e.id}, Column: ${n.columnId}, Field Period: ${m?JSON.stringify(m):"none"}, Column Period: ${(null==a?void 0:a.periodStartDate)||"none"} - ${(null==a?void 0:a.periodEndDate)||"none"}, Used Period: ${"instant"===g.period.type?g.period.date:`${g.period.startDate} - ${g.period.endDate}`}`);const b=null==(l=this._unitData[e.id])?void 0:l[n.columnId];b?(g.unit=b,console.log(`✅ [Submission] Adding unit to entry: ${b} for ${e.id}/${n.columnId}`)):console.log(`⚠️ [Submission] No unit found in _unitData for ${e.id}/${n.columnId}. _unitData state:`,JSON.stringify(this._unitData,null,2));const v=null==(d=e.type)?void 0:d.toLowerCase().includes("monetary"),y=(null==(c=this._decimalsData[e.id])?void 0:c[n.columnId])||("INF"!==this.decimals?this.decimals:void 0);if(v&&y){const e=parseFloat(y);g.decimals=isNaN(e)?y:String(-Math.abs(e))}if("dimension"===(null==a?void 0:a.type)&&(null==(p=a.dimensionData)?void 0:p.dimensionIdKey)?(g.dimension=a.dimensionData.dimensionIdKey,console.log(`🔍 [DynamicForm] Using dimension key from field's column (${n.columnId}):`,a.dimensionData.dimensionIdKey)):console.log(`🔍 [DynamicForm] No dimension data found for field column ${n.columnId}. Column type: ${null==a?void 0:a.type}, has dimensionData: ${!!(null==a?void 0:a.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?(g.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)),a&&console.log("🔍 [DynamicForm] Column details:",{id:a.id,type:a.type,hasTypedMembers:null==(u=a.dimensionData)?void 0:u.hasTypedMembers,dimensionData:a.dimensionData});if(!g.typedMembers&&(null==(h=n.crossRoleTypedMembers)?void 0:h.length)){const t=`${e.id}__${n.columnId}`,i=this._typedMemberData[t];if(i){const t={};n.crossRoleTypedMembers.forEach(e=>{const o=i[e.axisId];null!=o&&""!==o&&(t[e.axisId]={value:o,memberName:e.typedMemberId})}),Object.keys(t).length>0&&(g.typedMembers=t,console.log(`🔍 [Submission] Adding cross-role typed members for ${e.id}/${n.columnId}:`,t))}}r===o&&console.warn("[DUPLICATE DEBUG] Final submission entry:",g),t.push(g)}});const n=this._repeatCounts[e.id]||0;if(n>0&&e.fields.some(e=>{var t;return null==(t=e.crossRoleTypedMembers)?void 0:t.length}))for(let o=1;o<=n;o++){const r=`${e.id}__repeat_${o}`;e.fields.forEach(o=>{var n,a,s,l,d;const c=null==(n=this._formData[r])?void 0:n[o.columnId];if(null==c||""===c)return;const p=this._findColumnByIdInSection(o.columnId,i),u=null==(a=this._periodData[r])?void 0:a[o.columnId],h={conceptId:e.id,draftInstanceId:r,columnId:o.columnId,value:c,period:{type:e.periodType||"duration"}};"instant"===e.periodType?h.period.date=this._resolveSubmissionInstantDate(e,o,u,p):(h.period.startDate=(null==u?void 0:u.startDate)||(null==p?void 0:p.periodStartDate)||o.periodStartDate||this.periodStartDate,h.period.endDate=(null==u?void 0:u.endDate)||(null==p?void 0:p.periodEndDate)||o.periodEndDate||this.periodEndDate);const m=null==(s=this._unitData[r])?void 0:s[o.columnId];if(m&&(h.unit=m),"dimension"===(null==p?void 0:p.type)&&(null==(l=p.dimensionData)?void 0:l.dimensionIdKey)&&(h.dimension=p.dimensionData.dimensionIdKey),null==(d=o.crossRoleTypedMembers)?void 0:d.length){const e=`${r}__${o.columnId}`,t=this._typedMemberData[e];if(t){const e={};o.crossRoleTypedMembers.forEach(i=>{const o=t[i.axisId];null!=o&&""!==o&&(e[i.axisId]={value:o,memberName:i.typedMemberId})}),Object.keys(e).length>0&&(h.typedMembers=e)}}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}}_analyzeAllVisibleRoles(){if(this._currentSchema&&this._currentSchema.sections&&0!==this._currentSchema.sections.length){console.log(`🔍 Analyzing ${this._currentSchema.sections.length} visible roles for initial border status...`);for(const e of this._currentSchema.sections)this._analyzeAndLogRole(e.id);console.log("✅ Initial border status analysis complete for all visible roles")}else console.log("⏭️ No sections to analyze for initial border status")}_handleRoleContextMenu(e,t,i){e.preventDefault(),e.stopPropagation(),this._contextMenuX=e.clientX,this._contextMenuY=e.clientY,this._contextMenuRoleId=t,this._showRoleContextMenu=!0,console.log(`🖱️ Context menu opened for role: ${i} (ID: ${t})`),this.requestUpdate()}_closeRoleContextMenu(){this._showRoleContextMenu=!1,this._contextMenuRoleId=null,this.requestUpdate()}_handleRemoveRole(){if(!this._contextMenuRoleId)return void this._closeRoleContextMenu();const e=this._allSections.find(e=>e.id===this._contextMenuRoleId),t=(null==e?void 0:e.title)||"Unknown";if(console.log("🗑️ Removing role from side panel:"),console.log(` - Role ID: ${this._contextMenuRoleId}`),console.log(` - Role Title: ${t}`),Array.isArray(this._selectedRoleIds)&&(this._selectedRoleIds.length>0&&"object"==typeof this._selectedRoleIds[0]?this._selectedRoleIds=this._selectedRoleIds.filter(e=>e.roleId!==this._contextMenuRoleId):this._selectedRoleIds=this._selectedRoleIds.filter(e=>e!==this._contextMenuRoleId)),console.log(`✅ Role removed from _selectedRoleIds. Remaining roles: ${this._selectedRoleIds.length}`),this._activeSidePanelRoleId===this._contextMenuRoleId){const e=this._getRoleIdsArray();this._activeSidePanelRoleId=e.length>0?e[0]:null,console.log(`📌 Active role changed to: ${this._activeSidePanelRoleId||"None"}`)}this._applyRoleFilter(),this.dispatchEvent(new CustomEvent("role-removed",{detail:{roleId:this._contextMenuRoleId,roleTitle:t,remainingRolesCount:this._selectedRoleIds.length},bubbles:!0,composed:!0})),console.log(`✅ Role "${t}" successfully removed from side panel`),console.log("ℹ️ User can re-add this role using the Filter Roles dialog"),this._closeRoleContextMenu()}_handleRoleCompletedChange(e,t){t?this._roleCompletedStates.set(e,!0):this._roleCompletedStates.delete(e),this._roleCompletedStates=new Map(this._roleCompletedStates),this._handleSaveDraft("auto")}_handleSidePanelRoleClick(e){this._activeSidePanelRoleId&&this._activeSidePanelRoleId!==e&&this._analyzeAndLogRole(this._activeSidePanelRoleId),this._activeSidePanelRoleId=e}_analyzeAndLogRole(e){const t=this._allSections.find(t=>t.id===e);if(!t)return void console.warn(`⚠️ Section not found for roleId: ${e}`);console.warn("\n========================================"),console.warn(`🔍 ANALYZING ROLE: "${t.title}"`),console.warn("========================================"),this.masterData?console.warn("📦 masterData keys:",Object.keys(this.masterData)):console.warn("📦 masterData: NOT PROVIDED");const i=[];this._collectAllFields(t.concepts||[],new Set((t.columns||[]).map(e=>e.id)),t.columns||[],i);const o=this._roleHasErrors(e),r=i.filter(e=>e.isEmpty).length,n=i.filter(e=>!e.isEmpty).length;let a;console.warn("\n📈 SUMMARY:"),console.warn(` Total Fields: ${i.length}`),console.warn(` Filled: ${n}`),console.warn(` Empty: ${r}`),console.warn(` Has Errors: ${o}`),o?(a="INVALID",console.warn("\n🔴 RESULT: INVALID (contains validation errors)")):0===n?(a="UNTOUCHED",console.warn("\n⬜ RESULT: UNTOUCHED (no data entered)")):r>0?(a="INCOMPLETE",console.warn(`\n🟠 RESULT: INCOMPLETE (${r} field(s) blank)`)):(a="COMPLETE",console.warn("\n🟢 RESULT: COMPLETE (all fields filled)")),console.warn("========================================\n"),"INVALID"===a||("UNTOUCHED"===a?(this._roleBorderStatuses.set(e,"untouched"),this._roleBorderStatuses=new Map(this._roleBorderStatuses)):"INCOMPLETE"===a?(this._roleBorderStatuses.set(e,"incomplete"),this._roleBorderStatuses=new Map(this._roleBorderStatuses)):(this._roleBorderStatuses.set(e,"complete"),this._roleBorderStatuses=new Map(this._roleBorderStatuses)))}_collectAllFields(e,t,i,o){var r,n,a;for(const s of e)if(s.abstract)s.children&&s.children.length>0&&this._collectAllFields(s.children,t,i,o);else{if(s.fields&&s.fields.length>0){const e=s.fields.filter(e=>t.has(e.columnId));for(const t of e){const e=s.id,l=t.conceptId;let d=null==(r=this._formData[e])?void 0:r[t.columnId];void 0===d&&e!==l&&(d=null==(n=this._formData[l])?void 0:n[t.columnId]);const c=null==(a=this._effectiveMasterData)?void 0:a[l];(null==d||"string"==typeof d&&""===d.trim())&&void 0!==c&&(d=c,console.warn(` 📦 Using masterData value for: ${l} [${t.columnId}] = ${JSON.stringify(d)}`));let p=null==d||"string"==typeof d&&""===d.trim();if(p&&s.facts&&s.facts.length>0){const e=i.find(e=>e.id===t.columnId),o={conceptId:l,columnId:t.columnId,periodStartDate:t.periodStartDate||(null==e?void 0:e.periodStartDate),periodEndDate:t.periodEndDate||(null==e?void 0:e.periodEndDate),periodInstantDate:t.periodInstantDate||("instant"===t.periodType?t.periodEndDate||t.periodStartDate:void 0),periodType:t.periodType,dimensionData:null==e?void 0:e.dimensionData},r=ce.findMatchingFact(s.facts,o);r&&null!==r.value&&void 0!==r.value&&""!==r.value&&(d=r.value,p=!1)}o.push({conceptId:l,columnId:t.columnId,value:d,isEmpty:p})}}s.children&&s.children.length>0&&this._collectAllFields(s.children,t,i,o)}}_handleSidePanelSearchInput(e){const t=e.target;this._sidePanelSearchQuery=t.value}_clearSidePanelSearch(){var e;this._sidePanelSearchQuery="";const t=null==(e=this.shadowRoot)?void 0:e.querySelector(".side-panel-search-input");t&&(t.value="",t.focus())}_toggleSidePanelCollapse(){this._sidePanelCollapsed=!this._sidePanelCollapsed}_isSectionBlank(e){const t=e.columns||this._columns,i=e=>{var o;for(const r of e){if(!r.abstract)for(const e of t){const t=null==(o=this._formData[r.id])?void 0:o[e.id];if(null!=t&&""!==t)return!0}if(r.children&&r.children.length>0&&i(r.children))return!0}return!1};return!i(e.concepts)}_getConceptSearchMatchIds(e){var t,i,o;const r=new Set;if(!e.trim()||!(null==(i=null==(t=this.xbrlInput)?void 0:t.presentation)?void 0:i.length))return r;const n=e.toLowerCase().trim(),a=e=>{var t;for(const i of e)r.add(i.id),(null==(t=i.children)?void 0:t.length)&&a(i.children)},s=e=>{var t,i,o,l;for(const d of e){let e=(null==(t=d.conceptName)?void 0:t.toLowerCase().includes(n))||(null==(i=d.id)?void 0:i.toLowerCase().includes(n));!e&&Array.isArray(d.labels)&&(e=d.labels.some(e=>{var t;return null==(t=e.label)?void 0:t.toLowerCase().includes(n)})),e?(r.add(d.id),(null==(o=d.children)?void 0:o.length)&&a(d.children)):(null==(l=d.children)?void 0:l.length)&&s(d.children)}};for(const l of this.xbrlInput.presentation)for(const e of l.roles||[])s((null==(o=e.presentationLinkbase)?void 0:o.concepts)||[]);return r}_isSectionConceptSearchMatch(e,t){if(0===t.size)return!1;const i=e=>{var o;for(const r of e){if(t.has(r.originalConceptId))return!0;if((null==(o=r.children)?void 0:o.length)&&i(r.children))return!0}return!1};return i(e.concepts)}_filterSidePanelSections(e){if(!this._sidePanelSearchQuery.trim())return e;const t=this._sidePanelSearchQuery.toLowerCase().trim();return e.filter(e=>{var i,o,r;const n=e.title.toLowerCase().includes(t),a=e.id.toLowerCase().includes(t),s=(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||a||s||l})}_renderAdminModeContent(t){var i,o;if(!t)return e.html`
|
|
3100
3378
|
<div class="admin-mode-container">
|
|
3101
3379
|
<p>No role selected</p>
|
|
3102
3380
|
</div>
|
|
3103
|
-
`;const r=(null==(i=this._periodPreferences[t.id])?void 0:i.showPreviousYear)??t.showPreviousYear??!1,n=this._getDimensionsForRole(t.id),
|
|
3381
|
+
`;const r=(null==(i=this._periodPreferences[t.id])?void 0:i.showPreviousYear)??t.showPreviousYear??!1,n=this._getDimensionsForRole(t.id),a=n.length>0;if(a&&!(null==(o=this._periodPreferences[t.id])?void 0:o.dimensionSelections)){const e=this._periodPreferences[t.id]||{showDuration:!0,showInstant:!0,showPreviousYear:!1};e.dimensionSelections=[],n.forEach(t=>{var i,o;const r=this._getAllDimensionMembers(t.members).map(e=>e.id),n=(null==(o=null==(i=t.labels)?void 0:i.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:o.label)||t.conceptName;e.dimensionSelections&&e.dimensionSelections.push({dimensionId:t.id,dimensionLabel:n,selectedMemberIds:r})}),this._periodPreferences={...this._periodPreferences,[t.id]:e},console.log("✅ [Admin Mode] Initialized all dimension members as selected by default for role:",t.id)}return e.html`
|
|
3104
3382
|
<div class="admin-mode-container">
|
|
3105
3383
|
<h2 class="admin-mode-title">Role Configuration: ${t.title}</h2>
|
|
3106
3384
|
<div class="admin-roles-list">
|
|
@@ -3116,39 +3394,39 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3116
3394
|
</div>
|
|
3117
3395
|
</div>
|
|
3118
3396
|
|
|
3119
|
-
${
|
|
3397
|
+
${a?e.html`
|
|
3120
3398
|
<div class="admin-dimension-section">
|
|
3121
|
-
<div class="admin-dimension-header">📊 ${
|
|
3122
|
-
${n.map(i=>{var o,r;const n=this._getAllDimensionMembers(i.members),
|
|
3399
|
+
<div class="admin-dimension-header">📊 ${T.t("filter.dimensionMemberSelection")}</div>
|
|
3400
|
+
${n.map(i=>{var o,r;const n=this._getAllDimensionMembers(i.members),a=(null==(r=null==(o=i.labels)?void 0:o.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:r.label)||i.conceptName,s=this._isSingleMemberDimension(i);return e.html`
|
|
3123
3401
|
<div class="admin-dimension-group">
|
|
3124
|
-
<div class="admin-dimension-label">${
|
|
3402
|
+
<div class="admin-dimension-label">${a}${s?" (Mandatory)":""}</div>
|
|
3125
3403
|
<div class="admin-dimension-members">
|
|
3126
|
-
${n.map(o=>{var r,n;const
|
|
3404
|
+
${n.map(o=>{var r,n;const a=(null==(n=null==(r=o.labels)?void 0:r.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:n.label)||o.conceptName,l=this._isAdminDimensionMemberSelected(t.id,i.id,o.id);return e.html`
|
|
3127
3405
|
<label class="admin-member-checkbox-item">
|
|
3128
3406
|
<input
|
|
3129
3407
|
type="checkbox"
|
|
3130
3408
|
class="admin-member-checkbox"
|
|
3131
|
-
.checked="${
|
|
3132
|
-
?disabled="${
|
|
3409
|
+
.checked="${l}"
|
|
3410
|
+
?disabled="${s}"
|
|
3133
3411
|
@change="${e=>this._handleAdminDimensionMemberChange(e,t.id,i.id,o.id)}"
|
|
3134
3412
|
/>
|
|
3135
|
-
<span class="admin-member-checkbox-label">${
|
|
3413
|
+
<span class="admin-member-checkbox-label">${a}</span>
|
|
3136
3414
|
</label>
|
|
3137
3415
|
`})}
|
|
3138
3416
|
</div>
|
|
3139
|
-
${
|
|
3417
|
+
${s?"":e.html`
|
|
3140
3418
|
<div class="admin-member-select-controls">
|
|
3141
3419
|
<button
|
|
3142
3420
|
class="admin-member-select-btn"
|
|
3143
3421
|
@click="${()=>this._selectAllAdminDimensionMembers(t.id,i.id)}"
|
|
3144
3422
|
>
|
|
3145
|
-
${
|
|
3423
|
+
${T.t("filter.selectAllMembers")}
|
|
3146
3424
|
</button>
|
|
3147
3425
|
<button
|
|
3148
3426
|
class="admin-member-select-btn"
|
|
3149
3427
|
@click="${()=>this._deselectAllAdminDimensionMembers(t.id,i.id)}"
|
|
3150
3428
|
>
|
|
3151
|
-
${
|
|
3429
|
+
${T.t("filter.clearMembers")}
|
|
3152
3430
|
</button>
|
|
3153
3431
|
</div>
|
|
3154
3432
|
`}
|
|
@@ -3158,12 +3436,12 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3158
3436
|
`:""}
|
|
3159
3437
|
</div>
|
|
3160
3438
|
</div>
|
|
3161
|
-
`}_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])}_getDimensionsForRole(e){var t,i,o,r;if(!(null==(i=null==(t=this.xbrlInput)?void 0:t.hypercubes)?void 0:i[0]))return[];const n=null==(o=this.xbrlInput.hypercubes[0].roles)?void 0:o.find(t=>t.roleId===e);if(!(null==(r=null==n?void 0:n.items)?void 0:r.length))return[];const
|
|
3439
|
+
`}_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])}_getDimensionsForRole(e){var t,i,o,r;if(!(null==(i=null==(t=this.xbrlInput)?void 0:t.hypercubes)?void 0:i[0]))return[];const n=null==(o=this.xbrlInput.hypercubes[0].roles)?void 0:o.find(t=>t.roleId===e);if(!(null==(r=null==n?void 0:n.items)?void 0:r.length))return[];const a=new Map;return n.items.forEach(e=>{e.dimensions&&e.dimensions.forEach(e=>{a.has(e.id)||a.set(e.id,e)})}),Array.from(a.values())}_getAllDimensionMembers(e){if(!e||0===e.length)return[];let t=[];return e.forEach(e=>{t.push(e),e.children&&e.children.length>0&&(t=t.concat(this._getAllDimensionMembers(e.children)))}),t}_isSingleMemberDimension(e){if(!e||!e.members)return!1;return 1===this._getAllDimensionMembers(e.members).length}_handleAdminDimensionMemberChange(e,t,i,o){var r,n;e.stopPropagation();const a=e.target,s=this._periodPreferences[t]||{showDuration:!0,showInstant:!0,showPreviousYear:!1,dimensionSelections:[]};s.dimensionSelections||(s.dimensionSelections=[]);let l=s.dimensionSelections.find(e=>e.dimensionId===i);if(!l){const e=this._getDimensionsForRole(t).find(e=>e.id===i),o=(null==(n=null==(r=null==e?void 0:e.labels)?void 0:r.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:n.label)||i;l={dimensionId:i,dimensionLabel:o,selectedMemberIds:[]},s.dimensionSelections.push(l)}a.checked?l.selectedMemberIds.includes(o)||l.selectedMemberIds.push(o):l.selectedMemberIds=l.selectedMemberIds.filter(e=>e!==o),this._periodPreferences={...this._periodPreferences,[t]:s},console.log("📊 [Admin Mode] Updated dimension selections:",this._periodPreferences[t].dimensionSelections),this.requestUpdate()}_isAdminDimensionMemberSelected(e,t,i){const o=this._periodPreferences[e];if(!(null==o?void 0:o.dimensionSelections))return!0;const r=o.dimensionSelections.find(e=>e.dimensionId===t);return!r||r.selectedMemberIds.includes(i)}_selectAllAdminDimensionMembers(e,t){var i,o;const r=this._getDimensionsForRole(e).find(e=>e.id===t);if(!r)return;const n=this._getAllDimensionMembers(r.members).map(e=>e.id),a=this._periodPreferences[e]||{showDuration:!0,showInstant:!0,showPreviousYear:!1,dimensionSelections:[]};a.dimensionSelections||(a.dimensionSelections=[]);let s=a.dimensionSelections.find(e=>e.dimensionId===t);if(!s){const e=(null==(o=null==(i=r.labels)?void 0:i.find(e=>"http://www.xbrl.org/2003/role/label"===e.role))?void 0:o.label)||t;s={dimensionId:t,dimensionLabel:e,selectedMemberIds:[]},a.dimensionSelections.push(s)}s.selectedMemberIds=n,this._periodPreferences={...this._periodPreferences,[e]:a},this.requestUpdate()}_deselectAllAdminDimensionMembers(e,t){const i=this._periodPreferences[e];if(!(null==i?void 0:i.dimensionSelections))return;const o=i.dimensionSelections.find(e=>e.dimensionId===t);o&&(o.selectedMemberIds=[]),this._periodPreferences={...this._periodPreferences,[e]:i},this.requestUpdate()}_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});const a=this.dynaformsMetadata||this._loadMetadataFromLocalStorage();console.log("📋 Updated Presentation Data:",r),console.log("📋 Metadata from localStorage:",a),this.dispatchEvent(new CustomEvent("admin-config-updated",{detail:{presentationData:r,roleConfigs:this._adminRoleConfigs,metadata:a},bubbles:!0,composed:!0})),console.log("✅ Admin configuration saved successfully with metadata")}_loadMetadataFromLocalStorage(){try{const e=localStorage.getItem("jupiter-form-draft-metadata");if(e)return JSON.parse(e)}catch(e){console.error("Failed to load metadata from localStorage:",e)}return null}_renderAccordionLayout(t,i,o,r){return e.html`
|
|
3162
3440
|
<div class="form-sections">
|
|
3163
3441
|
<!-- Validation Summary -->
|
|
3164
3442
|
${o?e.html`
|
|
3165
3443
|
<div class="validation-summary ${0===r?"warnings-only":""}">
|
|
3166
|
-
<h4 class="validation-summary-title">${r>0?
|
|
3444
|
+
<h4 class="validation-summary-title">${r>0?T.t("validation.summary"):T.t("calculationWarning.title")}</h4>
|
|
3167
3445
|
<ul class="validation-summary-list">
|
|
3168
3446
|
${this._errors.filter(e=>"error"===e.severity||"warning"===e.severity&&"readonly"!==this.mode).map(t=>e.html`
|
|
3169
3447
|
<li class="validation-summary-item ${t.severity}">${"warning"===t.severity?"⚠️ ":""}${t.message}</li>
|
|
@@ -3179,16 +3457,16 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3179
3457
|
</div>
|
|
3180
3458
|
`):0===t.sections.length?e.html`
|
|
3181
3459
|
<div class="no-roles-message">
|
|
3182
|
-
<h3>${
|
|
3183
|
-
<p>${
|
|
3184
|
-
<p>${
|
|
3460
|
+
<h3>${T.t("form.noRoleSelected")}</h3>
|
|
3461
|
+
<p>${T.t("filter.selectRoles")}</p>
|
|
3462
|
+
<p>${T.t("filter.roles")}: ${this._allSections.length}</p>
|
|
3185
3463
|
</div>
|
|
3186
|
-
`:(()=>{const o=this._getConceptSearchMatchIds(this._conceptSearchText),r=this._conceptSearchText.trim().length>0;let n=t.sections;return("readonly"===this.mode||this._showFactsOnly)&&(n=n.filter(e=>!this._isSectionBlank(e))),r&&(n=n.filter(e=>this._isSectionConceptSearchMatch(e,o))),n.map((t,n)=>{var
|
|
3464
|
+
`:(()=>{const o=this._getConceptSearchMatchIds(this._conceptSearchText),r=this._conceptSearchText.trim().length>0;let n=t.sections;return("readonly"===this.mode||this._showFactsOnly)&&(n=n.filter(e=>!this._isSectionBlank(e))),r&&(n=n.filter(e=>this._isSectionConceptSearchMatch(e,o))),n.map((t,n)=>{var a;return e.html`
|
|
3187
3465
|
<jupiter-form-section
|
|
3188
3466
|
section-id="${t.id}"
|
|
3189
3467
|
.section="${t}"
|
|
3190
3468
|
.columns="${this._getColumnsWithHiddenFlags(t)}"
|
|
3191
|
-
.datatypes="${t.datatypes||(null==(
|
|
3469
|
+
.datatypes="${t.datatypes||(null==(a=this.xbrlInput)?void 0:a.datatypes)}"
|
|
3192
3470
|
.formData="${this._formData}"
|
|
3193
3471
|
.periodData="${this._periodData}"
|
|
3194
3472
|
.unitData="${this._unitData}"
|
|
@@ -3210,6 +3488,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3210
3488
|
.periodStartDate="${this.periodStartDate}"
|
|
3211
3489
|
.periodEndDate="${this.periodEndDate}"
|
|
3212
3490
|
.calculationEnabled="${this.calculationEnabled}"
|
|
3491
|
+
.totalManuallyEditedData="${this._totalManuallyEditedData}"
|
|
3213
3492
|
@field-change="${this._handleFieldChange}"
|
|
3214
3493
|
@period-change="${this._handlePeriodChange}"
|
|
3215
3494
|
@typed-member-change="${this._handleTypedMemberChange}"
|
|
@@ -3224,7 +3503,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3224
3503
|
></jupiter-form-section>
|
|
3225
3504
|
`})})()}
|
|
3226
3505
|
</div>
|
|
3227
|
-
`}_renderSidePanelLayout(t,i,o,r){var n;const
|
|
3506
|
+
`}_renderSidePanelLayout(t,i,o,r){var n;const a=this._getConceptSearchMatchIds(this._conceptSearchText),s=this._conceptSearchText.trim().length>0;let l="readonly"===this.mode||this._showFactsOnly?t.sections.filter(e=>!this._isSectionBlank(e)):t.sections;s&&(l=l.filter(e=>this._isSectionConceptSearchMatch(e,a)));const d=this._filterSidePanelSections(l);this._activeSidePanelRoleId&&d.find(e=>e.id===this._activeSidePanelRoleId)||(this._activeSidePanelRoleId=d.length>0?d[0].id:null);const c=l.find(e=>e.id===this._activeSidePanelRoleId);return e.html`
|
|
3228
3507
|
<div class="side-panel-layout">
|
|
3229
3508
|
<!-- Left: Roles List (filtered) -->
|
|
3230
3509
|
<div class="side-panel-roles-list ${this._sidePanelCollapsed?"collapsed":""}">
|
|
@@ -3232,7 +3511,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3232
3511
|
<button
|
|
3233
3512
|
class="side-panel-toggle-btn ${this._sidePanelCollapsed?"collapsed":""}"
|
|
3234
3513
|
@click="${this._toggleSidePanelCollapse}"
|
|
3235
|
-
title="${this._sidePanelCollapsed?
|
|
3514
|
+
title="${this._sidePanelCollapsed?T.t("form.expandPanel"):T.t("form.collapsePanel")}"
|
|
3236
3515
|
>
|
|
3237
3516
|
<svg viewBox="0 0 24 24">
|
|
3238
3517
|
<path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/>
|
|
@@ -3245,12 +3524,12 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3245
3524
|
<input
|
|
3246
3525
|
type="text"
|
|
3247
3526
|
class="side-panel-search-input"
|
|
3248
|
-
placeholder="${
|
|
3527
|
+
placeholder="${T.t("filter.searchPlaceholder")}"
|
|
3249
3528
|
.value="${this._sidePanelSearchQuery}"
|
|
3250
3529
|
@input="${this._handleSidePanelSearchInput}"
|
|
3251
3530
|
/>
|
|
3252
3531
|
${this._sidePanelSearchQuery?e.html`
|
|
3253
|
-
<button class="side-panel-clear-search" @click="${this._clearSidePanelSearch}" title="${
|
|
3532
|
+
<button class="side-panel-clear-search" @click="${this._clearSidePanelSearch}" title="${T.t("filter.clearSearch")}">
|
|
3254
3533
|
×
|
|
3255
3534
|
</button>
|
|
3256
3535
|
`:e.html`
|
|
@@ -3261,17 +3540,17 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3261
3540
|
</div>
|
|
3262
3541
|
|
|
3263
3542
|
<!-- Search Results Info -->
|
|
3264
|
-
${this._sidePanelSearchQuery.trim()&&d.length!==
|
|
3543
|
+
${this._sidePanelSearchQuery.trim()&&d.length!==l.length?e.html`
|
|
3265
3544
|
<div class="side-panel-search-results-info">
|
|
3266
|
-
${d.length} ${
|
|
3545
|
+
${d.length} ${T.t("filter.of")} ${l.length} ${T.t("filter.roles")}
|
|
3267
3546
|
</div>
|
|
3268
3547
|
`:""}
|
|
3269
3548
|
|
|
3270
3549
|
<!-- Roles List -->
|
|
3271
3550
|
${0===d.length?e.html`
|
|
3272
3551
|
<div class="side-panel-no-results">
|
|
3273
|
-
${
|
|
3274
|
-
${
|
|
3552
|
+
${T.t("filter.noRolesFound")} "${this._sidePanelSearchQuery}"<br>
|
|
3553
|
+
${T.t("filter.tryDifferentSearch")}
|
|
3275
3554
|
</div>
|
|
3276
3555
|
`:e.html`
|
|
3277
3556
|
${d.map(t=>{const i=this._roleHasErrors(t.id),o=this._roleBorderStatuses.get(t.id),r=!0===this._roleCompletedStates.get(t.id)?"has-complete-data":i?"has-errors":"untouched"===o?"has-no-data":"incomplete"===o?"has-empty-fields":"complete"===o?"has-complete-data":"";return e.html`
|
|
@@ -3293,7 +3572,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3293
3572
|
<!-- Validation Summary -->
|
|
3294
3573
|
${o?e.html`
|
|
3295
3574
|
<div class="validation-summary ${0===r?"warnings-only":""}">
|
|
3296
|
-
<h4 class="validation-summary-title">${r>0?
|
|
3575
|
+
<h4 class="validation-summary-title">${r>0?T.t("validation.summary"):T.t("calculationWarning.title")}</h4>
|
|
3297
3576
|
<ul class="validation-summary-list">
|
|
3298
3577
|
${this._errors.filter(e=>"error"===e.severity||"warning"===e.severity&&"readonly"!==this.mode).map(t=>e.html`
|
|
3299
3578
|
<li class="validation-summary-item ${t.severity}">${"warning"===t.severity?"⚠️ ":""}${t.message}</li>
|
|
@@ -3330,11 +3609,12 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3330
3609
|
.availableDimensions="${this._getAvailableDimensionsForSection(c.id)}"
|
|
3331
3610
|
.mode="${this.mode}"
|
|
3332
3611
|
.showFactsOnly="${this._showFactsOnly}"
|
|
3333
|
-
.conceptMatchIds="${
|
|
3612
|
+
.conceptMatchIds="${s?a:void 0}"
|
|
3334
3613
|
.masterData="${this._effectiveMasterData}"
|
|
3335
3614
|
.periodStartDate="${this.periodStartDate}"
|
|
3336
3615
|
.periodEndDate="${this.periodEndDate}"
|
|
3337
3616
|
.calculationEnabled="${this.calculationEnabled}"
|
|
3617
|
+
.totalManuallyEditedData="${this._totalManuallyEditedData}"
|
|
3338
3618
|
@field-change="${this._handleFieldChange}"
|
|
3339
3619
|
@typed-member-change="${this._handleTypedMemberChange}"
|
|
3340
3620
|
@add-concept-repeat="${this._handleAddConceptRepeat}"
|
|
@@ -3353,31 +3633,31 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3353
3633
|
.checked="${!0===this._roleCompletedStates.get(c.id)}"
|
|
3354
3634
|
@change="${e=>this._handleRoleCompletedChange(c.id,e.target.checked)}"
|
|
3355
3635
|
>
|
|
3356
|
-
<label for="role-complete-${c.id}">${
|
|
3636
|
+
<label for="role-complete-${c.id}">${T.t("form.markAsComplete")}</label>
|
|
3357
3637
|
</div>
|
|
3358
3638
|
`:e.html`
|
|
3359
3639
|
<div class="no-roles-message">
|
|
3360
|
-
<h3>${
|
|
3361
|
-
<p>${
|
|
3640
|
+
<h3>${T.t("form.noRoleSelected")}</h3>
|
|
3641
|
+
<p>${T.t("form.pleaseSelectRole")}</p>
|
|
3362
3642
|
</div>
|
|
3363
3643
|
`}
|
|
3364
3644
|
</div>
|
|
3365
3645
|
</div>
|
|
3366
3646
|
</div>
|
|
3367
|
-
`}getData(){return{...this._formData}}setData(e){this._formData={...e},this._dirty=!0,this._validateForm(),this.requestUpdate()}validate(){return this._validateForm(),this._valid}setValidation(e){console.log(`🔍 Validation status updated: ${e}`),this._validationStatus="cancel"===e?"idle":e,this.requestUpdate()}reset(){this._handleReset()}getState(){return this._getFormState()}_findConceptByName(e,t){var i;const o=t.includes(":")?t.split(":").pop():t;for(const r of e){if(r.name===t)return r;if((r.name.includes(":")?r.name.split(":").pop():r.name)===o)return r;if(null==(i=r.children)?void 0:i.length){const e=this._findConceptByName(r.children,t);if(e)return e}}return null}_findColumnByDimensions(e,t){var i;return null==(i=e.find(e=>{if("dimension"!==e.type||!e.dimensionData)return!1;const i=e.dimensionData.combinations;return(null==i?void 0:i.length)?t.every(e=>i.some(t=>this._normalizeAxisId(t.axisId)===this._normalizeAxisId(e.axis)&&this._normalizeMemberId(t.memberId)===this._normalizeMemberId(e.member))):1===t.length&&this._normalizeAxisId(e.dimensionData.axisId??"")===this._normalizeAxisId(t[0].axis)&&this._normalizeMemberId(e.dimensionData.memberId??"")===this._normalizeMemberId(t[0].member)}))?void 0:i.id}async scrollToConcept(e,t,i){var
|
|
3647
|
+
`}getData(){return{...this._formData}}setData(e){this._formData={...e},this._dirty=!0,this._validateForm(),this.requestUpdate()}validate(){return this._validateForm(),this._valid}setValidation(e){console.log(`🔍 Validation status updated: ${e}`),this._validationStatus="cancel"===e?"idle":e,this.requestUpdate()}reset(){this._handleReset()}getState(){return this._getFormState()}_findConceptByName(e,t){var i;const o=t.includes(":")?t.split(":").pop():t;for(const r of e){if(r.name===t)return r;if((r.name.includes(":")?r.name.split(":").pop():r.name)===o)return r;if(null==(i=r.children)?void 0:i.length){const e=this._findConceptByName(r.children,t);if(e)return e}}return null}_findColumnByDimensions(e,t){var i;return null==(i=e.find(e=>{if("dimension"!==e.type||!e.dimensionData)return!1;const i=e.dimensionData.combinations;return(null==i?void 0:i.length)?t.every(e=>i.some(t=>this._normalizeAxisId(t.axisId)===this._normalizeAxisId(e.axis)&&this._normalizeMemberId(t.memberId)===this._normalizeMemberId(e.member))):1===t.length&&this._normalizeAxisId(e.dimensionData.axisId??"")===this._normalizeAxisId(t[0].axis)&&this._normalizeMemberId(e.dimensionData.memberId??"")===this._normalizeMemberId(t[0].member)}))?void 0:i.id}async scrollToConcept(e,t,i,o){var r,n,a,s,l,d,c,p,u,h,m,f;console.log(`[scrollToConcept] ▶ START conceptName=${e} value=${null==i?void 0:i.value} dims=${JSON.stringify(t)} columnId=${o}`);let g=null,b=null;const v=[...(null==(r=this._currentSchema)?void 0:r.sections)??[],...this._allSections.filter(e=>{var t;return!(null==(t=this._currentSchema)?void 0:t.sections.find(t=>t.id===e.id))})];console.log(`[scrollToConcept] Searching ${v.length} sections`);for(const z of v){const i=this._findConceptByName(z.concepts,e);if(i)if(o){const e=(z.columns??this._columns).some(e=>e.id===o);if(console.log(`[scrollToConcept] Section "${z.id}" has concept "${i.id}" | columnId="${o}" present=${e}`),e){g=z,b=i;break}g||(g=z,b=i)}else{if(!(null==t?void 0:t.length)){console.log(`[scrollToConcept] Section "${z.id}" has concept "${i.id}" (no dims, taking first)`),g=z,b=i;break}{const e=z.columns??this._columns,o=this._findColumnByDimensions(e,t);if(console.log(`[scrollToConcept] Section "${z.id}" has concept "${i.id}" | colMatch=${o??"null"} | cols=${e.map(e=>e.id).join(",")}`),o){g=z,b=i;break}g||(g=z,b=i)}}}if(!g||!b)return void console.warn(`[scrollToConcept] Concept not found: ${e}`);console.log(`[scrollToConcept] → targetSection="${g.id}" targetConceptId="${b.id}"`),g.expanded=!0,"sidePanel"===this.display&&this._activeSidePanelRoleId!==g.id&&(this._activeSidePanelRoleId=g.id);const y=g.columns??this._columns;let x=null;const _=void 0!==(null==i?void 0:i.value)&&null!==(null==i?void 0:i.value),D=_?String(i.value):null;o?x=o:(null==t?void 0:t.length)?x=this._findColumnByDimensions(y,t)??null:_||(x=(null==(n=y[0])?void 0:n.id)??null),console.log(`[scrollToConcept] targetColumnId=${x} hasValueMatch=${_} targetValue=${D}`),this._conceptSearchText=e.includes(":")?e.split(":").pop():e,this.requestUpdate(),await this.updateComplete,await new Promise(e=>setTimeout(e,300));const I=null==(a=this.shadowRoot)?void 0:a.querySelectorAll("jupiter-form-section");console.log(`[scrollToConcept] DOM: found ${(null==I?void 0:I.length)??0} jupiter-form-section elements`);let $=null;if(null==I||I.forEach(e=>{var t;(null==(t=e.section)?void 0:t.id)===g.id&&($=e)}),!$)return void console.warn(`[scrollToConcept] Section element not found: ${g.id}`);await $.updateComplete;const w=null==(s=$.shadowRoot)?void 0:s.querySelectorAll("jupiter-concept-tree");console.log(`[scrollToConcept] conceptTrees in targetSection: ${(null==w?void 0:w.length)??0}`);let S=null;const C=b.id,F=C.includes("__")?C.split("__")[0]:C;console.log(`[scrollToConcept] conceptId="${C}" conceptIdBase="${F}"`);const k=e=>e===C||e.includes("__")&&e.split("__")[0]===F,T=e=>{const t=e.decimals||(void 0!==e.globalDecimals&&"INF"!==e.globalDecimals?e.globalDecimals:null);if(!t)return 1;const i=parseFloat(String(t));return isNaN(i)||i<=0?1:Math.pow(10,i)},E=(e,t)=>{if(String(e.value??"")===t)return!0;const i=Number(t),o=Number(e.value);if(!isNaN(i)&&!isNaN(o)&&0!==o){const t=T(e);if(1!==t&&Math.abs(o*t-i)<1e-4)return!0}return!1};let R=0;if(null==w||w.forEach(e=>{var t;if(S)return;const i=null==(t=e.shadowRoot)?void 0:t.querySelectorAll("jupiter-form-field");null==i||i.forEach(e=>{if(S)return;const t=x?e.conceptId===C&&e.columnId===x:e.conceptId===C,i=!_||E(e,D);t&&(R++,console.log(`[scrollToConcept] Phase1 candidate: conceptId=${e.conceptId} columnId=${e.columnId} value=${e.value} scale=${T(e)} valueMatch=${i}`)),t&&i&&(S=e)})}),console.log(`[scrollToConcept] Phase1: scanned ${R} candidates, found=${!!S}`),!S&&_){console.log("[scrollToConcept] Phase2: searching ALL sections by base concept name + value");const e=(null==(l=this.shadowRoot)?void 0:l.querySelectorAll("jupiter-form-section"))??[];for(const t of Array.from(e)){if(S)break;const e=(null==(d=t.shadowRoot)?void 0:d.querySelectorAll("jupiter-concept-tree"))??[];for(const t of Array.from(e)){if(S)break;((null==(c=t.shadowRoot)?void 0:c.querySelectorAll("jupiter-form-field"))??[]).forEach(e=>{if(S)return;const t=k(e.conceptId),i=E(e,D);t&&console.log(`[scrollToConcept] Phase2 candidate: conceptId=${e.conceptId} value=${e.value} scale=${T(e)} valMatch=${i}`),t&&i&&(console.log(`[scrollToConcept] Phase2 ✅ MATCH: conceptId=${e.conceptId} columnId=${e.columnId} value=${e.value}`),S=e)})}}}if(!S){const e=(null==(p=this.shadowRoot)?void 0:p.querySelectorAll("jupiter-form-section"))??[];for(const t of Array.from(e)){if(S)break;const e=(null==(u=t.shadowRoot)?void 0:u.querySelectorAll("jupiter-concept-tree"))??[];for(const t of Array.from(e)){if(S)break;((null==(h=t.shadowRoot)?void 0:h.querySelectorAll("jupiter-form-field"))??[]).forEach(e=>{if(S)return;(x?k(e.conceptId)&&e.columnId===x:k(e.conceptId))&&(console.log(`[scrollToConcept] Phase3 ✅ fallback: conceptId=${e.conceptId} columnId=${e.columnId} value=${e.value}`),S=e)})}}}if(!S)return void console.warn(`[scrollToConcept] Field element not found for concept: ${e}`);console.log(`[scrollToConcept] ✅ HIGHLIGHTING conceptId=${S.conceptId} columnId=${S.columnId} value=${S.value}`);const M=S.getBoundingClientRect(),A=this.shadowRoot,j=A?A.querySelector(".side-panel-content")??A.querySelector(".form-container"):null,P=j&&j.scrollHeight>j.clientHeight?j:null;if(P){const e=P.getBoundingClientRect(),t=Math.max(0,M.top-e.top+P.scrollTop-P.clientHeight/2+M.height/2);P.scrollTo({top:t,behavior:"smooth"})}else S.scrollIntoView({behavior:"smooth",block:"center"});const L=null==(m=null==$?void 0:$.shadowRoot)?void 0:m.querySelector(".table-container");if(L&&L.scrollWidth>L.clientWidth){const e=L.getBoundingClientRect(),t=Math.max(0,M.left-e.left+L.scrollLeft-L.clientWidth/2+M.width/2);L.scrollTo({left:t,behavior:"smooth"})}const N=S.getRootNode(),V=(N instanceof ShadowRoot?N.host:null)??S;V.classList.add("concept-highlight");const O=null==(f=S.shadowRoot)?void 0:f.querySelector('input:not([type="hidden"]), select, textarea, button, [tabindex]:not([tabindex="-1"])');O&&setTimeout(()=>O.focus({preventScroll:!0}),450),setTimeout(()=>V.classList.remove("concept-highlight"),1e4)}render(){var t;const i=this._errors.filter(e=>"error"===e.severity).length,o="readonly"===this.mode?0:this._errors.filter(e=>"warning"===e.severity).length,r=this.config||{},n=!1!==r.showValidationSummary&&(i>0&&this._submitted||o>0),a=this._currentSchema;return a?e.html`
|
|
3368
3648
|
<div class="form-container">
|
|
3369
3649
|
<!-- Form Header - Hidden in side panel mode -->
|
|
3370
3650
|
${"sidePanel"!==this.display?e.html`
|
|
3371
3651
|
<div class="form-header">
|
|
3372
|
-
<h1 class="form-title">${
|
|
3373
|
-
${
|
|
3374
|
-
<p class="form-description">${
|
|
3652
|
+
<h1 class="form-title">${a.title}</h1>
|
|
3653
|
+
${a.description?e.html`
|
|
3654
|
+
<p class="form-description">${a.description}</p>
|
|
3375
3655
|
`:""}
|
|
3376
3656
|
</div>
|
|
3377
3657
|
`:""}
|
|
3378
3658
|
|
|
3379
3659
|
<!-- Form Content -->
|
|
3380
|
-
${"sidePanel"===this.display?this._renderSidePanelLayout(
|
|
3660
|
+
${"sidePanel"===this.display?this._renderSidePanelLayout(a,r,n,i):this._renderAccordionLayout(a,r,n,i)}
|
|
3381
3661
|
|
|
3382
3662
|
<!-- Form Actions - Fixed Footer (hidden in readonly mode) -->
|
|
3383
3663
|
${"readonly"!==this.mode?e.html`
|
|
@@ -3392,7 +3672,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3392
3672
|
<svg class="filter-icon" viewBox="0 0 24 24">
|
|
3393
3673
|
<path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
|
|
3394
3674
|
</svg>
|
|
3395
|
-
${0===this._selectedRoleIds.length?
|
|
3675
|
+
${0===this._selectedRoleIds.length?T.t("filter.selectRoles"):T.t("filter.filterRoles")}
|
|
3396
3676
|
<span class="roles-count">${this._selectedRoleIds.length}/${this._allSections.length}</span>
|
|
3397
3677
|
</button>
|
|
3398
3678
|
${this._hasActiveAdvancedFilters?e.html`
|
|
@@ -3401,7 +3681,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3401
3681
|
@click="${this._handleClearAdvancedFilters}"
|
|
3402
3682
|
?disabled="${this.disabled||this.readonly}"
|
|
3403
3683
|
>
|
|
3404
|
-
× ${
|
|
3684
|
+
× ${T.t("filter.clearFilters")}
|
|
3405
3685
|
</button>
|
|
3406
3686
|
`:""}
|
|
3407
3687
|
`:""}
|
|
@@ -3412,7 +3692,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3412
3692
|
@click="${this._handleSaveDraft}"
|
|
3413
3693
|
?disabled="${this.disabled||this.readonly||this.isDraftSaving}"
|
|
3414
3694
|
>
|
|
3415
|
-
${this.isDraftSaving?
|
|
3695
|
+
${this.isDraftSaving?T.t("form.savingDraft"):T.t("form.saveDraft")}
|
|
3416
3696
|
</button>
|
|
3417
3697
|
`:""}
|
|
3418
3698
|
|
|
@@ -3424,7 +3704,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3424
3704
|
@click="${()=>this.dispatchEvent(new CustomEvent("showPreview",{bubbles:!0,composed:!0}))}"
|
|
3425
3705
|
?disabled="${this.disabled||this.readonly}"
|
|
3426
3706
|
>
|
|
3427
|
-
${
|
|
3707
|
+
${T.t("form.download")}
|
|
3428
3708
|
</button>
|
|
3429
3709
|
`:""}
|
|
3430
3710
|
|
|
@@ -3434,17 +3714,26 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3434
3714
|
@click="${()=>this.dispatchEvent(new CustomEvent("show-validation-results",{bubbles:!0,composed:!0}))}"
|
|
3435
3715
|
?disabled="${this.disabled||this.readonly}"
|
|
3436
3716
|
>
|
|
3437
|
-
${
|
|
3717
|
+
${T.t("form.lastValidationResults")}
|
|
3438
3718
|
</button>
|
|
3439
3719
|
`:""}
|
|
3440
3720
|
|
|
3721
|
+
${this.formulaEnabled&&"admin"!==this.mode?e.html`
|
|
3722
|
+
<button
|
|
3723
|
+
class="btn-secondary btn-quick-validate"
|
|
3724
|
+
@click="${this._handleQuickValidate}"
|
|
3725
|
+
?disabled="${this.disabled||this.readonly||"inProgress"===this._validationStatus}"
|
|
3726
|
+
>
|
|
3727
|
+
${T.t("form.quickValidate")}
|
|
3728
|
+
</button>
|
|
3729
|
+
`:""}
|
|
3441
3730
|
|
|
3442
3731
|
<button
|
|
3443
3732
|
class="btn-primary"
|
|
3444
3733
|
@click="${this._handleSubmit}"
|
|
3445
3734
|
?disabled="${this.disabled||this.readonly||this._submitDisabled||"inProgress"===this._validationStatus}"
|
|
3446
3735
|
>
|
|
3447
|
-
${this.submitButtonLabel||("admin"===this.mode?
|
|
3736
|
+
${this.submitButtonLabel||("admin"===this.mode?T.t("form.save"):T.t("form.submit"))}
|
|
3448
3737
|
</button>
|
|
3449
3738
|
|
|
3450
3739
|
</div>
|
|
@@ -3467,31 +3756,43 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3467
3756
|
@click="${this._handleFilterDialogCancel}"
|
|
3468
3757
|
></jupiter-filter-roles-dialog>
|
|
3469
3758
|
`:""}
|
|
3470
|
-
|
|
3759
|
+
|
|
3760
|
+
<!-- Formula Validation Results Dialog (JDF-050) -->
|
|
3761
|
+
${this._showFormulaValidationDialog?e.html`
|
|
3762
|
+
<jupiter-formula-validation-dialog
|
|
3763
|
+
?open="${this._showFormulaValidationDialog}"
|
|
3764
|
+
.results="${this._formulaValidationResults}"
|
|
3765
|
+
.summary="${this._formulaValidationSummary}"
|
|
3766
|
+
@dialog-cancel="${this._handleFormulaValidationDialogCancel}"
|
|
3767
|
+
@formula-concept-click="${this._handleFormulaConceptClick}"
|
|
3768
|
+
@click="${this._handleFormulaValidationDialogCancel}"
|
|
3769
|
+
></jupiter-formula-validation-dialog>
|
|
3770
|
+
`:""}
|
|
3771
|
+
|
|
3471
3772
|
<!-- Validation Error Popup -->
|
|
3472
3773
|
${this._showErrorPopup?e.html`
|
|
3473
3774
|
<div class="error-popup-overlay" @click="${()=>{this._showErrorPopup=!1,this.requestUpdate()}}">
|
|
3474
3775
|
<div class="error-popup" @click="${e=>e.stopPropagation()}">
|
|
3475
3776
|
<div class="error-popup-header">
|
|
3476
|
-
<h3>⚠️ ${
|
|
3777
|
+
<h3>⚠️ ${T.t("error.popup.title")}</h3>
|
|
3477
3778
|
<button class="error-popup-close" @click="${()=>{this._showErrorPopup=!1,this.requestUpdate()}}">×</button>
|
|
3478
3779
|
</div>
|
|
3479
3780
|
<div class="error-popup-content">
|
|
3480
|
-
<p>${
|
|
3781
|
+
<p>${T.t("error.popup.message")}</p>
|
|
3481
3782
|
<ul class="error-list">
|
|
3482
3783
|
${this._xbrlFormErrors.map(t=>{const i=this._findConceptInAllSections(t.conceptId),o=this._findColumnById(t.columnId),r=(null==i?void 0:i.label)||t.conceptId,n=(null==o?void 0:o.title)||t.columnId;return e.html`
|
|
3483
3784
|
<li>
|
|
3484
|
-
<strong>${
|
|
3785
|
+
<strong>${T.t("error.popup.field")}</strong>
|
|
3485
3786
|
<a
|
|
3486
3787
|
href="javascript:void(0)"
|
|
3487
3788
|
class="error-field-link"
|
|
3488
3789
|
@click="${()=>this._handleErrorFieldClick(t.conceptId,t.columnId,t.sectionId)}"
|
|
3489
|
-
title="${
|
|
3790
|
+
title="${T.t("error.popup.clickToFocus")}"
|
|
3490
3791
|
>
|
|
3491
3792
|
${r} (${n})
|
|
3492
3793
|
</a><br>
|
|
3493
|
-
<strong>${
|
|
3494
|
-
<strong>${
|
|
3794
|
+
<strong>${T.t("error.popup.value")}</strong> ${t.value}<br>
|
|
3795
|
+
<strong>${T.t("error.popup.errors")}</strong>
|
|
3495
3796
|
<ul>
|
|
3496
3797
|
${t.errors.map(t=>e.html`<li>${t.message}</li>`)}
|
|
3497
3798
|
</ul>
|
|
@@ -3500,7 +3801,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3500
3801
|
</ul>
|
|
3501
3802
|
</div>
|
|
3502
3803
|
<div class="error-popup-footer">
|
|
3503
|
-
<button class="btn-primary" @click="${()=>{this._showErrorPopup=!1,this.requestUpdate()}}">${
|
|
3804
|
+
<button class="btn-primary" @click="${()=>{this._showErrorPopup=!1,this.requestUpdate()}}">${T.t("error.popup.ok")}</button>
|
|
3504
3805
|
</div>
|
|
3505
3806
|
</div>
|
|
3506
3807
|
</div>
|
|
@@ -3525,7 +3826,7 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
3525
3826
|
</div>
|
|
3526
3827
|
`:""}
|
|
3527
3828
|
</div>
|
|
3528
|
-
`:e.html`<div>${
|
|
3829
|
+
`:e.html`<div>${T.t("form.loading")}</div>`}},exports.JupiterDynamicForm.styles=e.css`
|
|
3529
3830
|
:host {
|
|
3530
3831
|
display: block;
|
|
3531
3832
|
font-family: var(--jupiter-font-family, system-ui, -apple-system, sans-serif);
|
|
@@ -4342,5 +4643,5 @@ const I={attribute:!0,type:String,converter:y,reflect:!1,hasChanged:x},$=(e=I,t,
|
|
|
4342
4643
|
.context-menu-item.danger:hover {
|
|
4343
4644
|
background: #ffebee;
|
|
4344
4645
|
}
|
|
4345
|
-
`,
|
|
4646
|
+
`,Be([w({type:Object})],exports.JupiterDynamicForm.prototype,"schema",2),Be([w({type:Object})],exports.JupiterDynamicForm.prototype,"xbrlInput",2),Be([w({type:Object})],exports.JupiterDynamicForm.prototype,"config",2),Be([w({type:Object})],exports.JupiterDynamicForm.prototype,"initialData",2),Be([w({type:Boolean})],exports.JupiterDynamicForm.prototype,"disabled",2),Be([w({type:Boolean})],exports.JupiterDynamicForm.prototype,"readonly",2),Be([w({type:Boolean,attribute:"calculation-enabled"})],exports.JupiterDynamicForm.prototype,"calculationEnabled",2),Be([w({type:Boolean,attribute:"formula-enabled"})],exports.JupiterDynamicForm.prototype,"formulaEnabled",2),Be([w({type:String})],exports.JupiterDynamicForm.prototype,"periodStartDate",2),Be([w({type:String})],exports.JupiterDynamicForm.prototype,"periodEndDate",2),Be([w({type:String})],exports.JupiterDynamicForm.prototype,"language",2),Be([w({type:String})],exports.JupiterDynamicForm.prototype,"reportingLanguage",2),Be([w({type:String})],exports.JupiterDynamicForm.prototype,"display",2),Be([w({type:String})],exports.JupiterDynamicForm.prototype,"mode",2),Be([w({type:String,attribute:"submit-button-label"})],exports.JupiterDynamicForm.prototype,"submitButtonLabel",2),Be([w({type:Array})],exports.JupiterDynamicForm.prototype,"roleFilterAxes",2),Be([w({type:Boolean,attribute:"show-last-validation-result-btn"})],exports.JupiterDynamicForm.prototype,"showLastValidationResultBtn",2),Be([w({type:Boolean,attribute:"is-draft-saving"})],exports.JupiterDynamicForm.prototype,"isDraftSaving",2),Be([w({type:Array})],exports.JupiterDynamicForm.prototype,"defaultUnits",2),Be([w({type:String})],exports.JupiterDynamicForm.prototype,"decimals",2),Be([w({type:Object,attribute:"master-data"})],exports.JupiterDynamicForm.prototype,"masterData",2),Be([w({type:Object,attribute:"dynaforms-metadata"})],exports.JupiterDynamicForm.prototype,"dynaformsMetadata",2),Be([w({type:Object,attribute:"dynaforms-facts"})],exports.JupiterDynamicForm.prototype,"dynaformsFacts",2),Be([S()],exports.JupiterDynamicForm.prototype,"_formData",2),Be([S()],exports.JupiterDynamicForm.prototype,"_draftLoaded",2),Be([S()],exports.JupiterDynamicForm.prototype,"_draftLoadedAt",2),Be([S()],exports.JupiterDynamicForm.prototype,"_preservedFormData",2),Be([S()],exports.JupiterDynamicForm.prototype,"_periodData",2),Be([S()],exports.JupiterDynamicForm.prototype,"_preservedPeriodData",2),Be([S()],exports.JupiterDynamicForm.prototype,"_unitData",2),Be([S()],exports.JupiterDynamicForm.prototype,"_preservedUnitData",2),Be([S()],exports.JupiterDynamicForm.prototype,"_decimalsData",2),Be([S()],exports.JupiterDynamicForm.prototype,"_totalManuallyEditedData",2),Be([S()],exports.JupiterDynamicForm.prototype,"_effectiveMasterData",2),Be([S()],exports.JupiterDynamicForm.prototype,"_typedMemberData",2),Be([S()],exports.JupiterDynamicForm.prototype,"_preservedTypedMemberData",2),Be([S()],exports.JupiterDynamicForm.prototype,"_repeatCounts",2),Be([S()],exports.JupiterDynamicForm.prototype,"_hiddenColumnIds",2),Be([S()],exports.JupiterDynamicForm.prototype,"_columns",2),Be([S()],exports.JupiterDynamicForm.prototype,"_errors",2),Be([S()],exports.JupiterDynamicForm.prototype,"_touched",2),Be([S()],exports.JupiterDynamicForm.prototype,"_dirty",2),Be([S()],exports.JupiterDynamicForm.prototype,"_valid",2),Be([S()],exports.JupiterDynamicForm.prototype,"_submitted",2),Be([S()],exports.JupiterDynamicForm.prototype,"_xbrlFormErrors",2),Be([S()],exports.JupiterDynamicForm.prototype,"_calculationWarnings",2),Be([S()],exports.JupiterDynamicForm.prototype,"_showErrorPopup",2),Be([S()],exports.JupiterDynamicForm.prototype,"_submitDisabled",2),Be([S()],exports.JupiterDynamicForm.prototype,"_currentSchema",2),Be([S()],exports.JupiterDynamicForm.prototype,"_allSections",2),Be([S()],exports.JupiterDynamicForm.prototype,"_selectedRoleIds",2),Be([S()],exports.JupiterDynamicForm.prototype,"_showFilterDialog",2),Be([S()],exports.JupiterDynamicForm.prototype,"_showFactsOnly",2),Be([S()],exports.JupiterDynamicForm.prototype,"_conceptSearchText",2),Be([S()],exports.JupiterDynamicForm.prototype,"_periodPreferences",2),Be([S()],exports.JupiterDynamicForm.prototype,"_activeSidePanelRoleId",2),Be([S()],exports.JupiterDynamicForm.prototype,"_sidePanelSearchQuery",2),Be([S()],exports.JupiterDynamicForm.prototype,"_sidePanelCollapsed",2),Be([S()],exports.JupiterDynamicForm.prototype,"_adminRoleConfigs",2),Be([S()],exports.JupiterDynamicForm.prototype,"_roleBorderStatuses",2),Be([S()],exports.JupiterDynamicForm.prototype,"_roleCompletedStates",2),Be([S()],exports.JupiterDynamicForm.prototype,"_showRoleContextMenu",2),Be([S()],exports.JupiterDynamicForm.prototype,"_contextMenuX",2),Be([S()],exports.JupiterDynamicForm.prototype,"_contextMenuY",2),Be([S()],exports.JupiterDynamicForm.prototype,"_contextMenuRoleId",2),Be([S()],exports.JupiterDynamicForm.prototype,"_validationStatus",2),Be([S()],exports.JupiterDynamicForm.prototype,"_formulaValidationResults",2),Be([S()],exports.JupiterDynamicForm.prototype,"_formulaValidationSummary",2),Be([S()],exports.JupiterDynamicForm.prototype,"_showFormulaValidationDialog",2),exports.JupiterDynamicForm=Be([t("jupiter-dynamic-form")],exports.JupiterDynamicForm);exports.FactMatcher=ce,exports.FormValidator=C,exports.TYPE_INPUT_MAP=ue,exports.XBRLValidator=pe,exports.collectEnumerationsFromChain=ve,exports.determineInputTypeFromBaseChain=ye,exports.getInputTypeForConceptType=he,exports.isCheckboxType=fe,exports.isNumericType=ge,exports.isSelectType=function(e){return"select"===e},exports.isTextareaType=me,exports.resolveBaseTypeChain=be,exports.version="1.5.0";
|
|
4346
4647
|
//# sourceMappingURL=index.js.map
|