@pure-ds/core 0.7.1 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/.cursorrules +38 -1
  2. package/.github/copilot-instructions.md +32 -0
  3. package/custom-elements.json +77 -46
  4. package/dist/types/public/assets/js/pds-manager.d.ts +1 -1
  5. package/dist/types/public/assets/js/pds-manager.d.ts.map +1 -1
  6. package/dist/types/public/assets/js/pds.d.ts.map +1 -1
  7. package/dist/types/src/js/pds-core/pds-live.d.ts.map +1 -1
  8. package/dist/types/src/js/pds-core/pds-start-helpers.d.ts.map +1 -1
  9. package/package.json +1 -1
  10. package/packages/pds-cli/bin/pds-static.js +13 -2
  11. package/packages/pds-cli/bin/sync-assets.js +34 -0
  12. package/public/assets/js/app.js +1543 -4
  13. package/public/assets/js/app.js.map +7 -0
  14. package/public/assets/js/lit.js +1078 -3
  15. package/public/assets/js/lit.js.map +7 -0
  16. package/public/assets/js/pds-ask.js +239 -9
  17. package/public/assets/js/pds-ask.js.map +7 -0
  18. package/public/assets/js/pds-auto-definer.js +306 -1
  19. package/public/assets/js/pds-autocomplete.js +590 -7
  20. package/public/assets/js/pds-autocomplete.js.map +7 -0
  21. package/public/assets/js/pds-enhancers.js +689 -1
  22. package/public/assets/js/pds-enhancers.js.map +7 -0
  23. package/public/assets/js/pds-manager.js +15914 -3101
  24. package/public/assets/js/pds-manager.js.map +7 -0
  25. package/public/assets/js/pds-toast.js +30 -1
  26. package/public/assets/js/pds-toast.js.map +7 -0
  27. package/public/assets/js/pds.js +1409 -2
  28. package/public/assets/js/pds.js.map +7 -0
  29. package/public/assets/pds/components/pds-scrollrow.js +2 -4
  30. package/public/assets/pds/core/pds-ask.js +239 -9
  31. package/public/assets/pds/core/pds-auto-definer.js +306 -1
  32. package/public/assets/pds/core/pds-autocomplete.js +590 -7
  33. package/public/assets/pds/core/pds-enhancers.js +689 -1
  34. package/public/assets/pds/core/pds-manager.js +15914 -3101
  35. package/public/assets/pds/core/pds-toast.js +30 -1
  36. package/public/assets/pds/core.js +1409 -2
  37. package/public/assets/pds/custom-elements.json +77 -46
  38. package/public/assets/pds/external/lit.js +1078 -3
  39. package/public/assets/pds/pds-css-complete.json +2 -2
  40. package/public/assets/pds/pds.css-data.json +1 -1
  41. package/public/assets/pds/vscode-custom-data.json +5 -13
  42. package/src/js/pds-core/pds-live.js +0 -3
  43. package/src/js/pds-core/pds-start-helpers.js +13 -25
  44. package/src/js/pds.js +0 -4
