@spscommerce/ds-react 8.19.4 → 8.19.6

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.
package/lib/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var rv=Object.defineProperty;var Cc=e=>{throw TypeError(e)};var sv=(e,t,n)=>t in e?rv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Vt=(e,t,n)=>sv(e,typeof t!="symbol"?t+"":t,n),Dc=(e,t,n)=>t.has(e)||Cc("Cannot "+n);var An=(e,t,n)=>(Dc(e,t,"read from private field"),n?n.call(e):t.get(e)),ks=(e,t,n)=>t.has(e)?Cc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ln=(e,t,n,r)=>(Dc(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("react"),v=require("@spscommerce/utils"),it=require("moment-timezone"),H=require("@spscommerce/ds-shared"),no=require("react-dom"),xa=require("@spscommerce/ds-colors"),ov=require("@sps-woodland/tabs"),mr=require("@react-stately/collections"),up=require("@sps-woodland/illustrations");function mp(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const s=mp(_),br=mp(it);function fp(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=fp(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function W(){for(var e,t,n=0,r="";n<arguments.length;)(e=arguments[n++])&&(t=fp(e))&&(r&&(r+=" "),r+=t);return r}let gt=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");function Dn(e){return _.useRef(e||gt())}function Tt(e,t){const n=Dn(e),r=_.useRef(`${n.current}_ctrl`);return _.useEffect(()=>{t&&(t.id=r.current,t.update())},[t]),{wrapperId:n.current||void 0,controlId:r.current}}var qt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ei(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var av="[object Object]";function iv(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function lv(e,t){return function(n){return e(t(n))}}var cv=Function.prototype,hp=Object.prototype,Sp=cv.toString,dv=hp.hasOwnProperty,pv=Sp.call(Object),uv=hp.toString,mv=lv(Object.getPrototypeOf,Object);function fv(e){return!!e&&typeof e=="object"}function hv(e){if(!fv(e)||uv.call(e)!=av||iv(e))return!1;var t=mv(e);if(t===null)return!0;var n=dv.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Sp.call(n)==pv}var Sv=hv;const gp=ei(Sv),Nt=new Set,Cr=new Set,pn=new Set,ro=new Set;function bp(e){Nt.has(e)||pn.has(e)||ro.has(e)||Cr.add(e)}function vp(e){Nt.has(e)||pn.has(e)||Cr.has(e)||ro.add(e)}const et=br.default||br,vr="MM/DD/YYYY",gv="MM/DD/YYYY hh:mm A",bv="MM/DD/YYYY HH:mm",vv="hh:mm A",yv="HH:mm",Tv=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,zr=Symbol("Date Parse Error");function cr(e){return et.isMoment(e)?e.year()*1e4+(e.month()+1)*100+e.date():e.year*1e4+e.month*100+e.date}const Q=Object.freeze({createFrom(e,t){if(!e)return null;if(typeof e=="string"){if(t){const n=et(e,t,!0);if(n.isValid())return Object.freeze({year:n.year(),month:n.month()+1,date:n.date()})}else{const n=Tv.exec(e);if(n){const[,r,o,a]=n;return Object.freeze({year:Number(a),month:Number(r),date:Number(o)})}}return Object.freeze({[zr]:!0,year:void 0,month:void 0,date:void 0})}return Object.freeze({year:e.year(),month:e.month()+1,date:e.date()})},createMomentFrom(e,t){if(!e)return null;let n=null;return typeof e=="string"?t?n=et(e,t,!0):n=et(e):et.isMoment(e)?n=e:n=Q.toMoment(e),n!==null&&et.isMoment(n)&&n.isValid()?n:Object.freeze({[zr]:!0,year:void 0,month:void 0,date:void 0})},getRangeSeparator(e){return e!=null&&e.includes("-")?"/":"-"},createRangeFrom(e,t){if(!e)return null;if(t){const n=Q.getRangeSeparator(t),r=new RegExp(`[^\\d]*${n}[^\\d]*`);return e.split(r).slice(0,2).map(o=>Q.createFrom(o,t))}else return e.split(/[^\d]*-[^\d]*/).slice(0,2).map(n=>Q.createFrom(n))},isValid(e){var t;return e?et.isMoment(e)?e.isValid():typeof e=="object"&&typeof e.year=="number"&&typeof e.month=="number"&&typeof e.date=="number"&&((t=Q.toMoment(e))==null?void 0:t.isValid()):!1},nullifyInvalidDate(e){return Q.isValid(e)?e:null},toMoment(e){return e?et.isMoment(e)?e:et({...e,month:e.month-1}):null},toString(e,t){const n=Q.toMoment(e);return n&&n.isValid()?n.format(t||vr):""},toStringRange(e,t){if(!e)return"";const n=Q.getRangeSeparator(t);return e.slice(0,2).map(r=>Q.toString(r,t)).join(n)},toDateTimeString(e,t=!1,n){return e&&et.isMoment(e)&&e.isValid()?n?t?e.format(`${n} ${yv}`):e.format(`${n} ${vv}`):t?e.format(bv):e.format(gv):""},toDateTimeStringRange(e,t=!1,n){if(!e)return"";const r=Q.getRangeSeparator(n);return e.map(o=>Q.toDateTimeString(o,t,n)).join(r)},create(){const e=new Date;return Object.freeze({year:e.getFullYear(),month:e.getMonth()+1,date:e.getDate()})},isSameDate(e,t){return e&&t&&e.year===t.year&&e.month===t.month&&e.date===t.date},isSameMonth(e,t){return e&&t&&e.year===t.year&&e.month===t.month},isAfter(e,t){return!e||!t?null:cr(e)>cr(t)},isBefore(e,t){return!e||!t?null:cr(e)<cr(t)},isInRange(e,t,n=!0){if(!e||!t||!t[0]||!t[1])return null;const r=cr(e),[o,a]=t.map(cr);return e&&o&&a&&(n&&r>=o&&r<=a||!n&&r>o&&r<a)},prevMonth(e){return Object.freeze({year:e.month===1?e.year-1:e.year,month:e.month-1||12,date:e.date})},nextMonth(e){return Object.freeze({year:e.month===12?e.year+1:e.year,month:e.month+1>12?1:e.month+1,date:e.date})},createRangeFromPreset(e,t){if(typeof e.definition=="function")return e.definition();const n=et(),r=n.clone().subtract(et.duration(e.definition));return[Q.createFrom(r,t),Q.createFrom(n,t)]},createDateTimeRangeFromPreset(e){if(typeof e.definition=="function")return e.definition();let t;e.definition==="P0D"?t=et().startOf("day"):t=et().subtract(et.duration(e.definition));const n=et().endOf("day");return[t,n]},splitMomentInDateTimeParts(e,t=!1,n){return e&&et.isMoment(e)&&e.isValid()?Q.toDateTimeString(e,t,n).split(" "):["",t?"00:00":"12:00",t?void 0:"AM"]},getCurrentMoment(){return et()},validateTimeString(e,t=!1){if(!e)return!0;const n=e.split(":"),r=n[0]||"0",o=n[1]||"0",a=Number.isNaN(Number(r))?NaN:parseInt(r,10),l=Number.isNaN(Number(o))?NaN:parseInt(o,10),c=n.length<=2&&r.length<=2&&o.length<=2;return t?c&&a>=0&&a<=23&&l>=0&&l<=59:c&&(!Number.isNaN(a)&&r.length===1||a>=1)&&a<=12&&l>=0&&l<=59},padIncompleteTimeString(e,t=!1){if(!e)return"";const n=e.split(":"),r=parseInt(n[0]||"0",10),o=parseInt(n[1]||"0",10);if(t){const a=r<10?`0${r}`:`${r}`,l=o<10?`0${o}`:`${o}`;return`${a}:${l}`}else{const a=r===0?"12":r<10?`0${r}`:`${r}`,l=o<10?`0${o}`:`${o}`;return`${a}:${l}`}}}),ka=["01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00","12:00"],Ia=["00:00","01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00","22:00","23:00"];let Gs=vr;function yp(e){Gs=e}const jr=function(t){if(Array.isArray(t)){const n=jr(t[0]),r=jr(t[1]);return n||r}if(t&&t.hasOwnProperty("year")){if(t[zr])return{dateFormat:Gs};if(!Q.isValid(t))return{dateValidity:!0}}return null};Nt.add("dateFormat");Nt.add("dateValidity");const Tp=function(t){if(Array.isArray(t)){const n=jr(t);if(n)return n;if(t&&Q.isBefore(t[1],t[0]))return{dateRangeOrder:!0}}return null};Nt.add("dateRangeOrder");const Ep=function({minDate:t,maxDate:n}){function r(o){const a=Q.isBefore(o,t),l=Q.isAfter(o,n),c={minExceeded:a?Q.toString(t,Gs):null,maxExceeded:l?Q.toString(n,Gs):null};return a||l?{dateConstraint:c}:null}return function(a){if(!a)return null;if(Array.isArray(a)){const l=r(a[0]),c=r(a[1]);return l||c}return a.hasOwnProperty("year")?r(a):null}};Nt.add("dateConstraint");const Ev=Object.freeze(Object.defineProperty({__proto__:null,date:jr,dateConstraint:Ep,dateRange:Tp,setDateFormat:yp},Symbol.toStringTag,{value:"Module"}));function Nn(e,t){for(const n of[].concat(e)){const r=t(n);if(r)return r}return null}const wv=function(t){function n(r){return Number(r)>=t?null:{min:t}}return r=>Nn(r,n)};Nt.add("min");const Cv=function(t){function n(r){return Number(r)<=t?null:{max:t}}return r=>Nn(r,n)};Cr.add("max");const Dv=function(t){return typeof t>"u"||t===null||t===""||Number.isNaN(t)||(t==null?void 0:t.length)===0?{required:!0}:null};Cr.add("required");const Nv=function(t){function n(r){return r===void 0||r.toString().length<t?{minLength:t}:null}return r=>Nn(r,n)};Nt.add("minLength");const xv=function(t){function n(r){return r==null||Array.isArray(r)&&r.length<t?{minLengthArray:t}:null}return r=>n(r)};Nt.add("minLengthArray");const kv=function(t){function n(r){return r===void 0||r.toString().length<=t?null:{maxLength:t}}return r=>Nn(r,n)};pn.add("maxLength");const Iv=function(t){function n(r){return r==null||Array.isArray(r)&&r.length<=t?null:{maxLengthArray:t}}return r=>n(r)};Nt.add("maxLengthArray");const Mv=function(t){const n=t instanceof RegExp?t:new RegExp(t);function r(o){return n.test(o)?null:{pattern:t}}return o=>Nn(o,r)};Nt.add("pattern");const _v=function(e){function t(n){return new RegExp("^\\p{L}*$","u").test(n)?null:{alpha:!0}}return Nn(e,t)};pn.add("alpha");const Rv=function(e){function t(n){return/^[0-9,. ]*$/.test(n)?null:{numeric:!0}}return Nn(e,t)};pn.add("numeric");const Ov=function(e){function t(n){return/^[^0-9]*$/.test(n)?null:{nonNumeric:!0}}return Nn(e,t)};pn.add("nonNumeric");const so=Object.freeze({...Ev,min:wv,max:Cv,required:Dv,minLength:Nv,minLengthArray:xv,maxLength:kv,maxLengthArray:Iv,pattern:Mv,alpha:_v,numeric:Rv,nonNumeric:Ov,OnBlurErrorKeys:Nt});function oo(e,t=[]){const n=t.reduce((r,o)=>Object.assign(r,o(e)||{}),{});return Object.keys(n).length?n:null}var zt=(e=>(e[e.ON_CHANGE=0]="ON_CHANGE",e[e.ON_BLUR=1]="ON_BLUR",e[e.ON_SUBMIT=2]="ON_SUBMIT",e))(zt||{});function Lv(e,t={},n=[]){for(const[r,o]of Object.entries(t))o===0?bp(r):o===2&&vp(r);return s.useCallback(e,n)}var Yn,vn,yn;class Hn{constructor(t,n){Vt(this,"validators",[]);ks(this,Yn,null);ks(this,vn,null);ks(this,yn,null);Vt(this,"preventativeErrors",[]);Vt(this,"submitted",!1);this.path=t,this.update=n}get errors(){return An(this,Yn)===null&&An(this,vn)===null&&An(this,yn)===null?null:{...An(this,Yn)??{},...An(this,vn)??{},...An(this,yn)??{}}}setValidators(t){return this.update(this.path,null,void 0,t),this}validate(t,n,r=!1){if(this.validators&&this.validators.length>0){const o=oo(t,this.validators);let a={onSubmit:{},onChange:{},onBlur:{}};o&&(a=Object.keys(o).reduce((l,c)=>(ro.has(c)?l.onSubmit[c]=o[c]:Cr.has(c)?l.onChange[c]=o[c]:l.onBlur[c]=o[c],l),a)),(typeof n>"u"||n===zt.ON_CHANGE)&&ln(this,vn,Object.keys(a.onChange).length===0?null:a.onChange),(typeof n>"u"||n===zt.ON_BLUR)&&ln(this,yn,Object.keys(a.onBlur).length===0?null:a.onBlur),(typeof n>"u"||n===zt.ON_SUBMIT)&&(ln(this,Yn,Object.keys(a.onSubmit).length===0?null:a.onSubmit),ln(this,vn,Object.keys(a.onChange).length===0?null:a.onChange),ln(this,yn,Object.keys(a.onBlur).length===0?null:a.onBlur)),r||this.update(),this.isFocused()&&this.onFocus&&this.onFocus()}else this.errors&&(ln(this,Yn,null),ln(this,yn,null),ln(this,vn,null),r||this.update());return this}isValid(){return!this.errors||this.isPristine()}hasErrors(){return!!this.errors}isVisibilyInvalid(){return!this.isValid()}hasError(t){return this.errors&&Object.prototype.hasOwnProperty.call(this.errors,t)}hasPreventativeError(t){return this.preventativeErrors.includes(t)}hasPreventativeErrors(){return this.preventativeErrors.length>0}isRequired(){return this.validators&&this.validators.indexOf(so.required)>-1}isSubmitted(){return this.submitted}onFocus(){}onBlur(){}}Yn=new WeakMap,vn=new WeakMap,yn=new WeakMap;class qr extends Hn{constructor(){super(...arguments);Vt(this,"id",gt());Vt(this,"focused",!1);Vt(this,"pristine",!0)}setValue(n){if(this.preventativeErrors=[],this.validators&&this.validators.length>0){const r=oo(n,this.validators);if(r&&Object.keys(r).filter(a=>pn.has(a)).length>0){this.preventativeErrors=Object.keys(r);return}}this.update(this.path,n)}isPristine(){return this.pristine}markAsPristine(){return this.pristine=!0,this.update(),this}markAsDirty(){return this.pristine=!1,this.update(),this}isFocused(){return this.focused}markAsFocused(){return this.focused=!0,this.update(),this.onFocus&&this.onFocus(),this}markAsBlurred(){return this.update(this.path,null,!0),this.onBlur&&this.onBlur(),this.preventativeErrors=[],this}markAsSubmitted(){return this.submitted=!0,this.update(this.path,null,!1,void 0,!0),this}}class Wn extends qr{constructor(n,r,o){super(o?r:n,o||r);Vt(this,"fields");o&&this.inferMembers(n)}isFocused(){return super.isFocused()||this.rollup("isFocused")}isValid(){return super.isValid()&&this.rollup("isValid")}hasErrors(){return super.hasErrors()||Object.keys(this.fields).some(n=>this.fields[n].hasErrors())}contentsAreValid(){return this.rollup("isValid")&&this.rollup("contentsAreValid")}isPristine(){return super.isPristine()&&this.rollup("isPristine")}markAsPristine(){super.markAsPristine();for(const n of Object.keys(this.fields))this.fields[n].markAsPristine();return this}markAsDirty(){super.markAsDirty();for(const n of Object.keys(this.fields))this.fields[n].markAsDirty();return this}markAsBlurred(){super.markAsBlurred();for(const n of Object.keys(this.fields))this.fields[n].markAsBlurred();return this}markAsSubmitted(){super.markAsSubmitted();for(const n of Object.keys(this.fields))this.fields[n].markAsSubmitted();return this}inferSpsControl(n,r){return $s(n,[...this.path,r],this.update)}rollup(n){return Object.keys(this.fields).reduce((r,o)=>r&&(!this.fields[o][n]||this.fields[o][n]()),!0)}}class wp extends Wn{inferMembers(t){this.fields={};for(const n of Object.keys(t))this.fields[n]=this.inferSpsControl(t[n],n)}}class Cp extends Wn{inferMembers(t){this.fields=t.map((n,r)=>this.inferSpsControl(n,String(r)))}}function $s(e,t,n){return e instanceof Hn?(e.path=t,e.update=n,e):Array.isArray(e)?new Cp(e,t,n):gp(e)?new wp(e,t,n):new qr(t,n)}function Hr(e,t){return t.length===0||!e?e:Hr(e.fields[t[0]],t.slice(1,t.length))}function Ma(e,t){if(t.length===0||!e)return[e];const n=t[0];if(t=t.slice(1,t.length),n==="*"){const r=Array.isArray(e.fields)?e.fields:Object.keys(e.fields).map(o=>e.fields[o]);return t.length===0?r:r.reduce((o,a)=>[...o,...Ma(a,t)],[])}return Ma(e.fields[n],t)}function _a(e,t,n){for(const r of Object.keys(t)){const o=t[r];for(const a of Ma(e,r.split(".")))a&&o&&n(a,o)}}function Is(e,t,n,r=!1,o=!1){_a(t,n,(a,l)=>{a.validators=typeof l=="function"?l(e):l,r&&a.validate(v.getPath(e,a.path),void 0,o)})}function Ra(e,t){const n=t[0];return t=t.slice(1),Array.isArray(e)?e.map((r,o)=>o===Number(n)?Ra(r,t):r):gp(e)?Object.keys(e).reduce((r,o)=>Object.assign(r,{[o]:o===n?Ra(e[o],t):e[o]}),{}):e}function Pv(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("The initial value of useSpsForm() hook must be an object.")}function Dp(e,t={}){Pv(e);const[,n]=_.useState({}),r=_.useRef(!1);r.current=!1;const o=_.useRef(t),a=_.useCallback(h=>{var E,T;const S=u.current;let y;if(h)if(h.path)if(h.markAsBlurred){const w=Hr(S.formMeta,h.path);if(w){w.focused=!1;const N=v.getPath(S.formValue,h.path);w.validate(N,zt.ON_BLUR)}}else if(h.newValidators){if(o.current){const w=h.path.join(".");o.current={...o.current,[w]:h.newValidators},Is(S.formValue,S.formMeta,o.current,!0)}}else if(h.markAsSubmitted){const w=Hr(S.formMeta,h.path);if(w){w.submitted=!0;const N=v.getPath(S.formValue,h.path);w.validate(N,zt.ON_SUBMIT)}}else y=Ra(S.formValue,h.path),v.setPath(y,h.path,h.value);else y=h.value;if((E=h==null?void 0:h.updateFormOptions)!=null&&E.validators&&(o.current={...o.current,...h.updateFormOptions.validators},Is(S.formValue,S.formMeta,o.current,((T=h.updateFormOptions)==null?void 0:T.runValidators)??!0)),y){S.formMeta.submitted=!1,v.deepFreeze(y);const w=v.diff(S.formValue,y);for(const{type:I,key:x,parentPath:k,objects:[,F]}of w){const L=Hr(S.formMeta,k);if(typeof x!="symbol"&&L){let C;switch(I){case v.DiffChange.ADDITION:L.fields[x]=$s(F[x],[...k,x],c);break;case v.DiffChange.DELETION:Array.isArray(L.fields)?L.fields[x]=void 0:delete L.fields[x];break;case v.DiffChange.ALTERATION:C=$s(F[x],[...k,x],c),(C instanceof Wn&&!(L.fields[x]instanceof Wn)||!(C instanceof Wn)&&L.fields[x]instanceof Wn)&&(L.fields[x]=C);break}}}const N=new Set;if(w.filter(I=>I.type===v.DiffChange.DELETION).reduce((I,x)=>(I.has(x.parentPath)||I.add(x.parentPath),I),N),Array.from(N).forEach(I=>{const x=Hr(S.formMeta,I);Array.isArray(x.fields)&&(x.fields=x.fields.filter(k=>k!==void 0))}),o.current){Is(y,S.formMeta,o.current);const I=new Set;t&&_a(S.formMeta,t,(x,k)=>{typeof k=="function"&&(x.validate(v.getPath(y,x.path)),I.add(x))});for(const{type:x,key:k,parentPath:F,objects:[,L]}of w)if(typeof k!="symbol"){let C=S.formMeta,O=y;if(C){for(const R of F)C=C.fields[R],O=O[R],I.has(C)||C.validate(O,zt.ON_CHANGE);if(x===v.DiffChange.ADDITION||x===v.DiffChange.ALTERATION){const R=C.fields[k];if(!I.has(R)&&(C.fields[k].validate(L[k],zt.ON_CHANGE),x===v.DiffChange.ADDITION&&R.fields))for(const[$,j]of Object.entries(R.fields))j.validate(L[k][$],zt.ON_CHANGE)}}}}}u.current={...S,formValue:y||S.formValue},r.current||n({})},[]),l=_.useCallback((h,S)=>{h||S?a({value:h,updateFormOptions:S}):a()},[a]),c=_.useCallback((h,S,y=!1,E,T=!1)=>{h?a({path:h,value:S,markAsBlurred:y,newValidators:E,markAsSubmitted:T}):l()},[a,l]),p=_.useMemo(()=>{v.deepFreeze(e);const h=$s(e,[],c);return t&&Is(e,h,t,!1,!0),h},[]),m=_.useCallback(()=>(u.current.formMeta.markAsDirty(),o.current&&_a(u.current.formMeta,o.current,(h,S)=>{(typeof S=="function"||Array.isArray(S))&&h.validate(v.getPath(u.current.formValue,h.path))}),u.current.formMeta.isValid()),[]),f=_.useCallback(()=>u.current.formValue,[]),u=_.useRef({formValue:e,formMeta:p,updateForm:l,validateForm:m,getCurrentFormValue:f});return u.current}const lt=s.forwardRef((e,t)=>{const{className:n,children:r,focusInputOnClick:o,formControl:a,formMeta:l,inputRef:c,onClick:p,...m}=e,f=s.useRef(),h=c||(t||f);function S(){h&&h!==t&&h.current&&h.current.focus()}function y(){h&&h!==t&&h.current&&l&&l instanceof qr&&l.markAsFocused()}function E(){h&&h!==t&&h.current&&l&&l instanceof qr&&l.markAsBlurred()}const T=W("sps-form-group",(a&&a.isRequired()||l&&l.isRequired())&&"sps-form-group--required",(a&&!a.isValid()||l&&l.isVisibilyInvalid())&&"sps-form-group--error",l&&l.hasPreventativeErrors()&&"sps-form-group--preventative-error",n);function w(N){o&&S(),p&&p(N)}return s.useEffect(()=>{function N(I){I.target.classList.contains("sps-form-control__clear-btn")&&I.preventDefault()}return document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[]),s.createElement("div",{...m,className:T,ref:t,tabIndex:-1,onClick:w,onFocus:y,onBlur:E},r)});Object.assign(lt,{displayName:"SpsFormComponentWrapper"});function Nc(e){return typeof e=="object"&&e!=null&&e.nodeType===1}function xc(e,t){return(!t||e!=="hidden")&&e!=="visible"&&e!=="clip"}function Zo(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var n=getComputedStyle(e,null);return xc(n.overflowY,t)||xc(n.overflowX,t)||function(r){var o=function(a){if(!a.ownerDocument||!a.ownerDocument.defaultView)return null;try{return a.ownerDocument.defaultView.frameElement}catch{return null}}(r);return!!o&&(o.clientHeight<r.scrollHeight||o.clientWidth<r.scrollWidth)}(e)}return!1}function Ms(e,t,n,r,o,a,l,c){return a<e&&l>t||a>e&&l<t?0:a<=e&&c<=n||l>=t&&c>=n?a-e-r:l>t&&c<n||a<e&&c>n?l-t+o:0}var kc=function(e,t){var n=window,r=t.scrollMode,o=t.block,a=t.inline,l=t.boundary,c=t.skipOverflowHiddenElements,p=typeof l=="function"?l:function(Be){return Be!==l};if(!Nc(e))throw new TypeError("Invalid target");for(var m,f,u=document.scrollingElement||document.documentElement,h=[],S=e;Nc(S)&&p(S);){if((S=(f=(m=S).parentElement)==null?m.getRootNode().host||null:f)===u){h.push(S);break}S!=null&&S===document.body&&Zo(S)&&!Zo(document.documentElement)||S!=null&&Zo(S,c)&&h.push(S)}for(var y=n.visualViewport?n.visualViewport.width:innerWidth,E=n.visualViewport?n.visualViewport.height:innerHeight,T=window.scrollX||pageXOffset,w=window.scrollY||pageYOffset,N=e.getBoundingClientRect(),I=N.height,x=N.width,k=N.top,F=N.right,L=N.bottom,C=N.left,O=o==="start"||o==="nearest"?k:o==="end"?L:k+I/2,R=a==="center"?C+x/2:a==="end"?F:C,$=[],j=0;j<h.length;j++){var M=h[j],Y=M.getBoundingClientRect(),G=Y.height,z=Y.width,K=Y.top,J=Y.right,re=Y.bottom,P=Y.left;if(r==="if-needed"&&k>=0&&C>=0&&L<=E&&F<=y&&k>=K&&L<=re&&C>=P&&F<=J)return $;var U=getComputedStyle(M),te=parseInt(U.borderLeftWidth,10),ee=parseInt(U.borderTopWidth,10),le=parseInt(U.borderRightWidth,10),B=parseInt(U.borderBottomWidth,10),Z=0,X=0,ne="offsetWidth"in M?M.offsetWidth-M.clientWidth-te-le:0,ae="offsetHeight"in M?M.offsetHeight-M.clientHeight-ee-B:0,ce="offsetWidth"in M?M.offsetWidth===0?0:z/M.offsetWidth:0,oe="offsetHeight"in M?M.offsetHeight===0?0:G/M.offsetHeight:0;if(u===M)Z=o==="start"?O:o==="end"?O-E:o==="nearest"?Ms(w,w+E,E,ee,B,w+O,w+O+I,I):O-E/2,X=a==="start"?R:a==="center"?R-y/2:a==="end"?R-y:Ms(T,T+y,y,te,le,T+R,T+R+x,x),Z=Math.max(0,Z+w),X=Math.max(0,X+T);else{Z=o==="start"?O-K-ee:o==="end"?O-re+B+ae:o==="nearest"?Ms(K,re,G,ee,B+ae,O,O+I,I):O-(K+G/2)+ae/2,X=a==="start"?R-P-te:a==="center"?R-(P+z/2)+ne/2:a==="end"?R-J+le+ne:Ms(P,J,z,te,le+ne,R,R+x,x);var se=M.scrollLeft,Ee=M.scrollTop;O+=Ee-(Z=Math.max(0,Math.min(Ee+Z/oe,M.scrollHeight-G/oe+ae))),R+=se-(X=Math.max(0,Math.min(se+X/ce,M.scrollWidth-z/ce+ne)))}$.push({el:M,top:Z,left:X})}return $};function Np(e){return e===Object(e)&&Object.keys(e).length!==0}function Bv(e,t){t===void 0&&(t="auto");var n="scrollBehavior"in document.body.style;e.forEach(function(r){var o=r.el,a=r.top,l=r.left;o.scroll&&n?o.scroll({top:a,left:l,behavior:t}):(o.scrollTop=a,o.scrollLeft=l)})}function Av(e){return e===!1?{block:"end",inline:"nearest"}:Np(e)?e:{block:"start",inline:"nearest"}}function ao(e,t){var n=e.isConnected||e.ownerDocument.documentElement.contains(e);if(Np(t)&&typeof t.behavior=="function")return t.behavior(n?kc(e,t):[]);if(n){var r=Av(t);return Bv(kc(e,r),r.behavior)}}const ti=Object.freeze(Object.defineProperty({__proto__:null,default:ao},Symbol.toStringTag,{value:"Module"})),Ke=s.createContext(H.noI18nI18n),Fv={alt:"string",size:"SpinnerSize",title:"string"};function ni(e){const{alt:t,className:n,size:r=H.SpinnerSize.MEDIUM,"data-testid":o,title:a,unsafelyReplaceClassName:l,...c}=e,{t:p}=s.useContext(Ke),m=t||a||p("design-system:spinner.defaultAltText"),f=W(l||"sps-spinner",`sps-spinner--${r}`,n);return s.createElement("i",{className:f,"data-testid":o,title:m,...c})}Object.assign(ni,{props:Fv,displayName:"SpsSpinner"});const Vv=60;function _s(e){return typeof e>"u"?"inherit":`${e}px`}function ri(e){switch(e){case H.Position.TOP_LEFT:return H.Position.BOTTOM_LEFT;case H.Position.TOP_MIDDLE:return H.Position.BOTTOM_MIDDLE;case H.Position.TOP_RIGHT:return H.Position.BOTTOM_RIGHT;case H.Position.RIGHT_TOP:return H.Position.LEFT_TOP;case H.Position.RIGHT_MIDDLE:return H.Position.LEFT_MIDDLE;case H.Position.RIGHT_BOTTOM:return H.Position.LEFT_BOTTOM;case H.Position.BOTTOM_RIGHT:return H.Position.TOP_RIGHT;case H.Position.BOTTOM_MIDDLE:return H.Position.TOP_MIDDLE;case H.Position.BOTTOM_LEFT:return H.Position.TOP_LEFT;case H.Position.LEFT_BOTTOM:return H.Position.RIGHT_BOTTOM;case H.Position.LEFT_MIDDLE:return H.Position.RIGHT_MIDDLE;case H.Position.LEFT_TOP:return H.Position.RIGHT_TOP}}function $v(e,t,n,r,o,a,l,c){const p=l&&l.current,m=p?p.scrollTop:window.pageYOffset,f=c?0:m,u=p?p.scrollLeft:window.pageXOffset,h=c?0:u,[S,y]=e.split(" ");let E,T,w,N;switch(S){case"top":w=t.height-n.top-f-a[0];break;case"left":T=t.width-n.left-h-a[0];break;case"right":N=n.right+h-a[0];break;case"bottom":E=n.bottom+f-a[0];break;default:throw new Error(`Invalid position ${e}`)}switch(y){case"left":N=n.left+h+a[1];break;case"top":E=n.top+f+a[1];break;case"middle":S==="top"||S==="bottom"?N=n.left+h+n.width/2-o/2+a[1]:(S==="left"||S==="right")&&(E=n.top+f+n.height/2-r.height/2+a[1]);break;case"bottom":w=t.height-n.bottom-f+a[1];break;case"right":T=t.width-n.right-h+a[1];break;default:throw new Error(`Invalid position ${e}`)}return[E,T,w,N]}function Un(e,t,n,{altPosition:r,setMinWidth:o=!1,setWidth:a=!1,parentElementRef:l,fixed:c=!1,offsets:p=[0,0]}){if(e.current&&t.current){const m=Math.max(document.documentElement.clientHeight,window.innerHeight||0),f=document.documentElement.getBoundingClientRect().width,u=l&&l.current?l.current:document.documentElement,h=c?{width:f,height:m,top:0,left:0,bottom:m,right:f}:u.getBoundingClientRect(),S=e.current.getBoundingClientRect(),y=t.current.getBoundingClientRect(),[E]=n.split(" ");let T=n;r&&(E==="top"&&y.top-S.height<Vv||E==="right"&&y.right+S.width>f||E==="bottom"&&y.bottom+S.height>m||E==="left"&&y.left-S.width<0)&&(T=r);const w=o?Math.max(y.width,S.width):S.width,N=a?y.width:w,[I,x,k,F]=$v(T,h,y,S,N,p,l,c),L={top:_s(I),right:_s(x),bottom:_s(k),left:_s(F)};return c&&(L.position="fixed",L.zIndex=H.ZStratum.BAR),o&&(L.minWidth=`${y.width}px`),a&&(L.width=`${y.width}px`),[L,T===r]}return[{},!1]}const Ot=_.createContext(null);function Dr(e,t=[]){const n=_.useContext(Ot);return _.useMemo(()=>r=>{const a=n&&n.parentElementRef&&n.parentElementRef.current||document.body;let l=null,c=a.lastElementChild;for(;c&&c!==a.firstElementChild;){if(c.hasAttribute("data-portalid")&&c.getAttribute("data-portalid")===e){l=c;break}c=c.previousElementSibling}if(l)a.contains(l)||a.appendChild(l);else{l=document.createElement("div"),l.setAttribute("data-portalid",e);for(const p of t)l.classList.add(p);a.appendChild(l)}return no.createPortal(r,l)},[n])}async function Ic(e,t,n,r,o,a){const l=typeof e.options=="function"?e.options(t.value):e.options||[],c=l instanceof Promise,p=u=>u.replace(/([.?*+^$[\]\\(){}|-])/g,"");n({pending:c}),a.current=c?l:null;const m=c?await l||[]:l||[];if(c&&a.current!==l)return;let f=Array.from(m).filter(Boolean).map(u=>new H.SpsOptionListOption(u,typeof u=="function"?{textKey:"label",captionKey:"caption"}:{textKey:e.textKey,captionKey:e.captionKey}));if(e.nullOption&&f.unshift(new H.SpsOptionListOption(null,{text:e.nullOption})),t.value&&!e.disableDefaultOptionsFiltering){const u=p(t.value);n({replacementPattern:new RegExp(`(${u})`,"ig")}),f=f.filter(h=>{const S=new RegExp(u,"i"),y=p(h.text);return e.filterByTextAndCaptionKey?S.test(y)||S.test(p(h.caption)):S.test(y)})}else n({replacementPattern:null});if(e.disabledOptions)for(const u of f)e.disabledOptions.includes(u.value)&&(u.disabled=!0);r(Object.freeze(f)),e.onOptionListChanged&&e.onOptionListChanged(f.length),o(f.some(u=>u.value&&!!u.value.icon)),n({pending:!1})}function Kv(e,t,n){const[r,o]=s.useState(Object.freeze([])),[a,l]=s.useState(!1),c=s.useRef(null),p=s.useRef(e.options);(typeof e.options!="function"||e.disableOptionsMemoization)&&(p.current=e.options);const m=s.useMemo(()=>typeof p.current=="function"?v.debounce(Ic,typeof e.searchDebounce<"u"?e.searchDebounce:500):Ic,[p.current,e.disabledOptions]);return s.useEffect(()=>{m(e,t,n,o,l,c)},[p.current,t.value,e.disabledOptions]),[r,a]}class xn{constructor(t,n){Vt(this,"nativeEvent");Vt(this,"currentTarget");Vt(this,"isPgStoppedInternal",!1);this.target=t,this.currentTarget=t,this.nativeEvent=new CustomEvent("change",n),Object.defineProperty(this.nativeEvent,"target",{value:t,writable:!1,configurable:!1,enumerable:!0})}get bubbles(){return this.nativeEvent.bubbles}get cancelable(){return this.nativeEvent.cancelable}get defaultPrevented(){return this.nativeEvent.defaultPrevented}get eventPhase(){return this.nativeEvent.eventPhase}get isTrusted(){return this.nativeEvent.isTrusted}get timeStamp(){return this.nativeEvent.timeStamp}get type(){return this.nativeEvent.type}preventDefault(){this.nativeEvent.preventDefault()}isDefaultPrevented(){return this.defaultPrevented}stopPropagation(){this.nativeEvent.stopPropagation(),this.isPgStoppedInternal=!0}isPropagationStopped(){return this.isPgStoppedInternal}persist(){throw new Error("This is not a real React ChangeEvent. React does not permit the creation of SyntheticEvents in userland.")}}function Hv(e,t){return{...e,...t}}function Jt(e){return _.useReducer(Hv,e)}function Wv({hideInlineSearch:e,options:t,onSearchChange:n,search:r="",searchPlaceholder:o="Search…",searchInputRef:a}){const[l,c]=Jt({isAsync:typeof t=="function",pending:!1,value:r,replacementPattern:null}),p=s.useCallback(S=>{c({value:S.target.value}),n&&n(S)},[n]),m=s.useCallback(S=>{S.nativeEvent.stopImmediatePropagation(),S.stopPropagation()},[]),f=s.useCallback(S=>{S.nativeEvent.stopImmediatePropagation(),c({value:""}),a!=null&&a.current&&(n&&n(new xn(a.current)),a.current.focus())},[n]),u=S=>{S&&(["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"].includes(S.key)||S.stopPropagation())};return s.useEffect(()=>{c({value:r})},[r]),[l.isAsync&&!e?s.createElement("div",{className:"sps-option-list__search sps-form-group sps-text-input"},s.createElement("div",{className:"sps-form-control"},!l.value&&s.createElement("i",{className:"sps-icon sps-icon-filter sps-text-input__icon"}),s.createElement("input",{type:"text",className:"sps-text-input__input",placeholder:o,ref:a,value:l.value,onChange:p,onClick:m,onKeyDown:u}),l.value&&s.createElement("i",{className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:f}))):s.createElement(s.Fragment,null),l,c]}const Gv=ao||ti,Yv=["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"],Uv=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function zv(e,t,n){return n?(e&&e[n])===(t&&t[n]):e===t}function Mc(e,t,n){return typeof n.value=="function"&&n.disabled?!0:t?!!(e!=null&&e.find(r=>{var o;return r[t]&&r[t]===((o=n==null?void 0:n.value)==null?void 0:o[t])})):!1}const os=s.forwardRef((e,t)=>{const{captionKey:n,comparisonKey:r,disabledOptions:o,options:a,tall:l,textKey:c,valueKey:p,zeroState:m,hideInlineSearch:f,onSearchChange:u,search:h,searchDebounce:S,searchPlaceholder:y,onSpecialActionSelect:E,attachTo:T,className:w,conformWidth:N,id:I,ignoreWidthStyles:x,isOpen:k,keepOpen:F,keyDown:L,nullOption:C,onOptionListChanged:O,onOptionSelected:R,onPositionFlip:$,onSelfToggle:j,optionRole:M,positionOverride:Y,selectedOption:G,specialAction:z,unsafelyReplaceClassName:K,loading:J,filterByTextAndCaptionKey:re,maxHeightPx:P,maxHeightRem:U,disableOptionsMemoization:te,disableDefaultOptionsFiltering:ee,"data-testid":le,...B}=e,Z=s.useMemo(()=>z?new H.SpsOptionListOption(z,{textKey:"label",captionKey:"caption"}):null,[z]),[X,ne]=s.useState(-1),[ae,ce]=s.useState(k),oe=t||s.useRef(null),se=s.useRef(null),Ee=s.useRef(null),Be=Dr("sps-option-list-portal"),qe=s.useContext(Ot),[ct,ut]=Y||[H.Position.BOTTOM_LEFT,H.Position.TOP_LEFT],[[dt,he],ze]=s.useState([{},!1]),Ce=s.useRef(null),[ve,xe,Ze]=Wv({...e,searchInputRef:Ce}),[Ae,Xe]=Kv(e,xe,Ze);s.useEffect(()=>{ze(ae?Un(oe,T,ct,{altPosition:ut,setMinWidth:!x,setWidth:!x&&N,...qe}):[{},!1])},[ae,ct,ut,Ae]),s.useEffect(()=>{let ge;return ae&&(ge=()=>{ae&&ze(Un(oe,T,ct,{altPosition:ut,setMinWidth:!x,setWidth:!x&&N,...qe}))},document.addEventListener("scroll",ge)),()=>{ge&&document.removeEventListener("scroll",ge)}},[ae]),s.useEffect(()=>{ne(-1)},[xe]);const Yt=W(K||"sps-option-list","z-stratum-dropdown",ae&&"sps-option-list--open",xe.isAsync&&"sps-option-list--searchable",he&&"sps-option-list--opens-upward",z&&z.label&&"sps-option-list--has-special-action",w),fn=W(K||"sps-option-list__options",l&&"sps-option-list__options--tall"),pe=s.useCallback(()=>{ae||(ce(!0),Ce.current&&Ce.current.focus(),ne(-1),j&&j(!0))},[ae,j]),fe=s.useCallback(()=>{ae&&(ce(!1),ne(-1),j&&j(!1))},[ae,j]),Me=s.useCallback((ge,ye)=>{ye||ge&&!ge.disabled&&(typeof ge.value=="function"?(ge.value(),E&&E()):typeof R=="function"&&R(ge.value),F||fe())},[R,fe]),st=s.useCallback((ge,ye,je)=>{ge.stopPropagation(),Me(ye,je)},[Me]),De=s.useRef(o||[]);De.current=o||[];const mt=s.useCallback(ge=>{switch(ge.key){case"Tab":case"Escape":fe();break;case"Enter":if(X>-1){const ye=Ae[X]||Z;ge.preventDefault();const je=!!ye&&Mc(De.current,r||"",ye);!je&&ye&&typeof R=="function"&&typeof ye.value=="function"?ye.value():ye&&Me(ye,je)}break;case"Up":case"ArrowUp":{let ye=X;he?X<=-1?ye=Ae.length-1:X===0?z&&(ye=Ae.length):X<Ae.length&&(ye=X-1):X>-1&&(ye=X-1),ye!==X&&(ge.preventDefault(),ne(ye));break}case"Down":case"ArrowDown":{pe();let ye=X;he?X!==-1&&(X>=Ae.length?ye=0:X===Ae.length-1?ye=-1:ye=X+1):X<Ae.length-1+ +!!z&&(ye=X+1),ye!==X&&(ge.preventDefault(),ne(ye));break}default:pe()}},[fe,pe,X,Me,R,he,Ae]),bt=s.useCallback(ge=>{const ye=Ae.findIndex(je=>{if(je.textKey){const Bt=je.textKey;return je.value[Bt].toLowerCase().charAt([0])===ge.key.toLocaleLowerCase()}return je.value.toString().toLowerCase().charAt([0])===ge.key.toLocaleLowerCase()});ye>-1&&ne(ye)},[Ae]),Oe=s.useCallback(ge=>{ge&&(Yv.includes(ge.key)?mt(ge):Uv.includes(ge.key)&&!f&&bt(ge))},[fe,pe,X,Me,R,he,Ae]);s.useEffect(()=>{if(qe!==null&&document.getElementsByClassName("sps-modal__body").length>0){const ge=()=>{j&&j(!1)},ye=document.getElementsByClassName("sps-modal__body")[0];return ye.addEventListener("scroll",ge),()=>{ye.removeEventListener("scroll",ge)}}},[]),s.useEffect(()=>{ae&&Ee.current&&Gv(Ee.current,{scrollMode:"if-needed",block:"nearest",inline:"nearest"})},[X,ae]),s.useEffect(()=>{ce(k),k?Ce.current&&Ce.current.focus():ne(-1)},[k]),s.useEffect(()=>{L&&Oe(L)},[L]),s.useEffect(()=>{!ae&&se.current&&(Ze({value:""}),se.current.scrollTop=0),ae&&$&&$(he)},[ae]);const ot=P?P/16:U,Rn=ot?{maxHeight:`${ot}rem`}:{};function Pt(ge,ye){return ye?s.createElement(s.Fragment,null,ge.split(ye).map((je,Bt)=>ye.test(je)?s.createElement("u",{key:Bt},je):s.createElement(s.Fragment,{key:Bt},je))):s.createElement(s.Fragment,null,ge)}return Be(s.createElement("div",{className:Yt,id:I,"aria-activedescendant":X>-1?`${I}-option-${X}`:"",tabIndex:-1,ref:oe,style:dt,onMouseLeave:()=>ne(-1),"data-testid":le,...B},ve,s.createElement("div",{className:fn,ref:se,"data-testid":`${le}-options`,style:Rn},!J&&!xe.pending&&m&&Ae.length===0&&s.createElement("div",{className:"sps-option-list__zero-state"},m),(J||xe.pending)&&s.createElement("div",{className:"sps-option-list__loading"},s.createElement(ni,null)),!J&&!xe.pending&&Ae.map((ge,ye)=>{const je=`${I}-option-${ye}`,Bt=zv(ge.value,G,r),On=Mc(De.current,r||"",ge);return s.createElement("a",{key:je,id:je,role:M,"aria-selected":Bt,href:ge.href,className:W("sps-option-list__option",ge.caption&&"sps-option-list__option--has-caption",ge.disabled&&"sps-option-list__option--disabled",ge.bold&&"sps-option-list__option--bold",(Bt||On)&&"sps-option-list__option--selected",X===ye&&"sps-option-list__option--highlighted"),onClick:ue=>st(ue,ge,On),onMouseOver:()=>ne(ye),tabIndex:-1,ref:X===ye?Ee:null,"data-testid":`${le}-option-${ye}`},ge.value&&ge.value.icon&&s.createElement("i",{className:W("sps-icon","sps-option-list__option-icon",`sps-icon-${String(ge.value.icon)}`)}),(!ge.value||!ge.value.icon&&Xe)&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",null,Pt(ge.text,xe.replacementPattern)),ge.caption&&s.createElement("div",{className:"sps-option-list__option-caption"},s.createElement("span",null,Pt(ge.caption,xe.replacementPattern))))})),Z&&(z==null?void 0:z.label)&&s.createElement("a",{className:W("sps-option-list__option","sps-option-list__special-action",X===Ae.length&&"sps-option-list__option--highlighted",z.disabled&&"sps-option-list__special-action--disabled"),href:Z.href,target:Z.href&&z.newTab?"_blank":"_self",onClick:ge=>st(ge,Z),onMouseOver:()=>ne(Ae.length),"data-testid":`${le}-special-action`},z.icon&&s.createElement("i",{className:W("sps-icon","sps-option-list__option-icon",`sps-icon-${String(z.icon)}`)}),!z.icon&&Xe&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",null,z.label))))});Object.assign(os,{displayName:"SpsOptionList"});function jv(e,t,n=[]){return s.useMemo(()=>{function r(o){return s.createElement(e,{...o,...t},o.children)}return r},n)}function yt(e){return typeof e=="function"?e():e}const xp=function({children:e,elements:t}){if(t.length===0)return s.createElement(s.Fragment,null,e);const[n,r]=Array.isArray(t[0])?t[0]:[t[0]];return s.createElement(n,{...r??{}},s.createElement(xp,{elements:t.slice(1)},e))},kp=function({children:e,providers:t=[],...n}){return s.createElement("div",{...n},s.createElement(xp,{elements:t},e))},qv=function({children:e,className:t,...n}){return s.createElement(kp,{className:`sps-app ${t}`,...n},e)};function Lt(e=[],t=[]){const n=Array.isArray(e)?v.flatten(e):[e],r=t.map(a=>Array.isArray(a)?a:[a]),o=new Array(r.length+1).fill(null).map(()=>[]);for(const a of n){let l=!1;for(let c=0;c<r.length;c+=1)for(const{type:p,props:m={}}of r[c])if(a.type===p&&Object.keys(m).every(u=>m[u]===a.props[u])){l=!0,o[c].push(a);break}l||o[o.length-1].push(a)}return o}function Ip(e,t,n){const r=Object.entries(t).filter(([,a])=>typeof a!="string"&&a.deprecated).map(([a])=>a),o=r.map(a=>n[a]);s.useEffect(()=>{o.find(a=>typeof a<"u")&&console.warn(`The following prop(s) of ${e} are deprecated: ${r.join(", ")}`)},o)}function si(e,t){const n=_.useRef(!1);_.useEffect(()=>{if(n.current)return e();n.current=!0},t)}function Oa(e,t,n){const r=s.useRef(t(...n));s.useEffect(()=>(document.addEventListener(e,r.current),()=>document.removeEventListener(e,r.current)),[]),s.useEffect(()=>{document.removeEventListener(e,r.current),r.current=t(...n),document.addEventListener(e,r.current)},n)}function _c(e,t,n){return function(o){var a,l;!((a=e.current)!=null&&a.contains(o.target))&&!((l=t.current)!=null&&l.contains(o.target))&&n()}}function Nr(e,t,n){const r=s.useRef(!1),[o,a]=s.useState(!1),l=s.useCallback(()=>{r.current?r.current=!1:a(!0)},[]),c=s.useCallback((p=!1)=>{a(!1),r.current=p,n&&n()},[]);return Oa("mousedown",_c,[e,t,c]),Oa("pointerdown",_c,[e,t,c]),{showPopup:o,doShowPopup:l,doHidePopup:c}}const Mp=e=>{const t=/(auto|scroll)/,n=(c,p)=>c.parentNode===null?p:n(c.parentNode,p.concat([c])),r=(c,p)=>getComputedStyle(c,null).getPropertyValue(p),o=c=>r(c,"overflow")+r(c,"overflow-y"),a=c=>t.test(o(c));return(c=>{if(!(c instanceof HTMLElement||c instanceof SVGElement))return;const p=n(c.parentNode,[]);for(let m=0;m<p.length;m+=1)if(a(p[m]))return p[m];return null})(e)};let Xo=0;function io({isOpen:e,rootRef:t}){s.useLayoutEffect(()=>{let n,r,o;if(e&&t.current){Xo+=1,n=Mp(t.current)||document.body,r=n===document.body?window.innerWidth-document.documentElement.clientWidth:n.offsetWidth-n.clientWidth,n.style.overflow="hidden";const a=window.getComputedStyle(n).paddingRight;if(n.style.paddingRight=a&&a!=="0px"?`calc(${a} + ${r}px)`:`${r}px`,n===document.body)if(o=document.getElementsByClassName("sps-navbar-container").item(0),o&&window.getComputedStyle(o).position==="fixed"){const l=window.getComputedStyle(o).paddingRight;o.style.paddingRight=l&&l!=="0px"?`calc(${l} + ${r}px)`:`${r}px`}else{const l=document.getElementsByTagName("nav").item(0);if(o=l==null?void 0:l.parentElement,o&&window.getComputedStyle(o).position==="fixed"){const c=window.getComputedStyle(o).paddingRight;o.style.paddingRight=c&&c!=="0px"?`calc(${c} + ${r}px)`:`${r}px`}}}return()=>{n&&(Xo-=1,Xo===0&&(n.style.overflow=null,n.style.paddingRight=null,o&&(o.style.paddingRight=null)))}},[e])}const Jv={debounce:"number",disabled:"boolean",formMeta:"SpsFormFieldMeta<string>",icon:"SpsIcon",onChange:"React.ChangeEventHandler",onSelectionChange:"(newValue: string) => void",placeholder:"string",suggestions:{type:`
1
+ "use strict";var rv=Object.defineProperty;var Cc=e=>{throw TypeError(e)};var sv=(e,t,n)=>t in e?rv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Vt=(e,t,n)=>sv(e,typeof t!="symbol"?t+"":t,n),Dc=(e,t,n)=>t.has(e)||Cc("Cannot "+n);var An=(e,t,n)=>(Dc(e,t,"read from private field"),n?n.call(e):t.get(e)),ks=(e,t,n)=>t.has(e)?Cc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ln=(e,t,n,r)=>(Dc(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("react"),v=require("@spscommerce/utils"),it=require("moment-timezone"),H=require("@spscommerce/ds-shared"),no=require("react-dom"),xa=require("@spscommerce/ds-colors"),ov=require("@sps-woodland/tabs"),mr=require("@react-stately/collections"),up=require("@sps-woodland/illustrations");function mp(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const s=mp(_),br=mp(it);function fp(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=fp(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function W(){for(var e,t,n=0,r="";n<arguments.length;)(e=arguments[n++])&&(t=fp(e))&&(r&&(r+=" "),r+=t);return r}let gt=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");function Dn(e){return _.useRef(e||gt())}function Tt(e,t){const n=Dn(e),r=_.useRef(`${n.current}_ctrl`);return _.useEffect(()=>{t&&(t.id=r.current,t.update())},[t]),{wrapperId:n.current||void 0,controlId:r.current}}var qt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ei(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var av="[object Object]";function iv(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}function lv(e,t){return function(n){return e(t(n))}}var cv=Function.prototype,hp=Object.prototype,Sp=cv.toString,dv=hp.hasOwnProperty,pv=Sp.call(Object),uv=hp.toString,mv=lv(Object.getPrototypeOf,Object);function fv(e){return!!e&&typeof e=="object"}function hv(e){if(!fv(e)||uv.call(e)!=av||iv(e))return!1;var t=mv(e);if(t===null)return!0;var n=dv.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Sp.call(n)==pv}var Sv=hv;const gp=ei(Sv),Nt=new Set,Cr=new Set,pn=new Set,ro=new Set;function bp(e){Nt.has(e)||pn.has(e)||ro.has(e)||Cr.add(e)}function vp(e){Nt.has(e)||pn.has(e)||Cr.has(e)||ro.add(e)}const et=br.default||br,vr="MM/DD/YYYY",gv="MM/DD/YYYY hh:mm A",bv="MM/DD/YYYY HH:mm",vv="hh:mm A",yv="HH:mm",Tv=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,zr=Symbol("Date Parse Error");function cr(e){return et.isMoment(e)?e.year()*1e4+(e.month()+1)*100+e.date():e.year*1e4+e.month*100+e.date}const Q=Object.freeze({createFrom(e,t){if(!e)return null;if(typeof e=="string"){if(t){const n=et(e,t,!0);if(n.isValid())return Object.freeze({year:n.year(),month:n.month()+1,date:n.date()})}else{const n=Tv.exec(e);if(n){const[,r,o,a]=n;return Object.freeze({year:Number(a),month:Number(r),date:Number(o)})}}return Object.freeze({[zr]:!0,year:void 0,month:void 0,date:void 0})}return Object.freeze({year:e.year(),month:e.month()+1,date:e.date()})},createMomentFrom(e,t){if(!e)return null;let n=null;return typeof e=="string"?t?n=et(e,t,!0):n=et(e):et.isMoment(e)?n=e:n=Q.toMoment(e),n!==null&&et.isMoment(n)&&n.isValid()?n:Object.freeze({[zr]:!0,year:void 0,month:void 0,date:void 0})},getRangeSeparator(e){return e!=null&&e.includes("-")?"/":"-"},createRangeFrom(e,t){if(!e)return null;if(t){const n=Q.getRangeSeparator(t),r=new RegExp(`[^\\d]*${n}[^\\d]*`);return e.split(r).slice(0,2).map(o=>Q.createFrom(o,t))}else return e.split(/[^\d]*-[^\d]*/).slice(0,2).map(n=>Q.createFrom(n))},isValid(e){var t;return e?et.isMoment(e)?e.isValid():typeof e=="object"&&typeof e.year=="number"&&typeof e.month=="number"&&typeof e.date=="number"&&((t=Q.toMoment(e))==null?void 0:t.isValid()):!1},nullifyInvalidDate(e){return Q.isValid(e)?e:null},toMoment(e){return e?et.isMoment(e)?e:et({...e,month:e.month-1}):null},toString(e,t){const n=Q.toMoment(e);return n&&n.isValid()?n.format(t||vr):""},toStringRange(e,t){if(!e)return"";const n=Q.getRangeSeparator(t);return e.slice(0,2).map(r=>Q.toString(r,t)).join(n)},toDateTimeString(e,t=!1,n){return e&&et.isMoment(e)&&e.isValid()?n?t?e.format(`${n} ${yv}`):e.format(`${n} ${vv}`):t?e.format(bv):e.format(gv):""},toDateTimeStringRange(e,t=!1,n){if(!e)return"";const r=Q.getRangeSeparator(n);return e.map(o=>Q.toDateTimeString(o,t,n)).join(r)},create(){const e=new Date;return Object.freeze({year:e.getFullYear(),month:e.getMonth()+1,date:e.getDate()})},isSameDate(e,t){return e&&t&&e.year===t.year&&e.month===t.month&&e.date===t.date},isSameMonth(e,t){return e&&t&&e.year===t.year&&e.month===t.month},isAfter(e,t){return!e||!t?null:cr(e)>cr(t)},isBefore(e,t){return!e||!t?null:cr(e)<cr(t)},isInRange(e,t,n=!0){if(!e||!t||!t[0]||!t[1])return null;const r=cr(e),[o,a]=t.map(cr);return e&&o&&a&&(n&&r>=o&&r<=a||!n&&r>o&&r<a)},prevMonth(e){return Object.freeze({year:e.month===1?e.year-1:e.year,month:e.month-1||12,date:e.date})},nextMonth(e){return Object.freeze({year:e.month===12?e.year+1:e.year,month:e.month+1>12?1:e.month+1,date:e.date})},createRangeFromPreset(e,t){if(typeof e.definition=="function")return e.definition();const n=et(),r=n.clone().subtract(et.duration(e.definition));return[Q.createFrom(r,t),Q.createFrom(n,t)]},createDateTimeRangeFromPreset(e){if(typeof e.definition=="function")return e.definition();let t;e.definition==="P0D"?t=et().startOf("day"):t=et().subtract(et.duration(e.definition));const n=et().endOf("day");return[t,n]},splitMomentInDateTimeParts(e,t=!1,n){return e&&et.isMoment(e)&&e.isValid()?Q.toDateTimeString(e,t,n).split(" "):["",t?"00:00":"12:00",t?void 0:"AM"]},getCurrentMoment(){return et()},validateTimeString(e,t=!1){if(!e)return!0;const n=e.split(":"),r=n[0]||"0",o=n[1]||"0",a=Number.isNaN(Number(r))?NaN:parseInt(r,10),l=Number.isNaN(Number(o))?NaN:parseInt(o,10),c=n.length<=2&&r.length<=2&&o.length<=2;return t?c&&a>=0&&a<=23&&l>=0&&l<=59:c&&(!Number.isNaN(a)&&r.length===1||a>=1)&&a<=12&&l>=0&&l<=59},padIncompleteTimeString(e,t=!1){if(!e)return"";const n=e.split(":"),r=parseInt(n[0]||"0",10),o=parseInt(n[1]||"0",10);if(t){const a=r<10?`0${r}`:`${r}`,l=o<10?`0${o}`:`${o}`;return`${a}:${l}`}else{const a=r===0?"12":r<10?`0${r}`:`${r}`,l=o<10?`0${o}`:`${o}`;return`${a}:${l}`}}}),ka=["01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00","12:00"],Ia=["00:00","01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00","22:00","23:00"];let Gs=vr;function yp(e){Gs=e}const jr=function(t){if(Array.isArray(t)){const n=jr(t[0]),r=jr(t[1]);return n||r}if(t&&t.hasOwnProperty("year")){if(t[zr])return{dateFormat:Gs};if(!Q.isValid(t))return{dateValidity:!0}}return null};Nt.add("dateFormat");Nt.add("dateValidity");const Tp=function(t){if(Array.isArray(t)){const n=jr(t);if(n)return n;if(t&&Q.isBefore(t[1],t[0]))return{dateRangeOrder:!0}}return null};Nt.add("dateRangeOrder");const Ep=function({minDate:t,maxDate:n}){function r(o){const a=Q.isBefore(o,t),l=Q.isAfter(o,n),c={minExceeded:a?Q.toString(t,Gs):null,maxExceeded:l?Q.toString(n,Gs):null};return a||l?{dateConstraint:c}:null}return function(a){if(!a)return null;if(Array.isArray(a)){const l=r(a[0]),c=r(a[1]);return l||c}return a.hasOwnProperty("year")?r(a):null}};Nt.add("dateConstraint");const Ev=Object.freeze(Object.defineProperty({__proto__:null,date:jr,dateConstraint:Ep,dateRange:Tp,setDateFormat:yp},Symbol.toStringTag,{value:"Module"}));function Nn(e,t){for(const n of[].concat(e)){const r=t(n);if(r)return r}return null}const wv=function(t){function n(r){return Number(r)>=t?null:{min:t}}return r=>Nn(r,n)};Nt.add("min");const Cv=function(t){function n(r){return Number(r)<=t?null:{max:t}}return r=>Nn(r,n)};Cr.add("max");const Dv=function(t){return typeof t>"u"||t===null||t===""||Number.isNaN(t)||(t==null?void 0:t.length)===0?{required:!0}:null};Cr.add("required");const Nv=function(t){function n(r){return r===void 0||r.toString().length<t?{minLength:t}:null}return r=>Nn(r,n)};Nt.add("minLength");const xv=function(t){function n(r){return r==null||Array.isArray(r)&&r.length<t?{minLengthArray:t}:null}return r=>n(r)};Nt.add("minLengthArray");const kv=function(t){function n(r){return r===void 0||r.toString().length<=t?null:{maxLength:t}}return r=>Nn(r,n)};pn.add("maxLength");const Iv=function(t){function n(r){return r==null||Array.isArray(r)&&r.length<=t?null:{maxLengthArray:t}}return r=>n(r)};Nt.add("maxLengthArray");const Mv=function(t){const n=t instanceof RegExp?t:new RegExp(t);function r(o){return n.test(o)?null:{pattern:t}}return o=>Nn(o,r)};Nt.add("pattern");const _v=function(e){function t(n){return new RegExp("^\\p{L}*$","u").test(n)?null:{alpha:!0}}return Nn(e,t)};pn.add("alpha");const Rv=function(e){function t(n){return/^[0-9,. ]*$/.test(n)?null:{numeric:!0}}return Nn(e,t)};pn.add("numeric");const Ov=function(e){function t(n){return/^[^0-9]*$/.test(n)?null:{nonNumeric:!0}}return Nn(e,t)};pn.add("nonNumeric");const so=Object.freeze({...Ev,min:wv,max:Cv,required:Dv,minLength:Nv,minLengthArray:xv,maxLength:kv,maxLengthArray:Iv,pattern:Mv,alpha:_v,numeric:Rv,nonNumeric:Ov,OnBlurErrorKeys:Nt});function oo(e,t=[]){const n=t.reduce((r,o)=>Object.assign(r,o(e)||{}),{});return Object.keys(n).length?n:null}var zt=(e=>(e[e.ON_CHANGE=0]="ON_CHANGE",e[e.ON_BLUR=1]="ON_BLUR",e[e.ON_SUBMIT=2]="ON_SUBMIT",e))(zt||{});function Lv(e,t={},n=[]){for(const[r,o]of Object.entries(t))o===0?bp(r):o===2&&vp(r);return s.useCallback(e,n)}var Yn,vn,yn;class Hn{constructor(t,n){Vt(this,"validators",[]);ks(this,Yn,null);ks(this,vn,null);ks(this,yn,null);Vt(this,"preventativeErrors",[]);Vt(this,"submitted",!1);this.path=t,this.update=n}get errors(){return An(this,Yn)===null&&An(this,vn)===null&&An(this,yn)===null?null:{...An(this,Yn)??{},...An(this,vn)??{},...An(this,yn)??{}}}setValidators(t){return this.update(this.path,null,void 0,t),this}validate(t,n,r=!1){if(this.validators&&this.validators.length>0){const o=oo(t,this.validators);let a={onSubmit:{},onChange:{},onBlur:{}};o&&(a=Object.keys(o).reduce((l,c)=>(ro.has(c)?l.onSubmit[c]=o[c]:Cr.has(c)?l.onChange[c]=o[c]:l.onBlur[c]=o[c],l),a)),(typeof n>"u"||n===zt.ON_CHANGE)&&ln(this,vn,Object.keys(a.onChange).length===0?null:a.onChange),(typeof n>"u"||n===zt.ON_BLUR)&&ln(this,yn,Object.keys(a.onBlur).length===0?null:a.onBlur),(typeof n>"u"||n===zt.ON_SUBMIT)&&(ln(this,Yn,Object.keys(a.onSubmit).length===0?null:a.onSubmit),ln(this,vn,Object.keys(a.onChange).length===0?null:a.onChange),ln(this,yn,Object.keys(a.onBlur).length===0?null:a.onBlur)),r||this.update(),this.isFocused()&&this.onFocus&&this.onFocus()}else this.errors&&(ln(this,Yn,null),ln(this,yn,null),ln(this,vn,null),r||this.update());return this}isValid(){return!this.errors||this.isPristine()}hasErrors(){return!!this.errors}isVisibilyInvalid(){return!this.isValid()}hasError(t){return this.errors&&Object.prototype.hasOwnProperty.call(this.errors,t)}hasPreventativeError(t){return this.preventativeErrors.includes(t)}hasPreventativeErrors(){return this.preventativeErrors.length>0}isRequired(){return this.validators&&this.validators.indexOf(so.required)>-1}isSubmitted(){return this.submitted}onFocus(){}onBlur(){}}Yn=new WeakMap,vn=new WeakMap,yn=new WeakMap;class qr extends Hn{constructor(){super(...arguments);Vt(this,"id",gt());Vt(this,"focused",!1);Vt(this,"pristine",!0)}setValue(n){if(this.preventativeErrors=[],this.validators&&this.validators.length>0){const r=oo(n,this.validators);if(r&&Object.keys(r).filter(a=>pn.has(a)).length>0){this.preventativeErrors=Object.keys(r);return}}this.update(this.path,n)}isPristine(){return this.pristine}markAsPristine(){return this.pristine=!0,this.update(),this}markAsDirty(){return this.pristine=!1,this.update(),this}isFocused(){return this.focused}markAsFocused(){return this.focused=!0,this.update(),this.onFocus&&this.onFocus(),this}markAsBlurred(){return this.update(this.path,null,!0),this.onBlur&&this.onBlur(),this.preventativeErrors=[],this}markAsSubmitted(){return this.submitted=!0,this.update(this.path,null,!1,void 0,!0),this}}class Wn extends qr{constructor(n,r,o){super(o?r:n,o||r);Vt(this,"fields");o&&this.inferMembers(n)}isFocused(){return super.isFocused()||this.rollup("isFocused")}isValid(){return super.isValid()&&this.rollup("isValid")}hasErrors(){return super.hasErrors()||Object.keys(this.fields).some(n=>this.fields[n].hasErrors())}contentsAreValid(){return this.rollup("isValid")&&this.rollup("contentsAreValid")}isPristine(){return super.isPristine()&&this.rollup("isPristine")}markAsPristine(){super.markAsPristine();for(const n of Object.keys(this.fields))this.fields[n].markAsPristine();return this}markAsDirty(){super.markAsDirty();for(const n of Object.keys(this.fields))this.fields[n].markAsDirty();return this}markAsBlurred(){super.markAsBlurred();for(const n of Object.keys(this.fields))this.fields[n].markAsBlurred();return this}markAsSubmitted(){super.markAsSubmitted();for(const n of Object.keys(this.fields))this.fields[n].markAsSubmitted();return this}inferSpsControl(n,r){return $s(n,[...this.path,r],this.update)}rollup(n){return Object.keys(this.fields).reduce((r,o)=>r&&(!this.fields[o][n]||this.fields[o][n]()),!0)}}class wp extends Wn{inferMembers(t){this.fields={};for(const n of Object.keys(t))this.fields[n]=this.inferSpsControl(t[n],n)}}class Cp extends Wn{inferMembers(t){this.fields=t.map((n,r)=>this.inferSpsControl(n,String(r)))}}function $s(e,t,n){return e instanceof Hn?(e.path=t,e.update=n,e):Array.isArray(e)?new Cp(e,t,n):gp(e)?new wp(e,t,n):new qr(t,n)}function Hr(e,t){return t.length===0||!e?e:Hr(e.fields[t[0]],t.slice(1,t.length))}function Ma(e,t){if(t.length===0||!e)return[e];const n=t[0];if(t=t.slice(1,t.length),n==="*"){const r=Array.isArray(e.fields)?e.fields:Object.keys(e.fields).map(o=>e.fields[o]);return t.length===0?r:r.reduce((o,a)=>[...o,...Ma(a,t)],[])}return Ma(e.fields[n],t)}function _a(e,t,n){for(const r of Object.keys(t)){const o=t[r];for(const a of Ma(e,r.split(".")))a&&o&&n(a,o)}}function Is(e,t,n,r=!1,o=!1){_a(t,n,(a,l)=>{a.validators=typeof l=="function"?l(e):l,r&&a.validate(v.getPath(e,a.path),void 0,o)})}function Ra(e,t){const n=t[0];return t=t.slice(1),Array.isArray(e)?e.map((r,o)=>o===Number(n)?Ra(r,t):r):gp(e)?Object.keys(e).reduce((r,o)=>Object.assign(r,{[o]:o===n?Ra(e[o],t):e[o]}),{}):e}function Pv(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("The initial value of useSpsForm() hook must be an object.")}function Dp(e,t={}){Pv(e);const[,n]=_.useState({}),r=_.useRef(!1);r.current=!1;const o=_.useRef(t),a=_.useCallback(h=>{var E,T;const S=u.current;let y;if(h)if(h.path)if(h.markAsBlurred){const w=Hr(S.formMeta,h.path);if(w){w.focused=!1;const N=v.getPath(S.formValue,h.path);w.validate(N,zt.ON_BLUR)}}else if(h.newValidators){if(o.current){const w=h.path.join(".");o.current={...o.current,[w]:h.newValidators},Is(S.formValue,S.formMeta,o.current,!0)}}else if(h.markAsSubmitted){const w=Hr(S.formMeta,h.path);if(w){w.submitted=!0;const N=v.getPath(S.formValue,h.path);w.validate(N,zt.ON_SUBMIT)}}else y=Ra(S.formValue,h.path),v.setPath(y,h.path,h.value);else y=h.value;if((E=h==null?void 0:h.updateFormOptions)!=null&&E.validators&&(o.current={...o.current,...h.updateFormOptions.validators},Is(S.formValue,S.formMeta,o.current,((T=h.updateFormOptions)==null?void 0:T.runValidators)??!0)),y){S.formMeta.submitted=!1,v.deepFreeze(y);const w=v.diff(S.formValue,y);for(const{type:I,key:x,parentPath:k,objects:[,F]}of w){const L=Hr(S.formMeta,k);if(typeof x!="symbol"&&L){let C;switch(I){case v.DiffChange.ADDITION:L.fields[x]=$s(F[x],[...k,x],c);break;case v.DiffChange.DELETION:Array.isArray(L.fields)?L.fields[x]=void 0:delete L.fields[x];break;case v.DiffChange.ALTERATION:C=$s(F[x],[...k,x],c),(C instanceof Wn&&!(L.fields[x]instanceof Wn)||!(C instanceof Wn)&&L.fields[x]instanceof Wn)&&(C.pristine=!1,L.fields[x]=C);break}}}const N=new Set;if(w.filter(I=>I.type===v.DiffChange.DELETION).reduce((I,x)=>(I.has(x.parentPath)||I.add(x.parentPath),I),N),Array.from(N).forEach(I=>{const x=Hr(S.formMeta,I);Array.isArray(x.fields)&&(x.fields=x.fields.filter(k=>k!==void 0))}),o.current){Is(y,S.formMeta,o.current);const I=new Set;t&&_a(S.formMeta,t,(x,k)=>{typeof k=="function"&&(x.validate(v.getPath(y,x.path)),I.add(x))});for(const{type:x,key:k,parentPath:F,objects:[,L]}of w)if(typeof k!="symbol"){let C=S.formMeta,O=y;if(C){for(const R of F)C=C.fields[R],O=O[R],I.has(C)||C.validate(O,zt.ON_CHANGE);if(x===v.DiffChange.ADDITION||x===v.DiffChange.ALTERATION){const R=C.fields[k];if(!I.has(R)&&(C.fields[k].validate(L[k],zt.ON_CHANGE),x===v.DiffChange.ADDITION&&R.fields))for(const[$,j]of Object.entries(R.fields))j.validate(L[k][$],zt.ON_CHANGE)}}}}}u.current={...S,formValue:y||S.formValue},r.current||n({})},[]),l=_.useCallback((h,S)=>{h||S?a({value:h,updateFormOptions:S}):a()},[a]),c=_.useCallback((h,S,y=!1,E,T=!1)=>{h?a({path:h,value:S,markAsBlurred:y,newValidators:E,markAsSubmitted:T}):l()},[a,l]),p=_.useMemo(()=>{v.deepFreeze(e);const h=$s(e,[],c);return t&&Is(e,h,t,!1,!0),h},[]),m=_.useCallback(()=>(u.current.formMeta.markAsDirty(),o.current&&_a(u.current.formMeta,o.current,(h,S)=>{(typeof S=="function"||Array.isArray(S))&&h.validate(v.getPath(u.current.formValue,h.path))}),u.current.formMeta.isValid()),[]),f=_.useCallback(()=>u.current.formValue,[]),u=_.useRef({formValue:e,formMeta:p,updateForm:l,validateForm:m,getCurrentFormValue:f});return u.current}const lt=s.forwardRef((e,t)=>{const{className:n,children:r,focusInputOnClick:o,formControl:a,formMeta:l,inputRef:c,onClick:p,...m}=e,f=s.useRef(),h=c||(t||f);function S(){h&&h!==t&&h.current&&h.current.focus()}function y(){h&&h!==t&&h.current&&l&&l instanceof qr&&l.markAsFocused()}function E(){h&&h!==t&&h.current&&l&&l instanceof qr&&l.markAsBlurred()}const T=W("sps-form-group",(a&&a.isRequired()||l&&l.isRequired())&&"sps-form-group--required",(a&&!a.isValid()||l&&l.isVisibilyInvalid())&&"sps-form-group--error",l&&l.hasPreventativeErrors()&&"sps-form-group--preventative-error",n);function w(N){o&&S(),p&&p(N)}return s.useEffect(()=>{function N(I){I.target.classList.contains("sps-form-control__clear-btn")&&I.preventDefault()}return document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[]),s.createElement("div",{...m,className:T,ref:t,tabIndex:-1,onClick:w,onFocus:y,onBlur:E},r)});Object.assign(lt,{displayName:"SpsFormComponentWrapper"});function Nc(e){return typeof e=="object"&&e!=null&&e.nodeType===1}function xc(e,t){return(!t||e!=="hidden")&&e!=="visible"&&e!=="clip"}function Zo(e,t){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var n=getComputedStyle(e,null);return xc(n.overflowY,t)||xc(n.overflowX,t)||function(r){var o=function(a){if(!a.ownerDocument||!a.ownerDocument.defaultView)return null;try{return a.ownerDocument.defaultView.frameElement}catch{return null}}(r);return!!o&&(o.clientHeight<r.scrollHeight||o.clientWidth<r.scrollWidth)}(e)}return!1}function Ms(e,t,n,r,o,a,l,c){return a<e&&l>t||a>e&&l<t?0:a<=e&&c<=n||l>=t&&c>=n?a-e-r:l>t&&c<n||a<e&&c>n?l-t+o:0}var kc=function(e,t){var n=window,r=t.scrollMode,o=t.block,a=t.inline,l=t.boundary,c=t.skipOverflowHiddenElements,p=typeof l=="function"?l:function(Be){return Be!==l};if(!Nc(e))throw new TypeError("Invalid target");for(var m,f,u=document.scrollingElement||document.documentElement,h=[],S=e;Nc(S)&&p(S);){if((S=(f=(m=S).parentElement)==null?m.getRootNode().host||null:f)===u){h.push(S);break}S!=null&&S===document.body&&Zo(S)&&!Zo(document.documentElement)||S!=null&&Zo(S,c)&&h.push(S)}for(var y=n.visualViewport?n.visualViewport.width:innerWidth,E=n.visualViewport?n.visualViewport.height:innerHeight,T=window.scrollX||pageXOffset,w=window.scrollY||pageYOffset,N=e.getBoundingClientRect(),I=N.height,x=N.width,k=N.top,F=N.right,L=N.bottom,C=N.left,O=o==="start"||o==="nearest"?k:o==="end"?L:k+I/2,R=a==="center"?C+x/2:a==="end"?F:C,$=[],j=0;j<h.length;j++){var M=h[j],Y=M.getBoundingClientRect(),G=Y.height,z=Y.width,K=Y.top,J=Y.right,re=Y.bottom,P=Y.left;if(r==="if-needed"&&k>=0&&C>=0&&L<=E&&F<=y&&k>=K&&L<=re&&C>=P&&F<=J)return $;var U=getComputedStyle(M),te=parseInt(U.borderLeftWidth,10),ee=parseInt(U.borderTopWidth,10),le=parseInt(U.borderRightWidth,10),B=parseInt(U.borderBottomWidth,10),Z=0,X=0,ne="offsetWidth"in M?M.offsetWidth-M.clientWidth-te-le:0,ae="offsetHeight"in M?M.offsetHeight-M.clientHeight-ee-B:0,ce="offsetWidth"in M?M.offsetWidth===0?0:z/M.offsetWidth:0,oe="offsetHeight"in M?M.offsetHeight===0?0:G/M.offsetHeight:0;if(u===M)Z=o==="start"?O:o==="end"?O-E:o==="nearest"?Ms(w,w+E,E,ee,B,w+O,w+O+I,I):O-E/2,X=a==="start"?R:a==="center"?R-y/2:a==="end"?R-y:Ms(T,T+y,y,te,le,T+R,T+R+x,x),Z=Math.max(0,Z+w),X=Math.max(0,X+T);else{Z=o==="start"?O-K-ee:o==="end"?O-re+B+ae:o==="nearest"?Ms(K,re,G,ee,B+ae,O,O+I,I):O-(K+G/2)+ae/2,X=a==="start"?R-P-te:a==="center"?R-(P+z/2)+ne/2:a==="end"?R-J+le+ne:Ms(P,J,z,te,le+ne,R,R+x,x);var se=M.scrollLeft,Ee=M.scrollTop;O+=Ee-(Z=Math.max(0,Math.min(Ee+Z/oe,M.scrollHeight-G/oe+ae))),R+=se-(X=Math.max(0,Math.min(se+X/ce,M.scrollWidth-z/ce+ne)))}$.push({el:M,top:Z,left:X})}return $};function Np(e){return e===Object(e)&&Object.keys(e).length!==0}function Bv(e,t){t===void 0&&(t="auto");var n="scrollBehavior"in document.body.style;e.forEach(function(r){var o=r.el,a=r.top,l=r.left;o.scroll&&n?o.scroll({top:a,left:l,behavior:t}):(o.scrollTop=a,o.scrollLeft=l)})}function Av(e){return e===!1?{block:"end",inline:"nearest"}:Np(e)?e:{block:"start",inline:"nearest"}}function ao(e,t){var n=e.isConnected||e.ownerDocument.documentElement.contains(e);if(Np(t)&&typeof t.behavior=="function")return t.behavior(n?kc(e,t):[]);if(n){var r=Av(t);return Bv(kc(e,r),r.behavior)}}const ti=Object.freeze(Object.defineProperty({__proto__:null,default:ao},Symbol.toStringTag,{value:"Module"})),Ke=s.createContext(H.noI18nI18n),Fv={alt:"string",size:"SpinnerSize",title:"string"};function ni(e){const{alt:t,className:n,size:r=H.SpinnerSize.MEDIUM,"data-testid":o,title:a,unsafelyReplaceClassName:l,...c}=e,{t:p}=s.useContext(Ke),m=t||a||p("design-system:spinner.defaultAltText"),f=W(l||"sps-spinner",`sps-spinner--${r}`,n);return s.createElement("i",{className:f,"data-testid":o,title:m,...c})}Object.assign(ni,{props:Fv,displayName:"SpsSpinner"});const Vv=60;function _s(e){return typeof e>"u"?"inherit":`${e}px`}function ri(e){switch(e){case H.Position.TOP_LEFT:return H.Position.BOTTOM_LEFT;case H.Position.TOP_MIDDLE:return H.Position.BOTTOM_MIDDLE;case H.Position.TOP_RIGHT:return H.Position.BOTTOM_RIGHT;case H.Position.RIGHT_TOP:return H.Position.LEFT_TOP;case H.Position.RIGHT_MIDDLE:return H.Position.LEFT_MIDDLE;case H.Position.RIGHT_BOTTOM:return H.Position.LEFT_BOTTOM;case H.Position.BOTTOM_RIGHT:return H.Position.TOP_RIGHT;case H.Position.BOTTOM_MIDDLE:return H.Position.TOP_MIDDLE;case H.Position.BOTTOM_LEFT:return H.Position.TOP_LEFT;case H.Position.LEFT_BOTTOM:return H.Position.RIGHT_BOTTOM;case H.Position.LEFT_MIDDLE:return H.Position.RIGHT_MIDDLE;case H.Position.LEFT_TOP:return H.Position.RIGHT_TOP}}function $v(e,t,n,r,o,a,l,c){const p=l&&l.current,m=p?p.scrollTop:window.pageYOffset,f=c?0:m,u=p?p.scrollLeft:window.pageXOffset,h=c?0:u,[S,y]=e.split(" ");let E,T,w,N;switch(S){case"top":w=t.height-n.top-f-a[0];break;case"left":T=t.width-n.left-h-a[0];break;case"right":N=n.right+h-a[0];break;case"bottom":E=n.bottom+f-a[0];break;default:throw new Error(`Invalid position ${e}`)}switch(y){case"left":N=n.left+h+a[1];break;case"top":E=n.top+f+a[1];break;case"middle":S==="top"||S==="bottom"?N=n.left+h+n.width/2-o/2+a[1]:(S==="left"||S==="right")&&(E=n.top+f+n.height/2-r.height/2+a[1]);break;case"bottom":w=t.height-n.bottom-f+a[1];break;case"right":T=t.width-n.right-h+a[1];break;default:throw new Error(`Invalid position ${e}`)}return[E,T,w,N]}function Un(e,t,n,{altPosition:r,setMinWidth:o=!1,setWidth:a=!1,parentElementRef:l,fixed:c=!1,offsets:p=[0,0]}){if(e.current&&t.current){const m=Math.max(document.documentElement.clientHeight,window.innerHeight||0),f=document.documentElement.getBoundingClientRect().width,u=l&&l.current?l.current:document.documentElement,h=c?{width:f,height:m,top:0,left:0,bottom:m,right:f}:u.getBoundingClientRect(),S=e.current.getBoundingClientRect(),y=t.current.getBoundingClientRect(),[E]=n.split(" ");let T=n;r&&(E==="top"&&y.top-S.height<Vv||E==="right"&&y.right+S.width>f||E==="bottom"&&y.bottom+S.height>m||E==="left"&&y.left-S.width<0)&&(T=r);const w=o?Math.max(y.width,S.width):S.width,N=a?y.width:w,[I,x,k,F]=$v(T,h,y,S,N,p,l,c),L={top:_s(I),right:_s(x),bottom:_s(k),left:_s(F)};return c&&(L.position="fixed",L.zIndex=H.ZStratum.BAR),o&&(L.minWidth=`${y.width}px`),a&&(L.width=`${y.width}px`),[L,T===r]}return[{},!1]}const Ot=_.createContext(null);function Dr(e,t=[]){const n=_.useContext(Ot);return _.useMemo(()=>r=>{const a=n&&n.parentElementRef&&n.parentElementRef.current||document.body;let l=null,c=a.lastElementChild;for(;c&&c!==a.firstElementChild;){if(c.hasAttribute("data-portalid")&&c.getAttribute("data-portalid")===e){l=c;break}c=c.previousElementSibling}if(l)a.contains(l)||a.appendChild(l);else{l=document.createElement("div"),l.setAttribute("data-portalid",e);for(const p of t)l.classList.add(p);a.appendChild(l)}return no.createPortal(r,l)},[n])}async function Ic(e,t,n,r,o,a){const l=typeof e.options=="function"?e.options(t.value):e.options||[],c=l instanceof Promise,p=u=>u.replace(/([.?*+^$[\]\\(){}|-])/g,"");n({pending:c}),a.current=c?l:null;const m=c?await l||[]:l||[];if(c&&a.current!==l)return;let f=Array.from(m).filter(Boolean).map(u=>new H.SpsOptionListOption(u,typeof u=="function"?{textKey:"label",captionKey:"caption"}:{textKey:e.textKey,captionKey:e.captionKey}));if(e.nullOption&&f.unshift(new H.SpsOptionListOption(null,{text:e.nullOption})),t.value&&!e.disableDefaultOptionsFiltering){const u=p(t.value);n({replacementPattern:new RegExp(`(${u})`,"ig")}),f=f.filter(h=>{const S=new RegExp(u,"i"),y=p(h.text);return e.filterByTextAndCaptionKey?S.test(y)||S.test(p(h.caption)):S.test(y)})}else n({replacementPattern:null});if(e.disabledOptions)for(const u of f)e.disabledOptions.includes(u.value)&&(u.disabled=!0);r(Object.freeze(f)),e.onOptionListChanged&&e.onOptionListChanged(f.length),o(f.some(u=>u.value&&!!u.value.icon)),n({pending:!1})}function Kv(e,t,n){const[r,o]=s.useState(Object.freeze([])),[a,l]=s.useState(!1),c=s.useRef(null),p=s.useRef(e.options);(typeof e.options!="function"||e.disableOptionsMemoization)&&(p.current=e.options);const m=s.useMemo(()=>typeof p.current=="function"?v.debounce(Ic,typeof e.searchDebounce<"u"?e.searchDebounce:500):Ic,[p.current,e.disabledOptions]);return s.useEffect(()=>{m(e,t,n,o,l,c)},[p.current,t.value,e.disabledOptions]),[r,a]}class xn{constructor(t,n){Vt(this,"nativeEvent");Vt(this,"currentTarget");Vt(this,"isPgStoppedInternal",!1);this.target=t,this.currentTarget=t,this.nativeEvent=new CustomEvent("change",n),Object.defineProperty(this.nativeEvent,"target",{value:t,writable:!1,configurable:!1,enumerable:!0})}get bubbles(){return this.nativeEvent.bubbles}get cancelable(){return this.nativeEvent.cancelable}get defaultPrevented(){return this.nativeEvent.defaultPrevented}get eventPhase(){return this.nativeEvent.eventPhase}get isTrusted(){return this.nativeEvent.isTrusted}get timeStamp(){return this.nativeEvent.timeStamp}get type(){return this.nativeEvent.type}preventDefault(){this.nativeEvent.preventDefault()}isDefaultPrevented(){return this.defaultPrevented}stopPropagation(){this.nativeEvent.stopPropagation(),this.isPgStoppedInternal=!0}isPropagationStopped(){return this.isPgStoppedInternal}persist(){throw new Error("This is not a real React ChangeEvent. React does not permit the creation of SyntheticEvents in userland.")}}function Hv(e,t){return{...e,...t}}function Jt(e){return _.useReducer(Hv,e)}function Wv({hideInlineSearch:e,options:t,onSearchChange:n,search:r="",searchPlaceholder:o="Search…",searchInputRef:a}){const[l,c]=Jt({isAsync:typeof t=="function",pending:!1,value:r,replacementPattern:null}),p=s.useCallback(S=>{c({value:S.target.value}),n&&n(S)},[n]),m=s.useCallback(S=>{S.nativeEvent.stopImmediatePropagation(),S.stopPropagation()},[]),f=s.useCallback(S=>{S.nativeEvent.stopImmediatePropagation(),c({value:""}),a!=null&&a.current&&(n&&n(new xn(a.current)),a.current.focus())},[n]),u=S=>{S&&(["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"].includes(S.key)||S.stopPropagation())};return s.useEffect(()=>{c({value:r})},[r]),[l.isAsync&&!e?s.createElement("div",{className:"sps-option-list__search sps-form-group sps-text-input"},s.createElement("div",{className:"sps-form-control"},!l.value&&s.createElement("i",{className:"sps-icon sps-icon-filter sps-text-input__icon"}),s.createElement("input",{type:"text",className:"sps-text-input__input",placeholder:o,ref:a,value:l.value,onChange:p,onClick:m,onKeyDown:u}),l.value&&s.createElement("i",{className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:f}))):s.createElement(s.Fragment,null),l,c]}const Gv=ao||ti,Yv=["Tab","Escape","Enter","Up","ArrowUp","Down","ArrowDown"],Uv=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];function zv(e,t,n){return n?(e&&e[n])===(t&&t[n]):e===t}function Mc(e,t,n){return typeof n.value=="function"&&n.disabled?!0:t?!!(e!=null&&e.find(r=>{var o;return r[t]&&r[t]===((o=n==null?void 0:n.value)==null?void 0:o[t])})):!1}const os=s.forwardRef((e,t)=>{const{captionKey:n,comparisonKey:r,disabledOptions:o,options:a,tall:l,textKey:c,valueKey:p,zeroState:m,hideInlineSearch:f,onSearchChange:u,search:h,searchDebounce:S,searchPlaceholder:y,onSpecialActionSelect:E,attachTo:T,className:w,conformWidth:N,id:I,ignoreWidthStyles:x,isOpen:k,keepOpen:F,keyDown:L,nullOption:C,onOptionListChanged:O,onOptionSelected:R,onPositionFlip:$,onSelfToggle:j,optionRole:M,positionOverride:Y,selectedOption:G,specialAction:z,unsafelyReplaceClassName:K,loading:J,filterByTextAndCaptionKey:re,maxHeightPx:P,maxHeightRem:U,disableOptionsMemoization:te,disableDefaultOptionsFiltering:ee,"data-testid":le,...B}=e,Z=s.useMemo(()=>z?new H.SpsOptionListOption(z,{textKey:"label",captionKey:"caption"}):null,[z]),[X,ne]=s.useState(-1),[ae,ce]=s.useState(k),oe=t||s.useRef(null),se=s.useRef(null),Ee=s.useRef(null),Be=Dr("sps-option-list-portal"),qe=s.useContext(Ot),[ct,ut]=Y||[H.Position.BOTTOM_LEFT,H.Position.TOP_LEFT],[[dt,he],ze]=s.useState([{},!1]),Ce=s.useRef(null),[ve,xe,Ze]=Wv({...e,searchInputRef:Ce}),[Ae,Xe]=Kv(e,xe,Ze);s.useEffect(()=>{ze(ae?Un(oe,T,ct,{altPosition:ut,setMinWidth:!x,setWidth:!x&&N,...qe}):[{},!1])},[ae,ct,ut,Ae]),s.useEffect(()=>{let ge;return ae&&(ge=()=>{ae&&ze(Un(oe,T,ct,{altPosition:ut,setMinWidth:!x,setWidth:!x&&N,...qe}))},document.addEventListener("scroll",ge)),()=>{ge&&document.removeEventListener("scroll",ge)}},[ae]),s.useEffect(()=>{ne(-1)},[xe]);const Yt=W(K||"sps-option-list","z-stratum-dropdown",ae&&"sps-option-list--open",xe.isAsync&&"sps-option-list--searchable",he&&"sps-option-list--opens-upward",z&&z.label&&"sps-option-list--has-special-action",w),fn=W(K||"sps-option-list__options",l&&"sps-option-list__options--tall"),pe=s.useCallback(()=>{ae||(ce(!0),Ce.current&&Ce.current.focus(),ne(-1),j&&j(!0))},[ae,j]),fe=s.useCallback(()=>{ae&&(ce(!1),ne(-1),j&&j(!1))},[ae,j]),Me=s.useCallback((ge,ye)=>{ye||ge&&!ge.disabled&&(typeof ge.value=="function"?(ge.value(),E&&E()):typeof R=="function"&&R(ge.value),F||fe())},[R,fe]),st=s.useCallback((ge,ye,je)=>{ge.stopPropagation(),Me(ye,je)},[Me]),De=s.useRef(o||[]);De.current=o||[];const mt=s.useCallback(ge=>{switch(ge.key){case"Tab":case"Escape":fe();break;case"Enter":if(X>-1){const ye=Ae[X]||Z;ge.preventDefault();const je=!!ye&&Mc(De.current,r||"",ye);!je&&ye&&typeof R=="function"&&typeof ye.value=="function"?ye.value():ye&&Me(ye,je)}break;case"Up":case"ArrowUp":{let ye=X;he?X<=-1?ye=Ae.length-1:X===0?z&&(ye=Ae.length):X<Ae.length&&(ye=X-1):X>-1&&(ye=X-1),ye!==X&&(ge.preventDefault(),ne(ye));break}case"Down":case"ArrowDown":{pe();let ye=X;he?X!==-1&&(X>=Ae.length?ye=0:X===Ae.length-1?ye=-1:ye=X+1):X<Ae.length-1+ +!!z&&(ye=X+1),ye!==X&&(ge.preventDefault(),ne(ye));break}default:pe()}},[fe,pe,X,Me,R,he,Ae]),bt=s.useCallback(ge=>{const ye=Ae.findIndex(je=>{if(je.textKey){const Bt=je.textKey;return je.value[Bt].toLowerCase().charAt([0])===ge.key.toLocaleLowerCase()}return je.value.toString().toLowerCase().charAt([0])===ge.key.toLocaleLowerCase()});ye>-1&&ne(ye)},[Ae]),Oe=s.useCallback(ge=>{ge&&(Yv.includes(ge.key)?mt(ge):Uv.includes(ge.key)&&!f&&bt(ge))},[fe,pe,X,Me,R,he,Ae]);s.useEffect(()=>{if(qe!==null&&document.getElementsByClassName("sps-modal__body").length>0){const ge=()=>{j&&j(!1)},ye=document.getElementsByClassName("sps-modal__body")[0];return ye.addEventListener("scroll",ge),()=>{ye.removeEventListener("scroll",ge)}}},[]),s.useEffect(()=>{ae&&Ee.current&&Gv(Ee.current,{scrollMode:"if-needed",block:"nearest",inline:"nearest"})},[X,ae]),s.useEffect(()=>{ce(k),k?Ce.current&&Ce.current.focus():ne(-1)},[k]),s.useEffect(()=>{L&&Oe(L)},[L]),s.useEffect(()=>{!ae&&se.current&&(Ze({value:""}),se.current.scrollTop=0),ae&&$&&$(he)},[ae]);const ot=P?P/16:U,Rn=ot?{maxHeight:`${ot}rem`}:{};function Pt(ge,ye){return ye?s.createElement(s.Fragment,null,ge.split(ye).map((je,Bt)=>ye.test(je)?s.createElement("u",{key:Bt},je):s.createElement(s.Fragment,{key:Bt},je))):s.createElement(s.Fragment,null,ge)}return Be(s.createElement("div",{className:Yt,id:I,"aria-activedescendant":X>-1?`${I}-option-${X}`:"",tabIndex:-1,ref:oe,style:dt,onMouseLeave:()=>ne(-1),"data-testid":le,...B},ve,s.createElement("div",{className:fn,ref:se,"data-testid":`${le}-options`,style:Rn},!J&&!xe.pending&&m&&Ae.length===0&&s.createElement("div",{className:"sps-option-list__zero-state"},m),(J||xe.pending)&&s.createElement("div",{className:"sps-option-list__loading"},s.createElement(ni,null)),!J&&!xe.pending&&Ae.map((ge,ye)=>{const je=`${I}-option-${ye}`,Bt=zv(ge.value,G,r),On=Mc(De.current,r||"",ge);return s.createElement("a",{key:je,id:je,role:M,"aria-selected":Bt,href:ge.href,className:W("sps-option-list__option",ge.caption&&"sps-option-list__option--has-caption",ge.disabled&&"sps-option-list__option--disabled",ge.bold&&"sps-option-list__option--bold",(Bt||On)&&"sps-option-list__option--selected",X===ye&&"sps-option-list__option--highlighted"),onClick:ue=>st(ue,ge,On),onMouseOver:()=>ne(ye),tabIndex:-1,ref:X===ye?Ee:null,"data-testid":`${le}-option-${ye}`},ge.value&&ge.value.icon&&s.createElement("i",{className:W("sps-icon","sps-option-list__option-icon",`sps-icon-${String(ge.value.icon)}`)}),(!ge.value||!ge.value.icon&&Xe)&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",null,Pt(ge.text,xe.replacementPattern)),ge.caption&&s.createElement("div",{className:"sps-option-list__option-caption"},s.createElement("span",null,Pt(ge.caption,xe.replacementPattern))))})),Z&&(z==null?void 0:z.label)&&s.createElement("a",{className:W("sps-option-list__option","sps-option-list__special-action",X===Ae.length&&"sps-option-list__option--highlighted",z.disabled&&"sps-option-list__special-action--disabled"),href:Z.href,target:Z.href&&z.newTab?"_blank":"_self",onClick:ge=>st(ge,Z),onMouseOver:()=>ne(Ae.length),"data-testid":`${le}-special-action`},z.icon&&s.createElement("i",{className:W("sps-icon","sps-option-list__option-icon",`sps-icon-${String(z.icon)}`)}),!z.icon&&Xe&&s.createElement("span",{className:"sps-option-list__option-icon-spacer"}),s.createElement("span",null,z.label))))});Object.assign(os,{displayName:"SpsOptionList"});function jv(e,t,n=[]){return s.useMemo(()=>{function r(o){return s.createElement(e,{...o,...t},o.children)}return r},n)}function yt(e){return typeof e=="function"?e():e}const xp=function({children:e,elements:t}){if(t.length===0)return s.createElement(s.Fragment,null,e);const[n,r]=Array.isArray(t[0])?t[0]:[t[0]];return s.createElement(n,{...r??{}},s.createElement(xp,{elements:t.slice(1)},e))},kp=function({children:e,providers:t=[],...n}){return s.createElement("div",{...n},s.createElement(xp,{elements:t},e))},qv=function({children:e,className:t,...n}){return s.createElement(kp,{className:`sps-app ${t}`,...n},e)};function Lt(e=[],t=[]){const n=Array.isArray(e)?v.flatten(e):[e],r=t.map(a=>Array.isArray(a)?a:[a]),o=new Array(r.length+1).fill(null).map(()=>[]);for(const a of n){let l=!1;for(let c=0;c<r.length;c+=1)for(const{type:p,props:m={}}of r[c])if(a.type===p&&Object.keys(m).every(u=>m[u]===a.props[u])){l=!0,o[c].push(a);break}l||o[o.length-1].push(a)}return o}function Ip(e,t,n){const r=Object.entries(t).filter(([,a])=>typeof a!="string"&&a.deprecated).map(([a])=>a),o=r.map(a=>n[a]);s.useEffect(()=>{o.find(a=>typeof a<"u")&&console.warn(`The following prop(s) of ${e} are deprecated: ${r.join(", ")}`)},o)}function si(e,t){const n=_.useRef(!1);_.useEffect(()=>{if(n.current)return e();n.current=!0},t)}function Oa(e,t,n){const r=s.useRef(t(...n));s.useEffect(()=>(document.addEventListener(e,r.current),()=>document.removeEventListener(e,r.current)),[]),s.useEffect(()=>{document.removeEventListener(e,r.current),r.current=t(...n),document.addEventListener(e,r.current)},n)}function _c(e,t,n){return function(o){var a,l;!((a=e.current)!=null&&a.contains(o.target))&&!((l=t.current)!=null&&l.contains(o.target))&&n()}}function Nr(e,t,n){const r=s.useRef(!1),[o,a]=s.useState(!1),l=s.useCallback(()=>{r.current?r.current=!1:a(!0)},[]),c=s.useCallback((p=!1)=>{a(!1),r.current=p,n&&n()},[]);return Oa("mousedown",_c,[e,t,c]),Oa("pointerdown",_c,[e,t,c]),{showPopup:o,doShowPopup:l,doHidePopup:c}}const Mp=e=>{const t=/(auto|scroll)/,n=(c,p)=>c.parentNode===null?p:n(c.parentNode,p.concat([c])),r=(c,p)=>getComputedStyle(c,null).getPropertyValue(p),o=c=>r(c,"overflow")+r(c,"overflow-y"),a=c=>t.test(o(c));return(c=>{if(!(c instanceof HTMLElement||c instanceof SVGElement))return;const p=n(c.parentNode,[]);for(let m=0;m<p.length;m+=1)if(a(p[m]))return p[m];return null})(e)};let Xo=0;function io({isOpen:e,rootRef:t}){s.useLayoutEffect(()=>{let n,r,o;if(e&&t.current){Xo+=1,n=Mp(t.current)||document.body,r=n===document.body?window.innerWidth-document.documentElement.clientWidth:n.offsetWidth-n.clientWidth,n.style.overflow="hidden";const a=window.getComputedStyle(n).paddingRight;if(n.style.paddingRight=a&&a!=="0px"?`calc(${a} + ${r}px)`:`${r}px`,n===document.body)if(o=document.getElementsByClassName("sps-navbar-container").item(0),o&&window.getComputedStyle(o).position==="fixed"){const l=window.getComputedStyle(o).paddingRight;o.style.paddingRight=l&&l!=="0px"?`calc(${l} + ${r}px)`:`${r}px`}else{const l=document.getElementsByTagName("nav").item(0);if(o=l==null?void 0:l.parentElement,o&&window.getComputedStyle(o).position==="fixed"){const c=window.getComputedStyle(o).paddingRight;o.style.paddingRight=c&&c!=="0px"?`calc(${c} + ${r}px)`:`${r}px`}}}return()=>{n&&(Xo-=1,Xo===0&&(n.style.overflow=null,n.style.paddingRight=null,o&&(o.style.paddingRight=null)))}},[e])}const Jv={debounce:"number",disabled:"boolean",formMeta:"SpsFormFieldMeta<string>",icon:"SpsIcon",onChange:"React.ChangeEventHandler",onSelectionChange:"(newValue: string) => void",placeholder:"string",suggestions:{type:`
2
2
  Eventually<Iterable<string>>
3
3
  | ((filter?: string) => Eventually<Iterable<string>>)
4
4
  `,required:!0},tallOptionList:"boolean",value:"string",zeroState:"string",loading:"boolean",maxHeightOptionListPx:"number",maxHeightOptionListRem:"number",disableOptionsMemoization:"boolean",inputNotClearable:"boolean",autoFocusOnSelection:"boolean"};function jt({className:e,debounce:t=0,disabled:n,formControl:r,formMeta:o,onChange:a,onSelectionChange:l,icon:c,id:p,placeholder:m="",suggestions:f,unsafelyReplaceClassName:u,tallOptionList:h,value:S="",zeroState:y,loading:E,maxHeightOptionListPx:T,maxHeightOptionListRem:w,disableOptionsMemoization:N,inputNotClearable:I,autoFocusOnSelection:x,"data-testid":k,...F}){const L=o||r,{wrapperId:C,controlId:O}=Tt(p,L),[R,$]=Jt({keyDown:null,opensUpward:!1}),j=s.useRef(null),M=s.useRef(null),Y=s.useRef(null),{showPopup:G,doShowPopup:z,doHidePopup:K}=Nr(j,Y);function J(B,Z,X=!1){L&&(L.setValue(B),L.markAsDirty()),l&&X?l(B):a&&a(Z||new xn({value:B}))}function re(B){M.current&&(M.current.value="",J("")),B.stopPropagation()}function P(B){J(B.target.value,B)}function U(B){n||(["Up","ArrowUp","Down","ArrowDown","Enter"].indexOf(B.key)>-1&&(B.preventDefault(),B.persist()),B.stopPropagation(),$({keyDown:B})),B.key==="Tab"&&K()}function te(B){B?z():K()}function ee(B){$({opensUpward:B})}const le=W(u||"sps-autocomplete",G&&"sps-autocomplete--open",G&&"z-stratum-dropdown",R.opensUpward&&"sps-autocomplete--opens-upward",n&&"sps-form-control--disabled",e);return s.useEffect(()=>{let B;return G&&(B=()=>{K()},window.addEventListener("resize",B)),()=>{B&&window.removeEventListener("resize",B)}},[G]),io({isOpen:G,rootRef:j}),s.createElement(lt,{id:C,className:le,formControl:r,formMeta:o,inputRef:M,ref:j,focusInputOnClick:!0,onClick:B=>B.nativeEvent.stopImmediatePropagation(),"data-testid":`${k}`},s.createElement("div",{className:"sps-text-input"},s.createElement("div",{className:"sps-form-control"},c&&s.createElement("i",{className:W("sps-text-input__icon","sps-icon",`sps-icon-${c}`)}),s.createElement("input",{type:"text",ref:M,value:S,className:"sps-text-input__input",placeholder:m,onFocus:z,onClick:z,onChange:P,onKeyDown:U,disabled:n,id:O,"data-testid":`${k}__input`,...F}),S&&!n&&!I&&s.createElement("i",{"aria-label":"clear",className:"sps-icon sps-icon-x-circle sps-form-control__clear-btn",onClick:B=>re(B)}))),s.createElement(os,{id:`${C}_options`,ref:Y,attachTo:j,isOpen:G,options:f,hideInlineSearch:!0,keyDown:R.keyDown,onOptionSelected:B=>{var Z;J(B,void 0,!0),x&&((Z=M.current)==null||Z.focus())},onPositionFlip:ee,onSelfToggle:te,offsets:[1,0],search:S,searchDebounce:t,tall:h,zeroState:y,loading:E,maxHeightPx:T,maxHeightRem:w,disableOptionsMemoization:N}))}Object.assign(jt,{props:Jv,displayName:"SpsAutocomplete"});const _p={basic:{label:"Basic",examples:{basic:{react:v.code`
@@ -4843,7 +4843,7 @@ var r=n.defineLocale("zh-tw",{months:"一月_二月_三月_四月_五月_六月_
4843
4843
  import { FeedbackBlockKind } from "@spscommerce/ds-shared";
4844
4844
  `,jsx:v.code`
4845
4845
  <SpsMicroBlock kind={FeedbackBlockKind.TIP} message="Pro Tip: Don't be a loser."/>
4846
- `}}}},UN={kind:"ModalKind",size:"ModalSize",title:"string",onClose:"() => void",focusElementOnOpen:"React.MutableRefObject<HTMLElement>",fullHeight:"boolean"};function wo({children:e}){return s.createElement("div",{className:"sps-modal__footer"},e)}Object.assign(wo,{props:{},propTypes:{},displayName:"SpsModalFooter"});function Xi({children:e,className:t,id:n,kind:r=H.ModalKind.GENERAL,size:o=H.ModalSize.SMALL,onClose:a,focusElementOnOpen:l,title:c,fullHeight:p=!1,...m}){const f=Dn(n),u=W("sps-modal","z-stratum-dialog",`sps-modal--${r}`,`sps-modal--${o}`,t),{t:h}=s.useContext(Ke),S=s.useRef(null),y=s.useRef(document.body.style.paddingRight||""),E=s.useRef(document.body.style.overflow||"");E.current==="hidden"&&(E.current="",y.current=""),s.useLayoutEffect(()=>{let I=!1;if(document.body.style.overflow!=="hidden"){const x=`${window.innerWidth-document.body.clientWidth}px`;document.body.style.paddingRight=x,document.body.style.overflow="hidden",I=!0}return()=>{I&&(document.body.style.overflow=E.current,document.body.style.paddingRight=y.current)}},[]),s.useEffect(()=>{l&&l.current?l.current.focus():S.current&&S.current.focus()},[l]);const T=s.useCallback(I=>{if(I&&I.key==="Escape"&&a&&a(),I&&I.key==="Tab"&&S.current){const x=S.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),k=x[0],F=x[x.length-1];x.length===0?I.preventDefault():I.shiftKey&&I.target===k?(I.preventDefault(),F.focus()):!I.shiftKey&&I.target===F&&(I.preventDefault(),k.focus())}},[a]),[[w],N]=Lt(e,[{type:wo}]);return s.createElement("div",{id:f.current,role:"dialog","aria-modal":!0,"aria-labelledby":`${f.current}-title`,className:u,onKeyDown:T,tabIndex:-1,ref:S},s.createElement("div",{...m,className:W("sps-modal__dialog",{"sps-modal__dialog-full-height":p})},s.createElement("div",{className:"sps-modal__titlebar"},s.createElement("div",{className:"sps-modal__title",id:`${f.current}-title`},c||h(`design-system:modal.defaultTitle.${r}`)),a&&s.createElement("div",{className:"sps-button sps-button--icon",onClick:a},s.createElement("button",{"aria-label":h("design-system:modal.close"),type:"button"},s.createElement("i",{className:"sps-icon sps-icon-x"})))),s.createElement("div",{className:"sps-modal__body"},s.createElement(Ot.Provider,{value:{parentElementRef:S,fixed:!0}},N)),w||s.createElement("div",{className:"sps-modal__footer"},s.createElement(Ue,{kind:r===H.ModalKind.SERIOUS_WARNING?H.ButtonKind.DELETE:H.ButtonKind.KEY,onClick:a},h("design-system:modal.defaultButtonLabel")))))}Object.assign(Xi,{props:UN,displayName:"SpsModal"});const zN={title:"string",show:"boolean",closeOnEscapePressed:"boolean",onClose:"() => void",focusElementOnOpen:"React.MutableRefObject<HTMLElement>"};function Qi({children:e,className:t,id:n,show:r,closeOnEscapePressed:o=!0,onClose:a,focusElementOnOpen:l,title:c,...p}){const m=Dn(n),f=W("sps-slide-in-panel","z-stratum-dialog",r?"open":"",t),u=s.useRef(document.body.style.overflow||""),h=s.useRef(document.body.style.paddingRight||""),{t:S}=s.useContext(Ke),y=s.useRef(null);s.useEffect(()=>{if(r){const w=`${window.innerWidth-document.body.clientWidth}px`;document.body.style.paddingRight=w,document.body.style.overflow="hidden"}else document.body.style.overflow=u.current,document.body.style.paddingRight=h.current;return()=>{document.body.style.overflow=u.current,document.body.style.paddingRight=h.current}},[r]),s.useEffect(()=>{l&&l.current?l.current.focus():y.current&&y.current.focus()},[l]);const E=s.useCallback(w=>{if(o&&w&&w.key==="Escape"&&a&&a(),w&&w.key==="Tab"&&y.current){const N=y.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),I=N[0],x=N[N.length-1];N.length===0?w.preventDefault():w.shiftKey&&w.target===I?(w.preventDefault(),x.focus()):!w.shiftKey&&w.target===x&&(w.preventDefault(),I.focus())}},[a]);s.useEffect(()=>(window.addEventListener("keydown",E),()=>{window.removeEventListener("keydown",E)}),[E]);const[T]=Lt(e);return s.createElement("div",{id:m.current,role:"dialog","aria-labelledby":`${m.current}-title`,className:f,tabIndex:-1,ref:y},s.createElement("div",{...p,className:`sps-slide-in-panel__dialog ${r?"open":""}`},s.createElement("div",{className:"sps-slide-in-panel__titlebar"},s.createElement("div",{className:"sps-slide-in-panel__title",id:`${m.current}-title`},c||S("design-system:slideInPanel.defaultTitle")),a&&s.createElement("div",{className:"sps-button sps-button--icon",onClick:a},s.createElement("button",{"aria-label":S("design-system:slideInPanel.close"),type:"button"},s.createElement("i",{className:"sps-icon sps-icon-x"})))),s.createElement("div",{className:"sps-slide-in-panel__body"},s.createElement(Ot.Provider,{value:{parentElementRef:y,fixed:!0}},T))))}Object.assign(Qi,{props:zN,displayName:"SpsSlideInPanel"});const Hm={generalUsage:{label:"General Usage",description:()=>s.createElement(s.Fragment,null),examples:{noCloseButton:{description:()=>s.createElement(s.Fragment,null,s.createElement("p",null,"Click on the button below to show the slide-in panel.")),react:v.code`
4846
+ `}}}},UN={kind:"ModalKind",size:"ModalSize",title:"string",onClose:"() => void",focusElementOnOpen:"React.MutableRefObject<HTMLElement>",fullHeight:"boolean"};function wo({children:e}){return s.createElement("div",{className:"sps-modal__footer"},e)}Object.assign(wo,{props:{},propTypes:{},displayName:"SpsModalFooter"});function Xi({children:e,className:t,id:n,kind:r=H.ModalKind.GENERAL,size:o=H.ModalSize.SMALL,onClose:a,focusElementOnOpen:l,title:c,fullHeight:p=!1,...m}){const f=Dn(n),u=W("sps-modal","z-stratum-dialog",`sps-modal--${r}`,`sps-modal--${o}`,t),{t:h}=s.useContext(Ke),S=s.useRef(null),y=s.useRef(document.body.style.paddingRight||""),E=s.useRef(document.body.style.overflow||"");E.current==="hidden"&&(E.current="",y.current=""),s.useLayoutEffect(()=>{let I=!1;if(document.body.style.overflow!=="hidden"){const x=`${window.innerWidth-document.body.clientWidth}px`;document.body.style.paddingRight=x,document.body.style.overflow="hidden",I=!0}return()=>{I&&(document.body.style.overflow=E.current,document.body.style.paddingRight=y.current)}},[]),s.useEffect(()=>{l&&l.current?l.current.focus():S.current&&S.current.focus()},[l]);const T=s.useCallback(I=>{if(I&&I.key==="Escape"&&a&&a(),I&&I.key==="Tab"&&S.current){const x=S.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),k=x[0],F=x[x.length-1];x.length===0?I.preventDefault():I.shiftKey&&I.target===k?(I.preventDefault(),F.focus()):!I.shiftKey&&I.target===F&&(I.preventDefault(),k.focus())}},[a]),[[w],N]=Lt(e,[{type:wo}]);return s.createElement("div",{id:f.current,role:"dialog","aria-modal":!0,"aria-labelledby":`${f.current}-title`,className:u,onKeyDown:T,tabIndex:-1,ref:S},s.createElement("div",{...m,className:W("sps-modal__dialog",{"sps-modal__dialog-full-height":p})},s.createElement("div",{className:"sps-modal__titlebar"},s.createElement("div",{className:"sps-modal__title",id:`${f.current}-title`},c||h(`design-system:modal.defaultTitle.${r}`)),a&&s.createElement("div",{className:"sps-button sps-button--icon",onClick:a},s.createElement("button",{"aria-label":h("design-system:modal.close"),type:"button"},s.createElement("i",{className:"sps-icon sps-icon-x"})))),s.createElement("div",{className:"sps-modal__body"},s.createElement(Ot.Provider,{value:{parentElementRef:S,fixed:!0}},N)),w||s.createElement("div",{className:"sps-modal__footer"},s.createElement(Ue,{kind:r===H.ModalKind.SERIOUS_WARNING?H.ButtonKind.DELETE:H.ButtonKind.KEY,onClick:a},h("design-system:modal.defaultButtonLabel")))))}Object.assign(Xi,{props:UN,displayName:"SpsModal"});const zN={title:"string",show:"boolean",closeOnEscapePressed:"boolean",onClose:"() => void",focusElementOnOpen:"React.MutableRefObject<HTMLElement>"};function Qi({children:e,className:t,id:n,show:r,closeOnEscapePressed:o=!0,onClose:a,focusElementOnOpen:l,title:c,...p}){const m=Dn(n),f=W("sps-slide-in-panel","z-stratum-dialog",r?"open":"",t),{t:u}=s.useContext(Ke),h=s.useRef(null),S=s.useRef(document.body.style.paddingRight||""),y=s.useRef(document.body.style.overflow||"");y.current==="hidden"&&(y.current="",S.current=""),s.useLayoutEffect(()=>{let w=!1;if(r&&document.body.style.overflow!=="hidden"){const N=`${window.innerWidth-document.body.clientWidth}px`;document.body.style.paddingRight=N,document.body.style.overflow="hidden",w=!0}return()=>{w&&(document.body.style.overflow=y.current,document.body.style.paddingRight=S.current)}},[r]),s.useEffect(()=>{l&&l.current?l.current.focus():h.current&&h.current.focus()},[l]);const E=s.useCallback(w=>{if(o&&w&&w.key==="Escape"&&a&&a(),w&&w.key==="Tab"&&h.current){const N=h.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),I=N[0],x=N[N.length-1];N.length===0?w.preventDefault():w.shiftKey&&w.target===I?(w.preventDefault(),x.focus()):!w.shiftKey&&w.target===x&&(w.preventDefault(),I.focus())}},[a]);s.useEffect(()=>(window.addEventListener("keydown",E),()=>{window.removeEventListener("keydown",E)}),[E]);const[T]=Lt(e);return s.createElement("div",{id:m.current,role:"dialog","aria-labelledby":`${m.current}-title`,className:f,tabIndex:-1,ref:h},s.createElement("div",{...p,className:`sps-slide-in-panel__dialog ${r?"open":""}`},s.createElement("div",{className:"sps-slide-in-panel__titlebar"},s.createElement("div",{className:"sps-slide-in-panel__title",id:`${m.current}-title`},c||u("design-system:slideInPanel.defaultTitle")),a&&s.createElement("div",{className:"sps-button sps-button--icon",onClick:a},s.createElement("button",{"aria-label":u("design-system:slideInPanel.close"),type:"button"},s.createElement("i",{className:"sps-icon sps-icon-x"})))),s.createElement("div",{className:"sps-slide-in-panel__body"},s.createElement(Ot.Provider,{value:{parentElementRef:h,fixed:!0}},T))))}Object.assign(Qi,{props:zN,displayName:"SpsSlideInPanel"});const Hm={generalUsage:{label:"General Usage",description:()=>s.createElement(s.Fragment,null),examples:{noCloseButton:{description:()=>s.createElement(s.Fragment,null,s.createElement("p",null,"Click on the button below to show the slide-in panel.")),react:v.code`
4847
4847
  import { SpsButton, SpsSlideInPanel } from "@spscommerce/ds-react";
4848
4848
  import { ButtonKind } from "@spscommerce/ds-shared";
4849
4849
  function Component() {