@kashi-ui/elements 1.8.0 → 2.0.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 (31) hide show
  1. package/README.md +1 -1
  2. package/dist/base.d.ts +18 -0
  3. package/dist/cdn/{appointment-YPdrCT54.js → appointment-CZNwpkp1.js} +1 -1
  4. package/dist/cdn/base-BUQYhiEA.js +1 -0
  5. package/dist/cdn/{basic-BOoAih_D.js → basic-C815theM.js} +1 -1
  6. package/dist/cdn/{calendar-BazNrJPa.js → calendar-Di0xvA-Y.js} +1 -1
  7. package/dist/cdn/{charts-DKcI5AOn.js → charts-C5LT77Qo.js} +1 -1
  8. package/dist/cdn/{combobox-Bxc9krdH.js → combobox-Br5cwZFz.js} +1 -1
  9. package/dist/cdn/commerce-DYVxWBBe.js +1 -0
  10. package/dist/cdn/{controls-BxiBYyQo.js → controls-m5DTcF_s.js} +1 -1
  11. package/dist/cdn/{display-BR-7r4aB.js → display-CPw2LBkB.js} +1 -1
  12. package/dist/cdn/{fields-BOgowgq3.js → fields-BiEcHRiA.js} +1 -1
  13. package/dist/cdn/{forms-BiS_Z4nX.js → forms-C6-Wamak.js} +1 -1
  14. package/dist/cdn/{holidays-DcFnlygr.js → holidays-B5Ncz9aC.js} +1 -1
  15. package/dist/cdn/{inputs-BCJQY3U_.js → inputs-CI_r2s8t.js} +1 -1
  16. package/dist/cdn/kashi-elements.js +1 -1
  17. package/dist/cdn/{map-BOxAo1iN.js → map-Drave3MR.js} +1 -1
  18. package/dist/cdn/{menu-BOXyaiDK.js → menu-DtNKEt1M.js} +1 -1
  19. package/dist/cdn/{nav-DQfGe1Vd.js → nav-Ihmgl1sx.js} +1 -1
  20. package/dist/cdn/{overlay-BrVh7RHI.js → overlay-CZh0I9wA.js} +1 -1
  21. package/dist/cdn/{pickers-CgoXFr-d.js → pickers-BTH9LGo1.js} +1 -1
  22. package/dist/cdn/{table-CH9eyNL-.js → table-C2PzU0Rb.js} +1 -1
  23. package/dist/cdn/{text-Dhwh21Us.js → text-BcDsKxe_.js} +1 -1
  24. package/dist/cdn/{time-Bd1ee8FP.js → time-Chd8ZdFw.js} +1 -1
  25. package/dist/cdn.js +1 -0
  26. package/dist/commerce.d.ts +66 -0
  27. package/dist/commerce.js +306 -0
  28. package/dist/index.d.ts +6 -2
  29. package/dist/index.js +3 -1
  30. package/package.json +4 -4
  31. package/dist/cdn/base-C2zmRRrl.js +0 -1
