import{parseFragment as e,registerTemplate as t,freezeTemplate as a,registerDecorators as r,registerComponent as s}from"@kdcloudjs/kwc";import{s as i}from"../calendarMonth-DO-UkAk1.js";import n from"./icon.js";import o from"./shadowBaseClassPrivate.js";import{z as l,i as d}from"../intlFormat-DNT_1eg4.js";import"../i18n-B98kiI7M.js";import{i as c}from"../ssr-C2pjZzfv.js";import"../observable-tloG64m6.js";import{STANDARD_DATE_FORMAT as p}from"./iso8601Utils.js";import"../calendar.kdds-uFlR2mRB.js";import"../utilsPrivate-CI3EeA5x.js";import"../client-Ddi3i8XR.js";import"../colorValid-qIPgkqGp.js";import"../empty_html-CjXB8rB4.js";import"./i18nCldrOptions.js";import"./i18nService.js";import"./configProvider.js";import"../classSet-DY6Qvt6E.js";import"../labelUtils-DAuN2uUV.js";import"../label-CY8Q8HAO.js";import"./features.js";var u=[i,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 m=e`<div class="kdds-align-middle kdds-middle-text${0}"${2}><span role="year-title"${3}>${"t2"}</span></div>`,h=e`<button class="kdds-button kdds-month-button${0}"${"a0:data-year"}${"a0:aria-selected"}${"a0:aria-current"}${2}>${"t1"}</button>`,k={classMap:{"kdds-datepicker__filter":!0,"kdds-grid":!0},key:0},g={classMap:{"kdds-datepicker__filter_month":!0,"kdds-grid":!0,"kdds-grid_align-spread":!0,"kdds-grow":!0},key:1},Y={classMap:{"kdds-align-middle":!0},key:2},v={classMap:{"kdds-align-middle":!0},key:7},y={classMap:{"kdds-datepicker__month-list":!0},key:10};function f(e,t,a,r){const{ncls:s,b:i,c:o,h:l,d:d,sp:c,st:p,k:u,i:f}=e,{_m0:j,_m1:b,_m2:_,_m3:D}=r;return[l("div",k,[l("div",g,[l("div",Y,[l("span",{className:s(t.computePrevYearIconClass),key:3,on:j||(r._m0={click:i(t.goToPreviousYearRange)})},[o("kd-icon",n,{props:{iconName:t.previousYearIconName},key:4})])]),p(m,6,[c(2,null,d(t.computedYearTitle))]),l("div",v,[l("span",{className:s(t.computeNextYearIconClass),key:8,on:b||(r._m1={click:i(t.goToNextYearRange)})},[o("kd-icon",n,{props:{iconName:t.nextYearIconName},key:9})])])])]),l("div",y,f(t.years,function(e){return p(h,u(12,e.fullName),[c(0,{on:D||(r._m3={click:i(t.handleYearClick)}),attrs:{"data-year":e.fullName,"aria-selected":e.isSelected,"aria-current":e.isCurrent}},null),c(1,null,d(e.fullName))])}))]}var j=t(f);f.stylesheets=[],f.stylesheetToken="kwc-5g8qgb1ol8e",f.legacyStylesheetToken="D:\\new_workspace\\workspace\\kingdee-base-components\\src\\modules\\kd\\calendarYear-undefined_calendarYear",u&&f.stylesheets.push.apply(f.stylesheets,u),a(f);class b extends o{constructor(...e){super(...e),this.value=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.value&&e+a===this.getSelectedDate()?.getFullYear(),isDisabled:!1})}return t}get hostDirection(){let e;return c&&(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.value)}parseDate(e){return l(e,p,!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=d();const e=this.getSelectedDate()||this.getTodaysDate();this.renderCalendar(e)}disconnectedCallback(){this._connected=!1}}r(b,{publicProps:{value:{config:0}},track:{calendarYear:1}});const _=s(b,{tmpl:j,sel:"D:\\new_workspace\\workspace\\kingdee-base-components\\src\\modules\\kd\\calendarYear-",apiVersion:63});export{_ as default};
