@yassirbenmoussa/aicommerce-sdk 1.9.3 → 1.9.4

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.
@@ -1,11 +1,11 @@
1
1
  var AICommerceSDK=(function(exports){'use strict';/*! AI Commerce SDK v1.0.0 | MIT License | https://aicommerce.dev */
2
- var O=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var pe=Object.prototype.hasOwnProperty;var B=(a,r)=>()=>(a&&(r=a(a=0)),r);var G=(a,r)=>{for(var e in r)O(a,e,{get:r[e],enumerable:true});},ue=(a,r,e,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let h of le(r))!pe.call(a,h)&&h!==e&&O(a,h,{get:()=>r[h],enumerable:!(d=me(r,h))||d.enumerable});return a};var j=a=>ue(O({},"__esModule",{value:true}),a);var W={};G(W,{AICommerce:()=>exports.AICommerce,AICommerceError:()=>exports.AICommerceError});exports.AICommerce=void 0;exports.AICommerceError=void 0;var M=B(()=>{exports.AICommerce=class a{constructor(r){this.sessionToken=null;this.products={create:async r=>this.request("/api/v1/products",{method:"POST",body:JSON.stringify(r)}),batchUpsert:async r=>this.request("/api/v1/products",{method:"POST",body:JSON.stringify({products:r})}),list:async r=>{let e=new URLSearchParams;r?.page&&e.set("page",String(r.page)),r?.perPage&&e.set("perPage",String(r.perPage)),r?.search&&e.set("search",r.search),r?.categoryId&&e.set("categoryId",r.categoryId),r?.isActive!==void 0&&e.set("isActive",String(r.isActive));let d=e.toString();return this.request(`/api/v1/products${d?`?${d}`:""}`)},get:async r=>this.request(`/api/v1/products/${r}`),update:async(r,e)=>this.request(`/api/v1/products/${r}`,{method:"PUT",body:JSON.stringify(e)}),delete:async r=>this.request(`/api/v1/products/${r}`,{method:"DELETE"})};if(!r.apiKey)throw new Error("AICommerce: apiKey is required");this.apiKey=r.apiKey,this.storeId=r.storeId,this.baseUrl=this.normalizeUrl(r.baseUrl||this.detectBaseUrl()),this.timeout=r.timeout||3e4;}detectBaseUrl(){if(typeof window<"u"){let r=document.querySelector("script[data-aicommerce-url]");if(r)return r.getAttribute("data-aicommerce-url")||"https://api.aicommerce.dev"}return "https://api.aicommerce.dev"}normalizeUrl(r){return r.replace(/\/$/,"")}async request(r,e={}){let d=`${this.baseUrl}${r}`,h=new AbortController,s=setTimeout(()=>h.abort(),this.timeout);try{let g=await fetch(d,{...e,signal:h.signal,headers:{"Content-Type":"application/json","x-api-key":this.apiKey,...this.storeId&&{"x-store-id":this.storeId},...this.sessionToken&&{"X-Session-Token":this.sessionToken},...e.headers}});if(clearTimeout(s),!g.ok){let L=await g.json().catch(()=>({})),w={code:L.code||"UNKNOWN_ERROR",message:L.message||L.error||`HTTP ${g.status}`,status:g.status};throw new exports.AICommerceError(w.message,w.code,w.status)}return g.json()}catch(g){throw clearTimeout(s),g instanceof exports.AICommerceError?g:g instanceof Error&&g.name==="AbortError"?new exports.AICommerceError("Request timeout","TIMEOUT",408):new exports.AICommerceError(g instanceof Error?g.message:"Unknown error","NETWORK_ERROR",0)}}async chat(r,e){let d=typeof r=="string"?{message:r,context:e,sessionToken:this.sessionToken||void 0}:{...r,sessionToken:r.sessionToken||this.sessionToken||void 0},h=await this.request("/api/v1/chat",{method:"POST",body:JSON.stringify(d)});return h.sessionToken&&(this.sessionToken=h.sessionToken),h}async chatWithAudio(r,e){let d=await r.arrayBuffer(),s={audioBase64:btoa(new Uint8Array(d).reduce((L,w)=>L+String.fromCharCode(w),"")),audioMimeType:r.type||"audio/webm",context:e,sessionToken:this.sessionToken||void 0},g=await this.request("/api/v1/chat",{method:"POST",body:JSON.stringify(s)});return g.sessionToken&&(this.sessionToken=g.sessionToken),g}async createSession(){let r=await this.request("/api/v1/chat/session",{method:"POST"});return this.sessionToken=r.session.token,r.session}clearSession(){this.sessionToken=null;}getSessionToken(){return this.sessionToken}setSessionToken(r){this.sessionToken=r;}async checkApiKey(){return this.request("/api/v1/api-key/check")}async getHistory(r){let e=new URLSearchParams;return e.set("sessionToken",r.sessionToken),r.page&&e.set("page",String(r.page)),r.limit&&e.set("limit",String(r.limit)),this.request(`/api/v1/chat/history?${e.toString()}`)}async upload(r,e){let d=new FormData;d.append("file",r),e?.folder&&d.append("folder",e.folder),e?.productId&&d.append("productId",e.productId),e?.isPrimary&&d.append("isPrimary","true");let h=`${this.baseUrl}/api/v1/upload`,s=await fetch(h,{method:"POST",headers:{"X-API-Key":this.apiKey},body:d});if(!s.ok){let g=await s.json().catch(()=>({}));throw new exports.AICommerceError(g.message||g.error||`HTTP ${s.status}`,g.code||"UPLOAD_ERROR",s.status)}return s.json()}static async quickChat(r){return new a({apiKey:r.apiKey,baseUrl:r.baseUrl}).chat(r.message,r.context)}},exports.AICommerceError=class a extends Error{constructor(r,e,d){super(r),this.name="AICommerceError",this.code=e,this.status=d,Object.setPrototypeOf(this,a.prototype);}};});function ge(a){let r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);return r?{r:parseInt(r[1],16),g:parseInt(r[2],16),b:parseInt(r[3],16)}:{r:99,g:102,b:241}}function z(a){let r=a.primaryColor,e=ge(r),d=a.position==="bottom-left";return `
2
+ var se=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var dt=Object.prototype.hasOwnProperty;var pt=(r,e,t)=>e in r?se(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t;var ce=(r,e)=>()=>(r&&(e=r(r=0)),e);var Oe=(r,e)=>{for(var t in e)se(r,t,{get:e[t],enumerable:true});},ut=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of lt(e))!dt.call(r,n)&&n!==t&&se(r,n,{get:()=>e[n],enumerable:!(i=ct(e,n))||i.enumerable});return r};var xe=r=>ut(se({},"__esModule",{value:true}),r);var y=(r,e,t)=>pt(r,typeof e!="symbol"?e+"":e,t);var ke={};Oe(ke,{AICommerce:()=>exports.AICommerce,AICommerceError:()=>exports.AICommerceError});exports.AICommerce=void 0;exports.AICommerceError=void 0;var V=ce(()=>{exports.AICommerce=class r{constructor(e){this.sessionToken=null;this.products={create:async e=>this.request("/api/v1/products",{method:"POST",body:JSON.stringify(e)}),batchUpsert:async e=>this.request("/api/v1/products",{method:"POST",body:JSON.stringify({products:e})}),list:async e=>{let t=new URLSearchParams;e?.page&&t.set("page",String(e.page)),e?.perPage&&t.set("perPage",String(e.perPage)),e?.search&&t.set("search",e.search),e?.categoryId&&t.set("categoryId",e.categoryId),e?.isActive!==void 0&&t.set("isActive",String(e.isActive));let i=t.toString();return this.request(`/api/v1/products${i?`?${i}`:""}`)},get:async e=>this.request(`/api/v1/products/${e}`),update:async(e,t)=>this.request(`/api/v1/products/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:async e=>this.request(`/api/v1/products/${e}`,{method:"DELETE"})};if(!e.apiKey)throw new Error("AICommerce: apiKey is required");this.apiKey=e.apiKey,this.storeId=e.storeId,this.baseUrl=this.normalizeUrl(e.baseUrl||this.detectBaseUrl()),this.timeout=e.timeout||3e4;}detectBaseUrl(){if(typeof window<"u"){let e=document.querySelector("script[data-aicommerce-url]");if(e)return e.getAttribute("data-aicommerce-url")||"https://api.aicommerce.dev"}return "https://api.aicommerce.dev"}normalizeUrl(e){return e.replace(/\/$/,"")}async request(e,t={}){let i=`${this.baseUrl}${e}`,n=new AbortController,a=setTimeout(()=>n.abort(),this.timeout);try{let o=await fetch(i,{...t,signal:n.signal,headers:{"Content-Type":"application/json","x-api-key":this.apiKey,...this.storeId&&{"x-store-id":this.storeId},...this.sessionToken&&{"X-Session-Token":this.sessionToken},...t.headers}});if(clearTimeout(a),!o.ok){let s=await o.json().catch(()=>({})),l={code:s.code||"UNKNOWN_ERROR",message:s.message||s.error||`HTTP ${o.status}`,status:o.status};throw new exports.AICommerceError(l.message,l.code,l.status)}return o.json()}catch(o){throw clearTimeout(a),o instanceof exports.AICommerceError?o:o instanceof Error&&o.name==="AbortError"?new exports.AICommerceError("Request timeout","TIMEOUT",408):new exports.AICommerceError(o instanceof Error?o.message:"Unknown error","NETWORK_ERROR",0)}}async chat(e,t){let i=typeof e=="string"?{message:e,context:t,sessionToken:this.sessionToken||void 0}:{...e,sessionToken:e.sessionToken||this.sessionToken||void 0},n=await this.request("/api/v1/chat",{method:"POST",body:JSON.stringify(i)});return n.sessionToken&&(this.sessionToken=n.sessionToken),n}async chatWithAudio(e,t){let i=await e.arrayBuffer(),a={audioBase64:btoa(new Uint8Array(i).reduce((s,l)=>s+String.fromCharCode(l),"")),audioMimeType:e.type||"audio/webm",context:t,sessionToken:this.sessionToken||void 0},o=await this.request("/api/v1/chat",{method:"POST",body:JSON.stringify(a)});return o.sessionToken&&(this.sessionToken=o.sessionToken),o}async createSession(){let e=await this.request("/api/v1/chat/session",{method:"POST"});return this.sessionToken=e.session.token,e.session}clearSession(){this.sessionToken=null;}getSessionToken(){return this.sessionToken}setSessionToken(e){this.sessionToken=e;}async checkApiKey(){return this.request("/api/v1/api-key/check")}async getHistory(e){let t=new URLSearchParams;return t.set("sessionToken",e.sessionToken),e.page&&t.set("page",String(e.page)),e.limit&&t.set("limit",String(e.limit)),this.request(`/api/v1/chat/history?${t.toString()}`)}async upload(e,t){let i=new FormData;i.append("file",e),t?.folder&&i.append("folder",t.folder),t?.productId&&i.append("productId",t.productId),t?.isPrimary&&i.append("isPrimary","true");let n=`${this.baseUrl}/api/v1/upload`,a=await fetch(n,{method:"POST",headers:{"X-API-Key":this.apiKey},body:i});if(!a.ok){let o=await a.json().catch(()=>({}));throw new exports.AICommerceError(o.message||o.error||`HTTP ${a.status}`,o.code||"UPLOAD_ERROR",a.status)}return a.json()}static async quickChat(e){return new r({apiKey:e.apiKey,baseUrl:e.baseUrl}).chat(e.message,e.context)}},exports.AICommerceError=class r extends Error{constructor(e,t,i){super(e),this.name="AICommerceError",this.code=t,this.status=i,Object.setPrototypeOf(this,r.prototype);}};});function mt(r){let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:{r:99,g:102,b:241}}function ye(r){let e=r.primaryColor,t=mt(e),i=r.position==="bottom-left";return `
3
3
  /* AI Commerce Widget Styles */
4
4
  #aicommerce-widget {
5
- --aic-primary: ${r};
6
- --aic-primary-rgb: ${e.r}, ${e.g}, ${e.b};
7
- --aic-primary-light: rgba(${e.r}, ${e.g}, ${e.b}, 0.1);
8
- --aic-primary-dark: rgba(${e.r}, ${e.g}, ${e.b}, 0.9);
5
+ --aic-primary: ${e};
6
+ --aic-primary-rgb: ${t.r}, ${t.g}, ${t.b};
7
+ --aic-primary-light: rgba(${t.r}, ${t.g}, ${t.b}, 0.1);
8
+ --aic-primary-dark: rgba(${t.r}, ${t.g}, ${t.b}, 0.9);
9
9
  --aic-bg: #ffffff;
10
10
  --aic-bg-secondary: #f8fafc;
11
11
  --aic-text: #1e293b;
@@ -13,14 +13,14 @@ var O=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object
13
13
  --aic-border: #e2e8f0;
14
14
  --aic-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
15
15
  --aic-radius: 16px;
16
- --aic-z-index: ${a.zIndex};
16
+ --aic-z-index: ${r.zIndex};
17
17
 
18
18
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
19
19
  font-size: 14px;
20
20
  line-height: 1.5;
21
21
  position: fixed;
22
22
  bottom: 20px;
23
- ${d?"left: 20px;":"right: 20px;"}
23
+ ${i?"left: 20px;":"right: 20px;"}
24
24
  z-index: var(--aic-z-index);
25
25
  }
26
26
 
@@ -74,7 +74,7 @@ var O=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object
74
74
  .aicommerce-chat {
75
75
  position: absolute;
76
76
  bottom: 0;
77
- ${d?"left: 0;":"right: 0;"}
77
+ ${i?"left: 0;":"right: 0;"}
78
78
  width: 380px;
79
79
  max-width: calc(100vw - 40px);
80
80
  height: 600px;
@@ -86,7 +86,7 @@ var O=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object
86
86
  flex-direction: column;
87
87
  overflow: hidden;
88
88
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
89
- transform-origin: bottom ${d?"left":"right"};
89
+ transform-origin: bottom ${i?"left":"right"};
90
90
  }
91
91
 
92
92
  .aicommerce-chat.aicommerce-closed {
@@ -380,9 +380,9 @@ var O=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object
380
380
 
381
381
  .aicommerce-waveform-bars {
382
382
  display: flex;
383
- align-items: center;
383
+ align-items: flex-end;
384
384
  gap: 2px;
385
- height: 24px;
385
+ height: 32px;
386
386
  cursor: pointer;
387
387
  width: 100%;
388
388
  }
@@ -390,9 +390,9 @@ var O=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object
390
390
  .aicommerce-waveform-bar {
391
391
  width: 3px;
392
392
  border-radius: 2px;
393
- min-height: 3px;
393
+ min-height: 4px;
394
394
  transition: background-color 0.1s;
395
- flex-shrink: 0;
395
+ flex: 0 0 3px;
396
396
  }
397
397
 
398
398
  .aicommerce-audio-time {
@@ -515,7 +515,7 @@ var O=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object
515
515
  @media (max-width: 420px) {
516
516
  #aicommerce-widget {
517
517
  bottom: 16px;
518
- ${d?"left: 16px;":"right: 16px;"}
518
+ ${i?"left: 16px;":"right: 16px;"}
519
519
  }
520
520
 
521
521
  .aicommerce-chat {
@@ -847,6 +847,41 @@ var O=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object
847
847
  flex-shrink: 0;
848
848
  }
849
849
 
850
+ .aicommerce-product-actions {
851
+ display: flex;
852
+ gap: 8px;
853
+ margin-top: 8px;
854
+ }
855
+
856
+ .aicommerce-product-actions .aicommerce-add-to-cart {
857
+ margin-top: 0;
858
+ flex: 1;
859
+ }
860
+
861
+ .aicommerce-buy-now {
862
+ flex: 1;
863
+ padding: 8px 12px;
864
+ background: transparent;
865
+ color: var(--aic-primary);
866
+ border: 1px solid var(--aic-primary);
867
+ border-radius: 6px;
868
+ font-size: 12px;
869
+ font-weight: 500;
870
+ cursor: pointer;
871
+ transition: all 0.2s;
872
+ display: flex;
873
+ align-items: center;
874
+ justify-content: center;
875
+ }
876
+
877
+ .aicommerce-buy-now:hover {
878
+ background: rgba(0, 0, 0, 0.05);
879
+ }
880
+
881
+ .aicommerce-buy-now:active {
882
+ transform: translateY(1px);
883
+ }
884
+
850
885
  /* Spinner animation for loading state */
851
886
  @keyframes aicommerce-spin {
852
887
  to { transform: rotate(360deg); }
@@ -855,25 +890,137 @@ var O=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object
855
890
  .aicommerce-spinner {
856
891
  animation: aicommerce-spin 1s linear infinite;
857
892
  }
858
- `}function _(a){let r=document.createElement("style");r.id="aicommerce-widget-styles",r.textContent=a;let e=document.getElementById("aicommerce-widget-styles");return e&&e.remove(),document.head.appendChild(r),r}var Q=B(()=>{});var Z={};G(Z,{AICommerceWidget:()=>exports.AICommerceWidget,createWidget:()=>D});function D(a){if(!a.apiKey)throw new Error("AICommerceWidget: apiKey is required");let r=new exports.AICommerce({apiKey:a.apiKey,storeId:a.storeId,baseUrl:a.baseUrl}),e={isOpen:false,isLoading:true,isRecording:false,messages:[],storeConfig:null},d=null,h=[],s=null,w=null,m;async function ee(){try{let o=a.baseUrl||N(),i=await fetch(`${o}/api/v1/store`,{headers:{"x-api-key":a.apiKey}});return i.ok?(await i.json()).store:null}catch(o){return console.error("Failed to fetch store config:",o),null}}function N(){if(typeof window<"u"){let o=document.querySelector("script[data-aicommerce-url]");if(o)return o.getAttribute("data-aicommerce-url")||""}return "https://api.aicommerce.dev"}async function re(){e.storeConfig=await ee();let o=a.displayMode||"widget",i=o==="embedded";m={apiKey:a.apiKey,storeId:a.storeId,baseUrl:a.baseUrl||N(),displayMode:o,container:a.container,maxHeight:a.maxHeight||"600px",placeholder:a.placeholder||"Ask me anything about our products...",position:a.position||"bottom-right",theme:a.theme||"auto",primaryColor:a.primaryColor||e.storeConfig?.primaryColor||"#6366f1",welcomeMessage:a.welcomeMessage||e.storeConfig?.welcomeMessage||"Hi! How can I help you find the perfect product today?",botName:a.botName||e.storeConfig?.chatBotName||"Shopping Assistant",zIndex:a.zIndex||9999,buttonText:a.buttonText||"\u{1F4AC}",hideLauncher:a.hideLauncher||false,addToCartText:a.addToCartText,onOpen:a.onOpen,onClose:a.onClose,onProductClick:a.onProductClick,onAddToCart:a.onAddToCart,onMessage:a.onMessage};let c=z(m);if(w=_(c),i){let b=null;if(typeof a.container=="string"?b=document.querySelector(a.container):a.container instanceof HTMLElement&&(b=a.container),!b){console.error("[AI Commerce] Embedded mode requires a valid container element or selector");return}s=document.createElement("div"),s.id="aicommerce-widget",s.className=`aicommerce-widget aicommerce-embedded aicommerce-theme-${m.theme}`,s.style.setProperty("--aic-max-height",m.maxHeight),b.appendChild(s),e.isOpen=true;}else s=document.createElement("div"),s.id="aicommerce-widget",s.className=`aicommerce-widget aicommerce-${m.position} aicommerce-theme-${m.theme}`,document.body.appendChild(s);k(),i||e.messages.push({role:"assistant",content:m.welcomeMessage}),e.isLoading=false,k();}async function te(o,i=1){let c=o;if(o.includes("gid://")){let u=o.match(/\/(\d+)$/);u&&(c=u[1]);}if(!(await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:c,quantity:i})})).ok)throw new Error("Failed to add to cart");document.dispatchEvent(new CustomEvent("cart:refresh"));}function k(){if(!s)return;let o=m.displayMode==="embedded",i=e.messages.some(l=>l.role==="user");o&&(s.classList.remove("aicommerce-no-messages","aicommerce-has-messages"),s.classList.add(i?"aicommerce-has-messages":"aicommerce-no-messages"));let c=m.placeholder||"Ask me anything about our products...",b=`
893
+
894
+ /* ============================================
895
+ Markdown Content Styles
896
+ ============================================ */
897
+ .aicommerce-message-content p {
898
+ margin: 0 0 0.5em 0;
899
+ }
900
+ .aicommerce-message-content p:last-child {
901
+ margin-bottom: 0;
902
+ }
903
+
904
+ .aicommerce-message-content strong {
905
+ font-weight: 600;
906
+ }
907
+
908
+ .aicommerce-message-content em {
909
+ font-style: italic;
910
+ }
911
+
912
+ .aicommerce-message-content a {
913
+ text-decoration: underline;
914
+ color: inherit;
915
+ }
916
+ .aicommerce-user .aicommerce-message-content a {
917
+ color: rgba(255, 255, 255, 0.95);
918
+ }
919
+ .aicommerce-assistant .aicommerce-message-content a {
920
+ color: var(--aic-primary);
921
+ }
922
+
923
+ .aicommerce-message-content code {
924
+ background: rgba(0, 0, 0, 0.1);
925
+ padding: 0.1em 0.4em;
926
+ border-radius: 4px;
927
+ font-family: 'Courier New', Courier, monospace;
928
+ font-size: 0.9em;
929
+ }
930
+ .aicommerce-user .aicommerce-message-content code {
931
+ background: rgba(255, 255, 255, 0.2);
932
+ }
933
+
934
+ .aicommerce-message-content ul,
935
+ .aicommerce-message-content ol {
936
+ margin: 0.5em 0;
937
+ padding-left: 1.5em;
938
+ }
939
+
940
+ .aicommerce-message-content li {
941
+ margin-bottom: 0.25em;
942
+ }
943
+
944
+ .aicommerce-message-content blockquote {
945
+ border-left: 3px solid var(--aic-primary);
946
+ margin: 0.5em 0;
947
+ padding-left: 1em;
948
+ opacity: 0.9;
949
+ }
950
+ `}function He(r){let e=document.createElement("style");e.id="aicommerce-widget-styles",e.textContent=r;let t=document.getElementById("aicommerce-widget-styles");return t&&t.remove(),document.head.appendChild(e),e}var Ue=ce(()=>{});function $e(){return {async:false,breaks:false,extensions:null,gfm:true,hooks:null,pedantic:false,renderer:null,silent:false,tokenizer:null,walkTokens:null}}function Ke(r){K=r;}function x(r,e=""){let t=typeof r=="string"?r:r.source,i={replace:(n,a)=>{let o=typeof a=="string"?a:a.source;return o=o.replace(L.caret,"$1"),t=t.replace(n,o),i},getRegex:()=>new RegExp(t,e)};return i}function M(r,e){if(e){if(L.escapeTest.test(r))return r.replace(L.escapeReplace,je)}else if(L.escapeTestNoEncode.test(r))return r.replace(L.escapeReplaceNoEncode,je);return r}function Ne(r){try{r=encodeURI(r).replace(L.percentDecode,"%");}catch{return null}return r}function We(r,e){let t=r.replace(L.findPipe,(a,o,s)=>{let l=false,c=o;for(;--c>=0&&s[c]==="\\";)l=!l;return l?"|":" |"}),i=t.split(L.splitPipe),n=0;if(i[0].trim()||i.shift(),i.length>0&&!i.at(-1)?.trim()&&i.pop(),e)if(i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;n<i.length;n++)i[n]=i[n].trim().replace(L.slashPipe,"|");return i}function te(r,e,t){let i=r.length;if(i===0)return "";let n=0;for(;n<i;){let a=r.charAt(i-n-1);if(a===e&&true)n++;else break}return r.slice(0,i-n)}function Zt(r,e){if(r.indexOf(e[1])===-1)return -1;let t=0;for(let i=0;i<r.length;i++)if(r[i]==="\\")i++;else if(r[i]===e[0])t++;else if(r[i]===e[1]&&(t--,t<0))return i;return t>0?-2:-1}function Fe(r,e,t,i,n){let a=e.href,o=e.title||null,s=r[1].replace(n.other.outputLinkReplace,"$1");i.state.inLink=true;let l={type:r[0].charAt(0)==="!"?"image":"link",raw:t,href:a,title:o,text:s,tokens:i.inlineTokens(s)};return i.state.inLink=false,l}function Gt(r,e,t){let i=r.match(t.other.indentCodeCompensation);if(i===null)return e;let n=i[1];return e.split(`
951
+ `).map(a=>{let o=a.match(t.other.beginningSpace);if(o===null)return a;let[s]=o;return s.length>=n.length?a.slice(n.length):a}).join(`
952
+ `)}function f(r,e){return F.parse(r,e)}var K,re,L,ht,gt,ft,ne,bt,Se,Ze,Ge,xt,Re,kt,Ae,yt,wt,he,Ee,vt,Qe,Tt,Pe,De,Ct,$t,St,Rt,Xe,At,ge,Le,Ye,Et,Je,Pt,Lt,It,Ve,zt,Mt,et,Bt,qt,_t,Ot,Ht,Ut,Dt,pe,jt,tt,rt,Nt,Ie,Wt,ve,Ft,le,ee,Kt,je,ue,O,me,ze,H,we,de,Qt,F,nt=ce(()=>{K=$e();re={exec:()=>null};L={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:r=>new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}#`),htmlBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}<(?:[a-z].*>|!--)`,"i")},ht=/^(?:[ \t]*(?:\n|$))+/,gt=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ft=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ne=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,bt=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Se=/(?:[*+-]|\d{1,9}[.)])/,Ze=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ge=x(Ze).replace(/bull/g,Se).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),xt=x(Ze).replace(/bull/g,Se).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Re=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,kt=/^[^\n]+/,Ae=/(?!\s*\])(?:\\.|[^\[\]\\])+/,yt=x(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ae).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),wt=x(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Se).getRegex(),he="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Ee=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,vt=x("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Ee).replace("tag",he).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Qe=x(Re).replace("hr",ne).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",he).getRegex(),Tt=x(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Qe).getRegex(),Pe={blockquote:Tt,code:gt,def:yt,fences:ft,heading:bt,hr:ne,html:vt,lheading:Ge,list:wt,newline:ht,paragraph:Qe,table:re,text:kt},De=x("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ne).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",he).getRegex(),Ct={...Pe,lheading:xt,table:De,paragraph:x(Re).replace("hr",ne).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",De).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",he).getRegex()},$t={...Pe,html:x(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ee).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:re,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:x(Re).replace("hr",ne).replace("heading",` *#{1,6} *[^
953
+ ]`).replace("lheading",Ge).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},St=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Rt=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Xe=/^( {2,}|\\)\n(?!\s*$)/,At=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ge=/[\p{P}\p{S}]/u,Le=/[\s\p{P}\p{S}]/u,Ye=/[^\s\p{P}\p{S}]/u,Et=x(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Le).getRegex(),Je=/(?!~)[\p{P}\p{S}]/u,Pt=/(?!~)[\s\p{P}\p{S}]/u,Lt=/(?:[^\s\p{P}\p{S}]|~)/u,It=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Ve=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,zt=x(Ve,"u").replace(/punct/g,ge).getRegex(),Mt=x(Ve,"u").replace(/punct/g,Je).getRegex(),et="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Bt=x(et,"gu").replace(/notPunctSpace/g,Ye).replace(/punctSpace/g,Le).replace(/punct/g,ge).getRegex(),qt=x(et,"gu").replace(/notPunctSpace/g,Lt).replace(/punctSpace/g,Pt).replace(/punct/g,Je).getRegex(),_t=x("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ye).replace(/punctSpace/g,Le).replace(/punct/g,ge).getRegex(),Ot=x(/\\(punct)/,"gu").replace(/punct/g,ge).getRegex(),Ht=x(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ut=x(Ee).replace("(?:-->|$)","-->").getRegex(),Dt=x("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Ut).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),pe=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,jt=x(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",pe).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),tt=x(/^!?\[(label)\]\[(ref)\]/).replace("label",pe).replace("ref",Ae).getRegex(),rt=x(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ae).getRegex(),Nt=x("reflink|nolink(?!\\()","g").replace("reflink",tt).replace("nolink",rt).getRegex(),Ie={_backpedal:re,anyPunctuation:Ot,autolink:Ht,blockSkip:It,br:Xe,code:Rt,del:re,emStrongLDelim:zt,emStrongRDelimAst:Bt,emStrongRDelimUnd:_t,escape:St,link:jt,nolink:rt,punctuation:Et,reflink:tt,reflinkSearch:Nt,tag:Dt,text:At,url:re},Wt={...Ie,link:x(/^!?\[(label)\]\((.*?)\)/).replace("label",pe).getRegex(),reflink:x(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",pe).getRegex()},ve={...Ie,emStrongRDelimAst:qt,emStrongLDelim:Mt,url:x(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Ft={...ve,br:x(Xe).replace("{2,}","*").getRegex(),text:x(ve.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},le={normal:Pe,gfm:Ct,pedantic:$t},ee={normal:Ie,gfm:ve,breaks:Ft,pedantic:Wt},Kt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},je=r=>Kt[r];ue=class{constructor(r){y(this,"options");y(this,"rules");y(this,"lexer");this.options=r||K;}space(r){let e=this.rules.block.newline.exec(r);if(e&&e[0].length>0)return {type:"space",raw:e[0]}}code(r){let e=this.rules.block.code.exec(r);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return {type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:te(t,`
954
+ `)}}}fences(r){let e=this.rules.block.fences.exec(r);if(e){let t=e[0],i=Gt(t,e[3]||"",this.rules);return {type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:i}}}heading(r){let e=this.rules.block.heading.exec(r);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let i=te(t,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(t=i.trim());}return {type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(r){let e=this.rules.block.hr.exec(r);if(e)return {type:"hr",raw:te(e[0],`
955
+ `)}}blockquote(r){let e=this.rules.block.blockquote.exec(r);if(e){let t=te(e[0],`
956
+ `).split(`
957
+ `),i="",n="",a=[];for(;t.length>0;){let o=false,s=[],l;for(l=0;l<t.length;l++)if(this.rules.other.blockquoteStart.test(t[l]))s.push(t[l]),o=true;else if(!o)s.push(t[l]);else break;t=t.slice(l);let c=s.join(`
958
+ `),h=c.replace(this.rules.other.blockquoteSetextReplace,`
959
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
960
+ ${c}`:c,n=n?`${n}
961
+ ${h}`:h;let w=this.lexer.state.top;if(this.lexer.state.top=true,this.lexer.blockTokens(h,a,true),this.lexer.state.top=w,t.length===0)break;let g=a.at(-1);if(g?.type==="code")break;if(g?.type==="blockquote"){let P=g,v=P.raw+`
962
+ `+t.join(`
963
+ `),$=this.blockquote(v);a[a.length-1]=$,i=i.substring(0,i.length-P.raw.length)+$.raw,n=n.substring(0,n.length-P.text.length)+$.text;break}else if(g?.type==="list"){let P=g,v=P.raw+`
964
+ `+t.join(`
965
+ `),$=this.list(v);a[a.length-1]=$,i=i.substring(0,i.length-g.raw.length)+$.raw,n=n.substring(0,n.length-P.raw.length)+$.raw,t=v.substring(a.at(-1).raw.length).split(`
966
+ `);continue}}return {type:"blockquote",raw:i,tokens:a,text:n}}}list(r){let e=this.rules.block.list.exec(r);if(e){let t=e[1].trim(),i=t.length>1,n={type:"list",raw:"",ordered:i,start:i?+t.slice(0,-1):"",loose:false,items:[]};t=i?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=i?t:"[*+-]");let a=this.rules.other.listItemRegex(t),o=false;for(;r;){let l=false,c="",h="";if(!(e=a.exec(r))||this.rules.block.hr.test(r))break;c=e[0],r=r.substring(c.length);let w=e[2].split(`
967
+ `,1)[0].replace(this.rules.other.listReplaceTabs,Q=>" ".repeat(3*Q.length)),g=r.split(`
968
+ `,1)[0],P=!w.trim(),v=0;if(this.options.pedantic?(v=2,h=w.trimStart()):P?v=e[1].length+1:(v=e[2].search(this.rules.other.nonSpaceChar),v=v>4?1:v,h=w.slice(v),v+=e[1].length),P&&this.rules.other.blankLine.test(g)&&(c+=g+`
969
+ `,r=r.substring(g.length+1),l=true),!l){let Q=this.rules.other.nextBulletRegex(v),ie=this.rules.other.hrRegex(v),ae=this.rules.other.fencesBeginRegex(v),X=this.rules.other.headingBeginRegex(v),oe=this.rules.other.htmlBeginRegex(v);for(;r;){let Y=r.split(`
970
+ `,1)[0],B;if(g=Y,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),B=g):B=g.replace(this.rules.other.tabCharGlobal," "),ae.test(g)||X.test(g)||oe.test(g)||Q.test(g)||ie.test(g))break;if(B.search(this.rules.other.nonSpaceChar)>=v||!g.trim())h+=`
971
+ `+B.slice(v);else {if(P||w.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||ae.test(w)||X.test(w)||ie.test(w))break;h+=`
972
+ `+g;}!P&&!g.trim()&&(P=true),c+=Y+`
973
+ `,r=r.substring(Y.length+1),w=B.slice(v);}}n.loose||(o?n.loose=true:this.rules.other.doubleBlankLine.test(c)&&(o=true));let $=null,G;this.options.gfm&&($=this.rules.other.listIsTask.exec(h),$&&(G=$[0]!=="[ ] ",h=h.replace(this.rules.other.listReplaceTask,""))),n.items.push({type:"list_item",raw:c,task:!!$,checked:G,loose:false,text:h,tokens:[]}),n.raw+=c;}let s=n.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;n.raw=n.raw.trimEnd();for(let l=0;l<n.items.length;l++)if(this.lexer.state.top=false,n.items[l].tokens=this.lexer.blockTokens(n.items[l].text,[]),!n.loose){let c=n.items[l].tokens.filter(w=>w.type==="space"),h=c.length>0&&c.some(w=>this.rules.other.anyLine.test(w.raw));n.loose=h;}if(n.loose)for(let l=0;l<n.items.length;l++)n.items[l].loose=true;return n}}html(r){let e=this.rules.block.html.exec(r);if(e)return {type:"html",block:true,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(r){let e=this.rules.block.def.exec(r);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",n=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return {type:"def",tag:t,raw:e[0],href:i,title:n}}}table(r){let e=this.rules.block.table.exec(r);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=We(e[1]),i=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),n=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
974
+ `):[],a={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===i.length){for(let o of i)this.rules.other.tableAlignRight.test(o)?a.align.push("right"):this.rules.other.tableAlignCenter.test(o)?a.align.push("center"):this.rules.other.tableAlignLeft.test(o)?a.align.push("left"):a.align.push(null);for(let o=0;o<t.length;o++)a.header.push({text:t[o],tokens:this.lexer.inline(t[o]),header:true,align:a.align[o]});for(let o of n)a.rows.push(We(o,a.header.length).map((s,l)=>({text:s,tokens:this.lexer.inline(s),header:false,align:a.align[l]})));return a}}lheading(r){let e=this.rules.block.lheading.exec(r);if(e)return {type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(r){let e=this.rules.block.paragraph.exec(r);if(e){let t=e[1].charAt(e[1].length-1)===`
975
+ `?e[1].slice(0,-1):e[1];return {type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(r){let e=this.rules.block.text.exec(r);if(e)return {type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(r){let e=this.rules.inline.escape.exec(r);if(e)return {type:"escape",raw:e[0],text:e[1]}}tag(r){let e=this.rules.inline.tag.exec(r);if(e)return !this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=true:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=false),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=true:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=false),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:false,text:e[0]}}link(r){let e=this.rules.inline.link.exec(r);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let a=te(t.slice(0,-1),"\\");if((t.length-a.length)%2===0)return}else {let a=Zt(e[2],"()");if(a===-2)return;if(a>-1){let s=(e[0].indexOf("!")===0?5:4)+e[1].length+a;e[2]=e[2].substring(0,a),e[0]=e[0].substring(0,s).trim(),e[3]="";}}let i=e[2],n="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(i);a&&(i=a[1],n=a[3]);}else n=e[3]?e[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?i=i.slice(1):i=i.slice(1,-1)),Fe(e,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:n&&n.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(r,e){let t;if((t=this.rules.inline.reflink.exec(r))||(t=this.rules.inline.nolink.exec(r))){let i=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),n=e[i.toLowerCase()];if(!n){let a=t[0].charAt(0);return {type:"text",raw:a,text:a}}return Fe(t,n,t[0],this.lexer,this.rules)}}emStrong(r,e,t=""){let i=this.rules.inline.emStrongLDelim.exec(r);if(!i||i[3]&&t.match(this.rules.other.unicodeAlphaNumeric))return;if(!(i[1]||i[2]||"")||!t||this.rules.inline.punctuation.exec(t)){let a=[...i[0]].length-1,o,s,l=a,c=0,h=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,e=e.slice(-1*r.length+a);(i=h.exec(e))!=null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(s=[...o].length,i[3]||i[4]){l+=s;continue}else if((i[5]||i[6])&&a%3&&!((a+s)%3)){c+=s;continue}if(l-=s,l>0)continue;s=Math.min(s,s+l+c);let w=[...i[0]][0].length,g=r.slice(0,a+i.index+w+s);if(Math.min(a,s)%2){let v=g.slice(1,-1);return {type:"em",raw:g,text:v,tokens:this.lexer.inlineTokens(v)}}let P=g.slice(2,-2);return {type:"strong",raw:g,text:P,tokens:this.lexer.inlineTokens(P)}}}}codespan(r){let e=this.rules.inline.code.exec(r);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(t),n=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return i&&n&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(r){let e=this.rules.inline.br.exec(r);if(e)return {type:"br",raw:e[0]}}del(r){let e=this.rules.inline.del.exec(r);if(e)return {type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(r){let e=this.rules.inline.autolink.exec(r);if(e){let t,i;return e[2]==="@"?(t=e[1],i="mailto:"+t):(t=e[1],i=t),{type:"link",raw:e[0],text:t,href:i,tokens:[{type:"text",raw:t,text:t}]}}}url(r){let e;if(e=this.rules.inline.url.exec(r)){let t,i;if(e[2]==="@")t=e[0],i="mailto:"+t;else {let n;do n=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(n!==e[0]);t=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0];}return {type:"link",raw:e[0],text:t,href:i,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(r){let e=this.rules.inline.text.exec(r);if(e){let t=this.lexer.state.inRawBlock;return {type:"text",raw:e[0],text:e[0],escaped:t}}}},O=class Te{constructor(e){y(this,"tokens");y(this,"options");y(this,"state");y(this,"tokenizer");y(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=e||K,this.options.tokenizer=this.options.tokenizer||new ue,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:false,inRawBlock:false,top:true};let t={other:L,block:le.normal,inline:ee.normal};this.options.pedantic?(t.block=le.pedantic,t.inline=ee.pedantic):this.options.gfm&&(t.block=le.gfm,this.options.breaks?t.inline=ee.breaks:t.inline=ee.gfm),this.tokenizer.rules=t;}static get rules(){return {block:le,inline:ee}}static lex(e,t){return new Te(t).lex(e)}static lexInline(e,t){return new Te(t).inlineTokens(e)}lex(e){e=e.replace(L.carriageReturn,`
976
+ `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let i=this.inlineQueue[t];this.inlineTokens(i.src,i.tokens);}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],i=false){for(this.options.pedantic&&(e=e.replace(L.tabCharGlobal," ").replace(L.spaceLine,""));e;){let n;if(this.options.extensions?.block?.some(o=>(n=o.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),true):false))continue;if(n=this.tokenizer.space(e)){e=e.substring(n.raw.length);let o=t.at(-1);n.raw.length===1&&o!==void 0?o.raw+=`
977
+ `:t.push(n);continue}if(n=this.tokenizer.code(e)){e=e.substring(n.raw.length);let o=t.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=`
978
+ `+n.raw,o.text+=`
979
+ `+n.text,this.inlineQueue.at(-1).src=o.text):t.push(n);continue}if(n=this.tokenizer.fences(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.heading(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.hr(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.blockquote(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.list(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.html(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.def(e)){e=e.substring(n.raw.length);let o=t.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=`
980
+ `+n.raw,o.text+=`
981
+ `+n.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title});continue}if(n=this.tokenizer.table(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.lheading(e)){e=e.substring(n.raw.length),t.push(n);continue}let a=e;if(this.options.extensions?.startBlock){let o=1/0,s=e.slice(1),l;this.options.extensions.startBlock.forEach(c=>{l=c.call({lexer:this},s),typeof l=="number"&&l>=0&&(o=Math.min(o,l));}),o<1/0&&o>=0&&(a=e.substring(0,o+1));}if(this.state.top&&(n=this.tokenizer.paragraph(a))){let o=t.at(-1);i&&o?.type==="paragraph"?(o.raw+=`
982
+ `+n.raw,o.text+=`
983
+ `+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):t.push(n),i=a.length!==e.length,e=e.substring(n.raw.length);continue}if(n=this.tokenizer.text(e)){e=e.substring(n.raw.length);let o=t.at(-1);o?.type==="text"?(o.raw+=`
984
+ `+n.raw,o.text+=`
985
+ `+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):t.push(n);continue}if(e){let o="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=true,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let i=e,n=null;if(this.tokens.links){let s=Object.keys(this.tokens.links);if(s.length>0)for(;(n=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)s.includes(n[0].slice(n[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));}for(;(n=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,n.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(n=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let a=false,o="";for(;e;){a||(o=""),a=false;let s;if(this.options.extensions?.inline?.some(c=>(s=c.call({lexer:this},e,t))?(e=e.substring(s.raw.length),t.push(s),true):false))continue;if(s=this.tokenizer.escape(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.tag(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.link(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(s.raw.length);let c=t.at(-1);s.type==="text"&&c?.type==="text"?(c.raw+=s.raw,c.text+=s.text):t.push(s);continue}if(s=this.tokenizer.emStrong(e,i,o)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.codespan(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.br(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.del(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.autolink(e)){e=e.substring(s.raw.length),t.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(e))){e=e.substring(s.raw.length),t.push(s);continue}let l=e;if(this.options.extensions?.startInline){let c=1/0,h=e.slice(1),w;this.options.extensions.startInline.forEach(g=>{w=g.call({lexer:this},h),typeof w=="number"&&w>=0&&(c=Math.min(c,w));}),c<1/0&&c>=0&&(l=e.substring(0,c+1));}if(s=this.tokenizer.inlineText(l)){e=e.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(o=s.raw.slice(-1)),a=true;let c=t.at(-1);c?.type==="text"?(c.raw+=s.raw,c.text+=s.text):t.push(s);continue}if(e){let c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return t}},me=class{constructor(r){y(this,"options");y(this,"parser");this.options=r||K;}space(r){return ""}code({text:r,lang:e,escaped:t}){let i=(e||"").match(L.notSpaceStart)?.[0],n=r.replace(L.endingNewline,"")+`
986
+ `;return i?'<pre><code class="language-'+M(i)+'">'+(t?n:M(n,true))+`</code></pre>
987
+ `:"<pre><code>"+(t?n:M(n,true))+`</code></pre>
988
+ `}blockquote({tokens:r}){return `<blockquote>
989
+ ${this.parser.parse(r)}</blockquote>
990
+ `}html({text:r}){return r}heading({tokens:r,depth:e}){return `<h${e}>${this.parser.parseInline(r)}</h${e}>
991
+ `}hr(r){return `<hr>
992
+ `}list(r){let e=r.ordered,t=r.start,i="";for(let o=0;o<r.items.length;o++){let s=r.items[o];i+=this.listitem(s);}let n=e?"ol":"ul",a=e&&t!==1?' start="'+t+'"':"";return "<"+n+a+`>
993
+ `+i+"</"+n+`>
994
+ `}listitem(r){let e="";if(r.task){let t=this.checkbox({checked:!!r.checked});r.loose?r.tokens[0]?.type==="paragraph"?(r.tokens[0].text=t+" "+r.tokens[0].text,r.tokens[0].tokens&&r.tokens[0].tokens.length>0&&r.tokens[0].tokens[0].type==="text"&&(r.tokens[0].tokens[0].text=t+" "+M(r.tokens[0].tokens[0].text),r.tokens[0].tokens[0].escaped=true)):r.tokens.unshift({type:"text",raw:t+" ",text:t+" ",escaped:true}):e+=t+" ";}return e+=this.parser.parse(r.tokens,!!r.loose),`<li>${e}</li>
995
+ `}checkbox({checked:r}){return "<input "+(r?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:r}){return `<p>${this.parser.parseInline(r)}</p>
996
+ `}table(r){let e="",t="";for(let n=0;n<r.header.length;n++)t+=this.tablecell(r.header[n]);e+=this.tablerow({text:t});let i="";for(let n=0;n<r.rows.length;n++){let a=r.rows[n];t="";for(let o=0;o<a.length;o++)t+=this.tablecell(a[o]);i+=this.tablerow({text:t});}return i&&(i=`<tbody>${i}</tbody>`),`<table>
997
+ <thead>
998
+ `+e+`</thead>
999
+ `+i+`</table>
1000
+ `}tablerow({text:r}){return `<tr>
1001
+ ${r}</tr>
1002
+ `}tablecell(r){let e=this.parser.parseInline(r.tokens),t=r.header?"th":"td";return (r.align?`<${t} align="${r.align}">`:`<${t}>`)+e+`</${t}>
1003
+ `}strong({tokens:r}){return `<strong>${this.parser.parseInline(r)}</strong>`}em({tokens:r}){return `<em>${this.parser.parseInline(r)}</em>`}codespan({text:r}){return `<code>${M(r,true)}</code>`}br(r){return "<br>"}del({tokens:r}){return `<del>${this.parser.parseInline(r)}</del>`}link({href:r,title:e,tokens:t}){let i=this.parser.parseInline(t),n=Ne(r);if(n===null)return i;r=n;let a='<a href="'+r+'"';return e&&(a+=' title="'+M(e)+'"'),a+=">"+i+"</a>",a}image({href:r,title:e,text:t,tokens:i}){i&&(t=this.parser.parseInline(i,this.parser.textRenderer));let n=Ne(r);if(n===null)return M(t);r=n;let a=`<img src="${r}" alt="${t}"`;return e&&(a+=` title="${M(e)}"`),a+=">",a}text(r){return "tokens"in r&&r.tokens?this.parser.parseInline(r.tokens):"escaped"in r&&r.escaped?r.text:M(r.text)}},ze=class{strong({text:r}){return r}em({text:r}){return r}codespan({text:r}){return r}del({text:r}){return r}html({text:r}){return r}text({text:r}){return r}link({text:r}){return ""+r}image({text:r}){return ""+r}br(){return ""}},H=class Ce{constructor(e){y(this,"options");y(this,"renderer");y(this,"textRenderer");this.options=e||K,this.options.renderer=this.options.renderer||new me,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ze;}static parse(e,t){return new Ce(t).parse(e)}static parseInline(e,t){return new Ce(t).parseInline(e)}parse(e,t=true){let i="";for(let n=0;n<e.length;n++){let a=e[n];if(this.options.extensions?.renderers?.[a.type]){let s=a,l=this.options.extensions.renderers[s.type].call({parser:this},s);if(l!==false||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(s.type)){i+=l||"";continue}}let o=a;switch(o.type){case "space":{i+=this.renderer.space(o);continue}case "hr":{i+=this.renderer.hr(o);continue}case "heading":{i+=this.renderer.heading(o);continue}case "code":{i+=this.renderer.code(o);continue}case "table":{i+=this.renderer.table(o);continue}case "blockquote":{i+=this.renderer.blockquote(o);continue}case "list":{i+=this.renderer.list(o);continue}case "html":{i+=this.renderer.html(o);continue}case "paragraph":{i+=this.renderer.paragraph(o);continue}case "text":{let s=o,l=this.renderer.text(s);for(;n+1<e.length&&e[n+1].type==="text";)s=e[++n],l+=`
1004
+ `+this.renderer.text(s);t?i+=this.renderer.paragraph({type:"paragraph",raw:l,text:l,tokens:[{type:"text",raw:l,text:l,escaped:true}]}):i+=l;continue}default:{let s='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return i}parseInline(e,t=this.renderer){let i="";for(let n=0;n<e.length;n++){let a=e[n];if(this.options.extensions?.renderers?.[a.type]){let s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==false||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){i+=s||"";continue}}let o=a;switch(o.type){case "escape":{i+=t.text(o);break}case "html":{i+=t.html(o);break}case "link":{i+=t.link(o);break}case "image":{i+=t.image(o);break}case "strong":{i+=t.strong(o);break}case "em":{i+=t.em(o);break}case "codespan":{i+=t.codespan(o);break}case "br":{i+=t.br(o);break}case "del":{i+=t.del(o);break}case "text":{i+=t.text(o);break}default:{let s='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return i}},de=(we=class{constructor(r){y(this,"options");y(this,"block");this.options=r||K;}preprocess(r){return r}postprocess(r){return r}processAllTokens(r){return r}provideLexer(){return this.block?O.lex:O.lexInline}provideParser(){return this.block?H.parse:H.parseInline}},y(we,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"])),we),Qt=class{constructor(...r){y(this,"defaults",$e());y(this,"options",this.setOptions);y(this,"parse",this.parseMarkdown(true));y(this,"parseInline",this.parseMarkdown(false));y(this,"Parser",H);y(this,"Renderer",me);y(this,"TextRenderer",ze);y(this,"Lexer",O);y(this,"Tokenizer",ue);y(this,"Hooks",de);this.use(...r);}walkTokens(r,e){let t=[];for(let i of r)switch(t=t.concat(e.call(this,i)),i.type){case "table":{let n=i;for(let a of n.header)t=t.concat(this.walkTokens(a.tokens,e));for(let a of n.rows)for(let o of a)t=t.concat(this.walkTokens(o.tokens,e));break}case "list":{let n=i;t=t.concat(this.walkTokens(n.items,e));break}default:{let n=i;this.defaults.extensions?.childTokens?.[n.type]?this.defaults.extensions.childTokens[n.type].forEach(a=>{let o=n[a].flat(1/0);t=t.concat(this.walkTokens(o,e));}):n.tokens&&(t=t.concat(this.walkTokens(n.tokens,e)));}}return t}use(...r){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return r.forEach(t=>{let i={...t};if(i.async=this.defaults.async||i.async||false,t.extensions&&(t.extensions.forEach(n=>{if(!n.name)throw new Error("extension name required");if("renderer"in n){let a=e.renderers[n.name];a?e.renderers[n.name]=function(...o){let s=n.renderer.apply(this,o);return s===false&&(s=a.apply(this,o)),s}:e.renderers[n.name]=n.renderer;}if("tokenizer"in n){if(!n.level||n.level!=="block"&&n.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=e[n.level];a?a.unshift(n.tokenizer):e[n.level]=[n.tokenizer],n.start&&(n.level==="block"?e.startBlock?e.startBlock.push(n.start):e.startBlock=[n.start]:n.level==="inline"&&(e.startInline?e.startInline.push(n.start):e.startInline=[n.start]));}"childTokens"in n&&n.childTokens&&(e.childTokens[n.name]=n.childTokens);}),i.extensions=e),t.renderer){let n=this.defaults.renderer||new me(this.defaults);for(let a in t.renderer){if(!(a in n))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,s=t.renderer[o],l=n[o];n[o]=(...c)=>{let h=s.apply(n,c);return h===false&&(h=l.apply(n,c)),h||""};}i.renderer=n;}if(t.tokenizer){let n=this.defaults.tokenizer||new ue(this.defaults);for(let a in t.tokenizer){if(!(a in n))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,s=t.tokenizer[o],l=n[o];n[o]=(...c)=>{let h=s.apply(n,c);return h===false&&(h=l.apply(n,c)),h};}i.tokenizer=n;}if(t.hooks){let n=this.defaults.hooks||new de;for(let a in t.hooks){if(!(a in n))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,s=t.hooks[o],l=n[o];de.passThroughHooks.has(a)?n[o]=c=>{if(this.defaults.async)return Promise.resolve(s.call(n,c)).then(w=>l.call(n,w));let h=s.call(n,c);return l.call(n,h)}:n[o]=(...c)=>{let h=s.apply(n,c);return h===false&&(h=l.apply(n,c)),h};}i.hooks=n;}if(t.walkTokens){let n=this.defaults.walkTokens,a=t.walkTokens;i.walkTokens=function(o){let s=[];return s.push(a.call(this,o)),n&&(s=s.concat(n.call(this,o))),s};}this.defaults={...this.defaults,...i};}),this}setOptions(r){return this.defaults={...this.defaults,...r},this}lexer(r,e){return O.lex(r,e??this.defaults)}parser(r,e){return H.parse(r,e??this.defaults)}parseMarkdown(r){return (t,i)=>{let n={...i},a={...this.defaults,...n},o=this.onError(!!a.silent,!!a.async);if(this.defaults.async===true&&n.async===false)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));a.hooks&&(a.hooks.options=a,a.hooks.block=r);let s=a.hooks?a.hooks.provideLexer():r?O.lex:O.lexInline,l=a.hooks?a.hooks.provideParser():r?H.parse:H.parseInline;if(a.async)return Promise.resolve(a.hooks?a.hooks.preprocess(t):t).then(c=>s(c,a)).then(c=>a.hooks?a.hooks.processAllTokens(c):c).then(c=>a.walkTokens?Promise.all(this.walkTokens(c,a.walkTokens)).then(()=>c):c).then(c=>l(c,a)).then(c=>a.hooks?a.hooks.postprocess(c):c).catch(o);try{a.hooks&&(t=a.hooks.preprocess(t));let c=s(t,a);a.hooks&&(c=a.hooks.processAllTokens(c)),a.walkTokens&&this.walkTokens(c,a.walkTokens);let h=l(c,a);return a.hooks&&(h=a.hooks.postprocess(h)),h}catch(c){return o(c)}}}onError(r,e){return t=>{if(t.message+=`
1005
+ Please report this to https://github.com/markedjs/marked.`,r){let i="<p>An error occurred:</p><pre>"+M(t.message+"",true)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(t);throw t}}},F=new Qt;f.options=f.setOptions=function(r){return F.setOptions(r),f.defaults=F.defaults,Ke(f.defaults),f};f.getDefaults=$e;f.defaults=K;f.use=function(...r){return F.use(...r),f.defaults=F.defaults,Ke(f.defaults),f};f.walkTokens=function(r,e){return F.walkTokens(r,e)};f.parseInline=F.parseInline;f.Parser=H;f.parser=H.parse;f.Renderer=me;f.TextRenderer=ze;f.Lexer=O;f.lexer=O.lex;f.Tokenizer=ue;f.Hooks=de;f.parse=f;f.options,f.setOptions,f.use,f.walkTokens,f.parseInline,H.parse,O.lex;});var it={};Oe(it,{AICommerceWidget:()=>exports.AICommerceWidget,createWidget:()=>Me});function Me(r){if(!r.apiKey)throw new Error("AICommerceWidget: apiKey is required");let e=new exports.AICommerce({apiKey:r.apiKey,storeId:r.storeId,baseUrl:r.baseUrl}),t={isOpen:false,isLoading:true,isRecording:false,messages:[],storeConfig:null},i=null,n=[],a=null,l=null,c;async function h(){try{let p=r.baseUrl||w(),u=await fetch(`${p}/api/v1/store`,{headers:{"x-api-key":r.apiKey}});return u.ok?(await u.json()).store:null}catch(p){return console.error("Failed to fetch store config:",p),null}}function w(){if(typeof window<"u"){let p=document.querySelector("script[data-aicommerce-url]");if(p)return p.getAttribute("data-aicommerce-url")||""}return "https://api.aicommerce.dev"}async function g(){t.storeConfig=await h();let p=r.displayMode||"widget",u=p==="embedded";c={apiKey:r.apiKey,storeId:r.storeId,baseUrl:r.baseUrl||w(),displayMode:p,container:r.container,maxHeight:r.maxHeight||"600px",placeholder:r.placeholder||"Ask me anything about our products...",position:r.position||"bottom-right",theme:r.theme||"auto",primaryColor:r.primaryColor||t.storeConfig?.primaryColor||"#6366f1",welcomeMessage:r.welcomeMessage||t.storeConfig?.welcomeMessage||"Hi! How can I help you find the perfect product today?",botName:r.botName||t.storeConfig?.chatBotName||"Shopping Assistant",zIndex:r.zIndex||9999,buttonText:r.buttonText||"\u{1F4AC}",hideLauncher:r.hideLauncher||false,addToCartText:r.addToCartText,onOpen:r.onOpen,onClose:r.onClose,onProductClick:r.onProductClick,onAddToCart:r.onAddToCart,onMessage:r.onMessage};let m=ye(c);if(l=He(m),u){let S=null;if(typeof r.container=="string"?S=document.querySelector(r.container):r.container instanceof HTMLElement&&(S=r.container),!S){console.error("[AI Commerce] Embedded mode requires a valid container element or selector");return}a=document.createElement("div"),a.id="aicommerce-widget",a.className=`aicommerce-widget aicommerce-embedded aicommerce-theme-${c.theme}`,a.style.setProperty("--aic-max-height",c.maxHeight),S.appendChild(a),t.isOpen=true;}else a=document.createElement("div"),a.id="aicommerce-widget",a.className=`aicommerce-widget aicommerce-${c.position} aicommerce-theme-${c.theme}`,document.body.appendChild(a);$(),u||t.messages.push({role:"assistant",content:c.welcomeMessage}),t.isLoading=false,$();}async function P(p,u=1){let m=p;if(p.includes("gid://")){let A=p.match(/\/(\d+)$/);A&&(m=A[1]);}if(!(await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:m,quantity:u})})).ok)throw new Error("Failed to add to cart");document.dispatchEvent(new CustomEvent("cart:refresh")),document.dispatchEvent(new CustomEvent("cart:change")),document.dispatchEvent(new CustomEvent("cart:add")),document.dispatchEvent(new CustomEvent("cart:updated")),document.dispatchEvent(new CustomEvent("CartJS:change"));let T=window;T.Shopify&&T.Shopify.onCartUpdate&&T.Shopify.onCartUpdate(),fetch("/cart.js").then(A=>A.json()).then(A=>{document.dispatchEvent(new CustomEvent("cart:build",{detail:{cart:A}})),document.dispatchEvent(new CustomEvent("ajaxCart.afterCartLoad",{detail:{cart:A}}));}).catch(()=>{});}function v(p){let u=p;if(p.includes("gid://")){let m=p.match(/\/(\d+)$/);m&&(u=m[1]);}window.location.href=`/cart/${u}:1`;}function $(){if(!a)return;let p=c.displayMode==="embedded",u=t.messages.some(C=>C.role==="user");p&&(a.classList.remove("aicommerce-no-messages","aicommerce-has-messages"),a.classList.add(u?"aicommerce-has-messages":"aicommerce-no-messages"));let m=c.placeholder||"Ask me anything about our products...",S=`
859
1006
  <div class="aicommerce-input-container">
860
- ${o?`
1007
+ ${p?`
861
1008
  <textarea
862
1009
  class="aicommerce-input"
863
- placeholder="${c}"
1010
+ placeholder="${m}"
864
1011
  rows="1"
865
- ${e.isLoading||e.isRecording?"disabled":""}
1012
+ ${t.isLoading||t.isRecording?"disabled":""}
866
1013
  ></textarea>
867
1014
  `:`
868
1015
  <input
869
1016
  type="text"
870
1017
  class="aicommerce-input"
871
- placeholder="${c}"
872
- ${e.isLoading||e.isRecording?"disabled":""}
1018
+ placeholder="${m}"
1019
+ ${t.isLoading||t.isRecording?"disabled":""}
873
1020
  />
874
1021
  `}
875
- <button class="aicommerce-mic ${e.isRecording?"aicommerce-recording":""}" ${e.isLoading?"disabled":""} aria-label="${e.isRecording?"Stop recording":"Voice input"}">
876
- ${e.isRecording?`
1022
+ <button class="aicommerce-mic ${t.isRecording?"aicommerce-recording":""}" ${t.isLoading?"disabled":""} aria-label="${t.isRecording?"Stop recording":"Voice input"}">
1023
+ ${t.isRecording?`
877
1024
  <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor">
878
1025
  <rect x="6" y="6" width="12" height="12" rx="2"/>
879
1026
  </svg>
@@ -886,28 +1033,28 @@ var O=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object
886
1033
  </svg>
887
1034
  `}
888
1035
  </button>
889
- <button class="aicommerce-send" ${e.isLoading||e.isRecording?"disabled":""} aria-label="Send message">
1036
+ <button class="aicommerce-send" ${t.isLoading||t.isRecording?"disabled":""} aria-label="Send message">
890
1037
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
891
1038
  <path d="M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13"/>
892
1039
  </svg>
893
1040
  </button>
894
1041
  </div>
895
- `,u=`
896
- ${!o&&!m.hideLauncher?`
897
- <button class="aicommerce-launcher ${e.isOpen?"aicommerce-hidden":""}" aria-label="Open chat">
898
- <span class="aicommerce-launcher-icon">${m.buttonText}</span>
1042
+ `,T=`
1043
+ ${!p&&!c.hideLauncher?`
1044
+ <button class="aicommerce-launcher ${t.isOpen?"aicommerce-hidden":""}" aria-label="Open chat">
1045
+ <span class="aicommerce-launcher-icon">${c.buttonText}</span>
899
1046
  </button>
900
1047
  `:""}
901
1048
 
902
- <div class="aicommerce-chat ${e.isOpen?"aicommerce-open":"aicommerce-closed"}">
903
- ${o?"":`
1049
+ <div class="aicommerce-chat ${t.isOpen?"aicommerce-open":"aicommerce-closed"}">
1050
+ ${p?"":`
904
1051
  <div class="aicommerce-header">
905
1052
  <div class="aicommerce-header-info">
906
1053
  <div class="aicommerce-avatar">
907
- ${e.storeConfig?.logo?`<img src="${e.storeConfig.logo}" alt="${m.botName}" />`:"<span>\u{1F916}</span>"}
1054
+ ${t.storeConfig?.logo?`<img src="${t.storeConfig.logo}" alt="${c.botName}" />`:"<span>\u{1F916}</span>"}
908
1055
  </div>
909
1056
  <div class="aicommerce-header-text">
910
- <span class="aicommerce-bot-name">${m.botName}</span>
1057
+ <span class="aicommerce-bot-name">${c.botName}</span>
911
1058
  <span class="aicommerce-status">Online</span>
912
1059
  </div>
913
1060
  </div>
@@ -915,33 +1062,38 @@ var O=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object
915
1062
  </div>
916
1063
  `}
917
1064
 
918
- ${o&&i?`
1065
+ ${p&&u?`
919
1066
  <div class="aicommerce-messages">
920
- ${e.messages.map((l,S)=>{let A=J(l.content),n=l.role==="user";return `
921
- <div class="aicommerce-message aicommerce-${l.role}">
922
- <div class="aicommerce-message-content ${A?"aicommerce-rtl":"aicommerce-ltr"}">
923
- ${l.audioUrl?Y(l,S,n):T(l.content)}
1067
+ ${t.messages.map((C,j)=>{let D=X(C.content),N=C.role==="user";return `
1068
+ <div class="aicommerce-message aicommerce-${C.role}">
1069
+ <div class="aicommerce-message-content ${D?"aicommerce-rtl":"aicommerce-ltr"}">
1070
+ ${C.audioUrl?G(C,j,N):f.parse(C.content)}
924
1071
  </div>
925
- ${l.products&&l.products.length>0?`
1072
+ ${C.products&&C.products.length>0?`
926
1073
  <div class="aicommerce-products">
927
- ${l.products.map(t=>`
928
- <div class="aicommerce-product-card" data-product-id="${t.id}" data-variant-id="${t.variantId||""}">
929
- ${t.image||t.imageUrl?`
930
- <img src="${t.image||t.imageUrl}" alt="${T(t.name)}" class="aicommerce-product-image" />
1074
+ ${C.products.map(d=>`
1075
+ <div class="aicommerce-product-card" data-product-id="${d.id}" data-variant-id="${d.variantId||""}">
1076
+ ${d.image||d.imageUrl?`
1077
+ <img src="${d.image||d.imageUrl}" alt="${U(d.name)}" class="aicommerce-product-image" />
931
1078
  `:`
932
1079
  <div class="aicommerce-product-placeholder">\u{1F4E6}</div>
933
1080
  `}
934
1081
  <div class="aicommerce-product-info">
935
- <span class="aicommerce-product-name" title="${T(t.name)}">${T(t.name)}</span>
936
- ${t.description?`<p class="aicommerce-product-desc">${T(t.description)}</p>`:""}
937
- <span class="aicommerce-product-price">${X(t.price,t.currency)}</span>
938
- <button class="aicommerce-add-to-cart" data-product-id="${t.id}">
939
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
940
- <circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/>
941
- <path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/>
942
- </svg>
943
- ${m.addToCartText||"Add to Cart"}
944
- </button>
1082
+ <span class="aicommerce-product-name" title="${U(d.name)}">${U(d.name)}</span>
1083
+ ${d.description?`<p class="aicommerce-product-desc">${U(d.description)}</p>`:""}
1084
+ <span class="aicommerce-product-price">${_e(d.price,d.currency)}</span>
1085
+ <div class="aicommerce-product-actions">
1086
+ <button class="aicommerce-add-to-cart" data-product-id="${d.id}">
1087
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
1088
+ <circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/>
1089
+ <path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/>
1090
+ </svg>
1091
+ ${c.addToCartText||"Add to Cart"}
1092
+ </button>
1093
+ <button class="aicommerce-buy-now" data-variant-id="${d.variantId||""}">
1094
+ Buy Now
1095
+ </button>
1096
+ </div>
945
1097
  </div>
946
1098
  </div>
947
1099
  `).join("")}
@@ -949,7 +1101,7 @@ var O=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object
949
1101
  `:""}
950
1102
  </div>
951
1103
  `}).join("")}
952
- ${e.isLoading?`
1104
+ ${t.isLoading?`
953
1105
  <div class="aicommerce-message aicommerce-assistant">
954
1106
  <div class="aicommerce-typing">
955
1107
  <span></span><span></span><span></span>
@@ -959,32 +1111,32 @@ var O=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object
959
1111
  </div>
960
1112
  `:""}
961
1113
 
962
- ${o?"":`
1114
+ ${p?"":`
963
1115
  <div class="aicommerce-messages">
964
- ${e.messages.map((l,S)=>{let A=J(l.content),n=l.role==="user";return `
965
- <div class="aicommerce-message aicommerce-${l.role}">
966
- <div class="aicommerce-message-content ${A?"aicommerce-rtl":"aicommerce-ltr"}">
967
- ${l.audioUrl?Y(l,S,n):T(l.content)}
1116
+ ${t.messages.map((C,j)=>{let D=X(C.content),N=C.role==="user";return `
1117
+ <div class="aicommerce-message aicommerce-${C.role}">
1118
+ <div class="aicommerce-message-content ${D?"aicommerce-rtl":"aicommerce-ltr"}">
1119
+ ${C.audioUrl?G(C,j,N):f.parse(C.content)}
968
1120
  </div>
969
- ${l.products&&l.products.length>0?`
1121
+ ${C.products&&C.products.length>0?`
970
1122
  <div class="aicommerce-products">
971
- ${l.products.map(t=>`
972
- <div class="aicommerce-product-card" data-product-id="${t.id}" data-variant-id="${t.variantId||""}">
973
- ${t.image||t.imageUrl?`
974
- <img src="${t.image||t.imageUrl}" alt="${T(t.name)}" class="aicommerce-product-image" />
1123
+ ${C.products.map(d=>`
1124
+ <div class="aicommerce-product-card" data-product-id="${d.id}" data-variant-id="${d.variantId||""}">
1125
+ ${d.image||d.imageUrl?`
1126
+ <img src="${d.image||d.imageUrl}" alt="${U(d.name)}" class="aicommerce-product-image" />
975
1127
  `:`
976
1128
  <div class="aicommerce-product-placeholder">\u{1F4E6}</div>
977
1129
  `}
978
1130
  <div class="aicommerce-product-info">
979
- <span class="aicommerce-product-name" title="${T(t.name)}">${T(t.name)}</span>
980
- ${t.description?`<p class="aicommerce-product-desc">${T(t.description)}</p>`:""}
981
- <span class="aicommerce-product-price">${X(t.price,t.currency)}</span>
982
- <button class="aicommerce-add-to-cart" data-product-id="${t.id}">
1131
+ <span class="aicommerce-product-name" title="${U(d.name)}">${U(d.name)}</span>
1132
+ ${d.description?`<p class="aicommerce-product-desc">${U(d.description)}</p>`:""}
1133
+ <span class="aicommerce-product-price">${_e(d.price,d.currency)}</span>
1134
+ <button class="aicommerce-add-to-cart" data-product-id="${d.id}">
983
1135
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
984
1136
  <circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/>
985
1137
  <path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/>
986
1138
  </svg>
987
- ${m.addToCartText||"Add to Cart"}
1139
+ ${c.addToCartText||"Add to Cart"}
988
1140
  </button>
989
1141
  </div>
990
1142
  </div>
@@ -993,7 +1145,7 @@ var O=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object
993
1145
  `:""}
994
1146
  </div>
995
1147
  `}).join("")}
996
- ${e.isLoading?`
1148
+ ${t.isLoading?`
997
1149
  <div class="aicommerce-message aicommerce-assistant">
998
1150
  <div class="aicommerce-typing">
999
1151
  <span></span><span></span><span></span>
@@ -1003,39 +1155,39 @@ var O=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var le=Object
1003
1155
  </div>
1004
1156
  `}
1005
1157
 
1006
- ${o?`
1158
+ ${p?`
1007
1159
  <div class="aicommerce-input-wrapper">
1008
- ${b}
1160
+ ${S}
1009
1161
  </div>
1010
- `:b}
1162
+ `:S}
1011
1163
  </div>
1012
- `;s.innerHTML=u,oe();let E=s.querySelector(".aicommerce-messages");E&&(E.scrollTop=E.scrollHeight);}function Y(o,i,c){return `
1013
- <div class="aicommerce-audio-player" data-message-index="${i}">
1164
+ `;a.innerHTML=T,Q();let A=a.querySelector(".aicommerce-messages");A&&(A.scrollTop=A.scrollHeight);}function G(p,u,m){return `
1165
+ <div class="aicommerce-audio-player" data-message-index="${u}">
1014
1166
  <button class="aicommerce-audio-btn">
1015
1167
  <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" stroke-width="2"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg>
1016
1168
  </button>
1017
1169
  <div class="aicommerce-audio-waveform">
1018
1170
  <div class="aicommerce-waveform-bars">
1019
- ${(o.waveformBars||Array(40).fill(10)).map(b=>`
1020
- <div class="aicommerce-waveform-bar" style="height: ${b}%; background-color: ${c?"rgba(255,255,255,0.4)":"rgba(99,102,241,0.3)"}"></div>
1171
+ ${(p.waveformBars||Array(40).fill(10)).map(S=>`
1172
+ <div class="aicommerce-waveform-bar" style="height: ${S}%; background-color: ${m?"rgba(255,255,255,0.4)":"rgba(99,102,241,0.3)"}"></div>
1021
1173
  `).join("")}
1022
1174
  </div>
1023
1175
  <div class="aicommerce-audio-time">
1024
1176
  <span class="aicommerce-current-time">0:00</span>
1025
- <span>${V(o.audioDuration||0)}</span>
1177
+ <span>${oe(p.audioDuration||0)}</span>
1026
1178
  </div>
1027
1179
  </div>
1028
- <audio src="${o.audioUrl}" preload="metadata"></audio>
1180
+ <audio src="${p.audioUrl}" preload="metadata"></audio>
1029
1181
  </div>
1030
- `}function oe(){if(!s)return;let o=s.querySelector(".aicommerce-launcher");o&&o.addEventListener("click",()=>q());let i=s.querySelector(".aicommerce-close");i&&i.addEventListener("click",()=>H());let c=s.querySelector(".aicommerce-input"),b=s.querySelector(".aicommerce-send");c&&(c.addEventListener("keydown",n=>{let t=n;if(t.key==="Enter"){let p=c instanceof HTMLTextAreaElement;if(p&&t.shiftKey)return;n.preventDefault();let f=c.value.trim();f&&(U(f),c.value="",p&&(c.style.height="auto"));}}),c instanceof HTMLTextAreaElement&&c.addEventListener("input",()=>{c.style.height="auto",c.style.height=Math.min(c.scrollHeight,150)+"px";})),b&&c&&b.addEventListener("click",()=>{let n=c.value.trim();n&&(U(n),c.value="",c instanceof HTMLTextAreaElement&&(c.style.height="auto"));});let u=s.querySelector(".aicommerce-mic");u&&u.addEventListener("click",()=>ae()),s.querySelectorAll(".aicommerce-product-card").forEach(n=>{n.addEventListener("click",t=>{if(t.target.closest(".aicommerce-add-to-cart"))return;let p=n.getAttribute("data-product-id"),f=e.messages.flatMap(y=>y.products||[]).find(y=>y.id===p);f&&(m.onProductClick?m.onProductClick(f):f.url&&window.open(f.url,"_blank","noopener,noreferrer"));});}),s.querySelectorAll(".aicommerce-add-to-cart").forEach(n=>{n.addEventListener("click",async t=>{t.stopPropagation();let p=n,f=p.closest(".aicommerce-product-card"),y=f?.getAttribute("data-product-id"),x=f?.getAttribute("data-variant-id"),C=e.messages.flatMap(P=>P.products||[]).find(P=>P.id===y);if(!C)return;let v=p.innerHTML;p.disabled=true,p.innerHTML=`
1182
+ `}function Q(){if(!a)return;let p=a.querySelector(".aicommerce-launcher");p&&p.addEventListener("click",()=>fe());let u=a.querySelector(".aicommerce-close");u&&u.addEventListener("click",()=>be());let m=a.querySelector(".aicommerce-input"),S=a.querySelector(".aicommerce-send");m&&(m.addEventListener("keydown",d=>{let b=d;if(b.key==="Enter"){let k=m instanceof HTMLTextAreaElement;if(k&&b.shiftKey)return;d.preventDefault();let E=m.value.trim();E&&(B(E),m.value="",k&&(m.style.height="auto"));}}),m instanceof HTMLTextAreaElement&&m.addEventListener("input",()=>{m.style.height="auto",m.style.height=Math.min(m.scrollHeight,150)+"px";})),S&&m&&S.addEventListener("click",()=>{let d=m.value.trim();d&&(B(d),m.value="",m instanceof HTMLTextAreaElement&&(m.style.height="auto"));});let T=a.querySelector(".aicommerce-mic");T&&T.addEventListener("click",()=>ie()),a.querySelectorAll(".aicommerce-product-card").forEach(d=>{d.addEventListener("click",b=>{if(b.target.closest(".aicommerce-add-to-cart"))return;let k=d.getAttribute("data-product-id"),E=t.messages.flatMap(R=>R.products||[]).find(R=>R.id===k);E&&(c.onProductClick?c.onProductClick(E):E.url&&window.open(E.url,"_blank","noopener,noreferrer"));});}),a.querySelectorAll(".aicommerce-add-to-cart").forEach(d=>{d.addEventListener("click",async b=>{b.stopPropagation();let k=d,E=k.closest(".aicommerce-product-card"),R=E?.getAttribute("data-product-id"),W=E?.getAttribute("data-variant-id"),z=t.messages.flatMap(q=>q.products||[]).find(q=>q.id===R);if(!z)return;let I=k.innerHTML;k.disabled=true,k.innerHTML=`
1031
1183
  <svg class="aicommerce-spinner" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
1032
1184
  <circle cx="12" cy="12" r="10" stroke-dasharray="32" stroke-dashoffset="32"/>
1033
1185
  </svg>
1034
1186
  Adding...
1035
- `;try{m.onAddToCart?await m.onAddToCart(C):x&&window.Shopify?await te(x):C.url&&window.open(C.url,"_blank","noopener,noreferrer"),p.innerHTML=`
1187
+ `;try{c.onAddToCart?await c.onAddToCart(z):W&&window.Shopify?await P(W):z.url&&window.open(z.url,"_blank","noopener,noreferrer"),k.innerHTML=`
1036
1188
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
1037
1189
  <polyline points="20 6 9 17 4 12"/>
1038
1190
  </svg>
1039
1191
  Added!
1040
- `,setTimeout(()=>{p.innerHTML=v,p.disabled=!1;},2e3);}catch(P){console.error("[AI Commerce] Add to cart failed:",P),p.innerHTML=v,p.disabled=false;}});}),s.querySelectorAll(".aicommerce-products").forEach(n=>{let t=false,p=0,f=0;n.addEventListener("mousedown",y=>{t=true,n.style.cursor="grabbing",p=y.pageX-n.offsetLeft,f=n.scrollLeft;}),n.addEventListener("mouseleave",()=>{t=false,n.style.cursor="grab";}),n.addEventListener("mouseup",()=>{t=false,n.style.cursor="grab";}),n.addEventListener("mousemove",y=>{if(!t)return;y.preventDefault();let C=(y.pageX-n.offsetLeft-p)*2;n.scrollLeft=f-C;});}),s.querySelectorAll(".aicommerce-audio-player").forEach(n=>{let t=n.querySelector("audio"),p=n.querySelector(".aicommerce-audio-btn"),f=n.querySelectorAll(".aicommerce-waveform-bar"),y=n.querySelector(".aicommerce-current-time");if(!t||!p)return;p.addEventListener("click",()=>{!t.paused?(t.pause(),p.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" stroke-width="2"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg>'):(s?.querySelectorAll("audio").forEach(v=>{if(v!==t&&!v.paused){v.pause();let I=v.closest(".aicommerce-audio-player")?.querySelector(".aicommerce-audio-btn");I&&(I.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" stroke-width="2"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg>');}}),t.play(),p.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" stroke-width="2"><rect x="6" y="4" width="4" height="16"></rect><rect x="14" y="4" width="4" height="16"></rect></svg>');}),t.addEventListener("timeupdate",()=>{if(y&&(y.textContent=V(t.currentTime)),t.duration){let C=t.currentTime/t.duration*100;f.forEach((v,P)=>{P/f.length*100<=C?v.style.backgroundColor=n.closest(".aicommerce-user")?"rgba(255,255,255,1)":"var(--aic-primary)":v.style.backgroundColor=n.closest(".aicommerce-user")?"rgba(255,255,255,0.4)":"rgba(99,102,241,0.3)";});}}),t.addEventListener("ended",()=>{p.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" stroke-width="2"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg>';});let x=n.querySelector(".aicommerce-waveform-bars");x&&x.addEventListener("click",C=>{let v=x.getBoundingClientRect(),I=(C.clientX-v.left)/v.width;t.duration&&(t.currentTime=I*t.duration);});});}async function ae(){if(e.isRecording)d&&d.state!=="inactive"&&d.stop();else try{let o=await navigator.mediaDevices.getUserMedia({audio:!0});h=[],d=new MediaRecorder(o,{mimeType:MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4"}),d.ondataavailable=i=>{i.data.size>0&&h.push(i.data);},d.onstop=async()=>{if(o.getTracks().forEach(i=>i.stop()),h.length>0){let i=new Blob(h,{type:d?.mimeType||"audio/webm"});await ie(i);}e.isRecording=!1,k();},d.start(),e.isRecording=!0,k();}catch(o){console.error("Failed to start recording:",o),e.messages.push({role:"assistant",content:"Unable to access microphone. Please check your permissions."}),k();}}async function ie(o){let i=URL.createObjectURL(o),c=Array(40).fill(10),b=0;try{c=await se(o);let u=new Audio(i);await new Promise(E=>{u.onloadedmetadata=()=>{b=u.duration,E();},u.onerror=()=>E();});}catch(u){console.error("Audio analysis failed",u);}e.messages.push({role:"user",content:"Voice message",audioUrl:i,audioDuration:b,waveformBars:c}),e.isLoading=true,k();try{let u=await r.chatWithAudio(o);return e.messages.push({role:"assistant",content:u.reply,products:u.products}),m.onMessage&&m.onMessage("Voice message",u),u}catch(u){throw e.messages.push({role:"assistant",content:"Sorry, I encountered an error processing your voice message. Please try again."}),u}finally{e.isLoading=false,k();}}function J(o){return /[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/.test(o)}function V(o){let i=Math.floor(o/60),c=Math.floor(o%60);return `${i}:${c.toString().padStart(2,"0")}`}async function se(o){try{let i=new(window.AudioContext||window.webkitAudioContext),c=await o.arrayBuffer(),u=(await i.decodeAudioData(c)).getChannelData(0),E=40,l=Math.floor(u.length/E),S=[];for(let A=0;A<E;A++){let n=A*l,t=n+l,p=0;for(let x=n;x<t;x++)u[x]&&(p+=u[x]*u[x]);let f=Math.sqrt(p/l),y=Math.min(100,Math.max(10,f*400));S.push(y);}return S}catch(i){return console.error("Analysis error",i),Array.from({length:40},()=>20+Math.random()*60)}}async function U(o){e.messages.push({role:"user",content:o}),e.isLoading=true,k();try{let i=await r.chat(o);return e.messages.push({role:"assistant",content:i.reply,products:i.products}),m.onMessage&&m.onMessage(o,i),i}catch(i){throw e.messages.push({role:"assistant",content:"Sorry, I encountered an error. Please try again."}),i}finally{e.isLoading=false,k();}}function q(){e.isOpen=true,k(),m.onOpen?.(),setTimeout(()=>{s?.querySelector(".aicommerce-input")?.focus();},100);}function H(){e.isOpen=false,k(),m.onClose?.();}function ne(){e.isOpen?H():q();}function ce(){s&&(s.remove(),s=null),w&&(w.remove(),w=null);}function de(o){if(Object.assign(m,o),o.primaryColor){let i=z(m);w&&(w.textContent=i);}k();}function T(o){let i=document.createElement("div");return i.textContent=o,i.innerHTML}function X(o,i){let b={USD:"$",EUR:"\u20AC",GBP:"\xA3",MAD:"DH",SAR:"SAR",AED:"AED",JPY:"\xA5",CNY:"\xA5"}[i||"USD"]||i||"$";return `${o.toFixed(2)} ${b}`}return re(),{open:q,close:H,toggle:ne,destroy:ce,sendMessage:U,updateConfig:de}}exports.AICommerceWidget=void 0;var F=B(()=>{M();Q();exports.AICommerceWidget={init:D,VERSION:"1.0.0"};typeof window<"u"&&(window.AICommerceWidget=exports.AICommerceWidget);});M();F();var xe="1.0.0";typeof window<"u"&&(window.AICommerce=(M(),j(W)).AICommerce,window.AICommerceError=(M(),j(W)).AICommerceError,window.AICommerceWidget=(F(),j(Z)).AICommerceWidget);exports.VERSION=xe;exports.createWidget=D;return exports;})({});//# sourceMappingURL=index.min.js.map
1192
+ `,setTimeout(()=>{k.innerHTML=I,k.disabled=!1;},2e3);}catch(q){console.error("[AI Commerce] Add to cart failed:",q),k.innerHTML=I,k.disabled=false;}});}),a.querySelectorAll(".aicommerce-buy-now").forEach(d=>{d.addEventListener("click",b=>{b.stopPropagation();let k=d.getAttribute("data-variant-id");k&&v(k);});}),a.querySelectorAll(".aicommerce-products").forEach(d=>{let b=false,k=0,E=0;d.addEventListener("mousedown",R=>{b=true,d.style.cursor="grabbing",k=R.pageX-d.offsetLeft,E=d.scrollLeft;}),d.addEventListener("mouseleave",()=>{b=false,d.style.cursor="grab";}),d.addEventListener("mouseup",()=>{b=false,d.style.cursor="grab";}),d.addEventListener("mousemove",R=>{if(!b)return;R.preventDefault();let z=(R.pageX-d.offsetLeft-k)*2;d.scrollLeft=E-z;});}),a.querySelectorAll(".aicommerce-audio-player").forEach(d=>{let b=d.querySelector("audio"),k=d.querySelector(".aicommerce-audio-btn"),E=d.querySelectorAll(".aicommerce-waveform-bar"),R=d.querySelector(".aicommerce-current-time");if(!b||!k)return;k.addEventListener("click",()=>{!b.paused?(b.pause(),k.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" stroke-width="2"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg>'):(a?.querySelectorAll("audio").forEach(I=>{if(I!==b&&!I.paused){I.pause();let J=I.closest(".aicommerce-audio-player")?.querySelector(".aicommerce-audio-btn");J&&(J.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" stroke-width="2"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg>');}}),b.play(),k.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" stroke-width="2"><rect x="6" y="4" width="4" height="16"></rect><rect x="14" y="4" width="4" height="16"></rect></svg>');}),b.addEventListener("timeupdate",()=>{if(R&&(R.textContent=oe(b.currentTime)),b.duration){let z=b.currentTime/b.duration*100;E.forEach((I,q)=>{q/E.length*100<=z?I.style.backgroundColor=d.closest(".aicommerce-user")?"rgba(255,255,255,1)":"var(--aic-primary)":I.style.backgroundColor=d.closest(".aicommerce-user")?"rgba(255,255,255,0.4)":"rgba(99,102,241,0.3)";});}}),b.addEventListener("ended",()=>{k.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" stroke-width="2"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg>';});let W=d.querySelector(".aicommerce-waveform-bars");W&&W.addEventListener("click",z=>{let I=W.getBoundingClientRect(),J=(z.clientX-I.left)/I.width;b.duration&&(b.currentTime=J*b.duration);});});}async function ie(){if(t.isRecording)i&&i.state!=="inactive"&&i.stop();else try{let p=await navigator.mediaDevices.getUserMedia({audio:!0});n=[];let u=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4";i=new MediaRecorder(p,{mimeType:u}),i.ondataavailable=m=>{m.data.size>0&&n.push(m.data);},i.onstop=async()=>{if(p.getTracks().forEach(m=>m.stop()),n.length>0){let m=new Blob(n,{type:u});await ae(m);}t.isRecording=!1,$();},i.start(),t.isRecording=!0,$();}catch(p){console.error("Failed to start recording:",p),t.messages.push({role:"assistant",content:"Unable to access microphone. Please check your permissions."}),$();}}async function ae(p){let u=URL.createObjectURL(p),m=Array(40).fill(10),S=0;try{m=await Y(p);let T=new Audio(u);await new Promise(A=>{T.onloadedmetadata=()=>{S=T.duration,A();},T.onerror=()=>A();});}catch(T){console.error("Audio analysis failed",T);}t.messages.push({role:"user",content:"Voice message",audioUrl:u,audioDuration:S,waveformBars:m}),t.isLoading=true,$();try{let T=await e.chatWithAudio(p);return t.messages.push({role:"assistant",content:T.reply,products:T.products}),c.onMessage&&c.onMessage("Voice message",T),T}catch(T){throw t.messages.push({role:"assistant",content:"Sorry, I encountered an error processing your voice message. Please try again."}),T}finally{t.isLoading=false,$();}}function X(p){return /[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/.test(p)}function oe(p){let u=Math.floor(p/60),m=Math.floor(p%60);return `${u}:${m.toString().padStart(2,"0")}`}async function Y(p){try{let u=new(window.AudioContext||window.webkitAudioContext),m=await p.arrayBuffer(),T=(await u.decodeAudioData(m)).getChannelData(0),A=40,C=Math.floor(T.length/A),j=[];for(let D=0;D<A;D++){let N=D*C,d=N+C,b=0;for(let R=N;R<d;R++)T[R]&&(b+=T[R]*T[R]);let k=Math.sqrt(b/C),E=Math.min(100,Math.max(10,k*400));j.push(E);}return j}catch(u){return console.error("Analysis error",u),Array.from({length:40},()=>20+Math.random()*60)}}async function B(p){t.messages.push({role:"user",content:p}),t.isLoading=true,$();try{let u=await e.chat(p);return t.messages.push({role:"assistant",content:u.reply,products:u.products}),c.onMessage&&c.onMessage(p,u),u}catch(u){throw t.messages.push({role:"assistant",content:"Sorry, I encountered an error. Please try again."}),u}finally{t.isLoading=false,$();}}function fe(){t.isOpen=true,$(),c.onOpen?.(),setTimeout(()=>{a?.querySelector(".aicommerce-input")?.focus();},100);}function be(){t.isOpen=false,$(),c.onClose?.();}function at(){t.isOpen?be():fe();}function ot(){a&&(a.remove(),a=null),l&&(l.remove(),l=null);}function st(p){if(Object.assign(c,p),p.primaryColor){let u=ye(c);l&&(l.textContent=u);}$();}function U(p){let u=document.createElement("div");return u.textContent=p,u.innerHTML}function _e(p,u){let S={USD:"$",EUR:"\u20AC",GBP:"\xA3",MAD:"DH",SAR:"SAR",AED:"AED",JPY:"\xA5",CNY:"\xA5"}[u||"USD"]||u||"$";return `${p.toFixed(2)} ${S}`}return g(),{open:fe,close:be,toggle:at,destroy:ot,sendMessage:B,updateConfig:st}}exports.AICommerceWidget=void 0;var qe=ce(()=>{V();Ue();nt();f.setOptions({breaks:true,gfm:true});exports.AICommerceWidget={init:Me,VERSION:"1.0.0"};typeof window<"u"&&(window.AICommerceWidget=exports.AICommerceWidget);});V();qe();var gr="1.0.0";typeof window<"u"&&(window.AICommerce=(V(),xe(ke)).AICommerce,window.AICommerceError=(V(),xe(ke)).AICommerceError,window.AICommerceWidget=(qe(),xe(it)).AICommerceWidget);exports.VERSION=gr;exports.createWidget=Me;return exports;})({});//# sourceMappingURL=index.min.js.map
1041
1193
  //# sourceMappingURL=index.min.js.map