// comp-data.jsx — Competency dictionary SEED (from "Regional Competency.pptx").
//
// This is the starting template only. Once an admin saves it into the
// "comp_dict" / "comp_required" sheets via the Competency page, the SHEET
// becomes the source of truth and is edited from the web app (no redeploy).
//
// levels[] is ordered Level 1 → Level 5. required[] follows BANDS order.

(function () {
  const BANDS = ['President/COO', 'MD/SVP/VP', 'SGM/GM', 'AGM/DGM', 'Regional Specialist'];

  const COMPS = [
    // ── Leading Yourself ──
    { cat: 'Leading Yourself', id: '1', name: 'Take Bold Action and Seek Growth', tag: 'PCM-B',
      required: [5, 5, 4, 4, 4], levels: [
        "Understand personal strengths and weaknesses and actively focus on self-development.",
        "Understand the team's strengths and weaknesses and actively work to improve performance.",
        "Consistently aim high and embrace challenging assignments with a proactive mindset.",
        "Continuously seek new opportunities for improvement for both self and the team.",
        "Drive the team toward ambitious goals while fostering a supportive environment to take on challenges.",
      ] },
    { cat: 'Leading Yourself', id: '2', name: 'Build Genuine Trustworthy Relationships and Teamwork', tag: 'PCM-B',
      required: [5, 4, 3, 3, 4], levels: [
        "Ensure timely information sharing to enhance team collaboration and clarity.",
        "Fulfil the role and responsibility as a team member.",
        "Consistently communicate with the team and make timely decisions to drive progress.",
        "Earn the trust of the team and effectively lead them to achieve high-impact results.",
        "Exhibit strong accountability, recognizing team successes while constructively addressing failures.",
      ] },
    { cat: 'Leading Yourself', id: '3', name: 'Strive for Results', tag: 'PCM-B',
      required: [5, 4, 3, 3, 5], levels: [
        "Demonstrate the ability to complete tasks while maintaining focus on results.",
        "Maintain focus and effort in delivering against targets and organizational expectations.",
        "Actively embrace new ideas and diverse perspectives to drive higher performance and achieve ambitious goals.",
        "Consistently deliver strong results through a focus on total optimization.",
        "Demonstrate flexibility in taking action and leveraging diverse resources to drive the organization toward outstanding results.",
      ] },
    { cat: 'Leading Yourself', id: '4', name: 'Organization Commitment', tag: '',
      required: [5, 4, 4, 3, 5], levels: [
        "Understand company rules and policies and make effort to align with organizational direction.",
        "Demonstrate willingness to support the organization's objectives and prioritize to meet the needs of the organization.",
        "Demonstrate proactive leadership by driving mission-aligned initiatives and contributing beyond individual responsibilities.",
        "Advocate for the right direction for the organization's future, even when there are no immediate rewards or incentives.",
        "Place regional priorities above individual company or country interests, fostering organization-wide commitment and long-term impact.",
      ] },
    { cat: 'Leading Yourself', id: '5', name: 'Integrity', tag: '',
      required: [5, 5, 4, 4, 4], levels: [
        "Show foundational compliance with company policies and maintain acceptable ethical behavior.",
        "Consistently embody company values and ensure team compliance with established rules and regulations.",
        "Promote a culture of integrity by addressing non-compliance and reinforcing ethical standards across the organization.",
        "Promote organizational integrity by embedding Daikin Group Philosophy and policies into business decisions and long-term planning.",
        "Demonstrate trustworthiness and credibility by consistently walking the talk and upholding strong governance and accountability.",
      ] },

    // ── Leading Team ──
    { cat: 'Leading Team', id: '6', name: 'People Development', tag: 'PCM-L',
      required: [5, 5, 4, 4, 3], levels: [
        "Demonstrate a belief in the infinite potential of people by embracing diversity in management.",
        "Demonstrate the ability to discover and empower people by building trust and positively influencing their mindset.",
        "Strengthen team growth by leveraging challenging situations and promoting constructive learning from forward-looking mistakes.",
        "Build strong talent pipelines, empower individuals, and promote development across diverse teams.",
        "Lead a long-term people development strategy that promotes growth, empowerment, and inclusion across the organization.",
      ] },
    { cat: 'Leading Team', id: '7', name: 'Organizational Management', tag: 'PCM-L',
      required: [5, 4, 4, 3, 3], levels: [
        "Regularly share Daikin Core Values and Philosophy among team members.",
        "Demonstrate strong vertical leadership within the department and actively promote horizontal cross-departmental collaboration.",
        "Demonstrate ability to implement a Flat and Fast management approach, fostering strong communication and enabling speedy execution.",
        "Drive agile, cross-functional teams, leveraging diverse resources and collaboration across the organization.",
        "Shape organizational direction, foster a strong sense of crisis, and develop high execution capability across the organization.",
      ] },
    { cat: 'Leading Team', id: '8', name: 'Change Management', tag: '',
      required: [5, 4, 4, 4, 4], levels: [
        "Accept change and follow guidance to adapt own work accordingly.",
        "Support change initiatives and adjust team tasks dynamically to adapt to the changes.",
        "Effectively implement change initiatives and ensure team alignment and adoption.",
        "Lead and drive complex change across functions, manage resistance and ensure sustainable outcomes.",
        "Shape and accelerate organization-wide transformation, integrate and manage change capability across the organization.",
      ] },
    { cat: 'Leading Team', id: '9', name: 'Stakeholder Management', tag: '',
      required: [5, 4, 4, 4, 4], levels: [
        "Cooperate with immediate stakeholders when requested.",
        "Build working relationships and support coordination within own area.",
        "Actively manage stakeholder relationships to align interests and achieve business objectives.",
        "Lead cross-functional collaboration, balancing diverse stakeholder needs to drive results.",
        "Shape strategic partnerships and align key stakeholders to advance enterprise priorities.",
      ] },
    { cat: 'Leading Team', id: '10', name: 'Communication', tag: '',
      required: [5, 5, 5, 4, 4], levels: [
        "Communicate basic information clearly within own team.",
        "Convey complex ideas with some structure and adapt messages.",
        "Communicate clearly and confidently across levels, ensuring shared understanding and alignment.",
        "Influence stakeholders through structured and persuasive communication across functions to achieve common goals.",
        "Deliver clear, compelling messages that inspire several parties and obtain alignment and common direction across the organization.",
      ] },

    // ── Leading Strategy & Performance ──
    { cat: 'Leading Strategy & Performance', id: '11', name: 'Visioning', tag: '',
      required: [5, 4, 4, 3, 4], levels: [
        "Understand and follow defined goals and direction.",
        "Contribute ideas and align own actions with team goals.",
        "Translate organizational vision into actionable plans and drive team execution.",
        "Establish bold, long-term vision for own functions or teams and mobilize teams to achieve it.",
        "Establish bold, long-term vision and ensure organization-wide commitment and execution.",
      ] },
    { cat: 'Leading Strategy & Performance', id: '12', name: 'Strategic Thinking & Planning', tag: '',
      required: [5, 5, 4, 3, 4], levels: [
        "Focus on assigned tasks with limited understanding of prioritization.",
        "Understand priorities and support planning within own scope.",
        "Set clear priorities and plans, making decisions on what to focus on and what to deprioritize.",
        "Develop strategic plans across functions, optimize resources and trade-offs.",
        "Define organization strategy, making critical choices that shape long-term direction and competitiveness.",
      ] },
    { cat: 'Leading Strategy & Performance', id: '13', name: 'Global Mindset', tag: '',
      required: [5, 4, 4, 3, 4], levels: [
        "Show awareness of differences across markets and cultures.",
        "Show awareness of differences across countries and region and consider broader business context beyond own country.",
        "Understand global trends and apply insights to drive regional performance.",
        "Integrate global perspectives into strategy, aligning regional actions with global direction.",
        "Anticipate global shifts and position the organization suitably to continuously grow.",
      ] },
    { cat: 'Leading Strategy & Performance', id: '14', name: 'Decision Making and Achievement', tag: 'PCM-L',
      required: [5, 5, 4, 4, 4], levels: [
        "Follow decisions made by others and act on clear instructions.",
        "Able to participate in decision making with basic understanding of facts and situations.",
        "Able to make timely decisions based on understanding of actual situation on site (Genba), and drive consistent execution.",
        "Take bold and structured decisions, lead by example, and drive results through internal and external collaboration.",
        "Make high-impact strategic decisions with courage and speed, driving organization business results and external innovation partnerships.",
      ] },
    { cat: 'Leading Strategy & Performance', id: '15', name: 'Change Leadership', tag: '',
      required: [5, 5, 4, 3, 3], levels: [
        "Understand change initiatives and follow required adjustments in own work.",
        "Lead and align change execution with effective stakeholder management at company level.",
        "Lead and align change execution with effective stakeholder management at regional level.",
        "Drive complex cross-functional transformation aligned with business strategy and ensure impact.",
        "Lead organization-wide transformation and change for long-term sustainability as a strategic leader.",
      ] },
  ];

  const WEIGHTS = [['boss', '40'], ['peer', '30'], ['subordinate', '20'], ['self', '10']];

  // Build the {headers, rows} payload the backend (comp_save) expects.
  function buildSeedPayload() {
    const dictRows = [];
    COMPS.forEach((c) => {
      c.levels.forEach((behaviour, i) => {
        dictRows.push([c.cat, c.id, c.name, c.tag, String(i + 1), behaviour]);
      });
    });
    const reqRows = COMPS.map((c) => [c.id, c.name, c.cat].concat(c.required.map(String)));
    return {
      dict:     { headers: ['category', 'comp_id', 'comp_name', 'tag', 'level', 'behaviour'], rows: dictRows },
      required: { headers: ['comp_id', 'comp_name', 'category'].concat(BANDS), rows: reqRows },
      weights:  { headers: ['perspective', 'weight'], rows: WEIGHTS },
    };
  }

  window.RTDC_COMP = { BANDS, COMPS, WEIGHTS, buildSeedPayload };
})();
