@kashi-ui/elements 0.25.0 → 0.26.0

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.
Files changed (33) hide show
  1. package/README.md +2 -1
  2. package/dist/appointment.d.ts +40 -0
  3. package/dist/appointment.js +174 -0
  4. package/dist/base.js +2 -0
  5. package/dist/basic.d.ts +43 -0
  6. package/dist/basic.js +223 -0
  7. package/dist/cdn/appointment-DkMxtSWi.js +1 -0
  8. package/dist/cdn/base-DfzNTdQk.js +1 -0
  9. package/dist/cdn/basic-B5n1okZO.js +1 -0
  10. package/dist/cdn/calendar-oMlnK1_D.js +16 -0
  11. package/dist/cdn/{charts-DNOWi4sJ.js → charts-SHKq2S4I.js} +1 -1
  12. package/dist/cdn/{combobox-ZGrZ5okg.js → combobox-DiGy7lAB.js} +1 -1
  13. package/dist/cdn/{controls-K-OZcjg4.js → controls-C6zwNYWs.js} +1 -1
  14. package/dist/cdn/{display-C975tS7j.js → display-DZFW9EEX.js} +1 -1
  15. package/dist/cdn/{fields-BUTaSN8m.js → fields-D2hmrvVR.js} +1 -1
  16. package/dist/cdn/forms-CeItYHFx.js +1 -0
  17. package/dist/cdn/holidays-BwsAEOI1.js +1 -0
  18. package/dist/cdn/{inputs-BjOddAM7.js → inputs-DuP7P3ka.js} +1 -1
  19. package/dist/cdn/kashi-elements.js +1 -1
  20. package/dist/cdn/{map-BHuusa4t.js → map-w5X2fTQI.js} +1 -1
  21. package/dist/cdn/{menu-DhrqyLgy.js → menu-Cga7QOfs.js} +1 -1
  22. package/dist/cdn/{nav-D_w5BV_K.js → nav-CwPZ20z-.js} +1 -1
  23. package/dist/cdn/{overlay-DX9un2xm.js → overlay-BDzwsBN5.js} +1 -1
  24. package/dist/cdn/{pickers-BFLpUruK.js → pickers-BOpaZ-7q.js} +1 -1
  25. package/dist/cdn/{table-DPQfDMs-.js → table-BdF43L5q.js} +1 -1
  26. package/dist/cdn/time-DXw4vOne.js +1 -0
  27. package/dist/cdn.js +2 -0
  28. package/dist/index.d.ts +8 -2
  29. package/dist/index.js +4 -1
  30. package/package.json +4 -4
  31. package/dist/cdn/base-Cmq7zeIG.js +0 -1
  32. package/dist/cdn/calendar-Dm3fq2bs.js +0 -16
  33. package/dist/cdn/forms-C-effPKn.js +0 -1
