"use strict";var e=require("@kdcloudjs/kwc"),t=require("../calendarMonth-CWlrlbuW.js"),a=require("./icon.js"),r=require("./shadowBaseClassPrivate.js"),s=require("../intlFormat-Bs-dlvDH.js");require("../i18n-CP31jeWH.js");var i=require("../ssr-RXknEJpO.js");require("../observable-BXDJFaLN.js");var n=require("./iso8601Utils.js");require("../calendar.kdds-DhCBDTd8.js"),require("./utilsPrivate.js"),require("../client-Co_j5m_k.js"),require("../normalize-DKPi18vK.js"),require("../colorValid-BBnkvgd_.js"),require("../empty_html-hFq4zm9t.js"),require("./i18nCldrOptions.js"),require("./i18nService.js"),require("./configProvider.js"),require("../classSet-B5xuJbNb.js"),require("../labelUtils-C2UzbgdZ.js"),require("../label-DdXuOVTE.js"),require("./features.js");var l=[t.stylesheet0,function(e,t,a){var r=e?"["+e+"]":"",s=e?"["+e+"-host]":"";return(t?":host [role='year-title']"+r+",\r:host [role='year-title']:hover":s+" [role='year-title']"+r+","+s+" [role='year-title']:hover")+r+" {color: var(--kdds-c-datepicker-switch-color);pointer-events: none;}"}];const o=e.parseFragment`<div class="kdds-align-middle kdds-middle-text${0}"${2}><span role="year-title"${3}>${"t2"}</span></div>`,d=e.parseFragment`<button class="kdds-button kdds-month-button${0}"${"a0:data-year"}${"a0:aria-selected"}${"a0:aria-current"}${2}>${"t1"}</button>`,c={classMap:{"kdds-datepicker__filter":!0,"kdds-grid":!0},key:0},u={classMap:{"kdds-datepicker__filter_month":!0,"kdds-grid":!0,"kdds-grid_align-spread":!0,"kdds-grow":!0},key:1},h={classMap:{"kdds-align-middle":!0},key:2},p={classMap:{"kdds-align-middle":!0},key:7},g={classMap:{"kdds-datepicker__month-list":!0},key:10};function k(e,t,r,s){const{ncls:i,b:n,c:l,h:k,d:m,sp:Y,st:v,k:y,i:D}=e,{_m0:j,_m1:q,_m2:f,_m3:_}=s;return[k("div",c,[k("div",u,[k("div",h,[k("span",{className:i(t.computePrevYearIconClass),key:3,on:j||(s._m0={click:n(t.goToPreviousYearRange)})},[l("kd-icon",a,{props:{iconName:t.previousYearIconName},key:4})])]),v(o,6,[Y(2,null,m(t.computedYearTitle))]),k("div",p,[k("span",{className:i(t.computeNextYearIconClass),key:8,on:q||(s._m1={click:n(t.goToNextYearRange)})},[l("kd-icon",a,{props:{iconName:t.nextYearIconName},key:9})])])])]),k("div",g,D(t.years,function(e){return v(d,y(12,e.fullName),[Y(0,{on:_||(s._m3={click:n(t.handleYearClick)}),attrs:{"data-year":e.fullName,"aria-selected":e.isSelected,"aria-current":e.isCurrent}},null),Y(1,null,m(e.fullName))])}))]}var m=e.registerTemplate(k);k.stylesheets=[],k.stylesheetToken="kwc-5g8qgb1ol8e",k.legacyStylesheetToken="D:\\new_workspace\\workspace\\kingdee-base-components\\src\\modules\\kd\\calendarYear-undefined_calendarYear",l&&k.stylesheets.push.apply(k.stylesheets,l),e.freezeTemplate(k);class Y extends r{constructor(...e){super(...e),this.selectedDate=void 0,this.calendarYear=void 0}renderCalendar(e){let t=e.getFullYear();t>1&&(t=Math.max(1,t-14)),t<9999&&(t=Math.min(9999,t+14)),this.calendarYear=t}get computedYearTitle(){const e=this.calendarYear-14,t=this.calendarYear;return`${this.padYear(e)} - ${this.padYear(t)}`}get years(){const e=this.calendarYear-14,t=[];for(let a=0;a<15;a++){const r=e+a;t.push({fullName:this.padYear(r),isCurrent:this.getTodaysDate().getFullYear()===e+a,isSelected:this.selectedDate&&e+a===this.getSelectedDate()?.getFullYear(),isDisabled:!1})}return t}get hostDirection(){let e;return i.isCSR&&(e=window.getComputedStyle(this.template.host)),e?e.direction.toLowerCase():"ltr"}get previousYearIconName(){return"ltr"===this.hostDirection?"kdfont-qianfanshuangjiantou":"kdfont-houfanshuangjiantou"}get nextYearIconName(){return"ltr"===this.hostDirection?"kdfont-houfanshuangjiantou ":"kdfont-qianfanshuangjiantou"}get canPrevYear(){return this.calendarYear>15}get canNextYear(){return this.calendarYear<9999}get computePrevYearIconClass(){return this.canPrevYear?"":"disabled"}get computeNextYearIconClass(){return this.canNextYear?"":"disabled"}getTodaysDate(){return this.todayDate?this.parseDate(this.todayDate):new Date}getSelectedDate(){return this.parseDate(this.selectedDate)}parseDate(e){return s.parseDateTime(e,n.STANDARD_DATE_FORMAT,!0)}handleYearClick(e){const t=e.target.getAttribute("data-year");this.dispatchEvent(new CustomEvent("privateyearselect",{detail:{value:t}}))}padYear(e){return e.toString().padStart(4,"0")}goToPreviousYearRange(){this.canPrevYear&&(this.calendarYear=Math.max(15,this.calendarYear-15))}goToNextYearRange(){this.canNextYear&&(this.calendarYear=Math.min(9999,this.calendarYear+15))}connectedCallback(){super.connectedCallback(),this._connected=!0,this.todayDate=s.getCurrentDateString();const e=this.getSelectedDate()||this.getTodaysDate();this.renderCalendar(e)}disconnectedCallback(){this._connected=!1}}e.registerDecorators(Y,{publicProps:{selectedDate:{config:0}},track:{calendarYear:1}});const v=e.registerComponent(Y,{tmpl:m,sel:"D:\\new_workspace\\workspace\\kingdee-base-components\\src\\modules\\kd\\calendarYear-",apiVersion:63});module.exports=v;