@@ -1,12 +1,1551 @@
1
- var ge=Object.defineProperty;var be=(e,t)=>{for(var s in t)ge(e,s,{get:t[s],enumerable:!0})};var F=class{constructor(){this._mode="static",this._staticPaths={tokens:"/assets/pds/styles/pds-tokens.css.js",primitives:"/assets/pds/styles/pds-primitives.css.js",components:"/assets/pds/styles/pds-components.css.js",utilities:"/assets/pds/styles/pds-utilities.css.js",styles:"/assets/pds/styles/pds-styles.css.js"}}setLiveMode(){this._mode="live"}setStaticMode(t={}){this._mode="static",this._staticPaths={...this._staticPaths,...t}}async getStylesheet(t){if(this._mode==="live")return null;try{return(await import(this._staticPaths[t]))[t]}catch(s){console.error(`[PDS Registry] Failed to load static ${t}:`,s),console.error(`[PDS Registry] Looking for: ${this._staticPaths[t]}`),console.error("[PDS Registry] Make sure you've run 'npm run pds:build' and configured PDS.start() with the correct static.root path");let n=new CSSStyleSheet;return n.replaceSync("/* Failed to load "+t+" */"),n}}get mode(){return this._mode}get isLive(){return this._mode==="live"}},_=new F;async function Y(e,t=[],s=null){try{let n=s?.primitivesStylesheet?s.primitivesStylesheet:await _.getStylesheet("primitives");e.adoptedStyleSheets=[n,...t]}catch(n){let a=e.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${a}> failed to adopt primitives:`,n),e.adoptedStyleSheets=t}}async function Z(e,t=["primitives"],s=[],n=null){try{let o=(await Promise.all(t.map(async c=>{if(n)switch(c){case"tokens":return n.tokensStylesheet;case"primitives":return n.primitivesStylesheet;case"components":return n.componentsStylesheet;case"utilities":return n.utilitiesStylesheet;default:break}return _.getStylesheet(c)}))).filter(c=>c!==null);e.adoptedStyleSheets=[...o,...s]}catch(a){let o=e.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${o}> failed to adopt layers:`,a),e.adoptedStyleSheets=s}}function ee(e){let t=new CSSStyleSheet;return t.replaceSync(e),t}var te={FontWeights:{light:300,normal:400,medium:500,semibold:600,bold:700},LineHeights:{tight:1.25,normal:1.5,relaxed:1.75},BorderWidths:{hairline:.5,thin:1,medium:2,thick:3},RadiusSizes:{none:0,small:4,medium:8,large:16,xlarge:24,xxlarge:32},ShadowDepths:{none:"none",light:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",medium:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",deep:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",extreme:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"},TransitionSpeeds:{fast:150,normal:250,slow:350},AnimationEasings:{linear:"linear",ease:"ease","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out",bounce:"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},TouchTargetSizes:{compact:36,standard:44,comfortable:48,spacious:56},LinkStyles:{inline:"inline",block:"block",button:"button"},FocusStyles:{ring:"ring",outline:"outline",border:"border",glow:"glow"},TabSizes:{compact:2,standard:4,wide:8},SelectIcons:{chevron:"chevron",arrow:"arrow",caret:"caret",none:"none"},IconSizes:{xs:16,sm:20,md:24,lg:32,xl:48,"2xl":64,"3xl":96}};var B={};be(B,{deepMerge:()=>se,fragmentFromTemplateLike:()=>we,isObject:()=>P,parseHTML:()=>W});function P(e){return e&&typeof e=="object"&&!Array.isArray(e)}function se(e,t){let s={...e};return P(e)&&P(t)&&Object.keys(t).forEach(n=>{P(t[n])?n in e?s[n]=se(e[n],t[n]):Object.assign(s,{[n]:t[n]}):Object.assign(s,{[n]:t[n]})}),s}function we(e){let t=Array.isArray(e?.strings)?e.strings:[],s=Array.isArray(e?.values)?e.values:[],n=new Set,a=[],o=/(\s)(\.[\w-]+)=\s*$/;for(let i=0;i<t.length;i+=1){let l=t[i]??"",p=l.match(o);if(p&&i<s.length){let u=p[2].slice(1),f=`pds-val-${i}`;l=l.replace(o,`$1data-pds-prop="${u}:${f}"`),n.add(i)}a.push(l),i<s.length&&!n.has(i)&&a.push(`<!--pds-val-${i}-->`)}let c=document.createElement("template");c.innerHTML=a.join("");let m=(i,l)=>{let p=i.parentNode;if(!p)return;if(l==null){p.removeChild(i);return}let b=u=>{if(u!=null){if(u instanceof Node){p.insertBefore(u,i);return}if(Array.isArray(u)){u.forEach(f=>b(f));return}p.insertBefore(document.createTextNode(String(u)),i)}};b(l),p.removeChild(i)},v=document.createTreeWalker(c.content,NodeFilter.SHOW_COMMENT),S=[];for(;v.nextNode();){let i=v.currentNode;i?.nodeValue?.startsWith("pds-val-")&&S.push(i)}return S.forEach(i=>{let l=Number(i.nodeValue.replace("pds-val-",""));m(i,s[l])}),c.content.querySelectorAll("*").forEach(i=>{let l=i.getAttribute("data-pds-prop");if(!l)return;let[p,b]=l.split(":"),u=Number(String(b).replace("pds-val-",""));p&&Number.isInteger(u)&&(i[p]=s[u]),i.removeAttribute("data-pds-prop")}),c.content}function W(e){return new DOMParser().parseFromString(e,"text/html").body.childNodes}var re="pds",Se=/^([a-z][a-z0-9+\-.]*:)?\/\//i,ne=/^[a-z]:/i;function A(e=""){return e.endsWith("/")?e:`${e}/`}function Ee(e="",t=re){let s=e.replace(/\/+$/,"");return new RegExp(`(?:^|/)${t}$`,"i").test(s)?s:`${s}/${t}`}function ve(e){return e.replace(/^\.\/+/,"")}function Le(e){return ne.test(e)?e.replace(ne,"").replace(/^\/+/,""):e}function _e(e){return e.startsWith("public/")?e.substring(7):e}function M(e,t={}){let s=t.segment||re,n=t.defaultRoot||`/assets/${s}/`,a=e?.public&&e.public?.root||e?.static&&e.static?.root||null;if(!a||typeof a!="string")return A(n);let o=a.trim();return o?(o=o.replace(/\\/g,"/"),o=Ee(o,s),o=A(o),Se.test(o)?o:(o=ve(o),o=Le(o),o.startsWith("/")||(o=_e(o),o.startsWith("/")||(o=`/${o}`),o=o.replace(/\/+/g,(c,m)=>m===0?c:"/")),A(o))):A(n)}var ke=/^[a-z][a-z0-9+\-.]*:\/\//i,x=(()=>{try{return import.meta.url}catch{return}})(),T=e=>typeof e=="string"&&e.length&&!e.endsWith("/")?`${e}/`:e;function U(e,t={}){if(!e||ke.test(e))return e;let{preferModule:s=!0}=t,n=()=>{if(!x)return null;try{return new URL(e,x).href}catch{return null}},a=()=>{if(typeof window>"u"||!window.location?.origin)return null;try{return new URL(e,window.location.origin).href}catch{return null}};return(s?n()||a():a()||n())||e}var oe=(()=>{if(x)try{let e=new URL(x);if(/\/public\/assets\/js\//.test(e.pathname))return new URL("../pds/",x).href}catch{return}})(),ie=!1;function ae(e){ie||typeof document>"u"||(ie=!0,e.addEventListener("pds:ready",t=>{let s=t.detail?.mode;s&&document.documentElement.classList.add(`pds-${s}`,"pds-ready")}))}function ce({manageTheme:e,themeStorageKey:t,applyResolvedTheme:s,setupSystemListenerIfNeeded:n}){let a="light",o=null;if(e&&typeof window<"u"){try{o=localStorage.getItem(t)||null}catch{o=null}try{s?.(o),n?.(o)}catch{}o?o==="system"?a=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":a=o:a=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return{resolvedTheme:a,storedTheme:o}}function C(e,{resolvePublicAssetURL:t}){let s=!!(e?.public?.root||e?.static?.root),n=t(e);return!s&&oe&&(n=oe),T(U(n))}async function de(e,{baseEnhancers:t=[]}={}){let{autoDefineBaseURL:s="/auto-define/",autoDefinePreload:n=[],autoDefineMapper:a=null,autoDefinerModuleURL:o=null,enhancers:c=[],autoDefineOverrides:m=null,autoDefinePreferModule:v=!0}=e,S=(()=>{let i=new Map;return(t||[]).forEach(l=>i.set(l.selector,l)),(c||[]).forEach(l=>i.set(l.selector,l)),Array.from(i.values())})(),y=null;if(typeof window<"u"&&typeof document<"u"){let i=null;try{if(!o||typeof o!="string")throw new Error("AutoDefiner module URL is not configured");let d=await import(o);i=d?.AutoDefiner||d?.default?.AutoDefiner||d?.default||null}catch(d){console.warn("AutoDefiner not available:",d?.message||d)}let l=d=>{switch(d){case"pds-tabpanel":return"pds-tabstrip.js";default:return`${d}.js`}},{mapper:p,...b}=m&&typeof m=="object"?m:{},f={baseURL:s&&T(U(s,{preferModule:v})),predefine:n,scanExisting:!0,observeShadows:!0,patchAttachShadow:!0,debounceMs:16,enhancers:S,onError:(d,h)=>{if(typeof d=="string"&&d.startsWith("pds-")){let L=["pds-form","pds-drawer"].includes(d),z=h?.message?.includes("#pds/lit")||h?.message?.includes("Failed to resolve module specifier");L&&z?console.error(`\u274C PDS component <${d}> requires Lit but #pds/lit is not in import map.
2
- See: https://github.com/Pure-Web-Foundation/pure-ds/blob/main/readme.md#lit-components-not-working`):console.warn(`\u26A0\uFE0F PDS component <${d}> not found. Assets may not be installed.`)}else console.error(`\u274C Auto-define error for <${d}>:`,h)},...b,mapper:d=>{if(customElements.get(d))return null;if(typeof a=="function")try{let h=a(d);return h===void 0?l(d):h}catch(h){return console.warn("Custom autoDefine.mapper error; falling back to default:",h?.message||h),l(d)}return l(d)}};i&&(y=new i(f),n.length>0&&typeof i.define=="function"&&await i.define(...n,{baseURL:s,mapper:f.mapper,onError:f.onError}))}return{autoDefiner:y,mergedEnhancers:S}}var H=["light","dark"],V=new Set(H);function Ae(e){let s=(Array.isArray(e?.themes)?e.themes.map(n=>String(n).toLowerCase()):H).filter(n=>V.has(n));return s.length?s:H}function K(e,{preferDocument:t=!0}={}){let s=String(e||"").toLowerCase();if(V.has(s))return s;if(t&&typeof document<"u"){let n=document.documentElement?.getAttribute("data-theme");if(V.has(n))return n}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function le(e,t){let s=K(t);return Ae(e).includes(s)}var G=class extends EventTarget{},r=new G;r.initializing=!1;r.currentPreset=null;r.debug=!1;var I=null,$=null,N=null,O=null;function j(e,t){return t&&typeof t=="string"?t:`${C(r.currentConfig||{},{resolvePublicAssetURL:M})}core/${e}`}async function xe(){return Array.isArray(r.defaultEnhancers)&&r.defaultEnhancers.length>0?r.defaultEnhancers:(O||(O=import(j("pds-enhancers.js",r.currentConfig?.enhancersURL)).then(t=>{let s=Array.isArray(t?.defaultPDSEnhancers)?t.defaultPDSEnhancers:[];return r.defaultEnhancers=s,s}).catch(t=>{throw O=null,t})),O)}async function De(){return typeof r.ask=="function"&&r.ask!==ue?r.ask:($||($=import(j("pds-ask.js",r.currentConfig?.askURL)).then(t=>{let s=t?.ask;if(typeof s!="function")throw new Error("Failed to load ask helper");return r.ask=s,s}).catch(t=>{throw $=null,t})),$)}async function R(){return typeof r.toast=="function"&&r.toast!==k?r.toast:(N||(N=import(j("pds-toast.js",r.currentConfig?.toastURL)).then(t=>{let s=t?.toast;if(typeof s!="function")throw new Error("Failed to load toast helper");return r.toast=s,s}).catch(t=>{throw N=null,t})),N)}async function ue(...e){return(await De())(...e)}async function k(...e){return(await R())(...e)}k.success=async(...e)=>(await R()).success(...e);k.error=async(...e)=>(await R()).error(...e);k.warning=async(...e)=>(await R()).warning(...e);k.info=async(...e)=>(await R()).info(...e);var pe=function(e="log",t,...s){let n=!!(r.registry&&!r.registry.isLive),a=(this?.debug||this?.design?.debug||r.debug||!1)===!0;if(n){if(!r.debug)return}else if(!a&&e!=="error"&&e!=="warn")return;let o=console[e]||console.log;s.length>0?o(t,...s):o(t)};function Q(e){if(e==null)return e;if(typeof e=="function")return;if(typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>Q(s)).filter(s=>s!==void 0);let t={};for(let[s,n]of Object.entries(e)){let a=Q(n);a!==void 0&&(t[s]=a)}return t}async function je(e,t={}){if(t?.runtimeConfig===!1||typeof fetch!="function")return null;let s=t?.runtimeConfigURL||`${e}pds-runtime-config.json`;try{let n=await fetch(s,{cache:"no-store"});return n.ok?await n.json():null}catch{return null}}r.registry=_;r.enums=te;r.adoptLayers=Z;r.adoptPrimitives=Y;r.parse=W;r.createStylesheet=ee;r.isLiveMode=()=>_.isLive;r.ask=ue;r.toast=k;r.common=B;r.AutoComplete=null;r.loadAutoComplete=async()=>{if(r.AutoComplete&&typeof r.AutoComplete.connect=="function")return r.AutoComplete;let e=j("pds-autocomplete.js",r.currentConfig?.autoCompleteURL);return I||(I=import(e).then(t=>{let s=t?.AutoComplete||t?.default?.AutoComplete||t?.default||null;if(!s)throw new Error("AutoComplete export not found in module");return r.AutoComplete=s,s}).catch(t=>{throw I=null,t})),I};function me(e){let t=typeof CustomEvent=="function";try{let s=t?new CustomEvent("pds:ready",{detail:e}):new Event("pds:ready");r.dispatchEvent(s)}catch{}if(typeof document<"u")if(t){let s={detail:e,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:ready",s))}catch{}try{document.dispatchEvent(new CustomEvent("pds-ready",s))}catch{}}else{try{document.dispatchEvent(new Event("pds:ready"))}catch{}try{document.dispatchEvent(new Event("pds-ready"))}catch{}}}function fe(e={}){let t=typeof CustomEvent=="function",s={at:Date.now(),...e};try{let n=t?new CustomEvent("pds:config-changed",{detail:s}):new Event("pds:config-changed");r.dispatchEvent(n)}catch{}if(typeof document<"u")if(t){let n={detail:s,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:config-changed",n))}catch{}}else try{document.dispatchEvent(new Event("pds:config-changed"))}catch{}}var q="pure-ds-theme",E=null,D=null;function J(e){try{if(typeof document>"u")return;let t="light";e?e==="system"?t=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t=e:t=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",document.documentElement.setAttribute("data-theme",t)}catch{}}function X(e){try{if(E&&D){try{typeof E.removeEventListener=="function"?E.removeEventListener("change",D):typeof E.removeListener=="function"&&E.removeListener(D)}catch{}E=null,D=null}if(e==="system"&&typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),s=n=>{let a=n?.matches===void 0?t.matches:n.matches;try{let o=a?"dark":"light";document.documentElement.setAttribute("data-theme",o),r.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:o,source:"system"}}))}catch{}};E=t,D=s,typeof t.addEventListener=="function"?t.addEventListener("change",s):typeof t.addListener=="function"&&t.addListener(s)}}catch{}}Object.defineProperty(r,"theme",{get(){try{return typeof window>"u"?null:localStorage.getItem(q)||null}catch{return null}},set(e){try{if(typeof window>"u")return;let t=r.currentConfig?.design||null,s=K(e);if(t&&!le(t,s)){let n=t?.name||r.currentPreset?.name||r.currentConfig?.preset||"current preset";console.warn(`PDS theme "${s}" not supported by preset "${n}".`),r.dispatchEvent(new CustomEvent("pds:theme:blocked",{detail:{theme:e,resolvedTheme:s,preset:n}}));return}e==null?localStorage.removeItem(q):localStorage.setItem(q,e),J(e),X(e),r.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:e,source:"api"}}))}catch{}}});r.defaultEnhancers=[];async function Re(e){let t=e&&e.mode||"live",{mode:s,...n}=e||{};if(t==="static")return Pe(n);let a=C(n,{resolvePublicAssetURL:M}),o=n?.managerURL||n?.public?.managerURL||n?.manager?.url||new URL("core/pds-manager.js",a).href||new URL("./pds-manager.js",import.meta.url).href,{startLive:c}=await import(o);return c(r,n,{emitReady:me,emitConfigChanged:fe,applyResolvedTheme:J,setupSystemListenerIfNeeded:X})}r.start=Re;async function Pe(e){if(!e||typeof e!="object")throw new Error("PDS.start({ mode: 'static', ... }) requires a valid configuration object");let t=e.applyGlobalStyles??!0,s=e.manageTheme??!0,n=e.themeStorageKey??"pure-ds-theme",a=e.staticPaths??{},o=C(e,{resolvePublicAssetURL:M}),c=e&&e.autoDefine||null,m;c&&c.baseURL?m=T(U(c.baseURL,{preferModule:!1})):m=`${o}components/`;let v=c&&Array.isArray(c.predefine)&&c.predefine||[],S=c&&typeof c.mapper=="function"&&c.mapper||null;try{ae(r);let{resolvedTheme:y}=ce({manageTheme:s,themeStorageKey:n,applyResolvedTheme:J,setupSystemListenerIfNeeded:X}),i=await je(o,e),l=Array.isArray(e?.enhancers)?e.enhancers:e?.enhancers&&typeof e.enhancers=="object"?Object.values(e.enhancers):[],p=i?.config?{...i.config,...e,design:e?.design||i.config.design,preset:e?.preset||i.config.preset}:{...e},b={tokens:`${o}styles/pds-tokens.css.js`,primitives:`${o}styles/pds-primitives.css.js`,components:`${o}styles/pds-components.css.js`,utilities:`${o}styles/pds-utilities.css.js`,styles:`${o}styles/pds-styles.css.js`},u=i?.paths||{};if(a={...b,...u,...a},r.registry.setStaticMode(a),t&&typeof document<"u")try{let g=await r.registry.getStylesheet("styles");if(g){g._pds=!0;let L=(document.adoptedStyleSheets||[]).filter(z=>z._pds!==!0);document.adoptedStyleSheets=[...L,g],fe({mode:"static",source:"static:styles-applied"})}}catch(g){pe.call(r,"warn","Failed to apply static styles:",g)}let f=null,d=[];try{let g=await xe(),L=await de({autoDefineBaseURL:m,autoDefinePreload:v,autoDefineMapper:S,autoDefinerModuleURL:j("pds-auto-definer.js",c?.moduleURL||r.currentConfig?.autoDefinerURL),enhancers:l,autoDefineOverrides:c||null,autoDefinePreferModule:!(c&&c.baseURL)},{baseEnhancers:g});f=L.autoDefiner,d=L.mergedEnhancers||[]}catch(g){pe.call(r,"error","\u274C Failed to initialize AutoDefiner/Enhancers (static):",g)}let h=Q(e);return r.currentConfig=Object.freeze({mode:"static",...structuredClone(h),design:structuredClone(p.design||{}),preset:p.preset,theme:y,enhancers:d}),me({mode:"static",config:p,theme:y,autoDefiner:f}),{config:p,theme:y,autoDefiner:f}}catch(y){throw r.dispatchEvent(new CustomEvent("pds:error",{detail:{error:y}})),y}}var he={mode:"live",liveEdit:!0,preset:"default",autoDefine:{predefine:["pds-icon","pds-drawer","pds-toaster","pds-form"]},log(e,t,...s){console[e](t,...s)}};var w={name:"@pure-ds/core",shortname:"pds",version:"0.7.1",description:"Why develop a Design System when you can generate one?",repository:{type:"git",url:"git+https://github.com/Pure-Web-Foundation/pure-ds.git"},bugs:{url:"https://github.com/Pure-Web-Foundation/pure-ds/issues"},homepage:"https://puredesignsystem.z6.web.core.windows.net/",keywords:["design-system","css","web-components","lit","constructable-stylesheets","tokens","utilities","a11y"],type:"module",main:"./public/assets/pds/core.js",module:"./public/assets/pds/core.js",types:"./dist/types/pds.d.ts",bin:{"pds-build":"packages/pds-cli/bin/pds-static.js","pds-sync-assets":"packages/pds-cli/bin/sync-assets.js","pds-build-icons":"packages/pds-cli/bin/pds-build-icons.js","pds-import":"packages/pds-cli/bin/pds-import.js","pds-setup-copilot":"packages/pds-cli/bin/pds-setup-copilot.js","pds-init-config":"packages/pds-cli/bin/pds-init-config.js","pds-bootstrap":"packages/pds-cli/bin/pds-bootstrap.js"},exports:{".":{types:"./src/js/pds.d.ts",import:"./public/assets/pds/core.js"},"./pds-core":"./src/js/pds.js","./auto-define/*":"./public/auto-define/*"},files:[".github/copilot-instructions.md",".cursorrules","dist/types/","public/assets/js/","public/assets/pds/components/","public/assets/pds/templates/","public/assets/pds/core.js","public/assets/pds/core/","public/assets/pds/external/","public/assets/pds/vscode-custom-data.json","public/assets/pds/pds.css-data.json","public/assets/pds/pds-css-complete.json","public/auto-define/","public/pds/components/","public/assets/pds/icons/pds-icons.svg","packages/pds-cli/bin/","packages/pds-cli/lib/","src/js/pds.d.ts","src/js/pds.js","src/js/pds-live-manager/","src/js/pds-core/","custom-elements.json","custom-elements-manifest.config.js","pds.html-data.json","pds.css-data.json","readme.md","INTELLISENSE.md","CSS-INTELLISENSE-LIMITATION.md","CSS-INTELLISENSE-QUICK-REF.md"],scripts:{test:'echo "Error: no test specified" && exit 1',dev:"node esbuild-dev.js",prebuild:"npm run types",build:"node esbuild-build.js",types:"tsc -p tsconfig.json && node scripts/sync-types.mjs",postinstall:"node packages/pds-cli/bin/postinstall.mjs","prepds:build":"npm run types","pds:build":"node packages/pds-cli/bin/pds-static.js","pds:build-icons":"node packages/pds-cli/bin/pds-build-icons.js","pds:bootstrap":"node packages/pds-cli/bin/pds-bootstrap.js","pds:manifest":"node packages/pds-cli/bin/generate-manifest.js","pds:css-data":"node packages/pds-cli/bin/generate-css-data.js","pds:import":"node packages/pds-cli/bin/pds-import.js","pds:dx":"node packages/pds-cli/bin/pds-dx.js","storybook:generate":"cd packages/pds-storybook && npm run generate-stories","storybook:dev":"cd packages/pds-storybook && npm run storybook:dev","storybook:build":"cd packages/pds-storybook && npm run storybook:build"},author:"Marc van Neerven",license:"ISC",engines:{node:">=18"},publishConfig:{access:"public"},devDependencies:{"@custom-elements-manifest/analyzer":"^0.9.9",esbuild:"^0.19.0","fs-extra":"^11.1.1",typescript:"^5.6.3","@types/node":"^22.10.2"},dependencies:{lit:"^3.3.1","pure-web":"1.1.32"},customElements:"custom-elements.json"};await r.start(he);var ye=typeof w.repository=="string"?w.repository:w.repository?.url,Te=ye?ye.replace(/^git\+/,"").replace(/\.git$/,""):"",et=w.homepage||Te,tt=w.bugs?.url||"";document.body.innerHTML=`
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/js/pds-core/pds-registry.js
8
+ var PDSRegistry = class {
9
+ constructor() {
10
+ this._mode = "static";
11
+ this._staticPaths = {
12
+ tokens: "/assets/pds/styles/pds-tokens.css.js",
13
+ primitives: "/assets/pds/styles/pds-primitives.css.js",
14
+ components: "/assets/pds/styles/pds-components.css.js",
15
+ utilities: "/assets/pds/styles/pds-utilities.css.js",
16
+ styles: "/assets/pds/styles/pds-styles.css.js"
17
+ };
18
+ }
19
+ /**
20
+ * Switch to live mode
21
+ */
22
+ setLiveMode() {
23
+ this._mode = "live";
24
+ }
25
+ /**
26
+ * Switch to static mode with custom paths
27
+ * Called by consumers who want to use static CSS files
28
+ */
29
+ setStaticMode(paths = {}) {
30
+ this._mode = "static";
31
+ this._staticPaths = { ...this._staticPaths, ...paths };
32
+ }
33
+ /**
34
+ * Get stylesheet for adoption in shadow DOM
35
+ * Returns CSSStyleSheet object (constructable stylesheet)
36
+ */
37
+ async getStylesheet(layer) {
38
+ if (this._mode === "live") {
39
+ return null;
40
+ } else {
41
+ try {
42
+ const module = await import(
43
+ /* @vite-ignore */
44
+ this._staticPaths[layer]
45
+ );
46
+ return module[layer];
47
+ } catch (error) {
48
+ console.error(`[PDS Registry] Failed to load static ${layer}:`, error);
49
+ console.error(`[PDS Registry] Looking for: ${this._staticPaths[layer]}`);
50
+ console.error(`[PDS Registry] Make sure you've run 'npm run pds:build' and configured PDS.start() with the correct static.root path`);
51
+ const fallback = new CSSStyleSheet();
52
+ fallback.replaceSync("/* Failed to load " + layer + " */");
53
+ return fallback;
54
+ }
55
+ }
56
+ }
57
+ /**
58
+ * Get current mode
59
+ */
60
+ get mode() {
61
+ return this._mode;
62
+ }
63
+ /**
64
+ * Check if in live mode
65
+ */
66
+ get isLive() {
67
+ return this._mode === "live";
68
+ }
69
+ };
70
+ var registry = new PDSRegistry();
71
+
72
+ // src/js/pds-core/pds-runtime.js
73
+ async function adoptPrimitives(shadowRoot, additionalSheets = [], generator = null) {
74
+ try {
75
+ const primitives = generator?.primitivesStylesheet ? generator.primitivesStylesheet : await registry.getStylesheet("primitives");
76
+ shadowRoot.adoptedStyleSheets = [primitives, ...additionalSheets];
77
+ } catch (error) {
78
+ const componentName = shadowRoot.host?.tagName?.toLowerCase() || "unknown";
79
+ console.error(
80
+ `[PDS Adopter] <${componentName}> failed to adopt primitives:`,
81
+ error
82
+ );
83
+ shadowRoot.adoptedStyleSheets = additionalSheets;
84
+ }
85
+ }
86
+ async function adoptLayers(shadowRoot, layers = ["primitives"], additionalSheets = [], generator = null) {
87
+ try {
88
+ const stylesheets = await Promise.all(
89
+ layers.map(async (layer) => {
90
+ if (generator) {
91
+ switch (layer) {
92
+ case "tokens":
93
+ return generator.tokensStylesheet;
94
+ case "primitives":
95
+ return generator.primitivesStylesheet;
96
+ case "components":
97
+ return generator.componentsStylesheet;
98
+ case "utilities":
99
+ return generator.utilitiesStylesheet;
100
+ default:
101
+ break;
102
+ }
103
+ }
104
+ return registry.getStylesheet(layer);
105
+ })
106
+ );
107
+ const validStylesheets = stylesheets.filter((sheet) => sheet !== null);
108
+ shadowRoot.adoptedStyleSheets = [...validStylesheets, ...additionalSheets];
109
+ } catch (error) {
110
+ const componentName = shadowRoot.host?.tagName?.toLowerCase() || "unknown";
111
+ console.error(
112
+ `[PDS Adopter] <${componentName}> failed to adopt layers:`,
113
+ error
114
+ );
115
+ shadowRoot.adoptedStyleSheets = additionalSheets;
116
+ }
117
+ }
118
+ function createStylesheet(css) {
119
+ const sheet = new CSSStyleSheet();
120
+ sheet.replaceSync(css);
121
+ return sheet;
122
+ }
123
+
124
+ // src/js/pds-core/pds-enums.js
125
+ var enums = {
126
+ FontWeights: {
127
+ light: 300,
128
+ normal: 400,
129
+ medium: 500,
130
+ semibold: 600,
131
+ bold: 700
132
+ },
133
+ LineHeights: {
134
+ tight: 1.25,
135
+ normal: 1.5,
136
+ relaxed: 1.75
137
+ },
138
+ BorderWidths: {
139
+ hairline: 0.5,
140
+ thin: 1,
141
+ medium: 2,
142
+ thick: 3
143
+ },
144
+ RadiusSizes: {
145
+ none: 0,
146
+ small: 4,
147
+ medium: 8,
148
+ large: 16,
149
+ xlarge: 24,
150
+ xxlarge: 32
151
+ },
152
+ ShadowDepths: {
153
+ none: "none",
154
+ light: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
155
+ medium: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
156
+ deep: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",
157
+ extreme: "0 25px 50px -12px rgba(0, 0, 0, 0.25)"
158
+ },
159
+ TransitionSpeeds: {
160
+ fast: 150,
161
+ normal: 250,
162
+ slow: 350
163
+ },
164
+ AnimationEasings: {
165
+ linear: "linear",
166
+ ease: "ease",
167
+ "ease-in": "ease-in",
168
+ "ease-out": "ease-out",
169
+ "ease-in-out": "ease-in-out",
170
+ bounce: "cubic-bezier(0.68, -0.55, 0.265, 1.55)"
171
+ },
172
+ TouchTargetSizes: {
173
+ compact: 36,
174
+ standard: 44,
175
+ // iOS/Android accessibility standard
176
+ comfortable: 48,
177
+ spacious: 56
178
+ },
179
+ LinkStyles: {
180
+ inline: "inline",
181
+ // Normal inline text links
182
+ block: "block",
183
+ // Block-level links
184
+ button: "button"
185
+ // Button-like links (flex with touch target)
186
+ },
187
+ FocusStyles: {
188
+ ring: "ring",
189
+ // Box-shadow ring (default)
190
+ outline: "outline",
191
+ // Browser outline
192
+ border: "border",
193
+ // Border change
194
+ glow: "glow"
195
+ // Subtle glow effect
196
+ },
197
+ TabSizes: {
198
+ compact: 2,
199
+ standard: 4,
200
+ wide: 8
201
+ },
202
+ SelectIcons: {
203
+ chevron: "chevron",
204
+ // Standard chevron down
205
+ arrow: "arrow",
206
+ // Simple arrow
207
+ caret: "caret",
208
+ // Triangle caret
209
+ none: "none"
210
+ // No icon
211
+ },
212
+ IconSizes: {
213
+ xs: 16,
214
+ sm: 20,
215
+ md: 24,
216
+ lg: 32,
217
+ xl: 48,
218
+ "2xl": 64,
219
+ "3xl": 96
220
+ }
221
+ };
222
+
223
+ // src/js/common/common.js
224
+ var common_exports = {};
225
+ __export(common_exports, {
226
+ deepMerge: () => deepMerge,
227
+ fragmentFromTemplateLike: () => fragmentFromTemplateLike,
228
+ isObject: () => isObject,
229
+ parseHTML: () => parseHTML
230
+ });
231
+ function isObject(item) {
232
+ return item && typeof item === "object" && !Array.isArray(item);
233
+ }
234
+ function deepMerge(target, source) {
235
+ const output = { ...target };
236
+ if (isObject(target) && isObject(source)) {
237
+ Object.keys(source).forEach((key) => {
238
+ if (isObject(source[key])) {
239
+ if (!(key in target))
240
+ Object.assign(output, { [key]: source[key] });
241
+ else
242
+ output[key] = deepMerge(target[key], source[key]);
243
+ } else {
244
+ Object.assign(output, { [key]: source[key] });
245
+ }
246
+ });
247
+ }
248
+ return output;
249
+ }
250
+ function fragmentFromTemplateLike(templateLike) {
251
+ const strings = Array.isArray(templateLike?.strings) ? templateLike.strings : [];
252
+ const values = Array.isArray(templateLike?.values) ? templateLike.values : [];
253
+ const consumedValues = /* @__PURE__ */ new Set();
254
+ const htmlParts = [];
255
+ const propBindingPattern = /(\s)(\.[\w-]+)=\s*$/;
256
+ for (let i = 0; i < strings.length; i += 1) {
257
+ let chunk = strings[i] ?? "";
258
+ const match = chunk.match(propBindingPattern);
259
+ if (match && i < values.length) {
260
+ const propToken = match[2];
261
+ const propName = propToken.slice(1);
262
+ const marker = `pds-val-${i}`;
263
+ chunk = chunk.replace(
264
+ propBindingPattern,
265
+ `$1data-pds-prop="${propName}:${marker}"`
266
+ );
267
+ consumedValues.add(i);
268
+ }
269
+ htmlParts.push(chunk);
270
+ if (i < values.length && !consumedValues.has(i)) {
271
+ htmlParts.push(`<!--pds-val-${i}-->`);
272
+ }
273
+ }
274
+ const tpl = document.createElement("template");
275
+ tpl.innerHTML = htmlParts.join("");
276
+ const replaceValueAtMarker = (markerNode, value) => {
277
+ const parent = markerNode.parentNode;
278
+ if (!parent)
279
+ return;
280
+ if (value == null) {
281
+ parent.removeChild(markerNode);
282
+ return;
283
+ }
284
+ const insertValue = (val) => {
285
+ if (val == null)
286
+ return;
287
+ if (val instanceof Node) {
288
+ parent.insertBefore(val, markerNode);
289
+ return;
290
+ }
291
+ if (Array.isArray(val)) {
292
+ val.forEach((item) => insertValue(item));
293
+ return;
294
+ }
295
+ parent.insertBefore(document.createTextNode(String(val)), markerNode);
296
+ };
297
+ insertValue(value);
298
+ parent.removeChild(markerNode);
299
+ };
300
+ const walker = document.createTreeWalker(tpl.content, NodeFilter.SHOW_COMMENT);
301
+ const markers = [];
302
+ while (walker.nextNode()) {
303
+ const node = walker.currentNode;
304
+ if (node?.nodeValue?.startsWith("pds-val-")) {
305
+ markers.push(node);
306
+ }
307
+ }
308
+ markers.forEach((node) => {
309
+ const index = Number(node.nodeValue.replace("pds-val-", ""));
310
+ replaceValueAtMarker(node, values[index]);
311
+ });
312
+ const elements = tpl.content.querySelectorAll("*");
313
+ elements.forEach((el) => {
314
+ const propAttr = el.getAttribute("data-pds-prop");
315
+ if (!propAttr)
316
+ return;
317
+ const [propName, markerValue] = propAttr.split(":");
318
+ const index = Number(String(markerValue).replace("pds-val-", ""));
319
+ if (propName && Number.isInteger(index)) {
320
+ el[propName] = values[index];
321
+ }
322
+ el.removeAttribute("data-pds-prop");
323
+ });
324
+ return tpl.content;
325
+ }
326
+ function parseHTML(html) {
327
+ return new DOMParser().parseFromString(html, "text/html").body.childNodes;
328
+ }
329
+
330
+ // src/js/pds-core/pds-paths.js
331
+ var DEFAULT_SEGMENT = "pds";
332
+ var URL_PATTERN = /^([a-z][a-z0-9+\-.]*:)?\/\//i;
333
+ var DRIVE_PATTERN = /^[a-z]:/i;
334
+ function ensureTrailingSlash(value = "") {
335
+ return value.endsWith("/") ? value : `${value}/`;
336
+ }
337
+ function appendSegmentIfMissing(input = "", segment = DEFAULT_SEGMENT) {
338
+ const trimmed = input.replace(/\/+$/, "");
339
+ const regex = new RegExp(`(?:^|/)${segment}$`, "i");
340
+ if (regex.test(trimmed)) {
341
+ return trimmed;
342
+ }
343
+ return `${trimmed}/${segment}`;
344
+ }
345
+ function stripLeadingDotSlash(value) {
346
+ return value.replace(/^\.\/+/, "");
347
+ }
348
+ function stripDriveLetter(value) {
349
+ if (DRIVE_PATTERN.test(value)) {
350
+ return value.replace(DRIVE_PATTERN, "").replace(/^\/+/, "");
351
+ }
352
+ return value;
353
+ }
354
+ function stripPublicPrefix(value) {
355
+ if (value.startsWith("public/")) {
356
+ return value.substring("public/".length);
357
+ }
358
+ return value;
359
+ }
360
+ function resolvePublicAssetURL(config2, options = {}) {
361
+ const segment = options.segment || DEFAULT_SEGMENT;
362
+ const defaultRoot = options.defaultRoot || `/assets/${segment}/`;
363
+ const candidate = config2?.public && config2.public?.root || config2?.static && config2.static?.root || null;
364
+ if (!candidate || typeof candidate !== "string") {
365
+ return ensureTrailingSlash(defaultRoot);
366
+ }
367
+ let normalized = candidate.trim();
368
+ if (!normalized) {
369
+ return ensureTrailingSlash(defaultRoot);
370
+ }
371
+ normalized = normalized.replace(/\\/g, "/");
372
+ normalized = appendSegmentIfMissing(normalized, segment);
373
+ normalized = ensureTrailingSlash(normalized);
374
+ if (URL_PATTERN.test(normalized)) {
375
+ return normalized;
376
+ }
377
+ normalized = stripLeadingDotSlash(normalized);
378
+ normalized = stripDriveLetter(normalized);
379
+ if (normalized.startsWith("/")) {
380
+ return ensureTrailingSlash(normalized);
381
+ }
382
+ normalized = stripPublicPrefix(normalized);
383
+ if (!normalized.startsWith("/")) {
384
+ normalized = `/${normalized}`;
385
+ }
386
+ normalized = normalized.replace(
387
+ /\/+/g,
388
+ (match, offset) => offset === 0 ? match : "/"
389
+ );
390
+ return ensureTrailingSlash(normalized);
391
+ }
392
+
393
+ // node_modules/pure-web/src/js/auto-definer.js
394
+ async function defineWebComponents(...args) {
395
+ let opts = {};
396
+ if (args.length && typeof args[args.length - 1] === "object") {
397
+ opts = args.pop() || {};
398
+ }
399
+ const tags = args;
400
+ const {
401
+ baseURL,
402
+ mapper = (tag) => `${tag}.js`,
403
+ onError = (tag, err) => console.error(`[defineWebComponents] ${tag}:`, err)
404
+ } = opts;
405
+ const base = baseURL ? new URL(
406
+ baseURL,
407
+ typeof location !== "undefined" ? location.href : import.meta.url
408
+ ) : new URL("./", import.meta.url);
409
+ const toPascal = (tag) => tag.toLowerCase().replace(/(^|-)([a-z])/g, (_, __, c) => c.toUpperCase());
410
+ const loadOne = async (tag) => {
411
+ try {
412
+ if (customElements.get(tag))
413
+ return { tag, status: "already-defined" };
414
+ const spec = mapper(tag);
415
+ const href = spec instanceof URL ? spec.href : new URL(spec, base).href;
416
+ const mod = await import(href);
417
+ const Named = mod?.default ?? mod?.[toPascal(tag)];
418
+ if (!Named) {
419
+ if (customElements.get(tag))
420
+ return { tag, status: "self-defined" };
421
+ throw new Error(
422
+ `No export found for ${tag}. Expected default export or named export "${toPascal(
423
+ tag
424
+ )}".`
425
+ );
426
+ }
427
+ if (!customElements.get(tag)) {
428
+ customElements.define(tag, Named);
429
+ return { tag, status: "defined" };
430
+ }
431
+ return { tag, status: "race-already-defined" };
432
+ } catch (err) {
433
+ onError(tag, err);
434
+ throw err;
435
+ }
436
+ };
437
+ return Promise.all(tags.map(loadOne));
438
+ }
439
+ var AutoDefiner = class {
440
+ constructor(options = {}) {
441
+ const {
442
+ baseURL,
443
+ mapper,
444
+ onError,
445
+ predicate = () => true,
446
+ attributeModule = "data-module",
447
+ root = document,
448
+ scanExisting = true,
449
+ debounceMs = 16,
450
+ observeShadows = true,
451
+ enhancers = [],
452
+ // [{String selector, Function run(elem)}]
453
+ patchAttachShadow = true
454
+ } = options;
455
+ const pending = /* @__PURE__ */ new Set();
456
+ const inFlight = /* @__PURE__ */ new Set();
457
+ const knownMissing = /* @__PURE__ */ new Set();
458
+ const perTagModulePath = /* @__PURE__ */ new Map();
459
+ const shadowObservers = /* @__PURE__ */ new WeakMap();
460
+ const enhancerApplied = /* @__PURE__ */ new WeakMap();
461
+ let timer = 0;
462
+ let stopped = false;
463
+ let restoreAttachShadow = null;
464
+ const applyEnhancers = (element) => {
465
+ if (!element || !enhancers.length)
466
+ return;
467
+ let appliedEnhancers = enhancerApplied.get(element);
468
+ if (!appliedEnhancers) {
469
+ appliedEnhancers = /* @__PURE__ */ new Set();
470
+ enhancerApplied.set(element, appliedEnhancers);
471
+ }
472
+ for (const enhancer of enhancers) {
473
+ if (!enhancer.selector || !enhancer.run)
474
+ continue;
475
+ if (appliedEnhancers.has(enhancer.selector))
476
+ continue;
477
+ try {
478
+ if (element.matches && element.matches(enhancer.selector)) {
479
+ enhancer.run(element);
480
+ appliedEnhancers.add(enhancer.selector);
481
+ }
482
+ } catch (err) {
483
+ console.warn(
484
+ `[AutoDefiner] Error applying enhancer for selector "${enhancer.selector}":`,
485
+ err
486
+ );
487
+ }
488
+ }
489
+ };
490
+ const queueTag = (tag, el) => {
491
+ if (stopped)
492
+ return;
493
+ if (!tag || !tag.includes("-"))
494
+ return;
495
+ if (customElements.get(tag))
496
+ return;
497
+ if (inFlight.has(tag))
498
+ return;
499
+ if (knownMissing.has(tag))
500
+ return;
501
+ if (el && el.getAttribute) {
502
+ const override = el.getAttribute(attributeModule);
503
+ if (override && !perTagModulePath.has(tag)) {
504
+ perTagModulePath.set(tag, override);
505
+ }
506
+ }
507
+ pending.add(tag);
508
+ schedule();
509
+ };
510
+ const schedule = () => {
511
+ if (timer)
512
+ return;
513
+ timer = setTimeout(flush, debounceMs);
514
+ };
515
+ const crawlTree = (rootNode) => {
516
+ if (!rootNode)
517
+ return;
518
+ if (rootNode.nodeType === 1) {
519
+ const el = (
520
+ /** @type {Element} */
521
+ rootNode
522
+ );
523
+ const tag = el.tagName?.toLowerCase();
524
+ if (tag && tag.includes("-") && !customElements.get(tag) && predicate(tag, el)) {
525
+ queueTag(tag, el);
526
+ }
527
+ applyEnhancers(el);
528
+ if (observeShadows && el.shadowRoot) {
529
+ observeShadowRoot(el.shadowRoot);
530
+ }
531
+ }
532
+ if (rootNode.querySelectorAll) {
533
+ rootNode.querySelectorAll("*").forEach((e) => {
534
+ const t = e.tagName?.toLowerCase();
535
+ if (t && t.includes("-") && !customElements.get(t) && predicate(t, e)) {
536
+ queueTag(t, e);
537
+ }
538
+ applyEnhancers(e);
539
+ if (observeShadows && e.shadowRoot) {
540
+ observeShadowRoot(e.shadowRoot);
541
+ }
542
+ });
543
+ }
544
+ };
545
+ const observeShadowRoot = (sr) => {
546
+ if (!sr || shadowObservers.has(sr))
547
+ return;
548
+ crawlTree(sr);
549
+ const mo = new MutationObserver((mutations) => {
550
+ for (const m of mutations) {
551
+ m.addedNodes?.forEach((n) => {
552
+ crawlTree(n);
553
+ });
554
+ if (m.type === "attributes" && m.target) {
555
+ crawlTree(m.target);
556
+ }
557
+ }
558
+ });
559
+ mo.observe(sr, {
560
+ childList: true,
561
+ subtree: true,
562
+ attributes: true,
563
+ attributeFilter: [
564
+ attributeModule,
565
+ ...enhancers.map((e) => e.selector).filter((s) => s.startsWith("data-"))
566
+ ]
567
+ });
568
+ shadowObservers.set(sr, mo);
569
+ };
570
+ async function flush() {
571
+ clearTimeout(timer);
572
+ timer = 0;
573
+ if (!pending.size)
574
+ return;
575
+ const tags = Array.from(pending);
576
+ pending.clear();
577
+ tags.forEach((t) => inFlight.add(t));
578
+ try {
579
+ const effectiveMapper = (tag) => perTagModulePath.get(tag) ?? (mapper ? mapper(tag) : `${tag}.js`);
580
+ await defineWebComponents(...tags, {
581
+ baseURL,
582
+ mapper: effectiveMapper,
583
+ onError: (tag, err) => {
584
+ knownMissing.add(tag);
585
+ onError?.(tag, err);
586
+ }
587
+ });
588
+ } catch {
589
+ } finally {
590
+ tags.forEach((t) => inFlight.delete(t));
591
+ }
592
+ }
593
+ const mountNode = root === document ? document.documentElement : root;
594
+ const obs = new MutationObserver((mutations) => {
595
+ for (const m of mutations) {
596
+ m.addedNodes?.forEach((n) => {
597
+ crawlTree(n);
598
+ });
599
+ if (m.type === "attributes" && m.target) {
600
+ crawlTree(m.target);
601
+ }
602
+ }
603
+ });
604
+ obs.observe(mountNode, {
605
+ childList: true,
606
+ subtree: true,
607
+ attributes: true,
608
+ attributeFilter: [
609
+ attributeModule,
610
+ ...enhancers.map((e) => e.selector).filter((s) => s.startsWith("data-"))
611
+ ]
612
+ });
613
+ if (observeShadows && patchAttachShadow && Element.prototype.attachShadow) {
614
+ const orig = Element.prototype.attachShadow;
615
+ Element.prototype.attachShadow = function patchedAttachShadow(init) {
616
+ const sr = orig.call(this, init);
617
+ if (init && init.mode === "open") {
618
+ observeShadowRoot(sr);
619
+ const tag = this.tagName?.toLowerCase();
620
+ if (tag && tag.includes("-") && !customElements.get(tag)) {
621
+ queueTag(tag, this);
622
+ }
623
+ }
624
+ return sr;
625
+ };
626
+ restoreAttachShadow = () => Element.prototype.attachShadow = orig;
627
+ }
628
+ if (scanExisting) {
629
+ crawlTree(mountNode);
630
+ }
631
+ return {
632
+ stop() {
633
+ stopped = true;
634
+ obs.disconnect();
635
+ if (restoreAttachShadow)
636
+ restoreAttachShadow();
637
+ if (timer) {
638
+ clearTimeout(timer);
639
+ timer = 0;
640
+ }
641
+ shadowObservers.forEach((mo) => mo.disconnect());
642
+ },
643
+ flush
644
+ };
645
+ }
646
+ /**
647
+ * Dynamically load and (idempotently) define a set of web components by tag name.
648
+ */
649
+ static async define(...args) {
650
+ let opts = {};
651
+ if (args.length && typeof args[args.length - 1] === "object") {
652
+ opts = args.pop() || {};
653
+ }
654
+ const tags = args;
655
+ const {
656
+ baseURL,
657
+ mapper = (tag) => `${tag}.js`,
658
+ onError = (tag, err) => console.error(`[defineWebComponents] ${tag}:`, err)
659
+ } = opts;
660
+ const base = baseURL ? new URL(
661
+ baseURL,
662
+ typeof location !== "undefined" ? location.href : import.meta.url
663
+ ) : new URL("./", import.meta.url);
664
+ const toPascal = (tag) => tag.toLowerCase().replace(/(^|-)([a-z])/g, (_, __, c) => c.toUpperCase());
665
+ const loadOne = async (tag) => {
666
+ try {
667
+ if (customElements.get(tag))
668
+ return { tag, status: "already-defined" };
669
+ const spec = mapper(tag);
670
+ const href = spec instanceof URL ? spec.href : new URL(spec, base).href;
671
+ const mod = await import(href);
672
+ const Named = mod?.default ?? mod?.[toPascal(tag)];
673
+ if (!Named) {
674
+ if (customElements.get(tag))
675
+ return { tag, status: "self-defined" };
676
+ throw new Error(
677
+ `No export found for ${tag}. Expected default export or named export "${toPascal(
678
+ tag
679
+ )}".`
680
+ );
681
+ }
682
+ if (!customElements.get(tag)) {
683
+ customElements.define(tag, Named);
684
+ return { tag, status: "defined" };
685
+ }
686
+ return { tag, status: "race-already-defined" };
687
+ } catch (err) {
688
+ onError(tag, err);
689
+ throw err;
690
+ }
691
+ };
692
+ return Promise.all(tags.map(loadOne));
693
+ }
694
+ };
695
+
696
+ // src/js/pds-core/pds-start-helpers.js
697
+ var __ABSOLUTE_URL_PATTERN__ = /^[a-z][a-z0-9+\-.]*:\/\//i;
698
+ var __MODULE_URL__ = (() => {
699
+ try {
700
+ return import.meta.url;
701
+ } catch (e) {
702
+ return void 0;
703
+ }
704
+ })();
705
+ var ensureTrailingSlash2 = (value) => typeof value === "string" && value.length && !value.endsWith("/") ? `${value}/` : value;
706
+ function ensureAbsoluteAssetURL(value, options = {}) {
707
+ if (!value || __ABSOLUTE_URL_PATTERN__.test(value)) {
708
+ return value;
709
+ }
710
+ const { preferModule = true } = options;
711
+ const tryModule = () => {
712
+ if (!__MODULE_URL__)
713
+ return null;
714
+ try {
715
+ return new URL(value, __MODULE_URL__).href;
716
+ } catch (e) {
717
+ return null;
718
+ }
719
+ };
720
+ const tryWindow = () => {
721
+ if (typeof window === "undefined" || !window.location?.origin) {
722
+ return null;
723
+ }
724
+ try {
725
+ return new URL(value, window.location.origin).href;
726
+ } catch (e) {
727
+ return null;
728
+ }
729
+ };
730
+ const resolved = preferModule ? tryModule() || tryWindow() : tryWindow() || tryModule();
731
+ return resolved || value;
732
+ }
733
+ var __MODULE_DEFAULT_ASSET_ROOT__ = (() => {
734
+ if (!__MODULE_URL__)
735
+ return void 0;
736
+ try {
737
+ const parsed = new URL(__MODULE_URL__);
738
+ if (/\/public\/assets\/js\//.test(parsed.pathname)) {
739
+ return new URL("../pds/", __MODULE_URL__).href;
740
+ }
741
+ } catch (e) {
742
+ return void 0;
743
+ }
744
+ return void 0;
745
+ })();
746
+ var __foucListenerAttached = false;
747
+ function attachFoucListener(PDS2) {
748
+ if (__foucListenerAttached || typeof document === "undefined")
749
+ return;
750
+ __foucListenerAttached = true;
751
+ PDS2.addEventListener("pds:ready", (event) => {
752
+ const mode = event.detail?.mode;
753
+ if (mode) {
754
+ document.documentElement.classList.add(`pds-${mode}`, "pds-ready");
755
+ }
756
+ });
757
+ }
758
+ function resolveThemeAndApply({ manageTheme, themeStorageKey, applyResolvedTheme, setupSystemListenerIfNeeded }) {
759
+ let resolvedTheme = "light";
760
+ let storedTheme = null;
761
+ if (manageTheme && typeof window !== "undefined") {
762
+ try {
763
+ storedTheme = localStorage.getItem(themeStorageKey) || null;
764
+ } catch (e) {
765
+ storedTheme = null;
766
+ }
767
+ try {
768
+ applyResolvedTheme?.(storedTheme);
769
+ setupSystemListenerIfNeeded?.(storedTheme);
770
+ } catch (e) {
771
+ }
772
+ if (storedTheme) {
773
+ if (storedTheme === "system") {
774
+ const prefersDark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
775
+ resolvedTheme = prefersDark ? "dark" : "light";
776
+ } else {
777
+ resolvedTheme = storedTheme;
778
+ }
779
+ } else {
780
+ const prefersDark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
781
+ resolvedTheme = prefersDark ? "dark" : "light";
782
+ }
783
+ }
784
+ return { resolvedTheme, storedTheme };
785
+ }
786
+ function resolveRuntimeAssetRoot(config2, { resolvePublicAssetURL: resolvePublicAssetURL2 }) {
787
+ const hasCustomRoot = Boolean(config2?.public?.root || config2?.static?.root);
788
+ let candidate = resolvePublicAssetURL2(config2);
789
+ if (!hasCustomRoot && __MODULE_DEFAULT_ASSET_ROOT__) {
790
+ candidate = __MODULE_DEFAULT_ASSET_ROOT__;
791
+ }
792
+ return ensureTrailingSlash2(ensureAbsoluteAssetURL(candidate));
793
+ }
794
+ async function setupAutoDefinerAndEnhancers(options, { baseEnhancers = [] } = {}) {
795
+ const {
796
+ autoDefineBaseURL = "/auto-define/",
797
+ autoDefinePreload = [],
798
+ autoDefineMapper = null,
799
+ enhancers = [],
800
+ autoDefineOverrides = null,
801
+ autoDefinePreferModule = true
802
+ } = options;
803
+ const mergedEnhancers = (() => {
804
+ const map = /* @__PURE__ */ new Map();
805
+ (baseEnhancers || []).forEach((e) => map.set(e.selector, e));
806
+ (enhancers || []).forEach((e) => map.set(e.selector, e));
807
+ return Array.from(map.values());
808
+ })();
809
+ let autoDefiner = null;
810
+ if (typeof window !== "undefined" && typeof document !== "undefined") {
811
+ const AutoDefinerCtor = AutoDefiner;
812
+ const defaultMapper = (tag) => {
813
+ switch (tag) {
814
+ case "pds-tabpanel":
815
+ return "pds-tabstrip.js";
816
+ default:
817
+ return `${tag}.js`;
818
+ }
819
+ };
820
+ const { mapper: _overrideMapperIgnored, ...restAutoDefineOverrides } = autoDefineOverrides && typeof autoDefineOverrides === "object" ? autoDefineOverrides : {};
821
+ const normalizedBaseURL = autoDefineBaseURL ? ensureTrailingSlash2(
822
+ ensureAbsoluteAssetURL(autoDefineBaseURL, {
823
+ preferModule: autoDefinePreferModule
824
+ })
825
+ ) : autoDefineBaseURL;
826
+ const autoDefineConfig = {
827
+ baseURL: normalizedBaseURL,
828
+ predefine: autoDefinePreload,
829
+ scanExisting: true,
830
+ observeShadows: true,
831
+ patchAttachShadow: true,
832
+ debounceMs: 16,
833
+ enhancers: mergedEnhancers,
834
+ onError: (tag, err) => {
835
+ if (typeof tag === "string" && tag.startsWith("pds-")) {
836
+ const litDependentComponents = ["pds-form", "pds-drawer"];
837
+ const isLitComponent = litDependentComponents.includes(tag);
838
+ const isMissingLitError = err?.message?.includes("#pds/lit") || err?.message?.includes("Failed to resolve module specifier");
839
+ if (isLitComponent && isMissingLitError) {
840
+ console.error(
841
+ `\u274C PDS component <${tag}> requires Lit but #pds/lit is not in import map.
842
+ See: https://github.com/Pure-Web-Foundation/pure-ds/blob/main/readme.md#lit-components-not-working`
843
+ );
844
+ } else {
845
+ console.warn(
846
+ `\u26A0\uFE0F PDS component <${tag}> not found. Assets may not be installed.`
847
+ );
848
+ }
849
+ } else {
850
+ console.error(`\u274C Auto-define error for <${tag}>:`, err);
851
+ }
852
+ },
853
+ // Apply all user overrides except mapper so we can still wrap it
854
+ ...restAutoDefineOverrides,
855
+ mapper: (tag) => {
856
+ if (customElements.get(tag))
857
+ return null;
858
+ if (typeof autoDefineMapper === "function") {
859
+ try {
860
+ const mapped = autoDefineMapper(tag);
861
+ if (mapped === void 0) {
862
+ return defaultMapper(tag);
863
+ }
864
+ return mapped;
865
+ } catch (e) {
866
+ console.warn(
867
+ "Custom autoDefine.mapper error; falling back to default:",
868
+ e?.message || e
869
+ );
870
+ return defaultMapper(tag);
871
+ }
872
+ }
873
+ return defaultMapper(tag);
874
+ }
875
+ };
876
+ autoDefiner = new AutoDefinerCtor(autoDefineConfig);
877
+ if (autoDefinePreload.length > 0 && typeof AutoDefinerCtor.define === "function") {
878
+ await AutoDefinerCtor.define(...autoDefinePreload, {
879
+ baseURL: autoDefineBaseURL,
880
+ mapper: autoDefineConfig.mapper,
881
+ onError: autoDefineConfig.onError
882
+ });
883
+ }
884
+ }
885
+ return { autoDefiner, mergedEnhancers };
886
+ }
887
+
888
+ // src/js/pds-core/pds-theme-utils.js
889
+ var DEFAULT_THEMES = ["light", "dark"];
890
+ var VALID_THEMES = new Set(DEFAULT_THEMES);
891
+ function normalizePresetThemes(preset) {
892
+ const themes = Array.isArray(preset?.themes) ? preset.themes.map((theme) => String(theme).toLowerCase()) : DEFAULT_THEMES;
893
+ const normalized = themes.filter((theme) => VALID_THEMES.has(theme));
894
+ return normalized.length ? normalized : DEFAULT_THEMES;
895
+ }
896
+ function resolveThemePreference(preference, { preferDocument = true } = {}) {
897
+ const normalized = String(preference || "").toLowerCase();
898
+ if (VALID_THEMES.has(normalized))
899
+ return normalized;
900
+ if (preferDocument && typeof document !== "undefined") {
901
+ const applied = document.documentElement?.getAttribute("data-theme");
902
+ if (VALID_THEMES.has(applied))
903
+ return applied;
904
+ }
905
+ if (typeof window !== "undefined" && window.matchMedia) {
906
+ const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
907
+ return prefersDark ? "dark" : "light";
908
+ }
909
+ return "light";
910
+ }
911
+ function isPresetThemeCompatible(preset, themePreference) {
912
+ const resolvedTheme = resolveThemePreference(themePreference);
913
+ const themes = normalizePresetThemes(preset);
914
+ return themes.includes(resolvedTheme);
915
+ }
916
+
917
+ // src/js/pds.js
918
+ var PDSBase = class extends EventTarget {
919
+ };
920
+ var PDS = new PDSBase();
921
+ PDS.initializing = false;
922
+ PDS.currentPreset = null;
923
+ PDS.debug = false;
924
+ var __autoCompletePromise = null;
925
+ var __askPromise = null;
926
+ var __toastPromise = null;
927
+ var __defaultEnhancersPromise = null;
928
+ function __resolveExternalRuntimeModuleURL(filename, overrideURL) {
929
+ if (overrideURL && typeof overrideURL === "string") {
930
+ return overrideURL;
931
+ }
932
+ const assetRootURL = resolveRuntimeAssetRoot(PDS.currentConfig || {}, {
933
+ resolvePublicAssetURL
934
+ });
935
+ return `${assetRootURL}core/${filename}`;
936
+ }
937
+ async function __loadDefaultEnhancers() {
938
+ if (Array.isArray(PDS.defaultEnhancers) && PDS.defaultEnhancers.length > 0) {
939
+ return PDS.defaultEnhancers;
940
+ }
941
+ if (!__defaultEnhancersPromise) {
942
+ const enhancersModuleURL = __resolveExternalRuntimeModuleURL(
943
+ "pds-enhancers.js",
944
+ PDS.currentConfig?.enhancersURL
945
+ );
946
+ __defaultEnhancersPromise = import(enhancersModuleURL).then((mod) => {
947
+ const enhancers = Array.isArray(mod?.defaultPDSEnhancers) ? mod.defaultPDSEnhancers : [];
948
+ PDS.defaultEnhancers = enhancers;
949
+ return enhancers;
950
+ }).catch((error) => {
951
+ __defaultEnhancersPromise = null;
952
+ throw error;
953
+ });
954
+ }
955
+ return __defaultEnhancersPromise;
956
+ }
957
+ async function __loadAsk() {
958
+ if (typeof PDS.ask === "function" && PDS.ask !== __lazyAsk) {
959
+ return PDS.ask;
960
+ }
961
+ if (!__askPromise) {
962
+ const askModuleURL = __resolveExternalRuntimeModuleURL(
963
+ "pds-ask.js",
964
+ PDS.currentConfig?.askURL
965
+ );
966
+ __askPromise = import(askModuleURL).then((mod) => {
967
+ const impl = mod?.ask;
968
+ if (typeof impl !== "function") {
969
+ throw new Error("Failed to load ask helper");
970
+ }
971
+ PDS.ask = impl;
972
+ return impl;
973
+ }).catch((error) => {
974
+ __askPromise = null;
975
+ throw error;
976
+ });
977
+ }
978
+ return __askPromise;
979
+ }
980
+ async function __loadToast() {
981
+ if (typeof PDS.toast === "function" && PDS.toast !== __lazyToast) {
982
+ return PDS.toast;
983
+ }
984
+ if (!__toastPromise) {
985
+ const toastModuleURL = __resolveExternalRuntimeModuleURL(
986
+ "pds-toast.js",
987
+ PDS.currentConfig?.toastURL
988
+ );
989
+ __toastPromise = import(toastModuleURL).then((mod) => {
990
+ const impl = mod?.toast;
991
+ if (typeof impl !== "function") {
992
+ throw new Error("Failed to load toast helper");
993
+ }
994
+ PDS.toast = impl;
995
+ return impl;
996
+ }).catch((error) => {
997
+ __toastPromise = null;
998
+ throw error;
999
+ });
1000
+ }
1001
+ return __toastPromise;
1002
+ }
1003
+ async function __lazyAsk(...args) {
1004
+ const askImpl = await __loadAsk();
1005
+ return askImpl(...args);
1006
+ }
1007
+ async function __lazyToast(...args) {
1008
+ const toastImpl = await __loadToast();
1009
+ return toastImpl(...args);
1010
+ }
1011
+ __lazyToast.success = async (...args) => {
1012
+ const toastImpl = await __loadToast();
1013
+ return toastImpl.success(...args);
1014
+ };
1015
+ __lazyToast.error = async (...args) => {
1016
+ const toastImpl = await __loadToast();
1017
+ return toastImpl.error(...args);
1018
+ };
1019
+ __lazyToast.warning = async (...args) => {
1020
+ const toastImpl = await __loadToast();
1021
+ return toastImpl.warning(...args);
1022
+ };
1023
+ __lazyToast.info = async (...args) => {
1024
+ const toastImpl = await __loadToast();
1025
+ return toastImpl.info(...args);
1026
+ };
1027
+ var __defaultLog = function(level = "log", message, ...data) {
1028
+ const isStaticMode = Boolean(PDS.registry && !PDS.registry.isLive);
1029
+ const debug = (this?.debug || this?.design?.debug || PDS.debug || false) === true;
1030
+ if (isStaticMode) {
1031
+ if (!PDS.debug)
1032
+ return;
1033
+ } else if (!debug && level !== "error" && level !== "warn") {
1034
+ return;
1035
+ }
1036
+ const method = console[level] || console.log;
1037
+ if (data.length > 0) {
1038
+ method(message, ...data);
1039
+ } else {
1040
+ method(message);
1041
+ }
1042
+ };
1043
+ function __stripFunctionsForClone(value) {
1044
+ if (value === null || value === void 0)
1045
+ return value;
1046
+ if (typeof value === "function")
1047
+ return void 0;
1048
+ if (typeof value !== "object")
1049
+ return value;
1050
+ if (Array.isArray(value)) {
1051
+ return value.map((item) => __stripFunctionsForClone(item)).filter((item) => item !== void 0);
1052
+ }
1053
+ const result = {};
1054
+ for (const [key, entry] of Object.entries(value)) {
1055
+ const stripped = __stripFunctionsForClone(entry);
1056
+ if (stripped !== void 0) {
1057
+ result[key] = stripped;
1058
+ }
1059
+ }
1060
+ return result;
1061
+ }
1062
+ async function __loadRuntimeConfig(assetRootURL, config2 = {}) {
1063
+ if (config2?.runtimeConfig === false)
1064
+ return null;
1065
+ if (typeof fetch !== "function")
1066
+ return null;
1067
+ const runtimeUrl = config2?.runtimeConfigURL || `${assetRootURL}pds-runtime-config.json`;
1068
+ try {
1069
+ const res = await fetch(runtimeUrl, { cache: "no-store" });
1070
+ if (!res.ok)
1071
+ return null;
1072
+ return await res.json();
1073
+ } catch (e) {
1074
+ return null;
1075
+ }
1076
+ }
1077
+ PDS.registry = registry;
1078
+ PDS.enums = enums;
1079
+ PDS.adoptLayers = adoptLayers;
1080
+ PDS.adoptPrimitives = adoptPrimitives;
1081
+ PDS.parse = parseHTML;
1082
+ PDS.createStylesheet = createStylesheet;
1083
+ PDS.isLiveMode = () => registry.isLive;
1084
+ PDS.ask = __lazyAsk;
1085
+ PDS.toast = __lazyToast;
1086
+ PDS.common = common_exports;
1087
+ PDS.AutoComplete = null;
1088
+ PDS.loadAutoComplete = async () => {
1089
+ if (PDS.AutoComplete && typeof PDS.AutoComplete.connect === "function") {
1090
+ return PDS.AutoComplete;
1091
+ }
1092
+ const autoCompleteModuleURL = __resolveExternalRuntimeModuleURL(
1093
+ "pds-autocomplete.js",
1094
+ PDS.currentConfig?.autoCompleteURL
1095
+ );
1096
+ if (!__autoCompletePromise) {
1097
+ __autoCompletePromise = import(autoCompleteModuleURL).then((mod) => {
1098
+ const autoCompleteCtor = mod?.AutoComplete || mod?.default?.AutoComplete || mod?.default || null;
1099
+ if (!autoCompleteCtor) {
1100
+ throw new Error("AutoComplete export not found in module");
1101
+ }
1102
+ PDS.AutoComplete = autoCompleteCtor;
1103
+ return autoCompleteCtor;
1104
+ }).catch((error) => {
1105
+ __autoCompletePromise = null;
1106
+ throw error;
1107
+ });
1108
+ }
1109
+ return __autoCompletePromise;
1110
+ };
1111
+ function __emitPDSReady(detail) {
1112
+ const hasCustomEvent = typeof CustomEvent === "function";
1113
+ try {
1114
+ const readyEvent = hasCustomEvent ? new CustomEvent("pds:ready", { detail }) : new Event("pds:ready");
1115
+ PDS.dispatchEvent(readyEvent);
1116
+ } catch (e) {
1117
+ }
1118
+ if (typeof document !== "undefined") {
1119
+ if (hasCustomEvent) {
1120
+ const eventOptions = { detail, bubbles: true, composed: true };
1121
+ try {
1122
+ document.dispatchEvent(new CustomEvent("pds:ready", eventOptions));
1123
+ } catch (e) {
1124
+ }
1125
+ try {
1126
+ document.dispatchEvent(new CustomEvent("pds-ready", eventOptions));
1127
+ } catch (e) {
1128
+ }
1129
+ } else {
1130
+ try {
1131
+ document.dispatchEvent(new Event("pds:ready"));
1132
+ } catch (e) {
1133
+ }
1134
+ try {
1135
+ document.dispatchEvent(new Event("pds-ready"));
1136
+ } catch (e) {
1137
+ }
1138
+ }
1139
+ }
1140
+ }
1141
+ function __emitPDSConfigChanged(detail = {}) {
1142
+ const hasCustomEvent = typeof CustomEvent === "function";
1143
+ const payload = {
1144
+ at: Date.now(),
1145
+ ...detail
1146
+ };
1147
+ try {
1148
+ const changedEvent = hasCustomEvent ? new CustomEvent("pds:config-changed", { detail: payload }) : new Event("pds:config-changed");
1149
+ PDS.dispatchEvent(changedEvent);
1150
+ } catch (e) {
1151
+ }
1152
+ if (typeof document !== "undefined") {
1153
+ if (hasCustomEvent) {
1154
+ const eventOptions = { detail: payload, bubbles: true, composed: true };
1155
+ try {
1156
+ document.dispatchEvent(
1157
+ new CustomEvent("pds:config-changed", eventOptions)
1158
+ );
1159
+ } catch (e) {
1160
+ }
1161
+ } else {
1162
+ try {
1163
+ document.dispatchEvent(new Event("pds:config-changed"));
1164
+ } catch (e) {
1165
+ }
1166
+ }
1167
+ }
1168
+ }
1169
+ var __themeStorageKey = "pure-ds-theme";
1170
+ var __themeMQ = null;
1171
+ var __themeMQListener = null;
1172
+ function __applyResolvedTheme(raw) {
1173
+ try {
1174
+ if (typeof document === "undefined")
1175
+ return;
1176
+ let resolved = "light";
1177
+ if (!raw) {
1178
+ const prefersDark = typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
1179
+ resolved = prefersDark ? "dark" : "light";
1180
+ } else if (raw === "system") {
1181
+ const prefersDark = typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
1182
+ resolved = prefersDark ? "dark" : "light";
1183
+ } else {
1184
+ resolved = raw;
1185
+ }
1186
+ document.documentElement.setAttribute("data-theme", resolved);
1187
+ } catch (e) {
1188
+ }
1189
+ }
1190
+ function __setupSystemListenerIfNeeded(raw) {
1191
+ try {
1192
+ if (__themeMQ && __themeMQListener) {
1193
+ try {
1194
+ if (typeof __themeMQ.removeEventListener === "function")
1195
+ __themeMQ.removeEventListener("change", __themeMQListener);
1196
+ else if (typeof __themeMQ.removeListener === "function")
1197
+ __themeMQ.removeListener(__themeMQListener);
1198
+ } catch (e) {
1199
+ }
1200
+ __themeMQ = null;
1201
+ __themeMQListener = null;
1202
+ }
1203
+ if (raw === "system" && typeof window !== "undefined" && window.matchMedia) {
1204
+ const mq = window.matchMedia("(prefers-color-scheme: dark)");
1205
+ const listener = (e) => {
1206
+ const isDark = e?.matches === void 0 ? mq.matches : e.matches;
1207
+ try {
1208
+ const newTheme = isDark ? "dark" : "light";
1209
+ document.documentElement.setAttribute("data-theme", newTheme);
1210
+ PDS.dispatchEvent(
1211
+ new CustomEvent("pds:theme:changed", {
1212
+ detail: { theme: newTheme, source: "system" }
1213
+ })
1214
+ );
1215
+ } catch (ex) {
1216
+ }
1217
+ };
1218
+ __themeMQ = mq;
1219
+ __themeMQListener = listener;
1220
+ if (typeof mq.addEventListener === "function")
1221
+ mq.addEventListener("change", listener);
1222
+ else if (typeof mq.addListener === "function")
1223
+ mq.addListener(listener);
1224
+ }
1225
+ } catch (e) {
1226
+ }
1227
+ }
1228
+ Object.defineProperty(PDS, "theme", {
1229
+ get() {
1230
+ try {
1231
+ if (typeof window === "undefined")
1232
+ return null;
1233
+ return localStorage.getItem(__themeStorageKey) || null;
1234
+ } catch (e) {
1235
+ return null;
1236
+ }
1237
+ },
1238
+ set(value) {
1239
+ try {
1240
+ if (typeof window === "undefined")
1241
+ return;
1242
+ const currentPreset = PDS.currentConfig?.design || null;
1243
+ const resolvedTheme = resolveThemePreference(value);
1244
+ if (currentPreset && !isPresetThemeCompatible(currentPreset, resolvedTheme)) {
1245
+ const presetName = currentPreset?.name || PDS.currentPreset?.name || PDS.currentConfig?.preset || "current preset";
1246
+ console.warn(
1247
+ `PDS theme "${resolvedTheme}" not supported by preset "${presetName}".`
1248
+ );
1249
+ PDS.dispatchEvent(
1250
+ new CustomEvent("pds:theme:blocked", {
1251
+ detail: { theme: value, resolvedTheme, preset: presetName }
1252
+ })
1253
+ );
1254
+ return;
1255
+ }
1256
+ if (value === null || value === void 0) {
1257
+ localStorage.removeItem(__themeStorageKey);
1258
+ } else {
1259
+ localStorage.setItem(__themeStorageKey, value);
1260
+ }
1261
+ __applyResolvedTheme(value);
1262
+ __setupSystemListenerIfNeeded(value);
1263
+ PDS.dispatchEvent(
1264
+ new CustomEvent("pds:theme:changed", {
1265
+ detail: { theme: value, source: "api" }
1266
+ })
1267
+ );
1268
+ } catch (e) {
1269
+ }
1270
+ }
1271
+ });
1272
+ PDS.defaultEnhancers = [];
1273
+ async function start(config2) {
1274
+ const mode = config2 && config2.mode || "live";
1275
+ const { mode: _omit, ...rest } = config2 || {};
1276
+ if (mode === "static")
1277
+ return staticInit(rest);
1278
+ const assetRootURL = resolveRuntimeAssetRoot(rest, { resolvePublicAssetURL });
1279
+ const managerUrl = rest?.managerURL || rest?.public?.managerURL || rest?.manager?.url || new URL("core/pds-manager.js", assetRootURL).href || new URL("./pds-manager.js", import.meta.url).href;
1280
+ const { startLive } = await import(managerUrl);
1281
+ return startLive(PDS, rest, {
1282
+ emitReady: __emitPDSReady,
1283
+ emitConfigChanged: __emitPDSConfigChanged,
1284
+ applyResolvedTheme: __applyResolvedTheme,
1285
+ setupSystemListenerIfNeeded: __setupSystemListenerIfNeeded
1286
+ });
1287
+ }
1288
+ PDS.start = start;
1289
+ async function staticInit(config2) {
1290
+ if (!config2 || typeof config2 !== "object") {
1291
+ throw new Error(
1292
+ "PDS.start({ mode: 'static', ... }) requires a valid configuration object"
1293
+ );
1294
+ }
1295
+ const applyGlobalStyles = config2.applyGlobalStyles ?? true;
1296
+ const manageTheme = config2.manageTheme ?? true;
1297
+ const themeStorageKey = config2.themeStorageKey ?? "pure-ds-theme";
1298
+ let staticPaths = config2.staticPaths ?? {};
1299
+ const assetRootURL = resolveRuntimeAssetRoot(config2, { resolvePublicAssetURL });
1300
+ const cfgAuto = config2 && config2.autoDefine || null;
1301
+ let autoDefineBaseURL;
1302
+ if (cfgAuto && cfgAuto.baseURL) {
1303
+ autoDefineBaseURL = ensureTrailingSlash2(
1304
+ ensureAbsoluteAssetURL(cfgAuto.baseURL, { preferModule: false })
1305
+ );
1306
+ } else {
1307
+ autoDefineBaseURL = `${assetRootURL}components/`;
1308
+ }
1309
+ const autoDefinePreload = cfgAuto && Array.isArray(cfgAuto.predefine) && cfgAuto.predefine || [];
1310
+ const autoDefineMapper = cfgAuto && typeof cfgAuto.mapper === "function" && cfgAuto.mapper || null;
1311
+ try {
1312
+ attachFoucListener(PDS);
1313
+ const { resolvedTheme } = resolveThemeAndApply({
1314
+ manageTheme,
1315
+ themeStorageKey,
1316
+ applyResolvedTheme: __applyResolvedTheme,
1317
+ setupSystemListenerIfNeeded: __setupSystemListenerIfNeeded
1318
+ });
1319
+ const runtimeConfig = await __loadRuntimeConfig(assetRootURL, config2);
1320
+ const userEnhancers = Array.isArray(config2?.enhancers) ? config2.enhancers : config2?.enhancers && typeof config2.enhancers === "object" ? Object.values(config2.enhancers) : [];
1321
+ const resolvedConfig = runtimeConfig?.config ? {
1322
+ ...runtimeConfig.config,
1323
+ ...config2,
1324
+ design: config2?.design || runtimeConfig.config.design,
1325
+ preset: config2?.preset || runtimeConfig.config.preset
1326
+ } : { ...config2 };
1327
+ const baseStaticPaths = {
1328
+ tokens: `${assetRootURL}styles/pds-tokens.css.js`,
1329
+ primitives: `${assetRootURL}styles/pds-primitives.css.js`,
1330
+ components: `${assetRootURL}styles/pds-components.css.js`,
1331
+ utilities: `${assetRootURL}styles/pds-utilities.css.js`,
1332
+ styles: `${assetRootURL}styles/pds-styles.css.js`
1333
+ };
1334
+ const runtimePaths = runtimeConfig?.paths || {};
1335
+ staticPaths = { ...baseStaticPaths, ...runtimePaths, ...staticPaths };
1336
+ PDS.registry.setStaticMode(staticPaths);
1337
+ if (applyGlobalStyles && typeof document !== "undefined") {
1338
+ try {
1339
+ const stylesSheet = await PDS.registry.getStylesheet("styles");
1340
+ if (stylesSheet) {
1341
+ stylesSheet._pds = true;
1342
+ const others = (document.adoptedStyleSheets || []).filter(
1343
+ (s) => s._pds !== true
1344
+ );
1345
+ document.adoptedStyleSheets = [...others, stylesSheet];
1346
+ __emitPDSConfigChanged({
1347
+ mode: "static",
1348
+ source: "static:styles-applied"
1349
+ });
1350
+ }
1351
+ } catch (e) {
1352
+ __defaultLog.call(PDS, "warn", "Failed to apply static styles:", e);
1353
+ }
1354
+ }
1355
+ let autoDefiner = null;
1356
+ let mergedEnhancers = [];
1357
+ try {
1358
+ const defaultPDSEnhancers = await __loadDefaultEnhancers();
1359
+ const res = await setupAutoDefinerAndEnhancers({
1360
+ autoDefineBaseURL,
1361
+ autoDefinePreload,
1362
+ autoDefineMapper,
1363
+ enhancers: userEnhancers,
1364
+ autoDefineOverrides: cfgAuto || null,
1365
+ autoDefinePreferModule: !(cfgAuto && cfgAuto.baseURL)
1366
+ }, { baseEnhancers: defaultPDSEnhancers });
1367
+ autoDefiner = res.autoDefiner;
1368
+ mergedEnhancers = res.mergedEnhancers || [];
1369
+ } catch (error) {
1370
+ __defaultLog.call(
1371
+ PDS,
1372
+ "error",
1373
+ "\u274C Failed to initialize AutoDefiner/Enhancers (static):",
1374
+ error
1375
+ );
1376
+ }
1377
+ const cloneableConfig = __stripFunctionsForClone(config2);
1378
+ PDS.currentConfig = Object.freeze({
1379
+ mode: "static",
1380
+ ...structuredClone(cloneableConfig),
1381
+ design: structuredClone(resolvedConfig.design || {}),
1382
+ preset: resolvedConfig.preset,
1383
+ theme: resolvedTheme,
1384
+ enhancers: mergedEnhancers
1385
+ });
1386
+ __emitPDSReady({
1387
+ mode: "static",
1388
+ config: resolvedConfig,
1389
+ theme: resolvedTheme,
1390
+ autoDefiner
1391
+ });
1392
+ return {
1393
+ config: resolvedConfig,
1394
+ theme: resolvedTheme,
1395
+ autoDefiner
1396
+ };
1397
+ } catch (error) {
1398
+ PDS.dispatchEvent(new CustomEvent("pds:error", { detail: { error } }));
1399
+ throw error;
1400
+ }
1401
+ }
1402
+
1403
+ // pds.config.js
1404
+ var config = {
1405
+ mode: "live",
1406
+ liveEdit: true,
1407
+ preset: "default",
1408
+ autoDefine: {
1409
+ predefine: ["pds-icon", "pds-drawer", "pds-toaster", "pds-form"]
1410
+ },
1411
+ log(level, message, ...data) {
1412
+ console[level](message, ...data);
1413
+ }
1414
+ };
1415
+
1416
+ // package.json
1417
+ var package_default = {
1418
+ name: "@pure-ds/core",
1419
+ shortname: "pds",
1420
+ version: "0.7.2",
1421
+ description: "Why develop a Design System when you can generate one?",
1422
+ repository: {
1423
+ type: "git",
1424
+ url: "git+https://github.com/Pure-Web-Foundation/pure-ds.git"
1425
+ },
1426
+ bugs: {
1427
+ url: "https://github.com/Pure-Web-Foundation/pure-ds/issues"
1428
+ },
1429
+ homepage: "https://puredesignsystem.z6.web.core.windows.net/",
1430
+ keywords: [
1431
+ "design-system",
1432
+ "css",
1433
+ "web-components",
1434
+ "lit",
1435
+ "constructable-stylesheets",
1436
+ "tokens",
1437
+ "utilities",
1438
+ "a11y"
1439
+ ],
1440
+ type: "module",
1441
+ main: "./public/assets/pds/core.js",
1442
+ module: "./public/assets/pds/core.js",
1443
+ types: "./dist/types/pds.d.ts",
1444
+ bin: {
1445
+ "pds-build": "packages/pds-cli/bin/pds-static.js",
1446
+ "pds-sync-assets": "packages/pds-cli/bin/sync-assets.js",
1447
+ "pds-build-icons": "packages/pds-cli/bin/pds-build-icons.js",
1448
+ "pds-import": "packages/pds-cli/bin/pds-import.js",
1449
+ "pds-setup-copilot": "packages/pds-cli/bin/pds-setup-copilot.js",
1450
+ "pds-init-config": "packages/pds-cli/bin/pds-init-config.js",
1451
+ "pds-bootstrap": "packages/pds-cli/bin/pds-bootstrap.js"
1452
+ },
1453
+ exports: {
1454
+ ".": {
1455
+ types: "./src/js/pds.d.ts",
1456
+ import: "./public/assets/pds/core.js"
1457
+ },
1458
+ "./pds-core": "./src/js/pds.js",
1459
+ "./auto-define/*": "./public/auto-define/*"
1460
+ },
1461
+ files: [
1462
+ ".github/copilot-instructions.md",
1463
+ ".cursorrules",
1464
+ "dist/types/",
1465
+ "public/assets/js/",
1466
+ "public/assets/pds/components/",
1467
+ "public/assets/pds/templates/",
1468
+ "public/assets/pds/core.js",
1469
+ "public/assets/pds/core/",
1470
+ "public/assets/pds/external/",
1471
+ "public/assets/pds/vscode-custom-data.json",
1472
+ "public/assets/pds/pds.css-data.json",
1473
+ "public/assets/pds/pds-css-complete.json",
1474
+ "public/auto-define/",
1475
+ "public/pds/components/",
1476
+ "public/assets/pds/icons/pds-icons.svg",
1477
+ "packages/pds-cli/bin/",
1478
+ "packages/pds-cli/lib/",
1479
+ "src/js/pds.d.ts",
1480
+ "src/js/pds.js",
1481
+ "src/js/pds-live-manager/",
1482
+ "src/js/pds-core/",
1483
+ "custom-elements.json",
1484
+ "custom-elements-manifest.config.js",
1485
+ "pds.html-data.json",
1486
+ "pds.css-data.json",
1487
+ "readme.md",
1488
+ "INTELLISENSE.md",
1489
+ "CSS-INTELLISENSE-LIMITATION.md",
1490
+ "CSS-INTELLISENSE-QUICK-REF.md"
1491
+ ],
1492
+ scripts: {
1493
+ test: 'echo "Error: no test specified" && exit 1',
1494
+ dev: "node esbuild-dev.js",
1495
+ prebuild: "npm run types",
1496
+ build: "node esbuild-build.js",
1497
+ types: "tsc -p tsconfig.json && node scripts/sync-types.mjs",
1498
+ postinstall: "node packages/pds-cli/bin/postinstall.mjs",
1499
+ "prepds:build": "npm run types",
1500
+ "pds:build": "node packages/pds-cli/bin/pds-static.js",
1501
+ "pds:build-icons": "node packages/pds-cli/bin/pds-build-icons.js",
1502
+ "pds:bootstrap": "node packages/pds-cli/bin/pds-bootstrap.js",
1503
+ "pds:manifest": "node packages/pds-cli/bin/generate-manifest.js",
1504
+ "pds:css-data": "node packages/pds-cli/bin/generate-css-data.js",
1505
+ "pds:import": "node packages/pds-cli/bin/pds-import.js",
1506
+ "pds:dx": "node packages/pds-cli/bin/pds-dx.js",
1507
+ "storybook:generate": "cd packages/pds-storybook && npm run generate-stories",
1508
+ "storybook:dev": "cd packages/pds-storybook && npm run storybook:dev",
1509
+ "storybook:build": "cd packages/pds-storybook && npm run storybook:build"
1510
+ },
1511
+ author: "Marc van Neerven",
1512
+ license: "ISC",
1513
+ engines: {
1514
+ node: ">=18"
1515
+ },
1516
+ publishConfig: {
1517
+ access: "public"
1518
+ },
1519
+ devDependencies: {
1520
+ "@custom-elements-manifest/analyzer": "^0.9.9",
1521
+ esbuild: "^0.19.0",
1522
+ "fs-extra": "^11.1.1",
1523
+ typescript: "^5.6.3",
1524
+ "@types/node": "^22.10.2"
1525
+ },
1526
+ dependencies: {
1527
+ lit: "^3.3.1",
1528
+ "pure-web": "1.1.32"
1529
+ },
1530
+ customElements: "custom-elements.json"
1531
+ };
1532
+
1533
+ // src/js/app.js
1534
+ await PDS.start(config);
1535
+ var rawRepoUrl = typeof package_default.repository === "string" ? package_default.repository : package_default.repository?.url;
1536
+ var repoUrl = rawRepoUrl ? rawRepoUrl.replace(/^git\+/, "").replace(/\.git$/, "") : "";
1537
+ var homepageUrl = package_default.homepage || repoUrl;
1538
+ var issuesUrl = package_default.bugs?.url || "";
1539
+ document.body.innerHTML = /*html*/
1540
+ `
3
1541
  <pds-toaster id="global-toaster"></pds-toaster>
4
1542
 
5
1543
  <div class="container text-center">
6
1544
  <img src="/assets/img/pds-logo.svg" alt="PDS Logo" width="64" height="64" />
7
1545
  <header class="container section">
8
- <h1>${w.name} ${w.version}</h1>
9
- <small class="text-muted">${w.description}</small>
1546
+ <h1>${package_default.name} ${package_default.version}</h1>
1547
+ <small class="text-muted">${package_default.description}</small>
10
1548
  </header>
11
1549
  </div>
12
1550
  `;
1551
+ //# sourceMappingURL=app.js.map