@@ -1 +1 @@
1
- import{a as e,d as t,s as n,t as r}from"./base-Cmq7zeIG.js";import{t as i}from"./digits-DE1YGT94.js";import{d as a,i as o,l as s,o as c,t as l,u}from"./jalali-BiM5Kfep.js";const d=e=>{let t=Math.abs(e),n=(e,t)=>`${i(Math.round(e*10)/10).replace(`.`,`٫`)}${t}`;return t>=1e9?n(e/1e9,` میلیارد`):t>=1e6?n(e/1e6,` م`):t>=1e3?n(e/1e3,` هزار`):i(e)};function f(e,t=4){if(e<=0)return[0];let n=e/t,r=10**Math.floor(Math.log10(n)),i=[1,2,2.5,5,10].map(e=>e*r).find(e=>e>=n);return Array.from({length:Math.ceil(e/i)+1},(e,t)=>t*i)}const p=(e,t)=>`${i(Math.round(e/(t||1)*1e3)/10).replace(`.`,`٫`)}٪`,m=e=>`var(--k-chart-${e+1})`,h=(e,t)=>{if(!e)return t;try{return JSON.parse(e)}catch{return t}};var g=class extends r{constructor(){super(...arguments),this.key=t(`kashi-chart`),this.props={}}connectedCallback(){this.draw()}attributeChangedCallback(){this.isConnected&&this.draw()}get format(){let e=this.getAttribute(`unit`);return this.fmt??(t=>`${i(Math.round(t))}${e?` ${e}`:``}`)}set format(e){this.fmt=e,this.isConnected&&this.draw()}read(e,t){return this.props[e]??h(this.getAttribute(e),t)}write(e,t){this.props[e]=t,this.isConnected&&this.draw()}get heading(){return this.getAttribute(`label`)??``}tip(e,t,r=0,i,a=[]){let o=e.querySelector(`:scope > .k-chart__tip`);if(t===null){o?.remove();return}o||(o=document.createElement(`div`),o.className=`k-chart__tip`,o.setAttribute(`aria-hidden`,`true`),e.append(o));let s=e.clientWidth;o.style.left=`${s?Math.min(Math.max(t,80),s-80):t}px`,o.style.top=`${r}px`,o.innerHTML=`${i?`<span class="k-chart__tip-title">${n(i)}</span>`:``}${a.map(e=>`<span class="k-chart__tip-row"${e.color?` style="--_c: ${e.color}"`:``}>${e.name===void 0?``:`<span>${e.color?`<i></i>`:``}${n(e.name)}</span>`}<strong>${n(e.value)}</strong></span>`).join(``)}`}at(e,t){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return{x:r.left+r.width/2-n.left,y:r.top-n.top}}},_=class extends g{get data(){return this.read(`data`,[])}set data(e){this.write(`data`,e)}get series(){return this.read(`series`,[])}set series(e){this.write(`series`,e)}get labels(){return this.read(`labels`,[])}set labels(e){this.write(`labels`,e)}draw(){let e=this.format,t=this.series.length?this.series.slice(0,4):null,r=this.data,i=t?this.labels:r.map(e=>e.label),a=i.map((e,n)=>t?t.reduce((e,t)=>e+(t.values[n]??0),0):r[n].value),o=Math.max(0,...a),s=f(o),c=s.at(-1)||1,l=a.indexOf(o),u=this.getAttribute(`label-max`)!==`false`,p=n=>t?`${i[n]}: ${t.map(t=>`${t.name} ${e(t.values[n]??0)}`).join(`، `)}، جمع ${e(a[n])}`:`${i[n]}: ${e(a[n])}`,h=this.getAttribute(`height`);this.innerHTML=`<figure class="k-chart k-chart--bar" aria-labelledby="${this.key}-t" style="margin: 0${h?`; --k-chart-height: ${n(h)}`:``}"><figcaption class="k-chart__head"><p class="k-chart__title" id="${this.key}-t">${n(this.heading)}</p>${t&&t.length>1?`<ul class="k-chart__legend" aria-hidden="true">${t.map((e,t)=>`<li style="--_c: ${m(t)}"><span class="k-chart__key k-chart__key--box"></span>${n(e.name)}</li>`).join(``)}</ul>`:``}</figcaption><div class="k-chart__plot"><div class="k-bars__grid" aria-hidden="true">${s.map(e=>`<span data-v="${n(d(e))}"></span>`).join(``)}</div><div class="k-bars" role="list" aria-label="${n(this.heading)}">${i.map((r,i)=>`<div class="k-bars__col" role="listitem" tabindex="0" data-i="${i}" aria-label="${n(p(i))}" style="--_d: ${i*40}ms">${u&&i===l?`<span class="k-bars__value" aria-hidden="true">${n(e(a[i]))}</span>`:``}${t?`<span class="k-bars__stack" style="block-size: ${a[i]/c*100}%" aria-hidden="true">${t.map((e,t)=>`<span class="k-bars__seg" style="--_c: ${m(t)}; flex-grow: ${e.values[i]??0}"></span>`).join(``)}</span>`:`<span class="k-bars__bar" style="block-size: ${a[i]/c*100}%" aria-hidden="true"></span>`}<span class="k-bars__label" aria-hidden="true">${n(r)}</span></div>`).join(``)}</div></div></figure>`;let g=this.querySelector(`.k-chart__plot`),_=n=>{let r=Number(n.dataset.i);g.querySelector(`[data-active]`)?.removeAttribute(`data-active`),n.setAttribute(`data-active`,``);let o=this.at(n.querySelector(`.k-bars__bar, .k-bars__stack`)??n,g);this.tip(g,o.x,o.y,i[r],t?[...t.map((t,n)=>({name:t.name,value:e(t.values[r]??0),color:m(n)})),{name:`جمع`,value:e(a[r])}]:[{value:e(a[r])}])},v=()=>{g.querySelector(`[data-active]`)?.removeAttribute(`data-active`),this.tip(g,null)};g.querySelectorAll(`.k-bars__col`).forEach(e=>{e.addEventListener(`pointerenter`,()=>_(e)),e.addEventListener(`focus`,()=>_(e)),e.addEventListener(`pointerleave`,v),e.addEventListener(`blur`,v)})}};_.observedAttributes=[`label`,`data`,`labels`,`series`,`unit`,`label-max`,`height`];var v=class extends g{get data(){return this.read(`data`,[])}set data(e){this.write(`data`,e)}draw(){let e=this.format,t=this.data,r=Math.max(1,...t.map(e=>e.value)),i=t.reduce((e,t)=>e+t.value,0);this.innerHTML=`<figure class="k-chart" aria-labelledby="${this.key}-t" style="margin: 0"><figcaption class="k-chart__head"><p class="k-chart__title" id="${this.key}-t">${n(this.heading)}</p></figcaption><ol class="k-barlist" style="position: relative">${t.map((t,a)=>`<li class="k-barlist__row" data-i="${a}" style="--_d: ${a*60}ms"><span class="k-barlist__track"><span class="k-barlist__fill" style="inline-size: ${t.value/r*100}%" aria-hidden="true"></span>${t.href?`<a class="k-barlist__label" href="${n(t.href)}">${n(t.label)}</a>`:`<span class="k-barlist__label">${n(t.label)}</span>`}</span><span class="k-barlist__value">${n(e(t.value))} <span class="k-barlist__share">${p(t.value,i)}</span></span></li>`).join(``)}</ol></figure>`;let a=this.querySelector(`.k-barlist`);a.querySelectorAll(`.k-barlist__row`).forEach(n=>{n.addEventListener(`pointerenter`,()=>{let r=t[Number(n.dataset.i)];n.setAttribute(`data-active`,``);let o=this.at(n.querySelector(`.k-barlist__fill`),a);this.tip(a,o.x,o.y,r.label,[{name:`مقدار`,value:e(r.value)},{name:`سهم از کل`,value:p(r.value,i)}])}),n.addEventListener(`pointerleave`,()=>{n.removeAttribute(`data-active`),this.tip(a,null)})})}};v.observedAttributes=[`label`,`data`,`unit`];var y=class extends g{get data(){return this.read(`data`,[])}set data(e){this.write(`data`,e)}draw(){let e=this.format,t=this.data.slice(0,4),r=t.reduce((e,t)=>e+t.value,0),i=this.getAttribute(`percent`)!==`false`;this.innerHTML=`<figure class="k-chart" aria-labelledby="${this.key}-t" style="margin: 0"><figcaption class="k-chart__head"><p class="k-chart__title" id="${this.key}-t">${n(this.heading)}</p></figcaption><div class="k-proportion__wrap"><div class="k-proportion" aria-hidden="true">${t.map((e,t)=>`<span class="k-proportion__seg" data-i="${t}" style="--_c: ${m(t)}; flex-grow: ${e.value}"></span>`).join(``)}</div></div><ul class="k-proportion__legend">${t.map((t,a)=>`<li data-i="${a}" style="--_c: ${m(a)}"><span class="k-chart__key k-chart__key--box" aria-hidden="true"></span><span>${n(t.label)}</span><strong>${n(i?p(t.value,r):e(t.value))}</strong>${i?`<span class="k-proportion__abs">${n(e(t.value))}</span>`:``}</li>`).join(``)}</ul></figure>`;let a=this.querySelector(`.k-proportion__wrap`),o=e=>this.querySelectorAll(`[data-i]`).forEach(t=>t.toggleAttribute(`data-active`,Number(t.dataset.i)===e));a.querySelectorAll(`.k-proportion__seg`).forEach(n=>{n.addEventListener(`pointerenter`,()=>{let i=Number(n.dataset.i);o(i);let s=this.at(n,a);this.tip(a,s.x,s.y,void 0,[{name:t[i].label,value:p(t[i].value,r),color:m(i)},{name:`تعداد`,value:e(t[i].value)}])}),n.addEventListener(`pointerleave`,()=>{o(null),this.tip(a,null)})})}};y.observedAttributes=[`label`,`data`,`unit`,`percent`];var b=class extends g{get data(){return this.read(`data`,[])}set data(e){this.write(`data`,e)}draw(){let e=this.format,t=[...this.data].sort((e,t)=>t.value-e.value),r=t.length>5?[...t.slice(0,4),{label:`سایر`,value:t.slice(4).reduce((e,t)=>e+t.value,0)}]:t,i=r.reduce((e,t)=>e+t.value,0)||1,a=e=>e<4?m(e):`var(--k-text-quaternary)`,o=this.getAttribute(`variant`)!==`pie`,s=Number(this.getAttribute(`size`))||176,c=this.getAttribute(`total-label`)??`جمع`,l=o?40:25,u=o?16:50,d=2*Math.PI*l,f=r.length>1?o?1.6:.8:0,h=0,g=r.map(e=>{let t=e.value/i*d,n={start:h,len:t};return h+=t,n});this.innerHTML=`<figure class="k-chart k-pie" aria-labelledby="${this.key}-t" style="margin: 0"><figcaption class="k-chart__head"><p class="k-chart__title" id="${this.key}-t">${n(this.heading)}</p></figcaption><div class="k-pie__body"><div class="k-pie__plot" style="inline-size: ${s}px; block-size: ${s}px"><svg viewBox="0 0 100 100" class="k-pie__svg" aria-hidden="true">${o?`<circle cx="50" cy="50" r="${l}" fill="none" stroke="var(--k-bg-tertiary)" stroke-width="${u}"></circle>`:``}${r.map((e,t)=>`<circle class="k-pie__slice" data-i="${t}" cx="50" cy="50" r="${l}" fill="none" stroke="${a(t)}" stroke-width="${u}" stroke-dasharray="${Math.max(0,g[t].len-f)} ${d}" stroke-dashoffset="${-g[t].start}" transform="rotate(-90 50 50)" style="--_d: ${t*80}ms"></circle>`).join(``)}</svg>${o?`<div class="k-pie__center" aria-hidden="true"><strong>${n(e(i))}</strong><span>${n(c)}</span></div>`:``}</div><ul class="k-pie__legend">${r.map((t,r)=>`<li data-i="${r}" style="--_c: ${a(r)}"><span class="k-chart__key k-chart__key--box" aria-hidden="true"></span><span class="k-pie__name">${n(t.label)}</span><strong>${p(t.value,i)}</strong><span class="k-pie__abs">${n(e(t.value))}</span></li>`).join(``)}</ul></div></figure>`;let _=this.querySelector(`.k-pie__plot`),v=this.querySelector(`.k-pie__center`),y=e=>{let t=(g[e].start+g[e].len/2)/d*2*Math.PI-Math.PI/2,n=o?l:l*1.3;return{x:(50+n*Math.cos(t))/100*s,y:(50+n*Math.sin(t))/100*s-8}},b=t=>{this.querySelectorAll(`[data-i]`).forEach(e=>e.toggleAttribute(`data-active`,Number(e.dataset.i)===t)),v&&(v.innerHTML=t===null?`<strong>${n(e(i))}</strong><span>${n(c)}</span>`:`<strong>${p(r[t].value,i)}</strong><span>${n(r[t].label)}</span>`),o||(t===null?this.tip(_,null):this.tip(_,y(t).x,y(t).y,void 0,[{name:r[t].label,value:p(r[t].value,i),color:a(t)},{name:`تعداد`,value:e(r[t].value)}]))};this.querySelectorAll(`.k-pie__slice, .k-pie__legend li`).forEach(e=>e.addEventListener(`pointerenter`,()=>b(Number(e.dataset.i)))),_.addEventListener(`pointerleave`,()=>b(null)),this.querySelector(`.k-pie__legend`).addEventListener(`pointerleave`,()=>b(null))}};b.observedAttributes=[`label`,`data`,`unit`,`variant`,`total-label`,`size`];var x=class extends g{get values(){return this.props.values??(this.getAttribute(`values`)??``).split(/[,،\s]+/).filter(Boolean).map(Number).filter(e=>!Number.isNaN(e))}set values(e){this.write(`values`,e)}draw(){let e=this.values;if(!e.length){this.innerHTML=``;return}let t=Math.max(...e),r=Math.min(...e),i=Math.max(t-r,Math.abs(t)*.25)||1,a=(t+r)/2-i/2,o=e.map((t,n)=>`${n?`L`:`M`}${n/Math.max(1,e.length-1)*100},${28-(t-a)/i*24}`).join(` `),s=this.getAttribute(`tone`)??`brand`,c=s===`neutral`?`var(--k-text-tertiary)`:s===`brand`?`var(--k-text-brand)`:`var(--k-text-${s})`,l=this.getAttribute(`label`);this.innerHTML=`<svg class="k-sparkline" viewBox="0 0 100 30" preserveAspectRatio="none"${l?` role="img" aria-label="${n(l)}"`:` aria-hidden="true"`} style="color: ${c}">${this.getAttribute(`area`)===`false`?``:`<path d="${o} L100,30 L0,30 Z" fill="currentColor" opacity="0.1"></path>`}<path d="${o}" fill="none" stroke="currentColor" stroke-width="2" vector-effect="non-scaling-stroke" stroke-linejoin="round" stroke-linecap="round"></path></svg>`}};x.observedAttributes=[`values`,`tone`,`area`,`label`];var S=class extends g{constructor(){super(...arguments),this.ro=null,this.active=null}get labels(){return this.read(`labels`,[])}set labels(e){this.write(`labels`,e)}get series(){return this.read(`series`,[])}set series(e){this.write(`series`,e)}connectedCallback(){if(super.connectedCallback(),typeof ResizeObserver<`u`&&!this.ro){let e=0;this.ro=new ResizeObserver(()=>{let t=this.clientWidth;t&&t!==e&&(e=t,this.paintSvg())}),this.ro.observe(this)}}disconnectedCallback(){this.ro?.disconnect(),this.ro=null}draw(){let e=this.series.slice(0,4),t=this.format,r=this.labels,i=this.getAttribute(`height`);this.innerHTML=`<figure class="k-chart" aria-labelledby="${this.key}-t" style="margin: 0${i?`; --k-chart-height: ${n(i)}`:``}"><figcaption class="k-chart__head"><p class="k-chart__title" id="${this.key}-t">${n(this.heading)}</p>${e.length>1?`<ul class="k-chart__legend" aria-hidden="true">${e.map((e,t)=>`<li style="--_c: ${m(t)}"><span class="k-chart__key"></span>${n(e.name)}</li>`).join(``)}</ul>`:``}</figcaption><div class="k-chart__plot" tabindex="0" role="img" aria-label="${n(`${this.heading}. با کلیدهای جهت بین نقطه‌ها حرکت کنید.`)}" aria-describedby="${this.key}-live"><svg class="k-chart__svg" aria-hidden="true" direction="ltr"></svg></div><span class="k-sr-only" aria-live="polite" id="${this.key}-live"></span><table class="k-sr-only"><caption>${n(this.heading)}</caption><thead><tr><th scope="col">دوره</th>${e.map(e=>`<th scope="col">${n(e.name)}</th>`).join(``)}</tr></thead><tbody>${r.map((r,i)=>`<tr><th scope="row">${n(r)}</th>${e.map(e=>`<td>${n(t(e.values[i]))}</td>`).join(``)}</tr>`).join(``)}</tbody></table></figure>`;let a=this.querySelector(`.k-chart__plot`);a.addEventListener(`pointermove`,e=>this.pick(e.clientX)),a.addEventListener(`pointerleave`,()=>this.setActive(null)),a.addEventListener(`blur`,()=>this.setActive(null)),a.addEventListener(`keydown`,e=>{let t=getComputedStyle(a).direction===`rtl`,n=r.length,i={ArrowLeft:t?1:-1,ArrowRight:t?-1:1}[e.key];i?(e.preventDefault(),this.setActive(Math.min(n-1,Math.max(0,(this.active??(i>0?-1:n))+i)))):e.key===`Home`?this.setActive(0):e.key===`End`?this.setActive(n-1):e.key===`Escape`&&this.setActive(null)}),this.active=null,this.paintSvg()}geometry(){let e=this.querySelector(`.k-chart__plot`),t=this.series.slice(0,4),n=this.labels,r=e.clientWidth||600,i=e.clientHeight||220,a=getComputedStyle(e).direction===`rtl`,o={top:12,bottom:24,start:52,end:t.length>1?64:16},s=f(Math.max(0,...t.flatMap(e=>e.values))),c=s.at(-1)||1,l=Math.max(1,r-o.start-o.end),u=Math.max(1,i-o.top-o.bottom);return{plot:e,shown:t,labels:n,w:r,h:i,rtl:a,pad:o,ticks:s,innerW:l,innerH:u,x:e=>{let t=n.length>1?e/(n.length-1):.5;return a?r-o.start-t*l:o.start+t*l},y:e=>o.top+u-e/c*u}}paintSvg(){if(!this.querySelector(`.k-chart__plot`))return;let{plot:e,shown:t,labels:r,w:i,h:a,rtl:o,pad:s,ticks:c,innerW:l,innerH:u,x:f,y:p}=this.geometry(),h=e.querySelector(`svg`),g=o?i-s.start+8:s.start-8,_=o?`start`:`end`,v=r.length-1,y=t.map((e,t)=>({i:t,y:p(e.values[v])})).sort((e,t)=>e.y-t.y);for(let e=1;e<y.length;e++)y[e].y-y[e-1].y<14&&(y[e].y=y[e-1].y+14);let b=Object.fromEntries(y.map(e=>[e.i,e.y])),x=Math.max(1,Math.ceil(r.length/Math.max(2,Math.floor(l/64)))),S=`${this.key}-fade`,C=this.active;h.innerHTML=`<g class="k-chart__grid">${c.map(e=>`<line x1="${s.start}" x2="${i-s.end}" y1="${p(e)}" y2="${p(e)}"${o?` transform="translate(${s.end-s.start} 0)"`:``}></line>`).join(``)}</g>${c.map(e=>`<text class="k-chart__tick" x="${g}" y="${p(e)+4}" text-anchor="${_}">${n(d(e))}</text>`).join(``)}${r.map((e,t)=>t%x===0||t===v?`<text class="k-chart__tick" x="${f(t)}" y="${a-6}" text-anchor="middle">${n(e)}</text>`:``).join(``)}<defs><linearGradient id="${S}" x1="0" y1="0" x2="0" y2="1"><stop offset="0" style="stop-color: var(--k-chart-1); stop-opacity: 0.28"></stop><stop offset="1" style="stop-color: var(--k-chart-1); stop-opacity: 0"></stop></linearGradient></defs>${t.length===1&&this.getAttribute(`area`)!==`false`?`<path class="k-chart__area" fill="url(#${S})" d="M${f(0)},${p(0)} ${t[0].values.map((e,t)=>`L${f(t)},${p(e)}`).join(` `)} L${f(v)},${p(0)} Z"></path>`:``}${C===null?``:`<line class="k-chart__cross" x1="${f(C)}" x2="${f(C)}" y1="${s.top}" y2="${s.top+u}"></line>`}${t.map((e,r)=>`<g style="--_c: ${m(r)}"><path class="k-chart__line" pathLength="1" d="${e.values.map((e,t)=>`${t?`L`:`M`}${f(t)},${p(e)}`).join(` `)}"></path><circle class="k-chart__dot" cx="${f(e.values.length-1)}" cy="${p(e.values.at(-1)??0)}" r="4"></circle>${t.length>1?`<text class="k-chart__end" x="${f(v)+(o?-8:8)}" y="${b[r]+4}" text-anchor="${o?`end`:`start`}">${n(e.name)}</text>`:``}${C===null?``:`<circle class="k-chart__dot" cx="${f(C)}" cy="${p(e.values[C])}" r="4.5"></circle>`}</g>`).join(``)}`;let w=this.format;C===null?this.tip(e,null):this.tip(e,f(C),Math.min(...t.map(e=>p(e.values[C])))-6,r[C],t.map((e,t)=>({name:e.name,value:w(e.values[C]),color:m(t)}))),this.querySelector(`#${this.key}-live`).textContent=C===null?``:`${r[C]}: ${t.map(e=>`${e.name} ${w(e.values[C])}`).join(`، `)}`}pick(e){let{plot:t,labels:n,x:r}=this.geometry(),i=e-t.getBoundingClientRect().left,a=0;n.forEach((e,t)=>{Math.abs(r(t)-i)<Math.abs(r(a)-i)&&(a=t)}),a!==this.active&&this.setActive(a)}setActive(e){this.active=e,this.paintSvg()}};S.observedAttributes=[`label`,`labels`,`series`,`unit`,`area`,`height`];const C=[`ش`,``,`د`,``,`چ`,``,`ج`];var w=class extends g{get data(){return this.read(`data`,{})}set data(e){this.write(`data`,e)}draw(){let e=this.data,t=Number(this.getAttribute(`year`))||a(/* @__PURE__ */ new Date).jy,r=this.getAttribute(`unit`)??`فعالیت`,d=[];for(let n=1;n<=12;n++)for(let r=1;r<=c(t,n);r++){let i=s(t,n,r);d.push({date:i,value:e[u(i)]??0})}let f=Math.max(0,...d.map(e=>e.value)),p=e=>e<=0||f===0?0:Math.max(1,Math.ceil(e/f*4)),m=(d[0].date.getDay()+1)%7,h=e=>Math.floor((e+m)/7),g=l.map((e,t)=>({name:e,col:h(d.findIndex(e=>a(e.date).jm===t+1))})),_=d.reduce((e,t)=>e+t.value,0),v=l.map((e,t)=>({name:e,sum:d.filter(e=>a(e.date).jm===t+1).reduce((e,t)=>e+t.value,0)})),y=i(t).replace(/٬/g,``),b=this.getAttribute(`label`)??`${r} در سال ${y}`;this.innerHTML=`<figure class="k-heatmap" style="margin: 0"><div class="k-heatmap__scroll"><div role="img" aria-label="${n(`${b}: ${i(_)} ${r}`)}"><div class="k-heatmap__months" aria-hidden="true">${g.map(e=>`<span style="grid-column: ${e.col+1}">${e.name}</span>`).join(``)}</div><div class="k-heatmap__body" aria-hidden="true"><div class="k-heatmap__days">${C.map(e=>`<span>${e}</span>`).join(``)}</div><div class="k-heatmap__grid">${`<span class="k-heatmap__cell" data-empty=""></span>`.repeat(m)}${d.map((e,t)=>`<span class="k-heatmap__cell" data-l="${p(e.value)}" data-i="${t}"></span>`).join(``)}</div></div></div></div><figcaption class="k-heatmap__foot"><span>${i(_)} ${n(r)} در ${y}</span><span class="k-heatmap__scale" aria-hidden="true">کمتر ${[0,1,2,3,4].map(e=>`<span class="k-heatmap__cell" data-l="${e}"></span>`).join(``)} بیشتر</span></figcaption><table class="k-sr-only"><caption>${n(b)}، به تفکیک ماه</caption><tbody>${v.map(e=>`<tr><th scope="row">${e.name}</th><td>${i(e.sum)}</td></tr>`).join(``)}</tbody></table></figure>`;let x=this.querySelector(`figure`);this.querySelector(`.k-heatmap__grid`).addEventListener(`pointerover`,e=>{let t=e.target.closest(`[data-i]`);if(x.querySelector(`.k-heatmap__cell[data-active]`)?.removeAttribute(`data-active`),!t)return this.tip(x,null);t.setAttribute(`data-active`,``);let n=this.at(t,x),a=d[Number(t.dataset.i)];this.tip(x,n.x,n.y-2,o(a.date,{style:`full`}),[{value:`${i(a.value)} ${r}`}])}),x.addEventListener(`pointerleave`,()=>this.tip(x,null))}};w.observedAttributes=[`data`,`year`,`unit`,`label`],e(`kashi-bar-chart`,_,`block`),e(`kashi-line-chart`,S,`block`),e(`kashi-pie-chart`,b,`block`),e(`kashi-bar-list`,v,`block`),e(`kashi-proportion-bar`,y,`block`),e(`kashi-sparkline`,x),e(`kashi-activity-heatmap`,w,`block`);export{w as KashiActivityHeatmap,_ as KashiBarChart,v as KashiBarList,S as KashiLineChart,b as KashiPieChart,y as KashiProportionBar,x as KashiSparkline};
1
+ import{a as e,d as t,s as n,t as r}from"./base-DfzNTdQk.js";import{t as i}from"./digits-DE1YGT94.js";import{d as a,i as o,l as s,o as c,t as l,u}from"./jalali-BiM5Kfep.js";const d=e=>{let t=Math.abs(e),n=(e,t)=>`${i(Math.round(e*10)/10).replace(`.`,`٫`)}${t}`;return t>=1e9?n(e/1e9,` میلیارد`):t>=1e6?n(e/1e6,` م`):t>=1e3?n(e/1e3,` هزار`):i(e)};function f(e,t=4){if(e<=0)return[0];let n=e/t,r=10**Math.floor(Math.log10(n)),i=[1,2,2.5,5,10].map(e=>e*r).find(e=>e>=n);return Array.from({length:Math.ceil(e/i)+1},(e,t)=>t*i)}const p=(e,t)=>`${i(Math.round(e/(t||1)*1e3)/10).replace(`.`,`٫`)}٪`,m=e=>`var(--k-chart-${e+1})`,h=(e,t)=>{if(!e)return t;try{return JSON.parse(e)}catch{return t}};var g=class extends r{constructor(){super(...arguments),this.key=t(`kashi-chart`),this.props={}}connectedCallback(){this.draw()}attributeChangedCallback(){this.isConnected&&this.draw()}get format(){let e=this.getAttribute(`unit`);return this.fmt??(t=>`${i(Math.round(t))}${e?` ${e}`:``}`)}set format(e){this.fmt=e,this.isConnected&&this.draw()}read(e,t){return this.props[e]??h(this.getAttribute(e),t)}write(e,t){this.props[e]=t,this.isConnected&&this.draw()}get heading(){return this.getAttribute(`label`)??``}tip(e,t,r=0,i,a=[]){let o=e.querySelector(`:scope > .k-chart__tip`);if(t===null){o?.remove();return}o||(o=document.createElement(`div`),o.className=`k-chart__tip`,o.setAttribute(`aria-hidden`,`true`),e.append(o));let s=e.clientWidth;o.style.left=`${s?Math.min(Math.max(t,80),s-80):t}px`,o.style.top=`${r}px`,o.innerHTML=`${i?`<span class="k-chart__tip-title">${n(i)}</span>`:``}${a.map(e=>`<span class="k-chart__tip-row"${e.color?` style="--_c: ${e.color}"`:``}>${e.name===void 0?``:`<span>${e.color?`<i></i>`:``}${n(e.name)}</span>`}<strong>${n(e.value)}</strong></span>`).join(``)}`}at(e,t){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return{x:r.left+r.width/2-n.left,y:r.top-n.top}}},_=class extends g{get data(){return this.read(`data`,[])}set data(e){this.write(`data`,e)}get series(){return this.read(`series`,[])}set series(e){this.write(`series`,e)}get labels(){return this.read(`labels`,[])}set labels(e){this.write(`labels`,e)}draw(){let e=this.format,t=this.series.length?this.series.slice(0,4):null,r=this.data,i=t?this.labels:r.map(e=>e.label),a=i.map((e,n)=>t?t.reduce((e,t)=>e+(t.values[n]??0),0):r[n].value),o=Math.max(0,...a),s=f(o),c=s.at(-1)||1,l=a.indexOf(o),u=this.getAttribute(`label-max`)!==`false`,p=n=>t?`${i[n]}: ${t.map(t=>`${t.name} ${e(t.values[n]??0)}`).join(`، `)}، جمع ${e(a[n])}`:`${i[n]}: ${e(a[n])}`,h=this.getAttribute(`height`);this.innerHTML=`<figure class="k-chart k-chart--bar" aria-labelledby="${this.key}-t" style="margin: 0${h?`; --k-chart-height: ${n(h)}`:``}"><figcaption class="k-chart__head"><p class="k-chart__title" id="${this.key}-t">${n(this.heading)}</p>${t&&t.length>1?`<ul class="k-chart__legend" aria-hidden="true">${t.map((e,t)=>`<li style="--_c: ${m(t)}"><span class="k-chart__key k-chart__key--box"></span>${n(e.name)}</li>`).join(``)}</ul>`:``}</figcaption><div class="k-chart__plot"><div class="k-bars__grid" aria-hidden="true">${s.map(e=>`<span data-v="${n(d(e))}"></span>`).join(``)}</div><div class="k-bars" role="list" aria-label="${n(this.heading)}">${i.map((r,i)=>`<div class="k-bars__col" role="listitem" tabindex="0" data-i="${i}" aria-label="${n(p(i))}" style="--_d: ${i*40}ms">${u&&i===l?`<span class="k-bars__value" aria-hidden="true">${n(e(a[i]))}</span>`:``}${t?`<span class="k-bars__stack" style="block-size: ${a[i]/c*100}%" aria-hidden="true">${t.map((e,t)=>`<span class="k-bars__seg" style="--_c: ${m(t)}; flex-grow: ${e.values[i]??0}"></span>`).join(``)}</span>`:`<span class="k-bars__bar" style="block-size: ${a[i]/c*100}%" aria-hidden="true"></span>`}<span class="k-bars__label" aria-hidden="true">${n(r)}</span></div>`).join(``)}</div></div></figure>`;let g=this.querySelector(`.k-chart__plot`),_=n=>{let r=Number(n.dataset.i);g.querySelector(`[data-active]`)?.removeAttribute(`data-active`),n.setAttribute(`data-active`,``);let o=this.at(n.querySelector(`.k-bars__bar, .k-bars__stack`)??n,g);this.tip(g,o.x,o.y,i[r],t?[...t.map((t,n)=>({name:t.name,value:e(t.values[r]??0),color:m(n)})),{name:`جمع`,value:e(a[r])}]:[{value:e(a[r])}])},v=()=>{g.querySelector(`[data-active]`)?.removeAttribute(`data-active`),this.tip(g,null)};g.querySelectorAll(`.k-bars__col`).forEach(e=>{e.addEventListener(`pointerenter`,()=>_(e)),e.addEventListener(`focus`,()=>_(e)),e.addEventListener(`pointerleave`,v),e.addEventListener(`blur`,v)})}};_.observedAttributes=[`label`,`data`,`labels`,`series`,`unit`,`label-max`,`height`];var v=class extends g{get data(){return this.read(`data`,[])}set data(e){this.write(`data`,e)}draw(){let e=this.format,t=this.data,r=Math.max(1,...t.map(e=>e.value)),i=t.reduce((e,t)=>e+t.value,0);this.innerHTML=`<figure class="k-chart" aria-labelledby="${this.key}-t" style="margin: 0"><figcaption class="k-chart__head"><p class="k-chart__title" id="${this.key}-t">${n(this.heading)}</p></figcaption><ol class="k-barlist" style="position: relative">${t.map((t,a)=>`<li class="k-barlist__row" data-i="${a}" style="--_d: ${a*60}ms"><span class="k-barlist__track"><span class="k-barlist__fill" style="inline-size: ${t.value/r*100}%" aria-hidden="true"></span>${t.href?`<a class="k-barlist__label" href="${n(t.href)}">${n(t.label)}</a>`:`<span class="k-barlist__label">${n(t.label)}</span>`}</span><span class="k-barlist__value">${n(e(t.value))} <span class="k-barlist__share">${p(t.value,i)}</span></span></li>`).join(``)}</ol></figure>`;let a=this.querySelector(`.k-barlist`);a.querySelectorAll(`.k-barlist__row`).forEach(n=>{n.addEventListener(`pointerenter`,()=>{let r=t[Number(n.dataset.i)];n.setAttribute(`data-active`,``);let o=this.at(n.querySelector(`.k-barlist__fill`),a);this.tip(a,o.x,o.y,r.label,[{name:`مقدار`,value:e(r.value)},{name:`سهم از کل`,value:p(r.value,i)}])}),n.addEventListener(`pointerleave`,()=>{n.removeAttribute(`data-active`),this.tip(a,null)})})}};v.observedAttributes=[`label`,`data`,`unit`];var y=class extends g{get data(){return this.read(`data`,[])}set data(e){this.write(`data`,e)}draw(){let e=this.format,t=this.data.slice(0,4),r=t.reduce((e,t)=>e+t.value,0),i=this.getAttribute(`percent`)!==`false`;this.innerHTML=`<figure class="k-chart" aria-labelledby="${this.key}-t" style="margin: 0"><figcaption class="k-chart__head"><p class="k-chart__title" id="${this.key}-t">${n(this.heading)}</p></figcaption><div class="k-proportion__wrap"><div class="k-proportion" aria-hidden="true">${t.map((e,t)=>`<span class="k-proportion__seg" data-i="${t}" style="--_c: ${m(t)}; flex-grow: ${e.value}"></span>`).join(``)}</div></div><ul class="k-proportion__legend">${t.map((t,a)=>`<li data-i="${a}" style="--_c: ${m(a)}"><span class="k-chart__key k-chart__key--box" aria-hidden="true"></span><span>${n(t.label)}</span><strong>${n(i?p(t.value,r):e(t.value))}</strong>${i?`<span class="k-proportion__abs">${n(e(t.value))}</span>`:``}</li>`).join(``)}</ul></figure>`;let a=this.querySelector(`.k-proportion__wrap`),o=e=>this.querySelectorAll(`[data-i]`).forEach(t=>t.toggleAttribute(`data-active`,Number(t.dataset.i)===e));a.querySelectorAll(`.k-proportion__seg`).forEach(n=>{n.addEventListener(`pointerenter`,()=>{let i=Number(n.dataset.i);o(i);let s=this.at(n,a);this.tip(a,s.x,s.y,void 0,[{name:t[i].label,value:p(t[i].value,r),color:m(i)},{name:`تعداد`,value:e(t[i].value)}])}),n.addEventListener(`pointerleave`,()=>{o(null),this.tip(a,null)})})}};y.observedAttributes=[`label`,`data`,`unit`,`percent`];var b=class extends g{get data(){return this.read(`data`,[])}set data(e){this.write(`data`,e)}draw(){let e=this.format,t=[...this.data].sort((e,t)=>t.value-e.value),r=t.length>5?[...t.slice(0,4),{label:`سایر`,value:t.slice(4).reduce((e,t)=>e+t.value,0)}]:t,i=r.reduce((e,t)=>e+t.value,0)||1,a=e=>e<4?m(e):`var(--k-text-quaternary)`,o=this.getAttribute(`variant`)!==`pie`,s=Number(this.getAttribute(`size`))||176,c=this.getAttribute(`total-label`)??`جمع`,l=o?40:25,u=o?16:50,d=2*Math.PI*l,f=r.length>1?o?1.6:.8:0,h=0,g=r.map(e=>{let t=e.value/i*d,n={start:h,len:t};return h+=t,n});this.innerHTML=`<figure class="k-chart k-pie" aria-labelledby="${this.key}-t" style="margin: 0"><figcaption class="k-chart__head"><p class="k-chart__title" id="${this.key}-t">${n(this.heading)}</p></figcaption><div class="k-pie__body"><div class="k-pie__plot" style="inline-size: ${s}px; block-size: ${s}px"><svg viewBox="0 0 100 100" class="k-pie__svg" aria-hidden="true">${o?`<circle cx="50" cy="50" r="${l}" fill="none" stroke="var(--k-bg-tertiary)" stroke-width="${u}"></circle>`:``}${r.map((e,t)=>`<circle class="k-pie__slice" data-i="${t}" cx="50" cy="50" r="${l}" fill="none" stroke="${a(t)}" stroke-width="${u}" stroke-dasharray="${Math.max(0,g[t].len-f)} ${d}" stroke-dashoffset="${-g[t].start}" transform="rotate(-90 50 50)" style="--_d: ${t*80}ms"></circle>`).join(``)}</svg>${o?`<div class="k-pie__center" aria-hidden="true"><strong>${n(e(i))}</strong><span>${n(c)}</span></div>`:``}</div><ul class="k-pie__legend">${r.map((t,r)=>`<li data-i="${r}" style="--_c: ${a(r)}"><span class="k-chart__key k-chart__key--box" aria-hidden="true"></span><span class="k-pie__name">${n(t.label)}</span><strong>${p(t.value,i)}</strong><span class="k-pie__abs">${n(e(t.value))}</span></li>`).join(``)}</ul></div></figure>`;let _=this.querySelector(`.k-pie__plot`),v=this.querySelector(`.k-pie__center`),y=e=>{let t=(g[e].start+g[e].len/2)/d*2*Math.PI-Math.PI/2,n=o?l:l*1.3;return{x:(50+n*Math.cos(t))/100*s,y:(50+n*Math.sin(t))/100*s-8}},b=t=>{this.querySelectorAll(`[data-i]`).forEach(e=>e.toggleAttribute(`data-active`,Number(e.dataset.i)===t)),v&&(v.innerHTML=t===null?`<strong>${n(e(i))}</strong><span>${n(c)}</span>`:`<strong>${p(r[t].value,i)}</strong><span>${n(r[t].label)}</span>`),o||(t===null?this.tip(_,null):this.tip(_,y(t).x,y(t).y,void 0,[{name:r[t].label,value:p(r[t].value,i),color:a(t)},{name:`تعداد`,value:e(r[t].value)}]))};this.querySelectorAll(`.k-pie__slice, .k-pie__legend li`).forEach(e=>e.addEventListener(`pointerenter`,()=>b(Number(e.dataset.i)))),_.addEventListener(`pointerleave`,()=>b(null)),this.querySelector(`.k-pie__legend`).addEventListener(`pointerleave`,()=>b(null))}};b.observedAttributes=[`label`,`data`,`unit`,`variant`,`total-label`,`size`];var x=class extends g{get values(){return this.props.values??(this.getAttribute(`values`)??``).split(/[,،\s]+/).filter(Boolean).map(Number).filter(e=>!Number.isNaN(e))}set values(e){this.write(`values`,e)}draw(){let e=this.values;if(!e.length){this.innerHTML=``;return}let t=Math.max(...e),r=Math.min(...e),i=Math.max(t-r,Math.abs(t)*.25)||1,a=(t+r)/2-i/2,o=e.map((t,n)=>`${n?`L`:`M`}${n/Math.max(1,e.length-1)*100},${28-(t-a)/i*24}`).join(` `),s=this.getAttribute(`tone`)??`brand`,c=s===`neutral`?`var(--k-text-tertiary)`:s===`brand`?`var(--k-text-brand)`:`var(--k-text-${s})`,l=this.getAttribute(`label`);this.innerHTML=`<svg class="k-sparkline" viewBox="0 0 100 30" preserveAspectRatio="none"${l?` role="img" aria-label="${n(l)}"`:` aria-hidden="true"`} style="color: ${c}">${this.getAttribute(`area`)===`false`?``:`<path d="${o} L100,30 L0,30 Z" fill="currentColor" opacity="0.1"></path>`}<path d="${o}" fill="none" stroke="currentColor" stroke-width="2" vector-effect="non-scaling-stroke" stroke-linejoin="round" stroke-linecap="round"></path></svg>`}};x.observedAttributes=[`values`,`tone`,`area`,`label`];var S=class extends g{constructor(){super(...arguments),this.ro=null,this.active=null}get labels(){return this.read(`labels`,[])}set labels(e){this.write(`labels`,e)}get series(){return this.read(`series`,[])}set series(e){this.write(`series`,e)}connectedCallback(){if(super.connectedCallback(),typeof ResizeObserver<`u`&&!this.ro){let e=0;this.ro=new ResizeObserver(()=>{let t=this.clientWidth;t&&t!==e&&(e=t,this.paintSvg())}),this.ro.observe(this)}}disconnectedCallback(){this.ro?.disconnect(),this.ro=null}draw(){let e=this.series.slice(0,4),t=this.format,r=this.labels,i=this.getAttribute(`height`);this.innerHTML=`<figure class="k-chart" aria-labelledby="${this.key}-t" style="margin: 0${i?`; --k-chart-height: ${n(i)}`:``}"><figcaption class="k-chart__head"><p class="k-chart__title" id="${this.key}-t">${n(this.heading)}</p>${e.length>1?`<ul class="k-chart__legend" aria-hidden="true">${e.map((e,t)=>`<li style="--_c: ${m(t)}"><span class="k-chart__key"></span>${n(e.name)}</li>`).join(``)}</ul>`:``}</figcaption><div class="k-chart__plot" tabindex="0" role="img" aria-label="${n(`${this.heading}. با کلیدهای جهت بین نقطه‌ها حرکت کنید.`)}" aria-describedby="${this.key}-live"><svg class="k-chart__svg" aria-hidden="true" direction="ltr"></svg></div><span class="k-sr-only" aria-live="polite" id="${this.key}-live"></span><table class="k-sr-only"><caption>${n(this.heading)}</caption><thead><tr><th scope="col">دوره</th>${e.map(e=>`<th scope="col">${n(e.name)}</th>`).join(``)}</tr></thead><tbody>${r.map((r,i)=>`<tr><th scope="row">${n(r)}</th>${e.map(e=>`<td>${n(t(e.values[i]))}</td>`).join(``)}</tr>`).join(``)}</tbody></table></figure>`;let a=this.querySelector(`.k-chart__plot`);a.addEventListener(`pointermove`,e=>this.pick(e.clientX)),a.addEventListener(`pointerleave`,()=>this.setActive(null)),a.addEventListener(`blur`,()=>this.setActive(null)),a.addEventListener(`keydown`,e=>{let t=getComputedStyle(a).direction===`rtl`,n=r.length,i={ArrowLeft:t?1:-1,ArrowRight:t?-1:1}[e.key];i?(e.preventDefault(),this.setActive(Math.min(n-1,Math.max(0,(this.active??(i>0?-1:n))+i)))):e.key===`Home`?this.setActive(0):e.key===`End`?this.setActive(n-1):e.key===`Escape`&&this.setActive(null)}),this.active=null,this.paintSvg()}geometry(){let e=this.querySelector(`.k-chart__plot`),t=this.series.slice(0,4),n=this.labels,r=e.clientWidth||600,i=e.clientHeight||220,a=getComputedStyle(e).direction===`rtl`,o={top:12,bottom:24,start:52,end:t.length>1?64:16},s=f(Math.max(0,...t.flatMap(e=>e.values))),c=s.at(-1)||1,l=Math.max(1,r-o.start-o.end),u=Math.max(1,i-o.top-o.bottom);return{plot:e,shown:t,labels:n,w:r,h:i,rtl:a,pad:o,ticks:s,innerW:l,innerH:u,x:e=>{let t=n.length>1?e/(n.length-1):.5;return a?r-o.start-t*l:o.start+t*l},y:e=>o.top+u-e/c*u}}paintSvg(){if(!this.querySelector(`.k-chart__plot`))return;let{plot:e,shown:t,labels:r,w:i,h:a,rtl:o,pad:s,ticks:c,innerW:l,innerH:u,x:f,y:p}=this.geometry(),h=e.querySelector(`svg`),g=o?i-s.start+8:s.start-8,_=o?`start`:`end`,v=r.length-1,y=t.map((e,t)=>({i:t,y:p(e.values[v])})).sort((e,t)=>e.y-t.y);for(let e=1;e<y.length;e++)y[e].y-y[e-1].y<14&&(y[e].y=y[e-1].y+14);let b=Object.fromEntries(y.map(e=>[e.i,e.y])),x=Math.max(1,Math.ceil(r.length/Math.max(2,Math.floor(l/64)))),S=`${this.key}-fade`,C=this.active;h.innerHTML=`<g class="k-chart__grid">${c.map(e=>`<line x1="${s.start}" x2="${i-s.end}" y1="${p(e)}" y2="${p(e)}"${o?` transform="translate(${s.end-s.start} 0)"`:``}></line>`).join(``)}</g>${c.map(e=>`<text class="k-chart__tick" x="${g}" y="${p(e)+4}" text-anchor="${_}">${n(d(e))}</text>`).join(``)}${r.map((e,t)=>t%x===0||t===v?`<text class="k-chart__tick" x="${f(t)}" y="${a-6}" text-anchor="middle">${n(e)}</text>`:``).join(``)}<defs><linearGradient id="${S}" x1="0" y1="0" x2="0" y2="1"><stop offset="0" style="stop-color: var(--k-chart-1); stop-opacity: 0.28"></stop><stop offset="1" style="stop-color: var(--k-chart-1); stop-opacity: 0"></stop></linearGradient></defs>${t.length===1&&this.getAttribute(`area`)!==`false`?`<path class="k-chart__area" fill="url(#${S})" d="M${f(0)},${p(0)} ${t[0].values.map((e,t)=>`L${f(t)},${p(e)}`).join(` `)} L${f(v)},${p(0)} Z"></path>`:``}${C===null?``:`<line class="k-chart__cross" x1="${f(C)}" x2="${f(C)}" y1="${s.top}" y2="${s.top+u}"></line>`}${t.map((e,r)=>`<g style="--_c: ${m(r)}"><path class="k-chart__line" pathLength="1" d="${e.values.map((e,t)=>`${t?`L`:`M`}${f(t)},${p(e)}`).join(` `)}"></path><circle class="k-chart__dot" cx="${f(e.values.length-1)}" cy="${p(e.values.at(-1)??0)}" r="4"></circle>${t.length>1?`<text class="k-chart__end" x="${f(v)+(o?-8:8)}" y="${b[r]+4}" text-anchor="${o?`end`:`start`}">${n(e.name)}</text>`:``}${C===null?``:`<circle class="k-chart__dot" cx="${f(C)}" cy="${p(e.values[C])}" r="4.5"></circle>`}</g>`).join(``)}`;let w=this.format;C===null?this.tip(e,null):this.tip(e,f(C),Math.min(...t.map(e=>p(e.values[C])))-6,r[C],t.map((e,t)=>({name:e.name,value:w(e.values[C]),color:m(t)}))),this.querySelector(`#${this.key}-live`).textContent=C===null?``:`${r[C]}: ${t.map(e=>`${e.name} ${w(e.values[C])}`).join(`، `)}`}pick(e){let{plot:t,labels:n,x:r}=this.geometry(),i=e-t.getBoundingClientRect().left,a=0;n.forEach((e,t)=>{Math.abs(r(t)-i)<Math.abs(r(a)-i)&&(a=t)}),a!==this.active&&this.setActive(a)}setActive(e){this.active=e,this.paintSvg()}};S.observedAttributes=[`label`,`labels`,`series`,`unit`,`area`,`height`];const C=[`ش`,``,`د`,``,`چ`,``,`ج`];var w=class extends g{get data(){return this.read(`data`,{})}set data(e){this.write(`data`,e)}draw(){let e=this.data,t=Number(this.getAttribute(`year`))||a(/* @__PURE__ */ new Date).jy,r=this.getAttribute(`unit`)??`فعالیت`,d=[];for(let n=1;n<=12;n++)for(let r=1;r<=c(t,n);r++){let i=s(t,n,r);d.push({date:i,value:e[u(i)]??0})}let f=Math.max(0,...d.map(e=>e.value)),p=e=>e<=0||f===0?0:Math.max(1,Math.ceil(e/f*4)),m=(d[0].date.getDay()+1)%7,h=e=>Math.floor((e+m)/7),g=l.map((e,t)=>({name:e,col:h(d.findIndex(e=>a(e.date).jm===t+1))})),_=d.reduce((e,t)=>e+t.value,0),v=l.map((e,t)=>({name:e,sum:d.filter(e=>a(e.date).jm===t+1).reduce((e,t)=>e+t.value,0)})),y=i(t).replace(/٬/g,``),b=this.getAttribute(`label`)??`${r} در سال ${y}`;this.innerHTML=`<figure class="k-heatmap" style="margin: 0"><div class="k-heatmap__scroll"><div role="img" aria-label="${n(`${b}: ${i(_)} ${r}`)}"><div class="k-heatmap__months" aria-hidden="true">${g.map(e=>`<span style="grid-column: ${e.col+1}">${e.name}</span>`).join(``)}</div><div class="k-heatmap__body" aria-hidden="true"><div class="k-heatmap__days">${C.map(e=>`<span>${e}</span>`).join(``)}</div><div class="k-heatmap__grid">${`<span class="k-heatmap__cell" data-empty=""></span>`.repeat(m)}${d.map((e,t)=>`<span class="k-heatmap__cell" data-l="${p(e.value)}" data-i="${t}"></span>`).join(``)}</div></div></div></div><figcaption class="k-heatmap__foot"><span>${i(_)} ${n(r)} در ${y}</span><span class="k-heatmap__scale" aria-hidden="true">کمتر ${[0,1,2,3,4].map(e=>`<span class="k-heatmap__cell" data-l="${e}"></span>`).join(``)} بیشتر</span></figcaption><table class="k-sr-only"><caption>${n(b)}، به تفکیک ماه</caption><tbody>${v.map(e=>`<tr><th scope="row">${e.name}</th><td>${i(e.sum)}</td></tr>`).join(``)}</tbody></table></figure>`;let x=this.querySelector(`figure`);this.querySelector(`.k-heatmap__grid`).addEventListener(`pointerover`,e=>{let t=e.target.closest(`[data-i]`);if(x.querySelector(`.k-heatmap__cell[data-active]`)?.removeAttribute(`data-active`),!t)return this.tip(x,null);t.setAttribute(`data-active`,``);let n=this.at(t,x),a=d[Number(t.dataset.i)];this.tip(x,n.x,n.y-2,o(a.date,{style:`full`}),[{value:`${i(a.value)} ${r}`}])}),x.addEventListener(`pointerleave`,()=>this.tip(x,null))}};w.observedAttributes=[`data`,`year`,`unit`,`label`],e(`kashi-bar-chart`,_,`block`),e(`kashi-line-chart`,S,`block`),e(`kashi-pie-chart`,b,`block`),e(`kashi-bar-list`,v,`block`),e(`kashi-proportion-bar`,y,`block`),e(`kashi-sparkline`,x),e(`kashi-activity-heatmap`,w,`block`);export{w as KashiActivityHeatmap,_ as KashiBarChart,v as KashiBarList,S as KashiLineChart,b as KashiPieChart,y as KashiProportionBar,x as KashiSparkline};
@@ -1 +1 @@
1
- import{a as e,c as t,d as n,l as r,o as i,r as a,s as o,t as s,u as c}from"./base-Cmq7zeIG.js";import{i as l}from"./digits-DE1YGT94.js";import{n as u}from"./text-D1U32D6K.js";const d=[{name:`آذربایجان شرقی`,capital:`تبریز`,areaCode:`41`},{name:`آذربایجان غربی`,capital:`ارومیه`,areaCode:`44`},{name:`اردبیل`,capital:`اردبیل`,areaCode:`45`},{name:`اصفهان`,capital:`اصفهان`,areaCode:`31`},{name:`البرز`,capital:`کرج`,areaCode:`26`},{name:`ایلام`,capital:`ایلام`,areaCode:`84`},{name:`بوشهر`,capital:`بوشهر`,areaCode:`77`},{name:`تهران`,capital:`تهران`,areaCode:`21`},{name:`چهارمحال و بختیاری`,capital:`شهرکرد`,areaCode:`38`},{name:`خراسان جنوبی`,capital:`بیرجند`,areaCode:`56`},{name:`خراسان رضوی`,capital:`مشهد`,areaCode:`51`},{name:`خراسان شمالی`,capital:`بجنورد`,areaCode:`58`},{name:`خوزستان`,capital:`اهواز`,areaCode:`61`},{name:`زنجان`,capital:`زنجان`,areaCode:`24`},{name:`سمنان`,capital:`سمنان`,areaCode:`23`},{name:`سیستان و بلوچستان`,capital:`زاهدان`,areaCode:`54`},{name:`فارس`,capital:`شیراز`,areaCode:`71`},{name:`قزوین`,capital:`قزوین`,areaCode:`28`},{name:`قم`,capital:`قم`,areaCode:`25`},{name:`کردستان`,capital:`سنندج`,areaCode:`87`},{name:`کرمان`,capital:`کرمان`,areaCode:`34`},{name:`کرمانشاه`,capital:`کرمانشاه`,areaCode:`83`},{name:`کهگیلویه و بویراحمد`,capital:`یاسوج`,areaCode:`74`},{name:`گلستان`,capital:`گرگان`,areaCode:`17`},{name:`گیلان`,capital:`رشت`,areaCode:`13`},{name:`لرستان`,capital:`خرم‌آباد`,areaCode:`66`},{name:`مازندران`,capital:`ساری`,areaCode:`11`},{name:`مرکزی`,capital:`اراک`,areaCode:`86`},{name:`هرمزگان`,capital:`بندرعباس`,areaCode:`76`},{name:`همدان`,capital:`همدان`,areaCode:`81`},{name:`یزد`,capital:`یزد`,areaCode:`35`}],f={"آذربایجان شرقی":/* @__PURE__ */ `آبشاحمد.آچاچی.آذرشهر.آقکند.اسکو.اهر.ایلخچی.باسمنج.بخشایش.بستان‌آباد.بناب.بناب مرند.تبریز.ترک.ترکمانچای.تسوج.تیکمهداش.تیمورلو.جلفا.جوانقلعه.خاروانا.خامنه.خداجو.خسروشاه.خمارلو.خواجه.دریان.دوزدوزان.زرنق.زنوز.سراب.سردرود.سهند.سیس.سیهرود.شبستر.شربیان.شرفخانه.شندآباد.شهریار.صوفیان.عجبشیر.قرهآغاج.کشکسرای.کلوانق.کلیبر.کوزهکنان.گوگان.لیلان.مبارک آباد.مراغه.مرند.ملکان.ملککیان.ممقان.مهربان.میانه.نظرکهریزی.وایقان.ورزقان.هادی‌شهر.هریس.هشترود.هوراند.یامچی`.split(`.`),"آذربایجان غربی":/* @__PURE__ */ `آواجیق.ارومیه.اشنویه.ایواوغلی.باروق.بازرگان.بوکان.پلدشت.پیرانشهر.تازه‌شهر.تکاب.چهاربرج.خلیفان.خوی.دیزج دیز.ربط.زرآباد.سردشت.سرو.سلماس.سیلوانه.سیمینه.سیهچشمه.شاهیندژ.شوط.فیرورق.قرهضیاءالدین.قطور.قوشچی.کشاورز.گردکشانه.ماکو.محمدیار.محمودآباد.مرگنلر.مهاباد.میاندوآب.میرآباد.نازک علیا.نالوس.نقده.نوشینشهر`.split(`.`),اردبیل:[`آبیبیگلو`,`اردبیل`,`اسلام‌آباد قدیم`,`اصلاندوز`,`انگوت`,`بیلهسوار`,`پارس‌آباد`,`جعفرآباد`,`خلخال`,`رضی`,`سرعین`,`عنبران`,`قصابه`,`کلور`,`کوراییم`,`گرمی`,`گیوی`,`لاهرود`,`مرادلو`,`مشگینشهر`,`نمین`,`نیر`,`هشجین`,`هیر`],اصفهان:/* @__PURE__ */ `آران و بیدگل.ابریشم.ابوزیدآباد.اردستان.اژیه.اشترجان.اصغرآباد.اصفهان.افوس.انارک.بادرود.باغ بهادران.باغشاد.بافران.برزک.برفانبار.بوئین و میاندشت.بهارانشهر.بهارستان.پیربکران.تودشک.تیران.جندق.جوزدان.جوشقان قالی.جوشقان و کامو.چادگان.چرمهین.چمگردان.حبیب آباد برخوار.حسن‌آباد.حنا.خالدآباد.خمینی‌شهر.خوانسار.خور.خوراسگان.خورزوق.داران.دامنه.درچهپیاز.دستگرد.دولت‌آباد.دهاقان.دهق.دیزیچه.رزوه.رضوانشهر.زازران.زایندهرود.زرینشهر.زواره.زیار.زیباشهر.سده لنجان.سفیدشهر.سگزی.سمیرم.سین.شاپورآباد.شاهینشهر.شهر جدید مجلسی.شهرضا.طالخونچه.طرق.عسگران.علویجه.فرخی.فریدونشهر.فلاورجان.فولادشهر.قمصر.قهجاورستان.قهدریجان.کاشان.کرکوند.کلیشاد و سودرجان.کمشجه.کمه.کوشک.کوهپایه.کهریزسنگ.گرگاب.گز.گلپایگان.گلدشت.گلشن.گلشهر.گوگد.لای بید.مبارکه.محمدآباد.مشکات.منظریه.مهاباد.میمه.نائین.نجف‌آباد.نصرآباد.نطنز.نوش‌آباد.نیاسر.نیک‌آباد.ورزنه.ورنامخواست.وزوان.ونک.هرند.یزدانشهر نجف آباد`.split(`.`),البرز:[`آسارا`,`اشتهارد`,`تنکمان`,`چهارباغ`,`طالقان`,`فردیس`,`کرج`,`کمالشهر`,`کوهسار`,`گرمدره`,`گلسار`,`ماهدشت`,`محمدشهر`,`مشکیندشت`,`مهستان`,`نظرآباد`],ایلام:/* @__PURE__ */ `آبدانان.آسمان‌آباد.ارکواز.ایلام.ایوان.بدره.بلاوه تره سفلی.پهله.توحید.جعفرآباد.چشمه شیرین.چوار.دره‌شهر.دلگشا.دهلران.زرنه.سرابباغ.سرابله.شباب.صالح‌آباد.لومار.ماژین.مورموری.موسیان.مهر.مهران.میمه`.split(`.`),بوشهر:/* @__PURE__ */ `آباد.آبپخش.آبدان.امام حسن.انارستان.اهرم.بادوله.برازجان.بردخون.بردستان.بندر دیر.بندر دیلم.بندر ریگ.بندر سیراف.بندر کنگان.بندر گناوه.بندو.بنک.بوشکان.بوشهر.تنگ ارم.جم.چغادک.خارگ.خورموج.دالکی.دلوار.دوراهک.ریز.سعدآباد.شبانکاره.شنبه.عالی‌شهر.عسلویه.کاکی.کلمه.نخل تقی.وحدتیه`.split(`.`),تهران:/* @__PURE__ */ `آبسرد.آبعلی.احمدآباد مستوفی.ارجمند.اسلامشهر.اندیشه.باغستان.باقرشهر.بومهن.پاکدشت.پردیس.پرند.پیشوا.تهران.جلیل‌آباد.جوادآباد.چهاردانگه.حسن‌آباد.خاورشهر.دماوند.رباطکریم.رودهن.شاهدشهر.شریف‌آباد.شمشک.شهر ری.شهریار.صالحیه.صباشهر.صفادشت.فردوسیه.فرون‌آباد.فشم.فیروزکوه.قدس.قرچک.کرشته.کهریزک.کیلان.گلستان.لواسان.ملارد.نسیم‌شهر.نصیرشهر.وحیدیه.ورامین`.split(`.`),"چهارمحال و بختیاری":/* @__PURE__ */ `آلونی.اردل.باباحیدر.بروجن.بلداجی.بن.پردنجان.تلورد.جونقان.چالشتر.چلگرد.چلیچه.دستنا.دشتک.سامان.سرخون.سردشت.سفیددشت.سودجان.سورشجان.شلمزار.شهرکرد.صمصامی.طاقانک.فارسان.فرادنبه.فرخشهر.کاج.کیان.گندمان.گوجان.گهرو.لردگان.مالخلیفه.منج نسا.ناغان.نافچ.وردنجان.هارونی.هرچگان.هفشجان.یانچشمه`.split(`.`),"خراسان جنوبی":/* @__PURE__ */ `آرینشهر.آیسک.ارسک.اسدیه.اسفدن.اسلامیه.باغستان علیا.بشرویه.بیرجند.حاجی‌آباد.خضری دشتبیاض.خوسف.درح.دیهوک.زهان.سرایان.سربیشه.سهقلعه.شوسف.طبس.طبس مسینا.عشق‌آباد.فردوس.قائن.قهستان.گزیک.محمدشهر.مود.نهبندان.نیمبلوک`.split(`.`),"خراسان رضوی":/* @__PURE__ */ `احمدآباد.انابد.باجگیران.باخرز.بار.بایگ.بجستان.بردسکن.بیدخت.بینالود.تایباد.تربت جام.تربت حیدریه.جغتای.جنگل.چاپشلو.چکنه.چناران.خرو.خلیل‌آباد.خواف.داورزن.دررود.درگز.دولت‌آباد.رادکان.رباط سنگ.رشتخوار.رضویه.رودآب.ریوش.سبزوار.سرخس.سفیدسنگ.سلامی.سلطان‌آباد.سنگان.سیدآباد.شادمهر.شاندیز.ششتمد.شهرآباد.شهرزو.شهرکهنه.صالح‌آباد.طرقبه.عشق‌آباد.فرگ قلعه.فرهادگرد.فریمان.فیروزه.فیض‌آباد.قاسم‌آباد.قدمگاه.قلندرآباد.قوچان.کاخک.کاریز.کاشمر.کدکن.کلات.کندر.گلبهار.گلمکان.گناباد.لطف‌آباد.مزداوند.مشهد.مشهد ریزه.ملک‌آباد.نسر.نشتیفان.نصرآباد.نقاب.نوخندان.نیشابور.نیلشهر.همت‌آباد.یونسی`.split(`.`),"خراسان شمالی":[`آشخانه`,`آوا`,`اسفراین`,`ایور`,`بجنورد`,`پیشقلعه`,`تیتکانلو`,`جاجرم`,`چنارانشهر`,`حصار گرمخان`,`درق`,`راز`,`زیارت`,`سنخواست`,`شوقان`,`شیروان`,`صفی‌آباد`,`فاروج`,`فیروزه`,`قاضی`,`گرمه`,`لوجلی`],خوزستان:/* @__PURE__ */ `آبادان.آبژدان.آغاجاری.ابوحمیظه.اروندکنار.الوان.الهایی.امیدیه.اندیمشک.اهواز.ایذه.باغملک.بستان.بندر امام خمینی.بندر ماهشهر.بهبهان.بیدروبهمرکزی.ترکالکی.تشان.جایزان.جنتمکان.چغامیش.چم گلک.چمران.چویبده.حر ریاحی.حسینیه.حمیدیه.خرمشهر.دارخوین.دزآب.دزفول.دهدز.رامشیر.رامهرمز.رفیع.زهره.سالند.سردشت.سماله.سوسنگرد.سیاهمنصور.شادگان.شمس‌آباد.شوش.شوشتر.شهرک حمزه.شیبان.صالح شهر.صفی‌آباد.صیدون.فتح‌المبین.قلعه خواجه.قلعهتل.کوت سیدنعیم طالقانی.کوت عبدالله.گتوند.گوریه.لالی.مسجدسلیمان.مشراگه.مقاومت.ملاثانی.منصوریه.میانرود.میانکوه.میداود.مینوشهر.ویس.هفتکل.هندیجان.هویزه`.split(`.`),زنجان:[`آببر`,`ابهر`,`ارمغانخانه`,`چورزق`,`حلب`,`خرمدره`,`دندی`,`زرین‌آباد`,`زرینرود`,`زنجان`,`سجاس`,`سلطانیه`,`سهرورد`,`صایینقلعه`,`قیدار`,`کرسف`,`گرماب`,`ماهنشان`,`نیکپی`,`هیدج`],سمنان:[`آرادان`,`امیریه`,`ایوانکی`,`بسطام`,`بیارجمند`,`دامغان`,`درجزین`,`دیباج`,`رودیان`,`سرخه`,`سمنان`,`شاهرود`,`شهمیرزاد`,`کلاته خیج`,`کلاته رودبار`,`کهن‌آباد`,`گرمسار`,`مجن`,`مهدی‌شهر`,`میامی`],"سیستان و بلوچستان":/* @__PURE__ */ `آسپیچ محمدی.ادیمی.اسپکه.ایرانشهر.بریس.بزمان.بمپور.بنت.بنجار.پیشین.جالق.چابهار.خاش.دوستمحمد.راسک.رامشار.زابل.زاهدان.زرآباد.زهک.سراوان.سرباز.سوران.سیب.سیرکان.شهرک علیاکبر.فنوج.قصرقند.کنارک.گشت.گلمورتی.محمدآباد.مهرستان.میرجاوه.نصرت‌آباد.نگور.نوک‌آباد.نیکشهر.هیدوچ`.split(`.`),فارس:/* @__PURE__ */ `آباده.آباده طشک.ارد.اردکان.ارسنجان.استهبان.اسیر.اشکنان.افزر.اقلید.اوز.اهل.ایج.ایزدخواست.باب انار.بابامنیر.بایگان.بنارویه.بوانات.بهمن.بیرم.بیضا.جنتشهر.جویم.جهرم.حاجی‌آباد.حسامی.حسن‌آباد.خانه زنیان.خانیمن.خاوران.خرامه.خشت.خنج.خور.خوزی.خومهزار.داراب.داریان.دبیران.دژکرد.دوبرجی.دوزه.دهرم.رامجرد.رونیز.زاهدشهر.زرقان.سده.سروستان.سعادتشهر.سلطانشهر.سورمق.سیدان.ششده.شهر جدید صدرا.شهرپیر.شهرک امام.شیراز.صغاد.صفاشهر.علامرودشت.عمادشهر.فاروق.فتح آباد.فدامی.فراشبند.فسا.فیروزآباد.فیشور.قائمیه.قادرآباد.قرهبلاغ.قطب‌آباد.قطرویه.قیر.کازرون.کامفیروز.کرهای.کنارتخته.کوار.کوپن.کوهنجان.گراش.گلهدار.گویم.لار.لامرد.لپوئی.لطیفی.مادرسلیمان.مرودشت.مزایجان.مشکان.مصیری.مهر.میانشهر.میمند.نوبندگان.نوجین.نودان.نورآباد.نیریز.والاشهر.وراوی.هماشهر`.split(`.`),قزوین:[`آبگرم`,`آبیک`,`آوج`,`ارداق`,`اسفرورین`,`اقبالیه`,`الوند`,`بوئینزهرا`,`بیدستان`,`تاکستان`,`خاکعلی`,`خرمدشت`,`دانسفهان`,`رازمیان`,`سگزآباد`,`سیردان`,`شال`,`ضیاءآباد`,`قزوین`,`کوهین`,`محمدیه`,`محمودآباد نمونه`,`معلمکلایه`,`نرجه`],قم:[`جعفریه`,`دستجرد`,`سلفچگان`,`قاهان`,`قم`,`قنوات`,`کهک`],کردستان:/* @__PURE__ */ `آرمرده.اورامان.بابارشانی.بانه.برده رشه.بلبان‌آباد.بویین سفلی.بیجار.پیرتاج.توپآغاج.چناره.حسن‌آباد یاسوکند.دزج.دلبران.دهگلان.دیواندره.زرینه.سروآباد.سریش‌آباد.سقز.سنندج.شویشه.صاحب.قروه.کامیاران.کانیدینار.کانیسور.مریوان.موچش`.split(`.`),کرمان:/* @__PURE__ */ `اختیارآباد.ارزوئیه.امینشهر.انار.اندوهجرد.باغین.بافت.بردسیر.بروات.بزنجان.بلورد.بلوک.بم.بهرمان.پاریز.جبالبارز.جوپار.جوزم.جیرفت.چترود.خاتون‌آباد.خانوک.خرسند.خواجو شهر.درب بهشت.دشتکار.دوساری.دهج.دهستان بزنجان.رابر.راور.راین.رفسنجان.ریحانشهر.زرند.زنگی‌آباد.زهکلوت.زیدآباد.سیرجان.سیریز.شهداد.شهربابک.صفائیه.عنبرآباد.فاریاب.فهرج.قلعهگنج.کاظم‌آباد.کرمان.کشکوئیه.کوهبنان.کهنوج.کیانشهر.گلباف.گلزار.لاله زار.ماهان.محمدآباد.محمدآباد گنبکی.محی‌آباد.مردهک.مس سرچشمه.منوجان.نجفشهر.نرماشیر.نظامشهر.نگار.نودژ.هجدک.هماشهر.هنزا.یزدانشهر`.split(`.`),کرمانشاه:/* @__PURE__ */ `ازگله.اسلام‌آباد غرب.بانهوره.باینگان.بیستون.پاوه.تازه‌آباد.جوانرود.حمیل.روانسر.ریژاو.سرپل ذهاب.سرمست.سطر.سنقر.سومار.شروینه.صحنه.قصر شیرین.قلعه.کرمانشاه.کرند غرب.کنگاور.کوزران.گودین.گهواره.گیلانغرب.ماهیدشت.میانراهان.نودشه.نوسود.هرسین.هلشی`.split(`.`),"کهگیلویه و بویراحمد":[`باشت`,`پاتاوه`,`چرام`,`چیتاب`,`دوگنبدان`,`دهدشت`,`دیشموک`,`سوق`,`سیسخت`,`قلعه رئیسی`,`گراب سفلی`,`لنده`,`لیکک`,`مادوان علیا`,`مارگون`,`محله چینیها`,`یاسوج`],گلستان:/* @__PURE__ */ `آزادشهر.آققلا.انبارآلوم.اینچهبرون.بندر ترکمن.بندر گز.تاتار علیا.خانببین.دلند.رامیان.سرخنکلاته.سنگدوین.سیمینشهر.علی‌آباد کتول.فاضل‌آباد.فراغی.قرق.کردکوی.کلاله.گالیکش.گرگان.گمیشان.گنبد کاووس.مراوهتپه.مزرعه.مینودشت.نگینشهر.نوده خاندوز.نوکنده`.split(`.`),گیلان:/* @__PURE__ */ `آستارا.آستانه اشرفیه.احمدسرگوراب.اسالم.اطاقور.املش.بازارجمعه.برهسر.بندر انزلی.بندر کیاشهر.پرهسر.توتکابن.جیرنده.چابکسر.چاف و چمخاله.چوبر.حویق.خشکبیجار.خمام.دیلمان.رانکوه.رحیم‌آباد.رستم‌آباد.رشت.رضوانشهر.رودبار.رودبنه.رودسر.سنگر.سیاهکل.شفت.شلمان.صومعهسرا.فومن.کلاچای.کوچصفهان.کومله.گوراب زرمیخ.لاهیجان.لشت نشا.لنگرود.لوشان.لولمان.لوندویل.لیسار.ماسال.ماسوله.ماکلوان.مرجغل.منجیل.واجارگاه.هشتپر`.split(`.`),لرستان:[`ازنا`,`اشترینان`,`الشتر`,`الیگودرز`,`بروجرد`,`بیرانشهر`,`پل دختر`,`چالانچولان`,`چقابل`,`خرم‌آباد`,`درب گنبد`,`دورود`,`زاغه`,`سپیددشت`,`سرابدوره`,`شول‌آباد`,`فیروزآباد`,`کونانی`,`کوهدشت`,`گراب لکستان`,`معمولان`,`مومن‌آباد`,`نورآباد`,`ویسیان`,`هفتچشمه`],مازندران:/* @__PURE__ */ `آلاشت.آمل.ارطه.اکند.امامزاده عبدالله.امیرکلا.ایزدشهر.بابل.بابلسر.بلده.بهشهر.بهنمیر.پایین هولار.پل سفید.پول.تنکابن.جویبار.چالوس.چمستان.خرم‌آباد.خلیلشهر.خوشرودپی.دابودشت.رامسر.رستمکلا.رویان.رینه.زرگرمحله.زیرآب.ساری.سرخرود.سلمانشهر.سورک.شیرگاه.شیرود.طبقده.عباس‌آباد.فرح‌آباد.فریدونکنار.فریم.قائمشهر.کتالم و ساداتشهر.کجور.کلارآباد.کلاردشت.کلهبست.کوهیخیل.کیاسر.کیاکلا.گتاب.گزنک.گلوگاه.محمودآباد.مرزن‌آباد.مرزیکلا.نشتارود.نکا.نمکآبرود.نور.نوشهر.هچیرود`.split(`.`),مرکزی:/* @__PURE__ */ `آستانه.آشتیان.آوه.اراک.پرندک.تفرش.توره.جاورسیان.خشکرود.خمین.خنجین.خنداب.داوودآباد.دلیجان.رازقان.زاویه.ساروق.ساوه.سنجان.شازند.شهباز.شهر جدید امیرکبیر.غرق‌آباد.فرمهین.قورچیباشی.کارچان.کرهرود.کمیجان.مأمونیه.محلات.مهاجران.میلاجرد.نراق.نوبران.نیمور.هندودر`.split(`.`),هرمزگان:/* @__PURE__ */ `ابوموسی.بستک.بندر چارک.بندر خمیر.بندر کنگ.بندر لافت.بندر لنگه.بندرعباس.بیکا.پارسیان.تازیان پایین.تخت.تنب بزرگ.تیرور.جاسک.جناح.حاجی‌آباد.درگهان.دشتی.دهبارز.رویدر.زیارتعلی.سردشت.سرگز احمدی.سندرک.سوزا.سیریک.طبل.فارغان.فین.قشم.قلعه قاضی.کوخردهرنگ.کوهستک.کوهیج.کیش.گروک.گوهران.لمزان.میناب.هرمز.هشتبندی`.split(`.`),همدان:/* @__PURE__ */ `آجین.ازندریان.اسدآباد.برزول.بهار.تویسرکان.جورقان.جوکار.داقداق‌آباد.دمق.دهستان سلگی.رزن.زنگنه.سامن.سرکان.شیرینسو.صالح‌آباد.فامنین.فرسفج.فیروزان.قروه درجزین.قهاوند.کبودرآهنگ.گلتپه.گیان.لالجین.مریانج.ملایر.مهاجران.نهاوند.همدان`.split(`.`),یزد:[`ابرکوه`,`احمدآباد`,`اردکان`,`اشکذر`,`بافق`,`بخ`,`بفروییه`,`بهاباد`,`تفت`,`حمیدیا`,`خضرآباد`,`رضوانشهر`,`زارچ`,`شاهدیه`,`عقدا`,`مروست`,`مهردشت`,`مهریز`,`میبد`,`ندوشن`,`نیر`,`هرات`,`یزد`]};function p(e){return e&&f[e]||[]}const m={province:null,city:null,street:``,plaque:``,unit:``,postalCode:``},h=e=>u(e,{digits:`latin`}).toLowerCase();var g=class extends s{constructor(){super(...arguments),this.selected=null,this.query=``,this.list=null,this.filtered=[],this.typing=!1,this.isOpen=!1,this.active=-1,this.rendered=!1,this.valueSet=!1,this.key=n(`kashi-combo`),this.defaultLabel=null,this.defaultPlaceholder=``,this.onOutside=e=>{this.contains(e.target)||this.close()}}connectedCallback(){a(()=>{if(this.isConnected){if(!this.rendered){if(this.list===null&&(this.list=this.readOptions()),Object.prototype.hasOwnProperty.call(this,`value`)){let e=this.value;delete this.value,this.value=e??``}else if(!this.valueSet){let e=this.getAttribute(`value`);this.selected=e?this.find(e):null,this.query=this.selected?.label??``}}this.render()}})}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=n??``:this.render())}get options(){return this.list??[]}set options(e){this.list=[...e],this.selected&&=this.find(this.selected.value),this.rendered&&this.sync()}get value(){return this.selected?.value??``}set value(e){this.valueSet=!0,this.selected=e?this.find(e):null,this.query=this.selected?.label??``,this.typing=!1,this.rendered&&this.sync()}get selectedOption(){return this.selected}focus(e){this.input?.focus(e)}readOptions(){let e=[];for(let t of[...this.querySelectorAll(`:scope > option, :scope > optgroup > option`)]){let n=t.parentElement?.tagName===`OPTGROUP`?t.parentElement.getAttribute(`label`)??void 0:void 0;e.push({value:t.value,label:t.textContent?.trim()??t.value,description:t.dataset.description,keywords:t.dataset.keywords?.split(/[,،]\s*/),disabled:t.disabled,group:n})}for(let e of[...this.querySelectorAll(`:scope > option, :scope > optgroup`)])e.remove();return e}source(e){return this.options}accepts(e,t){let n=h(t.trim());return!n||[e.label,e.description??``,...e.keywords??[]].some(e=>h(e).includes(n))}find(e){return this.source(``).find(t=>t.value===e)??null}detail(){return{value:this.value,option:this.selected}}render(){let e=this.key,n=this.getAttribute(`aria-label`),r=this.hasAttribute(`label`)?this.getAttribute(`label`):n?null:this.defaultLabel,a=this.hasAttribute(`required`),s=this.hasAttribute(`disabled`),c=`${e}-list`,l=`<div class="k-combobox"><div class="k-input"${s?` data-state="disabled"`:``}><input id="${e}" class="k-input__control" type="text" role="combobox" aria-autocomplete="list" aria-expanded="false" aria-controls="${c}" autocomplete="off" placeholder="${o(this.getAttribute(`placeholder`)??this.defaultPlaceholder)}"${a?` required`:``}${s?` disabled`:``}${!r&&n?` aria-label="${o(n)}"`:``}><button type="button" tabindex="-1" class="k-input__action k-combobox__toggle" aria-label="نمایش گزینه‌ها"${s?` disabled`:``}><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 8 4 4 4-4"/></svg></button></div><ul id="${c}" role="listbox" class="k-listbox" hidden style="inset-block-start: calc(100% + 6px)"${r?` aria-label="${o(r)}"`:` aria-labelledby="${e}"`}></ul><span class="k-sr-only" aria-live="polite"></span></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,t({id:e,label:r,required:a,control:l})),this.input=this.querySelector(`input.k-input__control`),this.listbox=this.querySelector(`.k-listbox`),this.live=this.querySelector(`.k-combobox > .k-sr-only`),this.isOpen=!1,this.input.addEventListener(`input`,()=>{this.query=this.input.value,this.typing=!0,this.active=-1,this.open(!1),i(this,`kashi-input`,{query:this.query})}),this.input.addEventListener(`keydown`,e=>this.onKey(e)),this.input.addEventListener(`click`,()=>!this.isOpen&&this.open()),this.input.addEventListener(`blur`,e=>{this.contains(e.relatedTarget)||this.close()}),this.querySelector(`.k-combobox__toggle`).addEventListener(`click`,()=>{this.isOpen?this.close():(this.typing=!1,this.open(),this.input.focus())}),this.listbox.addEventListener(`pointerdown`,e=>e.preventDefault()),this.listbox.addEventListener(`click`,e=>{let t=e.target.closest(`[role="option"]`);t&&t.getAttribute(`aria-disabled`)!==`true`&&this.commit(this.filtered[Number(t.dataset.i)])}),this.listbox.addEventListener(`pointermove`,e=>{let t=e.target.closest(`[role="option"]`);t&&t.getAttribute(`aria-disabled`)!==`true`&&Number(t.dataset.i)!==this.active&&this.setActive(Number(t.dataset.i))}),this.rendered=!0,this.sync()}sync(){!this.typing&&this.input.value!==this.query&&(this.input.value=this.query),r(this.querySelector(`:scope > .k-field`),this.input,this.key,this.getAttribute(`error`),this.getAttribute(`hint`)),this.syncHidden(),this.isOpen&&this.renderList()}syncHidden(){c(this,this.getAttribute(`name`),this.value)}enabled(){return this.filtered.map((e,t)=>e.disabled?-1:t).filter(e=>e>=0)}open(e=!0,t=`selected`){if(!this.hasAttribute(`disabled`)){if(this.isOpen=!0,this.input.setAttribute(`aria-expanded`,`true`),this.listbox.hidden=!1,this.toggleAttribute(`data-open`,!0),this.querySelector(`.k-combobox`).setAttribute(`data-open`,``),this.filter(),e){let e=this.enabled(),n=this.filtered.findIndex(e=>e.value===this.selected?.value);this.active=t===`last`?e.at(-1)??-1:t===`first`||n<0?e[0]??-1:n}this.renderList(),document.addEventListener(`pointerdown`,this.onOutside)}}close(){this.rendered&&(this.isOpen=!1,this.input.setAttribute(`aria-expanded`,`false`),this.input.removeAttribute(`aria-activedescendant`),this.listbox.hidden=!0,this.querySelector(`.k-combobox`).removeAttribute(`data-open`),this.live.textContent=``,document.removeEventListener(`pointerdown`,this.onOutside),this.typing&&(this.typing=!1,this.query=this.selected?.label??``,this.input.value=this.query))}filter(){let e=this.source(this.typing?this.query:``);this.filtered=this.typing?e.filter(e=>this.accepts(e,this.query)):e}renderList(){let e=this.typing?h(this.query.trim()):``,t=t=>{let n=e?h(t).indexOf(e):-1;return n<0?o(t):`${o(t.slice(0,n))}<mark>${o(t.slice(n,n+e.length))}</mark>${o(t.slice(n+e.length))}`},n=`${this.key}-list`,r,i=this.filtered.slice(0,300).map((e,i)=>{let a=e.group&&e.group!==r?`<li role="presentation" class="k-listbox__group">${o(e.group)}</li>`:``;r=e.group;let s=e.value===this.selected?.value;return`${a}<li id="${n}-${i}" data-i="${i}" role="option" aria-selected="${s}"${e.disabled?` aria-disabled="true"`:``}${i===this.active?` data-active`:``} class="k-option"><span class="k-option__body"><span>${t(e.label)}</span>${e.description?`<span class="k-option__desc">${o(e.description)}</span>`:``}</span>${s?`<span class="k-option__check"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m5 10.5 3.2 3L15 7"/></svg></span>`:``}</li>`});this.filtered.length||i.push(`<li class="k-listbox__empty" role="presentation">${o(this.getAttribute(`empty-message`)??`نتیجه‌ای پیدا نشد.`)}</li>`),this.filtered.length>300&&i.push(`<li class="k-listbox__empty" role="presentation">${l(this.filtered.length-300)} گزینهٔ دیگر؛ برای پیدا کردن تایپ کنید.</li>`),this.listbox.innerHTML=i.join(``),this.live.textContent=this.typing?`${l(this.filtered.length)} نتیجه`:``,this.setActive(this.active)}setActive(e){this.active=e,this.listbox.querySelector(`[data-active]`)?.removeAttribute(`data-active`);let t=e>=0?this.listbox.querySelector(`[data-i="${e}"]`):null;t?(t.setAttribute(`data-active`,``),t.scrollIntoView?.({block:`nearest`}),this.input.setAttribute(`aria-activedescendant`,t.id)):this.input.removeAttribute(`aria-activedescendant`)}move(e){let t=this.enabled().filter(e=>e<300);if(!t.length)return;let n=t.indexOf(this.active);this.setActive(t[(n+e+t.length)%t.length])}onKey(e){if(e.key===`ArrowDown`)e.preventDefault(),this.isOpen?this.move(1):this.open(!0,e.altKey?`selected`:`first`);else if(e.key===`ArrowUp`)e.preventDefault(),this.isOpen?this.move(-1):this.open(!0,`last`);else if(e.key===`Enter`&&this.isOpen&&this.active>=0)e.preventDefault(),this.commit(this.filtered[this.active]);else if(e.key===`Escape`)this.isOpen?(e.preventDefault(),this.close()):this.input.value&&(e.preventDefault(),this.commit(null));else if((e.key===`Home`||e.key===`End`)&&this.isOpen){e.preventDefault();let t=this.enabled();this.setActive((e.key===`Home`?t[0]:t.at(-1))??-1)}}commit(e){let t=(e?.value??null)!==(this.selected?.value??null);this.selected=e,this.query=e?.label??``,this.typing=!1,this.input.value=this.query,this.close(),this.sync(),t&&i(this,`kashi-change`,this.detail())}};g.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`required`,`disabled`,`name`,`value`,`empty-message`,`aria-label`];var _=class extends g{constructor(){super(...arguments),this.defaultLabel=`استان`,this.defaultPlaceholder=`جستجوی استان یا شهر`}source(){let e=this.getAttribute(`show-capital`)!==`false`;return d.map(t=>({value:t.name,label:t.name,description:e?`مرکز: ${t.capital}`:void 0,keywords:[t.capital]}))}detail(){return{value:this.value,province:d.find(e=>e.name===this.value)??null}}};_.observedAttributes=[...g.observedAttributes,`show-capital`];const v=e=>h(e).replace(/[\s‌]/g,``);var y=class extends g{constructor(){super(...arguments),this.defaultLabel=`شهر`,this.custom=null}get province(){return this.getAttribute(`province`)||null}set province(e){e?this.setAttribute(`province`,e):this.removeAttribute(`province`)}get value(){return this.selected?this.selected.value.split(`|`)[1]:``}set value(e){this.valueSet=!0,this.custom=null;let t=this.source(``),n=this.province,r=e?t.find(t=>t.label===e&&(!n||t.value.startsWith(`${n}|`)))??null:null;e&&!r&&(this.custom=e,r={value:`custom|${e}`,label:e,description:`خارج از فهرست`}),this.selected=r,this.query=r?.label??``,this.isConnected&&this.querySelector(`.k-combobox`)&&this.sync()}find(e){return this.value=e,this.selected}attributeChangedCallback(e,t,n){if(e!==`province`)return super.attributeChangedCallback(e,t,n);if(t!==n){if(this.selected){let e=this.value;!n||!p(n).includes(e)?(this.selected=null,this.query=``,this.custom=null):this.selected={value:`${n}|${e}`,label:e}}this.querySelector(`.k-combobox`)&&(this.input.placeholder=this.getAttribute(`placeholder`)??this.placeholderText(),this.input.value=this.query,this.sync())}}connectedCallback(){this.defaultPlaceholder=this.placeholderText(),super.connectedCallback()}placeholderText(){return this.province?`جستجوی شهر`:`نام شهر، مثلاً کاشان`}source(e){let t=this.province,n=t?p(t).map(e=>({value:`${t}|${e}`,label:e})):Object.entries(f).flatMap(([e,t])=>t.map(t=>({value:`${e}|${t}`,label:t,description:e})));this.custom&&n.unshift({value:`custom|${this.custom}`,label:this.custom,description:`خارج از فهرست`});let r=e.trim();return this.getAttribute(`allow-custom`)!==`false`&&r&&r!==this.custom&&!n.some(e=>v(e.label)===v(r))&&n.push({value:`custom|${r}`,label:r,description:`شهر دیگر؛ همین نام ثبت شود`}),n}accepts(e,t){return e.value.startsWith(`custom|`)||[e.label,e.description??``].some(e=>v(e).includes(v(t)))}commit(e){this.custom=e?.value.startsWith(`custom|`)?e.label:null,super.commit(e)}detail(){let[e]=this.selected?this.selected.value.split(`|`):[null];return{value:this.value,province:e===`custom`?null:e}}};y.observedAttributes=[...g.observedAttributes,`province`,`allow-custom`],e(`kashi-combobox`,g,`block`),e(`kashi-province-select`,_,`block`),e(`kashi-city-select`,y,`block`);export{y as KashiCitySelect,g as KashiCombobox,_ as KashiProvinceSelect,p as n,d as r,h as searchText,m as t};
1
+ import{a as e,c as t,d as n,l as r,o as i,r as a,s as o,t as s,u as c}from"./base-DfzNTdQk.js";import{i as l}from"./digits-DE1YGT94.js";import{n as u}from"./text-D1U32D6K.js";const d=[{name:`آذربایجان شرقی`,capital:`تبریز`,areaCode:`41`},{name:`آذربایجان غربی`,capital:`ارومیه`,areaCode:`44`},{name:`اردبیل`,capital:`اردبیل`,areaCode:`45`},{name:`اصفهان`,capital:`اصفهان`,areaCode:`31`},{name:`البرز`,capital:`کرج`,areaCode:`26`},{name:`ایلام`,capital:`ایلام`,areaCode:`84`},{name:`بوشهر`,capital:`بوشهر`,areaCode:`77`},{name:`تهران`,capital:`تهران`,areaCode:`21`},{name:`چهارمحال و بختیاری`,capital:`شهرکرد`,areaCode:`38`},{name:`خراسان جنوبی`,capital:`بیرجند`,areaCode:`56`},{name:`خراسان رضوی`,capital:`مشهد`,areaCode:`51`},{name:`خراسان شمالی`,capital:`بجنورد`,areaCode:`58`},{name:`خوزستان`,capital:`اهواز`,areaCode:`61`},{name:`زنجان`,capital:`زنجان`,areaCode:`24`},{name:`سمنان`,capital:`سمنان`,areaCode:`23`},{name:`سیستان و بلوچستان`,capital:`زاهدان`,areaCode:`54`},{name:`فارس`,capital:`شیراز`,areaCode:`71`},{name:`قزوین`,capital:`قزوین`,areaCode:`28`},{name:`قم`,capital:`قم`,areaCode:`25`},{name:`کردستان`,capital:`سنندج`,areaCode:`87`},{name:`کرمان`,capital:`کرمان`,areaCode:`34`},{name:`کرمانشاه`,capital:`کرمانشاه`,areaCode:`83`},{name:`کهگیلویه و بویراحمد`,capital:`یاسوج`,areaCode:`74`},{name:`گلستان`,capital:`گرگان`,areaCode:`17`},{name:`گیلان`,capital:`رشت`,areaCode:`13`},{name:`لرستان`,capital:`خرم‌آباد`,areaCode:`66`},{name:`مازندران`,capital:`ساری`,areaCode:`11`},{name:`مرکزی`,capital:`اراک`,areaCode:`86`},{name:`هرمزگان`,capital:`بندرعباس`,areaCode:`76`},{name:`همدان`,capital:`همدان`,areaCode:`81`},{name:`یزد`,capital:`یزد`,areaCode:`35`}],f={"آذربایجان شرقی":/* @__PURE__ */ `آبشاحمد.آچاچی.آذرشهر.آقکند.اسکو.اهر.ایلخچی.باسمنج.بخشایش.بستان‌آباد.بناب.بناب مرند.تبریز.ترک.ترکمانچای.تسوج.تیکمهداش.تیمورلو.جلفا.جوانقلعه.خاروانا.خامنه.خداجو.خسروشاه.خمارلو.خواجه.دریان.دوزدوزان.زرنق.زنوز.سراب.سردرود.سهند.سیس.سیهرود.شبستر.شربیان.شرفخانه.شندآباد.شهریار.صوفیان.عجبشیر.قرهآغاج.کشکسرای.کلوانق.کلیبر.کوزهکنان.گوگان.لیلان.مبارک آباد.مراغه.مرند.ملکان.ملککیان.ممقان.مهربان.میانه.نظرکهریزی.وایقان.ورزقان.هادی‌شهر.هریس.هشترود.هوراند.یامچی`.split(`.`),"آذربایجان غربی":/* @__PURE__ */ `آواجیق.ارومیه.اشنویه.ایواوغلی.باروق.بازرگان.بوکان.پلدشت.پیرانشهر.تازه‌شهر.تکاب.چهاربرج.خلیفان.خوی.دیزج دیز.ربط.زرآباد.سردشت.سرو.سلماس.سیلوانه.سیمینه.سیهچشمه.شاهیندژ.شوط.فیرورق.قرهضیاءالدین.قطور.قوشچی.کشاورز.گردکشانه.ماکو.محمدیار.محمودآباد.مرگنلر.مهاباد.میاندوآب.میرآباد.نازک علیا.نالوس.نقده.نوشینشهر`.split(`.`),اردبیل:[`آبیبیگلو`,`اردبیل`,`اسلام‌آباد قدیم`,`اصلاندوز`,`انگوت`,`بیلهسوار`,`پارس‌آباد`,`جعفرآباد`,`خلخال`,`رضی`,`سرعین`,`عنبران`,`قصابه`,`کلور`,`کوراییم`,`گرمی`,`گیوی`,`لاهرود`,`مرادلو`,`مشگینشهر`,`نمین`,`نیر`,`هشجین`,`هیر`],اصفهان:/* @__PURE__ */ `آران و بیدگل.ابریشم.ابوزیدآباد.اردستان.اژیه.اشترجان.اصغرآباد.اصفهان.افوس.انارک.بادرود.باغ بهادران.باغشاد.بافران.برزک.برفانبار.بوئین و میاندشت.بهارانشهر.بهارستان.پیربکران.تودشک.تیران.جندق.جوزدان.جوشقان قالی.جوشقان و کامو.چادگان.چرمهین.چمگردان.حبیب آباد برخوار.حسن‌آباد.حنا.خالدآباد.خمینی‌شهر.خوانسار.خور.خوراسگان.خورزوق.داران.دامنه.درچهپیاز.دستگرد.دولت‌آباد.دهاقان.دهق.دیزیچه.رزوه.رضوانشهر.زازران.زایندهرود.زرینشهر.زواره.زیار.زیباشهر.سده لنجان.سفیدشهر.سگزی.سمیرم.سین.شاپورآباد.شاهینشهر.شهر جدید مجلسی.شهرضا.طالخونچه.طرق.عسگران.علویجه.فرخی.فریدونشهر.فلاورجان.فولادشهر.قمصر.قهجاورستان.قهدریجان.کاشان.کرکوند.کلیشاد و سودرجان.کمشجه.کمه.کوشک.کوهپایه.کهریزسنگ.گرگاب.گز.گلپایگان.گلدشت.گلشن.گلشهر.گوگد.لای بید.مبارکه.محمدآباد.مشکات.منظریه.مهاباد.میمه.نائین.نجف‌آباد.نصرآباد.نطنز.نوش‌آباد.نیاسر.نیک‌آباد.ورزنه.ورنامخواست.وزوان.ونک.هرند.یزدانشهر نجف آباد`.split(`.`),البرز:[`آسارا`,`اشتهارد`,`تنکمان`,`چهارباغ`,`طالقان`,`فردیس`,`کرج`,`کمالشهر`,`کوهسار`,`گرمدره`,`گلسار`,`ماهدشت`,`محمدشهر`,`مشکیندشت`,`مهستان`,`نظرآباد`],ایلام:/* @__PURE__ */ `آبدانان.آسمان‌آباد.ارکواز.ایلام.ایوان.بدره.بلاوه تره سفلی.پهله.توحید.جعفرآباد.چشمه شیرین.چوار.دره‌شهر.دلگشا.دهلران.زرنه.سرابباغ.سرابله.شباب.صالح‌آباد.لومار.ماژین.مورموری.موسیان.مهر.مهران.میمه`.split(`.`),بوشهر:/* @__PURE__ */ `آباد.آبپخش.آبدان.امام حسن.انارستان.اهرم.بادوله.برازجان.بردخون.بردستان.بندر دیر.بندر دیلم.بندر ریگ.بندر سیراف.بندر کنگان.بندر گناوه.بندو.بنک.بوشکان.بوشهر.تنگ ارم.جم.چغادک.خارگ.خورموج.دالکی.دلوار.دوراهک.ریز.سعدآباد.شبانکاره.شنبه.عالی‌شهر.عسلویه.کاکی.کلمه.نخل تقی.وحدتیه`.split(`.`),تهران:/* @__PURE__ */ `آبسرد.آبعلی.احمدآباد مستوفی.ارجمند.اسلامشهر.اندیشه.باغستان.باقرشهر.بومهن.پاکدشت.پردیس.پرند.پیشوا.تهران.جلیل‌آباد.جوادآباد.چهاردانگه.حسن‌آباد.خاورشهر.دماوند.رباطکریم.رودهن.شاهدشهر.شریف‌آباد.شمشک.شهر ری.شهریار.صالحیه.صباشهر.صفادشت.فردوسیه.فرون‌آباد.فشم.فیروزکوه.قدس.قرچک.کرشته.کهریزک.کیلان.گلستان.لواسان.ملارد.نسیم‌شهر.نصیرشهر.وحیدیه.ورامین`.split(`.`),"چهارمحال و بختیاری":/* @__PURE__ */ `آلونی.اردل.باباحیدر.بروجن.بلداجی.بن.پردنجان.تلورد.جونقان.چالشتر.چلگرد.چلیچه.دستنا.دشتک.سامان.سرخون.سردشت.سفیددشت.سودجان.سورشجان.شلمزار.شهرکرد.صمصامی.طاقانک.فارسان.فرادنبه.فرخشهر.کاج.کیان.گندمان.گوجان.گهرو.لردگان.مالخلیفه.منج نسا.ناغان.نافچ.وردنجان.هارونی.هرچگان.هفشجان.یانچشمه`.split(`.`),"خراسان جنوبی":/* @__PURE__ */ `آرینشهر.آیسک.ارسک.اسدیه.اسفدن.اسلامیه.باغستان علیا.بشرویه.بیرجند.حاجی‌آباد.خضری دشتبیاض.خوسف.درح.دیهوک.زهان.سرایان.سربیشه.سهقلعه.شوسف.طبس.طبس مسینا.عشق‌آباد.فردوس.قائن.قهستان.گزیک.محمدشهر.مود.نهبندان.نیمبلوک`.split(`.`),"خراسان رضوی":/* @__PURE__ */ `احمدآباد.انابد.باجگیران.باخرز.بار.بایگ.بجستان.بردسکن.بیدخت.بینالود.تایباد.تربت جام.تربت حیدریه.جغتای.جنگل.چاپشلو.چکنه.چناران.خرو.خلیل‌آباد.خواف.داورزن.دررود.درگز.دولت‌آباد.رادکان.رباط سنگ.رشتخوار.رضویه.رودآب.ریوش.سبزوار.سرخس.سفیدسنگ.سلامی.سلطان‌آباد.سنگان.سیدآباد.شادمهر.شاندیز.ششتمد.شهرآباد.شهرزو.شهرکهنه.صالح‌آباد.طرقبه.عشق‌آباد.فرگ قلعه.فرهادگرد.فریمان.فیروزه.فیض‌آباد.قاسم‌آباد.قدمگاه.قلندرآباد.قوچان.کاخک.کاریز.کاشمر.کدکن.کلات.کندر.گلبهار.گلمکان.گناباد.لطف‌آباد.مزداوند.مشهد.مشهد ریزه.ملک‌آباد.نسر.نشتیفان.نصرآباد.نقاب.نوخندان.نیشابور.نیلشهر.همت‌آباد.یونسی`.split(`.`),"خراسان شمالی":[`آشخانه`,`آوا`,`اسفراین`,`ایور`,`بجنورد`,`پیشقلعه`,`تیتکانلو`,`جاجرم`,`چنارانشهر`,`حصار گرمخان`,`درق`,`راز`,`زیارت`,`سنخواست`,`شوقان`,`شیروان`,`صفی‌آباد`,`فاروج`,`فیروزه`,`قاضی`,`گرمه`,`لوجلی`],خوزستان:/* @__PURE__ */ `آبادان.آبژدان.آغاجاری.ابوحمیظه.اروندکنار.الوان.الهایی.امیدیه.اندیمشک.اهواز.ایذه.باغملک.بستان.بندر امام خمینی.بندر ماهشهر.بهبهان.بیدروبهمرکزی.ترکالکی.تشان.جایزان.جنتمکان.چغامیش.چم گلک.چمران.چویبده.حر ریاحی.حسینیه.حمیدیه.خرمشهر.دارخوین.دزآب.دزفول.دهدز.رامشیر.رامهرمز.رفیع.زهره.سالند.سردشت.سماله.سوسنگرد.سیاهمنصور.شادگان.شمس‌آباد.شوش.شوشتر.شهرک حمزه.شیبان.صالح شهر.صفی‌آباد.صیدون.فتح‌المبین.قلعه خواجه.قلعهتل.کوت سیدنعیم طالقانی.کوت عبدالله.گتوند.گوریه.لالی.مسجدسلیمان.مشراگه.مقاومت.ملاثانی.منصوریه.میانرود.میانکوه.میداود.مینوشهر.ویس.هفتکل.هندیجان.هویزه`.split(`.`),زنجان:[`آببر`,`ابهر`,`ارمغانخانه`,`چورزق`,`حلب`,`خرمدره`,`دندی`,`زرین‌آباد`,`زرینرود`,`زنجان`,`سجاس`,`سلطانیه`,`سهرورد`,`صایینقلعه`,`قیدار`,`کرسف`,`گرماب`,`ماهنشان`,`نیکپی`,`هیدج`],سمنان:[`آرادان`,`امیریه`,`ایوانکی`,`بسطام`,`بیارجمند`,`دامغان`,`درجزین`,`دیباج`,`رودیان`,`سرخه`,`سمنان`,`شاهرود`,`شهمیرزاد`,`کلاته خیج`,`کلاته رودبار`,`کهن‌آباد`,`گرمسار`,`مجن`,`مهدی‌شهر`,`میامی`],"سیستان و بلوچستان":/* @__PURE__ */ `آسپیچ محمدی.ادیمی.اسپکه.ایرانشهر.بریس.بزمان.بمپور.بنت.بنجار.پیشین.جالق.چابهار.خاش.دوستمحمد.راسک.رامشار.زابل.زاهدان.زرآباد.زهک.سراوان.سرباز.سوران.سیب.سیرکان.شهرک علیاکبر.فنوج.قصرقند.کنارک.گشت.گلمورتی.محمدآباد.مهرستان.میرجاوه.نصرت‌آباد.نگور.نوک‌آباد.نیکشهر.هیدوچ`.split(`.`),فارس:/* @__PURE__ */ `آباده.آباده طشک.ارد.اردکان.ارسنجان.استهبان.اسیر.اشکنان.افزر.اقلید.اوز.اهل.ایج.ایزدخواست.باب انار.بابامنیر.بایگان.بنارویه.بوانات.بهمن.بیرم.بیضا.جنتشهر.جویم.جهرم.حاجی‌آباد.حسامی.حسن‌آباد.خانه زنیان.خانیمن.خاوران.خرامه.خشت.خنج.خور.خوزی.خومهزار.داراب.داریان.دبیران.دژکرد.دوبرجی.دوزه.دهرم.رامجرد.رونیز.زاهدشهر.زرقان.سده.سروستان.سعادتشهر.سلطانشهر.سورمق.سیدان.ششده.شهر جدید صدرا.شهرپیر.شهرک امام.شیراز.صغاد.صفاشهر.علامرودشت.عمادشهر.فاروق.فتح آباد.فدامی.فراشبند.فسا.فیروزآباد.فیشور.قائمیه.قادرآباد.قرهبلاغ.قطب‌آباد.قطرویه.قیر.کازرون.کامفیروز.کرهای.کنارتخته.کوار.کوپن.کوهنجان.گراش.گلهدار.گویم.لار.لامرد.لپوئی.لطیفی.مادرسلیمان.مرودشت.مزایجان.مشکان.مصیری.مهر.میانشهر.میمند.نوبندگان.نوجین.نودان.نورآباد.نیریز.والاشهر.وراوی.هماشهر`.split(`.`),قزوین:[`آبگرم`,`آبیک`,`آوج`,`ارداق`,`اسفرورین`,`اقبالیه`,`الوند`,`بوئینزهرا`,`بیدستان`,`تاکستان`,`خاکعلی`,`خرمدشت`,`دانسفهان`,`رازمیان`,`سگزآباد`,`سیردان`,`شال`,`ضیاءآباد`,`قزوین`,`کوهین`,`محمدیه`,`محمودآباد نمونه`,`معلمکلایه`,`نرجه`],قم:[`جعفریه`,`دستجرد`,`سلفچگان`,`قاهان`,`قم`,`قنوات`,`کهک`],کردستان:/* @__PURE__ */ `آرمرده.اورامان.بابارشانی.بانه.برده رشه.بلبان‌آباد.بویین سفلی.بیجار.پیرتاج.توپآغاج.چناره.حسن‌آباد یاسوکند.دزج.دلبران.دهگلان.دیواندره.زرینه.سروآباد.سریش‌آباد.سقز.سنندج.شویشه.صاحب.قروه.کامیاران.کانیدینار.کانیسور.مریوان.موچش`.split(`.`),کرمان:/* @__PURE__ */ `اختیارآباد.ارزوئیه.امینشهر.انار.اندوهجرد.باغین.بافت.بردسیر.بروات.بزنجان.بلورد.بلوک.بم.بهرمان.پاریز.جبالبارز.جوپار.جوزم.جیرفت.چترود.خاتون‌آباد.خانوک.خرسند.خواجو شهر.درب بهشت.دشتکار.دوساری.دهج.دهستان بزنجان.رابر.راور.راین.رفسنجان.ریحانشهر.زرند.زنگی‌آباد.زهکلوت.زیدآباد.سیرجان.سیریز.شهداد.شهربابک.صفائیه.عنبرآباد.فاریاب.فهرج.قلعهگنج.کاظم‌آباد.کرمان.کشکوئیه.کوهبنان.کهنوج.کیانشهر.گلباف.گلزار.لاله زار.ماهان.محمدآباد.محمدآباد گنبکی.محی‌آباد.مردهک.مس سرچشمه.منوجان.نجفشهر.نرماشیر.نظامشهر.نگار.نودژ.هجدک.هماشهر.هنزا.یزدانشهر`.split(`.`),کرمانشاه:/* @__PURE__ */ `ازگله.اسلام‌آباد غرب.بانهوره.باینگان.بیستون.پاوه.تازه‌آباد.جوانرود.حمیل.روانسر.ریژاو.سرپل ذهاب.سرمست.سطر.سنقر.سومار.شروینه.صحنه.قصر شیرین.قلعه.کرمانشاه.کرند غرب.کنگاور.کوزران.گودین.گهواره.گیلانغرب.ماهیدشت.میانراهان.نودشه.نوسود.هرسین.هلشی`.split(`.`),"کهگیلویه و بویراحمد":[`باشت`,`پاتاوه`,`چرام`,`چیتاب`,`دوگنبدان`,`دهدشت`,`دیشموک`,`سوق`,`سیسخت`,`قلعه رئیسی`,`گراب سفلی`,`لنده`,`لیکک`,`مادوان علیا`,`مارگون`,`محله چینیها`,`یاسوج`],گلستان:/* @__PURE__ */ `آزادشهر.آققلا.انبارآلوم.اینچهبرون.بندر ترکمن.بندر گز.تاتار علیا.خانببین.دلند.رامیان.سرخنکلاته.سنگدوین.سیمینشهر.علی‌آباد کتول.فاضل‌آباد.فراغی.قرق.کردکوی.کلاله.گالیکش.گرگان.گمیشان.گنبد کاووس.مراوهتپه.مزرعه.مینودشت.نگینشهر.نوده خاندوز.نوکنده`.split(`.`),گیلان:/* @__PURE__ */ `آستارا.آستانه اشرفیه.احمدسرگوراب.اسالم.اطاقور.املش.بازارجمعه.برهسر.بندر انزلی.بندر کیاشهر.پرهسر.توتکابن.جیرنده.چابکسر.چاف و چمخاله.چوبر.حویق.خشکبیجار.خمام.دیلمان.رانکوه.رحیم‌آباد.رستم‌آباد.رشت.رضوانشهر.رودبار.رودبنه.رودسر.سنگر.سیاهکل.شفت.شلمان.صومعهسرا.فومن.کلاچای.کوچصفهان.کومله.گوراب زرمیخ.لاهیجان.لشت نشا.لنگرود.لوشان.لولمان.لوندویل.لیسار.ماسال.ماسوله.ماکلوان.مرجغل.منجیل.واجارگاه.هشتپر`.split(`.`),لرستان:[`ازنا`,`اشترینان`,`الشتر`,`الیگودرز`,`بروجرد`,`بیرانشهر`,`پل دختر`,`چالانچولان`,`چقابل`,`خرم‌آباد`,`درب گنبد`,`دورود`,`زاغه`,`سپیددشت`,`سرابدوره`,`شول‌آباد`,`فیروزآباد`,`کونانی`,`کوهدشت`,`گراب لکستان`,`معمولان`,`مومن‌آباد`,`نورآباد`,`ویسیان`,`هفتچشمه`],مازندران:/* @__PURE__ */ `آلاشت.آمل.ارطه.اکند.امامزاده عبدالله.امیرکلا.ایزدشهر.بابل.بابلسر.بلده.بهشهر.بهنمیر.پایین هولار.پل سفید.پول.تنکابن.جویبار.چالوس.چمستان.خرم‌آباد.خلیلشهر.خوشرودپی.دابودشت.رامسر.رستمکلا.رویان.رینه.زرگرمحله.زیرآب.ساری.سرخرود.سلمانشهر.سورک.شیرگاه.شیرود.طبقده.عباس‌آباد.فرح‌آباد.فریدونکنار.فریم.قائمشهر.کتالم و ساداتشهر.کجور.کلارآباد.کلاردشت.کلهبست.کوهیخیل.کیاسر.کیاکلا.گتاب.گزنک.گلوگاه.محمودآباد.مرزن‌آباد.مرزیکلا.نشتارود.نکا.نمکآبرود.نور.نوشهر.هچیرود`.split(`.`),مرکزی:/* @__PURE__ */ `آستانه.آشتیان.آوه.اراک.پرندک.تفرش.توره.جاورسیان.خشکرود.خمین.خنجین.خنداب.داوودآباد.دلیجان.رازقان.زاویه.ساروق.ساوه.سنجان.شازند.شهباز.شهر جدید امیرکبیر.غرق‌آباد.فرمهین.قورچیباشی.کارچان.کرهرود.کمیجان.مأمونیه.محلات.مهاجران.میلاجرد.نراق.نوبران.نیمور.هندودر`.split(`.`),هرمزگان:/* @__PURE__ */ `ابوموسی.بستک.بندر چارک.بندر خمیر.بندر کنگ.بندر لافت.بندر لنگه.بندرعباس.بیکا.پارسیان.تازیان پایین.تخت.تنب بزرگ.تیرور.جاسک.جناح.حاجی‌آباد.درگهان.دشتی.دهبارز.رویدر.زیارتعلی.سردشت.سرگز احمدی.سندرک.سوزا.سیریک.طبل.فارغان.فین.قشم.قلعه قاضی.کوخردهرنگ.کوهستک.کوهیج.کیش.گروک.گوهران.لمزان.میناب.هرمز.هشتبندی`.split(`.`),همدان:/* @__PURE__ */ `آجین.ازندریان.اسدآباد.برزول.بهار.تویسرکان.جورقان.جوکار.داقداق‌آباد.دمق.دهستان سلگی.رزن.زنگنه.سامن.سرکان.شیرینسو.صالح‌آباد.فامنین.فرسفج.فیروزان.قروه درجزین.قهاوند.کبودرآهنگ.گلتپه.گیان.لالجین.مریانج.ملایر.مهاجران.نهاوند.همدان`.split(`.`),یزد:[`ابرکوه`,`احمدآباد`,`اردکان`,`اشکذر`,`بافق`,`بخ`,`بفروییه`,`بهاباد`,`تفت`,`حمیدیا`,`خضرآباد`,`رضوانشهر`,`زارچ`,`شاهدیه`,`عقدا`,`مروست`,`مهردشت`,`مهریز`,`میبد`,`ندوشن`,`نیر`,`هرات`,`یزد`]};function p(e){return e&&f[e]||[]}const m={province:null,city:null,street:``,plaque:``,unit:``,postalCode:``},h=e=>u(e,{digits:`latin`}).toLowerCase();var g=class extends s{constructor(){super(...arguments),this.selected=null,this.query=``,this.list=null,this.filtered=[],this.typing=!1,this.isOpen=!1,this.active=-1,this.rendered=!1,this.valueSet=!1,this.key=n(`kashi-combo`),this.defaultLabel=null,this.defaultPlaceholder=``,this.onOutside=e=>{this.contains(e.target)||this.close()}}connectedCallback(){a(()=>{if(this.isConnected){if(!this.rendered){if(this.list===null&&(this.list=this.readOptions()),Object.prototype.hasOwnProperty.call(this,`value`)){let e=this.value;delete this.value,this.value=e??``}else if(!this.valueSet){let e=this.getAttribute(`value`);this.selected=e?this.find(e):null,this.query=this.selected?.label??``}}this.render()}})}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=n??``:this.render())}get options(){return this.list??[]}set options(e){this.list=[...e],this.selected&&=this.find(this.selected.value),this.rendered&&this.sync()}get value(){return this.selected?.value??``}set value(e){this.valueSet=!0,this.selected=e?this.find(e):null,this.query=this.selected?.label??``,this.typing=!1,this.rendered&&this.sync()}get selectedOption(){return this.selected}focus(e){this.input?.focus(e)}readOptions(){let e=[];for(let t of[...this.querySelectorAll(`:scope > option, :scope > optgroup > option`)]){let n=t.parentElement?.tagName===`OPTGROUP`?t.parentElement.getAttribute(`label`)??void 0:void 0;e.push({value:t.value,label:t.textContent?.trim()??t.value,description:t.dataset.description,keywords:t.dataset.keywords?.split(/[,،]\s*/),disabled:t.disabled,group:n})}for(let e of[...this.querySelectorAll(`:scope > option, :scope > optgroup`)])e.remove();return e}source(e){return this.options}accepts(e,t){let n=h(t.trim());return!n||[e.label,e.description??``,...e.keywords??[]].some(e=>h(e).includes(n))}find(e){return this.source(``).find(t=>t.value===e)??null}detail(){return{value:this.value,option:this.selected}}render(){let e=this.key,n=this.getAttribute(`aria-label`),r=this.hasAttribute(`label`)?this.getAttribute(`label`):n?null:this.defaultLabel,a=this.hasAttribute(`required`),s=this.hasAttribute(`disabled`),c=`${e}-list`,l=`<div class="k-combobox"><div class="k-input"${s?` data-state="disabled"`:``}><input id="${e}" class="k-input__control" type="text" role="combobox" aria-autocomplete="list" aria-expanded="false" aria-controls="${c}" autocomplete="off" placeholder="${o(this.getAttribute(`placeholder`)??this.defaultPlaceholder)}"${a?` required`:``}${s?` disabled`:``}${!r&&n?` aria-label="${o(n)}"`:``}><button type="button" tabindex="-1" class="k-input__action k-combobox__toggle" aria-label="نمایش گزینه‌ها"${s?` disabled`:``}><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 8 4 4 4-4"/></svg></button></div><ul id="${c}" role="listbox" class="k-listbox" hidden style="inset-block-start: calc(100% + 6px)"${r?` aria-label="${o(r)}"`:` aria-labelledby="${e}"`}></ul><span class="k-sr-only" aria-live="polite"></span></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,t({id:e,label:r,required:a,control:l})),this.input=this.querySelector(`input.k-input__control`),this.listbox=this.querySelector(`.k-listbox`),this.live=this.querySelector(`.k-combobox > .k-sr-only`),this.isOpen=!1,this.input.addEventListener(`input`,()=>{this.query=this.input.value,this.typing=!0,this.active=-1,this.open(!1),i(this,`kashi-input`,{query:this.query})}),this.input.addEventListener(`keydown`,e=>this.onKey(e)),this.input.addEventListener(`click`,()=>!this.isOpen&&this.open()),this.input.addEventListener(`blur`,e=>{this.contains(e.relatedTarget)||this.close()}),this.querySelector(`.k-combobox__toggle`).addEventListener(`click`,()=>{this.isOpen?this.close():(this.typing=!1,this.open(),this.input.focus())}),this.listbox.addEventListener(`pointerdown`,e=>e.preventDefault()),this.listbox.addEventListener(`click`,e=>{let t=e.target.closest(`[role="option"]`);t&&t.getAttribute(`aria-disabled`)!==`true`&&this.commit(this.filtered[Number(t.dataset.i)])}),this.listbox.addEventListener(`pointermove`,e=>{let t=e.target.closest(`[role="option"]`);t&&t.getAttribute(`aria-disabled`)!==`true`&&Number(t.dataset.i)!==this.active&&this.setActive(Number(t.dataset.i))}),this.rendered=!0,this.sync()}sync(){!this.typing&&this.input.value!==this.query&&(this.input.value=this.query),r(this.querySelector(`:scope > .k-field`),this.input,this.key,this.getAttribute(`error`),this.getAttribute(`hint`)),this.syncHidden(),this.isOpen&&this.renderList()}syncHidden(){c(this,this.getAttribute(`name`),this.value)}enabled(){return this.filtered.map((e,t)=>e.disabled?-1:t).filter(e=>e>=0)}open(e=!0,t=`selected`){if(!this.hasAttribute(`disabled`)){if(this.isOpen=!0,this.input.setAttribute(`aria-expanded`,`true`),this.listbox.hidden=!1,this.toggleAttribute(`data-open`,!0),this.querySelector(`.k-combobox`).setAttribute(`data-open`,``),this.filter(),e){let e=this.enabled(),n=this.filtered.findIndex(e=>e.value===this.selected?.value);this.active=t===`last`?e.at(-1)??-1:t===`first`||n<0?e[0]??-1:n}this.renderList(),document.addEventListener(`pointerdown`,this.onOutside)}}close(){this.rendered&&(this.isOpen=!1,this.input.setAttribute(`aria-expanded`,`false`),this.input.removeAttribute(`aria-activedescendant`),this.listbox.hidden=!0,this.querySelector(`.k-combobox`).removeAttribute(`data-open`),this.live.textContent=``,document.removeEventListener(`pointerdown`,this.onOutside),this.typing&&(this.typing=!1,this.query=this.selected?.label??``,this.input.value=this.query))}filter(){let e=this.source(this.typing?this.query:``);this.filtered=this.typing?e.filter(e=>this.accepts(e,this.query)):e}renderList(){let e=this.typing?h(this.query.trim()):``,t=t=>{let n=e?h(t).indexOf(e):-1;return n<0?o(t):`${o(t.slice(0,n))}<mark>${o(t.slice(n,n+e.length))}</mark>${o(t.slice(n+e.length))}`},n=`${this.key}-list`,r,i=this.filtered.slice(0,300).map((e,i)=>{let a=e.group&&e.group!==r?`<li role="presentation" class="k-listbox__group">${o(e.group)}</li>`:``;r=e.group;let s=e.value===this.selected?.value;return`${a}<li id="${n}-${i}" data-i="${i}" role="option" aria-selected="${s}"${e.disabled?` aria-disabled="true"`:``}${i===this.active?` data-active`:``} class="k-option"><span class="k-option__body"><span>${t(e.label)}</span>${e.description?`<span class="k-option__desc">${o(e.description)}</span>`:``}</span>${s?`<span class="k-option__check"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m5 10.5 3.2 3L15 7"/></svg></span>`:``}</li>`});this.filtered.length||i.push(`<li class="k-listbox__empty" role="presentation">${o(this.getAttribute(`empty-message`)??`نتیجه‌ای پیدا نشد.`)}</li>`),this.filtered.length>300&&i.push(`<li class="k-listbox__empty" role="presentation">${l(this.filtered.length-300)} گزینهٔ دیگر؛ برای پیدا کردن تایپ کنید.</li>`),this.listbox.innerHTML=i.join(``),this.live.textContent=this.typing?`${l(this.filtered.length)} نتیجه`:``,this.setActive(this.active)}setActive(e){this.active=e,this.listbox.querySelector(`[data-active]`)?.removeAttribute(`data-active`);let t=e>=0?this.listbox.querySelector(`[data-i="${e}"]`):null;t?(t.setAttribute(`data-active`,``),t.scrollIntoView?.({block:`nearest`}),this.input.setAttribute(`aria-activedescendant`,t.id)):this.input.removeAttribute(`aria-activedescendant`)}move(e){let t=this.enabled().filter(e=>e<300);if(!t.length)return;let n=t.indexOf(this.active);this.setActive(t[(n+e+t.length)%t.length])}onKey(e){if(e.key===`ArrowDown`)e.preventDefault(),this.isOpen?this.move(1):this.open(!0,e.altKey?`selected`:`first`);else if(e.key===`ArrowUp`)e.preventDefault(),this.isOpen?this.move(-1):this.open(!0,`last`);else if(e.key===`Enter`&&this.isOpen&&this.active>=0)e.preventDefault(),this.commit(this.filtered[this.active]);else if(e.key===`Escape`)this.isOpen?(e.preventDefault(),this.close()):this.input.value&&(e.preventDefault(),this.commit(null));else if((e.key===`Home`||e.key===`End`)&&this.isOpen){e.preventDefault();let t=this.enabled();this.setActive((e.key===`Home`?t[0]:t.at(-1))??-1)}}commit(e){let t=(e?.value??null)!==(this.selected?.value??null);this.selected=e,this.query=e?.label??``,this.typing=!1,this.input.value=this.query,this.close(),this.sync(),t&&i(this,`kashi-change`,this.detail())}};g.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`required`,`disabled`,`name`,`value`,`empty-message`,`aria-label`];var _=class extends g{constructor(){super(...arguments),this.defaultLabel=`استان`,this.defaultPlaceholder=`جستجوی استان یا شهر`}source(){let e=this.getAttribute(`show-capital`)!==`false`;return d.map(t=>({value:t.name,label:t.name,description:e?`مرکز: ${t.capital}`:void 0,keywords:[t.capital]}))}detail(){return{value:this.value,province:d.find(e=>e.name===this.value)??null}}};_.observedAttributes=[...g.observedAttributes,`show-capital`];const v=e=>h(e).replace(/[\s‌]/g,``);var y=class extends g{constructor(){super(...arguments),this.defaultLabel=`شهر`,this.custom=null}get province(){return this.getAttribute(`province`)||null}set province(e){e?this.setAttribute(`province`,e):this.removeAttribute(`province`)}get value(){return this.selected?this.selected.value.split(`|`)[1]:``}set value(e){this.valueSet=!0,this.custom=null;let t=this.source(``),n=this.province,r=e?t.find(t=>t.label===e&&(!n||t.value.startsWith(`${n}|`)))??null:null;e&&!r&&(this.custom=e,r={value:`custom|${e}`,label:e,description:`خارج از فهرست`}),this.selected=r,this.query=r?.label??``,this.isConnected&&this.querySelector(`.k-combobox`)&&this.sync()}find(e){return this.value=e,this.selected}attributeChangedCallback(e,t,n){if(e!==`province`)return super.attributeChangedCallback(e,t,n);if(t!==n){if(this.selected){let e=this.value;!n||!p(n).includes(e)?(this.selected=null,this.query=``,this.custom=null):this.selected={value:`${n}|${e}`,label:e}}this.querySelector(`.k-combobox`)&&(this.input.placeholder=this.getAttribute(`placeholder`)??this.placeholderText(),this.input.value=this.query,this.sync())}}connectedCallback(){this.defaultPlaceholder=this.placeholderText(),super.connectedCallback()}placeholderText(){return this.province?`جستجوی شهر`:`نام شهر، مثلاً کاشان`}source(e){let t=this.province,n=t?p(t).map(e=>({value:`${t}|${e}`,label:e})):Object.entries(f).flatMap(([e,t])=>t.map(t=>({value:`${e}|${t}`,label:t,description:e})));this.custom&&n.unshift({value:`custom|${this.custom}`,label:this.custom,description:`خارج از فهرست`});let r=e.trim();return this.getAttribute(`allow-custom`)!==`false`&&r&&r!==this.custom&&!n.some(e=>v(e.label)===v(r))&&n.push({value:`custom|${r}`,label:r,description:`شهر دیگر؛ همین نام ثبت شود`}),n}accepts(e,t){return e.value.startsWith(`custom|`)||[e.label,e.description??``].some(e=>v(e).includes(v(t)))}commit(e){this.custom=e?.value.startsWith(`custom|`)?e.label:null,super.commit(e)}detail(){let[e]=this.selected?this.selected.value.split(`|`):[null];return{value:this.value,province:e===`custom`?null:e}}};y.observedAttributes=[...g.observedAttributes,`province`,`allow-custom`],e(`kashi-combobox`,g,`block`),e(`kashi-province-select`,_,`block`),e(`kashi-city-select`,y,`block`);export{y as KashiCitySelect,g as KashiCombobox,_ as KashiProvinceSelect,p as n,d as r,h as searchText,m as t};
@@ -1 +1 @@
1
- import{a as e,c as t,d as n,i as r,l as i,o as a,s as o,t as s}from"./base-Cmq7zeIG.js";import{i as c,n as l,r as u,t as d}from"./digits-DE1YGT94.js";import{n as f}from"./text-D1U32D6K.js";function p(e,t,n){if(e.querySelectorAll(`:scope > input[type=hidden][data-kashi-value]`).forEach(e=>e.remove()),t)for(let r of n){let n=document.createElement(`input`);n.type=`hidden`,n.name=t,n.value=r,n.dataset.kashiValue=``,e.append(n)}}var m=class extends s{constructor(){super(...arguments),this.tags=[],this.localError=null,this.rendered=!1,this.valueSet=!1,this.key=n(`kashi-tags`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.tags=this.parse(this.getAttribute(`value`))),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=this.parse(n):this.render())}parse(e){return(e??``).split(/[,،]/).map(e=>e.trim()).filter(Boolean)}get value(){return[...this.tags]}set value(e){this.valueSet=!0,this.tags=Array.isArray(e)?[...e]:this.parse(e),this.rendered&&this.paint()}focus(e){this.input?.focus(e)}render(){let e=this.key,n=this.getAttribute(`aria-label`),r=this.hasAttribute(`label`)?this.getAttribute(`label`):n?null:`برچسب‌ها`,i=`<div class="k-tag-input"><input id="${e}" class="k-tag-input__control"${this.hasAttribute(`disabled`)?` disabled`:``}${!r&&n?` aria-label="${o(n)}"`:``}></div><span class="k-sr-only" aria-live="polite"></span>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,t({id:e,label:r,control:i})),this.input=this.querySelector(`.k-tag-input__control`),this.querySelector(`.k-tag-input`).addEventListener(`click`,e=>{let t=e.target.closest(`.k-badge__remove`);t?this.removeAt(Number(t.dataset.i)):this.input.focus()}),this.input.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===`,`||e.key===`،`)&&this.input.value.trim()?(e.preventDefault(),this.add([this.input.value])):e.key===`Backspace`&&!this.input.value&&this.tags.length&&this.removeAt(this.tags.length-1)}),this.input.addEventListener(`input`,()=>{this.localError=null;let e=this.input.value.split(/[,،\n\t]/);if(e.length>1){let t=e.pop()??``;this.add(e),t&&!this.localError&&(this.input.value=t)}else this.paintMessages()}),this.input.addEventListener(`blur`,()=>this.input.value.trim()&&this.add([this.input.value])),this.rendered=!0,this.paint()}add(e){let t=Number(this.getAttribute(`max`))||1/0,n=r(this,`allow-duplicates`),i=[...this.tags],a=``;for(let r of e){let e=f(r).trim();if(!e)continue;let o=i.length>=t?`حداکثر ${c(t)} مورد`:!n&&i.includes(e)?`این مورد قبلاً اضافه شده است.`:this.validate?.(e);if(o){this.localError=o,this.commit(i,a),this.input.value=e;return}i=[...i,e],a=`${e} اضافه شد`}this.localError=null,this.input.value=``,this.commit(i,a)}removeAt(e){let t=this.tags[e];this.commit(this.tags.filter((t,n)=>n!==e),`${t} حذف شد`),this.input.focus()}commit(e,t){let n=e.join(`\0`)!==this.tags.join(`\0`);this.tags=e,this.paint(),t&&(this.querySelector(`.k-field > .k-sr-only`).textContent=t),n&&a(this,`kashi-change`,{value:[...e]})}paint(){this.querySelector(`.k-tag-input`).querySelectorAll(`.k-badge`).forEach(e=>e.remove());let e=this.getAttribute(`tone`)??`brand`,t=this.hasAttribute(`disabled`),n=this.tags.map((n,r)=>`<span class="k-badge${e===`neutral`?``:` k-badge--${o(e)}`}${t?``:` k-badge--removable`}">${o(n)}${t?``:`<button type="button" class="k-badge__remove" data-i="${r}" aria-label="حذف ${o(n)}"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="m6 6 8 8M14 6l-8 8"/></svg></button>`}</span>`).join(``);this.input.insertAdjacentHTML(`beforebegin`,n),this.input.placeholder=this.tags.length?``:this.getAttribute(`placeholder`)??``,this.paintMessages(),p(this,this.getAttribute(`name`),this.tags)}paintMessages(){let e=this.getAttribute(`error`)||this.localError;this.querySelector(`.k-tag-input`).toggleAttribute(`data-invalid`,!!e),i(this.querySelector(`:scope > .k-field`),this.input,this.key,e,this.getAttribute(`hint`))}};m.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`disabled`,`name`,`value`,`max`,`tone`,`allow-duplicates`,`aria-label`];var h=class extends s{constructor(){super(...arguments),this.current=null,this.rendered=!1,this.valueSet=!1,this.key=n(`kashi-num`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.current=this.num(this.getAttribute(`value`))??null),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=n===null||n===``?null:Number(n):this.render())}get value(){return this.current}set value(e){this.valueSet=!0,this.current=e==null||Number.isNaN(Number(e))?null:Number(e),this.rendered&&this.paint()}focus(e){this.input?.focus(e)}num(e){return e===null||e===``||Number.isNaN(Number(e))?void 0:Number(e)}get min(){return this.num(this.getAttribute(`min`))}get max(){return this.num(this.getAttribute(`max`))}clamp(e){return Math.min(this.max??1/0,Math.max(this.min??-1/0,e))}show(e){if(e===null)return``;let t=this.hasAttribute(`thousands`)?d(e,{digits:`latin`}):String(e);return this.getAttribute(`digits`)===`latin`?t:c(t).replace(/,/g,`٬`)}render(){let e=this.key,n=this.getAttribute(`aria-label`),r=this.hasAttribute(`label`)?this.getAttribute(`label`):n?null:`تعداد`,i=this.hasAttribute(`disabled`),a=this.getAttribute(`unit`),s=`<div class="k-number"><div class="k-input"${i?` data-state="disabled"`:``}><button type="button" class="k-number__step" data-step="-1" tabindex="-1" aria-label="کاهش"${i?` disabled`:``}><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M5 10h10"/></svg></button><input id="${e}" class="k-input__control" type="text" inputmode="decimal" role="spinbutton" dir="ltr"${i?` disabled`:``}${!r&&n?` aria-label="${o(n)}"`:``}>${a?`<span class="k-input__addon">${o(a)}</span>`:``}<button type="button" class="k-number__step" data-step="1" tabindex="-1" aria-label="افزایش"${i?` disabled`:``}><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M10 5v10M5 10h10"/></svg></button></div></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,t({id:e,label:r,control:s})),this.input=this.querySelector(`input.k-input__control`),this.querySelectorAll(`.k-number__step`).forEach(e=>e.addEventListener(`click`,()=>this.bump(Number(e.dataset.step)))),this.input.addEventListener(`input`,()=>{let e=this.input.value,t=l(e);this.set(t?(/^\s*[-−]/.test(e)?-1:1)*Number(t):null,!1)}),this.input.addEventListener(`blur`,()=>{this.current!==null&&this.current!==this.clamp(this.current)?this.set(this.clamp(this.current)):this.paint()}),this.input.addEventListener(`keydown`,e=>{let t={ArrowUp:()=>this.bump(1),ArrowDown:()=>this.bump(-1),PageUp:()=>this.bump(10),PageDown:()=>this.bump(-10),Home:()=>this.min!==void 0&&this.set(this.min),End:()=>this.max!==void 0&&this.set(this.max)};t[e.key]&&(e.preventDefault(),t[e.key]())}),this.rendered=!0,this.paint()}bump(e){let t=this.num(this.getAttribute(`step`))??1;this.set(this.clamp((this.current??this.min??0)+e*t))}set(e,t=!0){let n=e!==this.current;this.current=e,t?this.paint():this.paintState(),n&&a(this,`kashi-change`,{value:e})}paint(){let e=this.show(this.current);this.input.value!==e&&(this.input.value=e),this.paintState()}paintState(){let e=this.input,t=this.current;for(let[n,r]of[[`aria-valuenow`,t],[`aria-valuemin`,this.min],[`aria-valuemax`,this.max]])r==null?e.removeAttribute(n):e.setAttribute(n,String(r));t===null?e.removeAttribute(`aria-valuetext`):e.setAttribute(`aria-valuetext`,this.show(t));let n=this.hasAttribute(`disabled`),[r,a]=this.querySelectorAll(`.k-number__step`);r.disabled=n||this.min!==void 0&&(t??0)<=this.min,a.disabled=n||this.max!==void 0&&(t??0)>=this.max,i(this.querySelector(`:scope > .k-field`),e,this.key,this.getAttribute(`error`),this.getAttribute(`hint`)),p(this,this.getAttribute(`name`),[t===null?``:String(t)])}};h.observedAttributes=[`label`,`hint`,`error`,`value`,`min`,`max`,`step`,`thousands`,`digits`,`unit`,`disabled`,`name`,`aria-label`];const g=`<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M12 2.8l2.8 5.9 6.4.8-4.7 4.4 1.2 6.3L12 17.1l-5.7 3.1 1.2-6.3L2.8 9.5l6.4-.8z"/><path class="k-rating__half" fill="none" d="M12 2.8v14.3l-5.7 3.1 1.2-6.3L2.8 9.5l6.4-.8z"/></svg>`,_=e=>c(String(e)).replace(`.`,`٫`);var v=class extends s{constructor(){super(...arguments),this.current=0,this.valueSet=!1,this.key=n(`kashi-rate`)}connectedCallback(){this.valueSet||(this.current=Number(this.getAttribute(`value`))||0),this.render()}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&(e===`value`&&(this.current=Number(n)||0),this.render())}get value(){return this.current}set value(e){this.valueSet=!0,this.current=Number(e)||0,this.isConnected&&this.render()}render(){let e=Number(this.getAttribute(`max`))||5,t=this.getAttribute(`label`)??`امتیاز`,n=this.getAttribute(`size`),r=`k-rating${n===`sm`||n===`lg`?` k-rating--${n}`:``}`,i=this.current,s=Array.from({length:e},(e,t)=>t+1),c=this.hasAttribute(`show-value`)?`<span class="k-rating__value" aria-hidden="true">${_(i)}</span>`:``;if(this.hasAttribute(`readonly`)){this.innerHTML=`<span class="${r}" data-readonly="" role="img" aria-label="${o(`${t}: ${_(i)} از ${_(e)}`)}">${s.map(e=>`<span class="k-rating__star"${e<=Math.floor(i)?` data-filled=""`:``}${e===Math.ceil(i)&&i%1>=.25?` data-half=""`:``}>${g}</span>`).join(``)}${c}</span>`;return}let l=this.getAttribute(`name`)??this.key,u=this.hasAttribute(`disabled`);this.innerHTML=`<fieldset class="${r}"><legend class="k-sr-only">${o(t)}</legend>${s.map(t=>`<label class="k-rating__star"${t<=i?` data-filled=""`:``}><input type="radio" class="k-sr-only" name="${o(l)}" value="${t}"${i===t?` checked`:``}${u?` disabled`:``} aria-label="${_(t)} از ${_(e)}">${g}</label>`).join(``)}${c}</fieldset>`;let d=this.querySelector(`fieldset`),f=e=>d.querySelectorAll(`.k-rating__star`).forEach((t,n)=>t.toggleAttribute(`data-filled`,n+1<=e));d.addEventListener(`change`,e=>{this.current=Number(e.target.value),f(this.current),a(this,`kashi-change`,{value:this.current})}),d.addEventListener(`pointerover`,e=>{let t=e.target.closest(`.k-rating__star`);t&&!u&&f([...d.querySelectorAll(`.k-rating__star`)].indexOf(t)+1)}),d.addEventListener(`pointerleave`,()=>f(this.current))}};v.observedAttributes=[`value`,`max`,`readonly`,`show-value`,`size`,`label`,`name`,`disabled`];function y(e,t,n=1){let r=[1],i=Math.max(2,e-n),a=Math.min(t-1,e+n);i>2&&r.push(i===3?2:null);for(let e=i;e<=a;e++)r.push(e);return a<t-1&&r.push(a===t-2?t-1:null),t>1&&r.push(t),r}const b=e=>`<svg data-k-mirror="" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${e}"/></svg>`;var x=class extends s{connectedCallback(){this.render()}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&this.render()}get page(){return Math.max(1,Number(this.getAttribute(`page`))||1)}set page(e){this.setAttribute(`page`,String(e))}get total(){return Math.max(1,Number(this.getAttribute(`total`))||1)}render(){let e=Math.min(this.page,this.total),t=this.total,n=e=>this.getAttribute(`digits`)===`latin`?String(e):c(e),r=this.getAttribute(`href`),i=this.contains(document.activeElement)?document.activeElement.dataset.to:null,s=(e,t,n,{current:i=!1,disabled:a=!1,aria:s=``}={})=>r&&!a?`<a class="${n}" href="${o(r.replace(`{page}`,String(e)))}" data-to="${e}"${i?` aria-current="page"`:``}${s?` aria-label="${o(s)}"`:``}>${t}</a>`:`<button type="button" class="${n}" data-to="${e}"${a?` disabled`:``}${i?` aria-current="page"`:``}${s?` aria-label="${o(s)}"`:``}>${t}</button>`,l=this.getAttribute(`summary`);this.innerHTML=`<nav class="k-pagination" aria-label="${o(this.getAttribute(`label`)??`صفحه‌بندی`)}">${s(e-1,`${b(`m12 5-5 5 5 5`)}قبلی`,`k-btn k-btn--secondary k-btn--sm`,{disabled:e<=1})}${l?`<span class="k-pagination__summary">${o(l)}</span>`:``}<ul class="k-pagination__pages" role="list">${y(e,t,Number(this.getAttribute(`siblings`)??1)).map(t=>`<li>${t===null?`<span class="k-pagination__ellipsis" aria-hidden="true">…</span>`:s(t,n(t),`k-pagination__page`,{current:t===e,aria:`صفحهٔ ${n(t)}`})}</li>`).join(``)}</ul>${s(e+1,`بعدی${b(`m8 5 5 5-5 5`)}`,`k-btn k-btn--secondary k-btn--sm`,{disabled:e>=t})}</nav>`,this.querySelector(`nav`).addEventListener(`click`,e=>{let t=e.target.closest(`button[data-to]`);if(!t||t.disabled)return;let n=Number(t.dataset.to);this.setAttribute(`page`,String(n)),a(this,`kashi-change`,{page:n}),this.querySelector(`.k-pagination__page[data-to="${n}"]`)?.focus()}),i&&this.querySelector(`[data-to="${i}"]`)?.focus()}};x.observedAttributes=[`page`,`total`,`siblings`,`href`,`digits`,`label`,`summary`];const S=e=>{let t=u(e).replace(/[٬,\s]/g,``).replace(`٫`,`.`).replace(`−`,`-`).match(/-?\d+(\.\d+)?/);return t?Number(t[0]):NaN};e(`kashi-tag-input`,m,`block`),e(`kashi-number-input`,h,`block`),e(`kashi-rating`,v),e(`kashi-pagination`,x,`block`);export{h as KashiNumberInput,x as KashiPagination,v as KashiRating,m as KashiTagInput,S as cellNumber,y as pageRange};
1
+ import{a as e,c as t,d as n,i as r,l as i,o as a,s as o,t as s}from"./base-DfzNTdQk.js";import{i as c,n as l,r as u,t as d}from"./digits-DE1YGT94.js";import{n as f}from"./text-D1U32D6K.js";function p(e,t,n){if(e.querySelectorAll(`:scope > input[type=hidden][data-kashi-value]`).forEach(e=>e.remove()),t)for(let r of n){let n=document.createElement(`input`);n.type=`hidden`,n.name=t,n.value=r,n.dataset.kashiValue=``,e.append(n)}}var m=class extends s{constructor(){super(...arguments),this.tags=[],this.localError=null,this.rendered=!1,this.valueSet=!1,this.key=n(`kashi-tags`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.tags=this.parse(this.getAttribute(`value`))),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=this.parse(n):this.render())}parse(e){return(e??``).split(/[,،]/).map(e=>e.trim()).filter(Boolean)}get value(){return[...this.tags]}set value(e){this.valueSet=!0,this.tags=Array.isArray(e)?[...e]:this.parse(e),this.rendered&&this.paint()}focus(e){this.input?.focus(e)}render(){let e=this.key,n=this.getAttribute(`aria-label`),r=this.hasAttribute(`label`)?this.getAttribute(`label`):n?null:`برچسب‌ها`,i=`<div class="k-tag-input"><input id="${e}" class="k-tag-input__control"${this.hasAttribute(`disabled`)?` disabled`:``}${!r&&n?` aria-label="${o(n)}"`:``}></div><span class="k-sr-only" aria-live="polite"></span>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,t({id:e,label:r,control:i})),this.input=this.querySelector(`.k-tag-input__control`),this.querySelector(`.k-tag-input`).addEventListener(`click`,e=>{let t=e.target.closest(`.k-badge__remove`);t?this.removeAt(Number(t.dataset.i)):this.input.focus()}),this.input.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===`,`||e.key===`،`)&&this.input.value.trim()?(e.preventDefault(),this.add([this.input.value])):e.key===`Backspace`&&!this.input.value&&this.tags.length&&this.removeAt(this.tags.length-1)}),this.input.addEventListener(`input`,()=>{this.localError=null;let e=this.input.value.split(/[,،\n\t]/);if(e.length>1){let t=e.pop()??``;this.add(e),t&&!this.localError&&(this.input.value=t)}else this.paintMessages()}),this.input.addEventListener(`blur`,()=>this.input.value.trim()&&this.add([this.input.value])),this.rendered=!0,this.paint()}add(e){let t=Number(this.getAttribute(`max`))||1/0,n=r(this,`allow-duplicates`),i=[...this.tags],a=``;for(let r of e){let e=f(r).trim();if(!e)continue;let o=i.length>=t?`حداکثر ${c(t)} مورد`:!n&&i.includes(e)?`این مورد قبلاً اضافه شده است.`:this.validate?.(e);if(o){this.localError=o,this.commit(i,a),this.input.value=e;return}i=[...i,e],a=`${e} اضافه شد`}this.localError=null,this.input.value=``,this.commit(i,a)}removeAt(e){let t=this.tags[e];this.commit(this.tags.filter((t,n)=>n!==e),`${t} حذف شد`),this.input.focus()}commit(e,t){let n=e.join(`\0`)!==this.tags.join(`\0`);this.tags=e,this.paint(),t&&(this.querySelector(`.k-field > .k-sr-only`).textContent=t),n&&a(this,`kashi-change`,{value:[...e]})}paint(){this.querySelector(`.k-tag-input`).querySelectorAll(`.k-badge`).forEach(e=>e.remove());let e=this.getAttribute(`tone`)??`brand`,t=this.hasAttribute(`disabled`),n=this.tags.map((n,r)=>`<span class="k-badge${e===`neutral`?``:` k-badge--${o(e)}`}${t?``:` k-badge--removable`}">${o(n)}${t?``:`<button type="button" class="k-badge__remove" data-i="${r}" aria-label="حذف ${o(n)}"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="m6 6 8 8M14 6l-8 8"/></svg></button>`}</span>`).join(``);this.input.insertAdjacentHTML(`beforebegin`,n),this.input.placeholder=this.tags.length?``:this.getAttribute(`placeholder`)??``,this.paintMessages(),p(this,this.getAttribute(`name`),this.tags)}paintMessages(){let e=this.getAttribute(`error`)||this.localError;this.querySelector(`.k-tag-input`).toggleAttribute(`data-invalid`,!!e),i(this.querySelector(`:scope > .k-field`),this.input,this.key,e,this.getAttribute(`hint`))}};m.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`disabled`,`name`,`value`,`max`,`tone`,`allow-duplicates`,`aria-label`];var h=class extends s{constructor(){super(...arguments),this.current=null,this.rendered=!1,this.valueSet=!1,this.key=n(`kashi-num`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.current=this.num(this.getAttribute(`value`))??null),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=n===null||n===``?null:Number(n):this.render())}get value(){return this.current}set value(e){this.valueSet=!0,this.current=e==null||Number.isNaN(Number(e))?null:Number(e),this.rendered&&this.paint()}focus(e){this.input?.focus(e)}num(e){return e===null||e===``||Number.isNaN(Number(e))?void 0:Number(e)}get min(){return this.num(this.getAttribute(`min`))}get max(){return this.num(this.getAttribute(`max`))}clamp(e){return Math.min(this.max??1/0,Math.max(this.min??-1/0,e))}show(e){if(e===null)return``;let t=this.hasAttribute(`thousands`)?d(e,{digits:`latin`}):String(e);return this.getAttribute(`digits`)===`latin`?t:c(t).replace(/,/g,`٬`)}render(){let e=this.key,n=this.getAttribute(`aria-label`),r=this.hasAttribute(`label`)?this.getAttribute(`label`):n?null:`تعداد`,i=this.hasAttribute(`disabled`),a=this.getAttribute(`unit`),s=`<div class="k-number"><div class="k-input"${i?` data-state="disabled"`:``}><button type="button" class="k-number__step" data-step="-1" tabindex="-1" aria-label="کاهش"${i?` disabled`:``}><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M5 10h10"/></svg></button><input id="${e}" class="k-input__control" type="text" inputmode="decimal" role="spinbutton" dir="ltr"${i?` disabled`:``}${!r&&n?` aria-label="${o(n)}"`:``}>${a?`<span class="k-input__addon">${o(a)}</span>`:``}<button type="button" class="k-number__step" data-step="1" tabindex="-1" aria-label="افزایش"${i?` disabled`:``}><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M10 5v10M5 10h10"/></svg></button></div></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,t({id:e,label:r,control:s})),this.input=this.querySelector(`input.k-input__control`),this.querySelectorAll(`.k-number__step`).forEach(e=>e.addEventListener(`click`,()=>this.bump(Number(e.dataset.step)))),this.input.addEventListener(`input`,()=>{let e=this.input.value,t=l(e);this.set(t?(/^\s*[-−]/.test(e)?-1:1)*Number(t):null,!1)}),this.input.addEventListener(`blur`,()=>{this.current!==null&&this.current!==this.clamp(this.current)?this.set(this.clamp(this.current)):this.paint()}),this.input.addEventListener(`keydown`,e=>{let t={ArrowUp:()=>this.bump(1),ArrowDown:()=>this.bump(-1),PageUp:()=>this.bump(10),PageDown:()=>this.bump(-10),Home:()=>this.min!==void 0&&this.set(this.min),End:()=>this.max!==void 0&&this.set(this.max)};t[e.key]&&(e.preventDefault(),t[e.key]())}),this.rendered=!0,this.paint()}bump(e){let t=this.num(this.getAttribute(`step`))??1;this.set(this.clamp((this.current??this.min??0)+e*t))}set(e,t=!0){let n=e!==this.current;this.current=e,t?this.paint():this.paintState(),n&&a(this,`kashi-change`,{value:e})}paint(){let e=this.show(this.current);this.input.value!==e&&(this.input.value=e),this.paintState()}paintState(){let e=this.input,t=this.current;for(let[n,r]of[[`aria-valuenow`,t],[`aria-valuemin`,this.min],[`aria-valuemax`,this.max]])r==null?e.removeAttribute(n):e.setAttribute(n,String(r));t===null?e.removeAttribute(`aria-valuetext`):e.setAttribute(`aria-valuetext`,this.show(t));let n=this.hasAttribute(`disabled`),[r,a]=this.querySelectorAll(`.k-number__step`);r.disabled=n||this.min!==void 0&&(t??0)<=this.min,a.disabled=n||this.max!==void 0&&(t??0)>=this.max,i(this.querySelector(`:scope > .k-field`),e,this.key,this.getAttribute(`error`),this.getAttribute(`hint`)),p(this,this.getAttribute(`name`),[t===null?``:String(t)])}};h.observedAttributes=[`label`,`hint`,`error`,`value`,`min`,`max`,`step`,`thousands`,`digits`,`unit`,`disabled`,`name`,`aria-label`];const g=`<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M12 2.8l2.8 5.9 6.4.8-4.7 4.4 1.2 6.3L12 17.1l-5.7 3.1 1.2-6.3L2.8 9.5l6.4-.8z"/><path class="k-rating__half" fill="none" d="M12 2.8v14.3l-5.7 3.1 1.2-6.3L2.8 9.5l6.4-.8z"/></svg>`,_=e=>c(String(e)).replace(`.`,`٫`);var v=class extends s{constructor(){super(...arguments),this.current=0,this.valueSet=!1,this.key=n(`kashi-rate`)}connectedCallback(){this.valueSet||(this.current=Number(this.getAttribute(`value`))||0),this.render()}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&(e===`value`&&(this.current=Number(n)||0),this.render())}get value(){return this.current}set value(e){this.valueSet=!0,this.current=Number(e)||0,this.isConnected&&this.render()}render(){let e=Number(this.getAttribute(`max`))||5,t=this.getAttribute(`label`)??`امتیاز`,n=this.getAttribute(`size`),r=`k-rating${n===`sm`||n===`lg`?` k-rating--${n}`:``}`,i=this.current,s=Array.from({length:e},(e,t)=>t+1),c=this.hasAttribute(`show-value`)?`<span class="k-rating__value" aria-hidden="true">${_(i)}</span>`:``;if(this.hasAttribute(`readonly`)){this.innerHTML=`<span class="${r}" data-readonly="" role="img" aria-label="${o(`${t}: ${_(i)} از ${_(e)}`)}">${s.map(e=>`<span class="k-rating__star"${e<=Math.floor(i)?` data-filled=""`:``}${e===Math.ceil(i)&&i%1>=.25?` data-half=""`:``}>${g}</span>`).join(``)}${c}</span>`;return}let l=this.getAttribute(`name`)??this.key,u=this.hasAttribute(`disabled`);this.innerHTML=`<fieldset class="${r}"><legend class="k-sr-only">${o(t)}</legend>${s.map(t=>`<label class="k-rating__star"${t<=i?` data-filled=""`:``}><input type="radio" class="k-sr-only" name="${o(l)}" value="${t}"${i===t?` checked`:``}${u?` disabled`:``} aria-label="${_(t)} از ${_(e)}">${g}</label>`).join(``)}${c}</fieldset>`;let d=this.querySelector(`fieldset`),f=e=>d.querySelectorAll(`.k-rating__star`).forEach((t,n)=>t.toggleAttribute(`data-filled`,n+1<=e));d.addEventListener(`change`,e=>{this.current=Number(e.target.value),f(this.current),a(this,`kashi-change`,{value:this.current})}),d.addEventListener(`pointerover`,e=>{let t=e.target.closest(`.k-rating__star`);t&&!u&&f([...d.querySelectorAll(`.k-rating__star`)].indexOf(t)+1)}),d.addEventListener(`pointerleave`,()=>f(this.current))}};v.observedAttributes=[`value`,`max`,`readonly`,`show-value`,`size`,`label`,`name`,`disabled`];function y(e,t,n=1){let r=[1],i=Math.max(2,e-n),a=Math.min(t-1,e+n);i>2&&r.push(i===3?2:null);for(let e=i;e<=a;e++)r.push(e);return a<t-1&&r.push(a===t-2?t-1:null),t>1&&r.push(t),r}const b=e=>`<svg data-k-mirror="" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${e}"/></svg>`;var x=class extends s{connectedCallback(){this.render()}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&this.render()}get page(){return Math.max(1,Number(this.getAttribute(`page`))||1)}set page(e){this.setAttribute(`page`,String(e))}get total(){return Math.max(1,Number(this.getAttribute(`total`))||1)}render(){let e=Math.min(this.page,this.total),t=this.total,n=e=>this.getAttribute(`digits`)===`latin`?String(e):c(e),r=this.getAttribute(`href`),i=this.contains(document.activeElement)?document.activeElement.dataset.to:null,s=(e,t,n,{current:i=!1,disabled:a=!1,aria:s=``}={})=>r&&!a?`<a class="${n}" href="${o(r.replace(`{page}`,String(e)))}" data-to="${e}"${i?` aria-current="page"`:``}${s?` aria-label="${o(s)}"`:``}>${t}</a>`:`<button type="button" class="${n}" data-to="${e}"${a?` disabled`:``}${i?` aria-current="page"`:``}${s?` aria-label="${o(s)}"`:``}>${t}</button>`,l=this.getAttribute(`summary`);this.innerHTML=`<nav class="k-pagination" aria-label="${o(this.getAttribute(`label`)??`صفحه‌بندی`)}">${s(e-1,`${b(`m12 5-5 5 5 5`)}قبلی`,`k-btn k-btn--secondary k-btn--sm`,{disabled:e<=1})}${l?`<span class="k-pagination__summary">${o(l)}</span>`:``}<ul class="k-pagination__pages" role="list">${y(e,t,Number(this.getAttribute(`siblings`)??1)).map(t=>`<li>${t===null?`<span class="k-pagination__ellipsis" aria-hidden="true">…</span>`:s(t,n(t),`k-pagination__page`,{current:t===e,aria:`صفحهٔ ${n(t)}`})}</li>`).join(``)}</ul>${s(e+1,`بعدی${b(`m8 5 5 5-5 5`)}`,`k-btn k-btn--secondary k-btn--sm`,{disabled:e>=t})}</nav>`,this.querySelector(`nav`).addEventListener(`click`,e=>{let t=e.target.closest(`button[data-to]`);if(!t||t.disabled)return;let n=Number(t.dataset.to);this.setAttribute(`page`,String(n)),a(this,`kashi-change`,{page:n}),this.querySelector(`.k-pagination__page[data-to="${n}"]`)?.focus()}),i&&this.querySelector(`[data-to="${i}"]`)?.focus()}};x.observedAttributes=[`page`,`total`,`siblings`,`href`,`digits`,`label`,`summary`];const S=e=>{let t=u(e).replace(/[٬,\s]/g,``).replace(`٫`,`.`).replace(`−`,`-`).match(/-?\d+(\.\d+)?/);return t?Number(t[0]):NaN};e(`kashi-tag-input`,m,`block`),e(`kashi-number-input`,h,`block`),e(`kashi-rating`,v),e(`kashi-pagination`,x,`block`);export{h as KashiNumberInput,x as KashiPagination,v as KashiRating,m as KashiTagInput,S as cellNumber,y as pageRange};
@@ -1 +1 @@
1
- import{a as e,o as t,s as n,t as r}from"./base-Cmq7zeIG.js";import{i,t as a}from"./digits-DE1YGT94.js";import{a as o,i as s}from"./jalali-BiM5Kfep.js";import{t as c}from"./words-9OdzG7y6.js";const l=6e4,u=60*l,d=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();function f(e,{now:t=/* @__PURE__ */ new Date,digits:n=`fa`}={}){let r=e.getTime()-t.getTime(),a=r<0,o=Math.abs(r),s=e=>n===`fa`?i(e):String(e),c=(e,t)=>`${s(e)} ${t} ${a?`پیش`:`دیگر`}`;if(o<45e3)return`همین الان`;if(o<u)return c(Math.max(1,Math.round(o/l)),`دقیقه`);let f=Math.round((d(e)-d(t))/864e5);if(o<6*u||f===0)return c(Math.round(o/u),`ساعت`);if(f===-1)return`دیروز`;if(f===1)return`فردا`;let p=Math.abs(f);return p<7?c(p,`روز`):p<30?c(Math.round(p/7),`هفته`):p<365?c(Math.max(1,Math.round(p/30.44)),`ماه`):c(Math.round(p/365.25),`سال`)}const p=[[0xe8d4a51000,`همت`],[1e9,`میلیارد`],[1e6,`میلیون`],[1e3,`هزار`]],m=e=>Math.round(e/10),h=e=>e*10;function g(e,{unit:t=`toman`,from:n=`toman`,compact:r=!1,showUnit:o=!0,digits:s=`fa`}={}){let c=n===t?e:n===`rial`?m(e):h(e),l=c<0?`−`:``;c=Math.abs(c);let u=a(Math.round(c),{digits:s}),d=t===`toman`?`تومان`:`ریال`;if(r){let e=p.find(([e,n])=>c>=e&&(n!==`همت`||t===`toman`));if(e){let t=Math.round(c/e[0]*100)/100,n=String(t).replace(`.`,s===`fa`?`٫`:`.`);u=`${s===`fa`?i(n):n} ${e[1]}`,e[1]===`همت`&&(d=``)}}return`${l}${u}${o&&d?` ${d}`:``}`}const _=e=>{if(!e)return null;let t=o(e.trim())??new Date(e);return Number.isNaN(t.getTime())?null:t};var v=class extends r{connectedCallback(){this.render()}attributeChangedCallback(){this.isConnected&&this.render()}},y=class extends v{render(){let e=Number(this.getAttribute(`value`)??0),t=this.getAttribute(`unit`)===`rial`?`rial`:`toman`,r=this.getAttribute(`from`)===`rial`?`rial`:this.getAttribute(`from`)===`toman`?`toman`:t,i=this.hasAttribute(`compact`),a=this.getAttribute(`digits`)===`latin`?`latin`:`fa`,o=this.hasAttribute(`signed`),s=this.getAttribute(`size`)??`md`,l=r===t?e:r===`rial`?m(e):h(e),u=g(l,{unit:t,compact:i,digits:a,showUnit:!1}),d=g(l,{unit:t,compact:i}).endsWith(`همت`)?null:t===`toman`?`تومان`:`ریال`,f=this.getAttribute(`words`)!==`false`&&Number.isSafeInteger(Math.round(l))?`${c(Math.round(l))} ${t===`toman`?`تومان`:`ریال`}`:null,p=o?l>0?`positive`:l<0?`negative`:null:null,_=f?` aria-hidden="true"`:``;this.innerHTML=`<data value="${l}" class="k-money k-money--${n(s)}"${p?` data-tone="${p}"`:``}${f?` title="${n(f)}"`:``}><span class="k-money__amount"${_}>${o&&l>0?`+`:``}${n(u)}</span>${d?`<span class="k-money__unit"${_}>${d}</span>`:``}${f?`<span class="k-sr-only">${l<0?``:o&&l>0?`مثبت `:``}${n(f)}</span>`:``}</data>`}};y.observedAttributes=[`value`,`unit`,`from`,`compact`,`digits`,`signed`,`words`,`size`];var b=class extends v{render(){let e=_(this.getAttribute(`datetime`));if(!e){this.textContent=``;return}let t=this.getAttribute(`format`),r=t===`numeric`||t===`full`?t:`long`,i=this.getAttribute(`digits`)===`latin`?`latin`:`fa`;this.innerHTML=`<time datetime="${n(this.getAttribute(`datetime`))}">${n(s(e,{style:r,digits:i}))}</time>`}};b.observedAttributes=[`datetime`,`format`,`digits`];var x=class extends v{connectedCallback(){super.connectedCallback(),clearInterval(this.timer),this.timer=setInterval(()=>this.render(),Number(this.getAttribute(`refresh`))||6e4)}disconnectedCallback(){clearInterval(this.timer)}render(){let e=_(this.getAttribute(`datetime`));if(!e){this.textContent=``;return}let t=this.getAttribute(`digits`)===`latin`?`latin`:`fa`;this.innerHTML=`<time datetime="${e.toISOString()}" title="${n(s(e,{style:`full`,digits:t}))}">${n(f(e,{digits:t}))}</time>`}};x.observedAttributes=[`datetime`,`digits`,`refresh`];const S=e=>String(e).padStart(2,`0`);var C=class extends r{constructor(){super(...arguments),this.end=0,this.done=!1}connectedCallback(){this.restart()}disconnectedCallback(){clearInterval(this.timer)}attributeChangedCallback(e,t,n){this.isConnected&&t!==n&&(e===`to`||e===`seconds`?this.restart():this.render())}restart(){let e=_(this.getAttribute(`to`));this.end=e?e.getTime():Date.now()+(Number(this.getAttribute(`seconds`))||0)*1e3,this.done=!1,clearInterval(this.timer),this.render(),this.timer=setInterval(()=>this.render(),1e3)}get remaining(){return Math.max(0,Math.ceil((this.end-Date.now())/1e3))}render(){let e=this.remaining,r=Math.floor(e/86400),a=Math.floor(e%86400/3600),o=Math.floor(e%3600/60),s=e%60,c=this.getAttribute(`digits`)!==`latin`,l=e=>c?i(String(e)):String(e),u=[r&&`${l(r)} روز`,a&&`${l(a)} ساعت`,o&&`${l(o)} دقیقه`,`${l(s)} ثانیه`].filter(Boolean).join(` و `),d=this.getAttribute(`label`),f=n(d?`${d}: ${u}`:u),p=e===0?` data-done=""`:``;if(this.getAttribute(`variant`)===`blocks`){let e=[...r?[[r,`روز`]]:[],[a,`ساعت`],[o,`دقیقه`],[s,`ثانیه`]];this.innerHTML=`<div role="timer" aria-label="${f}" class="k-countdown k-countdown--blocks"${p}>${e.map(([e,t])=>`<span class="k-countdown__unit" aria-hidden="true"><span class="k-countdown__num">${l(S(e))}</span><span class="k-countdown__name">${t}</span></span>`).join(``)}</div>`}else{let e=(r?`${r}:`:``)+(a||r?`${S(a)}:`:``)+`${S(o)}:${S(s)}`;this.innerHTML=`<span role="timer" aria-label="${f}" class="k-countdown"${p} dir="ltr"><span aria-hidden="true">${l(e)}</span></span>`}e===0&&(clearInterval(this.timer),this.done||(this.done=!0,t(this,`kashi-complete`,{})))}};C.observedAttributes=[`to`,`seconds`,`variant`,`digits`,`label`],e(`kashi-money`,y),e(`kashi-date`,b),e(`kashi-relative-time`,x),e(`kashi-countdown`,C);export{C as KashiCountdown,b as KashiDate,y as KashiMoney,x as KashiRelativeTime};
1
+ import{a as e,o as t,s as n,t as r}from"./base-DfzNTdQk.js";import{i,t as a}from"./digits-DE1YGT94.js";import{a as o,i as s}from"./jalali-BiM5Kfep.js";import{t as c}from"./words-9OdzG7y6.js";const l=6e4,u=60*l,d=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();function f(e,{now:t=/* @__PURE__ */ new Date,digits:n=`fa`}={}){let r=e.getTime()-t.getTime(),a=r<0,o=Math.abs(r),s=e=>n===`fa`?i(e):String(e),c=(e,t)=>`${s(e)} ${t} ${a?`پیش`:`دیگر`}`;if(o<45e3)return`همین الان`;if(o<u)return c(Math.max(1,Math.round(o/l)),`دقیقه`);let f=Math.round((d(e)-d(t))/864e5);if(o<6*u||f===0)return c(Math.round(o/u),`ساعت`);if(f===-1)return`دیروز`;if(f===1)return`فردا`;let p=Math.abs(f);return p<7?c(p,`روز`):p<30?c(Math.round(p/7),`هفته`):p<365?c(Math.max(1,Math.round(p/30.44)),`ماه`):c(Math.round(p/365.25),`سال`)}const p=[[0xe8d4a51000,`همت`],[1e9,`میلیارد`],[1e6,`میلیون`],[1e3,`هزار`]],m=e=>Math.round(e/10),h=e=>e*10;function g(e,{unit:t=`toman`,from:n=`toman`,compact:r=!1,showUnit:o=!0,digits:s=`fa`}={}){let c=n===t?e:n===`rial`?m(e):h(e),l=c<0?`−`:``;c=Math.abs(c);let u=a(Math.round(c),{digits:s}),d=t===`toman`?`تومان`:`ریال`;if(r){let e=p.find(([e,n])=>c>=e&&(n!==`همت`||t===`toman`));if(e){let t=Math.round(c/e[0]*100)/100,n=String(t).replace(`.`,s===`fa`?`٫`:`.`);u=`${s===`fa`?i(n):n} ${e[1]}`,e[1]===`همت`&&(d=``)}}return`${l}${u}${o&&d?` ${d}`:``}`}const _=e=>{if(!e)return null;let t=o(e.trim())??new Date(e);return Number.isNaN(t.getTime())?null:t};var v=class extends r{connectedCallback(){this.render()}attributeChangedCallback(){this.isConnected&&this.render()}},y=class extends v{render(){let e=Number(this.getAttribute(`value`)??0),t=this.getAttribute(`unit`)===`rial`?`rial`:`toman`,r=this.getAttribute(`from`)===`rial`?`rial`:this.getAttribute(`from`)===`toman`?`toman`:t,i=this.hasAttribute(`compact`),a=this.getAttribute(`digits`)===`latin`?`latin`:`fa`,o=this.hasAttribute(`signed`),s=this.getAttribute(`size`)??`md`,l=r===t?e:r===`rial`?m(e):h(e),u=g(l,{unit:t,compact:i,digits:a,showUnit:!1}),d=g(l,{unit:t,compact:i}).endsWith(`همت`)?null:t===`toman`?`تومان`:`ریال`,f=this.getAttribute(`words`)!==`false`&&Number.isSafeInteger(Math.round(l))?`${c(Math.round(l))} ${t===`toman`?`تومان`:`ریال`}`:null,p=o?l>0?`positive`:l<0?`negative`:null:null,_=f?` aria-hidden="true"`:``;this.innerHTML=`<data value="${l}" class="k-money k-money--${n(s)}"${p?` data-tone="${p}"`:``}${f?` title="${n(f)}"`:``}><span class="k-money__amount"${_}>${o&&l>0?`+`:``}${n(u)}</span>${d?`<span class="k-money__unit"${_}>${d}</span>`:``}${f?`<span class="k-sr-only">${l<0?``:o&&l>0?`مثبت `:``}${n(f)}</span>`:``}</data>`}};y.observedAttributes=[`value`,`unit`,`from`,`compact`,`digits`,`signed`,`words`,`size`];var b=class extends v{render(){let e=_(this.getAttribute(`datetime`));if(!e){this.textContent=``;return}let t=this.getAttribute(`format`),r=t===`numeric`||t===`full`?t:`long`,i=this.getAttribute(`digits`)===`latin`?`latin`:`fa`;this.innerHTML=`<time datetime="${n(this.getAttribute(`datetime`))}">${n(s(e,{style:r,digits:i}))}</time>`}};b.observedAttributes=[`datetime`,`format`,`digits`];var x=class extends v{connectedCallback(){super.connectedCallback(),clearInterval(this.timer),this.timer=setInterval(()=>this.render(),Number(this.getAttribute(`refresh`))||6e4)}disconnectedCallback(){clearInterval(this.timer)}render(){let e=_(this.getAttribute(`datetime`));if(!e){this.textContent=``;return}let t=this.getAttribute(`digits`)===`latin`?`latin`:`fa`;this.innerHTML=`<time datetime="${e.toISOString()}" title="${n(s(e,{style:`full`,digits:t}))}">${n(f(e,{digits:t}))}</time>`}};x.observedAttributes=[`datetime`,`digits`,`refresh`];const S=e=>String(e).padStart(2,`0`);var C=class extends r{constructor(){super(...arguments),this.end=0,this.done=!1}connectedCallback(){this.restart()}disconnectedCallback(){clearInterval(this.timer)}attributeChangedCallback(e,t,n){this.isConnected&&t!==n&&(e===`to`||e===`seconds`?this.restart():this.render())}restart(){let e=_(this.getAttribute(`to`));this.end=e?e.getTime():Date.now()+(Number(this.getAttribute(`seconds`))||0)*1e3,this.done=!1,clearInterval(this.timer),this.render(),this.timer=setInterval(()=>this.render(),1e3)}get remaining(){return Math.max(0,Math.ceil((this.end-Date.now())/1e3))}render(){let e=this.remaining,r=Math.floor(e/86400),a=Math.floor(e%86400/3600),o=Math.floor(e%3600/60),s=e%60,c=this.getAttribute(`digits`)!==`latin`,l=e=>c?i(String(e)):String(e),u=[r&&`${l(r)} روز`,a&&`${l(a)} ساعت`,o&&`${l(o)} دقیقه`,`${l(s)} ثانیه`].filter(Boolean).join(` و `),d=this.getAttribute(`label`),f=n(d?`${d}: ${u}`:u),p=e===0?` data-done=""`:``;if(this.getAttribute(`variant`)===`blocks`){let e=[...r?[[r,`روز`]]:[],[a,`ساعت`],[o,`دقیقه`],[s,`ثانیه`]];this.innerHTML=`<div role="timer" aria-label="${f}" class="k-countdown k-countdown--blocks"${p}>${e.map(([e,t])=>`<span class="k-countdown__unit" aria-hidden="true"><span class="k-countdown__num">${l(S(e))}</span><span class="k-countdown__name">${t}</span></span>`).join(``)}</div>`}else{let e=(r?`${r}:`:``)+(a||r?`${S(a)}:`:``)+`${S(o)}:${S(s)}`;this.innerHTML=`<span role="timer" aria-label="${f}" class="k-countdown"${p} dir="ltr"><span aria-hidden="true">${l(e)}</span></span>`}e===0&&(clearInterval(this.timer),this.done||(this.done=!0,t(this,`kashi-complete`,{})))}};C.observedAttributes=[`to`,`seconds`,`variant`,`digits`,`label`],e(`kashi-money`,y),e(`kashi-date`,b),e(`kashi-relative-time`,x),e(`kashi-countdown`,C);export{C as KashiCountdown,b as KashiDate,y as KashiMoney,x as KashiRelativeTime};
@@ -1 +1 @@
1
- import{a as e,c as t,d as n,l as r,o as i,s as a,t as o,u as s}from"./base-Cmq7zeIG.js";import{i as c,n as l}from"./digits-DE1YGT94.js";var u=class extends o{constructor(){super(...arguments),this.code=``,this.caret=0,this.valueSet=!1,this.rendered=!1,this.key=n(`kashi-otp`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.code=l(this.getAttribute(`value`)??``).slice(0,this.length)),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?(this.code=l(n??``).slice(0,this.length),this.paint()):this.render())}get value(){return this.code}set value(e){this.valueSet=!0,this.code=l(String(e??``)).slice(0,this.length),this.rendered&&this.paint()}focus(e){this.input?.focus(e)}get length(){let e=Number(this.getAttribute(`length`));return Number.isInteger(e)&&e>0?e:6}render(){let e=this.key,n=this.length,r=Number(this.getAttribute(`group-after`))||0,o=this.getAttribute(`aria-label`),s=this.hasAttribute(`label`)?this.getAttribute(`label`):o?null:`کد تأیید`,c=Array.from({length:n},(e,t)=>`${r&&t===r?`<span class="k-otp__sep" aria-hidden="true"></span>`:``}<span class="k-otp__slot" aria-hidden="true"></span>`).join(``),u=`<div class="k-otp${this.getAttribute(`size`)===`sm`?` k-otp--sm`:``}"><input id="${e}" class="k-otp__input" type="text" inputmode="numeric" autocomplete="one-time-code" pattern="\\d*" maxlength="${n*2}"${this.hasAttribute(`disabled`)?` disabled`:``}${!s&&o?` aria-label="${a(o)}"`:``}>${c}</div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,t({id:e,label:s,control:u})),this.input=this.querySelector(`.k-otp__input`),this.querySelector(`.k-otp`).addEventListener(`click`,()=>this.input.focus()),this.input.addEventListener(`input`,()=>{let e=l(this.input.value).slice(0,this.length),t=this.code;this.code=e,this.caret=e.length,this.paint(),e!==t&&i(this,`kashi-change`,{value:e}),e.length===this.length&&e!==t&&i(this,`kashi-complete`,{value:e})});let d=()=>{this.caret=Math.min(this.input.selectionStart??this.code.length,this.length),this.paintSlots()};for(let e of[`select`,`keyup`,`focus`])this.input.addEventListener(e,d);this.input.addEventListener(`blur`,()=>this.paintSlots()),this.rendered=!0,this.paint()}paint(){this.input.value!==this.code&&(this.input.value=this.code),this.paintSlots();let e=this.getAttribute(`error`);this.querySelector(`.k-otp`).classList.toggle(`k-otp--invalid`,!!e),r(this.querySelector(`:scope > .k-field`),this.input,this.key,e,this.getAttribute(`hint`)),s(this,this.getAttribute(`name`),this.code)}paintSlots(){let e=this.getAttribute(`digits`)!==`latin`,t=this.ownerDocument.activeElement===this.input,n=Math.min(this.caret,this.length-1);this.querySelectorAll(`.k-otp__slot`).forEach((r,i)=>{let a=this.code[i]??``;r.textContent=e?c(a):a,r.toggleAttribute(`data-filled`,!!a),r.toggleAttribute(`data-active`,t&&i===n)})}};u.observedAttributes=[`label`,`hint`,`error`,`length`,`digits`,`group-after`,`size`,`disabled`,`name`,`value`,`aria-label`],e(`kashi-otp`,u,`block`);export{u as KashiOtp};
1
+ import{a as e,c as t,d as n,l as r,o as i,s as a,t as o,u as s}from"./base-DfzNTdQk.js";import{i as c,n as l}from"./digits-DE1YGT94.js";var u=class extends o{constructor(){super(...arguments),this.code=``,this.caret=0,this.valueSet=!1,this.rendered=!1,this.key=n(`kashi-otp`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.code=l(this.getAttribute(`value`)??``).slice(0,this.length)),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?(this.code=l(n??``).slice(0,this.length),this.paint()):this.render())}get value(){return this.code}set value(e){this.valueSet=!0,this.code=l(String(e??``)).slice(0,this.length),this.rendered&&this.paint()}focus(e){this.input?.focus(e)}get length(){let e=Number(this.getAttribute(`length`));return Number.isInteger(e)&&e>0?e:6}render(){let e=this.key,n=this.length,r=Number(this.getAttribute(`group-after`))||0,o=this.getAttribute(`aria-label`),s=this.hasAttribute(`label`)?this.getAttribute(`label`):o?null:`کد تأیید`,c=Array.from({length:n},(e,t)=>`${r&&t===r?`<span class="k-otp__sep" aria-hidden="true"></span>`:``}<span class="k-otp__slot" aria-hidden="true"></span>`).join(``),u=`<div class="k-otp${this.getAttribute(`size`)===`sm`?` k-otp--sm`:``}"><input id="${e}" class="k-otp__input" type="text" inputmode="numeric" autocomplete="one-time-code" pattern="\\d*" maxlength="${n*2}"${this.hasAttribute(`disabled`)?` disabled`:``}${!s&&o?` aria-label="${a(o)}"`:``}>${c}</div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,t({id:e,label:s,control:u})),this.input=this.querySelector(`.k-otp__input`),this.querySelector(`.k-otp`).addEventListener(`click`,()=>this.input.focus()),this.input.addEventListener(`input`,()=>{let e=l(this.input.value).slice(0,this.length),t=this.code;this.code=e,this.caret=e.length,this.paint(),e!==t&&i(this,`kashi-change`,{value:e}),e.length===this.length&&e!==t&&i(this,`kashi-complete`,{value:e})});let d=()=>{this.caret=Math.min(this.input.selectionStart??this.code.length,this.length),this.paintSlots()};for(let e of[`select`,`keyup`,`focus`])this.input.addEventListener(e,d);this.input.addEventListener(`blur`,()=>this.paintSlots()),this.rendered=!0,this.paint()}paint(){this.input.value!==this.code&&(this.input.value=this.code),this.paintSlots();let e=this.getAttribute(`error`);this.querySelector(`.k-otp`).classList.toggle(`k-otp--invalid`,!!e),r(this.querySelector(`:scope > .k-field`),this.input,this.key,e,this.getAttribute(`hint`)),s(this,this.getAttribute(`name`),this.code)}paintSlots(){let e=this.getAttribute(`digits`)!==`latin`,t=this.ownerDocument.activeElement===this.input,n=Math.min(this.caret,this.length-1);this.querySelectorAll(`.k-otp__slot`).forEach((r,i)=>{let a=this.code[i]??``;r.textContent=e?c(a):a,r.toggleAttribute(`data-filled`,!!a),r.toggleAttribute(`data-active`,t&&i===n)})}};u.observedAttributes=[`label`,`hint`,`error`,`length`,`digits`,`group-after`,`size`,`disabled`,`name`,`value`,`aria-label`],e(`kashi-otp`,u,`block`);export{u as KashiOtp};
@@ -0,0 +1 @@
1
+ import{a as e,c as t,d as n,i as r,l as i,o as a,r as o,s,t as c,u as l}from"./base-DfzNTdQk.js";import{i as u,n as d,t as f}from"./digits-DE1YGT94.js";import{t as p}from"./text-D1U32D6K.js";import{n as m,t as h}from"./time-DXw4vOne.js";import{searchText as g}from"./combobox-DiGy7lAB.js";const _=[`الف`,`ب`,`پ`,`ت`,`ث`,`ج`,`د`,`ز`,`س`,`ش`,`ص`,`ط`,`ع`,`ف`,`ق`,`ک`,`گ`,`ل`,`م`,`ن`,`و`,`ه`,`ی`,`ژ`],v={الف:`government`,پ:`police`,ث:`police`,ت:`taxi`,ع:`public`,ک:`agricultural`,ش:`army`,ز:`defense`,ف:`defense`,ژ:`disabled`};function y(e){return v[e]??`private`}function b(e){let t=d(e.first??``),n=d(e.middle??``),r=d(e.region??``);return/^[1-9]\d$/.test(t)&&/^[1-9]\d{2}$/.test(n)&&/^[1-9]\d$/.test(r)&&_.includes(e.letter??``)}function x(e,{digits:t=`fa`}={}){let n=e=>t===`fa`?u(d(e)):d(e);return`${n(e.first)} ${e.letter} ${n(e.middle)} ایران ${n(e.region)}`}const S=`ضصثقفغعهخحجچپشسیبلاتنمکگظطزرذدپوژ؟آ`,C=/* @__PURE__ */ new Map,w=/* @__PURE__ */ new Map;[...`qwertyuiop[]\\asdfghjkl;'zxcvbnm,C?H`].forEach((e,t)=>{C.set(e,S[t]),w.has(S[t])||w.set(S[t],e)});function T(e,t=`fa`){let n=t===`fa`?C:w;return[...e].map(e=>n.get(t===`fa`&&e!==`C`&&e!==`H`?e.toLowerCase():e)??e).join(``)}function E(e){let t=e.trim();if(!t||/[\u0600-\u06FF]/.test(t)||!/[a-z]/i.test(t))return!1;let n=t.split(/\s+/).filter(e=>/[a-z]/i.test(e)),r=n.filter(e=>/[a-z][;'[\],\\]|[;'[\],\\][a-z]/i.test(e)||e.length>=3&&!/[aeiouy]/i.test(e));return r.length>0&&r.length*2>=n.length}const D=`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m5 10.5 3.2 3L15 7"/></svg>`,O=`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="m6 6 8 8M14 6l-8 8"/></svg>`;function k(e,t,n){if(e.querySelectorAll(`:scope > input[type=hidden][data-kashi-value]`).forEach(e=>e.remove()),t)for(let r of n)e.insertAdjacentHTML(`beforeend`,`<input type="hidden" data-kashi-value name="${s(t)}" value="${s(r)}">`)}function A(e){let t=[...e.querySelectorAll(`:scope > option`)].map(e=>({value:e.value,label:e.textContent?.trim()??e.value,description:e.dataset.description,disabled:e.disabled,selected:e.hasAttribute(`selected`)}));return e.querySelectorAll(`:scope > option`).forEach(e=>e.remove()),t}var j=class extends c{constructor(){super(...arguments),this.list=null,this.chosen=[],this.query=``,this.active=-1,this.isOpen=!1,this.valueSet=!1,this.key=n(`kashi-multi`),this.onOutside=e=>{this.contains(e.target)||this.close()}}connectedCallback(){o(()=>{if(this.isConnected){if(this.list===null){let e=A(this);this.list=e,this.valueSet||(this.chosen=e.filter(e=>e.selected).map(e=>e.value))}this.render()}})}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}attributeChangedCallback(e,t,n){this.box&&t!==n&&this.render()}get options(){return this.list??[]}set options(e){this.list=[...e],this.box&&this.paint()}get value(){return[...this.chosen]}set value(e){this.valueSet=!0,this.chosen=[...e],this.box&&this.paint()}render(){let e=this.key,n=this.getAttribute(`aria-label`),r=this.hasAttribute(`label`)?this.getAttribute(`label`):n?null:`انتخاب`,i=`<div class="k-combobox k-multiselect"><div class="k-tag-input"><input id="${e}" class="k-tag-input__control" role="combobox" aria-autocomplete="list" aria-expanded="false" aria-controls="${e}-list" autocomplete="off"${this.hasAttribute(`disabled`)?` disabled`:``}${!r&&n?` aria-label="${s(n)}"`:``}></div><ul id="${e}-list" role="listbox" aria-multiselectable="true" class="k-listbox" hidden style="inset-block-start: calc(100% + 6px)"${r?` aria-label="${s(r)}"`:``}></ul><span id="${e}-count" class="k-sr-only"></span><span class="k-sr-only" aria-live="polite"></span></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,t({id:e,label:r,control:i})),this.input=this.querySelector(`.k-tag-input__control`),this.box=this.querySelector(`.k-tag-input`),this.listbox=this.querySelector(`.k-listbox`),this.box.addEventListener(`click`,e=>{let t=e.target.closest(`[data-remove]`);t?this.set(this.chosen.filter(e=>e!==t.dataset.remove),`${this.labelOf(t.dataset.remove)} حذف شد`):e.target.closest(`[data-clear]`)&&this.set([],`همه حذف شد`),this.input.focus()}),this.input.addEventListener(`input`,()=>{this.query=this.input.value,this.active=0,this.open()}),this.input.addEventListener(`focus`,()=>this.open()),this.input.addEventListener(`keydown`,e=>this.onKey(e)),this.listbox.addEventListener(`pointerdown`,e=>e.preventDefault()),this.listbox.addEventListener(`click`,e=>{let t=e.target.closest(`[role="option"]`);t&&this.toggle(this.filtered()[Number(t.dataset.i)])}),this.paint()}labelOf(e){return this.options.find(t=>t.value===e)?.label??e}filtered(){let e=g(this.query.trim());return this.options.filter(t=>!e||[t.label,t.description??``].some(t=>g(t).includes(e)))}get full(){let e=Number(this.getAttribute(`max`));return!!e&&this.chosen.length>=e}toggle(e){if(!e||e.disabled)return;let t=this.chosen.includes(e.value);if(!t&&this.full)return this.announce(`حداکثر ${u(Number(this.getAttribute(`max`)))} مورد`);this.query=``,this.input.value=``,this.set(t?this.chosen.filter(t=>t!==e.value):[...this.chosen,e.value],`${e.label} ${t?`حذف شد`:`انتخاب شد`}`)}set(e,t){this.chosen=e,this.paint(),this.announce(t),a(this,`kashi-change`,{value:[...e]})}announce(e){this.querySelector(`.k-multiselect > .k-sr-only[aria-live]`).textContent=e}open(){this.hasAttribute(`disabled`)||(this.isOpen=!0,this.listbox.hidden=!1,this.input.setAttribute(`aria-expanded`,`true`),this.querySelector(`.k-combobox`).setAttribute(`data-open`,``),document.addEventListener(`pointerdown`,this.onOutside),this.paintList())}close(){this.isOpen=!1,this.listbox.hidden=!0,this.input.setAttribute(`aria-expanded`,`false`),this.input.removeAttribute(`aria-activedescendant`),this.querySelector(`.k-combobox`).removeAttribute(`data-open`),document.removeEventListener(`pointerdown`,this.onOutside)}onKey(e){let t=this.filtered(),n=t.map((e,t)=>e.disabled?-1:t).filter(e=>e>=0),r=e=>{n.length&&(this.active=n[(n.indexOf(this.active)+e+n.length)%n.length],this.paintList())};if(e.key===`ArrowDown`)e.preventDefault(),this.isOpen?r(1):this.open();else if(e.key===`ArrowUp`)e.preventDefault(),this.isOpen?r(-1):this.open();else if(e.key===`Enter`&&this.isOpen&&t[this.active])e.preventDefault(),this.toggle(t[this.active]);else if(e.key===`Escape`&&this.isOpen)e.preventDefault(),this.close();else if(e.key===`Backspace`&&!this.input.value&&this.chosen.length){let e=this.chosen.at(-1);this.set(this.chosen.slice(0,-1),`${this.labelOf(e)} حذف شد`)}}paint(){let e=this.hasAttribute(`disabled`);this.box.querySelectorAll(`.k-badge, [data-clear]`).forEach(e=>e.remove());let t=this.chosen.map(t=>`<span class="k-badge k-badge--brand${e?``:` k-badge--removable`}">${s(this.labelOf(t))}${e?``:`<button type="button" class="k-badge__remove" data-remove="${s(t)}" aria-label="حذف ${s(this.labelOf(t))}">${O}</button>`}</span>`).join(``);this.input.insertAdjacentHTML(`beforebegin`,t),this.chosen.length>1&&!e&&this.box.insertAdjacentHTML(`beforeend`,`<button type="button" class="k-input__action" data-clear aria-label="پاک کردن همه">${O}</button>`),this.input.placeholder=this.chosen.length?``:this.getAttribute(`placeholder`)??``,this.querySelector(`#${this.key}-count`).textContent=`${u(this.chosen.length)} مورد انتخاب شده`;let n=this.getAttribute(`error`);this.box.toggleAttribute(`data-invalid`,!!n),i(this.querySelector(`:scope > .k-field`),this.input,this.key,n,this.getAttribute(`hint`),`${this.key}-count`),k(this,this.getAttribute(`name`),this.chosen),this.isOpen&&this.paintList()}paintList(){let e=this.filtered(),t=g(this.query.trim()),n=this.full,r=e=>{let n=t?g(e).indexOf(t):-1;return n<0?s(e):`${s(e.slice(0,n))}<mark>${s(e.slice(n,n+t.length))}</mark>${s(e.slice(n+t.length))}`};this.listbox.innerHTML=e.length?e.map((e,t)=>{let i=this.chosen.includes(e.value);return`<li id="${this.key}-list-${t}" data-i="${t}" role="option" aria-selected="${i}"${e.disabled||!i&&n?` aria-disabled="true"`:``}${t===this.active?` data-active`:``} class="k-option k-option--check"><span class="k-multiselect__box" aria-hidden="true">${i?D:``}</span><span class="k-option__body"><span>${r(e.label)}</span>${e.description?`<span class="k-option__desc">${s(e.description)}</span>`:``}</span></li>`}).join(``):`<li class="k-listbox__empty" role="presentation">نتیجه‌ای پیدا نشد.</li>`;let i=this.active>=0?this.listbox.querySelector(`[data-i="${this.active}"]`):null;i?(this.input.setAttribute(`aria-activedescendant`,i.id),i.scrollIntoView?.({block:`nearest`})):this.input.removeAttribute(`aria-activedescendant`)}};j.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`max`,`disabled`,`name`,`aria-label`];var M=class extends c{constructor(){super(...arguments),this.lo=0,this.hi=0,this.valueSet=!1,this.rendered=!1,this.key=n(`kashi-slider`)}connectedCallback(){!this.rendered&&!this.valueSet&&this.readValue(this.getAttribute(`value`)),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`&&this.readValue(n),this.render())}num(e,t){let n=this.getAttribute(e);return n===null||n===``||Number.isNaN(Number(n))?t:Number(n)}get min(){return this.num(`min`,0)}get max(){return this.num(`max`,100)}get isRange(){return this.hasAttribute(`range`)}readValue(e){let t=(e??``).split(/[,،]/).map(e=>Number(e.trim())).filter(e=>!Number.isNaN(e)&&String(e)!==``);this.isRange?[this.lo,this.hi]=[t[0]??this.min,t[1]??this.max]:[this.lo,this.hi]=[this.min,t[0]??this.min]}get value(){return this.isRange?[this.lo,this.hi]:this.hi}set value(e){this.valueSet=!0,this.readValue(Array.isArray(e)?e.join(`,`):String(e)),this.rendered&&this.render()}fmt(e){let t=this.getAttribute(`unit`);return`${f(e)}${t?` ${t}`:``}`}render(){let e=this.getAttribute(`label`),t=this.isRange,n=this.getAttribute(`name`),r=this.hasAttribute(`disabled`),i=e=>`${(e-this.min)/(this.max-this.min)*100}%`,o=i=>{let a=i===`lo`?this.lo:this.hi,o=n?t?`${n}_${i===`lo`?`min`:`max`}`:n:``;return`<input type="range" class="k-slider__input" data-which="${i}" min="${this.min}" max="${this.max}" step="${this.num(`step`,1)}" value="${a}"${r?` disabled`:``}${o?` name="${s(o)}"`:``}${t?` aria-label="${i===`lo`?`حداقل`:`حداکثر`}${e?` ${s(e)}`:``}"`:e?` aria-labelledby="${this.key}-label"`:``} aria-valuetext="${s(this.fmt(a))}">`},c=(this.getAttribute(`marks`)??``).split(/[,،]/).map(e=>e.trim()).filter(Boolean).map(Number),l=this.getAttribute(`show-value`)!==`false`;this.innerHTML=`<div class="k-slider"${t?` data-range=""`:``}>${e||l?`<div class="k-slider__head">${e?`<span class="k-label" id="${this.key}-label">${s(e)}</span>`:``}${l?`<span class="k-slider__value" aria-hidden="true">${s(t?`${this.fmt(this.lo)} تا ${this.fmt(this.hi)}`:this.fmt(this.hi))}</span>`:``}</div>`:``}<div class="k-slider__track" style="--_from: ${t?i(this.lo):`0%`}; --_to: ${i(this.hi)}"><span class="k-slider__fill" aria-hidden="true"></span>${t?o(`lo`):``}${o(`hi`)}</div>${c.length?`<div class="k-slider__marks" aria-hidden="true">${c.map(e=>`<span>${s(this.fmt(e))}</span>`).join(``)}</div>`:``}</div>`,this.rendered=!0,this.querySelectorAll(`.k-slider__input`).forEach(e=>e.addEventListener(`input`,()=>{let n=Number(e.value);t?e.dataset.which===`lo`?this.lo=Math.min(n,this.hi):this.hi=Math.max(n,this.lo):this.hi=n,e.value=String(e.dataset.which===`lo`?this.lo:this.hi),e.setAttribute(`aria-valuetext`,this.fmt(Number(e.value)));let r=this.querySelector(`.k-slider__track`);r.style.setProperty(`--_from`,t?i(this.lo):`0%`),r.style.setProperty(`--_to`,i(this.hi));let o=this.querySelector(`.k-slider__value`);o&&(o.textContent=t?`${this.fmt(this.lo)} تا ${this.fmt(this.hi)}`:this.fmt(this.hi)),a(this,`kashi-change`,{value:this.value})}))}};M.observedAttributes=[`label`,`min`,`max`,`step`,`value`,`range`,`show-value`,`marks`,`unit`,`disabled`,`name`];var N=class extends c{constructor(){super(...arguments),this.built=!1}connectedCallback(){o(()=>this.isConnected&&!this.built&&this.build())}attributeChangedCallback(){if(!this.built)return;let e=this.getAttribute(`label`);e&&this.setAttribute(`aria-label`,e),this.sync(!1)}get value(){return[...this.querySelectorAll(`.k-chip[aria-pressed="true"]`)].map(e=>e.dataset.value??``)}set value(e){this.querySelectorAll(`.k-chip`).forEach(t=>t.setAttribute(`aria-pressed`,String(e.includes(t.dataset.value??``)))),this.sync(!1)}build(){this.built=!0,this.classList.add(`k-chips`),this.setAttribute(`role`,`group`);let e=this.getAttribute(`label`);e&&this.setAttribute(`aria-label`,e),this.querySelectorAll(`:scope > button`).forEach(e=>{var t;e.type=`button`,e.classList.add(`k-chip`),(t=e.dataset).value||(t.value=e.textContent?.trim()??``),e.setAttribute(`aria-pressed`,String(e.hasAttribute(`data-pressed`)||e.getAttribute(`aria-pressed`)===`true`)),e.insertAdjacentHTML(`afterbegin`,`<svg class="k-chip__check" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m5 10.5 3.2 3L15 7"/></svg>`),e.dataset.count&&e.insertAdjacentHTML(`beforeend`,`<span class="k-chip__count">${u(e.dataset.count)}</span>`)}),this.addEventListener(`click`,e=>{let t=e.target.closest(`.k-chip`);if(!t||t.disabled)return;let n=t.getAttribute(`aria-pressed`)!==`true`;r(this,`single`)&&this.querySelectorAll(`.k-chip`).forEach(e=>e.setAttribute(`aria-pressed`,`false`)),t.setAttribute(`aria-pressed`,String(n)),this.sync(!0)}),this.sync(!1)}sync(e){k(this,this.getAttribute(`name`),this.value),e&&a(this,`kashi-change`,{value:this.value})}};N.observedAttributes=[`label`,`single`,`name`];const P=[[`حداقل ${u(8)} نویسه`,e=>e.length>=8],[`حروف بزرگ و کوچک انگلیسی`,e=>/[a-z]/.test(e)&&/[A-Z]/.test(e)],[`دست‌کم یک عدد`,e=>/\d/.test(e)],[`دست‌کم یک نماد، مثل ! یا @`,e=>/[^A-Za-z0-9\s؀-ۿ]/.test(e)]];var F=class extends c{constructor(){super(...arguments),this.target=null,this.onInput=()=>this.render(this.target?.value??``)}connectedCallback(){o(()=>{this.isConnected&&(this.attach(),this.render(``))})}disconnectedCallback(){this.target?.removeEventListener(`input`,this.onInput)}attributeChangedCallback(){this.isConnected&&(this.attach(),this.render(this.target?.value??``))}attach(){this.target?.removeEventListener(`input`,this.onInput);let e=this.getAttribute(`for`),t=e?document.getElementById(e):null;if(this.target=t instanceof HTMLInputElement?t:t?.querySelector(`input`)??null,this.target?.addEventListener(`input`,this.onInput),this.target){this.id||=n(`kashi-strength`);let e=(this.target.getAttribute(`aria-describedby`)??``).split(` `).filter(Boolean);e.includes(this.id)||this.target.setAttribute(`aria-describedby`,[...e,this.id].join(` `))}}score(e){let t=P.filter(([,t])=>t(e)).length;return e?Math.max(1,Math.round(t/P.length*4)):0}render(e){let t=this.score(e),n=[`ضعیف`,`متوسط`,`خوب`,`قوی`],r=/[؀-ۿ]/.test(e);this.innerHTML=`<div class="k-strength" data-score="${t}"><div class="k-strength__bars" aria-hidden="true">${`<span class="k-strength__bar"></span>`.repeat(4)}</div><p class="k-strength__label" aria-live="polite" style="margin: 0">${t?`قدرت رمز: <strong>${n[t-1]}</strong>`:``}</p>${r?`<p class="k-hint k-hint--error" role="alert">رمز حروف فارسی دارد؛ شاید صفحه‌کلید روی فارسی مانده است.</p>`:``}${this.getAttribute(`show-rules`)===`false`?``:`<ul class="k-strength__rules">${P.map(([t,n])=>{let r=n(e);return`<li class="k-strength__rule"${r?` data-met=""`:``}>${r?D:`<svg viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="2.5" fill="currentColor"/></svg>`}<span>${t}<span class="k-sr-only">${r?`، رعایت شده`:`، رعایت نشده`}</span></span></li>`}).join(``)}</ul>`}</div>`}};F.observedAttributes=[`for`,`show-rules`];var I=class extends c{constructor(){super(...arguments),this.key=n(`kashi-text`),this.rendered=!1,this.valueSet=!1,this.text=``}connectedCallback(){!this.rendered&&!this.valueSet&&(this.text=this.getAttribute(`value`)??``),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=n??``:this.render())}get value(){return this.text}set value(e){this.valueSet=!0,this.text=String(e??``),this.rendered&&(this.control.value=this.text,this.paint())}focus(e){this.control?.focus(e)}render(){let e=this.key,n=this.getAttribute(`aria-label`),r=this.hasAttribute(`label`)?this.getAttribute(`label`):n?null:this.defaultLabel,i=this.getAttribute(`name`),o=`id="${e}" class="k-input__control" dir="auto"${i?` name="${s(i)}"`:``}${this.hasAttribute(`required`)?` required`:``}${this.hasAttribute(`disabled`)?` disabled`:``} placeholder="${s(this.getAttribute(`placeholder`)??``)}"${!r&&n?` aria-label="${s(n)}"`:``}`,c=this.multiline?`<div class="k-input k-input--textarea"><textarea ${o} rows="${Number(this.getAttribute(`rows`))||4}"></textarea></div>`:`<div class="k-input"><input ${o}></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,t({id:e,label:r,required:this.hasAttribute(`required`),control:c})),this.control=this.querySelector(`.k-input__control`),this.control.value=this.text,this.control.addEventListener(`input`,()=>{this.text=this.control.value,this.paint(),a(this,`kashi-change`,{value:this.text})}),this.rendered=!0,this.paint()}paint(){let e=this.querySelector(`:scope > .k-field`);i(e,this.control,this.key,this.getAttribute(`error`),null);let t=this.hint();if(e.querySelector(`.k-field__hint-row[data-extra]`)?.remove(),t){e.insertAdjacentHTML(`beforeend`,`<div class="k-field__hint-row" data-extra><div class="k-field__hints"><p class="k-hint" id="${this.key}-hint">${t}</p></div></div>`);let n=(this.control.getAttribute(`aria-describedby`)??``).split(` `).filter(Boolean);this.control.setAttribute(`aria-describedby`,[...n,`${this.key}-hint`].join(` `))}}replace(e){this.text=e,this.control.value=e,this.paint(),this.control.focus(),a(this,`kashi-change`,{value:e})}};const L={arabic:`حرف عربی`,zwnj:`نیم‌فاصله`,punctuation:`علامت`,digits:`رقم`,spacing:`فاصله`};var R=class extends I{constructor(){super(...arguments),this.multiline=!0,this.defaultLabel=`متن`}render(){super.render(),this.control.addEventListener(`blur`,()=>{let e=this.result();r(this,`fix-on-blur`)&&e.count&&this.replace(e.text)}),this.addEventListener(`click`,e=>{e.target.closest(`[data-fix]`)&&this.replace(this.result().text)})}result(){return p(this.text,{digits:this.getAttribute(`fix-digits`)!==`false`})}hint(){if(!this.text.trim())return this.getAttribute(`hint`)?s(this.getAttribute(`hint`)):null;let e=this.result();if(!e.count)return`<span class="k-textfix" data-state="clean"><span class="k-textfix__text">نگارش متن درست است.</span></span>`;let t=Object.keys(L).filter(t=>e.fixes[t]).map(t=>`${u(e.fixes[t])} ${L[t]}`).join(`، `);return`<span class="k-textfix" data-state="fix"><span class="k-textfix__text">${u(e.count)} مورد قابل اصلاح: ${t}</span><button type="button" class="k-btn k-btn--tertiary k-btn--xs" data-fix>اصلاح نگارش</button></span>`}};R.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`required`,`disabled`,`name`,`value`,`rows`,`fix-on-blur`,`fix-digits`,`aria-label`];var z=class extends I{constructor(){super(...arguments),this.multiline=!1,this.defaultLabel=`متن`}render(){super.render(),this.addEventListener(`click`,e=>{e.target.closest(`[data-fix]`)&&this.replace(T(this.text))})}hint(){let e=this.text,t=/[a-z]/i.test(e)&&!/[؀-ۿ]/.test(e);return(this.getAttribute(`suggest`)===`always`?t:E(e))?`<span class="k-kbfix" role="status">منظورتان <button type="button" class="k-kbfix__btn" data-fix>«${s(T(e))}»</button> بود؟</span>`:this.getAttribute(`hint`)?s(this.getAttribute(`hint`)):null}};z.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`required`,`disabled`,`name`,`value`,`suggest`,`aria-label`];const B=e=>e.hours*60+e.minutes,V=e=>({hours:Math.floor(e/60),minutes:e%60});var H=class extends c{constructor(){super(...arguments),this.current=null,this.invalid=!1,this.valueSet=!1,this.rendered=!1,this.key=n(`kashi-time`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.current=this.normal(this.getAttribute(`value`))),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=n??``:this.render())}get value(){return this.current??``}set value(e){this.valueSet=!0,this.current=this.normal(e),this.invalid=!1,this.rendered&&this.paint()}normal(e){let t=e?m(e):null;return t?h(t):null}show(e){return e?this.getAttribute(`digits`)===`latin`?e:u(e):``}get lo(){let e=m(this.getAttribute(`min`)??``);return e?B(e):0}get hi(){let e=m(this.getAttribute(`max`)??``);return e?B(e):1439}render(){let e=this.key,n=this.getAttribute(`aria-label`),r=this.hasAttribute(`label`)?this.getAttribute(`label`):n?null:`ساعت`,i=this.getAttribute(`digits`)!==`latin`,a=`<div class="k-input"><input id="${e}" class="k-input__control" type="text" inputmode="numeric" dir="ltr" autocomplete="off" placeholder="${s(this.getAttribute(`placeholder`)??(i?`۰۹:۳۰`:`09:30`))}"${this.hasAttribute(`required`)?` required`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${!r&&n?` aria-label="${s(n)}"`:``}><span class="k-input__addon"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="10" cy="10" r="7"/><path d="M10 6v4l2.5 2"/></svg></span></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,t({id:e,label:r,required:this.hasAttribute(`required`),control:a})),this.input=this.querySelector(`input.k-input__control`),this.input.addEventListener(`blur`,()=>this.commitText()),this.input.addEventListener(`keydown`,e=>{if(e.key===`Enter`&&this.commitText(),e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;e.preventDefault();let t=Number(this.getAttribute(`step`))||15,n=m(this.input.value)??m(this.current??``)??V(this.lo),r=B(n),i=e.key===`ArrowUp`?Math.floor(r/t)*t+t:Math.ceil(r/t)*t-t;this.commit(V(Math.min(this.hi,Math.max(this.lo,i))))}),this.rendered=!0,this.paint()}commitText(){let e=this.input.value.trim();if(!e)return this.commit(null);let t=m(e);if(!t)this.invalid=`format`;else if(B(t)<this.lo||B(t)>this.hi)this.invalid=`range`;else return this.commit(t);this.paint(!1)}commit(e){let t=e?h(e):null,n=t!==this.current;this.current=t,this.invalid=!1,this.paint(),n&&a(this,`kashi-change`,{value:t??``})}paint(e=!0){e&&(this.input.value=this.show(this.current));let t=this.invalid===`range`?`ساعت باید بین ${this.show(h(V(this.lo)))} و ${this.show(h(V(this.hi)))} باشد.`:this.invalid?`ساعت معتبر نیست؛ آن را به شکل ۰۹:۳۰ وارد کنید.`:null;this.input.setCustomValidity(t??``),i(this.querySelector(`:scope > .k-field`),this.input,this.key,this.getAttribute(`error`)||t,this.getAttribute(`hint`)),l(this,this.getAttribute(`name`),this.current??``)}};H.observedAttributes=[`label`,`hint`,`error`,`value`,`min`,`max`,`step`,`digits`,`required`,`disabled`,`name`,`placeholder`,`aria-label`];const U={first:``,letter:``,middle:``,region:``};var W=class extends c{constructor(){super(...arguments),this.plate={...U},this.touched=!1,this.valueSet=!1,this.rendered=!1,this.key=n(`kashi-plate`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.plate=this.parse(this.getAttribute(`value`))),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.value=this.parse(n):this.render())}parse(e){let[t=``,n=``,r=``,i=``]=(e??``).split(`-`);return{first:d(t),letter:n,middle:d(r),region:d(i)}}get value(){return{...this.plate}}set value(e){this.valueSet=!0,this.plate={...U,...e},this.rendered&&this.render()}get valid(){return b(this.plate)}render(){let e=this.key,n=this.plate,r=this.hasAttribute(`disabled`)?` disabled`:``,i=(t,i,a,o=``,s=!1)=>`<input${s?` id="${e}-first"`:``} class="k-plate__seg ${o}" data-key="${t}" data-len="${i}" inputmode="numeric" autocomplete="off" aria-label="${a}" placeholder="${u(`0`.repeat(i))}" value="${u(n[t])}"${r}>`,o=this.getAttribute(`label`)??`پلاک خودرو`,c=`<div class="k-plate" role="group" aria-label="${s(o)}" data-type="${y(n.letter)}"><span class="k-plate__flag" aria-hidden="true"><span class="k-plate__flag-colors"></span>I.R.<br>IRAN</span>${i(`first`,2,`دو رقم اول پلاک`,``,!0)}<select class="k-plate__letter" data-key="letter" aria-label="حرف پلاک"${r}><option value="">–</option>${_.map(e=>`<option value="${e}"${e===n.letter?` selected`:``}>${e===`ه`?`هـ`:e}</option>`).join(``)}</select>${i(`middle`,3,`سه رقم پلاک`,`k-plate__seg--3`)}<span class="k-plate__region"><span class="k-plate__region-label" aria-hidden="true">ایران</span>${i(`region`,2,`کد استان`)}</span></div><span class="k-sr-only" aria-live="polite"></span>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,t({id:`${e}-first`,label:o,control:c}));let l=[...this.querySelectorAll(`[data-key]`)];l.forEach((e,t)=>{e.addEventListener(e instanceof HTMLSelectElement?`change`:`input`,()=>{let n=e.dataset.key;if(e instanceof HTMLSelectElement)this.plate.letter=e.value,e.value&&l[t+1]?.focus();else{let r=Number(e.dataset.len),i=d(e.value);n===`middle`&&i.length>r&&(this.plate.region=(this.plate.region+i.slice(r)).slice(0,2)),this.plate[n]=i.slice(0,r),e.value=u(this.plate[n]),this.plate[n].length===r&&l[t+1]?.focus()}this.paint(),a(this,`kashi-change`,{value:this.value,valid:this.valid})}),e.addEventListener(`keydown`,n=>{n.key===`Backspace`&&!e.value&&l[t-1]?.focus()})});let f=this.querySelector(`.k-plate`);f.addEventListener(`focusout`,e=>{f.contains(e.relatedTarget)||(this.touched=!0,this.paint())}),this.rendered=!0,this.paint()}paint(){let e=this.plate,t=this.querySelector(`.k-plate`),n=this.querySelector(`[data-key="region"]`);n.value!==u(e.region)&&(n.value=u(e.region)),t.dataset.type=y(e.letter);let r=e.first.length===2&&!!e.letter&&e.middle.length===3&&e.region.length===2,a=(this.touched||r)&&Object.values(e).some(Boolean)&&!this.valid,o=this.getAttribute(`error`)||(a?`پلاک خودرو معتبر نیست.`:null);t.toggleAttribute(`data-invalid`,!!o),i(this.querySelector(`:scope > .k-field`),t,this.key,o,this.getAttribute(`hint`)),this.querySelector(`.k-field > .k-sr-only`).textContent=this.valid?x(e):``;let c=this.getAttribute(`name`);if(this.querySelectorAll(`:scope > input[type=hidden]`).forEach(e=>e.remove()),c)for(let t of[`first`,`letter`,`middle`,`region`])this.insertAdjacentHTML(`beforeend`,`<input type="hidden" name="${s(`${c}_${t}`)}" value="${s(e[t])}">`)}};W.observedAttributes=[`label`,`hint`,`error`,`name`,`disabled`,`value`];var G=class extends c{constructor(){super(...arguments),this.text=``,this.editing=!1,this.valueSet=!1,this.rendered=!1}connectedCallback(){!this.rendered&&!this.valueSet&&(this.text=this.getAttribute(`value`)??this.textContent?.trim()??``),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`&&(this.text=n??``),this.editing||this.render())}get value(){return this.text}set value(e){this.valueSet=!0,this.text=String(e??``),this.rendered&&!this.editing&&this.render()}render(e=!1){let t=this.getAttribute(`label`)??`متن`;this.rendered=!0,this.editing=!1,this.innerHTML=`<span class="k-inline-edit"><button type="button" class="k-inline-edit__view" aria-label="${s(`${t}: ${this.text||`خالی`}، ویرایش`)}">${this.text?s(this.text):`<span class="k-inline-edit__placeholder">${s(this.getAttribute(`placeholder`)??`خالی`)}</span>`}<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m13.5 3.5 3 3L7 16H4v-3Z"/></svg></button></span>`;let n=this.querySelector(`button`);n.addEventListener(`click`,()=>this.edit()),e&&n.focus()}edit(e,t=this.text){this.editing=!0;let r=this.getAttribute(`label`)??`متن`,i=n(`kashi-ie-err`);this.innerHTML=`<span class="k-inline-edit"><span class="k-field" style="gap: 4px"><span class="k-input"${e?` data-state="invalid"`:``}><input class="k-input__control" aria-label="${s(r)}" placeholder="${s(this.getAttribute(`placeholder`)??``)}"${e?` aria-invalid="true" aria-describedby="${i}"`:``}></span>${e?`<span class="k-hint k-hint--error" id="${i}">${s(e)}</span>`:``}</span><span class="k-inline-edit__actions"><button type="button" class="k-btn k-btn--primary k-btn--icon k-btn--sm" data-save aria-label="ثبت">${D}</button><button type="button" class="k-btn k-btn--secondary k-btn--icon k-btn--sm" data-cancel aria-label="انصراف">${O}</button></span></span>`;let a=this.querySelector(`input`);a.value=t,a.focus(),a.select(),a.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),this.commit(a.value)):e.key===`Escape`&&(e.preventDefault(),this.render(!0))}),this.querySelector(`[data-save]`).addEventListener(`click`,()=>this.commit(a.value)),this.querySelector(`[data-cancel]`).addEventListener(`click`,()=>this.render(!0))}async commit(e){let t=e.trim(),n=this.validate?.(t);if(n)return this.edit(n,e);if(t===this.text)return this.render(!0);let r=this.text,i=null;if(a(this,`kashi-save`,{value:t,wait:e=>i=e}),this.text=t,i){this.querySelector(`[data-save]`)?.setAttribute(`aria-busy`,`true`);try{await i}catch{return this.text=r,this.edit(`ذخیره نشد؛ دوباره امتحان کنید.`,e)}}this.render(!0),a(this,`kashi-change`,{value:t})}};G.observedAttributes=[`value`,`label`,`placeholder`],e(`kashi-multi-select`,j,`block`),e(`kashi-slider`,M,`block`),e(`kashi-chip-group`,N),e(`kashi-password-strength`,F,`block`),e(`kashi-persian-textarea`,R,`block`),e(`kashi-keyboard-fix`,z,`block`),e(`kashi-time-input`,H,`block`),e(`kashi-plate-input`,W,`block`),e(`kashi-inline-edit`,G);export{N as KashiChipGroup,G as KashiInlineEdit,z as KashiKeyboardFix,j as KashiMultiSelect,F as KashiPasswordStrength,R as KashiPersianTextarea,W as KashiPlateInput,M as KashiSlider,H as KashiTimeInput};
@@ -0,0 +1 @@
1
+ import{d as e}from"./jalali-BiM5Kfep.js";const t={"1-1":`عید نوروز`,"1-2":`عید نوروز`,"1-3":`عید نوروز`,"1-4":`عید نوروز`,"1-12":`روز جمهوری اسلامی`,"1-13":`روز طبیعت`,"3-14":`رحلت امام خمینی`,"3-15":`قیام ۱۵ خرداد`,"11-22":`پیروزی انقلاب اسلامی`,"12-29":`ملی شدن صنعت نفت`};function n(n,{extra:r={},friday:i=!0}={}){let{jm:a,jd:o}=e(n);return r[`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,`0`)}-${String(n.getDate()).padStart(2,`0`)}`]??r[`${a}-${o}`]??t[`${a}-${o}`]??(i&&n.getDay()===5?`جمعه`:null)}export{n as t};
@@ -1 +1 @@
1
- import{a as e,c as t,d as n,i as r,l as i,o as a,s as o,t as s,u as c}from"./base-Cmq7zeIG.js";import{i as l,n as u,r as d,t as f}from"./digits-DE1YGT94.js";import{t as p}from"./words-9OdzG7y6.js";function m(e){let t=u(e);if(!/^\d{10}$/.test(t)||/^(\d)\1{9}$/.test(t))return!1;let n=Number(t[9]),r=0;for(let e=0;e<9;e++)r+=Number(t[e])*(10-e);let i=r%11;return i<2?n===i:n===11-i}const h={603799:{name:`بانک ملی`,slug:`melli`},589210:{name:`بانک سپه`,slug:`sepah`},627648:{name:`بانک توسعه صادرات`,slug:`edbi`},627961:{name:`بانک صنعت و معدن`,slug:`bim`},603770:{name:`بانک کشاورزی`,slug:`keshavarzi`},639217:{name:`بانک کشاورزی`,slug:`keshavarzi`},628023:{name:`بانک مسکن`,slug:`maskan`},627760:{name:`پست بانک`,slug:`postbank`},502908:{name:`بانک توسعه تعاون`,slug:`tosee-taavon`},627412:{name:`بانک اقتصاد نوین`,slug:`eghtesad-novin`},622106:{name:`بانک پارسیان`,slug:`parsian`},639194:{name:`بانک پارسیان`,slug:`parsian`},627884:{name:`بانک پارسیان`,slug:`parsian`},502229:{name:`بانک پاسارگاد`,slug:`pasargad`},639347:{name:`بانک پاسارگاد`,slug:`pasargad`},627488:{name:`بانک کارآفرین`,slug:`karafarin`},502910:{name:`بانک کارآفرین`,slug:`karafarin`},621986:{name:`بانک سامان`,slug:`saman`},639346:{name:`بانک سینا`,slug:`sina`},639607:{name:`بانک سرمایه`,slug:`sarmayeh`},636214:{name:`بانک آینده`,slug:`ayandeh`},502806:{name:`بانک شهر`,slug:`shahr`},504706:{name:`بانک شهر`,slug:`shahr`},502938:{name:`بانک دی`,slug:`dey`},603769:{name:`بانک صادرات`,slug:`saderat`},610433:{name:`بانک ملت`,slug:`mellat`},991975:{name:`بانک ملت`,slug:`mellat`},627353:{name:`بانک تجارت`,slug:`tejarat`},585983:{name:`بانک تجارت`,slug:`tejarat`},589463:{name:`بانک رفاه`,slug:`refah`},505785:{name:`بانک ایران زمین`,slug:`iran-zamin`},606373:{name:`بانک قرض‌الحسنه مهر ایران`,slug:`mehr-iran`},505416:{name:`بانک گردشگری`,slug:`gardeshgari`},636795:{name:`بانک مرکزی`,slug:`markazi`},585947:{name:`بانک خاورمیانه`,slug:`khavarmianeh`},505809:{name:`بانک خاورمیانه`,slug:`khavarmianeh`},507677:{name:`موسسه اعتباری نور`,slug:`noor`},606256:{name:`موسسه اعتباری ملل`,slug:`melal`},628157:{name:`موسسه اعتباری توسعه`,slug:`tosee`},504172:{name:`بانک قرض‌الحسنه رسالت`,slug:`resalat`},627381:{name:`بانک انصار`,slug:`ansar`},639599:{name:`بانک قوامین`,slug:`ghavamin`},636949:{name:`بانک حکمت ایرانیان`,slug:`hekmat`},505801:{name:`موسسه اعتباری کوثر`,slug:`kosar`},639370:{name:`بانک مهر اقتصاد`,slug:`mehr-eghtesad`}};function g(e){let t=0;for(let n=0;n<e.length;n++){let r=Number(e[e.length-1-n]);n%2==1&&(r*=2,r>9&&(r-=9)),t+=r}return t%10==0}function _(e){let t=u(e);return/^\d{16}$/.test(t)&&g(t)}function v(e){let t=u(e);return t.length>=6?h[t.slice(0,6)]??null:null}function y(e){return u(e).slice(0,16).replace(/(\d{4})(?=\d)/g,`$1 `)}const b={"010":{name:`بانک مرکزی`,slug:`markazi`},"011":{name:`بانک صنعت و معدن`,slug:`bim`},"012":{name:`بانک ملت`,slug:`mellat`},"013":{name:`بانک رفاه`,slug:`refah`},"014":{name:`بانک مسکن`,slug:`maskan`},"015":{name:`بانک سپه`,slug:`sepah`},"016":{name:`بانک کشاورزی`,slug:`keshavarzi`},"017":{name:`بانک ملی`,slug:`melli`},"018":{name:`بانک تجارت`,slug:`tejarat`},"019":{name:`بانک صادرات`,slug:`saderat`},"020":{name:`بانک توسعه صادرات`,slug:`edbi`},"021":{name:`پست بانک`,slug:`postbank`},"022":{name:`بانک توسعه تعاون`,slug:`tosee-taavon`},"053":{name:`بانک کارآفرین`,slug:`karafarin`},"054":{name:`بانک پارسیان`,slug:`parsian`},"055":{name:`بانک اقتصاد نوین`,slug:`eghtesad-novin`},"056":{name:`بانک سامان`,slug:`saman`},"057":{name:`بانک پاسارگاد`,slug:`pasargad`},"058":{name:`بانک سرمایه`,slug:`sarmayeh`},"059":{name:`بانک سینا`,slug:`sina`},"060":{name:`بانک قرض‌الحسنه مهر ایران`,slug:`mehr-iran`},"061":{name:`بانک شهر`,slug:`shahr`},"062":{name:`بانک آینده`,slug:`ayandeh`},"064":{name:`بانک گردشگری`,slug:`gardeshgari`},"066":{name:`بانک دی`,slug:`dey`},"069":{name:`بانک ایران زمین`,slug:`iran-zamin`},"070":{name:`بانک قرض‌الحسنه رسالت`,slug:`resalat`},"078":{name:`بانک خاورمیانه`,slug:`khavarmianeh`}};function x(e){return d(e).toUpperCase().replace(/^\s*IR/,``).replace(/\D/g,``).slice(0,24)}function S(e){let t=0;for(let n=0;n<e.length;n+=7)t=Number(String(t)+e.slice(n,n+7))%97;return t}function C(e){let t=d(e).toUpperCase().replace(/[\s-]/g,``),n=t.startsWith(`IR`)?t.slice(2):t;return/^\d{24}$/.test(n)?S(n.slice(2)+`1827`+n.slice(0,2))===1:!1}function w(e){let t=x(e);return t.length>=5?b[t.slice(2,5)]??null:null}function T(e){let t=x(e);return t?`IR${t}`.replace(/(.{4})(?=.)/g,`$1 `):``}const E={name:`همراه اول`,slug:`mci`},D={name:`ایرانسل`,slug:`irancell`},O={name:`رایتل`,slug:`rightel`},k={...Object.fromEntries([`10`,`11`,`12`,`13`,`14`,`15`,`16`,`17`,`18`,`19`,`90`,`91`,`92`,`93`,`94`].map(e=>[e,E])),...Object.fromEntries([`01`,`02`,`03`,`04`,`05`,`30`,`33`,`35`,`36`,`37`,`38`,`39`,`41`].map(e=>[e,D])),...Object.fromEntries([`20`,`21`,`22`].map(e=>[e,O]))};function A(e){let t=u(e);return t.startsWith(`0098`)?t=`0`+t.slice(4):t.startsWith(`98`)&&t.length===12?t=`0`+t.slice(2):t.startsWith(`9`)&&t.length===10&&(t=`0`+t),t}function j(e){return/^09\d{9}$/.test(A(e))}function M(e){let t=A(e);return t.length>=4&&t.startsWith(`09`)?k[t.slice(2,4)]??null:null}function N(e){let t=A(e).slice(0,11);return[t.slice(0,4),t.slice(4,7),t.slice(7,11)].filter(Boolean).join(` `)}function P(e){let t=u(e);return/^(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}$/.test(t)}function F(e){let t=u(e).slice(0,10);return t.length>5?`${t.slice(0,5)}-${t.slice(5)}`:t}const I={11:`مازندران`,13:`گیلان`,17:`گلستان`,21:`تهران`,23:`سمنان`,24:`زنجان`,25:`قم`,26:`البرز`,28:`قزوین`,31:`اصفهان`,34:`کرمان`,35:`یزد`,38:`چهارمحال و بختیاری`,41:`آذربایجان شرقی`,44:`آذربایجان غربی`,45:`اردبیل`,51:`خراسان رضوی`,54:`سیستان و بلوچستان`,56:`خراسان جنوبی`,58:`خراسان شمالی`,61:`خوزستان`,66:`لرستان`,71:`فارس`,74:`کهگیلویه و بویراحمد`,76:`هرمزگان`,77:`بوشهر`,81:`همدان`,83:`کرمانشاه`,84:`ایلام`,86:`مرکزی`,87:`کردستان`};function L(e){let t=u(e);return t.startsWith(`0098`)?t=`0`+t.slice(4):t.startsWith(`98`)&&t.length===12?t=`0`+t.slice(2):/^[1-8]/.test(t)&&t.length===10&&(t=`0`+t),t}function R(e){let t=L(e);return t.length>=3&&t[0]===`0`?I[t.slice(1,3)]??null:null}function z(e){let t=L(e);return/^0\d{2}[2-9]\d{7}$/.test(t)&&R(t)!==null}function B(e){let t=L(e).slice(0,11);return[t.slice(0,3),t.slice(3,7),t.slice(7,11)].filter(Boolean).join(` `)}const V=[29,27,23,19,17,29,27,23,19,17];function H(e){let t=u(e);if(!/^\d{11}$/.test(t)||/^0+$/.test(t.slice(3,9)))return!1;let n=[...t].map(Number),r=n[9]+2,i=0;for(let e=0;e<10;e++)i+=(n[e]+r)*V[e];let a=i%11;return(a===10?0:a)===n[10]}const U=e=>l(e);function W(e,t){if(t===0)return e.search(/[0-9۰-۹]/)===-1?e.length:e.search(/[0-9۰-۹]/);let n=0;for(let r=0;r<e.length;r++)if(/[0-9۰-۹]/.test(e[r])&&++n===t)return r+1;return e.length}var G=class extends s{constructor(){super(...arguments),this.raw=``,this.touched=!1,this.valueSet=!1,this.rendered=!1,this.key=n(`kashi-in`),this.logoSlug=null}connectedCallback(){if(!this.rendered&&!this.valueSet&&(this.raw=this.clean(this.getAttribute(`value`)??``)),Object.prototype.hasOwnProperty.call(this,`value`)){let e=this.value;delete this.value,this.raw=this.clean(String(e??``))}this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.setRaw(this.clean(n??``),!1):this.render())}get value(){return this.kind.submit?this.kind.submit(this.raw):this.raw}set value(e){this.valueSet=!0,this.setRaw(this.clean(String(e??``)),!1)}get valid(){return this.isValid()}isValid(){return this.kind.valid(this.raw)}focus(e){this.input?.focus(e)}clean(e){let t=this.kind;return(t.normalize??(e=>e))(u(e)).slice(0,t.maxDigits)}get digits(){let e=this.getAttribute(`digits`);return e===`fa`||e===`latin`?e:this.kind.digits}shown(){let e=this.kind.format(this.raw);return this.digits===`fa`?U(e):e}render(){let e=this.kind,n=this.key,r=this.getAttribute(`aria-label`),i=this.hasAttribute(`label`)?this.getAttribute(`label`):r?null:e.label,a=this.getAttribute(`size`),s=this.hasAttribute(`required`),c=this.hasAttribute(`disabled`),l=this.getAttribute(`placeholder`)??e.placeholder[this.digits],u=`<div class="k-input${a===`sm`||a===`lg`?` k-input--${a}`:``}" data-size="${a??`md`}"${c?` data-state="disabled"`:``}><input id="${n}" class="k-input__control" type="${e.type??`text`}" inputmode="${e.inputMode??`numeric`}" autocomplete="${e.autocomplete??`off`}" dir="ltr" spellcheck="false" placeholder="${o(l)}"${s?` required`:``}${c?` disabled`:``}${this.hasAttribute(`readonly`)?` readonly`:``}${!i&&r?` aria-label="${o(r)}"`:``}></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,t({id:n,label:i,required:s,control:u})),this.input=this.querySelector(`input.k-input__control`),this.input.addEventListener(`input`,()=>this.onInput()),this.input.addEventListener(`blur`,()=>{this.touched=!0,this.paint()}),this.rendered=!0,this.paint()}onInput(){let e=this.input,t=e.value.slice(0,e.selectionStart??e.value.length),n=this.clean(e.value),r=Math.min(u(t).length,n.length);if(this.setRaw(n,!0),e.ownerDocument.activeElement===e){let t=W(e.value,r);e.setSelectionRange(t,t)}}setRaw(e,t){let n=e!==this.raw;this.raw=e,this.rendered&&(this.paint(),t&&n&&a(this,`kashi-change`,{value:this.value,valid:this.isValid(),...this.kind.detail?.(this.raw)}))}invalidText(e){return this.raw.length>0&&(e||this.raw.length===this.kind.maxDigits)&&!this.isValid()?this.getAttribute(`invalid-message`)??this.kind.invalidMessage:null}hintText(){return this.getAttribute(`hint`)}paint(){let e=this.input,t=this.shown();e.value!==t&&(e.value=t);let n=e.parentElement;n.querySelector(`:scope > .k-input__addon`)?.remove();let a=r(this,`show-meta`,!0)?this.kind.meta?.(this.raw,this):null,s=`${this.key}-meta`;if(a){let e=document.createElement(`span`);e.className=`k-input__addon`,e.innerHTML=a.bank?`<span class="k-bank" id="${s}">${o(a.text)}</span>`:`<span class="k-input__meta" id="${s}">${o(a.text)}</span>`,n.append(e),a.bank&&r(this,`bank-logo`,!0)&&this.loadLogo(a.bank,e.firstElementChild)}let l=this.getAttribute(`error`)||this.invalidText(this.touched);e.setCustomValidity(this.raw&&!this.isValid()?this.invalidText(!0)??``:``),i(this.querySelector(`:scope > .k-field`),e,this.key,l,this.hintText(),a?s:null),c(this,this.getAttribute(`name`),this.raw?this.value:``)}loadLogo(e,t){this.logoSlug=e.slug,import(`./dist-D670Gw0K.js`).then(n=>{let r=n.bankLogoDataUri(e.slug);if(!r||this.logoSlug!==e.slug||!t.isConnected)return;let i=document.createElement(`img`);i.className=`k-bank__logo`,i.src=r,i.alt=``,i.width=i.height=24,t.prepend(i)}).catch(()=>{})}};G.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`required`,`disabled`,`readonly`,`digits`,`invalid-message`,`name`,`value`,`size`,`aria-label`,`show-meta`,`bank-logo`];var K=class extends G{constructor(){super(...arguments),this.kind={label:`کد ملی`,maxDigits:10,format:e=>e,valid:e=>m(e),invalidMessage:`کد ملی معتبر نیست.`,placeholder:{fa:`۰۰۰۰۰۰۰۰۰۰`,latin:`0000000000`},digits:`fa`}}},q=class extends G{constructor(){super(...arguments),this.kind={label:`شناسهٔ ملی شرکت`,maxDigits:11,format:e=>e,valid:e=>H(e),invalidMessage:`شناسهٔ ملی معتبر نیست.`,placeholder:{fa:`۰۰۰۰۰۰۰۰۰۰۰`,latin:`00000000000`},digits:`fa`}}},J=class extends G{constructor(){super(...arguments),this.kind={label:`شمارهٔ موبایل`,maxDigits:11,normalize:A,format:N,valid:e=>j(e),invalidMessage:`شماره موبایل معتبر نیست.`,placeholder:{fa:`۰۹۱۲ ۳۴۵ ۶۷۸۹`,latin:`0912 345 6789`},digits:`fa`,type:`tel`,inputMode:`tel`,autocomplete:`tel-national`,meta:e=>{let t=M(e);return t?{text:t.name}:null},detail:e=>({operator:M(e)?.name??null})}}},Y=class extends G{constructor(){super(...arguments),this.kind={label:`تلفن ثابت`,maxDigits:11,normalize:L,format:B,valid:e=>z(e),invalidMessage:`شمارهٔ تلفن ثابت معتبر نیست.`,placeholder:{fa:`۰۲۱ ۸۸۷۷ ۶۶۵۵`,latin:`021 8877 6655`},digits:`fa`,type:`tel`,inputMode:`tel`,autocomplete:`tel-national`,meta:e=>{let t=R(e);return t?{text:t}:null},detail:e=>({province:R(e)})}}},X=class extends G{constructor(){super(...arguments),this.kind={label:`شمارهٔ کارت`,maxDigits:16,format:y,valid:e=>_(e),invalidMessage:`شماره کارت معتبر نیست.`,placeholder:{fa:`۰۰۰۰ ۰۰۰۰ ۰۰۰۰ ۰۰۰۰`,latin:`0000 0000 0000 0000`},digits:`fa`,autocomplete:`cc-number`,meta:e=>{let t=v(e);return t?{text:t.name,bank:t}:null},detail:e=>({bank:v(e)?.name??null})}}},Z=class extends G{constructor(){super(...arguments),this.kind={label:`شمارهٔ شبا`,maxDigits:24,format:e=>T(e),valid:e=>C(e),invalidMessage:`شماره شبا معتبر نیست.`,placeholder:{fa:`IR00 0000 0000 0000 0000 0000 00`,latin:`IR00 0000 0000 0000 0000 0000 00`},digits:`latin`,meta:e=>{let t=w(e);return t?{text:t.name,bank:t}:null},submit:e=>e?`IR${e}`:``,detail:e=>({bank:w(e)?.name??null})}}clean(e){return super.clean(e.replace(/^\s*IR/i,``))}},Q=class extends G{constructor(){super(...arguments),this.kind={label:`کد پستی`,maxDigits:10,format:F,valid:e=>P(e),invalidMessage:`کد پستی معتبر نیست.`,placeholder:{fa:`۱۲۳۴۵-۶۷۸۹۰`,latin:`12345-67890`},digits:`fa`,autocomplete:`postal-code`}}},$=class extends G{constructor(){super(...arguments),this.kind={label:`مبلغ`,maxDigits:15,normalize:e=>e.replace(/^0+(?=\d)/,``),format:e=>e?f(e,{digits:`latin`}).replace(/,/g,`٬`):``,valid:()=>this.inRange(),invalidMessage:``,placeholder:{fa:`۰`,latin:`0`},digits:`fa`,meta:(e,t)=>{let n=t.getAttribute(`unit`)??`تومان`;return n?{text:n}:null},detail:e=>({value:e?Number(e):null})}}get valueAsNumber(){return this.raw?Number(this.raw):null}num(e){let t=this.getAttribute(e);return t===null||t===``||Number.isNaN(Number(t))?void 0:Number(t)}inRange(){if(!this.raw)return!0;let e=Number(this.raw),t=this.num(`min`),n=this.num(`max`);return!(t!==void 0&&e<t||n!==void 0&&e>n)}invalidText(e){if(!e||this.inRange())return null;let t=this.getAttribute(`invalid-message`);if(t)return t;let n=this.num(`min`),r=this.num(`max`),i=e=>U(f(e));return`مبلغ باید ${n===void 0?``:`حداقل ${i(n)}`}${n!==void 0&&r!==void 0?` و `:``}${r===void 0?``:`حداکثر ${i(r)}`} باشد.`}hintText(){if(this.raw&&r(this,`show-words`,!0)){let e=this.getAttribute(`unit`)??`تومان`;return`${p(Number(this.raw))}${e?` ${e}`:``}`}return this.getAttribute(`hint`)}};$.observedAttributes=[...G.observedAttributes,`unit`,`min`,`max`,`show-words`],e(`kashi-national-id`,K,`block`),e(`kashi-legal-id`,q,`block`),e(`kashi-mobile`,J,`block`),e(`kashi-landline`,Y,`block`),e(`kashi-card-number`,X,`block`),e(`kashi-iban`,Z,`block`),e(`kashi-postal-code`,Q,`block`),e(`kashi-price`,$,`block`);export{X as KashiCardNumber,G as KashiDigitsInput,Z as KashiIban,Y as KashiLandline,q as KashiLegalId,J as KashiMobile,K as KashiNationalId,Q as KashiPostalCode,$ as KashiPrice};
1
+ import{a as e,c as t,d as n,i as r,l as i,o as a,s as o,t as s,u as c}from"./base-DfzNTdQk.js";import{i as l,n as u,r as d,t as f}from"./digits-DE1YGT94.js";import{t as p}from"./words-9OdzG7y6.js";function m(e){let t=u(e);if(!/^\d{10}$/.test(t)||/^(\d)\1{9}$/.test(t))return!1;let n=Number(t[9]),r=0;for(let e=0;e<9;e++)r+=Number(t[e])*(10-e);let i=r%11;return i<2?n===i:n===11-i}const h={603799:{name:`بانک ملی`,slug:`melli`},589210:{name:`بانک سپه`,slug:`sepah`},627648:{name:`بانک توسعه صادرات`,slug:`edbi`},627961:{name:`بانک صنعت و معدن`,slug:`bim`},603770:{name:`بانک کشاورزی`,slug:`keshavarzi`},639217:{name:`بانک کشاورزی`,slug:`keshavarzi`},628023:{name:`بانک مسکن`,slug:`maskan`},627760:{name:`پست بانک`,slug:`postbank`},502908:{name:`بانک توسعه تعاون`,slug:`tosee-taavon`},627412:{name:`بانک اقتصاد نوین`,slug:`eghtesad-novin`},622106:{name:`بانک پارسیان`,slug:`parsian`},639194:{name:`بانک پارسیان`,slug:`parsian`},627884:{name:`بانک پارسیان`,slug:`parsian`},502229:{name:`بانک پاسارگاد`,slug:`pasargad`},639347:{name:`بانک پاسارگاد`,slug:`pasargad`},627488:{name:`بانک کارآفرین`,slug:`karafarin`},502910:{name:`بانک کارآفرین`,slug:`karafarin`},621986:{name:`بانک سامان`,slug:`saman`},639346:{name:`بانک سینا`,slug:`sina`},639607:{name:`بانک سرمایه`,slug:`sarmayeh`},636214:{name:`بانک آینده`,slug:`ayandeh`},502806:{name:`بانک شهر`,slug:`shahr`},504706:{name:`بانک شهر`,slug:`shahr`},502938:{name:`بانک دی`,slug:`dey`},603769:{name:`بانک صادرات`,slug:`saderat`},610433:{name:`بانک ملت`,slug:`mellat`},991975:{name:`بانک ملت`,slug:`mellat`},627353:{name:`بانک تجارت`,slug:`tejarat`},585983:{name:`بانک تجارت`,slug:`tejarat`},589463:{name:`بانک رفاه`,slug:`refah`},505785:{name:`بانک ایران زمین`,slug:`iran-zamin`},606373:{name:`بانک قرض‌الحسنه مهر ایران`,slug:`mehr-iran`},505416:{name:`بانک گردشگری`,slug:`gardeshgari`},636795:{name:`بانک مرکزی`,slug:`markazi`},585947:{name:`بانک خاورمیانه`,slug:`khavarmianeh`},505809:{name:`بانک خاورمیانه`,slug:`khavarmianeh`},507677:{name:`موسسه اعتباری نور`,slug:`noor`},606256:{name:`موسسه اعتباری ملل`,slug:`melal`},628157:{name:`موسسه اعتباری توسعه`,slug:`tosee`},504172:{name:`بانک قرض‌الحسنه رسالت`,slug:`resalat`},627381:{name:`بانک انصار`,slug:`ansar`},639599:{name:`بانک قوامین`,slug:`ghavamin`},636949:{name:`بانک حکمت ایرانیان`,slug:`hekmat`},505801:{name:`موسسه اعتباری کوثر`,slug:`kosar`},639370:{name:`بانک مهر اقتصاد`,slug:`mehr-eghtesad`}};function g(e){let t=0;for(let n=0;n<e.length;n++){let r=Number(e[e.length-1-n]);n%2==1&&(r*=2,r>9&&(r-=9)),t+=r}return t%10==0}function _(e){let t=u(e);return/^\d{16}$/.test(t)&&g(t)}function v(e){let t=u(e);return t.length>=6?h[t.slice(0,6)]??null:null}function y(e){return u(e).slice(0,16).replace(/(\d{4})(?=\d)/g,`$1 `)}const b={"010":{name:`بانک مرکزی`,slug:`markazi`},"011":{name:`بانک صنعت و معدن`,slug:`bim`},"012":{name:`بانک ملت`,slug:`mellat`},"013":{name:`بانک رفاه`,slug:`refah`},"014":{name:`بانک مسکن`,slug:`maskan`},"015":{name:`بانک سپه`,slug:`sepah`},"016":{name:`بانک کشاورزی`,slug:`keshavarzi`},"017":{name:`بانک ملی`,slug:`melli`},"018":{name:`بانک تجارت`,slug:`tejarat`},"019":{name:`بانک صادرات`,slug:`saderat`},"020":{name:`بانک توسعه صادرات`,slug:`edbi`},"021":{name:`پست بانک`,slug:`postbank`},"022":{name:`بانک توسعه تعاون`,slug:`tosee-taavon`},"053":{name:`بانک کارآفرین`,slug:`karafarin`},"054":{name:`بانک پارسیان`,slug:`parsian`},"055":{name:`بانک اقتصاد نوین`,slug:`eghtesad-novin`},"056":{name:`بانک سامان`,slug:`saman`},"057":{name:`بانک پاسارگاد`,slug:`pasargad`},"058":{name:`بانک سرمایه`,slug:`sarmayeh`},"059":{name:`بانک سینا`,slug:`sina`},"060":{name:`بانک قرض‌الحسنه مهر ایران`,slug:`mehr-iran`},"061":{name:`بانک شهر`,slug:`shahr`},"062":{name:`بانک آینده`,slug:`ayandeh`},"064":{name:`بانک گردشگری`,slug:`gardeshgari`},"066":{name:`بانک دی`,slug:`dey`},"069":{name:`بانک ایران زمین`,slug:`iran-zamin`},"070":{name:`بانک قرض‌الحسنه رسالت`,slug:`resalat`},"078":{name:`بانک خاورمیانه`,slug:`khavarmianeh`}};function x(e){return d(e).toUpperCase().replace(/^\s*IR/,``).replace(/\D/g,``).slice(0,24)}function S(e){let t=0;for(let n=0;n<e.length;n+=7)t=Number(String(t)+e.slice(n,n+7))%97;return t}function C(e){let t=d(e).toUpperCase().replace(/[\s-]/g,``),n=t.startsWith(`IR`)?t.slice(2):t;return/^\d{24}$/.test(n)?S(n.slice(2)+`1827`+n.slice(0,2))===1:!1}function w(e){let t=x(e);return t.length>=5?b[t.slice(2,5)]??null:null}function T(e){let t=x(e);return t?`IR${t}`.replace(/(.{4})(?=.)/g,`$1 `):``}const E={name:`همراه اول`,slug:`mci`},D={name:`ایرانسل`,slug:`irancell`},O={name:`رایتل`,slug:`rightel`},k={...Object.fromEntries([`10`,`11`,`12`,`13`,`14`,`15`,`16`,`17`,`18`,`19`,`90`,`91`,`92`,`93`,`94`].map(e=>[e,E])),...Object.fromEntries([`01`,`02`,`03`,`04`,`05`,`30`,`33`,`35`,`36`,`37`,`38`,`39`,`41`].map(e=>[e,D])),...Object.fromEntries([`20`,`21`,`22`].map(e=>[e,O]))};function A(e){let t=u(e);return t.startsWith(`0098`)?t=`0`+t.slice(4):t.startsWith(`98`)&&t.length===12?t=`0`+t.slice(2):t.startsWith(`9`)&&t.length===10&&(t=`0`+t),t}function j(e){return/^09\d{9}$/.test(A(e))}function M(e){let t=A(e);return t.length>=4&&t.startsWith(`09`)?k[t.slice(2,4)]??null:null}function N(e){let t=A(e).slice(0,11);return[t.slice(0,4),t.slice(4,7),t.slice(7,11)].filter(Boolean).join(` `)}function P(e){let t=u(e);return/^(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}$/.test(t)}function F(e){let t=u(e).slice(0,10);return t.length>5?`${t.slice(0,5)}-${t.slice(5)}`:t}const I={11:`مازندران`,13:`گیلان`,17:`گلستان`,21:`تهران`,23:`سمنان`,24:`زنجان`,25:`قم`,26:`البرز`,28:`قزوین`,31:`اصفهان`,34:`کرمان`,35:`یزد`,38:`چهارمحال و بختیاری`,41:`آذربایجان شرقی`,44:`آذربایجان غربی`,45:`اردبیل`,51:`خراسان رضوی`,54:`سیستان و بلوچستان`,56:`خراسان جنوبی`,58:`خراسان شمالی`,61:`خوزستان`,66:`لرستان`,71:`فارس`,74:`کهگیلویه و بویراحمد`,76:`هرمزگان`,77:`بوشهر`,81:`همدان`,83:`کرمانشاه`,84:`ایلام`,86:`مرکزی`,87:`کردستان`};function L(e){let t=u(e);return t.startsWith(`0098`)?t=`0`+t.slice(4):t.startsWith(`98`)&&t.length===12?t=`0`+t.slice(2):/^[1-8]/.test(t)&&t.length===10&&(t=`0`+t),t}function R(e){let t=L(e);return t.length>=3&&t[0]===`0`?I[t.slice(1,3)]??null:null}function z(e){let t=L(e);return/^0\d{2}[2-9]\d{7}$/.test(t)&&R(t)!==null}function B(e){let t=L(e).slice(0,11);return[t.slice(0,3),t.slice(3,7),t.slice(7,11)].filter(Boolean).join(` `)}const V=[29,27,23,19,17,29,27,23,19,17];function H(e){let t=u(e);if(!/^\d{11}$/.test(t)||/^0+$/.test(t.slice(3,9)))return!1;let n=[...t].map(Number),r=n[9]+2,i=0;for(let e=0;e<10;e++)i+=(n[e]+r)*V[e];let a=i%11;return(a===10?0:a)===n[10]}const U=e=>l(e);function W(e,t){if(t===0)return e.search(/[0-9۰-۹]/)===-1?e.length:e.search(/[0-9۰-۹]/);let n=0;for(let r=0;r<e.length;r++)if(/[0-9۰-۹]/.test(e[r])&&++n===t)return r+1;return e.length}var G=class extends s{constructor(){super(...arguments),this.raw=``,this.touched=!1,this.valueSet=!1,this.rendered=!1,this.key=n(`kashi-in`),this.logoSlug=null}connectedCallback(){if(!this.rendered&&!this.valueSet&&(this.raw=this.clean(this.getAttribute(`value`)??``)),Object.prototype.hasOwnProperty.call(this,`value`)){let e=this.value;delete this.value,this.raw=this.clean(String(e??``))}this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`value`?this.setRaw(this.clean(n??``),!1):this.render())}get value(){return this.kind.submit?this.kind.submit(this.raw):this.raw}set value(e){this.valueSet=!0,this.setRaw(this.clean(String(e??``)),!1)}get valid(){return this.isValid()}isValid(){return this.kind.valid(this.raw)}focus(e){this.input?.focus(e)}clean(e){let t=this.kind;return(t.normalize??(e=>e))(u(e)).slice(0,t.maxDigits)}get digits(){let e=this.getAttribute(`digits`);return e===`fa`||e===`latin`?e:this.kind.digits}shown(){let e=this.kind.format(this.raw);return this.digits===`fa`?U(e):e}render(){let e=this.kind,n=this.key,r=this.getAttribute(`aria-label`),i=this.hasAttribute(`label`)?this.getAttribute(`label`):r?null:e.label,a=this.getAttribute(`size`),s=this.hasAttribute(`required`),c=this.hasAttribute(`disabled`),l=this.getAttribute(`placeholder`)??e.placeholder[this.digits],u=`<div class="k-input${a===`sm`||a===`lg`?` k-input--${a}`:``}" data-size="${a??`md`}"${c?` data-state="disabled"`:``}><input id="${n}" class="k-input__control" type="${e.type??`text`}" inputmode="${e.inputMode??`numeric`}" autocomplete="${e.autocomplete??`off`}" dir="ltr" spellcheck="false" placeholder="${o(l)}"${s?` required`:``}${c?` disabled`:``}${this.hasAttribute(`readonly`)?` readonly`:``}${!i&&r?` aria-label="${o(r)}"`:``}></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,t({id:n,label:i,required:s,control:u})),this.input=this.querySelector(`input.k-input__control`),this.input.addEventListener(`input`,()=>this.onInput()),this.input.addEventListener(`blur`,()=>{this.touched=!0,this.paint()}),this.rendered=!0,this.paint()}onInput(){let e=this.input,t=e.value.slice(0,e.selectionStart??e.value.length),n=this.clean(e.value),r=Math.min(u(t).length,n.length);if(this.setRaw(n,!0),e.ownerDocument.activeElement===e){let t=W(e.value,r);e.setSelectionRange(t,t)}}setRaw(e,t){let n=e!==this.raw;this.raw=e,this.rendered&&(this.paint(),t&&n&&a(this,`kashi-change`,{value:this.value,valid:this.isValid(),...this.kind.detail?.(this.raw)}))}invalidText(e){return this.raw.length>0&&(e||this.raw.length===this.kind.maxDigits)&&!this.isValid()?this.getAttribute(`invalid-message`)??this.kind.invalidMessage:null}hintText(){return this.getAttribute(`hint`)}paint(){let e=this.input,t=this.shown();e.value!==t&&(e.value=t);let n=e.parentElement;n.querySelector(`:scope > .k-input__addon`)?.remove();let a=r(this,`show-meta`,!0)?this.kind.meta?.(this.raw,this):null,s=`${this.key}-meta`;if(a){let e=document.createElement(`span`);e.className=`k-input__addon`,e.innerHTML=a.bank?`<span class="k-bank" id="${s}">${o(a.text)}</span>`:`<span class="k-input__meta" id="${s}">${o(a.text)}</span>`,n.append(e),a.bank&&r(this,`bank-logo`,!0)&&this.loadLogo(a.bank,e.firstElementChild)}let l=this.getAttribute(`error`)||this.invalidText(this.touched);e.setCustomValidity(this.raw&&!this.isValid()?this.invalidText(!0)??``:``),i(this.querySelector(`:scope > .k-field`),e,this.key,l,this.hintText(),a?s:null),c(this,this.getAttribute(`name`),this.raw?this.value:``)}loadLogo(e,t){this.logoSlug=e.slug,import(`./dist-D670Gw0K.js`).then(n=>{let r=n.bankLogoDataUri(e.slug);if(!r||this.logoSlug!==e.slug||!t.isConnected)return;let i=document.createElement(`img`);i.className=`k-bank__logo`,i.src=r,i.alt=``,i.width=i.height=24,t.prepend(i)}).catch(()=>{})}};G.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`required`,`disabled`,`readonly`,`digits`,`invalid-message`,`name`,`value`,`size`,`aria-label`,`show-meta`,`bank-logo`];var K=class extends G{constructor(){super(...arguments),this.kind={label:`کد ملی`,maxDigits:10,format:e=>e,valid:e=>m(e),invalidMessage:`کد ملی معتبر نیست.`,placeholder:{fa:`۰۰۰۰۰۰۰۰۰۰`,latin:`0000000000`},digits:`fa`}}},q=class extends G{constructor(){super(...arguments),this.kind={label:`شناسهٔ ملی شرکت`,maxDigits:11,format:e=>e,valid:e=>H(e),invalidMessage:`شناسهٔ ملی معتبر نیست.`,placeholder:{fa:`۰۰۰۰۰۰۰۰۰۰۰`,latin:`00000000000`},digits:`fa`}}},J=class extends G{constructor(){super(...arguments),this.kind={label:`شمارهٔ موبایل`,maxDigits:11,normalize:A,format:N,valid:e=>j(e),invalidMessage:`شماره موبایل معتبر نیست.`,placeholder:{fa:`۰۹۱۲ ۳۴۵ ۶۷۸۹`,latin:`0912 345 6789`},digits:`fa`,type:`tel`,inputMode:`tel`,autocomplete:`tel-national`,meta:e=>{let t=M(e);return t?{text:t.name}:null},detail:e=>({operator:M(e)?.name??null})}}},Y=class extends G{constructor(){super(...arguments),this.kind={label:`تلفن ثابت`,maxDigits:11,normalize:L,format:B,valid:e=>z(e),invalidMessage:`شمارهٔ تلفن ثابت معتبر نیست.`,placeholder:{fa:`۰۲۱ ۸۸۷۷ ۶۶۵۵`,latin:`021 8877 6655`},digits:`fa`,type:`tel`,inputMode:`tel`,autocomplete:`tel-national`,meta:e=>{let t=R(e);return t?{text:t}:null},detail:e=>({province:R(e)})}}},X=class extends G{constructor(){super(...arguments),this.kind={label:`شمارهٔ کارت`,maxDigits:16,format:y,valid:e=>_(e),invalidMessage:`شماره کارت معتبر نیست.`,placeholder:{fa:`۰۰۰۰ ۰۰۰۰ ۰۰۰۰ ۰۰۰۰`,latin:`0000 0000 0000 0000`},digits:`fa`,autocomplete:`cc-number`,meta:e=>{let t=v(e);return t?{text:t.name,bank:t}:null},detail:e=>({bank:v(e)?.name??null})}}},Z=class extends G{constructor(){super(...arguments),this.kind={label:`شمارهٔ شبا`,maxDigits:24,format:e=>T(e),valid:e=>C(e),invalidMessage:`شماره شبا معتبر نیست.`,placeholder:{fa:`IR00 0000 0000 0000 0000 0000 00`,latin:`IR00 0000 0000 0000 0000 0000 00`},digits:`latin`,meta:e=>{let t=w(e);return t?{text:t.name,bank:t}:null},submit:e=>e?`IR${e}`:``,detail:e=>({bank:w(e)?.name??null})}}clean(e){return super.clean(e.replace(/^\s*IR/i,``))}},Q=class extends G{constructor(){super(...arguments),this.kind={label:`کد پستی`,maxDigits:10,format:F,valid:e=>P(e),invalidMessage:`کد پستی معتبر نیست.`,placeholder:{fa:`۱۲۳۴۵-۶۷۸۹۰`,latin:`12345-67890`},digits:`fa`,autocomplete:`postal-code`}}},$=class extends G{constructor(){super(...arguments),this.kind={label:`مبلغ`,maxDigits:15,normalize:e=>e.replace(/^0+(?=\d)/,``),format:e=>e?f(e,{digits:`latin`}).replace(/,/g,`٬`):``,valid:()=>this.inRange(),invalidMessage:``,placeholder:{fa:`۰`,latin:`0`},digits:`fa`,meta:(e,t)=>{let n=t.getAttribute(`unit`)??`تومان`;return n?{text:n}:null},detail:e=>({value:e?Number(e):null})}}get valueAsNumber(){return this.raw?Number(this.raw):null}num(e){let t=this.getAttribute(e);return t===null||t===``||Number.isNaN(Number(t))?void 0:Number(t)}inRange(){if(!this.raw)return!0;let e=Number(this.raw),t=this.num(`min`),n=this.num(`max`);return!(t!==void 0&&e<t||n!==void 0&&e>n)}invalidText(e){if(!e||this.inRange())return null;let t=this.getAttribute(`invalid-message`);if(t)return t;let n=this.num(`min`),r=this.num(`max`),i=e=>U(f(e));return`مبلغ باید ${n===void 0?``:`حداقل ${i(n)}`}${n!==void 0&&r!==void 0?` و `:``}${r===void 0?``:`حداکثر ${i(r)}`} باشد.`}hintText(){if(this.raw&&r(this,`show-words`,!0)){let e=this.getAttribute(`unit`)??`تومان`;return`${p(Number(this.raw))}${e?` ${e}`:``}`}return this.getAttribute(`hint`)}};$.observedAttributes=[...G.observedAttributes,`unit`,`min`,`max`,`show-words`],e(`kashi-national-id`,K,`block`),e(`kashi-legal-id`,q,`block`),e(`kashi-mobile`,J,`block`),e(`kashi-landline`,Y,`block`),e(`kashi-card-number`,X,`block`),e(`kashi-iban`,Z,`block`),e(`kashi-postal-code`,Q,`block`),e(`kashi-price`,$,`block`);export{X as KashiCardNumber,G as KashiDigitsInput,Z as KashiIban,Y as KashiLandline,q as KashiLegalId,J as KashiMobile,K as KashiNationalId,Q as KashiPostalCode,$ as KashiPrice};