PageSourceSearch

https://newmode.ai/assets/ProposalDemo-Du2NIrtp.js

js newmode.ai collected 2026-10-05 12:18:23 UTC 12,732 bytes, 6 lines download raw bytes

1import{w as C,x as D,p as T,o as r,y as E,r as w,t as U}from"./chunk-LFPYN7LY-XMI0Pofr.js";import{T as N,g as P,r as W}from"./demos-Co6V-B7-.js";import{L as A}from"./loader-circle-DW85mCXF.js";import{A as O}from"./arrow-left-WMj5xnfe.js";import{c as _}from"./createLucideIcon-B7YfR71f.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const B=_("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]),te=({params:t})=>[{title:`${t.slug??"Demo"} Demo | Algomo`}],I="https://demo-resolvers-production.up.railway.app";function L(){try{const t=localStorage.getItem("nm-visitor-id")||localStorage.getItem("newmode-visitor-id")||localStorage.getItem("nm_visitor_id");if(t)return t;for(let n=0;n<localStorage.length;n++){const u=localStorage.key(n)||"";if(/visitor/i.test(u)){const o=localStorage.getItem(u);if(o&&/^[A-Za-z0-9._-]{6,64}$/.test(o))return o}}}catch{}return null}function M({vendor:t}){const n=t.since&&/^\d{4}-\d{2}/.test(t.since)?new Date(t.since).toLocaleDateString(void 0,{year:"numeric",month:"short"}):null,u=[`This site currently runs ${t.name}`,n?`, observed since ${n}`:"",t.note?` (${t.note})`:"",". You are looking at Algomo for comparison."].join("");return r.jsxs("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",title:u,children:[r.jsx("span",{className:"hidden sm:inline",children:"Currently runs"}),r.jsx("span",{className:"inline-flex items-center gap-1 rounded-full border border-border px-2 py-0.5 font-medium text-foreground/80",children:t.name}),r.jsx("span",{"aria-hidden":!0,className:"text-muted-foreground/60",children:"vs"}),r.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-foreground px-2 py-0.5 font-medium text-background",children:"Algomo"})]})}function R({demo:t,url:n}){const{pathname:u}=T(),o=u.startsWith("/demos/")?"demos":"proposals",m=t.backTo??`/${o}/${t.slug}`;return r.jsxs("div",{className:"fixed top-0 left-0 right-0 z-50 bg-background/95 backdrop-blur-sm border-b border-border px-4 py-2 flex items-center justify-between gap-3",children:[r.jsxs(U,{to:m,className:"inline-flex shrink-0 items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[r.jsx(O,{className:"w-4 h-4"})," ",t.backTo?"Back to playbook":"Back to overview"]}),n?r.jsx(V,{url:n}):null,t.currentVendor?r.jsx(M,{vendor:t.currentVendor}):r.jsx("span",{className:"hidden sm:block shrink-0 text-xs text-muted-foreground",children:t.topbarNote})]})}function V({url:t}){const n=t.replace(/^https?:\/\//,"").replace(/\/$/,"");return r.jsx("div",{className:"flex min-w-0 flex-1 justify-center",children:r.jsxs("div",{className:"flex min-w-0 max-w-xl flex-1 items-center gap-2 rounded-full border border-border bg-muted/60 px-3 py-1",title:t,children:[r.jsx(B,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate text-xs text-muted-foreground",children:n})]})})}function H({demo:t}){return r.jsxs("div",{className:"min-h-screen flex flex-col bg-background",children:[r.jsx(R,{demo:t}),r.jsx("iframe",{src:t.embedUrl,className:"w-full flex-grow mt-10",style:{border:"none",minHeight:"100vh"},title:`${t.name} live demo`,sandbox:"allow-scripts allow-same-origin allow-popups allow-forms"})]})}function q({demo:t}){const n=t.domain||t.siteUrl.replace(/^https?:\/\//,"").replace(/\/.*$/,""),u=t.domain?`https://${t.domain}/`:t.siteUrl,o=["Install the Algomo extension (one-time, the launcher below walks you through it).",`Open ${n} -- the assistant appears on the real site, in your own session.`,`Ask it anything: it searches the live catalogue, and add-to-cart, checkout and co-navigation run on ${n} for real.`];return r.jsx("div",{className:"mt-10 flex w-full flex-grow items-center justify-center bg-muted/30 px-4 py-16",children:r.jsxs("div",{className:"w-full max-w-xl rounded-2xl border border-border bg-card p-8",children:[r.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Runs live via the Algomo extension"}),r.jsxs("h2",{className:"mt-2 text-2xl font-semibold text-foreground",children:["Experience this on ",n]}),r.jsx("p",{className:"mt-2 text-sm leading-relaxed text-foreground
6/85",children:"This demo runs at full fidelity on the real site through the Algomo browser extension, in your own session -- so add-to-cart, checkout and page navigation happen for real, with no proxy in between. Chat with the assistant here, or run the full flow live:"}),r.jsx("ol",{className:"mt-5 space-y-3",children:o.map((m,h)=>r.jsxs("li",{className:"flex gap-3 text-sm text-foreground/85",children:[r.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-border text-xs font-semibold text-muted-foreground",children:h+1}),r.jsx("span",{className:"leading-relaxed",children:m})]},h))}),r.jsxs(U,{to:`/demo/${t.slug}`,className:"mt-6 inline-flex items-center justify-center rounded-xl bg-foreground px-5 py-2.5 text-sm font-medium text-background transition-opacity hover:opacity-90",children:["Run it live on ",n]}),r.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"mt-3 inline-flex items-center justify-center rounded-xl border border-border px-5 py-2.5 text-sm font-medium text-foreground hover:bg-muted",children:["Just open ",n]})]})})}function z({demo:t}){const[n,u]=w.useState(!1),o=w.useRef(null),m=w.useRef(""),[h,$]=w.useState(t.origin||t.siteUrl);return w.useEffect(()=>{const f=/^https:\/\/demo-proxy\./.test(t.siteUrl)||/^https:\/\/[^/]+\.algomostudio\.com(\/|$)/.test(t.siteUrl),j=(()=>{const i=[],e=a=>a.replace(/^www\./,"");t.domain&&i.push(e(t.domain));const p=t.origin;if(p)try{i.push(e(new URL(p).hostname))}catch{}return i})();function b(i){try{const e=new URL(i);if(j.some(a=>e.hostname===a||e.hostname===`www.${a}`||e.hostname.endsWith(`.${a}`))&&o.current){const a=new URL(t.siteUrl),g=a.pathname.split("/").filter(Boolean)[0];return o.current.src=g?`${a.origin}/${g}${e.pathname}${e.search}${e.hash}`:`${a.origin}${e.pathname}${e.search}${e.hash}`,!0}}catch{}return!1}const c=new Map;let v=0;function S(i,e,p=8e3){var s;const a=(s=o.current)==null?void 0:s.contentWindow;if(!f||!a)return Promise.reject(new Error("page-driving unavailable (demo is not proxied)"));const g=`a${++v}`;return new Promise((d,y)=>{const k=window.setTimeout(()=>{c.delete(g),y(new Error(`action ${i} timed out`))},p);c.set(g,{resolve:d,reject:y,timer:k}),a.postMessage({source:"newmode-demo-host",type:"nm-action",id:g,action:i,args:e||{}},"*")})}function l(i){var p,a,g;const e=i.data;if(!(!e||typeof e!="object")){if(e.source==="newmode-demo"&&e.type==="actionResult"){const s=typeof e.id=="string"?e.id:null;if(!s)return;const d=c.get(s);if(!d)return;c.delete(s),clearTimeout(d.timer),e.ok?d.resolve(e.result??null):d.reject(new Error(typeof e.error=="string"?e.error:"action failed"));return}if(e.type==="nm-demo-action"){const s=typeof e.action=="string"?e.action:null;if(!s)return;const d=e.args&&typeof e.args=="object"?e.args:void 0;S(s,d).catch(()=>{});return}if(e.type==="nm-demo-add-to-cart"){if(!f||!((p=o.current)!=null&&p.contentWindow))return;const s=typeof e.nodeId=="string"||typeof e.nodeId=="number"?String(e.nodeId):void 0;if(!s)return;o.current.contentWindow.postMessage({source:"newmode-demo-host",type:"addToCart",nodeId:s,url:typeof e.url=="string"?e.url:void 0,quantity:typeof e.quantity=="number"||typeof e.quantity=="string"?e.quantity:void 0},"*");return}if(e.type==="nm-demo-remove-from-cart"){if(!f||!((a=o.current)!=null&&a.contentWindow))return;const s=e.match&&typeof e.match=="object"?e.match:void 0;if(!s)return;o.current.contentWindow.postMessage({source:"newmode-demo-host",type:"removeFromCart",match:s,url:typeof e.url=="string"?e.url:void 0},"*");return}if(e.type==="nm-demo-checkout"){if(!f||!((g=o.current)!=null&&g.contentWindow))return;o.current.contentWindow.postMessage({source:"newmode-demo-host",type:"checkout",url:typeof e.url=="string"?e.url:void 0},"*");return}if(e.type==="nm-journey"){if(!f||typeof e.url!="string"||!e.url||e.url===m.current)return;$(e.url);const s=L();if(!s)return;m.current=e.url;const d=e.title,y=new URLSearchParams({demo:t.slug,visitor:s,url:e.url});typeof d=="string"&&d&&y.set("title",d),fetch(`${I}/journey/add?${y.toString()}`,{mode:"no-cors",keepalive:!0}
6).catch(()=>{});return}if(e.type==="nm-cart-state"){if(!f)return;const s=L();if(!s)return;const d=Array.isArray(e.items)?e.items:[],y=e.total,k=e.currency;fetch(`${I}/cart/sync`,{method:"POST",mode:"no-cors",keepalive:!0,headers:{"Content-Type":"text/plain"},body:JSON.stringify({demo:t.slug,visitor:s,items:d,total:typeof y=="number"?y:void 0,currency:typeof k=="string"?k:void 0})}).catch(()=>{});return}if(e.type==="nm-demo-open"&&typeof e.url=="string"){if(f){if(b(e.url)){$(e.url);return}window.open(e.url,"_blank","noopener");return}if(o.current){o.current.src=e.url,$(e.url);return}window.open(e.url,"_blank","noopener")}}}function x(i){if(!f||i.defaultPrevented)return;const e=i.composedPath&&i.composedPath()||[];let p=null;for(const a of e)if(a instanceof HTMLAnchorElement&&a.href){p=a;break}p&&b(p.href)&&(i.preventDefault(),i.stopPropagation())}return window.addEventListener("message",l),document.addEventListener("click",x,!0),()=>{window.removeEventListener("message",l),document.removeEventListener("click",x,!0);for(const i of c.values())clearTimeout(i.timer),i.reject(new Error("demo unmounted"));c.clear()}},[t]),w.useEffect(()=>{const f=t.orgId??N,j=f===N;if(j&&new URLSearchParams(location.search).get("demo")!==t.slug){const l=new URL(location.href);l.searchParams.set("demo",t.slug),history.replaceState({},"",l.href)}for(let l=localStorage.length-1;l>=0;l--){const x=localStorage.key(l);x&&(x.startsWith("nm-")||x.startsWith("newmode")||x.startsWith("algomo"))&&localStorage.removeItem(x)}let b=!1,c=null;const v=()=>!b&&u(!0),S=setTimeout(v,6e3);return(async()=>{const l=j?await W(t.slug,f):void 0;if(!b){if(j&&!l){console.error(`[demo:${t.slug}] no experienceId from variants.newmode.ai -- chat suppressed to avoid loading the org base bot (ANTHBOT). This demo needs a non-template variant bound to its audience.`),v();return}window.algomo={orgId:f,...l?{experienceId:l}:{},isContentRevealed:()=>!0,onContentReplacement:()=>{}},c=document.createElement("script"),c.src="https://cdn.algomo.com/pixel.js",c.setAttribute("fetchpriority","high"),c.crossOrigin="anonymous",c.onload=()=>setTimeout(v,500),c.onerror=v,document.head.appendChild(c)}})(),()=>{b=!0,clearTimeout(S);const l=window;l.algomo=l.algomo||{},l.algomo.orgId="org_36vvDhdi7ghcCmZbbxIizWH43Ua",c&&c.remove()}},[t]),n?r.jsxs("div",{className:"min-h-screen flex flex-col bg-background",children:[r.jsx(R,{demo:t,url:t.extensionOnly?void 0:h}),t.extensionOnly?r.jsx(q,{demo:t}):r.jsx("iframe",{ref:o,src:t.siteUrl,className:"w-full flex-grow mt-10",style:{border:"none",minHeight:"100vh"},title:`${t.name} website`,sandbox:"allow-scripts allow-same-origin allow-popups allow-forms"})]}):r.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-background gap-4",children:[r.jsx(A,{className:"w-6 h-6 animate-spin text-muted-foreground"}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Loading ",t.name," demo..."]})]})}const G="https://demo-proxy.procurement-c92.workers.dev/config";function J(t){if(!t||typeof t!="object")return!1;const n=t;return typeof n.slug!="string"||typeof n.name!="string"?!1:n.kind==="hosted"?typeof n.embedUrl=="string":n.kind==="overlay"?typeof n.siteUrl=="string":!1}function F(t){const n=P(t),[u,o]=w.useState(n?{demo:n,status:"ready"}:{demo:null,status:"loading"});return w.useEffect(()=>{if(n||!t)return;let m=!1;return fetch(`${G}/${encodeURIComponent(t)}`).then(h=>h.ok?h.json():null).then(h=>{m||(J(h)?o({demo:h,status:"ready"}):o({demo:null,status:"notfound"}))}).catch(()=>!m&&o({demo:null,status:"notfound"})),()=>{m=!0}},[t,n]),u}const Z=()=>{const{slug:t}=D(),{pathname:n,search:u}=T(),{demo:o,status:m}=F(t);return o&&n.startsWith("/proposals/")&&o.kind!=="hosted"&&(o.orgId??N)===N?r.jsx(E,{to:`/demos/${o.slug}/demo${u}`,replace:!0}):m==="loading"?r.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-background gap-4",children:[r.jsx(A,{className:"w-6 h-6 animate-spin text-muted-foreground"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading demo..."})]}):m==="notfound"||!o?r.jsx(E,{to:"/404",replace:!0}):o.kind==="hosted"?r.jsx(H,{demo:o}):r.jsx(z,{demo:o})},re=C(Z);export{re as default,te as meta};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.