@@ -1 +1 @@
1
- import{A as e,M as t,_ as n,c as r,i,j as a,k as o,l as s,m as c,o as l,p as u,s as d,t as f,u as p,y as m}from"./base-C2zmRRrl.js";import{n as h}from"./text-Dhwh21Us.js";function g(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 _=class extends f{constructor(){super(...arguments),this.tags=[],this.localError=null,this.rendered=!1,this.valueSet=!1,this.key=m(`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,t=this.getAttribute(`aria-label`),n=this.hasAttribute(`label`)?this.getAttribute(`label`):t?null:u().tagInput.label,r=`<div class="k-tag-input"><input id="${e}" class="k-tag-input__control"${this.hasAttribute(`disabled`)?` disabled`:``}${!n&&t?` aria-label="${s(t)}"`:``}></div><span class="k-sr-only" aria-live="polite"></span>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,p({id:e,label:n,control:r})),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=i(this,`allow-duplicates`),r=[...this.tags],a=``;for(let i of e){let e=h(i).trim();if(!e)continue;let o=r.length>=t?u().common.max(c(this,t)):!n&&r.includes(e)?u().tagInput.duplicate:this.validate?.(e);if(o){this.localError=o,this.commit(r,a),this.input.value=e;return}r=[...r,e],a=u().common.added(e)}this.localError=null,this.input.value=``,this.commit(r,a)}removeAt(e){let t=this.tags[e];this.commit(this.tags.filter((t,n)=>n!==e),u().common.removed(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&&r(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--${s(e)}`}${t?``:` k-badge--removable`}">${s(n)}${t?``:`<button type="button" class="k-badge__remove" data-i="${r}" aria-label="${s(u().common.remove(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(),g(this,this.getAttribute(`name`),this.tags)}paintMessages(){let e=this.getAttribute(`error`)||this.localError;this.querySelector(`.k-tag-input`).toggleAttribute(`data-invalid`,!!e),n(this.querySelector(`:scope > .k-field`),this.input,this.key,e,this.getAttribute(`hint`))}};_.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`disabled`,`name`,`value`,`max`,`tone`,`allow-duplicates`,`aria-label`];var v=class extends f{constructor(){super(...arguments),this.current=null,this.rendered=!1,this.valueSet=!1,this.key=m(`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 n=this.hasAttribute(`thousands`)?o(e,{digits:`latin`}):String(e);return d(this)===`latin`?n:t(n).replace(/,/g,`٬`)}render(){let t=this.key,n=this.getAttribute(`aria-label`),r=this.hasAttribute(`label`)?this.getAttribute(`label`):n?null:u().numberInput.label,i=this.hasAttribute(`disabled`),a=this.getAttribute(`unit`),o=`<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="${s(u().numberInput.decrement)}"${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="${t}" class="k-input__control" type="text" inputmode="decimal" role="spinbutton" dir="ltr"${i?` disabled`:``}${!r&&n?` aria-label="${s(n)}"`:``}>${a?`<span class="k-input__addon">${s(a)}</span>`:``}<button type="button" class="k-number__step" data-step="1" tabindex="-1" aria-label="${s(u().numberInput.increment)}"${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`,p({id:t,label:r,control:o})),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 t=this.input.value,n=e(t);this.set(n?(/^\s*[-−]/.test(t)?-1:1)*Number(n):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&&r(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 r=this.hasAttribute(`disabled`),[i,a]=this.querySelectorAll(`.k-number__step`);i.disabled=r||this.min!==void 0&&(t??0)<=this.min,a.disabled=r||this.max!==void 0&&(t??0)>=this.max,n(this.querySelector(`:scope > .k-field`),e,this.key,this.getAttribute(`error`),this.getAttribute(`hint`)),g(this,this.getAttribute(`name`),[t===null?``:String(t)])}};v.observedAttributes=[`label`,`hint`,`error`,`value`,`min`,`max`,`step`,`thousands`,`digits`,`unit`,`disabled`,`name`,`aria-label`];const y=`<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>`;var b=class extends f{constructor(){super(...arguments),this.current=0,this.valueSet=!1,this.key=m(`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`)??u().rating.label,n=e=>c(this,e).replace(`.`,u().common.decimal),i=this.getAttribute(`size`),a=`k-rating${i===`sm`||i===`lg`?` k-rating--${i}`:``}`,o=this.current,l=Array.from({length:e},(e,t)=>t+1),d=this.hasAttribute(`show-value`)?`<span class="k-rating__value" aria-hidden="true">${n(o)}</span>`:``;if(this.hasAttribute(`readonly`)){this.innerHTML=`<span class="${a}" data-readonly="" role="img" aria-label="${s(`${t}: ${u().common.of(n(o),n(e))}`)}">${l.map(e=>`<span class="k-rating__star"${e<=Math.floor(o)?` data-filled=""`:``}${e===Math.ceil(o)&&o%1>=.25?` data-half=""`:``}>${y}</span>`).join(``)}${d}</span>`;return}let f=this.getAttribute(`name`)??this.key,p=this.hasAttribute(`disabled`);this.innerHTML=`<fieldset class="${a}"><legend class="k-sr-only">${s(t)}</legend>${l.map(t=>`<label class="k-rating__star"${t<=o?` data-filled=""`:``}><input type="radio" class="k-sr-only" name="${s(f)}" value="${t}"${o===t?` checked`:``}${p?` disabled`:``} aria-label="${s(u().common.of(n(t),n(e)))}">${y}</label>`).join(``)}${d}</fieldset>`;let m=this.querySelector(`fieldset`),h=e=>m.querySelectorAll(`.k-rating__star`).forEach((t,n)=>t.toggleAttribute(`data-filled`,n+1<=e));m.addEventListener(`change`,e=>{this.current=Number(e.target.value),h(this.current),r(this,`kashi-change`,{value:this.current})}),m.addEventListener(`pointerover`,e=>{let t=e.target.closest(`.k-rating__star`);t&&!p&&h([...m.querySelectorAll(`.k-rating__star`)].indexOf(t)+1)}),m.addEventListener(`pointerleave`,()=>h(this.current))}};b.observedAttributes=[`value`,`max`,`readonly`,`show-value`,`size`,`label`,`name`,`disabled`];function x(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 S=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 C=class extends f{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),n=this.total,i=e=>d(this)===`latin`?String(e):t(e),a=this.getAttribute(`href`),o=this.contains(document.activeElement)?document.activeElement.dataset.to:null,c=(e,t,n,{current:r=!1,disabled:i=!1,aria:o=``}={})=>a&&!i?`<a class="${n}" href="${s(a.replace(`{page}`,String(e)))}" data-to="${e}"${r?` aria-current="page"`:``}${o?` aria-label="${s(o)}"`:``}>${t}</a>`:`<button type="button" class="${n}" data-to="${e}"${i?` disabled`:``}${r?` aria-current="page"`:``}${o?` aria-label="${s(o)}"`:``}>${t}</button>`,l=this.getAttribute(`summary`);this.innerHTML=`<nav class="k-pagination" aria-label="${s(this.getAttribute(`label`)??u().pagination.nav)}">${c(e-1,`${S(`m12 5-5 5 5 5`)}${s(u().common.prev)}`,`k-btn k-btn--secondary k-btn--sm`,{disabled:e<=1})}${l?`<span class="k-pagination__summary">${s(l)}</span>`:``}<ul class="k-pagination__pages" role="list">${x(e,n,Number(this.getAttribute(`siblings`)??1)).map(t=>`<li>${t===null?`<span class="k-pagination__ellipsis" aria-hidden="true">…</span>`:c(t,i(t),`k-pagination__page`,{current:t===e,aria:u().pagination.page(i(t))})}</li>`).join(``)}</ul>${c(e+1,`${s(u().common.next)}${S(`m8 5 5 5-5 5`)}`,`k-btn k-btn--secondary k-btn--sm`,{disabled:e>=n})}</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)),r(this,`kashi-change`,{page:n}),this.querySelector(`.k-pagination__page[data-to="${n}"]`)?.focus()}),o&&this.querySelector(`[data-to="${o}"]`)?.focus()}};C.observedAttributes=[`page`,`total`,`siblings`,`href`,`digits`,`label`,`summary`];const w=e=>{let t=a(e).replace(/[٬,\s]/g,``).replace(`٫`,`.`).replace(`−`,`-`).match(/-?\d+(\.\d+)?/);return t?Number(t[0]):NaN};l(`kashi-tag-input`,_,`block`),l(`kashi-number-input`,v,`block`),l(`kashi-rating`,b),l(`kashi-pagination`,C,`block`);export{v as KashiNumberInput,C as KashiPagination,b as KashiRating,_ as KashiTagInput,w as cellNumber,x as pageRange};
1
+ import{A as e,M as t,_ as n,c as r,i,j as a,k as o,l as s,m as c,o as l,p as u,s as d,t as f,u as p,y as m}from"./base-BUQYhiEA.js";import{n as h}from"./text-BcDsKxe_.js";function g(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 _=class extends f{constructor(){super(...arguments),this.tags=[],this.localError=null,this.rendered=!1,this.valueSet=!1,this.key=m(`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,t=this.getAttribute(`aria-label`),n=this.hasAttribute(`label`)?this.getAttribute(`label`):t?null:u().tagInput.label,r=`<div class="k-tag-input"><input id="${e}" class="k-tag-input__control"${this.hasAttribute(`disabled`)?` disabled`:``}${!n&&t?` aria-label="${s(t)}"`:``}></div><span class="k-sr-only" aria-live="polite"></span>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,p({id:e,label:n,control:r})),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=i(this,`allow-duplicates`),r=[...this.tags],a=``;for(let i of e){let e=h(i).trim();if(!e)continue;let o=r.length>=t?u().common.max(c(this,t)):!n&&r.includes(e)?u().tagInput.duplicate:this.validate?.(e);if(o){this.localError=o,this.commit(r,a),this.input.value=e;return}r=[...r,e],a=u().common.added(e)}this.localError=null,this.input.value=``,this.commit(r,a)}removeAt(e){let t=this.tags[e];this.commit(this.tags.filter((t,n)=>n!==e),u().common.removed(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&&r(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--${s(e)}`}${t?``:` k-badge--removable`}">${s(n)}${t?``:`<button type="button" class="k-badge__remove" data-i="${r}" aria-label="${s(u().common.remove(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(),g(this,this.getAttribute(`name`),this.tags)}paintMessages(){let e=this.getAttribute(`error`)||this.localError;this.querySelector(`.k-tag-input`).toggleAttribute(`data-invalid`,!!e),n(this.querySelector(`:scope > .k-field`),this.input,this.key,e,this.getAttribute(`hint`))}};_.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`disabled`,`name`,`value`,`max`,`tone`,`allow-duplicates`,`aria-label`];var v=class extends f{constructor(){super(...arguments),this.current=null,this.rendered=!1,this.valueSet=!1,this.key=m(`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 n=this.hasAttribute(`thousands`)?o(e,{digits:`latin`}):String(e);return d(this)===`latin`?n:t(n).replace(/,/g,`٬`)}render(){let t=this.key,n=this.getAttribute(`aria-label`),r=this.hasAttribute(`label`)?this.getAttribute(`label`):n?null:u().numberInput.label,i=this.hasAttribute(`disabled`),a=this.getAttribute(`unit`),o=`<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="${s(u().numberInput.decrement)}"${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="${t}" class="k-input__control" type="text" inputmode="decimal" role="spinbutton" dir="ltr"${i?` disabled`:``}${!r&&n?` aria-label="${s(n)}"`:``}>${a?`<span class="k-input__addon">${s(a)}</span>`:``}<button type="button" class="k-number__step" data-step="1" tabindex="-1" aria-label="${s(u().numberInput.increment)}"${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`,p({id:t,label:r,control:o})),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 t=this.input.value,n=e(t);this.set(n?(/^\s*[-−]/.test(t)?-1:1)*Number(n):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&&r(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 r=this.hasAttribute(`disabled`),[i,a]=this.querySelectorAll(`.k-number__step`);i.disabled=r||this.min!==void 0&&(t??0)<=this.min,a.disabled=r||this.max!==void 0&&(t??0)>=this.max,n(this.querySelector(`:scope > .k-field`),e,this.key,this.getAttribute(`error`),this.getAttribute(`hint`)),g(this,this.getAttribute(`name`),[t===null?``:String(t)])}};v.observedAttributes=[`label`,`hint`,`error`,`value`,`min`,`max`,`step`,`thousands`,`digits`,`unit`,`disabled`,`name`,`aria-label`];const y=`<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>`;var b=class extends f{constructor(){super(...arguments),this.current=0,this.valueSet=!1,this.key=m(`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`)??u().rating.label,n=e=>c(this,e).replace(`.`,u().common.decimal),i=this.getAttribute(`size`),a=`k-rating${i===`sm`||i===`lg`?` k-rating--${i}`:``}`,o=this.current,l=Array.from({length:e},(e,t)=>t+1),d=this.hasAttribute(`show-value`)?`<span class="k-rating__value" aria-hidden="true">${n(o)}</span>`:``;if(this.hasAttribute(`readonly`)){this.innerHTML=`<span class="${a}" data-readonly="" role="img" aria-label="${s(`${t}: ${u().common.of(n(o),n(e))}`)}">${l.map(e=>`<span class="k-rating__star"${e<=Math.floor(o)?` data-filled=""`:``}${e===Math.ceil(o)&&o%1>=.25?` data-half=""`:``}>${y}</span>`).join(``)}${d}</span>`;return}let f=this.getAttribute(`name`)??this.key,p=this.hasAttribute(`disabled`);this.innerHTML=`<fieldset class="${a}"><legend class="k-sr-only">${s(t)}</legend>${l.map(t=>`<label class="k-rating__star"${t<=o?` data-filled=""`:``}><input type="radio" class="k-sr-only" name="${s(f)}" value="${t}"${o===t?` checked`:``}${p?` disabled`:``} aria-label="${s(u().common.of(n(t),n(e)))}">${y}</label>`).join(``)}${d}</fieldset>`;let m=this.querySelector(`fieldset`),h=e=>m.querySelectorAll(`.k-rating__star`).forEach((t,n)=>t.toggleAttribute(`data-filled`,n+1<=e));m.addEventListener(`change`,e=>{this.current=Number(e.target.value),h(this.current),r(this,`kashi-change`,{value:this.current})}),m.addEventListener(`pointerover`,e=>{let t=e.target.closest(`.k-rating__star`);t&&!p&&h([...m.querySelectorAll(`.k-rating__star`)].indexOf(t)+1)}),m.addEventListener(`pointerleave`,()=>h(this.current))}};b.observedAttributes=[`value`,`max`,`readonly`,`show-value`,`size`,`label`,`name`,`disabled`];function x(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 S=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 C=class extends f{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),n=this.total,i=e=>d(this)===`latin`?String(e):t(e),a=this.getAttribute(`href`),o=this.contains(document.activeElement)?document.activeElement.dataset.to:null,c=(e,t,n,{current:r=!1,disabled:i=!1,aria:o=``}={})=>a&&!i?`<a class="${n}" href="${s(a.replace(`{page}`,String(e)))}" data-to="${e}"${r?` aria-current="page"`:``}${o?` aria-label="${s(o)}"`:``}>${t}</a>`:`<button type="button" class="${n}" data-to="${e}"${i?` disabled`:``}${r?` aria-current="page"`:``}${o?` aria-label="${s(o)}"`:``}>${t}</button>`,l=this.getAttribute(`summary`);this.innerHTML=`<nav class="k-pagination" aria-label="${s(this.getAttribute(`label`)??u().pagination.nav)}">${c(e-1,`${S(`m12 5-5 5 5 5`)}${s(u().common.prev)}`,`k-btn k-btn--secondary k-btn--sm`,{disabled:e<=1})}${l?`<span class="k-pagination__summary">${s(l)}</span>`:``}<ul class="k-pagination__pages" role="list">${x(e,n,Number(this.getAttribute(`siblings`)??1)).map(t=>`<li>${t===null?`<span class="k-pagination__ellipsis" aria-hidden="true">…</span>`:c(t,i(t),`k-pagination__page`,{current:t===e,aria:u().pagination.page(i(t))})}</li>`).join(``)}</ul>${c(e+1,`${s(u().common.next)}${S(`m8 5 5 5-5 5`)}`,`k-btn k-btn--secondary k-btn--sm`,{disabled:e>=n})}</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)),r(this,`kashi-change`,{page:n}),this.querySelector(`.k-pagination__page[data-to="${n}"]`)?.focus()}),o&&this.querySelector(`[data-to="${o}"]`)?.focus()}};C.observedAttributes=[`page`,`total`,`siblings`,`href`,`digits`,`label`,`summary`];const w=e=>{let t=a(e).replace(/[٬,\s]/g,``).replace(`٫`,`.`).replace(`−`,`-`).match(/-?\d+(\.\d+)?/);return t?Number(t[0]):NaN};l(`kashi-tag-input`,_,`block`),l(`kashi-number-input`,v,`block`),l(`kashi-rating`,b),l(`kashi-pagination`,C,`block`);export{v as KashiNumberInput,C as KashiPagination,b as KashiRating,_ as KashiTagInput,w as cellNumber,x as pageRange};
@@ -1 +1 @@
1
- import{M as e,S as t,c as n,d as r,k as i,l as a,o,p as s,s as c,t as l,x as u}from"./base-C2zmRRrl.js";import{t as d}from"./words-BdADG_9U.js";const f={دقیقه:`minute`,ساعت:`hour`,روز:`day`,هفته:`week`,ماه:`month`,سال:`year`},p=6e4,m=60*p,h=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();function g(t,{now:n=/* @__PURE__ */ new Date,locale:r=`fa`,digits:i=r===`en`?`latin`:`fa`}={}){let a=r===`en`,o=t.getTime()-n.getTime(),s=o<0,c=Math.abs(o),l=t=>i===`fa`?e(t):String(t),u=(e,t)=>{if(!a)return`${l(e)} ${t} ${s?`پیش`:`دیگر`}`;let n=`${f[t]}${e===1?``:`s`}`;return s?`${l(e)} ${n} ago`:`in ${l(e)} ${n}`};if(c<45e3)return a?`just now`:`همین الان`;if(c<m)return u(Math.max(1,Math.round(c/p)),`دقیقه`);let d=Math.round((h(t)-h(n))/864e5);if(c<6*m||d===0)return u(Math.round(c/m),`ساعت`);if(d===-1)return a?`yesterday`:`دیروز`;if(d===1)return a?`tomorrow`:`فردا`;let g=Math.abs(d);return g<7?u(g,`روز`):g<30?u(Math.round(g/7),`هفته`):g<365?u(Math.max(1,Math.round(g/30.44)),`ماه`):u(Math.round(g/365.25),`سال`)}const _={همت:`trillion`,میلیارد:`billion`,میلیون:`million`,هزار:`thousand`},v=[[0xe8d4a51000,`همت`],[1e9,`میلیارد`],[1e6,`میلیون`],[1e3,`هزار`]],y=e=>Math.round(e/10),b=e=>e*10;function x(t,{unit:n=`toman`,from:r=`toman`,compact:a=!1,showUnit:o=!0,locale:s=`fa`,digits:c=s===`en`?`latin`:`fa`}={}){let l=s===`en`,u=r===n?t:r===`rial`?y(t):b(t),d=u<0?`−`:``;u=Math.abs(u);let f=i(Math.round(u),{digits:c}),p=l?n===`toman`?`Toman`:`Rial`:n===`toman`?`تومان`:`ریال`;if(a){let t=v.find(([e,t])=>u>=e&&(t!==`همت`||n===`toman`&&!l));if(t){let n=Math.round(u/t[0]*100)/100,r=String(n).replace(`.`,c===`fa`?`٫`:`.`);f=`${c===`fa`?e(r):r} ${l?_[t[1]]:t[1]}`,t[1]===`همت`&&(p=``)}}return`${d}${f}${o&&p?` ${p}`:``}`}const S=e=>{if(!e)return null;let n=t(e.trim())??new Date(e);return Number.isNaN(n.getTime())?null:n};var C=class extends l{connectedCallback(){this.render()}attributeChangedCallback(){this.isConnected&&this.render()}},w=class extends C{render(){let e=Number(this.getAttribute(`value`)??0),t=this.getAttribute(`unit`)===`rial`?`rial`:`toman`,n=this.getAttribute(`from`)===`rial`?`rial`:this.getAttribute(`from`)===`toman`?`toman`:t,i=this.hasAttribute(`compact`),o=c(this),l=this.hasAttribute(`signed`),u=this.getAttribute(`size`)??`md`,f=n===t?e:n===`rial`?y(e):b(e),p=r(),m=s(),h=x(f,{unit:t,compact:i,digits:o,locale:p,showUnit:!1}),g=x(f,{unit:t,compact:i,locale:p}),_=t===`toman`?m.money.toman:m.money.rial,v=g.endsWith(`همت`)?null:_,S=this.getAttribute(`words`)!==`false`&&Number.isSafeInteger(Math.round(f))?`${d(Math.round(f),{locale:p})} ${_}`:null,C=l?f>0?`positive`:f<0?`negative`:null:null,w=S?` aria-hidden="true"`:``;this.innerHTML=`<data value="${f}" class="k-money k-money--${a(u)}"${C?` data-tone="${C}"`:``}${S?` title="${a(S)}"`:``}><span class="k-money__amount"${w}>${l&&f>0?`+`:``}${a(h)}</span>${v?`<span class="k-money__unit"${w}>${v}</span>`:``}${S?`<span class="k-sr-only">${f<0?``:l&&f>0?m.money.positive:``}${a(S)}</span>`:``}</data>`}};w.observedAttributes=[`value`,`unit`,`from`,`compact`,`digits`,`signed`,`words`,`size`];var T=class extends C{render(){let e=S(this.getAttribute(`datetime`));if(!e){this.textContent=``;return}let t=this.getAttribute(`format`),n=t===`numeric`||t===`full`?t:`long`,i=c(this);this.innerHTML=`<time datetime="${a(this.getAttribute(`datetime`))}">${a(u(e,{style:n,digits:i,locale:r()}))}</time>`}};T.observedAttributes=[`datetime`,`format`,`digits`];var E=class extends C{connectedCallback(){super.connectedCallback(),clearInterval(this.timer),this.timer=setInterval(()=>this.render(),Number(this.getAttribute(`refresh`))||6e4)}disconnectedCallback(){clearInterval(this.timer)}render(){let e=S(this.getAttribute(`datetime`));if(!e){this.textContent=``;return}let t=c(this);this.innerHTML=`<time datetime="${e.toISOString()}" title="${a(u(e,{style:`full`,digits:t,locale:r()}))}">${a(g(e,{digits:t,locale:r()}))}</time>`}};E.observedAttributes=[`datetime`,`digits`,`refresh`];const D=e=>String(e).padStart(2,`0`);var O=class extends l{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=S(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 t=this.remaining,r=Math.floor(t/86400),i=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),l=t%60,u=c(this)===`fa`,d=t=>u?e(String(t)):String(t),f=s().countdown,p=[r&&`${d(r)} ${f.days}`,i&&`${d(i)} ${f.hours}`,o&&`${d(o)} ${f.minutes}`,`${d(l)} ${f.seconds}`].filter(Boolean).join(s().common.and),m=this.getAttribute(`label`),h=a(m?`${m}: ${p}`:p),g=t===0?` data-done=""`:``;if(this.getAttribute(`variant`)===`blocks`){let e=[...r?[[r,f.days]]:[],[i,f.hours],[o,f.minutes],[l,f.seconds]];this.innerHTML=`<div role="timer" aria-label="${h}" class="k-countdown k-countdown--blocks"${g}>${e.map(([e,t])=>`<span class="k-countdown__unit" aria-hidden="true"><span class="k-countdown__num">${d(D(e))}</span><span class="k-countdown__name">${t}</span></span>`).join(``)}</div>`}else{let e=(r?`${r}:`:``)+(i||r?`${D(i)}:`:``)+`${D(o)}:${D(l)}`;this.innerHTML=`<span role="timer" aria-label="${h}" class="k-countdown"${g} dir="ltr"><span aria-hidden="true">${d(e)}</span></span>`}t===0&&(clearInterval(this.timer),this.done||(this.done=!0,n(this,`kashi-complete`,{})))}};O.observedAttributes=[`to`,`seconds`,`variant`,`digits`,`label`],o(`kashi-money`,w),o(`kashi-date`,T),o(`kashi-relative-time`,E),o(`kashi-countdown`,O);export{O as KashiCountdown,T as KashiDate,w as KashiMoney,E as KashiRelativeTime};
1
+ import{M as e,S as t,c as n,d as r,k as i,l as a,o,p as s,s as c,t as l,x as u}from"./base-BUQYhiEA.js";import{t as d}from"./words-BdADG_9U.js";const f={دقیقه:`minute`,ساعت:`hour`,روز:`day`,هفته:`week`,ماه:`month`,سال:`year`},p=6e4,m=60*p,h=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();function g(t,{now:n=/* @__PURE__ */ new Date,locale:r=`fa`,digits:i=r===`en`?`latin`:`fa`}={}){let a=r===`en`,o=t.getTime()-n.getTime(),s=o<0,c=Math.abs(o),l=t=>i===`fa`?e(t):String(t),u=(e,t)=>{if(!a)return`${l(e)} ${t} ${s?`پیش`:`دیگر`}`;let n=`${f[t]}${e===1?``:`s`}`;return s?`${l(e)} ${n} ago`:`in ${l(e)} ${n}`};if(c<45e3)return a?`just now`:`همین الان`;if(c<m)return u(Math.max(1,Math.round(c/p)),`دقیقه`);let d=Math.round((h(t)-h(n))/864e5);if(c<6*m||d===0)return u(Math.round(c/m),`ساعت`);if(d===-1)return a?`yesterday`:`دیروز`;if(d===1)return a?`tomorrow`:`فردا`;let g=Math.abs(d);return g<7?u(g,`روز`):g<30?u(Math.round(g/7),`هفته`):g<365?u(Math.max(1,Math.round(g/30.44)),`ماه`):u(Math.round(g/365.25),`سال`)}const _={همت:`trillion`,میلیارد:`billion`,میلیون:`million`,هزار:`thousand`},v=[[0xe8d4a51000,`همت`],[1e9,`میلیارد`],[1e6,`میلیون`],[1e3,`هزار`]],y=e=>Math.round(e/10),b=e=>e*10;function x(t,{unit:n=`toman`,from:r=`toman`,compact:a=!1,showUnit:o=!0,locale:s=`fa`,digits:c=s===`en`?`latin`:`fa`}={}){let l=s===`en`,u=r===n?t:r===`rial`?y(t):b(t),d=u<0?`−`:``;u=Math.abs(u);let f=i(Math.round(u),{digits:c}),p=l?n===`toman`?`Toman`:`Rial`:n===`toman`?`تومان`:`ریال`;if(a){let t=v.find(([e,t])=>u>=e&&(t!==`همت`||n===`toman`&&!l));if(t){let n=Math.round(u/t[0]*100)/100,r=String(n).replace(`.`,c===`fa`?`٫`:`.`);f=`${c===`fa`?e(r):r} ${l?_[t[1]]:t[1]}`,t[1]===`همت`&&(p=``)}}return`${d}${f}${o&&p?` ${p}`:``}`}const S=e=>{if(!e)return null;let n=t(e.trim())??new Date(e);return Number.isNaN(n.getTime())?null:n};var C=class extends l{connectedCallback(){this.render()}attributeChangedCallback(){this.isConnected&&this.render()}},w=class extends C{render(){let e=Number(this.getAttribute(`value`)??0),t=this.getAttribute(`unit`)===`rial`?`rial`:`toman`,n=this.getAttribute(`from`)===`rial`?`rial`:this.getAttribute(`from`)===`toman`?`toman`:t,i=this.hasAttribute(`compact`),o=c(this),l=this.hasAttribute(`signed`),u=this.getAttribute(`size`)??`md`,f=n===t?e:n===`rial`?y(e):b(e),p=r(),m=s(),h=x(f,{unit:t,compact:i,digits:o,locale:p,showUnit:!1}),g=x(f,{unit:t,compact:i,locale:p}),_=t===`toman`?m.money.toman:m.money.rial,v=g.endsWith(`همت`)?null:_,S=this.getAttribute(`words`)!==`false`&&Number.isSafeInteger(Math.round(f))?`${d(Math.round(f),{locale:p})} ${_}`:null,C=l?f>0?`positive`:f<0?`negative`:null:null,w=S?` aria-hidden="true"`:``;this.innerHTML=`<data value="${f}" class="k-money k-money--${a(u)}"${C?` data-tone="${C}"`:``}${S?` title="${a(S)}"`:``}><span class="k-money__amount"${w}>${l&&f>0?`+`:``}${a(h)}</span>${v?`<span class="k-money__unit"${w}>${v}</span>`:``}${S?`<span class="k-sr-only">${f<0?``:l&&f>0?m.money.positive:``}${a(S)}</span>`:``}</data>`}};w.observedAttributes=[`value`,`unit`,`from`,`compact`,`digits`,`signed`,`words`,`size`];var T=class extends C{render(){let e=S(this.getAttribute(`datetime`));if(!e){this.textContent=``;return}let t=this.getAttribute(`format`),n=t===`numeric`||t===`full`?t:`long`,i=c(this);this.innerHTML=`<time datetime="${a(this.getAttribute(`datetime`))}">${a(u(e,{style:n,digits:i,locale:r()}))}</time>`}};T.observedAttributes=[`datetime`,`format`,`digits`];var E=class extends C{connectedCallback(){super.connectedCallback(),clearInterval(this.timer),this.timer=setInterval(()=>this.render(),Number(this.getAttribute(`refresh`))||6e4)}disconnectedCallback(){clearInterval(this.timer)}render(){let e=S(this.getAttribute(`datetime`));if(!e){this.textContent=``;return}let t=c(this);this.innerHTML=`<time datetime="${e.toISOString()}" title="${a(u(e,{style:`full`,digits:t,locale:r()}))}">${a(g(e,{digits:t,locale:r()}))}</time>`}};E.observedAttributes=[`datetime`,`digits`,`refresh`];const D=e=>String(e).padStart(2,`0`);var O=class extends l{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=S(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 t=this.remaining,r=Math.floor(t/86400),i=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),l=t%60,u=c(this)===`fa`,d=t=>u?e(String(t)):String(t),f=s().countdown,p=[r&&`${d(r)} ${f.days}`,i&&`${d(i)} ${f.hours}`,o&&`${d(o)} ${f.minutes}`,`${d(l)} ${f.seconds}`].filter(Boolean).join(s().common.and),m=this.getAttribute(`label`),h=a(m?`${m}: ${p}`:p),g=t===0?` data-done=""`:``;if(this.getAttribute(`variant`)===`blocks`){let e=[...r?[[r,f.days]]:[],[i,f.hours],[o,f.minutes],[l,f.seconds]];this.innerHTML=`<div role="timer" aria-label="${h}" class="k-countdown k-countdown--blocks"${g}>${e.map(([e,t])=>`<span class="k-countdown__unit" aria-hidden="true"><span class="k-countdown__num">${d(D(e))}</span><span class="k-countdown__name">${t}</span></span>`).join(``)}</div>`}else{let e=(r?`${r}:`:``)+(i||r?`${D(i)}:`:``)+`${D(o)}:${D(l)}`;this.innerHTML=`<span role="timer" aria-label="${h}" class="k-countdown"${g} dir="ltr"><span aria-hidden="true">${d(e)}</span></span>`}t===0&&(clearInterval(this.timer),this.done||(this.done=!0,n(this,`kashi-complete`,{})))}};O.observedAttributes=[`to`,`seconds`,`variant`,`digits`,`label`],o(`kashi-money`,w),o(`kashi-date`,T),o(`kashi-relative-time`,E),o(`kashi-countdown`,O);export{O as KashiCountdown,T as KashiDate,w as KashiMoney,E as KashiRelativeTime};
@@ -1 +1 @@
1
- import{A as e,M as t,_ as n,c as r,l as i,o as a,p as o,s,t as c,u as l,v as u,y as d}from"./base-C2zmRRrl.js";var f=class extends c{constructor(){super(...arguments),this.code=``,this.caret=0,this.valueSet=!1,this.rendered=!1,this.key=d(`kashi-otp`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.code=e(this.getAttribute(`value`)??``).slice(0,this.length)),this.render()}attributeChangedCallback(t,n,r){this.rendered&&n!==r&&(t===`value`?(this.code=e(r??``).slice(0,this.length),this.paint()):this.render())}get value(){return this.code}set value(t){this.valueSet=!0,this.code=e(String(t??``)).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 t=this.key,n=this.length,a=Number(this.getAttribute(`group-after`))||0,s=this.getAttribute(`aria-label`),c=this.hasAttribute(`label`)?this.getAttribute(`label`):s?null:o().otp.label,u=Array.from({length:n},(e,t)=>`${a&&t===a?`<span class="k-otp__sep" aria-hidden="true"></span>`:``}<span class="k-otp__slot" aria-hidden="true"></span>`).join(``),d=`<div class="k-otp${this.getAttribute(`size`)===`sm`?` k-otp--sm`:``}"><input id="${t}" class="k-otp__input" type="text" inputmode="numeric" autocomplete="one-time-code" pattern="\\d*" maxlength="${n*2}"${this.hasAttribute(`disabled`)?` disabled`:``}${!c&&s?` aria-label="${i(s)}"`:``}>${u}</div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,l({id:t,label:c,control:d})),this.input=this.querySelector(`.k-otp__input`),this.querySelector(`.k-otp`).addEventListener(`click`,()=>this.input.focus()),this.input.addEventListener(`input`,()=>{let t=e(this.input.value).slice(0,this.length),n=this.code;this.code=t,this.caret=t.length,this.paint(),t!==n&&r(this,`kashi-change`,{value:t}),t.length===this.length&&t!==n&&r(this,`kashi-complete`,{value:t})});let f=()=>{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,f);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),n(this.querySelector(`:scope > .k-field`),this.input,this.key,e,this.getAttribute(`hint`)),u(this,this.getAttribute(`name`),this.code)}paintSlots(){let e=s(this)===`fa`,n=this.ownerDocument.activeElement===this.input,r=Math.min(this.caret,this.length-1);this.querySelectorAll(`.k-otp__slot`).forEach((i,a)=>{let o=this.code[a]??``;i.textContent=e?t(o):o,i.toggleAttribute(`data-filled`,!!o),i.toggleAttribute(`data-active`,n&&a===r)})}};f.observedAttributes=[`label`,`hint`,`error`,`length`,`digits`,`group-after`,`size`,`disabled`,`name`,`value`,`aria-label`],a(`kashi-otp`,f,`block`);export{f as KashiOtp};
1
+ import{A as e,M as t,_ as n,c as r,l as i,o as a,p as o,s,t as c,u as l,v as u,y as d}from"./base-BUQYhiEA.js";var f=class extends c{constructor(){super(...arguments),this.code=``,this.caret=0,this.valueSet=!1,this.rendered=!1,this.key=d(`kashi-otp`)}connectedCallback(){!this.rendered&&!this.valueSet&&(this.code=e(this.getAttribute(`value`)??``).slice(0,this.length)),this.render()}attributeChangedCallback(t,n,r){this.rendered&&n!==r&&(t===`value`?(this.code=e(r??``).slice(0,this.length),this.paint()):this.render())}get value(){return this.code}set value(t){this.valueSet=!0,this.code=e(String(t??``)).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 t=this.key,n=this.length,a=Number(this.getAttribute(`group-after`))||0,s=this.getAttribute(`aria-label`),c=this.hasAttribute(`label`)?this.getAttribute(`label`):s?null:o().otp.label,u=Array.from({length:n},(e,t)=>`${a&&t===a?`<span class="k-otp__sep" aria-hidden="true"></span>`:``}<span class="k-otp__slot" aria-hidden="true"></span>`).join(``),d=`<div class="k-otp${this.getAttribute(`size`)===`sm`?` k-otp--sm`:``}"><input id="${t}" class="k-otp__input" type="text" inputmode="numeric" autocomplete="one-time-code" pattern="\\d*" maxlength="${n*2}"${this.hasAttribute(`disabled`)?` disabled`:``}${!c&&s?` aria-label="${i(s)}"`:``}>${u}</div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,l({id:t,label:c,control:d})),this.input=this.querySelector(`.k-otp__input`),this.querySelector(`.k-otp`).addEventListener(`click`,()=>this.input.focus()),this.input.addEventListener(`input`,()=>{let t=e(this.input.value).slice(0,this.length),n=this.code;this.code=t,this.caret=t.length,this.paint(),t!==n&&r(this,`kashi-change`,{value:t}),t.length===this.length&&t!==n&&r(this,`kashi-complete`,{value:t})});let f=()=>{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,f);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),n(this.querySelector(`:scope > .k-field`),this.input,this.key,e,this.getAttribute(`hint`)),u(this,this.getAttribute(`name`),this.code)}paintSlots(){let e=s(this)===`fa`,n=this.ownerDocument.activeElement===this.input,r=Math.min(this.caret,this.length-1);this.querySelectorAll(`.k-otp__slot`).forEach((i,a)=>{let o=this.code[a]??``;i.textContent=e?t(o):o,i.toggleAttribute(`data-filled`,!!o),i.toggleAttribute(`data-active`,n&&a===r)})}};f.observedAttributes=[`label`,`hint`,`error`,`length`,`digits`,`group-after`,`size`,`disabled`,`name`,`value`,`aria-label`],a(`kashi-otp`,f,`block`);export{f as KashiOtp};
@@ -1 +1 @@
1
- import{A as e,M as t,_ as n,c as r,d as i,f as a,i as o,k as s,l as c,m as l,o as u,p as d,r as f,s as p,t as m,u as h,v as g,y as _}from"./base-C2zmRRrl.js";import{t as v}from"./text-Dhwh21Us.js";import{n as y,t as b}from"./time-Bd1ee8FP.js";import{searchText as x}from"./combobox-Bxc9krdH.js";const S=[`الف`,`ب`,`پ`,`ت`,`ث`,`ج`,`د`,`ز`,`س`,`ش`,`ص`,`ط`,`ع`,`ف`,`ق`,`ک`,`گ`,`ل`,`م`,`ن`,`و`,`ه`,`ی`,`ژ`],C={الف:`government`,پ:`police`,ث:`police`,ت:`taxi`,ع:`public`,ک:`agricultural`,ش:`army`,ز:`defense`,ف:`defense`,ژ:`disabled`};function w(e){return C[e]??`private`}function T(t){let n=e(t.first??``),r=e(t.middle??``),i=e(t.region??``);return/^[1-9]\d$/.test(n)&&/^[1-9]\d{2}$/.test(r)&&/^[1-9]\d$/.test(i)&&S.includes(t.letter??``)}function E(n,{digits:r=`fa`}={}){let i=n=>r===`fa`?t(e(n)):e(n);return`${i(n.first)} ${n.letter} ${i(n.middle)} ایران ${i(n.region)}`}const D=`ضصثقفغعهخحجچپشسیبلاتنمکگظطزرذدپوژ؟آ`,O=/* @__PURE__ */ new Map,k=/* @__PURE__ */ new Map;[...`qwertyuiop[]\\asdfghjkl;'zxcvbnm,C?H`].forEach((e,t)=>{O.set(e,D[t]),k.has(D[t])||k.set(D[t],e)});function A(e,t=`fa`){let n=t===`fa`?O:k;return[...e].map(e=>n.get(t===`fa`&&e!==`C`&&e!==`H`?e.toLowerCase():e)??e).join(``)}function j(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 M=`<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>`,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>`;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)e.insertAdjacentHTML(`beforeend`,`<input type="hidden" data-kashi-value name="${c(t)}" value="${c(r)}">`)}function F(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 I=class extends m{constructor(){super(...arguments),this.list=null,this.chosen=[],this.query=``,this.active=-1,this.isOpen=!1,this.valueSet=!1,this.key=_(`kashi-multi`),this.onOutside=e=>{this.contains(e.target)||this.close()}}connectedCallback(){f(()=>{if(this.isConnected){if(this.list===null){let e=F(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,t=this.getAttribute(`aria-label`),n=this.hasAttribute(`label`)?this.getAttribute(`label`):t?null:d().multiSelect.label,r=`<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`:``}${!n&&t?` aria-label="${c(t)}"`:``}></div><ul id="${e}-list" role="listbox" aria-multiselectable="true" class="k-listbox" hidden style="inset-block-start: calc(100% + 6px)"${n?` aria-label="${c(n)}"`:``}></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`,h({id:e,label:n,control:r})),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),d().common.removed(this.labelOf(t.dataset.remove))):e.target.closest(`[data-clear]`)&&this.set([],d().multiSelect.clearedAll),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=x(this.query.trim());return this.options.filter(t=>!e||[t.label,t.description??``].some(t=>x(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(d().common.max(l(this,Number(this.getAttribute(`max`)))));this.query=``,this.input.value=``,this.set(t?this.chosen.filter(t=>t!==e.value):[...this.chosen,e.value],t?d().common.removed(e.label):d().common.selected(e.label))}set(e,t){this.chosen=e,this.paint(),this.announce(t),r(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),d().common.removed(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`}">${c(this.labelOf(t))}${e?``:`<button type="button" class="k-badge__remove" data-remove="${c(t)}" aria-label="${c(d().common.remove(this.labelOf(t)))}">${N}</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="${c(d().common.clearAll)}">${N}</button>`),this.input.placeholder=this.chosen.length?``:this.getAttribute(`placeholder`)??``,this.querySelector(`#${this.key}-count`).textContent=d().multiSelect.selected(l(this,this.chosen.length));let r=this.getAttribute(`error`);this.box.toggleAttribute(`data-invalid`,!!r),n(this.querySelector(`:scope > .k-field`),this.input,this.key,r,this.getAttribute(`hint`),`${this.key}-count`),P(this,this.getAttribute(`name`),this.chosen),this.isOpen&&this.paintList()}paintList(){let e=this.filtered(),t=x(this.query.trim()),n=this.full,r=e=>{let n=t?x(e).indexOf(t):-1;return n<0?c(e):`${c(e.slice(0,n))}<mark>${c(e.slice(n,n+t.length))}</mark>${c(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?M:``}</span><span class="k-option__body"><span>${r(e.label)}</span>${e.description?`<span class="k-option__desc">${c(e.description)}</span>`:``}</span></li>`}).join(``):`<li class="k-listbox__empty" role="presentation">${c(d().common.noResults)}</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`)}};I.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`max`,`disabled`,`name`,`aria-label`];var L=class extends m{constructor(){super(...arguments),this.lo=0,this.hi=0,this.valueSet=!1,this.rendered=!1,this.key=_(`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`${s(e,{digits:p(this)})}${t?` ${t}`:``}`}render(){let e=this.getAttribute(`label`),t=this.isRange,n=this.getAttribute(`name`),i=this.hasAttribute(`disabled`),a=e=>`${(e-this.min)/(this.max-this.min)*100}%`,o=r=>{let a=r===`lo`?this.lo:this.hi,o=n?t?`${n}_${r===`lo`?`min`:`max`}`:n:``;return`<input type="range" class="k-slider__input" data-which="${r}" min="${this.min}" max="${this.max}" step="${this.num(`step`,1)}" value="${a}"${i?` disabled`:``}${o?` name="${c(o)}"`:``}${t?` aria-label="${c(r===`lo`?d().slider.from:d().slider.to)}${e?` ${c(e)}`:``}"`:e?` aria-labelledby="${this.key}-label"`:``} aria-valuetext="${c(this.fmt(a))}">`},s=(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">${c(e)}</span>`:``}${l?`<span class="k-slider__value" aria-hidden="true">${c(t?`${this.fmt(this.lo)}${d().common.range}${this.fmt(this.hi)}`:this.fmt(this.hi))}</span>`:``}</div>`:``}<div class="k-slider__track" style="--_from: ${t?a(this.lo):`0%`}; --_to: ${a(this.hi)}"><span class="k-slider__fill" aria-hidden="true"></span>${t?o(`lo`):``}${o(`hi`)}</div>${s.length?`<div class="k-slider__marks" aria-hidden="true">${s.map(e=>`<span>${c(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 i=this.querySelector(`.k-slider__track`);i.style.setProperty(`--_from`,t?a(this.lo):`0%`),i.style.setProperty(`--_to`,a(this.hi));let o=this.querySelector(`.k-slider__value`);o&&(o.textContent=t?`${this.fmt(this.lo)}${d().common.range}${this.fmt(this.hi)}`:this.fmt(this.hi)),r(this,`kashi-change`,{value:this.value})}))}};L.observedAttributes=[`label`,`min`,`max`,`step`,`value`,`range`,`show-value`,`marks`,`unit`,`disabled`,`name`];var R=class extends m{constructor(){super(...arguments),this.built=!1}connectedCallback(){f(()=>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">${l(this,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`;o(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){P(this,this.getAttribute(`name`),this.value),e&&r(this,`kashi-change`,{value:this.value})}};R.observedAttributes=[`label`,`single`,`name`];const z=[[e=>e.length(a()===`fa`?t(8):`8`),e=>e.length>=8],[e=>e.cases,e=>/[a-z]/.test(e)&&/[A-Z]/.test(e)],[e=>e.digit,e=>/\d/.test(e)],[e=>e.symbol,e=>/[^A-Za-z0-9\s؀-ۿ]/.test(e)]];var B=class extends m{constructor(){super(...arguments),this.target=null,this.onInput=()=>this.render(this.target?.value??``)}connectedCallback(){f(()=>{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||=_(`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=z.filter(([,t])=>t(e)).length;return e?Math.max(1,Math.round(t/z.length*4)):0}render(e){let t=this.score(e),n=d().password,r=n.levels,i=/[؀-ۿ]/.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?c(n.strength(`\0`)).replace(`\0`,`<strong>${c(r[t-1])}</strong>`):``}</p>${i?`<p class="k-hint k-hint--error" role="alert">${c(n.persian)}</p>`:``}${this.getAttribute(`show-rules`)===`false`?``:`<ul class="k-strength__rules">${z.map(([t,r])=>{let i=r(e);return`<li class="k-strength__rule"${i?` data-met=""`:``}>${i?M:`<svg viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="2.5" fill="currentColor"/></svg>`}<span>${c(t(n))}<span class="k-sr-only">${i?n.met:n.unmet}</span></span></li>`}).join(``)}</ul>`}</div>`}};B.observedAttributes=[`for`,`show-rules`];var V=class extends m{constructor(){super(...arguments),this.key=_(`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,t=this.getAttribute(`aria-label`),n=this.hasAttribute(`label`)?this.getAttribute(`label`):t?null:this.defaultLabel,i=this.getAttribute(`name`),a=`id="${e}" class="k-input__control" dir="auto"${i?` name="${c(i)}"`:``}${this.hasAttribute(`required`)?` required`:``}${this.hasAttribute(`disabled`)?` disabled`:``} placeholder="${c(this.getAttribute(`placeholder`)??``)}"${!n&&t?` aria-label="${c(t)}"`:``}`,o=this.multiline?`<div class="k-input k-input--textarea"><textarea ${a} rows="${Number(this.getAttribute(`rows`))||4}"></textarea></div>`:`<div class="k-input"><input ${a}></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,h({id:e,label:n,required:this.hasAttribute(`required`),control:o})),this.control=this.querySelector(`.k-input__control`),this.control.value=this.text,this.control.addEventListener(`input`,()=>{this.text=this.control.value,this.paint(),r(this,`kashi-change`,{value:this.text})}),this.rendered=!0,this.paint()}paint(){let e=this.querySelector(`:scope > .k-field`);n(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(),r(this,`kashi-change`,{value:e})}};const H=[`arabic`,`zwnj`,`punctuation`,`digits`,`spacing`];var U=class extends V{constructor(){super(...arguments),this.multiline=!0}get defaultLabel(){return d().persianInput.text}render(){super.render(),this.control.addEventListener(`blur`,()=>{let e=this.result();o(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 v(this.text,{digits:this.getAttribute(`fix-digits`)!==`false`})}hint(){if(!this.text.trim())return this.getAttribute(`hint`)?c(this.getAttribute(`hint`)):null;let e=this.result();if(!e.count)return`<span class="k-textfix" data-state="clean"><span class="k-textfix__text">${c(d().textFix.clean)}</span></span>`;let t=d().textFix,n=H.filter(t=>e.fixes[t]).map(n=>`${l(this,e.fixes[n])} ${t[n]}`).join(d().common.list);return`<span class="k-textfix" data-state="fix"><span class="k-textfix__text">${c(t.count(l(this,e.count),n))}</span><button type="button" class="k-btn k-btn--tertiary k-btn--xs" data-fix>${c(t.fix)}</button></span>`}};U.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`required`,`disabled`,`name`,`value`,`rows`,`fix-on-blur`,`fix-digits`,`aria-label`];var W=class extends V{constructor(){super(...arguments),this.multiline=!1}get defaultLabel(){return d().persianInput.text}render(){super.render(),this.addEventListener(`click`,e=>{e.target.closest(`[data-fix]`)&&this.replace(A(this.text))})}hint(){let e=this.text,t=/[a-z]/i.test(e)&&!/[؀-ۿ]/.test(e);return(this.getAttribute(`suggest`)===`always`?t:j(e))?`<span class="k-kbfix" role="status">${c(d().keyboardFix.before)} <button type="button" class="k-kbfix__btn" data-fix>«${c(A(e))}»</button>${i()===`en`?``:` `}${c(d().keyboardFix.after)}</span>`:this.getAttribute(`hint`)?c(this.getAttribute(`hint`)):null}};W.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`required`,`disabled`,`name`,`value`,`suggest`,`aria-label`];const G=e=>e.hours*60+e.minutes,K=e=>({hours:Math.floor(e/60),minutes:e%60});var q=class extends m{constructor(){super(...arguments),this.current=null,this.invalid=!1,this.valueSet=!1,this.rendered=!1,this.key=_(`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?y(e):null;return t?b(t):null}show(e){return e?p(this)===`latin`?e:t(e):``}get lo(){let e=y(this.getAttribute(`min`)??``);return e?G(e):0}get hi(){let e=y(this.getAttribute(`max`)??``);return e?G(e):1439}render(){let e=this.key,t=this.getAttribute(`aria-label`),n=this.hasAttribute(`label`)?this.getAttribute(`label`):t?null:d().persianInput.time,r=p(this)===`fa`,i=`<div class="k-input"><input id="${e}" class="k-input__control" type="text" inputmode="numeric" dir="ltr" autocomplete="off" placeholder="${c(this.getAttribute(`placeholder`)??(r?`۰۹:۳۰`:`09:30`))}"${this.hasAttribute(`required`)?` required`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${!n&&t?` aria-label="${c(t)}"`:``}><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`,h({id:e,label:n,required:this.hasAttribute(`required`),control:i})),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=y(this.input.value)??y(this.current??``)??K(this.lo),r=G(n),i=e.key===`ArrowUp`?Math.floor(r/t)*t+t:Math.ceil(r/t)*t-t;this.commit(K(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=y(e);if(!t)this.invalid=`format`;else if(G(t)<this.lo||G(t)>this.hi)this.invalid=`range`;else return this.commit(t);this.paint(!1)}commit(e){let t=e?b(e):null,n=t!==this.current;this.current=t,this.invalid=!1,this.paint(),n&&r(this,`kashi-change`,{value:t??``})}paint(e=!0){e&&(this.input.value=this.show(this.current));let t=this.invalid===`range`?d().invalid.timeRange(this.show(b(K(this.lo))),this.show(b(K(this.hi)))):this.invalid?d().invalid.time:null;this.input.setCustomValidity(t??``),n(this.querySelector(`:scope > .k-field`),this.input,this.key,this.getAttribute(`error`)||t,this.getAttribute(`hint`)),g(this,this.getAttribute(`name`),this.current??``)}};q.observedAttributes=[`label`,`hint`,`error`,`value`,`min`,`max`,`step`,`digits`,`required`,`disabled`,`name`,`placeholder`,`aria-label`];const J={first:``,letter:``,middle:``,region:``};var Y=class extends m{constructor(){super(...arguments),this.plate={...J},this.touched=!1,this.valueSet=!1,this.rendered=!1,this.key=_(`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(t){let[n=``,r=``,i=``,a=``]=(t??``).split(`-`);return{first:e(n),letter:r,middle:e(i),region:e(a)}}get value(){return{...this.plate}}set value(e){this.valueSet=!0,this.plate={...J,...e},this.rendered&&this.render()}get valid(){return T(this.plate)}render(){let n=this.key,i=this.plate,a=this.hasAttribute(`disabled`)?` disabled`:``,o=(e,r,o,s=``,c=!1)=>`<input${c?` id="${n}-first"`:``} class="k-plate__seg ${s}" data-key="${e}" data-len="${r}" inputmode="numeric" autocomplete="off" aria-label="${o}" placeholder="${t(`0`.repeat(r))}" value="${t(i[e])}"${a}>`,s=d().plate,l=this.getAttribute(`label`)??s.label,u=`<div class="k-plate" role="group" aria-label="${c(l)}" data-type="${w(i.letter)}"><span class="k-plate__flag" aria-hidden="true"><span class="k-plate__flag-colors"></span>I.R.<br>IRAN</span>${o(`first`,2,s.first,``,!0)}<select class="k-plate__letter" data-key="letter" aria-label="${c(s.letter)}"${a}><option value="">–</option>${S.map(e=>`<option value="${e}"${e===i.letter?` selected`:``}>${e===`ه`?`هـ`:e}</option>`).join(``)}</select>${o(`middle`,3,s.middle,`k-plate__seg--3`)}<span class="k-plate__region"><span class="k-plate__region-label" aria-hidden="true">ایران</span>${o(`region`,2,s.region)}</span></div><span class="k-sr-only" aria-live="polite"></span>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,h({id:`${n}-first`,label:l,control:u}));let f=[...this.querySelectorAll(`[data-key]`)];f.forEach((n,i)=>{n.addEventListener(n instanceof HTMLSelectElement?`change`:`input`,()=>{let a=n.dataset.key;if(n instanceof HTMLSelectElement)this.plate.letter=n.value,n.value&&f[i+1]?.focus();else{let r=Number(n.dataset.len),o=e(n.value);a===`middle`&&o.length>r&&(this.plate.region=(this.plate.region+o.slice(r)).slice(0,2)),this.plate[a]=o.slice(0,r),n.value=t(this.plate[a]),this.plate[a].length===r&&f[i+1]?.focus()}this.paint(),r(this,`kashi-change`,{value:this.value,valid:this.valid})}),n.addEventListener(`keydown`,e=>{e.key===`Backspace`&&!n.value&&f[i-1]?.focus()})});let p=this.querySelector(`.k-plate`);p.addEventListener(`focusout`,e=>{p.contains(e.relatedTarget)||(this.touched=!0,this.paint())}),this.rendered=!0,this.paint()}paint(){let e=this.plate,r=this.querySelector(`.k-plate`),i=this.querySelector(`[data-key="region"]`);i.value!==t(e.region)&&(i.value=t(e.region)),r.dataset.type=w(e.letter);let a=e.first.length===2&&!!e.letter&&e.middle.length===3&&e.region.length===2,o=(this.touched||a)&&Object.values(e).some(Boolean)&&!this.valid,s=this.getAttribute(`error`)||(o?d().invalid.plate:null);r.toggleAttribute(`data-invalid`,!!s),n(this.querySelector(`:scope > .k-field`),r,this.key,s,this.getAttribute(`hint`)),this.querySelector(`.k-field > .k-sr-only`).textContent=this.valid?E(e):``;let l=this.getAttribute(`name`);if(this.querySelectorAll(`:scope > input[type=hidden]`).forEach(e=>e.remove()),l)for(let t of[`first`,`letter`,`middle`,`region`])this.insertAdjacentHTML(`beforeend`,`<input type="hidden" name="${c(`${l}_${t}`)}" value="${c(e[t])}">`)}};Y.observedAttributes=[`label`,`hint`,`error`,`name`,`disabled`,`value`];var X=class extends m{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`)??d().persianInput.text;this.rendered=!0,this.editing=!1,this.innerHTML=`<span class="k-inline-edit"><button type="button" class="k-inline-edit__view" aria-label="${c(`${t}: ${this.text||d().inlineEdit.empty}${d().common.list}${d().common.edit}`)}">${this.text?c(this.text):`<span class="k-inline-edit__placeholder">${c(this.getAttribute(`placeholder`)??d().inlineEdit.empty)}</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 n=this.getAttribute(`label`)??d().persianInput.text,r=_(`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="${c(n)}" placeholder="${c(this.getAttribute(`placeholder`)??``)}"${e?` aria-invalid="true" aria-describedby="${r}"`:``}></span>${e?`<span class="k-hint k-hint--error" id="${r}">${c(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="${c(d().common.save)}">${M}</button><button type="button" class="k-btn k-btn--secondary k-btn--icon k-btn--sm" data-cancel aria-label="${c(d().common.cancel)}">${N}</button></span></span>`;let i=this.querySelector(`input`);i.value=t,i.focus(),i.select(),i.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),this.commit(i.value)):e.key===`Escape`&&(e.preventDefault(),this.render(!0))}),this.querySelector(`[data-save]`).addEventListener(`click`,()=>this.commit(i.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 i=this.text,a=null;if(r(this,`kashi-save`,{value:t,wait:e=>a=e}),this.text=t,a){this.querySelector(`[data-save]`)?.setAttribute(`aria-busy`,`true`);try{await a}catch{return this.text=i,this.edit(d().inlineEdit.failed,e)}}this.render(!0),r(this,`kashi-change`,{value:t})}};X.observedAttributes=[`value`,`label`,`placeholder`],u(`kashi-multi-select`,I,`block`),u(`kashi-slider`,L,`block`),u(`kashi-chip-group`,R),u(`kashi-password-strength`,B,`block`),u(`kashi-persian-textarea`,U,`block`),u(`kashi-keyboard-fix`,W,`block`),u(`kashi-time-input`,q,`block`),u(`kashi-plate-input`,Y,`block`),u(`kashi-inline-edit`,X);export{R as KashiChipGroup,X as KashiInlineEdit,W as KashiKeyboardFix,I as KashiMultiSelect,B as KashiPasswordStrength,U as KashiPersianTextarea,Y as KashiPlateInput,L as KashiSlider,q as KashiTimeInput};
1
+ import{A as e,M as t,_ as n,c as r,d as i,f as a,i as o,k as s,l as c,m as l,o as u,p as d,r as f,s as p,t as m,u as h,v as g,y as _}from"./base-BUQYhiEA.js";import{t as v}from"./text-BcDsKxe_.js";import{n as y,t as b}from"./time-Chd8ZdFw.js";import{searchText as x}from"./combobox-Br5cwZFz.js";const S=[`الف`,`ب`,`پ`,`ت`,`ث`,`ج`,`د`,`ز`,`س`,`ش`,`ص`,`ط`,`ع`,`ف`,`ق`,`ک`,`گ`,`ل`,`م`,`ن`,`و`,`ه`,`ی`,`ژ`],C={الف:`government`,پ:`police`,ث:`police`,ت:`taxi`,ع:`public`,ک:`agricultural`,ش:`army`,ز:`defense`,ف:`defense`,ژ:`disabled`};function w(e){return C[e]??`private`}function T(t){let n=e(t.first??``),r=e(t.middle??``),i=e(t.region??``);return/^[1-9]\d$/.test(n)&&/^[1-9]\d{2}$/.test(r)&&/^[1-9]\d$/.test(i)&&S.includes(t.letter??``)}function E(n,{digits:r=`fa`}={}){let i=n=>r===`fa`?t(e(n)):e(n);return`${i(n.first)} ${n.letter} ${i(n.middle)} ایران ${i(n.region)}`}const D=`ضصثقفغعهخحجچپشسیبلاتنمکگظطزرذدپوژ؟آ`,O=/* @__PURE__ */ new Map,k=/* @__PURE__ */ new Map;[...`qwertyuiop[]\\asdfghjkl;'zxcvbnm,C?H`].forEach((e,t)=>{O.set(e,D[t]),k.has(D[t])||k.set(D[t],e)});function A(e,t=`fa`){let n=t===`fa`?O:k;return[...e].map(e=>n.get(t===`fa`&&e!==`C`&&e!==`H`?e.toLowerCase():e)??e).join(``)}function j(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 M=`<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>`,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>`;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)e.insertAdjacentHTML(`beforeend`,`<input type="hidden" data-kashi-value name="${c(t)}" value="${c(r)}">`)}function F(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 I=class extends m{constructor(){super(...arguments),this.list=null,this.chosen=[],this.query=``,this.active=-1,this.isOpen=!1,this.valueSet=!1,this.key=_(`kashi-multi`),this.onOutside=e=>{this.contains(e.target)||this.close()}}connectedCallback(){f(()=>{if(this.isConnected){if(this.list===null){let e=F(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,t=this.getAttribute(`aria-label`),n=this.hasAttribute(`label`)?this.getAttribute(`label`):t?null:d().multiSelect.label,r=`<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`:``}${!n&&t?` aria-label="${c(t)}"`:``}></div><ul id="${e}-list" role="listbox" aria-multiselectable="true" class="k-listbox" hidden style="inset-block-start: calc(100% + 6px)"${n?` aria-label="${c(n)}"`:``}></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`,h({id:e,label:n,control:r})),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),d().common.removed(this.labelOf(t.dataset.remove))):e.target.closest(`[data-clear]`)&&this.set([],d().multiSelect.clearedAll),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=x(this.query.trim());return this.options.filter(t=>!e||[t.label,t.description??``].some(t=>x(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(d().common.max(l(this,Number(this.getAttribute(`max`)))));this.query=``,this.input.value=``,this.set(t?this.chosen.filter(t=>t!==e.value):[...this.chosen,e.value],t?d().common.removed(e.label):d().common.selected(e.label))}set(e,t){this.chosen=e,this.paint(),this.announce(t),r(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),d().common.removed(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`}">${c(this.labelOf(t))}${e?``:`<button type="button" class="k-badge__remove" data-remove="${c(t)}" aria-label="${c(d().common.remove(this.labelOf(t)))}">${N}</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="${c(d().common.clearAll)}">${N}</button>`),this.input.placeholder=this.chosen.length?``:this.getAttribute(`placeholder`)??``,this.querySelector(`#${this.key}-count`).textContent=d().multiSelect.selected(l(this,this.chosen.length));let r=this.getAttribute(`error`);this.box.toggleAttribute(`data-invalid`,!!r),n(this.querySelector(`:scope > .k-field`),this.input,this.key,r,this.getAttribute(`hint`),`${this.key}-count`),P(this,this.getAttribute(`name`),this.chosen),this.isOpen&&this.paintList()}paintList(){let e=this.filtered(),t=x(this.query.trim()),n=this.full,r=e=>{let n=t?x(e).indexOf(t):-1;return n<0?c(e):`${c(e.slice(0,n))}<mark>${c(e.slice(n,n+t.length))}</mark>${c(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?M:``}</span><span class="k-option__body"><span>${r(e.label)}</span>${e.description?`<span class="k-option__desc">${c(e.description)}</span>`:``}</span></li>`}).join(``):`<li class="k-listbox__empty" role="presentation">${c(d().common.noResults)}</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`)}};I.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`max`,`disabled`,`name`,`aria-label`];var L=class extends m{constructor(){super(...arguments),this.lo=0,this.hi=0,this.valueSet=!1,this.rendered=!1,this.key=_(`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`${s(e,{digits:p(this)})}${t?` ${t}`:``}`}render(){let e=this.getAttribute(`label`),t=this.isRange,n=this.getAttribute(`name`),i=this.hasAttribute(`disabled`),a=e=>`${(e-this.min)/(this.max-this.min)*100}%`,o=r=>{let a=r===`lo`?this.lo:this.hi,o=n?t?`${n}_${r===`lo`?`min`:`max`}`:n:``;return`<input type="range" class="k-slider__input" data-which="${r}" min="${this.min}" max="${this.max}" step="${this.num(`step`,1)}" value="${a}"${i?` disabled`:``}${o?` name="${c(o)}"`:``}${t?` aria-label="${c(r===`lo`?d().slider.from:d().slider.to)}${e?` ${c(e)}`:``}"`:e?` aria-labelledby="${this.key}-label"`:``} aria-valuetext="${c(this.fmt(a))}">`},s=(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">${c(e)}</span>`:``}${l?`<span class="k-slider__value" aria-hidden="true">${c(t?`${this.fmt(this.lo)}${d().common.range}${this.fmt(this.hi)}`:this.fmt(this.hi))}</span>`:``}</div>`:``}<div class="k-slider__track" style="--_from: ${t?a(this.lo):`0%`}; --_to: ${a(this.hi)}"><span class="k-slider__fill" aria-hidden="true"></span>${t?o(`lo`):``}${o(`hi`)}</div>${s.length?`<div class="k-slider__marks" aria-hidden="true">${s.map(e=>`<span>${c(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 i=this.querySelector(`.k-slider__track`);i.style.setProperty(`--_from`,t?a(this.lo):`0%`),i.style.setProperty(`--_to`,a(this.hi));let o=this.querySelector(`.k-slider__value`);o&&(o.textContent=t?`${this.fmt(this.lo)}${d().common.range}${this.fmt(this.hi)}`:this.fmt(this.hi)),r(this,`kashi-change`,{value:this.value})}))}};L.observedAttributes=[`label`,`min`,`max`,`step`,`value`,`range`,`show-value`,`marks`,`unit`,`disabled`,`name`];var R=class extends m{constructor(){super(...arguments),this.built=!1}connectedCallback(){f(()=>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">${l(this,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`;o(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){P(this,this.getAttribute(`name`),this.value),e&&r(this,`kashi-change`,{value:this.value})}};R.observedAttributes=[`label`,`single`,`name`];const z=[[e=>e.length(a()===`fa`?t(8):`8`),e=>e.length>=8],[e=>e.cases,e=>/[a-z]/.test(e)&&/[A-Z]/.test(e)],[e=>e.digit,e=>/\d/.test(e)],[e=>e.symbol,e=>/[^A-Za-z0-9\s؀-ۿ]/.test(e)]];var B=class extends m{constructor(){super(...arguments),this.target=null,this.onInput=()=>this.render(this.target?.value??``)}connectedCallback(){f(()=>{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||=_(`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=z.filter(([,t])=>t(e)).length;return e?Math.max(1,Math.round(t/z.length*4)):0}render(e){let t=this.score(e),n=d().password,r=n.levels,i=/[؀-ۿ]/.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?c(n.strength(`\0`)).replace(`\0`,`<strong>${c(r[t-1])}</strong>`):``}</p>${i?`<p class="k-hint k-hint--error" role="alert">${c(n.persian)}</p>`:``}${this.getAttribute(`show-rules`)===`false`?``:`<ul class="k-strength__rules">${z.map(([t,r])=>{let i=r(e);return`<li class="k-strength__rule"${i?` data-met=""`:``}>${i?M:`<svg viewBox="0 0 20 20" aria-hidden="true"><circle cx="10" cy="10" r="2.5" fill="currentColor"/></svg>`}<span>${c(t(n))}<span class="k-sr-only">${i?n.met:n.unmet}</span></span></li>`}).join(``)}</ul>`}</div>`}};B.observedAttributes=[`for`,`show-rules`];var V=class extends m{constructor(){super(...arguments),this.key=_(`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,t=this.getAttribute(`aria-label`),n=this.hasAttribute(`label`)?this.getAttribute(`label`):t?null:this.defaultLabel,i=this.getAttribute(`name`),a=`id="${e}" class="k-input__control" dir="auto"${i?` name="${c(i)}"`:``}${this.hasAttribute(`required`)?` required`:``}${this.hasAttribute(`disabled`)?` disabled`:``} placeholder="${c(this.getAttribute(`placeholder`)??``)}"${!n&&t?` aria-label="${c(t)}"`:``}`,o=this.multiline?`<div class="k-input k-input--textarea"><textarea ${a} rows="${Number(this.getAttribute(`rows`))||4}"></textarea></div>`:`<div class="k-input"><input ${a}></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,h({id:e,label:n,required:this.hasAttribute(`required`),control:o})),this.control=this.querySelector(`.k-input__control`),this.control.value=this.text,this.control.addEventListener(`input`,()=>{this.text=this.control.value,this.paint(),r(this,`kashi-change`,{value:this.text})}),this.rendered=!0,this.paint()}paint(){let e=this.querySelector(`:scope > .k-field`);n(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(),r(this,`kashi-change`,{value:e})}};const H=[`arabic`,`zwnj`,`punctuation`,`digits`,`spacing`];var U=class extends V{constructor(){super(...arguments),this.multiline=!0}get defaultLabel(){return d().persianInput.text}render(){super.render(),this.control.addEventListener(`blur`,()=>{let e=this.result();o(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 v(this.text,{digits:this.getAttribute(`fix-digits`)!==`false`})}hint(){if(!this.text.trim())return this.getAttribute(`hint`)?c(this.getAttribute(`hint`)):null;let e=this.result();if(!e.count)return`<span class="k-textfix" data-state="clean"><span class="k-textfix__text">${c(d().textFix.clean)}</span></span>`;let t=d().textFix,n=H.filter(t=>e.fixes[t]).map(n=>`${l(this,e.fixes[n])} ${t[n]}`).join(d().common.list);return`<span class="k-textfix" data-state="fix"><span class="k-textfix__text">${c(t.count(l(this,e.count),n))}</span><button type="button" class="k-btn k-btn--tertiary k-btn--xs" data-fix>${c(t.fix)}</button></span>`}};U.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`required`,`disabled`,`name`,`value`,`rows`,`fix-on-blur`,`fix-digits`,`aria-label`];var W=class extends V{constructor(){super(...arguments),this.multiline=!1}get defaultLabel(){return d().persianInput.text}render(){super.render(),this.addEventListener(`click`,e=>{e.target.closest(`[data-fix]`)&&this.replace(A(this.text))})}hint(){let e=this.text,t=/[a-z]/i.test(e)&&!/[؀-ۿ]/.test(e);return(this.getAttribute(`suggest`)===`always`?t:j(e))?`<span class="k-kbfix" role="status">${c(d().keyboardFix.before)} <button type="button" class="k-kbfix__btn" data-fix>«${c(A(e))}»</button>${i()===`en`?``:` `}${c(d().keyboardFix.after)}</span>`:this.getAttribute(`hint`)?c(this.getAttribute(`hint`)):null}};W.observedAttributes=[`label`,`hint`,`error`,`placeholder`,`required`,`disabled`,`name`,`value`,`suggest`,`aria-label`];const G=e=>e.hours*60+e.minutes,K=e=>({hours:Math.floor(e/60),minutes:e%60});var q=class extends m{constructor(){super(...arguments),this.current=null,this.invalid=!1,this.valueSet=!1,this.rendered=!1,this.key=_(`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?y(e):null;return t?b(t):null}show(e){return e?p(this)===`latin`?e:t(e):``}get lo(){let e=y(this.getAttribute(`min`)??``);return e?G(e):0}get hi(){let e=y(this.getAttribute(`max`)??``);return e?G(e):1439}render(){let e=this.key,t=this.getAttribute(`aria-label`),n=this.hasAttribute(`label`)?this.getAttribute(`label`):t?null:d().persianInput.time,r=p(this)===`fa`,i=`<div class="k-input"><input id="${e}" class="k-input__control" type="text" inputmode="numeric" dir="ltr" autocomplete="off" placeholder="${c(this.getAttribute(`placeholder`)??(r?`۰۹:۳۰`:`09:30`))}"${this.hasAttribute(`required`)?` required`:``}${this.hasAttribute(`disabled`)?` disabled`:``}${!n&&t?` aria-label="${c(t)}"`:``}><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`,h({id:e,label:n,required:this.hasAttribute(`required`),control:i})),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=y(this.input.value)??y(this.current??``)??K(this.lo),r=G(n),i=e.key===`ArrowUp`?Math.floor(r/t)*t+t:Math.ceil(r/t)*t-t;this.commit(K(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=y(e);if(!t)this.invalid=`format`;else if(G(t)<this.lo||G(t)>this.hi)this.invalid=`range`;else return this.commit(t);this.paint(!1)}commit(e){let t=e?b(e):null,n=t!==this.current;this.current=t,this.invalid=!1,this.paint(),n&&r(this,`kashi-change`,{value:t??``})}paint(e=!0){e&&(this.input.value=this.show(this.current));let t=this.invalid===`range`?d().invalid.timeRange(this.show(b(K(this.lo))),this.show(b(K(this.hi)))):this.invalid?d().invalid.time:null;this.input.setCustomValidity(t??``),n(this.querySelector(`:scope > .k-field`),this.input,this.key,this.getAttribute(`error`)||t,this.getAttribute(`hint`)),g(this,this.getAttribute(`name`),this.current??``)}};q.observedAttributes=[`label`,`hint`,`error`,`value`,`min`,`max`,`step`,`digits`,`required`,`disabled`,`name`,`placeholder`,`aria-label`];const J={first:``,letter:``,middle:``,region:``};var Y=class extends m{constructor(){super(...arguments),this.plate={...J},this.touched=!1,this.valueSet=!1,this.rendered=!1,this.key=_(`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(t){let[n=``,r=``,i=``,a=``]=(t??``).split(`-`);return{first:e(n),letter:r,middle:e(i),region:e(a)}}get value(){return{...this.plate}}set value(e){this.valueSet=!0,this.plate={...J,...e},this.rendered&&this.render()}get valid(){return T(this.plate)}render(){let n=this.key,i=this.plate,a=this.hasAttribute(`disabled`)?` disabled`:``,o=(e,r,o,s=``,c=!1)=>`<input${c?` id="${n}-first"`:``} class="k-plate__seg ${s}" data-key="${e}" data-len="${r}" inputmode="numeric" autocomplete="off" aria-label="${o}" placeholder="${t(`0`.repeat(r))}" value="${t(i[e])}"${a}>`,s=d().plate,l=this.getAttribute(`label`)??s.label,u=`<div class="k-plate" role="group" aria-label="${c(l)}" data-type="${w(i.letter)}"><span class="k-plate__flag" aria-hidden="true"><span class="k-plate__flag-colors"></span>I.R.<br>IRAN</span>${o(`first`,2,s.first,``,!0)}<select class="k-plate__letter" data-key="letter" aria-label="${c(s.letter)}"${a}><option value="">–</option>${S.map(e=>`<option value="${e}"${e===i.letter?` selected`:``}>${e===`ه`?`هـ`:e}</option>`).join(``)}</select>${o(`middle`,3,s.middle,`k-plate__seg--3`)}<span class="k-plate__region"><span class="k-plate__region-label" aria-hidden="true">ایران</span>${o(`region`,2,s.region)}</span></div><span class="k-sr-only" aria-live="polite"></span>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,h({id:`${n}-first`,label:l,control:u}));let f=[...this.querySelectorAll(`[data-key]`)];f.forEach((n,i)=>{n.addEventListener(n instanceof HTMLSelectElement?`change`:`input`,()=>{let a=n.dataset.key;if(n instanceof HTMLSelectElement)this.plate.letter=n.value,n.value&&f[i+1]?.focus();else{let r=Number(n.dataset.len),o=e(n.value);a===`middle`&&o.length>r&&(this.plate.region=(this.plate.region+o.slice(r)).slice(0,2)),this.plate[a]=o.slice(0,r),n.value=t(this.plate[a]),this.plate[a].length===r&&f[i+1]?.focus()}this.paint(),r(this,`kashi-change`,{value:this.value,valid:this.valid})}),n.addEventListener(`keydown`,e=>{e.key===`Backspace`&&!n.value&&f[i-1]?.focus()})});let p=this.querySelector(`.k-plate`);p.addEventListener(`focusout`,e=>{p.contains(e.relatedTarget)||(this.touched=!0,this.paint())}),this.rendered=!0,this.paint()}paint(){let e=this.plate,r=this.querySelector(`.k-plate`),i=this.querySelector(`[data-key="region"]`);i.value!==t(e.region)&&(i.value=t(e.region)),r.dataset.type=w(e.letter);let a=e.first.length===2&&!!e.letter&&e.middle.length===3&&e.region.length===2,o=(this.touched||a)&&Object.values(e).some(Boolean)&&!this.valid,s=this.getAttribute(`error`)||(o?d().invalid.plate:null);r.toggleAttribute(`data-invalid`,!!s),n(this.querySelector(`:scope > .k-field`),r,this.key,s,this.getAttribute(`hint`)),this.querySelector(`.k-field > .k-sr-only`).textContent=this.valid?E(e):``;let l=this.getAttribute(`name`);if(this.querySelectorAll(`:scope > input[type=hidden]`).forEach(e=>e.remove()),l)for(let t of[`first`,`letter`,`middle`,`region`])this.insertAdjacentHTML(`beforeend`,`<input type="hidden" name="${c(`${l}_${t}`)}" value="${c(e[t])}">`)}};Y.observedAttributes=[`label`,`hint`,`error`,`name`,`disabled`,`value`];var X=class extends m{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`)??d().persianInput.text;this.rendered=!0,this.editing=!1,this.innerHTML=`<span class="k-inline-edit"><button type="button" class="k-inline-edit__view" aria-label="${c(`${t}: ${this.text||d().inlineEdit.empty}${d().common.list}${d().common.edit}`)}">${this.text?c(this.text):`<span class="k-inline-edit__placeholder">${c(this.getAttribute(`placeholder`)??d().inlineEdit.empty)}</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 n=this.getAttribute(`label`)??d().persianInput.text,r=_(`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="${c(n)}" placeholder="${c(this.getAttribute(`placeholder`)??``)}"${e?` aria-invalid="true" aria-describedby="${r}"`:``}></span>${e?`<span class="k-hint k-hint--error" id="${r}">${c(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="${c(d().common.save)}">${M}</button><button type="button" class="k-btn k-btn--secondary k-btn--icon k-btn--sm" data-cancel aria-label="${c(d().common.cancel)}">${N}</button></span></span>`;let i=this.querySelector(`input`);i.value=t,i.focus(),i.select(),i.addEventListener(`keydown`,e=>{e.key===`Enter`?(e.preventDefault(),this.commit(i.value)):e.key===`Escape`&&(e.preventDefault(),this.render(!0))}),this.querySelector(`[data-save]`).addEventListener(`click`,()=>this.commit(i.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 i=this.text,a=null;if(r(this,`kashi-save`,{value:t,wait:e=>a=e}),this.text=t,a){this.querySelector(`[data-save]`)?.setAttribute(`aria-busy`,`true`);try{await a}catch{return this.text=i,this.edit(d().inlineEdit.failed,e)}}this.render(!0),r(this,`kashi-change`,{value:t})}};X.observedAttributes=[`value`,`label`,`placeholder`],u(`kashi-multi-select`,I,`block`),u(`kashi-slider`,L,`block`),u(`kashi-chip-group`,R),u(`kashi-password-strength`,B,`block`),u(`kashi-persian-textarea`,U,`block`),u(`kashi-keyboard-fix`,W,`block`),u(`kashi-time-input`,q,`block`),u(`kashi-plate-input`,Y,`block`),u(`kashi-inline-edit`,X);export{R as KashiChipGroup,X as KashiInlineEdit,W as KashiKeyboardFix,I as KashiMultiSelect,B as KashiPasswordStrength,U as KashiPersianTextarea,Y as KashiPlateInput,L as KashiSlider,q as KashiTimeInput};
@@ -1 +1 @@
1
- import{O as e}from"./base-C2zmRRrl.js";const t={"1-1":`عید نوروز`,"1-2":`عید نوروز`,"1-3":`عید نوروز`,"1-4":`عید نوروز`,"1-12":`روز جمهوری اسلامی`,"1-13":`روز طبیعت`,"3-14":`رحلت امام خمینی`,"3-15":`قیام ۱۵ خرداد`,"11-22":`پیروزی انقلاب اسلامی`,"12-29":`ملی شدن صنعت نفت`},n={"1-1":`Nowruz`,"1-2":`Nowruz`,"1-3":`Nowruz`,"1-4":`Nowruz`,"1-12":`Islamic Republic Day`,"1-13":`Nature Day`,"3-14":`Death of Imam Khomeini`,"3-15":`15 Khordad Uprising`,"11-22":`Islamic Revolution Victory Day`,"12-29":`Oil Nationalization Day`};function r(r,{extra:i={},friday:a=!0,locale:o=`fa`}={}){let{jm:s,jd:c}=e(r),l=`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,`0`)}-${String(r.getDate()).padStart(2,`0`)}`,u=(o===`en`?n:t)[`${s}-${c}`];return i[l]??i[`${s}-${c}`]??u??(a&&r.getDay()===5?o===`en`?`Friday`:`جمعه`:null)}export{r as t};
1
+ import{O as e}from"./base-BUQYhiEA.js";const t={"1-1":`عید نوروز`,"1-2":`عید نوروز`,"1-3":`عید نوروز`,"1-4":`عید نوروز`,"1-12":`روز جمهوری اسلامی`,"1-13":`روز طبیعت`,"3-14":`رحلت امام خمینی`,"3-15":`قیام ۱۵ خرداد`,"11-22":`پیروزی انقلاب اسلامی`,"12-29":`ملی شدن صنعت نفت`},n={"1-1":`Nowruz`,"1-2":`Nowruz`,"1-3":`Nowruz`,"1-4":`Nowruz`,"1-12":`Islamic Republic Day`,"1-13":`Nature Day`,"3-14":`Death of Imam Khomeini`,"3-15":`15 Khordad Uprising`,"11-22":`Islamic Revolution Victory Day`,"12-29":`Oil Nationalization Day`};function r(r,{extra:i={},friday:a=!0,locale:o=`fa`}={}){let{jm:s,jd:c}=e(r),l=`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,`0`)}-${String(r.getDate()).padStart(2,`0`)}`,u=(o===`en`?n:t)[`${s}-${c}`];return i[l]??i[`${s}-${c}`]??u??(a&&r.getDay()===5?o===`en`?`Friday`:`جمعه`:null)}export{r as t};
@@ -1 +1 @@
1
- import{A as e,M as t,_ as n,c as r,d as i,i as a,j as o,k as s,l as c,o as l,p as u,t as d,u as f,v as p,y as m}from"./base-C2zmRRrl.js";import{t as h}from"./words-BdADG_9U.js";function ee(t){let n=e(t);if(!/^\d{10}$/.test(n)||/^(\d)\1{9}$/.test(n))return!1;let r=Number(n[9]),i=0;for(let e=0;e<9;e++)i+=Number(n[e])*(10-e);let a=i%11;return a<2?r===a:r===11-a}const g={melli:`Bank Melli`,sepah:`Bank Sepah`,edbi:`Export Development Bank`,bim:`Bank of Industry and Mine`,keshavarzi:`Bank Keshavarzi`,maskan:`Bank Maskan`,postbank:`Post Bank`,"tosee-taavon":`Tose'e Ta'avon Bank`,"eghtesad-novin":`EN Bank`,parsian:`Parsian Bank`,pasargad:`Bank Pasargad`,karafarin:`Karafarin Bank`,saman:`Saman Bank`,sina:`Sina Bank`,sarmayeh:`Sarmayeh Bank`,ayandeh:`Ayandeh Bank`,shahr:`Shahr Bank`,dey:`Dey Bank`,saderat:`Bank Saderat`,mellat:`Bank Mellat`,tejarat:`Tejarat Bank`,refah:`Refah Bank`,"iran-zamin":`Iran Zamin Bank`,"mehr-iran":`Mehr Iran Bank`,gardeshgari:`Tourism Bank`,markazi:`Central Bank of Iran`,khavarmianeh:`Middle East Bank`,noor:`Noor Credit Institution`,melal:`Melal Credit Institution`,tosee:`Tose'e Credit Institution`,resalat:`Resalat Bank`,ansar:`Ansar Bank`,ghavamin:`Ghavamin Bank`,hekmat:`Hekmat Iranian Bank`,kosar:`Kosar Credit Institution`,"mehr-eghtesad":`Mehr Eghtesad Bank`};function _(e,t=`fa`){return t===`en`?g[e.slug]??e.name:e.name}const v={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 te(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 ne(t){let n=e(t);return/^\d{16}$/.test(n)&&te(n)}function y(t){let n=e(t);return n.length>=6?v[n.slice(0,6)]??null:null}function b(t){return e(t).slice(0,16).replace(/(\d{4})(?=\d)/g,`$1 `)}const x={"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 S(e){return o(e).toUpperCase().replace(/^\s*IR/,``).replace(/\D/g,``).slice(0,24)}function re(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 ie(e){let t=o(e).toUpperCase().replace(/[\s-]/g,``),n=t.startsWith(`IR`)?t.slice(2):t;return/^\d{24}$/.test(n)?re(n.slice(2)+`1827`+n.slice(0,2))===1:!1}function C(e){let t=S(e);return t.length>=5?x[t.slice(2,5)]??null:null}function ae(e){let t=S(e);return t?`IR${t}`.replace(/(.{4})(?=.)/g,`$1 `):``}const w={name:`همراه اول`,slug:`mci`},T={name:`ایرانسل`,slug:`irancell`},E={name:`رایتل`,slug:`rightel`},D={mci:`Hamrah-e Aval`,irancell:`Irancell`,rightel:`RighTel`},O=(e,t=`fa`)=>t===`en`?D[e.slug]:e.name,k={...Object.fromEntries([`10`,`11`,`12`,`13`,`14`,`15`,`16`,`17`,`18`,`19`,`90`,`91`,`92`,`93`,`94`].map(e=>[e,w])),...Object.fromEntries([`01`,`02`,`03`,`04`,`05`,`30`,`33`,`35`,`36`,`37`,`38`,`39`,`41`].map(e=>[e,T])),...Object.fromEntries([`20`,`21`,`22`].map(e=>[e,E]))};function A(t){let n=e(t);return n.startsWith(`0098`)?n=`0`+n.slice(4):n.startsWith(`98`)&&n.length===12?n=`0`+n.slice(2):n.startsWith(`9`)&&n.length===10&&(n=`0`+n),n}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(t){let n=e(t);return/^(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}$/.test(n)}function F(t){let n=e(t).slice(0,10);return n.length>5?`${n.slice(0,5)}-${n.slice(5)}`:n}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(t){let n=e(t);return n.startsWith(`0098`)?n=`0`+n.slice(4):n.startsWith(`98`)&&n.length===12?n=`0`+n.slice(2):/^[1-8]/.test(n)&&n.length===10&&(n=`0`+n),n}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(t){let n=e(t);if(!/^\d{11}$/.test(n)||/^0+$/.test(n.slice(3,9)))return!1;let r=[...n].map(Number),i=r[9]+2,a=0;for(let e=0;e<10;e++)a+=(r[e]+i)*V[e];let o=a%11;return(o===10?0:o)===r[10]}const U=e=>t(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 d{constructor(){super(...arguments),this.raw=``,this.touched=!1,this.valueSet=!1,this.rendered=!1,this.key=m(`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(t){let n=this.kind;return(n.normalize??(e=>e))(e(t)).slice(0,n.maxDigits)}get digits(){let e=this.getAttribute(`digits`);return e===`fa`||e===`latin`?e:i()===`en`?`latin`:this.kind.digits}shown(){let e=this.kind.format(this.raw);return this.digits===`fa`?U(e):e}render(){let e=this.kind,t=this.key,n=this.getAttribute(`aria-label`),r=this.hasAttribute(`label`)?this.getAttribute(`label`):n?null:e.label(),i=this.getAttribute(`size`),a=this.hasAttribute(`required`),o=this.hasAttribute(`disabled`),s=this.getAttribute(`placeholder`)??e.placeholder[this.digits],l=`<div class="k-input${i===`sm`||i===`lg`?` k-input--${i}`:``}" data-size="${i??`md`}"${o?` data-state="disabled"`:``}><input id="${t}" class="k-input__control" type="${e.type??`text`}" inputmode="${e.inputMode??`numeric`}" autocomplete="${e.autocomplete??`off`}" dir="ltr" spellcheck="false" placeholder="${c(s)}"${a?` required`:``}${o?` disabled`:``}${this.hasAttribute(`readonly`)?` readonly`:``}${!r&&n?` aria-label="${c(n)}"`:``}></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,f({id:t,label:r,required:a,control:l})),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 t=this.input,n=t.value.slice(0,t.selectionStart??t.value.length),r=this.clean(t.value),i=Math.min(e(n).length,r.length);if(this.setRaw(r,!0),t.ownerDocument.activeElement===t){let e=W(t.value,i);t.setSelectionRange(e,e)}}setRaw(e,t){let n=e!==this.raw;this.raw=e,this.rendered&&(this.paint(),t&&n&&r(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 r=e.parentElement;r.querySelector(`:scope > .k-input__addon`)?.remove();let i=a(this,`show-meta`,!0)?this.kind.meta?.(this.raw,this):null,o=`${this.key}-meta`;if(i){let e=document.createElement(`span`);e.className=`k-input__addon`,e.innerHTML=i.bank?`<span class="k-bank" id="${o}">${c(i.text)}</span>`:`<span class="k-input__meta" id="${o}">${c(i.text)}</span>`,r.append(e),i.bank&&a(this,`bank-logo`,!0)&&this.loadLogo(i.bank,e.firstElementChild)}let s=this.getAttribute(`error`)||this.invalidText(this.touched);e.setCustomValidity(this.raw&&!this.isValid()?this.invalidText(!0)??``:``),n(this.querySelector(`:scope > .k-field`),e,this.key,s,this.hintText(),i?o:null),p(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:()=>u().persianInput[`national-id`],maxDigits:10,format:e=>e,valid:e=>ee(e),invalidMessage:()=>u().invalid.nationalId,placeholder:{fa:`۰۰۰۰۰۰۰۰۰۰`,latin:`0000000000`},digits:`fa`}}},q=class extends G{constructor(){super(...arguments),this.kind={label:()=>u().persianInput[`legal-id`],maxDigits:11,format:e=>e,valid:e=>H(e),invalidMessage:()=>u().invalid.legalId,placeholder:{fa:`۰۰۰۰۰۰۰۰۰۰۰`,latin:`00000000000`},digits:`fa`}}},J=class extends G{constructor(){super(...arguments),this.kind={label:()=>u().persianInput.mobile,maxDigits:11,normalize:A,format:N,valid:e=>j(e),invalidMessage:()=>u().invalid.mobile,placeholder:{fa:`۰۹۱۲ ۳۴۵ ۶۷۸۹`,latin:`0912 345 6789`},digits:`fa`,type:`tel`,inputMode:`tel`,autocomplete:`tel-national`,meta:e=>{let t=M(e);return t?{text:O(t,i())}:null},detail:e=>({operator:M(e)?.name??null})}}},Y=class extends G{constructor(){super(...arguments),this.kind={label:()=>u().persianInput.landline,maxDigits:11,normalize:L,format:B,valid:e=>z(e),invalidMessage:()=>u().invalid.landline,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:()=>u().persianInput.card,maxDigits:16,format:b,valid:e=>ne(e),invalidMessage:()=>u().invalid.card,placeholder:{fa:`۰۰۰۰ ۰۰۰۰ ۰۰۰۰ ۰۰۰۰`,latin:`0000 0000 0000 0000`},digits:`fa`,autocomplete:`cc-number`,meta:e=>{let t=y(e);return t?{text:_(t,i()),bank:t}:null},detail:e=>({bank:y(e)?.name??null})}}},Z=class extends G{constructor(){super(...arguments),this.kind={label:()=>u().persianInput.iban,maxDigits:24,format:e=>ae(e),valid:e=>ie(e),invalidMessage:()=>u().invalid.iban,placeholder:{fa:`IR00 0000 0000 0000 0000 0000 00`,latin:`IR00 0000 0000 0000 0000 0000 00`},digits:`latin`,meta:e=>{let t=C(e);return t?{text:_(t,i()),bank:t}:null},submit:e=>e?`IR${e}`:``,detail:e=>({bank:C(e)?.name??null})}}clean(e){return super.clean(e.replace(/^\s*IR/i,``))}},Q=class extends G{constructor(){super(...arguments),this.kind={label:()=>u().persianInput.postal,maxDigits:10,format:F,valid:e=>P(e),invalidMessage:()=>u().invalid.postal,placeholder:{fa:`۱۲۳۴۵-۶۷۸۹۰`,latin:`12345-67890`},digits:`fa`,autocomplete:`postal-code`}}},$=class extends G{constructor(){super(...arguments),this.kind={label:()=>u().persianInput.price,maxDigits:15,normalize:e=>e.replace(/^0+(?=\d)/,``),format:e=>e?s(e,{digits:`latin`}).replace(/,/g,this.digits===`fa`?`٬`:`,`):``,valid:()=>this.inRange(),invalidMessage:()=>``,placeholder:{fa:`۰`,latin:`0`},digits:`fa`,meta:(e,t)=>{let n=t.getAttribute(`unit`)??u().money.toman;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=>this.digits===`fa`?U(s(e)):s(e,{digits:`latin`}),a=u().invalid;return n!==void 0&&r!==void 0?a.priceRange(i(n),i(r)):n===void 0?a.priceMax(i(r)):a.priceMin(i(n))}hintText(){if(this.raw&&a(this,`show-words`,!0)){let e=this.getAttribute(`unit`)??u().money.toman;return`${h(Number(this.raw),{locale:i()})}${e?` ${e}`:``}`}return this.getAttribute(`hint`)}};$.observedAttributes=[...G.observedAttributes,`unit`,`min`,`max`,`show-words`],l(`kashi-national-id`,K,`block`),l(`kashi-legal-id`,q,`block`),l(`kashi-mobile`,J,`block`),l(`kashi-landline`,Y,`block`),l(`kashi-card-number`,X,`block`),l(`kashi-iban`,Z,`block`),l(`kashi-postal-code`,Q,`block`),l(`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,M as t,_ as n,c as r,d as i,i as a,j as o,k as s,l as c,o as l,p as u,t as d,u as f,v as p,y as m}from"./base-BUQYhiEA.js";import{t as h}from"./words-BdADG_9U.js";function ee(t){let n=e(t);if(!/^\d{10}$/.test(n)||/^(\d)\1{9}$/.test(n))return!1;let r=Number(n[9]),i=0;for(let e=0;e<9;e++)i+=Number(n[e])*(10-e);let a=i%11;return a<2?r===a:r===11-a}const g={melli:`Bank Melli`,sepah:`Bank Sepah`,edbi:`Export Development Bank`,bim:`Bank of Industry and Mine`,keshavarzi:`Bank Keshavarzi`,maskan:`Bank Maskan`,postbank:`Post Bank`,"tosee-taavon":`Tose'e Ta'avon Bank`,"eghtesad-novin":`EN Bank`,parsian:`Parsian Bank`,pasargad:`Bank Pasargad`,karafarin:`Karafarin Bank`,saman:`Saman Bank`,sina:`Sina Bank`,sarmayeh:`Sarmayeh Bank`,ayandeh:`Ayandeh Bank`,shahr:`Shahr Bank`,dey:`Dey Bank`,saderat:`Bank Saderat`,mellat:`Bank Mellat`,tejarat:`Tejarat Bank`,refah:`Refah Bank`,"iran-zamin":`Iran Zamin Bank`,"mehr-iran":`Mehr Iran Bank`,gardeshgari:`Tourism Bank`,markazi:`Central Bank of Iran`,khavarmianeh:`Middle East Bank`,noor:`Noor Credit Institution`,melal:`Melal Credit Institution`,tosee:`Tose'e Credit Institution`,resalat:`Resalat Bank`,ansar:`Ansar Bank`,ghavamin:`Ghavamin Bank`,hekmat:`Hekmat Iranian Bank`,kosar:`Kosar Credit Institution`,"mehr-eghtesad":`Mehr Eghtesad Bank`};function _(e,t=`fa`){return t===`en`?g[e.slug]??e.name:e.name}const v={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 te(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 ne(t){let n=e(t);return/^\d{16}$/.test(n)&&te(n)}function y(t){let n=e(t);return n.length>=6?v[n.slice(0,6)]??null:null}function b(t){return e(t).slice(0,16).replace(/(\d{4})(?=\d)/g,`$1 `)}const x={"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 S(e){return o(e).toUpperCase().replace(/^\s*IR/,``).replace(/\D/g,``).slice(0,24)}function re(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 ie(e){let t=o(e).toUpperCase().replace(/[\s-]/g,``),n=t.startsWith(`IR`)?t.slice(2):t;return/^\d{24}$/.test(n)?re(n.slice(2)+`1827`+n.slice(0,2))===1:!1}function C(e){let t=S(e);return t.length>=5?x[t.slice(2,5)]??null:null}function ae(e){let t=S(e);return t?`IR${t}`.replace(/(.{4})(?=.)/g,`$1 `):``}const w={name:`همراه اول`,slug:`mci`},T={name:`ایرانسل`,slug:`irancell`},E={name:`رایتل`,slug:`rightel`},D={mci:`Hamrah-e Aval`,irancell:`Irancell`,rightel:`RighTel`},O=(e,t=`fa`)=>t===`en`?D[e.slug]:e.name,k={...Object.fromEntries([`10`,`11`,`12`,`13`,`14`,`15`,`16`,`17`,`18`,`19`,`90`,`91`,`92`,`93`,`94`].map(e=>[e,w])),...Object.fromEntries([`01`,`02`,`03`,`04`,`05`,`30`,`33`,`35`,`36`,`37`,`38`,`39`,`41`].map(e=>[e,T])),...Object.fromEntries([`20`,`21`,`22`].map(e=>[e,E]))};function A(t){let n=e(t);return n.startsWith(`0098`)?n=`0`+n.slice(4):n.startsWith(`98`)&&n.length===12?n=`0`+n.slice(2):n.startsWith(`9`)&&n.length===10&&(n=`0`+n),n}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(t){let n=e(t);return/^(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}$/.test(n)}function F(t){let n=e(t).slice(0,10);return n.length>5?`${n.slice(0,5)}-${n.slice(5)}`:n}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(t){let n=e(t);return n.startsWith(`0098`)?n=`0`+n.slice(4):n.startsWith(`98`)&&n.length===12?n=`0`+n.slice(2):/^[1-8]/.test(n)&&n.length===10&&(n=`0`+n),n}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(t){let n=e(t);if(!/^\d{11}$/.test(n)||/^0+$/.test(n.slice(3,9)))return!1;let r=[...n].map(Number),i=r[9]+2,a=0;for(let e=0;e<10;e++)a+=(r[e]+i)*V[e];let o=a%11;return(o===10?0:o)===r[10]}const U=e=>t(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 d{constructor(){super(...arguments),this.raw=``,this.touched=!1,this.valueSet=!1,this.rendered=!1,this.key=m(`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(t){let n=this.kind;return(n.normalize??(e=>e))(e(t)).slice(0,n.maxDigits)}get digits(){let e=this.getAttribute(`digits`);return e===`fa`||e===`latin`?e:i()===`en`?`latin`:this.kind.digits}shown(){let e=this.kind.format(this.raw);return this.digits===`fa`?U(e):e}render(){let e=this.kind,t=this.key,n=this.getAttribute(`aria-label`),r=this.hasAttribute(`label`)?this.getAttribute(`label`):n?null:e.label(),i=this.getAttribute(`size`),a=this.hasAttribute(`required`),o=this.hasAttribute(`disabled`),s=this.getAttribute(`placeholder`)??e.placeholder[this.digits],l=`<div class="k-input${i===`sm`||i===`lg`?` k-input--${i}`:``}" data-size="${i??`md`}"${o?` data-state="disabled"`:``}><input id="${t}" class="k-input__control" type="${e.type??`text`}" inputmode="${e.inputMode??`numeric`}" autocomplete="${e.autocomplete??`off`}" dir="ltr" spellcheck="false" placeholder="${c(s)}"${a?` required`:``}${o?` disabled`:``}${this.hasAttribute(`readonly`)?` readonly`:``}${!r&&n?` aria-label="${c(n)}"`:``}></div>`;this.querySelector(`:scope > .k-field`)?.remove(),this.insertAdjacentHTML(`afterbegin`,f({id:t,label:r,required:a,control:l})),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 t=this.input,n=t.value.slice(0,t.selectionStart??t.value.length),r=this.clean(t.value),i=Math.min(e(n).length,r.length);if(this.setRaw(r,!0),t.ownerDocument.activeElement===t){let e=W(t.value,i);t.setSelectionRange(e,e)}}setRaw(e,t){let n=e!==this.raw;this.raw=e,this.rendered&&(this.paint(),t&&n&&r(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 r=e.parentElement;r.querySelector(`:scope > .k-input__addon`)?.remove();let i=a(this,`show-meta`,!0)?this.kind.meta?.(this.raw,this):null,o=`${this.key}-meta`;if(i){let e=document.createElement(`span`);e.className=`k-input__addon`,e.innerHTML=i.bank?`<span class="k-bank" id="${o}">${c(i.text)}</span>`:`<span class="k-input__meta" id="${o}">${c(i.text)}</span>`,r.append(e),i.bank&&a(this,`bank-logo`,!0)&&this.loadLogo(i.bank,e.firstElementChild)}let s=this.getAttribute(`error`)||this.invalidText(this.touched);e.setCustomValidity(this.raw&&!this.isValid()?this.invalidText(!0)??``:``),n(this.querySelector(`:scope > .k-field`),e,this.key,s,this.hintText(),i?o:null),p(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:()=>u().persianInput[`national-id`],maxDigits:10,format:e=>e,valid:e=>ee(e),invalidMessage:()=>u().invalid.nationalId,placeholder:{fa:`۰۰۰۰۰۰۰۰۰۰`,latin:`0000000000`},digits:`fa`}}},q=class extends G{constructor(){super(...arguments),this.kind={label:()=>u().persianInput[`legal-id`],maxDigits:11,format:e=>e,valid:e=>H(e),invalidMessage:()=>u().invalid.legalId,placeholder:{fa:`۰۰۰۰۰۰۰۰۰۰۰`,latin:`00000000000`},digits:`fa`}}},J=class extends G{constructor(){super(...arguments),this.kind={label:()=>u().persianInput.mobile,maxDigits:11,normalize:A,format:N,valid:e=>j(e),invalidMessage:()=>u().invalid.mobile,placeholder:{fa:`۰۹۱۲ ۳۴۵ ۶۷۸۹`,latin:`0912 345 6789`},digits:`fa`,type:`tel`,inputMode:`tel`,autocomplete:`tel-national`,meta:e=>{let t=M(e);return t?{text:O(t,i())}:null},detail:e=>({operator:M(e)?.name??null})}}},Y=class extends G{constructor(){super(...arguments),this.kind={label:()=>u().persianInput.landline,maxDigits:11,normalize:L,format:B,valid:e=>z(e),invalidMessage:()=>u().invalid.landline,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:()=>u().persianInput.card,maxDigits:16,format:b,valid:e=>ne(e),invalidMessage:()=>u().invalid.card,placeholder:{fa:`۰۰۰۰ ۰۰۰۰ ۰۰۰۰ ۰۰۰۰`,latin:`0000 0000 0000 0000`},digits:`fa`,autocomplete:`cc-number`,meta:e=>{let t=y(e);return t?{text:_(t,i()),bank:t}:null},detail:e=>({bank:y(e)?.name??null})}}},Z=class extends G{constructor(){super(...arguments),this.kind={label:()=>u().persianInput.iban,maxDigits:24,format:e=>ae(e),valid:e=>ie(e),invalidMessage:()=>u().invalid.iban,placeholder:{fa:`IR00 0000 0000 0000 0000 0000 00`,latin:`IR00 0000 0000 0000 0000 0000 00`},digits:`latin`,meta:e=>{let t=C(e);return t?{text:_(t,i()),bank:t}:null},submit:e=>e?`IR${e}`:``,detail:e=>({bank:C(e)?.name??null})}}clean(e){return super.clean(e.replace(/^\s*IR/i,``))}},Q=class extends G{constructor(){super(...arguments),this.kind={label:()=>u().persianInput.postal,maxDigits:10,format:F,valid:e=>P(e),invalidMessage:()=>u().invalid.postal,placeholder:{fa:`۱۲۳۴۵-۶۷۸۹۰`,latin:`12345-67890`},digits:`fa`,autocomplete:`postal-code`}}},$=class extends G{constructor(){super(...arguments),this.kind={label:()=>u().persianInput.price,maxDigits:15,normalize:e=>e.replace(/^0+(?=\d)/,``),format:e=>e?s(e,{digits:`latin`}).replace(/,/g,this.digits===`fa`?`٬`:`,`):``,valid:()=>this.inRange(),invalidMessage:()=>``,placeholder:{fa:`۰`,latin:`0`},digits:`fa`,meta:(e,t)=>{let n=t.getAttribute(`unit`)??u().money.toman;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=>this.digits===`fa`?U(s(e)):s(e,{digits:`latin`}),a=u().invalid;return n!==void 0&&r!==void 0?a.priceRange(i(n),i(r)):n===void 0?a.priceMax(i(r)):a.priceMin(i(n))}hintText(){if(this.raw&&a(this,`show-words`,!0)){let e=this.getAttribute(`unit`)??u().money.toman;return`${h(Number(this.raw),{locale:i()})}${e?` ${e}`:``}`}return this.getAttribute(`hint`)}};$.observedAttributes=[...G.observedAttributes,`unit`,`min`,`max`,`show-words`],l(`kashi-national-id`,K,`block`),l(`kashi-legal-id`,q,`block`),l(`kashi-mobile`,J,`block`),l(`kashi-landline`,Y,`block`),l(`kashi-card-number`,X,`block`),l(`kashi-iban`,Z,`block`),l(`kashi-postal-code`,Q,`block`),l(`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 +1 @@
1
- import{g as e,l as t,n,o as r,p as i,t as a}from"./base-C2zmRRrl.js";let o=1;function s(){let e=document.querySelectorAll(`kashi-toaster`);if(e.length)return e[e.length-1];let t=document.createElement(`kashi-toaster`);return document.body.append(t),t}function c(e){let t=e.id??o++;return s().upsert({...e,id:t}),t}function l(e){return c(typeof e==`string`?{title:e}:e)}l.success=(e,t={})=>l({...t,title:e,tone:`success`}),l.error=(e,t={})=>l({...t,title:e,tone:`error`}),l.warning=(e,t={})=>l({...t,title:e,tone:`warning`}),l.info=(e,t={})=>l({...t,title:e,tone:`info`}),l.dismiss=e=>document.querySelectorAll(`kashi-toaster`).forEach(t=>t.dismiss(e)),l.promise=(e,t)=>{let n=c({title:t.loading,tone:`info`,duration:1/0,loading:!0});return e.then(e=>c({id:n,title:typeof t.success==`function`?t.success(e):t.success,tone:`success`}),e=>c({id:n,title:typeof t.error==`function`?t.error(e):t.error,tone:`error`})),e};var u=class extends a{constructor(){super(...arguments),this.list=null}connectedCallback(){this.list||=(this.innerHTML=`<section><ol class="k-toaster" aria-live="polite"></ol></section>`,this.querySelector(`ol`)),this.decorate()}attributeChangedCallback(){this.list&&this.decorate()}decorate(){let e=this.getAttribute(`placement`)??`bottom-end`;this.list.className=`k-toaster k-toaster--${e}`,this.list.dataset.placement=e,this.querySelector(`section`).setAttribute(`aria-label`,this.getAttribute(`label`)??i().toast.region)}upsert(e){this.list||this.connectedCallback();let t=[...this.list.children].find(t=>t.toastId===e.id),n=d(e,this.getAttribute(`close-label`)??i().toast.close,()=>this.dismiss(e.id));t?(t.stop?.(),t.replaceWith(n)):this.list.append(n);let r=Number(this.getAttribute(`max`))||5;for(;this.list.children.length>r;)this.list.firstElementChild.stop?.(),this.list.firstElementChild.remove()}dismiss(e){let t=[...this.list?.children??[]].find(t=>t.toastId===e);t&&t.dataset.state!==`closing`&&(t.stop?.(),t.dataset.state=`closing`,setTimeout(()=>t.remove(),200))}};u.observedAttributes=[`placement`,`label`];function d(e,r,i){let a=e.duration??(e.action?1/0:5e3),o=e.tone??`neutral`,s=document.createElement(`li`);s.toastId=e.id,s.className=`k-toast${o===`neutral`?``:` k-toast--${o}`}`,s.dataset.state=`open`,s.setAttribute(`role`,o===`error`?`alert`:`status`),s.innerHTML=`<span class="k-toast__icon" aria-hidden="true">${e.loading?`<span class="k-spinner k-spinner--sm" style="color: inherit"></span>`:n[o===`neutral`?`info`:o]}</span><div class="k-toast__content"><p class="k-toast__title">${t(e.title)}</p>${e.description?`<p class="k-toast__description">${t(e.description)}</p>`:``}${e.action?`<button type="button" class="k-btn k-btn--link k-toast__action">${t(e.action.label)}</button>`:``}</div><button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm k-toast__close" aria-label="${t(r)}">${n.close}</button>${Number.isFinite(a)?`<span class="k-toast__progress" aria-hidden="true" style="animation-duration: ${a}ms"></span>`:``}`,s.querySelector(`.k-toast__close`).addEventListener(`click`,i),s.querySelector(`.k-toast__action`)?.addEventListener(`click`,()=>{e.action.onClick(),i()}),s.addEventListener(`keydown`,e=>e.key===`Escape`&&i());let c=a,l=0,u,d=()=>{u===void 0&&Number.isFinite(c)&&(l=Date.now(),u=setTimeout(i,c))},f=()=>{u!==void 0&&(clearTimeout(u),u=void 0,c-=Date.now()-l)};return s.addEventListener(`mouseenter`,f),s.addEventListener(`focusin`,f),s.addEventListener(`mouseleave`,d),s.addEventListener(`focusout`,d),s.stop=()=>{clearTimeout(u),c=1/0},d(),s}r(`kashi-toaster`,u),typeof document<`u`&&document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`[data-kashi-toast]`);t&&l({title:t.dataset.kashiToast,description:t.dataset.description,tone:t.dataset.tone??`neutral`})});const f=/* @__PURE__ */ new Set([[[`kashi-national-id`,`kashi-legal-id`,`kashi-mobile`,`kashi-landline`,`kashi-card-number`,`kashi-iban`,`kashi-postal-code`,`kashi-price`],()=>import(`./inputs-BCJQY3U_.js`)],[[`kashi-otp`],()=>import(`./fields-BOgowgq3.js`)],[[`kashi-combobox`,`kashi-province-select`,`kashi-city-select`],()=>import(`./combobox-Bxc9krdH.js`)],[[`kashi-iran-map`,`kashi-address-form`],()=>import(`./map-BOxAo1iN.js`)],[[`kashi-calendar`,`kashi-date-picker`],()=>import(`./calendar-BazNrJPa.js`)],[[`kashi-money`,`kashi-date`,`kashi-relative-time`,`kashi-countdown`],()=>import(`./display-BR-7r4aB.js`)],[[`kashi-dialog`,`kashi-tabs`,`kashi-tooltip`,`kashi-copy-button`],()=>import(`./overlay-BrVh7RHI.js`)],[[`kashi-dropdown-menu`,`kashi-popover`],()=>import(`./menu-BOXyaiDK.js`)],[[`kashi-tag-input`,`kashi-number-input`,`kashi-rating`,`kashi-pagination`],()=>import(`./controls-BxiBYyQo.js`)],[[`kashi-data-table`],()=>import(`./table-CH9eyNL-.js`)],[[`kashi-multi-select`,`kashi-slider`,`kashi-chip-group`,`kashi-password-strength`,`kashi-persian-textarea`,`kashi-keyboard-fix`,`kashi-time-input`,`kashi-plate-input`,`kashi-inline-edit`],()=>import(`./forms-BiS_Z4nX.js`)],[[`kashi-date-range-picker`,`kashi-month-picker`,`kashi-file-upload`,`kashi-color-picker`],()=>import(`./pickers-CgoXFr-d.js`)],[[`kashi-bar-chart`,`kashi-line-chart`,`kashi-pie-chart`,`kashi-bar-list`,`kashi-proportion-bar`,`kashi-sparkline`,`kashi-activity-heatmap`],()=>import(`./charts-DKcI5AOn.js`)],[[`kashi-input`,`kashi-textarea`,`kashi-banner`],()=>import(`./basic-BOoAih_D.js`)],[[`kashi-appointment-picker`],()=>import(`./appointment-YPdrCT54.js`)],[[`kashi-command-palette`,`kashi-context-menu`,`kashi-carousel`,`kashi-tree-view`,`kashi-tour`,`kashi-splitter`,`kashi-side-nav`],()=>import(`./nav-DQfGe1Vd.js`)]]);function p(){for(let e of f)document.querySelector(e[0].join(`,`))&&(f.delete(e),e[1]().catch(e=>console.error(`[kashi] بارگذاری نشد:`,e)));f.size||h?.disconnect()}function m(){let e=[...f].map(([,e])=>e());return f.clear(),h?.disconnect(),Promise.all(e)}let h=null;typeof document<`u`&&(p(),h=new MutationObserver(p),h.observe(document.documentElement,{childList:!0,subtree:!0}));export{m as loadAll,e as setLocale,l as toast};
1
+ import{g as e,l as t,n,o as r,p as i,t as a}from"./base-BUQYhiEA.js";let o=1;function s(){let e=document.querySelectorAll(`kashi-toaster`);if(e.length)return e[e.length-1];let t=document.createElement(`kashi-toaster`);return document.body.append(t),t}function c(e){let t=e.id??o++;return s().upsert({...e,id:t}),t}function l(e){return c(typeof e==`string`?{title:e}:e)}l.success=(e,t={})=>l({...t,title:e,tone:`success`}),l.error=(e,t={})=>l({...t,title:e,tone:`error`}),l.warning=(e,t={})=>l({...t,title:e,tone:`warning`}),l.info=(e,t={})=>l({...t,title:e,tone:`info`}),l.dismiss=e=>document.querySelectorAll(`kashi-toaster`).forEach(t=>t.dismiss(e)),l.promise=(e,t)=>{let n=c({title:t.loading,tone:`info`,duration:1/0,loading:!0});return e.then(e=>c({id:n,title:typeof t.success==`function`?t.success(e):t.success,tone:`success`}),e=>c({id:n,title:typeof t.error==`function`?t.error(e):t.error,tone:`error`})),e};var u=class extends a{constructor(){super(...arguments),this.list=null}connectedCallback(){this.list||=(this.innerHTML=`<section><ol class="k-toaster" aria-live="polite"></ol></section>`,this.querySelector(`ol`)),this.decorate()}attributeChangedCallback(){this.list&&this.decorate()}decorate(){let e=this.getAttribute(`placement`)??`bottom-end`;this.list.className=`k-toaster k-toaster--${e}`,this.list.dataset.placement=e,this.querySelector(`section`).setAttribute(`aria-label`,this.getAttribute(`label`)??i().toast.region)}upsert(e){this.list||this.connectedCallback();let t=[...this.list.children].find(t=>t.toastId===e.id),n=d(e,this.getAttribute(`close-label`)??i().toast.close,()=>this.dismiss(e.id));t?(t.stop?.(),t.replaceWith(n)):this.list.append(n);let r=Number(this.getAttribute(`max`))||5;for(;this.list.children.length>r;)this.list.firstElementChild.stop?.(),this.list.firstElementChild.remove()}dismiss(e){let t=[...this.list?.children??[]].find(t=>t.toastId===e);t&&t.dataset.state!==`closing`&&(t.stop?.(),t.dataset.state=`closing`,setTimeout(()=>t.remove(),200))}};u.observedAttributes=[`placement`,`label`];function d(e,r,i){let a=e.duration??(e.action?1/0:5e3),o=e.tone??`neutral`,s=document.createElement(`li`);s.toastId=e.id,s.className=`k-toast${o===`neutral`?``:` k-toast--${o}`}`,s.dataset.state=`open`,s.setAttribute(`role`,o===`error`?`alert`:`status`),s.innerHTML=`<span class="k-toast__icon" aria-hidden="true">${e.loading?`<span class="k-spinner k-spinner--sm" style="color: inherit"></span>`:n[o===`neutral`?`info`:o]}</span><div class="k-toast__content"><p class="k-toast__title">${t(e.title)}</p>${e.description?`<p class="k-toast__description">${t(e.description)}</p>`:``}${e.action?`<button type="button" class="k-btn k-btn--link k-toast__action">${t(e.action.label)}</button>`:``}</div><button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm k-toast__close" aria-label="${t(r)}">${n.close}</button>${Number.isFinite(a)?`<span class="k-toast__progress" aria-hidden="true" style="animation-duration: ${a}ms"></span>`:``}`,s.querySelector(`.k-toast__close`).addEventListener(`click`,i),s.querySelector(`.k-toast__action`)?.addEventListener(`click`,()=>{e.action.onClick(),i()}),s.addEventListener(`keydown`,e=>e.key===`Escape`&&i());let c=a,l=0,u,d=()=>{u===void 0&&Number.isFinite(c)&&(l=Date.now(),u=setTimeout(i,c))},f=()=>{u!==void 0&&(clearTimeout(u),u=void 0,c-=Date.now()-l)};return s.addEventListener(`mouseenter`,f),s.addEventListener(`focusin`,f),s.addEventListener(`mouseleave`,d),s.addEventListener(`focusout`,d),s.stop=()=>{clearTimeout(u),c=1/0},d(),s}r(`kashi-toaster`,u),typeof document<`u`&&document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`[data-kashi-toast]`);t&&l({title:t.dataset.kashiToast,description:t.dataset.description,tone:t.dataset.tone??`neutral`})});const f=/* @__PURE__ */ new Set([[[`kashi-national-id`,`kashi-legal-id`,`kashi-mobile`,`kashi-landline`,`kashi-card-number`,`kashi-iban`,`kashi-postal-code`,`kashi-price`],()=>import(`./inputs-CI_r2s8t.js`)],[[`kashi-otp`],()=>import(`./fields-BiEcHRiA.js`)],[[`kashi-combobox`,`kashi-province-select`,`kashi-city-select`],()=>import(`./combobox-Br5cwZFz.js`)],[[`kashi-iran-map`,`kashi-address-form`],()=>import(`./map-Drave3MR.js`)],[[`kashi-calendar`,`kashi-date-picker`],()=>import(`./calendar-Di0xvA-Y.js`)],[[`kashi-money`,`kashi-date`,`kashi-relative-time`,`kashi-countdown`],()=>import(`./display-CPw2LBkB.js`)],[[`kashi-dialog`,`kashi-tabs`,`kashi-tooltip`,`kashi-copy-button`],()=>import(`./overlay-CZh0I9wA.js`)],[[`kashi-dropdown-menu`,`kashi-popover`],()=>import(`./menu-DtNKEt1M.js`)],[[`kashi-tag-input`,`kashi-number-input`,`kashi-rating`,`kashi-pagination`],()=>import(`./controls-m5DTcF_s.js`)],[[`kashi-data-table`],()=>import(`./table-C2PzU0Rb.js`)],[[`kashi-multi-select`,`kashi-slider`,`kashi-chip-group`,`kashi-password-strength`,`kashi-persian-textarea`,`kashi-keyboard-fix`,`kashi-time-input`,`kashi-plate-input`,`kashi-inline-edit`],()=>import(`./forms-C6-Wamak.js`)],[[`kashi-date-range-picker`,`kashi-month-picker`,`kashi-file-upload`,`kashi-color-picker`],()=>import(`./pickers-BTH9LGo1.js`)],[[`kashi-bar-chart`,`kashi-line-chart`,`kashi-pie-chart`,`kashi-bar-list`,`kashi-proportion-bar`,`kashi-sparkline`,`kashi-activity-heatmap`],()=>import(`./charts-C5LT77Qo.js`)],[[`kashi-input`,`kashi-textarea`,`kashi-banner`],()=>import(`./basic-C815theM.js`)],[[`kashi-appointment-picker`],()=>import(`./appointment-CZNwpkp1.js`)],[[`kashi-price-range`,`kashi-swatch-group`,`kashi-search-suggest`],()=>import(`./commerce-DYVxWBBe.js`)],[[`kashi-command-palette`,`kashi-context-menu`,`kashi-carousel`,`kashi-tree-view`,`kashi-tour`,`kashi-splitter`,`kashi-side-nav`],()=>import(`./nav-Ihmgl1sx.js`)]]);function p(){for(let e of f)document.querySelector(e[0].join(`,`))&&(f.delete(e),e[1]().catch(e=>console.error(`[kashi] بارگذاری نشد:`,e)));f.size||h?.disconnect()}function m(){let e=[...f].map(([,e])=>e());return f.clear(),h?.disconnect(),Promise.all(e)}let h=null;typeof document<`u`&&(p(),h=new MutationObserver(p),h.observe(document.documentElement,{childList:!0,subtree:!0}));export{m as loadAll,e as setLocale,l as toast};
@@ -1,4 +1,4 @@
1
- import{c as e,i as t,k as n,l as r,o as i,p as a,r as o,s,t as c,y as l}from"./base-C2zmRRrl.js";import{n as u,r as d,t as f}from"./combobox-Bxc9krdH.js";import"./inputs-BCJQY3U_.js";const p=`0 0 1000 907`,m={"آذربایجان شرقی":{x:123,y:128,d:`M163 199l1-7l10-12l11-8l17-2l20 2l7-4l-13-8l-2-7l-12-7l-1-7l2-10l-8-10l-5-17l-15 0l-10-6l10-13l7 0l2-16l-6-22l-13 8l-12 19l-8-2l-10 4l-5-5l5-9l5 1l12-6l6-7l-4-9l-8 1l-15 18l-10-1l-13 4l-33-8l-6 6l-3 10l0 14l-9 9l-3 10l5 7l4 34l4 7l2 15l16 10l12 1l8 8l11 7l5-7l13-5l8 5l2 13l7 3z`},"آذربایجان غربی":{x:39,y:59,d:`M75 53l-8-13l-9-3l-6-11l-5-4l-4-11l-17-11l-5 5l-3 17l-7 4l-11-1l1 13l6 4l-3 10l7 10l-1 8l2 7l0 15l7 1l-5 18l-6 9l0 6l8 1l4 6l8 3l-2 18l13 10l-3 12l7 5l-3 16l9 3l2 6l-3 7l7 9l6 0l6 20l1 7l7-2l12-15l8-3l4-8l4-2l13 2l27-3l6 6l11 2l10-11l-7-16l-12 1l-7-3l-2-13l-8-5l-13 5l-5 7l-11-7l-8-8l-12-1l-16-10l-2-15l-4-7l-4-34l-5-7l3-10l9-9l0-14l3-10z`},اردبیل:{x:202,y:87,d:`M229 168l7 5l3-4l12 1l-1-10l-8-8l-8-13l-5-13l3-13l12-14l-7-7l-9-12l-7-2l-5-9l-10-6l2-8l10-2l3-5l-8-9l-1-8l11-5l-15-18l-11-3l-29 21l-10 5l-4 8l4 9l-6 7l-12 6l-5-1l-5 9l5 5l10-4l8 2l12-19l13-8l6 22l-2 16l-7 0l-10 13l10 6l15 0l5 17l8 10l-2 10l1 7l12 7l2 7z`},اصفهان:{x:414,y:418,d:`M296 467l10-6l9-1l6 4l10 0l6-4l15-2l6 10l1 10l15 12l4 11l-4 7l-1 18l5 16l0 7l3 11l14 12l5-1l0-11l7-21l-9-7l6-6l17-11l4 10l16 2l18-5l-3-9l5-25l-2-19l15-11l9-2l16 4l55-19l9-6l6-19l3-4l12-5l6-12l-1-42l-4-3l-125 4l-25-8l-23 0l-10-6l-17 5l-15 1l-8 6l-2 12l3 3l-7 19l-12 5l-22 6l-13 8l-1 9l-7 14l-8 2l-4 11l-8 7l2 6l13 3z`},البرز:{x:353,y:249,d:`M351 227l-12-1l-8 2l11 9l-5 13l-12 7l-3 7l2 5l16 1l11 3l13-13l4-11l12-3l0-6l-3-4l-14-6z`},ایلام:{x:143,y:429,d:`M87 397l8 0l8 16l6 7l1 6l-4 13l9 0l11 4l12 8l21 18l12 1l3 7l9 14l9-7l-1-7l9-16l-10-20l-13-15l-11-5l-22-20l7-9l18-5l6-6l-2-9l-11 1l1 12l-24 1l-13-4l-7-5l-16-5l-11 1z`},بوشهر:{x:387,y:698,d:`M312 606l4 5l1 11l5 5l8 12l13 12l0 19l10 0l4 4l-5 9l3 5l9 6l1 10l4 10l6 7l0 7l6 10l11 8l7 1l15 0l12 9l9 2l8 6l2 11l4 2l2-3l13-1l-10-7l-14-15l-7-16l-9-8l-9-27l-24-44l-8-6l-14-19l-21-5l-6-9l-1-7l-9-4l-11-2z`},تهران:{x:384,y:274,d:`M380 240l0 6l-12 3l-4 11l-13 13l4 10l-5 14l15 1l13 3l29 18l5-16l-8-12l2-15l6 1l13 8l24 5l11-5l8-7l2-6l-3-14l-11-2l-22-7l-11 12l-12-1l-10-13l-15-4z`},"چهارمحال و بختیاری":{x:346,y:499,d:`M323 529l12 6l5 0l19 17l8 1l11-4l0-7l-5-16l1-18l4-7l-4-11l-15-12l-1-10l-6-10l-15 2l-6 4l-10 0l-6-4l-9 1l-10 6l1 5l9 17l6 4l6 14l8 9l1 6z`},"خراسان جنوبی":{x:802,y:473,d:`M734 452l-3 11l7 13l-3 13l-7 9l-11 22l59 27l8 5l21 30l40-12l18 10l12 15l10-4l-3-12l1-20l6-17l0-11l-16-2l-3-33l3-14l-13-45l0-10l13-16l3-9l-12 0l-7-5l0-13l-2-15l-36 1l-7-3l-8-10l-10 4l-16 3l-2 2l-14-2l-3 22l-2 6l4 8l8 6l-7 11l-16 11l-7 11z`},"خراسان رضوی":{x:784,y:272,d:`M657 206l6 6l-4 10l0 19l4 12l15 14l0 4l-13 22l-11 4l-13 10l-8 10l21-5l21-10l13-4l6 2l15 12l1 8l-5 5l-21 14l-3 6l-7 20l0 11l3 18l2 4l11 1l13-3l4 7l4 26l3 7l14 8l6 8l5-13l7-11l16-11l7-11l-8-6l-4-8l2-6l3-22l14 2l2-2l16-3l10-4l8 10l7 3l36-1l2-7l7-7l12-1l-9-14l12-6l6-11l3-16l0-13l9-18l-3-7l1-14l-4-8l3-7l-4-19l2-11l-6-4l-38 1l-17-26l-27-10l-7-9l-1-11l-7-2l-9-6l-9-4l-8 2l-10-3l-8 4l-8-3l-2-7l-23-8l-8 6l0 9l24 1l7 11l-1 9l-7 21l11 9l-4 5l1 9l-5 3l-15-2l-34-20l-9 0l-12 10z`},"خراسان شمالی":{x:674,y:152,d:`M712 124l-20-4l0-8l-7-12l-9 5l-16-5l-8 2l-8-1l-14 11l0 21l7 5l-2 8l-15 6l-5 8l12 16l-2 15l13 14l11 3l8-2l3-11l12-10l9 0l34 20l15 2l5-3l-1-9l4-5l-11-9l7-21l1-9l-7-11l-24-1l0-9z`},خوزستان:{x:253,y:524,d:`M183 491l13 21l-8 22l0 25l18 1l0 31l7 2l13 12l3 14l8 2l1-5l13 1l3-3l-1-10l-3-6l6-10l10 0l-9 12l13 9l12 0l6 8l17-11l7 0l9-2l11 2l-4-19l2-10l-8-5l-6-7l-9 2l0-9l-2-9l2-7l6-3l10-10l4-7l-1-6l-8-9l-6-14l-6-4l-9-17l-1-5l0-10l-13-3l-2-6l-11 0l-12-8l-12-1l-11-5l-22 2l-3 2l-10 23l-9 16l1 7z`},زنجان:{x:228,y:211,d:`M170 215l2 1l26 6l4 7l1 15l-3 11l14 8l3 4l4 5l11 0l9 4l6-5l-11-12l10-5l13-3l9-6l9-3l0-8l-4-11l-8-3l-6-11l1-9l10-5l-3-11l-8-9l-8-5l-12-1l-3 4l-7-5l-7 4l-20-2l-17 2l-11 8l-10 12l-1 7z`},سمنان:{x:554,y:286,d:`M615 160l-12 17l-10 22l-18-3l-14 6l-12 11l-7 3l-18 0l-10 4l-6 8l-2 9l-10 12l-6 4l-8 1l-15 4l3 14l-2 6l-8 7l-11 5l-24-5l-13-8l-6-1l-2 15l8 12l-5 16l1 8l-6 13l10 6l23 0l25 8l125-4l4 3l19-1l6-3l19-32l8-10l13-10l11-4l13-22l0-4l-15-14l-4-12l0-19l4-10l-6-6l-8 2l-11-3l-13-14l2-15z`},"سیستان و بلوچستان":{x:863,y:770,d:`M805 582l-11 50l0 5l5 8l2 12l-2 11l-4 7l0 13l2 7l-16 11l-9 3l8 10l-7 13l-1 27l-6 23l3 21l6 10l-3 7l0 9l3 8l-4 16l-2 4l13 11l9 14l0 4l11-2l4 4l12 0l7 4l9-2l7 2l8 0l3-5l7-2l4 10l21 4l8 5l12 3l4-8l6-5l2-27l6-4l2-19l3-5l20-6l2-9l7-3l9-1l8-4l21 1l2-12l4-3l-2-10l1-9l-4-3l-13 3l-6-1l-2-7l3-8l-2-20l-3-10l2-12l-10-1l-11-12l-16-3l-8-4l-13-12l-4-7l-5-13l-7-10l-3-9l-23-27l49-58l2-13l-4-16l-5-5l-27-4l0 11l-6 17l-1 20l3 12l-10 4l-12-15l-18-10z`},فارس:{x:473,y:666,d:`M464 773l5 7l12 1l8 5l5-1l16 2l5-2l3-13l8-5l27-2l14 2l9-5l4-8l17-6l2-5l-7-8l2-14l0-10l-16-15l1-6l-3-9l-10-26l-17-4l-9-20l-19-11l-3-17l-11-14l-8-16l-12-30l-15-16l-13-5l-18 5l-16-2l-4-10l-17 11l-6 6l9 7l-7 21l0 11l-5 1l0 13l-6 2l-16-7l-5-1l4 16l-1 6l-14 8l-16 1l1 7l6 9l21 5l14 19l8 6l24 44l9 27l9 8l7 16l14 15z`},قزوین:{x:304,y:239,d:`M270 195l-10 5l-1 9l6 11l8 3l4 11l0 8l-9 3l-9 6l-13 3l-10 5l11 12l8-1l8 10l17 3l9 0l4-5l31-9l-2-5l3-7l12-7l5-13l-11-9l8-2l12 1l-1-3l-25-20l-11 1l-15 6l-17-4z`},قم:{x:368,y:323,d:`M407 319l-29-18l-13-3l-15-1l-3 7l-2 13l-28 8l1 7l-6 6l13 9l1 7l6 6l14 1l17 6l-3-3l2-12l8-6l15-1l17-5l6-13z`},کردستان:{x:152,y:265,d:`M75 247l16 13l13-3l9 9l-10 1l-4 13l8 13l12 8l12 17l5 9l14-1l4-8l12-5l1-5l7-1l1-5l11 3l8 9l3 0l13-1l3-8l-1-6l-8-7l-9-18l8 1l14-8l-3-4l-14-8l3-11l-1-15l-4-7l-26-6l-2-1l-10 11l-11-2l-6-6l-27 3l-13-2l-4 2l-4 8l-8 3z`},کرمان:{x:697,y:622,d:`M717 520l-56-24l-6-1l-4 4l-14 10l-28 15l-2 4l-2 24l-9 4l-9 1l-11-1l-30 5l-7 10l-1 7l11 23l-1 19l2 8l-10 3l9 20l17 4l10 26l14 3l7 7l7 2l11-8l9-1l1 33l4 6l10 7l6 1l10-4l10-9l8 3l2 16l6 4l8 11l-2 6l5 10l3 25l21 11l9-5l11 9l-3 3l-4 30l16-1l7 2l5 8l7-2l7 5l4-16l-3-8l0-9l3-7l-6-10l-3-21l6-23l1-27l7-13l-8-10l9-3l16-11l-2-7l0-13l4-7l2-11l-2-12l-5-8l0-5l11-50l-21-30l-8-5z`},کرمانشاه:{x:139,y:357,d:`M107 293l3 6l-9 8l-7 3l-2 8l-8 5l-2 6l3 11l-10-3l-3 14l6 4l-1 11l-6 8l12 20l4 3l5-24l11-1l16 5l7 5l13 4l24-1l-1-12l11-1l1-8l9-3l0-8l6-1l3-4l13-1l0-7l-19-6l11-20l-3 0l-8-9l-11-3l-1 5l-7 1l-1 5l-12 5l-4 8l-14 1l-5-9l-12-17z`},"کهگیلویه و بویراحمد":{x:348,y:570,d:`M332 606l9 4l16-1l14-8l1-6l-4-16l5 1l16 7l6-2l0-13l-14-12l-3-11l-11 4l-8-1l-19-17l-5 0l-12-6l-10 10l-6 3l-2 7l2 9l0 9l9-2l6 7l8 5l-2 10z`},گلستان:{x:577,y:168,d:`M630 112l-9 1l-14-3l-15 3l-16 8l-14 12l-3 8l-1 8l-8 6l-23 7l-14-1l6 25l-1 9l-16 0l3 6l11 6l8 9l18 0l7-3l12-11l14-6l18 3l10-22l12-17l5-8l15-6l2-8l-7-5z`},گیلان:{x:295,y:181,d:`M251 170l8 5l8 9l3 11l12 12l17 4l15-6l11-1l7-12l7-8l-13-11l-9-16l-11-4l-26-2l-16-9l-6-7l-6-23l-1-23l-14 3l7 7l-12 14l-3 13l5 13l8 13l8 8z`},لرستان:{x:221,y:403,d:`M173 372l2 9l-6 6l-18 5l-7 9l22 20l11 5l13 15l10 20l10-23l3-2l22-2l11 5l12 1l12 8l11 0l8-7l4-11l8-2l7-14l1-9l-9-10l-4 6l-9-8l1-6l-7-6l-7 4l-7 9l-14-4l3-15l-15-6l-10 3l-15-2l-27-18l-6 1l0 8l-9 3z`},مازندران:{x:467,y:227,d:`M325 204l25 20l1 3l12 3l14 6l3 4l6 3l15 4l10 13l12 1l11-12l22 7l11 2l15-4l8-1l6-4l10-12l2-9l6-8l10-4l-8-9l-11-6l-3-6l-2-4l-9-1l-20 5l-17 5l-45 10l-43-10l-27-16l-7 8z`},مرکزی:{x:294,y:357,d:`M280 283l2 8l-8 0l4 11l-7 7l11 4l5 13l-8-2l-1-7l-14 0l-2 10l0 9l-7 2l1 11l4 7l2 11l-6 8l-3 15l14 4l7-9l7-4l7 6l-1 6l9 8l4-6l9 10l13-8l22-6l12-5l7-19l-17-6l-14-1l-6-6l-1-7l-13-9l6-6l-1-7l28-8l2-13l3-7l5-14l-4-10l-11-3l-16-1l-31 9l-4 5z`},هرمزگان:{x:651,y:758,d:`M771 853l-7-5l-7 2l-5-8l-7-2l-16 1l4-30l3-3l-11-9l-9 5l-21-11l-3-25l-5-10l2-6l-8-11l-6-4l-2-16l-8-3l-10 9l-10 4l-6-1l-10-7l-4-6l-1-33l-9 1l-11 8l-7-2l-7-7l-14-3l3 9l-1 6l16 15l0 10l-2 14l7 8l-2 5l-17 6l-4 8l-9 5l-14-2l-27 2l-8 5l-3 13l-5 2l-16-2l-5 1l-8-5l-12-1l-5-7l-13 1l-2 3l20 13l18 6l4 8l12 8l14-2l17 2l4 6l9 2l3 4l9 1l25-17l6 1l8-2l3-9l4-3l14-1l9-8l12-2l12 3l12 0l8 10l6 21l0 10l3 10l4 6l-3 4l9 18l23 3l1 5l9-3l6 7l24-1l14 1l10 9l6 1l7-2l0-4l-9-14l-13-11zM633 795l-9 2l-13 8l-3 3l-20 8l8 3l10-6l9-3l4 3l7-5z`},همدان:{x:235,y:319,d:`M197 314l-11 20l19 6l0 7l-13 1l-3 4l27 18l15 2l10-3l15 6l6-8l-2-11l-4-7l-1-11l7-2l0-9l2-10l14 0l1 7l8 2l-5-13l-11-4l7-7l-4-11l8 0l-2-8l-17-3l-8-10l-8 1l-6 5l-9-4l-11 0l-4-5l-14 8l-8-1l9 18l8 7l1 6l-3 8z`},یزد:{x:615,y:452,d:`M633 317l-19 32l-6 3l-19 1l1 42l-6 12l-12 5l-3 4l-6 19l-9 6l-55 19l-16-4l-9 2l-15 11l2 19l-5 25l3 9l13 5l15 16l12 30l8 16l11 14l3 17l19 11l10-3l-2-8l1-19l-11-23l1-7l7-10l30-5l11 1l9-1l9-4l2-24l2-4l28-15l14-10l4-4l6 1l56 24l11-22l7-9l3-13l-7-13l3-11l-6-8l-14-8l-3-7l-4-26l-4-7l-13 3l-11-1l-2-4l-3-18l0-11l7-20l3-6l21-14l5-5l-1-8l-15-12l-6-2l-13 4l-21 10z`}},h=d.map(e=>e.name),g=Object.fromEntries(d.map(e=>[e.name,e.capital])),[,,_,v]=p.split(` `).map(Number);var y=class extends c{constructor(){super(...arguments),this.values=null,this.selected=[],this.active=0,this.rendered=!1,this.valueSet=!1,this.key=l(`kashi-map`)}connectedCallback(){this.rendered||(this.valueSet||(this.selected=(this.getAttribute(`value`)??``).split(/[,،]/).map(e=>e.trim()).filter(e=>h.includes(e))),this.values===null&&(this.values=this.parseData(this.getAttribute(`data`)))),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`data`&&(this.values=this.parseData(n)),e===`value`?this.value=n??``:this.render())}parseData(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}get data(){return this.values}set data(e){this.values=e,this.rendered&&this.render()}get value(){return this.selected.join(`,`)}set value(e){this.valueSet=!0,this.selected=String(e??``).split(/[,،]/).map(e=>e.trim()).filter(e=>h.includes(e)),this.multiple||(this.selected=this.selected.slice(0,1)),this.rendered&&this.paint()}get selectedProvinces(){return[...this.selected]}get multiple(){return t(this,`multiple`)}get selectable(){return this.multiple||t(this,`selectable`)||this.hasAttribute(`value`)||this.hasAttribute(`name`)}fmt(e){return n(e,{digits:s(this)})}level(e){let t=this.values,n=t?.[e];if(typeof n!=`number`||!t)return;let r=this.steps,i=h.map(e=>t[e]).filter(e=>typeof e==`number`),a=Math.min(...i),o=Math.max(...i);if(o===a)return r;if(this.getAttribute(`scale`)!==`linear`){let e=[...i].sort((e,t)=>e-t);return 1+Math.round(e.indexOf(n)*(r-1)/(e.length-1))}return Math.min(r,1+Math.floor((n-a)/(o-a)*r))}get steps(){return Number(this.getAttribute(`steps`))||5}shade(e){return`${Math.round(12+88*e/this.steps)}%`}describe(e){let t=this.values?.[e],n=this.getAttribute(`unit`);return typeof t==`number`?`${e}: ${this.fmt(t)}${n?` ${n}`:``}`:e}render(){let e=this.getAttribute(`label`)??a().iranMap.label,n=this.selectable,i=this.multiple,o=this.values,s=this.getAttribute(`unit`),c=h.map((e,t)=>{let a=this.level(e);return`<path d="${m[e].d}" class="k-iran-map__province" data-i="${t}"${a?` data-l="${a}" style="--_p: ${this.shade(a)}"`:``}${n?` role="${i?`checkbox`:`radio`}" aria-label="${r(this.describe(e))}"`:``}></path>`}).join(``),l=o?h.map(e=>o[e]).filter(e=>typeof e==`number`):[],u=(this.hasAttribute(`legend`)?t(this,`legend`):o)&&l.length?`<figcaption class="k-iran-map__legend"><span>${this.fmt(Math.min(...l))}</span><span class="k-iran-map__scale" aria-hidden="true">${Array.from({length:this.steps},(e,t)=>`<i style="--_p: ${this.shade(t+1)}"></i>`).join(``)}</span><span>${this.fmt(Math.max(...l))}${s?` ${r(s)}`:``}</span></figcaption>`:``,d=o?`<table class="k-sr-only"><caption>${r(e)}</caption><tbody>${h.filter(e=>typeof o[e]==`number`).sort((e,t)=>o[t]-o[e]).map(e=>`<tr><th scope="row">${r(e)}</th><td>${this.fmt(o[e])}${s?` ${r(s)}`:``}</td></tr>`).join(``)}</tbody></table>`:``;this.innerHTML=`<figure class="k-iran-map${n?` k-iran-map--selectable`:``}"><div class="k-iran-map__canvas" style="block-size: auto; aspect-ratio: ${_} / ${v}"><svg viewBox="${p}" class="k-iran-map__svg" role="${n?i?`group`:`radiogroup`:`img`}" aria-label="${r(n?e:`${e}${o?a().iranMap.tableNote:``}`)}">${c}</svg><div class="k-chart__tip" aria-hidden="true" style="display: none"></div></div>${u}${d}</figure>`;let f=this.querySelector(`svg`),g=this.querySelector(`figure`);f.addEventListener(`pointerover`,e=>{let t=e.target.getAttribute?.(`data-i`);t!=null&&this.tip(Number(t))}),g.addEventListener(`pointerleave`,()=>this.tip(null)),n&&(f.addEventListener(`click`,e=>{let t=e.target.getAttribute?.(`data-i`);t!=null&&(this.active=Number(t),this.toggle(h[this.active]))}),f.addEventListener(`keydown`,e=>this.onKey(e)),f.addEventListener(`focusin`,e=>{let t=e.target.getAttribute?.(`data-i`);t!=null&&(this.active=Number(t),this.tip(this.active))}),f.addEventListener(`focusout`,()=>this.tip(null))),this.rendered=!0,this.paint()}paint(){let e=this.selectable,t=h.findIndex(e=>this.selected.includes(e)),n=this.contains(document.activeElement)||t<0?this.active:t;this.querySelectorAll(`.k-iran-map__province`).forEach((t,r)=>{let i=this.selected.includes(h[r]);t.toggleAttribute(`data-selected`,i),e&&(t.setAttribute(`aria-checked`,String(i)),t.setAttribute(`tabindex`,r===n?`0`:`-1`))});let r=this.getAttribute(`name`);if(this.querySelectorAll(`:scope > input[type=hidden]`).forEach(e=>e.remove()),r)for(let e of this.multiple?this.selected:[this.selected[0]??``]){let t=document.createElement(`input`);t.type=`hidden`,t.name=r,t.value=e,this.append(t)}}toggle(t){this.selected=this.multiple?this.selected.includes(t)?this.selected.filter(e=>e!==t):[...this.selected,t]:this.selected[0]===t?[]:[t],this.paint(),e(this,`kashi-change`,{value:this.multiple?[...this.selected]:this.selected[0]??null})}onKey(e){let t=this.active,n={ArrowLeft:1,ArrowDown:1,ArrowRight:-1,ArrowUp:-1}[e.key],r=t;if(n)r=(t+n+h.length)%h.length;else if(e.key===`Home`)r=0;else if(e.key===`End`)r=h.length-1;else if(e.key===`Enter`||e.key===` `){e.preventDefault(),this.toggle(h[t]);return}else return;e.preventDefault(),this.active=r,this.paint(),this.querySelector(`[data-i="${r}"]`)?.focus()}tip(e){let t=this.querySelector(`.k-chart__tip`);if(!t)return;if(this.querySelector(`.k-iran-map__province[data-active]`)?.removeAttribute(`data-active`),e===null){t.style.display=`none`;return}let n=h[e];this.querySelector(`[data-i="${e}"]`)?.setAttribute(`data-active`,``);let i=m[n],o=this.querySelector(`figure`).clientWidth||_,s=this.values?.[n],c=this.getAttribute(`unit`),l=typeof s==`number`?`${this.fmt(s)}${c?` ${c}`:``}`:a().province.capital(g[n]);t.innerHTML=`<span class="k-chart__tip-title">${r(n)}</span><span class="k-chart__tip-row"><strong>${r(l)}</strong></span>`,t.style.left=`${Math.min(Math.max(i.x/_*o,80),o-80)}px`,t.style.top=`${Math.max(64,i.y/v*(v/_*o)-6)}px`,t.style.display=``}};y.observedAttributes=[`data`,`value`,`label`,`unit`,`steps`,`scale`,`legend`,`selectable`,`multiple`,`name`];const b=()=>{let e=a().address;return{province:e.province,city:e.city,street:e.street,plaque:e.plaque,unit:e.unit,postalCode:e.postalCode}};var x=class extends c{constructor(){super(...arguments),this.address={...f},this.built=!1,this.key=l(`kashi-address`)}connectedCallback(){o(()=>{if(this.isConnected){if(!this.built){let e=Object.prototype.hasOwnProperty.call(this,`value`)?this.value:null;delete this.value;let t=this.getAttribute(`value`),n=e??{};if(!e&&t)try{n=JSON.parse(t)}catch{}this.address={...f,...n}}this.render()}})}attributeChangedCallback(e,t,n){this.built&&t!==n&&this.render()}get value(){return{...this.address}}set value(e){this.address={...f,...e},this.built&&this.render()}set errors(e){for(let t of Object.keys(b())){let n=this.querySelector(`[data-field="${t}"]`);n&&(n.matches(`kashi-province-select, kashi-city-select, kashi-postal-code`)?e[t]?n.setAttribute(`error`,e[t]):n.removeAttribute(`error`):this.fieldError(n,e[t]??null))}}label(e){return this.getAttribute(`label-${e===`postalCode`?`postal-code`:e}`)??b()[e]}render(){let e=this.address,n=this.getAttribute(`name`),i=e=>n?` name="${r(`${n}[${e}]`)}"`:``,o=t(this,`required`,!0),s=o?` required`:``,c=t(this,`map`),l=this.key,d=o?`<span class="k-label__required" aria-hidden="true">*</span>`:``,f=this.getAttribute(`legend`)??a().address.legend;this.innerHTML=`<fieldset class="k-address${c?` k-address--map`:``}"${this.hasAttribute(`disabled`)?` disabled`:``}>
1
+ import{c as e,i as t,k as n,l as r,o as i,p as a,r as o,s,t as c,y as l}from"./base-BUQYhiEA.js";import{n as u,r as d,t as f}from"./combobox-Br5cwZFz.js";import"./inputs-CI_r2s8t.js";const p=`0 0 1000 907`,m={"آذربایجان شرقی":{x:123,y:128,d:`M163 199l1-7l10-12l11-8l17-2l20 2l7-4l-13-8l-2-7l-12-7l-1-7l2-10l-8-10l-5-17l-15 0l-10-6l10-13l7 0l2-16l-6-22l-13 8l-12 19l-8-2l-10 4l-5-5l5-9l5 1l12-6l6-7l-4-9l-8 1l-15 18l-10-1l-13 4l-33-8l-6 6l-3 10l0 14l-9 9l-3 10l5 7l4 34l4 7l2 15l16 10l12 1l8 8l11 7l5-7l13-5l8 5l2 13l7 3z`},"آذربایجان غربی":{x:39,y:59,d:`M75 53l-8-13l-9-3l-6-11l-5-4l-4-11l-17-11l-5 5l-3 17l-7 4l-11-1l1 13l6 4l-3 10l7 10l-1 8l2 7l0 15l7 1l-5 18l-6 9l0 6l8 1l4 6l8 3l-2 18l13 10l-3 12l7 5l-3 16l9 3l2 6l-3 7l7 9l6 0l6 20l1 7l7-2l12-15l8-3l4-8l4-2l13 2l27-3l6 6l11 2l10-11l-7-16l-12 1l-7-3l-2-13l-8-5l-13 5l-5 7l-11-7l-8-8l-12-1l-16-10l-2-15l-4-7l-4-34l-5-7l3-10l9-9l0-14l3-10z`},اردبیل:{x:202,y:87,d:`M229 168l7 5l3-4l12 1l-1-10l-8-8l-8-13l-5-13l3-13l12-14l-7-7l-9-12l-7-2l-5-9l-10-6l2-8l10-2l3-5l-8-9l-1-8l11-5l-15-18l-11-3l-29 21l-10 5l-4 8l4 9l-6 7l-12 6l-5-1l-5 9l5 5l10-4l8 2l12-19l13-8l6 22l-2 16l-7 0l-10 13l10 6l15 0l5 17l8 10l-2 10l1 7l12 7l2 7z`},اصفهان:{x:414,y:418,d:`M296 467l10-6l9-1l6 4l10 0l6-4l15-2l6 10l1 10l15 12l4 11l-4 7l-1 18l5 16l0 7l3 11l14 12l5-1l0-11l7-21l-9-7l6-6l17-11l4 10l16 2l18-5l-3-9l5-25l-2-19l15-11l9-2l16 4l55-19l9-6l6-19l3-4l12-5l6-12l-1-42l-4-3l-125 4l-25-8l-23 0l-10-6l-17 5l-15 1l-8 6l-2 12l3 3l-7 19l-12 5l-22 6l-13 8l-1 9l-7 14l-8 2l-4 11l-8 7l2 6l13 3z`},البرز:{x:353,y:249,d:`M351 227l-12-1l-8 2l11 9l-5 13l-12 7l-3 7l2 5l16 1l11 3l13-13l4-11l12-3l0-6l-3-4l-14-6z`},ایلام:{x:143,y:429,d:`M87 397l8 0l8 16l6 7l1 6l-4 13l9 0l11 4l12 8l21 18l12 1l3 7l9 14l9-7l-1-7l9-16l-10-20l-13-15l-11-5l-22-20l7-9l18-5l6-6l-2-9l-11 1l1 12l-24 1l-13-4l-7-5l-16-5l-11 1z`},بوشهر:{x:387,y:698,d:`M312 606l4 5l1 11l5 5l8 12l13 12l0 19l10 0l4 4l-5 9l3 5l9 6l1 10l4 10l6 7l0 7l6 10l11 8l7 1l15 0l12 9l9 2l8 6l2 11l4 2l2-3l13-1l-10-7l-14-15l-7-16l-9-8l-9-27l-24-44l-8-6l-14-19l-21-5l-6-9l-1-7l-9-4l-11-2z`},تهران:{x:384,y:274,d:`M380 240l0 6l-12 3l-4 11l-13 13l4 10l-5 14l15 1l13 3l29 18l5-16l-8-12l2-15l6 1l13 8l24 5l11-5l8-7l2-6l-3-14l-11-2l-22-7l-11 12l-12-1l-10-13l-15-4z`},"چهارمحال و بختیاری":{x:346,y:499,d:`M323 529l12 6l5 0l19 17l8 1l11-4l0-7l-5-16l1-18l4-7l-4-11l-15-12l-1-10l-6-10l-15 2l-6 4l-10 0l-6-4l-9 1l-10 6l1 5l9 17l6 4l6 14l8 9l1 6z`},"خراسان جنوبی":{x:802,y:473,d:`M734 452l-3 11l7 13l-3 13l-7 9l-11 22l59 27l8 5l21 30l40-12l18 10l12 15l10-4l-3-12l1-20l6-17l0-11l-16-2l-3-33l3-14l-13-45l0-10l13-16l3-9l-12 0l-7-5l0-13l-2-15l-36 1l-7-3l-8-10l-10 4l-16 3l-2 2l-14-2l-3 22l-2 6l4 8l8 6l-7 11l-16 11l-7 11z`},"خراسان رضوی":{x:784,y:272,d:`M657 206l6 6l-4 10l0 19l4 12l15 14l0 4l-13 22l-11 4l-13 10l-8 10l21-5l21-10l13-4l6 2l15 12l1 8l-5 5l-21 14l-3 6l-7 20l0 11l3 18l2 4l11 1l13-3l4 7l4 26l3 7l14 8l6 8l5-13l7-11l16-11l7-11l-8-6l-4-8l2-6l3-22l14 2l2-2l16-3l10-4l8 10l7 3l36-1l2-7l7-7l12-1l-9-14l12-6l6-11l3-16l0-13l9-18l-3-7l1-14l-4-8l3-7l-4-19l2-11l-6-4l-38 1l-17-26l-27-10l-7-9l-1-11l-7-2l-9-6l-9-4l-8 2l-10-3l-8 4l-8-3l-2-7l-23-8l-8 6l0 9l24 1l7 11l-1 9l-7 21l11 9l-4 5l1 9l-5 3l-15-2l-34-20l-9 0l-12 10z`},"خراسان شمالی":{x:674,y:152,d:`M712 124l-20-4l0-8l-7-12l-9 5l-16-5l-8 2l-8-1l-14 11l0 21l7 5l-2 8l-15 6l-5 8l12 16l-2 15l13 14l11 3l8-2l3-11l12-10l9 0l34 20l15 2l5-3l-1-9l4-5l-11-9l7-21l1-9l-7-11l-24-1l0-9z`},خوزستان:{x:253,y:524,d:`M183 491l13 21l-8 22l0 25l18 1l0 31l7 2l13 12l3 14l8 2l1-5l13 1l3-3l-1-10l-3-6l6-10l10 0l-9 12l13 9l12 0l6 8l17-11l7 0l9-2l11 2l-4-19l2-10l-8-5l-6-7l-9 2l0-9l-2-9l2-7l6-3l10-10l4-7l-1-6l-8-9l-6-14l-6-4l-9-17l-1-5l0-10l-13-3l-2-6l-11 0l-12-8l-12-1l-11-5l-22 2l-3 2l-10 23l-9 16l1 7z`},زنجان:{x:228,y:211,d:`M170 215l2 1l26 6l4 7l1 15l-3 11l14 8l3 4l4 5l11 0l9 4l6-5l-11-12l10-5l13-3l9-6l9-3l0-8l-4-11l-8-3l-6-11l1-9l10-5l-3-11l-8-9l-8-5l-12-1l-3 4l-7-5l-7 4l-20-2l-17 2l-11 8l-10 12l-1 7z`},سمنان:{x:554,y:286,d:`M615 160l-12 17l-10 22l-18-3l-14 6l-12 11l-7 3l-18 0l-10 4l-6 8l-2 9l-10 12l-6 4l-8 1l-15 4l3 14l-2 6l-8 7l-11 5l-24-5l-13-8l-6-1l-2 15l8 12l-5 16l1 8l-6 13l10 6l23 0l25 8l125-4l4 3l19-1l6-3l19-32l8-10l13-10l11-4l13-22l0-4l-15-14l-4-12l0-19l4-10l-6-6l-8 2l-11-3l-13-14l2-15z`},"سیستان و بلوچستان":{x:863,y:770,d:`M805 582l-11 50l0 5l5 8l2 12l-2 11l-4 7l0 13l2 7l-16 11l-9 3l8 10l-7 13l-1 27l-6 23l3 21l6 10l-3 7l0 9l3 8l-4 16l-2 4l13 11l9 14l0 4l11-2l4 4l12 0l7 4l9-2l7 2l8 0l3-5l7-2l4 10l21 4l8 5l12 3l4-8l6-5l2-27l6-4l2-19l3-5l20-6l2-9l7-3l9-1l8-4l21 1l2-12l4-3l-2-10l1-9l-4-3l-13 3l-6-1l-2-7l3-8l-2-20l-3-10l2-12l-10-1l-11-12l-16-3l-8-4l-13-12l-4-7l-5-13l-7-10l-3-9l-23-27l49-58l2-13l-4-16l-5-5l-27-4l0 11l-6 17l-1 20l3 12l-10 4l-12-15l-18-10z`},فارس:{x:473,y:666,d:`M464 773l5 7l12 1l8 5l5-1l16 2l5-2l3-13l8-5l27-2l14 2l9-5l4-8l17-6l2-5l-7-8l2-14l0-10l-16-15l1-6l-3-9l-10-26l-17-4l-9-20l-19-11l-3-17l-11-14l-8-16l-12-30l-15-16l-13-5l-18 5l-16-2l-4-10l-17 11l-6 6l9 7l-7 21l0 11l-5 1l0 13l-6 2l-16-7l-5-1l4 16l-1 6l-14 8l-16 1l1 7l6 9l21 5l14 19l8 6l24 44l9 27l9 8l7 16l14 15z`},قزوین:{x:304,y:239,d:`M270 195l-10 5l-1 9l6 11l8 3l4 11l0 8l-9 3l-9 6l-13 3l-10 5l11 12l8-1l8 10l17 3l9 0l4-5l31-9l-2-5l3-7l12-7l5-13l-11-9l8-2l12 1l-1-3l-25-20l-11 1l-15 6l-17-4z`},قم:{x:368,y:323,d:`M407 319l-29-18l-13-3l-15-1l-3 7l-2 13l-28 8l1 7l-6 6l13 9l1 7l6 6l14 1l17 6l-3-3l2-12l8-6l15-1l17-5l6-13z`},کردستان:{x:152,y:265,d:`M75 247l16 13l13-3l9 9l-10 1l-4 13l8 13l12 8l12 17l5 9l14-1l4-8l12-5l1-5l7-1l1-5l11 3l8 9l3 0l13-1l3-8l-1-6l-8-7l-9-18l8 1l14-8l-3-4l-14-8l3-11l-1-15l-4-7l-26-6l-2-1l-10 11l-11-2l-6-6l-27 3l-13-2l-4 2l-4 8l-8 3z`},کرمان:{x:697,y:622,d:`M717 520l-56-24l-6-1l-4 4l-14 10l-28 15l-2 4l-2 24l-9 4l-9 1l-11-1l-30 5l-7 10l-1 7l11 23l-1 19l2 8l-10 3l9 20l17 4l10 26l14 3l7 7l7 2l11-8l9-1l1 33l4 6l10 7l6 1l10-4l10-9l8 3l2 16l6 4l8 11l-2 6l5 10l3 25l21 11l9-5l11 9l-3 3l-4 30l16-1l7 2l5 8l7-2l7 5l4-16l-3-8l0-9l3-7l-6-10l-3-21l6-23l1-27l7-13l-8-10l9-3l16-11l-2-7l0-13l4-7l2-11l-2-12l-5-8l0-5l11-50l-21-30l-8-5z`},کرمانشاه:{x:139,y:357,d:`M107 293l3 6l-9 8l-7 3l-2 8l-8 5l-2 6l3 11l-10-3l-3 14l6 4l-1 11l-6 8l12 20l4 3l5-24l11-1l16 5l7 5l13 4l24-1l-1-12l11-1l1-8l9-3l0-8l6-1l3-4l13-1l0-7l-19-6l11-20l-3 0l-8-9l-11-3l-1 5l-7 1l-1 5l-12 5l-4 8l-14 1l-5-9l-12-17z`},"کهگیلویه و بویراحمد":{x:348,y:570,d:`M332 606l9 4l16-1l14-8l1-6l-4-16l5 1l16 7l6-2l0-13l-14-12l-3-11l-11 4l-8-1l-19-17l-5 0l-12-6l-10 10l-6 3l-2 7l2 9l0 9l9-2l6 7l8 5l-2 10z`},گلستان:{x:577,y:168,d:`M630 112l-9 1l-14-3l-15 3l-16 8l-14 12l-3 8l-1 8l-8 6l-23 7l-14-1l6 25l-1 9l-16 0l3 6l11 6l8 9l18 0l7-3l12-11l14-6l18 3l10-22l12-17l5-8l15-6l2-8l-7-5z`},گیلان:{x:295,y:181,d:`M251 170l8 5l8 9l3 11l12 12l17 4l15-6l11-1l7-12l7-8l-13-11l-9-16l-11-4l-26-2l-16-9l-6-7l-6-23l-1-23l-14 3l7 7l-12 14l-3 13l5 13l8 13l8 8z`},لرستان:{x:221,y:403,d:`M173 372l2 9l-6 6l-18 5l-7 9l22 20l11 5l13 15l10 20l10-23l3-2l22-2l11 5l12 1l12 8l11 0l8-7l4-11l8-2l7-14l1-9l-9-10l-4 6l-9-8l1-6l-7-6l-7 4l-7 9l-14-4l3-15l-15-6l-10 3l-15-2l-27-18l-6 1l0 8l-9 3z`},مازندران:{x:467,y:227,d:`M325 204l25 20l1 3l12 3l14 6l3 4l6 3l15 4l10 13l12 1l11-12l22 7l11 2l15-4l8-1l6-4l10-12l2-9l6-8l10-4l-8-9l-11-6l-3-6l-2-4l-9-1l-20 5l-17 5l-45 10l-43-10l-27-16l-7 8z`},مرکزی:{x:294,y:357,d:`M280 283l2 8l-8 0l4 11l-7 7l11 4l5 13l-8-2l-1-7l-14 0l-2 10l0 9l-7 2l1 11l4 7l2 11l-6 8l-3 15l14 4l7-9l7-4l7 6l-1 6l9 8l4-6l9 10l13-8l22-6l12-5l7-19l-17-6l-14-1l-6-6l-1-7l-13-9l6-6l-1-7l28-8l2-13l3-7l5-14l-4-10l-11-3l-16-1l-31 9l-4 5z`},هرمزگان:{x:651,y:758,d:`M771 853l-7-5l-7 2l-5-8l-7-2l-16 1l4-30l3-3l-11-9l-9 5l-21-11l-3-25l-5-10l2-6l-8-11l-6-4l-2-16l-8-3l-10 9l-10 4l-6-1l-10-7l-4-6l-1-33l-9 1l-11 8l-7-2l-7-7l-14-3l3 9l-1 6l16 15l0 10l-2 14l7 8l-2 5l-17 6l-4 8l-9 5l-14-2l-27 2l-8 5l-3 13l-5 2l-16-2l-5 1l-8-5l-12-1l-5-7l-13 1l-2 3l20 13l18 6l4 8l12 8l14-2l17 2l4 6l9 2l3 4l9 1l25-17l6 1l8-2l3-9l4-3l14-1l9-8l12-2l12 3l12 0l8 10l6 21l0 10l3 10l4 6l-3 4l9 18l23 3l1 5l9-3l6 7l24-1l14 1l10 9l6 1l7-2l0-4l-9-14l-13-11zM633 795l-9 2l-13 8l-3 3l-20 8l8 3l10-6l9-3l4 3l7-5z`},همدان:{x:235,y:319,d:`M197 314l-11 20l19 6l0 7l-13 1l-3 4l27 18l15 2l10-3l15 6l6-8l-2-11l-4-7l-1-11l7-2l0-9l2-10l14 0l1 7l8 2l-5-13l-11-4l7-7l-4-11l8 0l-2-8l-17-3l-8-10l-8 1l-6 5l-9-4l-11 0l-4-5l-14 8l-8-1l9 18l8 7l1 6l-3 8z`},یزد:{x:615,y:452,d:`M633 317l-19 32l-6 3l-19 1l1 42l-6 12l-12 5l-3 4l-6 19l-9 6l-55 19l-16-4l-9 2l-15 11l2 19l-5 25l3 9l13 5l15 16l12 30l8 16l11 14l3 17l19 11l10-3l-2-8l1-19l-11-23l1-7l7-10l30-5l11 1l9-1l9-4l2-24l2-4l28-15l14-10l4-4l6 1l56 24l11-22l7-9l3-13l-7-13l3-11l-6-8l-14-8l-3-7l-4-26l-4-7l-13 3l-11-1l-2-4l-3-18l0-11l7-20l3-6l21-14l5-5l-1-8l-15-12l-6-2l-13 4l-21 10z`}},h=d.map(e=>e.name),g=Object.fromEntries(d.map(e=>[e.name,e.capital])),[,,_,v]=p.split(` `).map(Number);var y=class extends c{constructor(){super(...arguments),this.values=null,this.selected=[],this.active=0,this.rendered=!1,this.valueSet=!1,this.key=l(`kashi-map`)}connectedCallback(){this.rendered||(this.valueSet||(this.selected=(this.getAttribute(`value`)??``).split(/[,،]/).map(e=>e.trim()).filter(e=>h.includes(e))),this.values===null&&(this.values=this.parseData(this.getAttribute(`data`)))),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`data`&&(this.values=this.parseData(n)),e===`value`?this.value=n??``:this.render())}parseData(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}get data(){return this.values}set data(e){this.values=e,this.rendered&&this.render()}get value(){return this.selected.join(`,`)}set value(e){this.valueSet=!0,this.selected=String(e??``).split(/[,،]/).map(e=>e.trim()).filter(e=>h.includes(e)),this.multiple||(this.selected=this.selected.slice(0,1)),this.rendered&&this.paint()}get selectedProvinces(){return[...this.selected]}get multiple(){return t(this,`multiple`)}get selectable(){return this.multiple||t(this,`selectable`)||this.hasAttribute(`value`)||this.hasAttribute(`name`)}fmt(e){return n(e,{digits:s(this)})}level(e){let t=this.values,n=t?.[e];if(typeof n!=`number`||!t)return;let r=this.steps,i=h.map(e=>t[e]).filter(e=>typeof e==`number`),a=Math.min(...i),o=Math.max(...i);if(o===a)return r;if(this.getAttribute(`scale`)!==`linear`){let e=[...i].sort((e,t)=>e-t);return 1+Math.round(e.indexOf(n)*(r-1)/(e.length-1))}return Math.min(r,1+Math.floor((n-a)/(o-a)*r))}get steps(){return Number(this.getAttribute(`steps`))||5}shade(e){return`${Math.round(12+88*e/this.steps)}%`}describe(e){let t=this.values?.[e],n=this.getAttribute(`unit`);return typeof t==`number`?`${e}: ${this.fmt(t)}${n?` ${n}`:``}`:e}render(){let e=this.getAttribute(`label`)??a().iranMap.label,n=this.selectable,i=this.multiple,o=this.values,s=this.getAttribute(`unit`),c=h.map((e,t)=>{let a=this.level(e);return`<path d="${m[e].d}" class="k-iran-map__province" data-i="${t}"${a?` data-l="${a}" style="--_p: ${this.shade(a)}"`:``}${n?` role="${i?`checkbox`:`radio`}" aria-label="${r(this.describe(e))}"`:``}></path>`}).join(``),l=o?h.map(e=>o[e]).filter(e=>typeof e==`number`):[],u=(this.hasAttribute(`legend`)?t(this,`legend`):o)&&l.length?`<figcaption class="k-iran-map__legend"><span>${this.fmt(Math.min(...l))}</span><span class="k-iran-map__scale" aria-hidden="true">${Array.from({length:this.steps},(e,t)=>`<i style="--_p: ${this.shade(t+1)}"></i>`).join(``)}</span><span>${this.fmt(Math.max(...l))}${s?` ${r(s)}`:``}</span></figcaption>`:``,d=o?`<table class="k-sr-only"><caption>${r(e)}</caption><tbody>${h.filter(e=>typeof o[e]==`number`).sort((e,t)=>o[t]-o[e]).map(e=>`<tr><th scope="row">${r(e)}</th><td>${this.fmt(o[e])}${s?` ${r(s)}`:``}</td></tr>`).join(``)}</tbody></table>`:``;this.innerHTML=`<figure class="k-iran-map${n?` k-iran-map--selectable`:``}"><div class="k-iran-map__canvas" style="block-size: auto; aspect-ratio: ${_} / ${v}"><svg viewBox="${p}" class="k-iran-map__svg" role="${n?i?`group`:`radiogroup`:`img`}" aria-label="${r(n?e:`${e}${o?a().iranMap.tableNote:``}`)}">${c}</svg><div class="k-chart__tip" aria-hidden="true" style="display: none"></div></div>${u}${d}</figure>`;let f=this.querySelector(`svg`),g=this.querySelector(`figure`);f.addEventListener(`pointerover`,e=>{let t=e.target.getAttribute?.(`data-i`);t!=null&&this.tip(Number(t))}),g.addEventListener(`pointerleave`,()=>this.tip(null)),n&&(f.addEventListener(`click`,e=>{let t=e.target.getAttribute?.(`data-i`);t!=null&&(this.active=Number(t),this.toggle(h[this.active]))}),f.addEventListener(`keydown`,e=>this.onKey(e)),f.addEventListener(`focusin`,e=>{let t=e.target.getAttribute?.(`data-i`);t!=null&&(this.active=Number(t),this.tip(this.active))}),f.addEventListener(`focusout`,()=>this.tip(null))),this.rendered=!0,this.paint()}paint(){let e=this.selectable,t=h.findIndex(e=>this.selected.includes(e)),n=this.contains(document.activeElement)||t<0?this.active:t;this.querySelectorAll(`.k-iran-map__province`).forEach((t,r)=>{let i=this.selected.includes(h[r]);t.toggleAttribute(`data-selected`,i),e&&(t.setAttribute(`aria-checked`,String(i)),t.setAttribute(`tabindex`,r===n?`0`:`-1`))});let r=this.getAttribute(`name`);if(this.querySelectorAll(`:scope > input[type=hidden]`).forEach(e=>e.remove()),r)for(let e of this.multiple?this.selected:[this.selected[0]??``]){let t=document.createElement(`input`);t.type=`hidden`,t.name=r,t.value=e,this.append(t)}}toggle(t){this.selected=this.multiple?this.selected.includes(t)?this.selected.filter(e=>e!==t):[...this.selected,t]:this.selected[0]===t?[]:[t],this.paint(),e(this,`kashi-change`,{value:this.multiple?[...this.selected]:this.selected[0]??null})}onKey(e){let t=this.active,n={ArrowLeft:1,ArrowDown:1,ArrowRight:-1,ArrowUp:-1}[e.key],r=t;if(n)r=(t+n+h.length)%h.length;else if(e.key===`Home`)r=0;else if(e.key===`End`)r=h.length-1;else if(e.key===`Enter`||e.key===` `){e.preventDefault(),this.toggle(h[t]);return}else return;e.preventDefault(),this.active=r,this.paint(),this.querySelector(`[data-i="${r}"]`)?.focus()}tip(e){let t=this.querySelector(`.k-chart__tip`);if(!t)return;if(this.querySelector(`.k-iran-map__province[data-active]`)?.removeAttribute(`data-active`),e===null){t.style.display=`none`;return}let n=h[e];this.querySelector(`[data-i="${e}"]`)?.setAttribute(`data-active`,``);let i=m[n],o=this.querySelector(`figure`).clientWidth||_,s=this.values?.[n],c=this.getAttribute(`unit`),l=typeof s==`number`?`${this.fmt(s)}${c?` ${c}`:``}`:a().province.capital(g[n]);t.innerHTML=`<span class="k-chart__tip-title">${r(n)}</span><span class="k-chart__tip-row"><strong>${r(l)}</strong></span>`,t.style.left=`${Math.min(Math.max(i.x/_*o,80),o-80)}px`,t.style.top=`${Math.max(64,i.y/v*(v/_*o)-6)}px`,t.style.display=``}};y.observedAttributes=[`data`,`value`,`label`,`unit`,`steps`,`scale`,`legend`,`selectable`,`multiple`,`name`];const b=()=>{let e=a().address;return{province:e.province,city:e.city,street:e.street,plaque:e.plaque,unit:e.unit,postalCode:e.postalCode}};var x=class extends c{constructor(){super(...arguments),this.address={...f},this.built=!1,this.key=l(`kashi-address`)}connectedCallback(){o(()=>{if(this.isConnected){if(!this.built){let e=Object.prototype.hasOwnProperty.call(this,`value`)?this.value:null;delete this.value;let t=this.getAttribute(`value`),n=e??{};if(!e&&t)try{n=JSON.parse(t)}catch{}this.address={...f,...n}}this.render()}})}attributeChangedCallback(e,t,n){this.built&&t!==n&&this.render()}get value(){return{...this.address}}set value(e){this.address={...f,...e},this.built&&this.render()}set errors(e){for(let t of Object.keys(b())){let n=this.querySelector(`[data-field="${t}"]`);n&&(n.matches(`kashi-province-select, kashi-city-select, kashi-postal-code`)?e[t]?n.setAttribute(`error`,e[t]):n.removeAttribute(`error`):this.fieldError(n,e[t]??null))}}label(e){return this.getAttribute(`label-${e===`postalCode`?`postal-code`:e}`)??b()[e]}render(){let e=this.address,n=this.getAttribute(`name`),i=e=>n?` name="${r(`${n}[${e}]`)}"`:``,o=t(this,`required`,!0),s=o?` required`:``,c=t(this,`map`),l=this.key,d=o?`<span class="k-label__required" aria-hidden="true">*</span>`:``,f=this.getAttribute(`legend`)??a().address.legend;this.innerHTML=`<fieldset class="k-address${c?` k-address--map`:``}"${this.hasAttribute(`disabled`)?` disabled`:``}>
2
2
  ${f?`<legend class="k-address__legend">${r(f)}</legend>`:``}
3
3
  <div class="k-address__fields">
4
4
  <kashi-province-select class="k-address__province" data-field="province" label="${r(this.label(`province`))}" show-capital="false" placeholder="${r(a().address.provinceSearch)}"${i(`province`)}${s}></kashi-province-select>
@@ -1 +1 @@
1
- import{c as e,l as t,o as n,r,t as i,y as a}from"./base-C2zmRRrl.js";const o=e=>[...e.querySelectorAll(`[role^="menuitem"]:not([aria-disabled="true"])`)];var s=class extends i{constructor(){super(...arguments),this.menu=null,this.trigger=null,this.key=a(`kashi-menu`),this.onOutside=e=>{this.contains(e.target)||this.close(!1)}}connectedCallback(){r(()=>this.isConnected&&!this.menu&&this.build())}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}attributeChangedCallback(){this.menu&&this.decorate()}get open(){return!!this.menu&&!this.menu.hidden}build(){let[n,...r]=[...this.children];if(!n)return;this.classList.add(`k-menu-anchor`),this.trigger=n,n.id||=`${this.key}-trigger`,n.setAttribute(`aria-haspopup`,`menu`),n.setAttribute(`aria-expanded`,`false`);let i=document.createElement(`ul`);i.id=`${this.key}-menu`,i.setAttribute(`role`,`menu`),i.hidden=!0;for(let e of r){let n=document.createElement(`li`);if(e.tagName===`HR`)n.setAttribute(`role`,`separator`),n.className=`k-menu__separator`,e.remove();else if(e.hasAttribute(`data-label`))n.setAttribute(`role`,`presentation`),n.className=`k-menu__label`,n.textContent=e.textContent,e.remove();else{n.setAttribute(`role`,`none`);let r=e.hasAttribute(`data-checked`);e.setAttribute(`role`,r?`menuitemcheckbox`:`menuitem`),e.tabIndex=-1,e.classList.add(`k-menu__item`),e.dataset.tone===`danger`&&e.classList.add(`k-menu__item--danger`),e instanceof HTMLButtonElement&&(e.type=`button`,e.disabled&&(e.disabled=!1,e.setAttribute(`aria-disabled`,`true`)));let i=e.innerHTML;e.innerHTML=`${r?`<span class="k-menu__check" aria-hidden="true"></span>`:``}<span>${i}</span>${e.dataset.shortcut?`<span class="k-menu__shortcut" aria-hidden="true">${t(e.dataset.shortcut)}</span>`:``}`,r&&this.paintCheck(e),n.append(e)}i.append(n)}this.append(i),this.menu=i,this.decorate(),n.addEventListener(`click`,()=>this.open?this.close(!1):this.show(`first`)),n.addEventListener(`keydown`,e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),this.show(e.key===`ArrowUp`?`last`:`first`))}),i.addEventListener(`keydown`,e=>this.onKey(e)),i.addEventListener(`click`,t=>{let n=t.target.closest(`[role^="menuitem"]`);n&&n.getAttribute(`aria-disabled`)!==`true`&&(n.getAttribute(`role`)===`menuitemcheckbox`&&(n.dataset.checked=String(n.dataset.checked!==`true`),this.paintCheck(n)),e(this,`kashi-select`,{value:n.dataset.value??n.textContent?.trim()??``,checked:n.dataset.checked===void 0?void 0:n.dataset.checked===`true`}),n.getAttribute(`role`)===`menuitem`&&this.close(n.tagName!==`A`))})}paintCheck(e){let t=e.dataset.checked===`true`;e.setAttribute(`aria-checked`,String(t)),e.querySelector(`.k-menu__check`).innerHTML=t?`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m5 10.5 3.2 3L15 7"/></svg>`:``}decorate(){let e=this.getAttribute(`label`);this.menu.className=`k-menu${this.getAttribute(`align`)===`end`?` k-menu--end`:``}`,e?(this.menu.setAttribute(`aria-label`,e),this.menu.removeAttribute(`aria-labelledby`)):(this.menu.setAttribute(`aria-labelledby`,this.trigger.id),this.menu.removeAttribute(`aria-label`))}show(e=`first`){if(!this.menu)return;this.menu.hidden=!1,this.trigger.setAttribute(`aria-expanded`,`true`),this.trigger.setAttribute(`aria-controls`,this.menu.id);let t=o(this.menu);(e===`last`?t.at(-1):t[0])?.focus(),document.addEventListener(`pointerdown`,this.onOutside)}close(e=!0){this.menu&&!this.menu.hidden&&(this.menu.hidden=!0,this.trigger.setAttribute(`aria-expanded`,`false`),this.trigger.removeAttribute(`aria-controls`),document.removeEventListener(`pointerdown`,this.onOutside),e&&this.trigger.focus())}onKey(e){let t=o(this.menu),n=t.indexOf(document.activeElement),r=e=>t[(e+t.length)%t.length]?.focus();if(e.key===`ArrowDown`)r(n+1);else if(e.key===`ArrowUp`)r(n-1);else if(e.key===`Home`)r(0);else if(e.key===`End`)r(t.length-1);else if(e.key===`Escape`)this.close();else if(e.key===`Tab`)return this.close(!1);else if(e.key.length===1&&/\S/.test(e.key)){let r=e.key.toLowerCase();[...t.slice(n+1),...t.slice(0,n+1)].find(e=>e.textContent?.trim().toLowerCase().startsWith(r))?.focus()}else return;e.preventDefault()}};s.observedAttributes=[`label`,`align`];var c=class extends i{constructor(){super(...arguments),this.panel=null,this.trigger=null,this.key=a(`kashi-pop`),this.onOutside=e=>{this.contains(e.target)||this.close(!1)}}connectedCallback(){r(()=>this.isConnected&&!this.panel&&this.build())}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}attributeChangedCallback(){this.panel&&this.decorate()}get open(){return!!this.panel&&!this.panel.hidden}set open(e){e?this.show():this.close(!1)}build(){let[e,...t]=[...this.childNodes].filter(e=>e.nodeType===1||e.textContent?.trim());if(!e)return;this.classList.add(`k-popover-anchor`),this.trigger=e,e.setAttribute(`aria-haspopup`,`dialog`),e.setAttribute(`aria-expanded`,`false`);let n=document.createElement(`div`);n.id=`${this.key}-panel`,n.setAttribute(`role`,`dialog`),n.tabIndex=-1,n.hidden=!0,n.innerHTML=`<p class="k-popover__title" id="${this.key}-title"></p><div class="k-popover__body"></div>`,n.querySelector(`.k-popover__body`).append(...t),this.append(n),this.panel=n,this.decorate(),e.addEventListener(`click`,()=>this.open?this.close(!1):this.show()),n.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.stopPropagation(),this.close(!0))}),n.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t&&!this.contains(t)&&this.close(!1)})}decorate(){let e=this.panel,[t,n]=(this.getAttribute(`placement`)??`bottom-start`).split(`-`);e.className=[`k-popover`,t===`top`&&`k-popover--top`,n===`end`&&`k-popover--end`].filter(Boolean).join(` `);let r=this.getAttribute(`heading`),i=e.querySelector(`.k-popover__title`);i.textContent=r??``,i.hidden=!r,r?(e.setAttribute(`aria-labelledby`,i.id),e.removeAttribute(`aria-label`)):(e.removeAttribute(`aria-labelledby`),e.setAttribute(`aria-label`,this.getAttribute(`label`)??``))}show(){this.panel&&!this.open&&(this.panel.hidden=!1,this.trigger.setAttribute(`aria-expanded`,`true`),this.trigger.setAttribute(`aria-controls`,this.panel.id),(this.panel.querySelector(`.k-popover__body :is(a[href], button:not([disabled]), input:not([disabled]), select, textarea, [tabindex]:not([tabindex="-1"]))`)??this.panel).focus(),document.addEventListener(`pointerdown`,this.onOutside),e(this,`kashi-open`,{}))}close(t=!0){this.panel&&!this.panel.hidden&&(this.panel.hidden=!0,this.trigger.setAttribute(`aria-expanded`,`false`),this.trigger.removeAttribute(`aria-controls`),document.removeEventListener(`pointerdown`,this.onOutside),t&&this.trigger.focus(),e(this,`kashi-close`,{}))}};c.observedAttributes=[`heading`,`placement`,`label`],n(`kashi-dropdown-menu`,s),n(`kashi-popover`,c);export{s as KashiDropdownMenu,c as KashiPopover};
1
+ import{c as e,l as t,o as n,r,t as i,y as a}from"./base-BUQYhiEA.js";const o=e=>[...e.querySelectorAll(`[role^="menuitem"]:not([aria-disabled="true"])`)];var s=class extends i{constructor(){super(...arguments),this.menu=null,this.trigger=null,this.key=a(`kashi-menu`),this.onOutside=e=>{this.contains(e.target)||this.close(!1)}}connectedCallback(){r(()=>this.isConnected&&!this.menu&&this.build())}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}attributeChangedCallback(){this.menu&&this.decorate()}get open(){return!!this.menu&&!this.menu.hidden}build(){let[n,...r]=[...this.children];if(!n)return;this.classList.add(`k-menu-anchor`),this.trigger=n,n.id||=`${this.key}-trigger`,n.setAttribute(`aria-haspopup`,`menu`),n.setAttribute(`aria-expanded`,`false`);let i=document.createElement(`ul`);i.id=`${this.key}-menu`,i.setAttribute(`role`,`menu`),i.hidden=!0;for(let e of r){let n=document.createElement(`li`);if(e.tagName===`HR`)n.setAttribute(`role`,`separator`),n.className=`k-menu__separator`,e.remove();else if(e.hasAttribute(`data-label`))n.setAttribute(`role`,`presentation`),n.className=`k-menu__label`,n.textContent=e.textContent,e.remove();else{n.setAttribute(`role`,`none`);let r=e.hasAttribute(`data-checked`);e.setAttribute(`role`,r?`menuitemcheckbox`:`menuitem`),e.tabIndex=-1,e.classList.add(`k-menu__item`),e.dataset.tone===`danger`&&e.classList.add(`k-menu__item--danger`),e instanceof HTMLButtonElement&&(e.type=`button`,e.disabled&&(e.disabled=!1,e.setAttribute(`aria-disabled`,`true`)));let i=e.innerHTML;e.innerHTML=`${r?`<span class="k-menu__check" aria-hidden="true"></span>`:``}<span>${i}</span>${e.dataset.shortcut?`<span class="k-menu__shortcut" aria-hidden="true">${t(e.dataset.shortcut)}</span>`:``}`,r&&this.paintCheck(e),n.append(e)}i.append(n)}this.append(i),this.menu=i,this.decorate(),n.addEventListener(`click`,()=>this.open?this.close(!1):this.show(`first`)),n.addEventListener(`keydown`,e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),this.show(e.key===`ArrowUp`?`last`:`first`))}),i.addEventListener(`keydown`,e=>this.onKey(e)),i.addEventListener(`click`,t=>{let n=t.target.closest(`[role^="menuitem"]`);n&&n.getAttribute(`aria-disabled`)!==`true`&&(n.getAttribute(`role`)===`menuitemcheckbox`&&(n.dataset.checked=String(n.dataset.checked!==`true`),this.paintCheck(n)),e(this,`kashi-select`,{value:n.dataset.value??n.textContent?.trim()??``,checked:n.dataset.checked===void 0?void 0:n.dataset.checked===`true`}),n.getAttribute(`role`)===`menuitem`&&this.close(n.tagName!==`A`))})}paintCheck(e){let t=e.dataset.checked===`true`;e.setAttribute(`aria-checked`,String(t)),e.querySelector(`.k-menu__check`).innerHTML=t?`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m5 10.5 3.2 3L15 7"/></svg>`:``}decorate(){let e=this.getAttribute(`label`);this.menu.className=`k-menu${this.getAttribute(`align`)===`end`?` k-menu--end`:``}`,e?(this.menu.setAttribute(`aria-label`,e),this.menu.removeAttribute(`aria-labelledby`)):(this.menu.setAttribute(`aria-labelledby`,this.trigger.id),this.menu.removeAttribute(`aria-label`))}show(e=`first`){if(!this.menu)return;this.menu.hidden=!1,this.trigger.setAttribute(`aria-expanded`,`true`),this.trigger.setAttribute(`aria-controls`,this.menu.id);let t=o(this.menu);(e===`last`?t.at(-1):t[0])?.focus(),document.addEventListener(`pointerdown`,this.onOutside)}close(e=!0){this.menu&&!this.menu.hidden&&(this.menu.hidden=!0,this.trigger.setAttribute(`aria-expanded`,`false`),this.trigger.removeAttribute(`aria-controls`),document.removeEventListener(`pointerdown`,this.onOutside),e&&this.trigger.focus())}onKey(e){let t=o(this.menu),n=t.indexOf(document.activeElement),r=e=>t[(e+t.length)%t.length]?.focus();if(e.key===`ArrowDown`)r(n+1);else if(e.key===`ArrowUp`)r(n-1);else if(e.key===`Home`)r(0);else if(e.key===`End`)r(t.length-1);else if(e.key===`Escape`)this.close();else if(e.key===`Tab`)return this.close(!1);else if(e.key.length===1&&/\S/.test(e.key)){let r=e.key.toLowerCase();[...t.slice(n+1),...t.slice(0,n+1)].find(e=>e.textContent?.trim().toLowerCase().startsWith(r))?.focus()}else return;e.preventDefault()}};s.observedAttributes=[`label`,`align`];var c=class extends i{constructor(){super(...arguments),this.panel=null,this.trigger=null,this.key=a(`kashi-pop`),this.onOutside=e=>{this.contains(e.target)||this.close(!1)}}connectedCallback(){r(()=>this.isConnected&&!this.panel&&this.build())}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}attributeChangedCallback(){this.panel&&this.decorate()}get open(){return!!this.panel&&!this.panel.hidden}set open(e){e?this.show():this.close(!1)}build(){let[e,...t]=[...this.childNodes].filter(e=>e.nodeType===1||e.textContent?.trim());if(!e)return;this.classList.add(`k-popover-anchor`),this.trigger=e,e.setAttribute(`aria-haspopup`,`dialog`),e.setAttribute(`aria-expanded`,`false`);let n=document.createElement(`div`);n.id=`${this.key}-panel`,n.setAttribute(`role`,`dialog`),n.tabIndex=-1,n.hidden=!0,n.innerHTML=`<p class="k-popover__title" id="${this.key}-title"></p><div class="k-popover__body"></div>`,n.querySelector(`.k-popover__body`).append(...t),this.append(n),this.panel=n,this.decorate(),e.addEventListener(`click`,()=>this.open?this.close(!1):this.show()),n.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.stopPropagation(),this.close(!0))}),n.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t&&!this.contains(t)&&this.close(!1)})}decorate(){let e=this.panel,[t,n]=(this.getAttribute(`placement`)??`bottom-start`).split(`-`);e.className=[`k-popover`,t===`top`&&`k-popover--top`,n===`end`&&`k-popover--end`].filter(Boolean).join(` `);let r=this.getAttribute(`heading`),i=e.querySelector(`.k-popover__title`);i.textContent=r??``,i.hidden=!r,r?(e.setAttribute(`aria-labelledby`,i.id),e.removeAttribute(`aria-label`)):(e.removeAttribute(`aria-labelledby`),e.setAttribute(`aria-label`,this.getAttribute(`label`)??``))}show(){this.panel&&!this.open&&(this.panel.hidden=!1,this.trigger.setAttribute(`aria-expanded`,`true`),this.trigger.setAttribute(`aria-controls`,this.panel.id),(this.panel.querySelector(`.k-popover__body :is(a[href], button:not([disabled]), input:not([disabled]), select, textarea, [tabindex]:not([tabindex="-1"]))`)??this.panel).focus(),document.addEventListener(`pointerdown`,this.onOutside),e(this,`kashi-open`,{}))}close(t=!0){this.panel&&!this.panel.hidden&&(this.panel.hidden=!0,this.trigger.setAttribute(`aria-expanded`,`false`),this.trigger.removeAttribute(`aria-controls`),document.removeEventListener(`pointerdown`,this.onOutside),t&&this.trigger.focus(),e(this,`kashi-close`,{}))}};c.observedAttributes=[`heading`,`placement`,`label`],n(`kashi-dropdown-menu`,s),n(`kashi-popover`,c);export{s as KashiDropdownMenu,c as KashiPopover};