dev-process-kit 0.0.14 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/README.md +1 -1
  2. package/dist/chunks/{shared-Dc_FGuLM.js → shared-BJvnqK51.js} +1 -1
  3. package/dist/chunks/{shared-BFTEmZvI.js → shared-BS9TMOvt.js} +1 -1
  4. package/dist/chunks/{shared-CTK76mc_.js → shared-BYoX4LxS.js} +14 -26
  5. package/dist/chunks/{shared-DUEkF1z7.js → shared-B_nvELQt.js} +1 -1
  6. package/dist/chunks/{shared-C2gu-y4m.js → shared-Bp3FCPZj.js} +2 -13
  7. package/dist/chunks/{shared-CGPv8MQ7.js → shared-BtEAASxQ.js} +1 -1
  8. package/dist/chunks/{shared-rZQ5j0Kh.js → shared-CBRj9Yll.js} +52 -43
  9. package/dist/chunks/{shared-DjOBIYHF.js → shared-CLabLKYD.js} +1 -1
  10. package/dist/chunks/{shared-wtt8CCP_.js → shared-CRpGBd1Z.js} +1 -1
  11. package/dist/chunks/{shared-NnvpqsPp.js → shared-CVI7znpk.js} +1 -1
  12. package/dist/chunks/{shared-BESRsbtm.js → shared-CeM-gXAw.js} +1 -1
  13. package/dist/chunks/{shared-CmBhMY6X.js → shared-D0PnnUir.js} +1 -1
  14. package/dist/chunks/{shared-DD-fi15c.js → shared-DsUcMhpJ.js} +1 -1
  15. package/dist/chunks/{shared-CE1P_7xs.js → shared-m1HXI5YR.js} +1 -1
  16. package/dist/components.js +1 -1
  17. package/dist/index.js +1 -1
  18. package/dist/templates/delegation-poker.js +1 -1
  19. package/dist/templates/event-storming.js +1 -1
  20. package/dist/templates/example-mapping.js +1 -1
  21. package/dist/templates/grill.js +1 -1
  22. package/dist/templates/plain.js +1 -1
  23. package/dist/templates/prototype.js +1 -1
  24. package/dist/templates/slides.js +1 -1
  25. package/dist/templates/task-board.js +1 -1
  26. package/dist/templates/usm.js +1 -1
  27. package/dist/templates/whiteboard.js +1 -1
  28. package/package.json +1 -1
package/README.md CHANGED
@@ -59,7 +59,7 @@ Claude Code can publish the page as a Claude Artifact instead of a local file, a
59
59
  - **Fits the viewer.** The template follows the reader's claude.ai light / dark theme and sizes itself to the viewer's frame.
60
60
  - **Nothing to configure.** The page detects the Artifact at runtime; outside one, or when a send cannot land, the copy hand-off stays as it is.
61
61
 
62
- The skill's [Claude Artifact reference](skills/dev-process-kit/references/claude-artifact.md) tells the agent how to write and publish such a page.
62
+ [docs/claude-artifact.md](docs/claude-artifact.md) tells the agent when to publish such a page and how to write it; the skill sends the agent there whenever it can publish an Artifact.
63
63
 
64
64
  ### Install the skill
65
65
 
@@ -1,4 +1,4 @@
1
- import{a0 as r,a3 as a,a4 as o}from"./shared-rZQ5j0Kh.js";const i=r({en:{comment:"Comment",commentOn:s=>`Comment on ${s}`,submit:"Send",cancel:"Cancel"},ja:{comment:"\u30B3\u30E1\u30F3\u30C8",commentOn:s=>`${s}\u3078\u306E\u30B3\u30E1\u30F3\u30C8`,submit:"\u9001\u4FE1",cancel:"\u30AD\u30E3\u30F3\u30BB\u30EB"}}),c=(s,t,n={})=>({body:s,notes:t,submission:s.trim()||null,label:n.label??null,error:n.error??null,key:n.key??null}),p=(s,t,n)=>{const l=()=>{t.submission!==null&&n({kind:"comment",body:t.submission})};return o`<div
1
+ import{a0 as r,a3 as a,a4 as o}from"./shared-CBRj9Yll.js";const i=r({en:{comment:"Comment",commentOn:s=>`Comment on ${s}`,submit:"Send",cancel:"Cancel"},ja:{comment:"\u30B3\u30E1\u30F3\u30C8",commentOn:s=>`${s}\u3078\u306E\u30B3\u30E1\u30F3\u30C8`,submit:"\u9001\u4FE1",cancel:"\u30AD\u30E3\u30F3\u30BB\u30EB"}}),c=(s,t,n={})=>({body:s,notes:t,submission:s.trim()||null,label:n.label??null,error:n.error??null,key:n.key??null}),p=(s,t,n)=>{const l=()=>{t.submission!==null&&n({kind:"comment",body:t.submission})};return o`<div
2
2
  class="comment-pop"
3
3
  popover="manual"
4
4
  role="dialog"
@@ -1,4 +1,4 @@
1
- import{a0 as _,Z as _e,j as Be,a1 as Ge,a2 as B,a3 as b,a4 as h,a5 as J,a6 as zs,J as Ds,a7 as I,a8 as Ye,a9 as Ve,aa as We,A as Ke,ab as Ts,ac as As,ad as G,ae as q,af as f,ag as z,ah as u,ai as H,aj as S,ak as M,al as ae,am as Xe,an as Je,ao as Z,ap as we,aq as Ze,ar as Ls,as as Rs,at as $e,au as Se,av as Os,aw as Me,l as Qe,ax as Is,ay as Ps,az as js,aA as ne,q as Fs,r as Ns}from"./shared-rZQ5j0Kh.js";import{i as et}from"./shared-DjOBIYHF.js";import{p as tt,r as st,c as at}from"./shared-Dc_FGuLM.js";import{c as me}from"./shared-ml5h7U5L.js";const Us='script[type="application/json"]',nt=(a,e)=>{const t=a.querySelector(Us);if(!t)return null;const s=t.textContent??"";if(s.trim()==="")return{ok:!1,error:"JSON block is empty"};try{return{ok:!0,value:e(JSON.parse(s))}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},rt=(a,e,t)=>{const s=nt(a,e);if(s)return t(s),()=>{};const n=new MutationObserver(()=>{const r=nt(a,e);r&&(n.disconnect(),t(r))});return n.observe(a,{childList:!0,subtree:!0}),()=>n.disconnect()},it={nodeSpacing:34,layerSpacing:84,padding:28,sweeps:4,coordinatePasses:6},ge=a=>{const e=[...a].sort((s,n)=>s-n);if(e.length===0)return 0;const t=Math.floor(e.length/2);return e.length%2===1?e[t]??0:((e[t-1]??0)+(e[t]??0))/2},Hs=(a,e)=>{const t=new Map;for(const i of a)t.set(i.id,[]);for(const i of e)t.get(i.from)?.push(i);const s=new Map,n=new Set,r=i=>{s.set(i,"open");for(const o of t.get(i)??[]){const d=s.get(o.to)??"new";d==="open"?n.add(o.id):d==="new"&&r(o.to)}s.set(i,"done")};for(const i of a)(s.get(i.id)??"new")==="new"&&r(i.id);return{reversed:n,forward:e.filter(i=>!n.has(i.id))}},_s=(a,e)=>{const t=new Map,s=new Map;for(const o of a)t.set(o.id,[]),s.set(o.id,[]);for(const o of e)s.get(o.from)?.push(o),t.get(o.to)?.push(o);const n=new Map(a.map(o=>[o.id,0])),r=new Map(a.map(o=>[o.id,(t.get(o.id)??[]).length])),i=a.filter(o=>(r.get(o.id)??0)===0).map(o=>o.id);for(const o of i)for(const d of s.get(o)??[]){const l=n.get(d.to)??0;n.set(d.to,Math.max(l,(n.get(o)??0)+1));const c=(r.get(d.to)??0)-1;r.set(d.to,c),c===0&&i.push(d.to)}return n},Bs=(a,e,t,s)=>{const n=[...a.keys()].sort((r,i)=>r-i);for(let r=0;r<s;r++){const i=r%2===0;for(const o of i?n:[...n].reverse()){const d=a.get(o)??[],l=new Map(d.map((p,k)=>[p,k])),c=p=>{const k=l.get(p);return k===void 0?null:k},g=d.map(p=>{const k=(e.get(p)??[]).filter(x=>(t.get(x)??o)===o+(i?-1:1)).map(c).filter(x=>x!==null);return{id:p,want:k.length>0?ge(k):l.get(p)??0}});g.sort((p,k)=>p.want-k.want||(l.get(p.id)??0)-(l.get(k.id)??0)),a.set(o,g.map(p=>p.id))}}},ot=(a,e,t,s)=>{const n=a.map((i,o)=>({id:i,want:t.get(i)??o*100,index:o}));n.sort((i,o)=>i.want-o.want||i.index-o.index);let r=0;for(const i of n){const o=e.get(i.id);o&&(o.y=r,r+=o.spec.height+s)}return{height:Math.max(0,r-s)}},Gs=(a,e,t,s,n)=>{const r=[...a.keys()].sort((l,c)=>l-c),i=new Map;for(const l of r)i.set(l,ot(a.get(l)??[],e,new Map,n.nodeSpacing).height);const o=Math.max(0,...i.values());for(const l of r){const c=(o-(i.get(l)??0))/2;for(const g of a.get(l)??[]){const p=e.get(g);p&&(p.y+=c)}}const d=(l,c)=>{const g=(t.get(l)??[]).filter(p=>s.get(p)===c).flatMap(p=>{const k=e.get(p);return k?[k.y+k.spec.height/2]:[]});return g.length>0?ge(g):null};for(let l=0;l<n.coordinatePasses;l++){const c=l%2===0;for(const g of c?r:[...r].reverse()){const p=a.get(g)??[],k=new Map;for(const w of p){const D=d(w,g+(c?-1:1)),L=e.get(w);L!==void 0&&k.set(w,D===null?L.y+L.spec.height/2:D)}const x=p.map(w=>e.get(w)?.y??0);ot(p,e,k,n.nodeSpacing);const v=p.map(w=>e.get(w)?.y??0),y=ge(x)-ge(v);for(const w of p){const D=e.get(w);D&&(D.y+=y)}}}},dt=(a,e,t)=>{const s=e===void 0?void 0:a.spec.ports?.[e];return s?{x:a.x+s.x,y:a.y+s.y}:t==="out"?{x:a.x+a.spec.width,y:a.y+a.spec.height/2}:{x:a.x,y:a.y+a.spec.height/2}},lt=(a,e,t)=>{let s=0;const n=[];for(const r of a){const i=t.byId.get(r.from),o=t.byId.get(r.to);if(!i||!o)continue;const d=dt(i,r.fromPort,"out"),l=dt(o,r.toPort,"in");if(r.from===r.to){const x=i.x+i.spec.width,v=i.y+i.spec.height,y=Math.max(t.padding/2,v+18);n.push({id:r.id,points:[d,{x:x+20,y:d.y},{x:x+20,y},{x:i.x-20,y},{x:i.x-20,y:l.y},l]});continue}if(!e.has(r.id)&&(i.layer<o.layer||i.layer===o.layer&&l.x>d.x+12)){if(Math.abs(d.y-l.y)<.5){n.push({id:r.id,points:[d,l]});continue}const v=i.layer<o.layer?Math.max(d.x+14,o.x-Math.max(12,t.layerSpacing/2)):(d.x+l.x)/2;n.push({id:r.id,points:[d,{x:v,y:d.y},{x:v,y:l.y},l]});continue}const c=r.fromPort===void 0?{x:i.x+i.spec.width/2,y:i.y+i.spec.height}:d,g=r.toPort===void 0?{x:o.x+o.spec.width/2,y:o.y+o.spec.height}:l,p=Math.max(c.y,g.y)+18+s*14;s+=1;const k=[d,c,{x:c.x,y:p},{x:g.x,y:p},g,l].filter((x,v,y)=>v===0||x.x!==y[v-1]?.x||x.y!==y[v-1]?.y);n.push({id:r.id,points:k})}return n},ct=(a,e,t)=>{const s=e.flatMap(p=>[...p.points]),n=[...a.map(p=>p.x),...a.map(p=>p.x+p.spec.width),...s.map(p=>p.x)],r=[...a.map(p=>p.y),...a.map(p=>p.y+p.spec.height),...s.map(p=>p.y)],i=Math.min(0,...n),o=Math.min(0,...r),d=Math.max(0,...n),l=Math.max(0,...r),c=t-i,g=t-o;return{width:d-i+t*2,height:l-o+t*2,nodes:a.map(p=>({id:p.spec.id,x:p.x+c,y:p.y+g,width:p.spec.width,height:p.spec.height,layer:p.layer,order:p.order})),routes:e.map(p=>({id:p.id,points:p.points.map(k=>({x:k.x+c,y:k.y+g}))}))}},pt=(a,e)=>{const t=new Map(a.map(s=>[s.id,[]]));for(const s of e)s.from!==s.to&&(t.get(s.from)?.push(s.to),t.get(s.to)?.push(s.from));return t},ht=(a,e,t,s)=>a.map(n=>({spec:n,layer:e.get(n.id)??0,order:t.get(n.id)??0,...s(n)})),Ys=(a,e)=>{const t=new Map;for(const s of a){const n=e.get(s.id)??0,r=t.get(n);r?r.push(s.id):t.set(n,[s.id])}return t},Vs=(a,e,t={})=>{const s={...it,...t};if(a.length===0)return{width:0,height:0,nodes:[],routes:[]};const n=new Set(a.map(v=>v.id)),r=e.filter(v=>n.has(v.from)&&n.has(v.to)),{forward:i,reversed:o}=Hs(a,r),d=_s(a,i),l=Ys(a,d);Bs(l,pt(a,r),d,s.sweeps);const c=new Map;for(const v of l.values())v.forEach((y,w)=>c.set(y,w));const g=ht(a,d,c,()=>({x:0,y:0})),p=new Map(g.map(v=>[v.spec.id,v]));Gs(l,p,pt(a,r),d,s);const k=[...l.keys()].sort((v,y)=>v-y);let x=0;for(const v of k){const y=Math.max(...(l.get(v)??[]).map(w=>p.get(w)?.spec.width??0));for(const w of l.get(v)??[]){const D=p.get(w);D&&(D.x=x)}x+=y+s.layerSpacing}return ct(g,lt(r,o,{byId:p,layerSpacing:s.layerSpacing,padding:s.padding}),s.padding)},Ws=(a,e,t={})=>{const s={...it,...t};if(a.length===0)return{width:0,height:0,nodes:[],routes:[]};const n=new Set(a.map(d=>d.id)),r=e.filter(d=>n.has(d.from)&&n.has(d.to)),i=ht(a,new Map,new Map,d=>d.position??{x:0,y:0}),o=new Map(i.map(d=>[d.spec.id,d]));return ct(i,lt(r,new Set,{byId:o,layerSpacing:s.layerSpacing,padding:s.padding}),s.padding)},Ks=_({en:{tagFilter:"Filter by tag",tagMatch:"Tag matching",clearTags:"Clear",zoomOut:"Zoom out",fit:"Fit to view",zoomIn:"Zoom in",sendFailed:"Could not send. Please try again.",commentOn:a=>`Comment on ${a}`,noMatches:"No matching elements.",maximize:"Maximize",restore:"Restore size",canvas:"Diagram. Arrow keys pan, plus and minus zoom, 0 fits the view.",dataError:"Could not load the diagram data.",nodes:"elements",edges:"relations",change:(a,e)=>`\u201C${a}\u201D \u2192 \u201C${e}\u201D`},ja:{tagFilter:"\u30BF\u30B0\u306E\u7D5E\u308A\u8FBC\u307F",tagMatch:"\u30BF\u30B0\u306E\u4E00\u81F4\u6761\u4EF6",clearTags:"\u89E3\u9664",zoomOut:"\u7E2E\u5C0F",fit:"\u5168\u4F53\u3092\u8868\u793A",zoomIn:"\u62E1\u5927",sendFailed:"\u9001\u4FE1\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u3082\u3046\u4E00\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002",commentOn:a=>`${a}\u306B\u30B3\u30E1\u30F3\u30C8`,noMatches:"\u8A72\u5F53\u3059\u308B\u8981\u7D20\u306F\u3042\u308A\u307E\u305B\u3093\u3002",maximize:"\u6700\u5927\u5316",restore:"\u5143\u306E\u30B5\u30A4\u30BA\u306B\u623B\u3059",canvas:"\u56F3\u3002\u77E2\u5370\u30AD\u30FC\u3067\u30D1\u30F3\u3001\u30D7\u30E9\u30B9\u30FB\u30DE\u30A4\u30CA\u30B9\u3067\u30BA\u30FC\u30E0\u30010\u3067\u5168\u4F53\u8868\u793A\u3002",dataError:"\u56F3\u306E\u30C7\u30FC\u30BF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F\u3002",nodes:"\u8981\u7D20",edges:"\u95A2\u9023",change:(a,e)=>`\u300C${a}\u300D\u2192\u300C${e}\u300D`}}),Xs={active:[],match:"single"},Q=(a,e)=>e.active.length===0?!0:e.match==="all"?e.active.every(t=>a.includes(t)):e.active.some(t=>a.includes(t)),Js=(a,e)=>a.active.includes(e)?{...a,active:a.active.filter(t=>t!==e)}:a.match==="single"?{...a,active:[e]}:{...a,active:[...a.active,e]},Zs=(a,e)=>({match:e,active:e==="single"&&a.active.length>1?a.active.slice(-1):a.active}),Qs=a=>({...a,active:[]}),ea=a=>{const e=new Map;for(const t of a)for(const s of new Set(t))e.set(s,(e.get(s)??0)+1);return[...e].map(([t,s])=>({tag:t,count:s}))},Y={nodes:new Map,edges:new Set},N=(a,e,t,s)=>{const n=new Map,r=new Set,i=[{id:e,depth:0}],o=new Set([e]);for(const d of i)if(!(!s&&d.depth>=1))for(const l of a){const c=t==="outgoing"?l.from:l.to,g=t==="outgoing"?l.to:l.from;c===d.id&&(r.add(l.id),!o.has(g)&&(o.add(g),n.set(g,d.depth+1),i.push({id:g,depth:d.depth+1})))}return{nodes:n,edges:r}},ta=(a,e)=>{const t=new Map(a.map(r=>[r,N(e,r,"outgoing",!0).nodes])),s=new Set,n=[];for(const r of a){if(s.has(r))continue;const i=a.filter(o=>o===r||t.get(r)?.has(o)===!0&&t.get(o)?.has(r)===!0);for(const o of i)s.add(o);(i.length>1||e.some(o=>o.from===r&&o.to===r))&&n.push(i)}return n},Ce=a=>new Map(a.flatMap((e,t)=>e.map(s=>[s,t]))),ut=(a,e)=>e.get(a.from)===e.get(a.to)&&e.has(a.from),mt=a=>{try{return a.split("/").map(e=>decodeURIComponent(e))}catch{return null}},gt=(a,e,t,s)=>{const n=e!==null&&e.kind===t&&e.id===a,r=t==="node"?s.nodes.has(a):s.edges.has(a),i=t==="node"?s.nodes.get(a)??null:null;return{selected:n,related:r&&!n,dimmed:e!==null&&!n&&!r,depth:i}},ee=(...a)=>a.filter(e=>typeof e=="string"&&e!=="").join(" "),sa=a=>{const e=a[0]??{x:0,y:0},t=a.at(-1)??e;if(a.length<=2)return{x:(e.x+t.x)/2,y:(e.y+t.y)/2};if(a.length===4){const r=a[1]??e,i=a[2]??t;return{x:r.x,y:(r.y+i.y)/2}}const s=a[2]??e,n=a[3]??t;return{x:(s.x+n.x)/2,y:s.y}},aa=(a,e)=>ea(a).map(t=>({tag:t.tag,count:t.count,selected:e.active.includes(t.tag)})),na=(a,e,t)=>`${a} ${t.node} \xB7 ${e} ${t.edge}`,W=[_e,Be,Ge,B`
1
+ import{a0 as _,Z as _e,j as Be,a1 as Ge,a2 as B,a3 as b,a4 as h,a5 as J,a6 as zs,J as Ds,a7 as I,a8 as Ye,a9 as Ve,aa as We,A as Ke,ab as Ts,ac as As,ad as G,ae as q,af as f,ag as z,ah as u,ai as H,aj as S,ak as M,al as ae,am as Xe,an as Je,ao as Z,ap as we,aq as Ze,ar as Ls,as as Rs,at as $e,au as Se,av as Os,aw as Me,l as Qe,ax as Is,ay as Ps,az as js,aA as ne,q as Fs,r as Ns}from"./shared-CBRj9Yll.js";import{i as et}from"./shared-CLabLKYD.js";import{p as tt,r as st,c as at}from"./shared-BJvnqK51.js";import{c as me}from"./shared-ml5h7U5L.js";const Us='script[type="application/json"]',nt=(a,e)=>{const t=a.querySelector(Us);if(!t)return null;const s=t.textContent??"";if(s.trim()==="")return{ok:!1,error:"JSON block is empty"};try{return{ok:!0,value:e(JSON.parse(s))}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},rt=(a,e,t)=>{const s=nt(a,e);if(s)return t(s),()=>{};const n=new MutationObserver(()=>{const r=nt(a,e);r&&(n.disconnect(),t(r))});return n.observe(a,{childList:!0,subtree:!0}),()=>n.disconnect()},it={nodeSpacing:34,layerSpacing:84,padding:28,sweeps:4,coordinatePasses:6},ge=a=>{const e=[...a].sort((s,n)=>s-n);if(e.length===0)return 0;const t=Math.floor(e.length/2);return e.length%2===1?e[t]??0:((e[t-1]??0)+(e[t]??0))/2},Hs=(a,e)=>{const t=new Map;for(const i of a)t.set(i.id,[]);for(const i of e)t.get(i.from)?.push(i);const s=new Map,n=new Set,r=i=>{s.set(i,"open");for(const o of t.get(i)??[]){const d=s.get(o.to)??"new";d==="open"?n.add(o.id):d==="new"&&r(o.to)}s.set(i,"done")};for(const i of a)(s.get(i.id)??"new")==="new"&&r(i.id);return{reversed:n,forward:e.filter(i=>!n.has(i.id))}},_s=(a,e)=>{const t=new Map,s=new Map;for(const o of a)t.set(o.id,[]),s.set(o.id,[]);for(const o of e)s.get(o.from)?.push(o),t.get(o.to)?.push(o);const n=new Map(a.map(o=>[o.id,0])),r=new Map(a.map(o=>[o.id,(t.get(o.id)??[]).length])),i=a.filter(o=>(r.get(o.id)??0)===0).map(o=>o.id);for(const o of i)for(const d of s.get(o)??[]){const l=n.get(d.to)??0;n.set(d.to,Math.max(l,(n.get(o)??0)+1));const c=(r.get(d.to)??0)-1;r.set(d.to,c),c===0&&i.push(d.to)}return n},Bs=(a,e,t,s)=>{const n=[...a.keys()].sort((r,i)=>r-i);for(let r=0;r<s;r++){const i=r%2===0;for(const o of i?n:[...n].reverse()){const d=a.get(o)??[],l=new Map(d.map((p,k)=>[p,k])),c=p=>{const k=l.get(p);return k===void 0?null:k},g=d.map(p=>{const k=(e.get(p)??[]).filter(x=>(t.get(x)??o)===o+(i?-1:1)).map(c).filter(x=>x!==null);return{id:p,want:k.length>0?ge(k):l.get(p)??0}});g.sort((p,k)=>p.want-k.want||(l.get(p.id)??0)-(l.get(k.id)??0)),a.set(o,g.map(p=>p.id))}}},ot=(a,e,t,s)=>{const n=a.map((i,o)=>({id:i,want:t.get(i)??o*100,index:o}));n.sort((i,o)=>i.want-o.want||i.index-o.index);let r=0;for(const i of n){const o=e.get(i.id);o&&(o.y=r,r+=o.spec.height+s)}return{height:Math.max(0,r-s)}},Gs=(a,e,t,s,n)=>{const r=[...a.keys()].sort((l,c)=>l-c),i=new Map;for(const l of r)i.set(l,ot(a.get(l)??[],e,new Map,n.nodeSpacing).height);const o=Math.max(0,...i.values());for(const l of r){const c=(o-(i.get(l)??0))/2;for(const g of a.get(l)??[]){const p=e.get(g);p&&(p.y+=c)}}const d=(l,c)=>{const g=(t.get(l)??[]).filter(p=>s.get(p)===c).flatMap(p=>{const k=e.get(p);return k?[k.y+k.spec.height/2]:[]});return g.length>0?ge(g):null};for(let l=0;l<n.coordinatePasses;l++){const c=l%2===0;for(const g of c?r:[...r].reverse()){const p=a.get(g)??[],k=new Map;for(const w of p){const D=d(w,g+(c?-1:1)),L=e.get(w);L!==void 0&&k.set(w,D===null?L.y+L.spec.height/2:D)}const x=p.map(w=>e.get(w)?.y??0);ot(p,e,k,n.nodeSpacing);const v=p.map(w=>e.get(w)?.y??0),y=ge(x)-ge(v);for(const w of p){const D=e.get(w);D&&(D.y+=y)}}}},dt=(a,e,t)=>{const s=e===void 0?void 0:a.spec.ports?.[e];return s?{x:a.x+s.x,y:a.y+s.y}:t==="out"?{x:a.x+a.spec.width,y:a.y+a.spec.height/2}:{x:a.x,y:a.y+a.spec.height/2}},lt=(a,e,t)=>{let s=0;const n=[];for(const r of a){const i=t.byId.get(r.from),o=t.byId.get(r.to);if(!i||!o)continue;const d=dt(i,r.fromPort,"out"),l=dt(o,r.toPort,"in");if(r.from===r.to){const x=i.x+i.spec.width,v=i.y+i.spec.height,y=Math.max(t.padding/2,v+18);n.push({id:r.id,points:[d,{x:x+20,y:d.y},{x:x+20,y},{x:i.x-20,y},{x:i.x-20,y:l.y},l]});continue}if(!e.has(r.id)&&(i.layer<o.layer||i.layer===o.layer&&l.x>d.x+12)){if(Math.abs(d.y-l.y)<.5){n.push({id:r.id,points:[d,l]});continue}const v=i.layer<o.layer?Math.max(d.x+14,o.x-Math.max(12,t.layerSpacing/2)):(d.x+l.x)/2;n.push({id:r.id,points:[d,{x:v,y:d.y},{x:v,y:l.y},l]});continue}const c=r.fromPort===void 0?{x:i.x+i.spec.width/2,y:i.y+i.spec.height}:d,g=r.toPort===void 0?{x:o.x+o.spec.width/2,y:o.y+o.spec.height}:l,p=Math.max(c.y,g.y)+18+s*14;s+=1;const k=[d,c,{x:c.x,y:p},{x:g.x,y:p},g,l].filter((x,v,y)=>v===0||x.x!==y[v-1]?.x||x.y!==y[v-1]?.y);n.push({id:r.id,points:k})}return n},ct=(a,e,t)=>{const s=e.flatMap(p=>[...p.points]),n=[...a.map(p=>p.x),...a.map(p=>p.x+p.spec.width),...s.map(p=>p.x)],r=[...a.map(p=>p.y),...a.map(p=>p.y+p.spec.height),...s.map(p=>p.y)],i=Math.min(0,...n),o=Math.min(0,...r),d=Math.max(0,...n),l=Math.max(0,...r),c=t-i,g=t-o;return{width:d-i+t*2,height:l-o+t*2,nodes:a.map(p=>({id:p.spec.id,x:p.x+c,y:p.y+g,width:p.spec.width,height:p.spec.height,layer:p.layer,order:p.order})),routes:e.map(p=>({id:p.id,points:p.points.map(k=>({x:k.x+c,y:k.y+g}))}))}},pt=(a,e)=>{const t=new Map(a.map(s=>[s.id,[]]));for(const s of e)s.from!==s.to&&(t.get(s.from)?.push(s.to),t.get(s.to)?.push(s.from));return t},ht=(a,e,t,s)=>a.map(n=>({spec:n,layer:e.get(n.id)??0,order:t.get(n.id)??0,...s(n)})),Ys=(a,e)=>{const t=new Map;for(const s of a){const n=e.get(s.id)??0,r=t.get(n);r?r.push(s.id):t.set(n,[s.id])}return t},Vs=(a,e,t={})=>{const s={...it,...t};if(a.length===0)return{width:0,height:0,nodes:[],routes:[]};const n=new Set(a.map(v=>v.id)),r=e.filter(v=>n.has(v.from)&&n.has(v.to)),{forward:i,reversed:o}=Hs(a,r),d=_s(a,i),l=Ys(a,d);Bs(l,pt(a,r),d,s.sweeps);const c=new Map;for(const v of l.values())v.forEach((y,w)=>c.set(y,w));const g=ht(a,d,c,()=>({x:0,y:0})),p=new Map(g.map(v=>[v.spec.id,v]));Gs(l,p,pt(a,r),d,s);const k=[...l.keys()].sort((v,y)=>v-y);let x=0;for(const v of k){const y=Math.max(...(l.get(v)??[]).map(w=>p.get(w)?.spec.width??0));for(const w of l.get(v)??[]){const D=p.get(w);D&&(D.x=x)}x+=y+s.layerSpacing}return ct(g,lt(r,o,{byId:p,layerSpacing:s.layerSpacing,padding:s.padding}),s.padding)},Ws=(a,e,t={})=>{const s={...it,...t};if(a.length===0)return{width:0,height:0,nodes:[],routes:[]};const n=new Set(a.map(d=>d.id)),r=e.filter(d=>n.has(d.from)&&n.has(d.to)),i=ht(a,new Map,new Map,d=>d.position??{x:0,y:0}),o=new Map(i.map(d=>[d.spec.id,d]));return ct(i,lt(r,new Set,{byId:o,layerSpacing:s.layerSpacing,padding:s.padding}),s.padding)},Ks=_({en:{tagFilter:"Filter by tag",tagMatch:"Tag matching",clearTags:"Clear",zoomOut:"Zoom out",fit:"Fit to view",zoomIn:"Zoom in",sendFailed:"Could not send. Please try again.",commentOn:a=>`Comment on ${a}`,noMatches:"No matching elements.",maximize:"Maximize",restore:"Restore size",canvas:"Diagram. Arrow keys pan, plus and minus zoom, 0 fits the view.",dataError:"Could not load the diagram data.",nodes:"elements",edges:"relations",change:(a,e)=>`\u201C${a}\u201D \u2192 \u201C${e}\u201D`},ja:{tagFilter:"\u30BF\u30B0\u306E\u7D5E\u308A\u8FBC\u307F",tagMatch:"\u30BF\u30B0\u306E\u4E00\u81F4\u6761\u4EF6",clearTags:"\u89E3\u9664",zoomOut:"\u7E2E\u5C0F",fit:"\u5168\u4F53\u3092\u8868\u793A",zoomIn:"\u62E1\u5927",sendFailed:"\u9001\u4FE1\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u3082\u3046\u4E00\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002",commentOn:a=>`${a}\u306B\u30B3\u30E1\u30F3\u30C8`,noMatches:"\u8A72\u5F53\u3059\u308B\u8981\u7D20\u306F\u3042\u308A\u307E\u305B\u3093\u3002",maximize:"\u6700\u5927\u5316",restore:"\u5143\u306E\u30B5\u30A4\u30BA\u306B\u623B\u3059",canvas:"\u56F3\u3002\u77E2\u5370\u30AD\u30FC\u3067\u30D1\u30F3\u3001\u30D7\u30E9\u30B9\u30FB\u30DE\u30A4\u30CA\u30B9\u3067\u30BA\u30FC\u30E0\u30010\u3067\u5168\u4F53\u8868\u793A\u3002",dataError:"\u56F3\u306E\u30C7\u30FC\u30BF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F\u3002",nodes:"\u8981\u7D20",edges:"\u95A2\u9023",change:(a,e)=>`\u300C${a}\u300D\u2192\u300C${e}\u300D`}}),Xs={active:[],match:"single"},Q=(a,e)=>e.active.length===0?!0:e.match==="all"?e.active.every(t=>a.includes(t)):e.active.some(t=>a.includes(t)),Js=(a,e)=>a.active.includes(e)?{...a,active:a.active.filter(t=>t!==e)}:a.match==="single"?{...a,active:[e]}:{...a,active:[...a.active,e]},Zs=(a,e)=>({match:e,active:e==="single"&&a.active.length>1?a.active.slice(-1):a.active}),Qs=a=>({...a,active:[]}),ea=a=>{const e=new Map;for(const t of a)for(const s of new Set(t))e.set(s,(e.get(s)??0)+1);return[...e].map(([t,s])=>({tag:t,count:s}))},Y={nodes:new Map,edges:new Set},N=(a,e,t,s)=>{const n=new Map,r=new Set,i=[{id:e,depth:0}],o=new Set([e]);for(const d of i)if(!(!s&&d.depth>=1))for(const l of a){const c=t==="outgoing"?l.from:l.to,g=t==="outgoing"?l.to:l.from;c===d.id&&(r.add(l.id),!o.has(g)&&(o.add(g),n.set(g,d.depth+1),i.push({id:g,depth:d.depth+1})))}return{nodes:n,edges:r}},ta=(a,e)=>{const t=new Map(a.map(r=>[r,N(e,r,"outgoing",!0).nodes])),s=new Set,n=[];for(const r of a){if(s.has(r))continue;const i=a.filter(o=>o===r||t.get(r)?.has(o)===!0&&t.get(o)?.has(r)===!0);for(const o of i)s.add(o);(i.length>1||e.some(o=>o.from===r&&o.to===r))&&n.push(i)}return n},Ce=a=>new Map(a.flatMap((e,t)=>e.map(s=>[s,t]))),ut=(a,e)=>e.get(a.from)===e.get(a.to)&&e.has(a.from),mt=a=>{try{return a.split("/").map(e=>decodeURIComponent(e))}catch{return null}},gt=(a,e,t,s)=>{const n=e!==null&&e.kind===t&&e.id===a,r=t==="node"?s.nodes.has(a):s.edges.has(a),i=t==="node"?s.nodes.get(a)??null:null;return{selected:n,related:r&&!n,dimmed:e!==null&&!n&&!r,depth:i}},ee=(...a)=>a.filter(e=>typeof e=="string"&&e!=="").join(" "),sa=a=>{const e=a[0]??{x:0,y:0},t=a.at(-1)??e;if(a.length<=2)return{x:(e.x+t.x)/2,y:(e.y+t.y)/2};if(a.length===4){const r=a[1]??e,i=a[2]??t;return{x:r.x,y:(r.y+i.y)/2}}const s=a[2]??e,n=a[3]??t;return{x:(s.x+n.x)/2,y:s.y}},aa=(a,e)=>ea(a).map(t=>({tag:t.tag,count:t.count,selected:e.active.includes(t.tag)})),na=(a,e,t)=>`${a} ${t.node} \xB7 ${e} ${t.edge}`,W=[_e,Be,Ge,B`
2
2
  :host {
3
3
  display: block;
4
4
  container-type: inline-size;
@@ -1,16 +1,16 @@
1
- import{aj as x,aO as Ir,ae as C,aA as R,aB as g,ah as u,af as z,ai as ce,ad as Pr,aP as Qe,aQ as _r,ag as Y,ak as E,as as Rr,p as b,au as m,v as ue,az as te,P as Dr,e as Cr,a0 as Or,h as et,N as Ae,V as U,U as Mr,R as y,a4 as d,a3 as c,aR as Ie,aS as Pe,aF as _e,a5 as Lr,z as Re,aE as tt,l as Nr,A as rt,aT as O,aU as zr,aV as Vr,J as it,aW as Yr,ac as Ur,ab as Wr,a2 as Br,T as nt,a1 as Hr,aX as Gr,a9 as Fr,C as jr,aY as qr}from"./shared-rZQ5j0Kh.js";import{p as Kr,r as Xr,c as Zr}from"./shared-Dc_FGuLM.js";import{i as ot}from"./shared-DjOBIYHF.js";const Jr=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}],["path",{d:"M2 12h20"}]],Qr=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}]],ei=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21"}]],ti=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"}]],ri=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}]],ii=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2"}],["path",{d:"M12 18h.01"}]],ni=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18"}]],oi=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}],["circle",{cx:"12",cy:"7",r:"4"}]],st=["browser","native","mail","plain"],at=["mobile","tablet","desktop","fluid"],K=e=>"screen"in e,si=C({from:g(u()),to:g(u()),cc:g(u()),subject:g(u()),date:g(u())}),ai={id:R,kind:z(ce(st),"browser"),viewport:z(ce(at),"fluid"),label:g(u()),url:g(u()),mail:g(si)},De=x(C(ai),Ir(e=>e.mail===void 0||e.kind==="mail",'a preview `mail` envelope needs `"kind": "mail"`')),dt=Rr([C({screen:R,preview:g(R)}),C({material:De})]),di=C({id:R,name:x(u(),E(1)),description:g(u()),actor:g(x(u(),E(1))),situation:g(x(u(),E(1))),panes:z(Y(dt),[])}),pi=C({id:R,name:x(u(),E(1)),description:g(u()),actor:g(x(u(),E(1))),steps:z(Y(di),[])}),li=C({id:R,name:x(u(),E(1)),description:g(u()),actor:g(x(u(),E(1))),stories:z(Y(pi),[])}),ci=C({id:R,title:x(u(),E(1)),description:g(u()),previews:z(Y(De),[])}),ui=C({id:R,name:x(u(),E(1)),description:g(u()),actor:g(x(u(),E(1))),screens:z(Y(ci),[])}),pt=C({title:g(u()),baseUrl:g(u()),apps:z(Y(ui),[]),activities:z(Y(li),[])}),lt=e=>e.flatMap(t=>K(t)?[]:[t.material]),hi=e=>{const t=new Set,r=s=>{for(const a of s){if(t.has(a.id))return`duplicate preview id "${a.id}": preview ids are global, they name a light DOM slot`;t.add(a.id)}return null},i=new Set,n=new Set;for(const s of e.apps){if(i.has(s.id))return`duplicate app id "${s.id}"`;i.add(s.id);for(const a of s.screens){if(n.has(a.id))return`duplicate screen id "${a.id}": screen ids are global`;n.add(a.id);const p=r(a.previews);if(p!==null)return p}}const o=new Set;for(const s of e.activities){if(o.has(s.id))return`duplicate activity id "${s.id}"`;o.add(s.id);const a=new Set;for(const p of s.stories){if(a.has(p.id))return`duplicate story id "${p.id}" in activity "${s.id}"`;a.add(p.id);const l=new Set;for(const w of p.steps){if(l.has(w.id))return`duplicate step id "${w.id}" in story "${p.id}"`;l.add(w.id);const h=r(lt(w.panes));if(h!==null)return h}}}return null},ct=(e,t)=>{const r=new Map;for(const i of t.panes){if(!K(i))continue;const n=e(i.screen);if(n===void 0)return`unknown screen "${i.screen}" on step "${t.id}": declare it under \`apps[].screens\``;if(i.preview!==void 0&&!n.includes(i.preview))return`preview "${i.preview}" on step "${t.id}" is not a rendition of screen "${i.screen}"`;const o=r.get(i.screen)??[];if(o.length>0&&(i.preview===void 0||o.includes(i.preview)||o.includes(void 0)))return`screen "${i.screen}" is shown twice on step "${t.id}": give each pane a different \`preview\``;r.set(i.screen,[...o,i.preview])}return null},vi=e=>{const t=new Map(e.apps.flatMap(r=>r.screens.map(i=>[i.id,i.previews.map(n=>n.id)])));for(const r of e.activities.flatMap(i=>i.stories.flatMap(n=>n.steps))){const i=ct(n=>t.get(n),r);if(i!==null)return i}return null},gi=(e,t)=>ct(r=>M(e,r)?.screen.previews.map(i=>i.id),t),re="ui",ut=e=>{const t=e.text?.replaceAll('"',"'");return`${e.previewId}/${e.selector}${t===void 0?"":` "${t}"`}`},Ce=e=>{const t=e.indexOf("/");if(t<=0)return;const r=e.slice(0,t);if(!_r(R,r))return;const i=e.slice(t+1),n=/ "([^"]*)"$/.exec(i),o=(n?i.slice(0,n.index):i).trim();if(o!=="")return n?.[1]===void 0?{previewId:r,selector:o}:{previewId:r,selector:o,text:n[1]}},ht=e=>{const t=Pr(pt,e),r=hi(t)??vi(t);if(r!==null)throw new Error(r);return t},vt=()=>({apps:[],activities:[]}),W=e=>e.apps.flatMap(t=>t.screens.map(r=>({app:t,screen:r}))),M=(e,t)=>{if(t!==void 0)return W(e).find(r=>r.screen.id===t)},he=(e,t)=>t.panes.flatMap(r=>{const i=K(r)?M(e,r.screen):void 0;return i?[i]:[]}),X=e=>lt(e.panes),fi=(e,t)=>e.panes.some(r=>K(r)&&r.screen===t),L=(e,t)=>{if(t!==void 0)return e.activities.find(r=>r.id===t)},D=(e,t)=>`${e}.${t}`,$=(e,t)=>{if(t===void 0)return;const r=Qe(t,2);if(r){const[n,o]=r;if(n===void 0||o===void 0)return;const s=e.activities.find(p=>p.id===n),a=s?.stories.find(p=>p.id===o);return s&&a?{activity:s,story:a}:void 0}if(t.includes("."))return;const i=e.activities.flatMap(n=>n.stories.filter(o=>o.id===t).map(o=>({activity:n,story:o})));return i.length===1?i[0]:void 0},gt=e=>{const t=e.lastIndexOf(".");return t>=0?e.slice(t+1):e},ie=e=>`${e.activity.id}.${e.story.id}.${e.step.id}`,ve=(e,t,r)=>`${e.id}.${t.id}.${r.id}`,k=(e,t)=>{if(t===void 0)return;const r=Qe(t,3);if(r){const[n,o,s]=r;if(n===void 0||o===void 0||s===void 0)return;const a=e.activities.find(h=>h.id===n),p=a?.stories.find(h=>h.id===o),l=p?p.steps.findIndex(h=>h.id===s):-1,w=p&&l>=0?p.steps[l]:void 0;return a&&p&&w?{activity:a,story:p,step:w,stepIndex:l}:void 0}if(t.includes("."))return;const i=B(e).filter(n=>n.step.id===t);return i.length===1?i[0]:void 0},A=(e,t)=>{if(t!==void 0){for(const r of W(e)){const i=r.screen.previews.find(n=>n.id===t);if(i)return{owner:{kind:"screen",...r},preview:i}}for(const r of B(e)){const i=X(r.step).find(n=>n.id===t);if(i)return{owner:{kind:"step",...r},preview:i}}}},B=e=>e.activities.flatMap(t=>t.stories.flatMap(r=>r.steps.map((i,n)=>({activity:t,story:r,step:i,stepIndex:n})))),ft=e=>B(e).map(t=>t.step.id),f={SET_ACTIVITY_NAME:b("SET_ACTIVITY_NAME","activity",m({name:x(u(),E(1))})),SET_ACTIVITY_DESCRIPTION:b("SET_ACTIVITY_DESCRIPTION","activity",m({description:u()})),SET_STORY_NAME:b("SET_STORY_NAME","story",m({name:x(u(),E(1))})),SET_STORY_DESCRIPTION:b("SET_STORY_DESCRIPTION","story",m({description:u()})),SET_STEP_NAME:b("SET_STEP_NAME","step",m({name:x(u(),E(1))})),SET_STEP_DESCRIPTION:b("SET_STEP_DESCRIPTION","step",m({description:u()})),SET_PREVIEW_KIND:b("SET_PREVIEW_KIND","preview",m({kind:ce(st)})),SET_PREVIEW_VIEWPORT:b("SET_PREVIEW_VIEWPORT","preview",m({viewport:ce(at)})),SET_PREVIEW_LABEL:b("SET_PREVIEW_LABEL","preview",m({label:u()})),REORDER_ACTIVITY:b("REORDER_ACTIVITY","activity",m({after:te(u())}),{mode:"sequence"}),REORDER_STORY:b("REORDER_STORY","story",m({after:te(u())}),{mode:"sequence"}),REORDER_STEP:b("REORDER_STEP","step",m({after:te(u())}),{mode:"sequence"}),MOVE_STORY:b("MOVE_STORY","story",m({toActivity:x(u(),E(1)),after:te(u())}),{mode:"sequence"}),MOVE_STEP:b("MOVE_STEP","step",m({toStory:x(u(),E(1)),after:te(u())}),{mode:"sequence"}),ADD_ACTIVITY:b("ADD_ACTIVITY","page",m({id:R,name:x(u(),E(1)),description:g(u())}),{dedupeKey:ue}),ADD_STORY:b("ADD_STORY","activity",m({id:R,name:x(u(),E(1)),description:g(u())}),{dedupeKey:ue}),ADD_STEP:b("ADD_STEP","story",m({id:R,name:x(u(),E(1)),description:g(u()),panes:g(Y(dt))}),{dedupeKey:ue}),ADD_PREVIEW:b("ADD_PREVIEW","step",De,{dedupeKey:ue}),DELETE_ACTIVITY:b("DELETE_ACTIVITY","activity",m({})),DELETE_STORY:b("DELETE_STORY","story",m({})),DELETE_STEP:b("DELETE_STEP","step",m({})),DELETE_PREVIEW:b("DELETE_PREVIEW","preview",m({}))},ne={setActivityName:(e,t)=>({type:"SET_ACTIVITY_NAME",target:{type:"activity",id:e},payload:{name:t}}),setActivityDescription:(e,t)=>({type:"SET_ACTIVITY_DESCRIPTION",target:{type:"activity",id:e},payload:{description:t}}),setStoryName:(e,t)=>({type:"SET_STORY_NAME",target:{type:"story",id:e},payload:{name:t}}),setStoryDescription:(e,t)=>({type:"SET_STORY_DESCRIPTION",target:{type:"story",id:e},payload:{description:t}}),setStepName:(e,t)=>({type:"SET_STEP_NAME",target:{type:"step",id:e},payload:{name:t}}),setStepDescription:(e,t)=>({type:"SET_STEP_DESCRIPTION",target:{type:"step",id:e},payload:{description:t}}),setPreviewViewport:(e,t)=>({type:"SET_PREVIEW_VIEWPORT",target:{type:"preview",id:e},payload:{viewport:t}}),setPreviewKind:(e,t)=>({type:"SET_PREVIEW_KIND",target:{type:"preview",id:e},payload:{kind:t}}),setPreviewLabel:(e,t)=>({type:"SET_PREVIEW_LABEL",target:{type:"preview",id:e},payload:{label:t}}),reorderActivity:(e,t)=>({type:"REORDER_ACTIVITY",target:{type:"activity",id:e},payload:{after:t}}),reorderStory:(e,t)=>({type:"REORDER_STORY",target:{type:"story",id:e},payload:{after:t}}),reorderStep:(e,t)=>({type:"REORDER_STEP",target:{type:"step",id:e},payload:{after:t}}),moveStep:(e,t,r)=>({type:"MOVE_STEP",target:{type:"step",id:e},payload:{toStory:t,after:r}}),moveStory:(e,t,r)=>({type:"MOVE_STORY",target:{type:"story",id:e},payload:{toActivity:t,after:r}}),addActivity:(e,t,r)=>({type:"ADD_ACTIVITY",target:{type:"page",id:"prototype"},payload:{id:e,name:t,...r===void 0?{}:{description:r}}}),addStory:(e,t,r,i)=>({type:"ADD_STORY",target:{type:"activity",id:e},payload:{id:t,name:r,...i===void 0?{}:{description:i}}}),addStep:(e,t,r,i)=>({type:"ADD_STEP",target:{type:"story",id:e},payload:{id:t,name:r,...i===void 0?{}:{panes:i}}}),addPreview:(e,t)=>({type:"ADD_PREVIEW",target:{type:"step",id:e},payload:{...t}}),deleteActivity:e=>({type:"DELETE_ACTIVITY",target:{type:"activity",id:e},payload:{}}),deleteStory:e=>({type:"DELETE_STORY",target:{type:"story",id:e},payload:{}}),deleteStep:e=>({type:"DELETE_STEP",target:{type:"step",id:e},payload:{}}),deletePreview:e=>({type:"DELETE_PREVIEW",target:{type:"preview",id:e},payload:{}})},wt=(e,t)=>{const r=Dr(f,t);if(r===null)return null;const i=r.target.id;switch(r.type){case"SET_ACTIVITY_NAME":return H(e,i,n=>({...n,name:r.payload.name}));case"SET_ACTIVITY_DESCRIPTION":return H(e,i,n=>({...n,description:r.payload.description}));case"SET_STORY_NAME":return G(e,i,n=>({...n,name:r.payload.name}));case"SET_STORY_DESCRIPTION":return G(e,i,n=>({...n,description:r.payload.description}));case"SET_STEP_NAME":return ge(e,i,n=>({...n,name:r.payload.name}));case"SET_STEP_DESCRIPTION":return ge(e,i,n=>({...n,description:r.payload.description}));case"SET_PREVIEW_KIND":return Me(e,i,n=>({...n,kind:r.payload.kind}));case"SET_PREVIEW_VIEWPORT":return Me(e,i,n=>({...n,viewport:r.payload.viewport}));case"SET_PREVIEW_LABEL":return Me(e,i,n=>({...n,label:r.payload.label}));case"REORDER_ACTIVITY":{const{after:n}=r.payload,o=oe(e.activities,i,n);return o===null?null:{...e,activities:o}}case"REORDER_STORY":{const{after:n}=r.payload,o=$(e,i);if(!o)return null;const s=n===null?null:$(e,n);if(n!==null&&(!s||s.activity!==o.activity))return null;const a=oe(o.activity.stories,o.story.id,s?.story.id??null);return a===null?null:H(e,o.activity.id,p=>({...p,stories:a}))}case"REORDER_STEP":{const{after:n}=r.payload,o=k(e,i);if(!o)return null;const s=n===null?null:k(e,n);if(n!==null&&(!s||s.story!==o.story))return null;const a=oe(o.story.steps,o.step.id,s?.step.id??null);return a===null?null:G(e,D(o.activity.id,o.story.id),p=>({...p,steps:a}))}case"MOVE_STORY":{const{toActivity:n,after:o}=r.payload,s=$(e,i);if(!s)return null;const a=e.activities.find(h=>h.id===n);if(!a)return null;const p=o===null?null:$(e,o);if(o!==null&&(!p||p.activity!==a))return null;const l=p?.story.id??null;if(s.activity.id===n){const h=oe(s.activity.stories,s.story.id,l);return h===null?null:H(e,n,v=>({...v,stories:h}))}if(a.stories.some(h=>h.id===s.story.id))return null;const w=Le(a.stories,s.story,l);return Oe(e,h=>h.id===s.activity.id?{...h,stories:h.stories.filter(v=>v.id!==gt(i))}:h.id===n?{...h,stories:w}:h)}case"MOVE_STEP":{const{toStory:n,after:o}=r.payload,s=k(e,i);if(!s)return null;const a=$(e,n);if(!a)return null;const p=o===null?null:k(e,o);if(o!==null&&(!p||p.story!==a.story))return null;const l=p?.step.id??null;if(s.story===a.story){const h=oe(s.story.steps,s.step.id,l);return h===null?null:G(e,n,v=>({...v,steps:h}))}if(a.story.steps.some(h=>h.id===s.step.id))return null;const w=Le(a.story.steps,s.step,l);return Oe(e,h=>({...h,stories:h.stories.map(v=>v===s.story?{...v,steps:v.steps.filter(I=>I.id!==gt(i))}:v===a.story?{...v,steps:w}:v)}))}case"ADD_ACTIVITY":{const n=r.payload;if(e.activities.some(s=>s.id===n.id))return e;const o={id:n.id,name:n.name,...n.description===void 0?{}:{description:n.description},stories:[]};return{...e,activities:[...e.activities,o]}}case"ADD_STORY":{const n=r.payload,o=e.activities.find(a=>a.id===i);if(!o)return null;if(o.stories.some(a=>a.id===n.id))return e;const s={id:n.id,name:n.name,...n.description===void 0?{}:{description:n.description},steps:[]};return H(e,i,a=>({...a,stories:[...a.stories,s]}))}case"ADD_STEP":{const n=r.payload,o=$(e,i)?.story;if(!o)return null;if(o.steps.some(p=>p.id===n.id))return e;const s=n.panes??[],a={id:n.id,name:n.name,...n.description===void 0?{}:{description:n.description},panes:s};return wi(e,a)?G(e,i,p=>({...p,steps:[...p.steps,a]})):null}case"ADD_PREVIEW":{const n=r.payload,o=k(e,i)?.step;return o?X(o).some(s=>s.id===n.id)?e:A(e,n.id)?null:ge(e,i,s=>({...s,panes:[...s.panes,{material:n}]})):null}case"DELETE_ACTIVITY":{const n=i;return e.activities.some(o=>o.id===n)?{...e,activities:e.activities.filter(o=>o.id!==n)}:null}case"DELETE_STORY":{const n=$(e,i);return n?H(e,n.activity.id,o=>({...o,stories:o.stories.filter(s=>s.id!==n.story.id)})):null}case"DELETE_STEP":{const n=k(e,i);return n?G(e,D(n.activity.id,n.story.id),o=>({...o,steps:o.steps.filter(s=>s.id!==n.step.id)})):null}case"DELETE_PREVIEW":{const n=A(e,i);return n?bt(e,n.owner,o=>o.filter(s=>s.id!==n.preview.id)):null}default:return Cr(r)}},Oe=(e,t)=>({...e,activities:e.activities.map(t)}),H=(e,t,r)=>{const i=t;return e.activities.some(n=>n.id===i)?Oe(e,n=>n.id===i?r(n):n):null},G=(e,t,r)=>{const i=$(e,t);if(!i)return null;const n=i.story.id;return H(e,i.activity.id,o=>({...o,stories:o.stories.map(s=>s.id===n?r(s):s)}))},ge=(e,t,r)=>{const i=k(e,t);if(!i)return null;const n=i.step.id;return G(e,D(i.activity.id,i.story.id),o=>({...o,steps:o.steps.map(s=>s.id===n?r(s):s)}))},Me=(e,t,r)=>{const i=A(e,t);if(!i)return null;const n=i.preview.id;return bt(e,i.owner,o=>o.map(s=>s.id===n?r(s):s))},wi=(e,t)=>{const r=X(t).map(i=>i.id);return gi(e,t)===null&&new Set(r).size===r.length&&!r.some(i=>A(e,i))},bt=(e,t,r)=>{if(t.kind==="step")return ge(e,ie(t),n=>{const o=new Map(r([...X(n)]).map(s=>[s.id,s]));return{...n,panes:n.panes.flatMap(s=>{if(K(s))return[s];const a=o.get(s.material.id);return a?[{material:a}]:[]})}});const i=t.screen.id;return{...e,apps:e.apps.map(n=>n.id===t.app.id?{...n,screens:n.screens.map(o=>o.id===i?{...o,previews:r(o.previews)}:o)}:n)}},oe=(e,t,r)=>{const i=e.findIndex(s=>s.id===t);if(i<0||r!==null&&!e.some(s=>s.id===r))return null;if(t===r)return[...e];const n=e[i];if(n===void 0)return null;const o=e.filter(s=>s.id!==t);return Le(o,n,r)},Le=(e,t,r)=>{const i=[...e],n=r===null?-1:i.findIndex(o=>o.id===r);return i.splice(n+1,0,t),i},mt={"iphone-se":"iPhone SE","iphone-16":"iPhone 16","iphone-16-pro-max":"iPhone 16 Pro Max","pixel-7":"Pixel 7","galaxy-s24":"Galaxy S24","ipad-mini":"iPad mini","ipad-air-11":'iPad Air 11"',"ipad-pro-11":'iPad Pro 11"',"ipad-pro-13":'iPad Pro 13"'},bi={"laptop-13":'13" laptop',"laptop-15":'15" laptop',"full-hd":"Full HD","monitor-27":'27" monitor',ultrawide:"Ultrawide"},mi={"laptop-13":"13 \u30A4\u30F3\u30C1 \u30CE\u30FC\u30C8","laptop-15":"15 \u30A4\u30F3\u30C1 \u30CE\u30FC\u30C8","full-hd":"\u30D5\u30EB HD","monitor-27":"27 \u30A4\u30F3\u30C1 \u30E2\u30CB\u30BF\u30FC",ultrawide:"\u30A6\u30EB\u30C8\u30E9\u30EF\u30A4\u30C9"},fe=Or({en:{renameActivity:"Rename Activity",updateActivityDescription:"Update Activity description",renameStory:"Rename UserStory",updateStoryDescription:"Update UserStory description",renameStep:"Rename Step",updateStepDescription:"Update Step description",changePreviewKind:"Change Preview kind",changePreviewViewport:"Change Preview viewport",changePreviewLabel:"Change Preview label",moveStory:"Move UserStory",moveStep:"Move Step",deleteTitle:"Delete",reorderTitle:e=>`Reorder ${e}`,addTitle:e=>`Add ${e}`,toFront:"\u2192 To the front",afterName:e=>`\u2192 Right after "${e}"`,unknownTarget:"(unknown target)",activityGroup:"Activity",storyGroup:"UserStory",stepGroup:"Step",screenGroup:"Screen",openInApp:"Open this screen in the app view",previewGroup:"Preview",pageGroup:"Page",uiGroup:"UI",targetLabel:(e,t)=>`${e} \xB7 ${t}`,targetMissing:(e,t)=>`${e} \xB7 ${t} (missing)`,noActivityBefore:"There are no Activities yet. Add ",noActivityAfter:" to the base JSON, or ask the agent.",deleteStepAria:"Delete step",addStepButton:"+ Step",stepNameLabel:"Step name",descriptionLabel:"Description",descriptionPlaceholder:"What happens in this Step (click to edit)",newStepName:"New step",viewLabel:"View",viewScenario:"Scenario",viewApp:"App",viewScenarioHint:"Follow one user story step by step",viewAppHint:"Use the UI as one app, whatever the scenario",appScreens:"Screens",appScreensHint:"Pick a screen to start from, then move around through the UI itself.",appSelectLabel:"App",appOutsideBrowser:"Outside the browser",noStepBefore:"There are no Steps yet. A Prototype has the meaning structure ",noStepAfter:" \u2014 one Step is one moment of the story: the screen the user is on and what they have at hand. Add a Step to the base JSON, and its screen will appear here.",noScreens:"This product has no screens yet. Declare its apps and their screens under apps[].screens in the base JSON, and they will appear here.",noPreviewMetadata:"No preview metadata \u2014 ask the agent to add it.",storyWithoutSteps:"This UserStory has no Steps yet, so there is no screen to show. Add one with + Step, or ask the agent to prototype it.",pageActor:e=>`Used by ${e}`,maximize:"Maximize",restore:"Restore size",maximizeHint:"Show the preview alone across the tab \xB7 Esc to restore",situation:"Situation",uiComment:"Comment on UI",uiCommentHint:"Click any part of the preview to comment on it \xB7 Esc to finish",uiCommentPin:(e,t)=>`Comment ${e}: ${t}`,mailFrom:"From",mailTo:"To",mailCc:"Cc",mailDate:"Date",demo:"Demo",demoHint:"Use the app in a browser across the tab, with nothing else on screen \xB7 Esc to finish",exitDemo:"Exit demo",browserBack:"Back",browserForward:"Forward",browserReload:"Reload",browserAddress:"Address",browserTabs:"Tabs",newTab:"New tab",closeTab:"Close tab",browserProfile:e=>`Profile: ${e}`,browserGuest:"Guest",newTabShortcuts:"Pages of this app",unreachableTitle:"This site can\u2019t be reached",unreachableBody:"No page of the prototype has this address.",device:"Device",deviceHint:"The window the app runs in: a page taller than it scrolls inside, as on the device",deviceName:e=>mt[e]??bi[e]??e,deviceZoom:e=>`Shown at ${e}% to fit`},ja:{renameActivity:"Activity \u540D\u3092\u5909\u66F4",updateActivityDescription:"Activity \u306E\u8AAC\u660E\u3092\u66F4\u65B0",renameStory:"UserStory \u540D\u3092\u5909\u66F4",updateStoryDescription:"UserStory \u306E\u8AAC\u660E\u3092\u66F4\u65B0",renameStep:"Step \u540D\u3092\u5909\u66F4",updateStepDescription:"Step \u306E\u8AAC\u660E\u3092\u66F4\u65B0",changePreviewKind:"Preview \u306E\u7A2E\u5225\u3092\u5909\u66F4",changePreviewViewport:"Preview \u306E\u30D3\u30E5\u30FC\u30DD\u30FC\u30C8\u3092\u5909\u66F4",changePreviewLabel:"Preview \u306E\u30E9\u30D9\u30EB\u3092\u5909\u66F4",moveStory:"UserStory \u3092\u79FB\u52D5",moveStep:"Step \u3092\u79FB\u52D5",deleteTitle:"\u524A\u9664",reorderTitle:e=>`${e} \u306E\u9806\u5E8F\u3092\u5909\u66F4`,addTitle:e=>`${e} \u3092\u8FFD\u52A0`,toFront:"\u2192 \u5148\u982D\u3078",afterName:e=>`\u2192 "${e}" \u306E\u76F4\u5F8C\u3078`,unknownTarget:"(unknown target)",activityGroup:"Activity",storyGroup:"UserStory",stepGroup:"Step",screenGroup:"\u753B\u9762",openInApp:"\u3053\u306E\u753B\u9762\u3092\u30A2\u30D7\u30EA\u30D3\u30E5\u30FC\u3067\u958B\u304F",previewGroup:"Preview",pageGroup:"Page",uiGroup:"UI",targetLabel:(e,t)=>`${e} \xB7 ${t}`,targetMissing:(e,t)=>`${e} \xB7 ${t} (missing)`,noActivityBefore:"Activity \u304C\u307E\u3060\u3042\u308A\u307E\u305B\u3093\u3002base JSON \u306E ",noActivityAfter:" \u3092\u8FFD\u52A0\u3059\u308B\u304B\u3001Agent \u306B\u4F9D\u983C\u3057\u3066\u304F\u3060\u3055\u3044\u3002",deleteStepAria:"\u30B9\u30C6\u30C3\u30D7\u3092\u524A\u9664",addStepButton:"+ Step",stepNameLabel:"Step \u540D",descriptionLabel:"\u8AAC\u660E",descriptionPlaceholder:"\u3053\u306E Step \u3067\u4F55\u304C\u8D77\u304D\u308B\u304B\uFF08\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u7DE8\u96C6\uFF09",newStepName:"\u65B0\u3057\u3044\u30B9\u30C6\u30C3\u30D7",viewLabel:"\u8868\u793A",viewScenario:"\u30B7\u30CA\u30EA\u30AA",viewApp:"\u30A2\u30D7\u30EA",viewScenarioHint:"\u30E6\u30FC\u30B6\u30FC\u30B9\u30C8\u30FC\u30EA\u30FC\u306B\u6CBF\u3063\u3066 Step \u3092\u9806\u306B\u305F\u3069\u308B",viewAppHint:"\u30B7\u30CA\u30EA\u30AA\u306B\u95A2\u4FC2\u306A\u304F\u3001UI \u3092 1 \u3064\u306E\u30A2\u30D7\u30EA\u3068\u3057\u3066\u89E6\u308B",appScreens:"\u753B\u9762",appScreensHint:"\u8D77\u70B9\u306B\u3059\u308B\u753B\u9762\u3092\u9078\u3073\u3001\u3042\u3068\u306F UI \u306E\u30EA\u30F3\u30AF\u3067\u79FB\u52D5\u3057\u307E\u3059\u3002",appSelectLabel:"\u30A2\u30D7\u30EA",appOutsideBrowser:"\u30D6\u30E9\u30A6\u30B6\u4EE5\u5916",noStepBefore:"Step \u304C\u307E\u3060\u3042\u308A\u307E\u305B\u3093\u3002Prototype \u306F ",noStepAfter:" \u306E\u610F\u5473\u69CB\u9020\u3092\u6301\u3061\u30011 Step = \u30B7\u30CA\u30EA\u30AA\u306E 1 \u5834\u9762\uFF08\u30E6\u30FC\u30B6\u30FC\u304C\u3044\u308B\u753B\u9762\u3068\u3001\u624B\u5143\u306B\u3042\u308B\u3082\u306E\uFF09\u3067\u3059\u3002base JSON \u306B Step \u3092\u8FFD\u52A0\u3059\u308B\u3068\u3001\u3053\u3053\u306B\u305D\u306E\u753B\u9762\u304C\u73FE\u308C\u307E\u3059\u3002",noScreens:"\u3053\u306E\u30D7\u30ED\u30C0\u30AF\u30C8\u306B\u306F\u307E\u3060\u753B\u9762\u304C\u3042\u308A\u307E\u305B\u3093\u3002base JSON \u306E apps[].screens \u306B\u30A2\u30D7\u30EA\u3068\u753B\u9762\u3092\u5BA3\u8A00\u3059\u308B\u3068\u3001\u3053\u3053\u306B\u73FE\u308C\u307E\u3059\u3002",noPreviewMetadata:"preview metadata \u304C\u3042\u308A\u307E\u305B\u3093 \u2014 \u8FFD\u52A0\u306F Agent \u306B\u4F9D\u983C\u3057\u3066\u304F\u3060\u3055\u3044",storyWithoutSteps:"\u3053\u306E UserStory \u306B\u306F\u307E\u3060 Step \u304C\u306A\u304F\u3001\u898B\u305B\u308B\u753B\u9762\u304C\u3042\u308A\u307E\u305B\u3093\u3002+ Step \u3067\u8FFD\u52A0\u3059\u308B\u304B\u3001Agent \u306B\u30D7\u30ED\u30C8\u30BF\u30A4\u30D7\u3092\u4F9D\u983C\u3057\u3066\u304F\u3060\u3055\u3044\u3002",pageActor:e=>`\u5229\u7528\u8005: ${e}`,maximize:"\u6700\u5927\u5316",restore:"\u5143\u306E\u30B5\u30A4\u30BA\u306B\u623B\u3059",maximizeHint:"\u30D7\u30EC\u30D3\u30E5\u30FC\u3060\u3051\u3092\u30BF\u30D6\u3044\u3063\u3071\u3044\u306B\u8868\u793A \xB7 Esc \u3067\u623B\u308B",situation:"\u72B6\u6CC1",uiComment:"UI \u306B\u30B3\u30E1\u30F3\u30C8",uiCommentHint:"\u30D7\u30EC\u30D3\u30E5\u30FC\u306E\u8981\u7D20\u3092\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u30B3\u30E1\u30F3\u30C8 \xB7 Esc \u3067\u7D42\u4E86",uiCommentPin:(e,t)=>`\u30B3\u30E1\u30F3\u30C8 ${e}: ${t}`,mailFrom:"\u5DEE\u51FA\u4EBA",mailTo:"\u5B9B\u5148",mailCc:"Cc",mailDate:"\u65E5\u6642",demo:"\u30C7\u30E2",demoHint:"\u307B\u304B\u306B\u4F55\u3082\u51FA\u3055\u305A\u3001\u30BF\u30D6\u3044\u3063\u3071\u3044\u306E\u30D6\u30E9\u30A6\u30B6\u3067\u30A2\u30D7\u30EA\u3092\u89E6\u308B \xB7 Esc \u3067\u7D42\u4E86",exitDemo:"\u30C7\u30E2\u3092\u7D42\u4E86",browserBack:"\u623B\u308B",browserForward:"\u9032\u3080",browserReload:"\u518D\u8AAD\u307F\u8FBC\u307F",browserAddress:"\u30A2\u30C9\u30EC\u30B9",browserTabs:"\u30BF\u30D6",newTab:"\u65B0\u3057\u3044\u30BF\u30D6",closeTab:"\u30BF\u30D6\u3092\u9589\u3058\u308B",browserProfile:e=>`\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB: ${e}`,browserGuest:"\u30B2\u30B9\u30C8",newTabShortcuts:"\u3053\u306E\u30A2\u30D7\u30EA\u306E\u30DA\u30FC\u30B8",unreachableTitle:"\u3053\u306E\u30B5\u30A4\u30C8\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093",unreachableBody:"\u30D7\u30ED\u30C8\u30BF\u30A4\u30D7\u306B\u3053\u306E\u30A2\u30C9\u30EC\u30B9\u306E\u30DA\u30FC\u30B8\u306F\u3042\u308A\u307E\u305B\u3093\u3002",device:"\u30C7\u30D0\u30A4\u30B9",deviceHint:"\u30A2\u30D7\u30EA\u3092\u52D5\u304B\u3059\u753B\u9762\u306E\u5927\u304D\u3055\u3002\u53CE\u307E\u3089\u306A\u3044\u30DA\u30FC\u30B8\u306F\u5B9F\u6A5F\u3068\u540C\u3058\u304F\u753B\u9762\u306E\u4E2D\u3067\u30B9\u30AF\u30ED\u30FC\u30EB\u3059\u308B",deviceName:e=>mt[e]??mi[e]??e,deviceZoom:e=>`\u53CE\u307E\u308B\u3088\u3046 ${e}% \u3067\u8868\u793A`}}),yi=["scenario","app"],N="view",se=e=>e[N]==="app"?"app":"scenario",yt=e=>({[N]:e==="app"?"app":null}),ae=(e,t)=>e===void 0?`\u2192 "${t}"`:`"${e}" \u2192 "${t}"`,ki=e=>({SET_ACTIVITY_NAME:(t,r)=>({title:e.renameActivity,tone:"update",body:ae(L(r,t.target.id)?.name,y(f.SET_ACTIVITY_NAME,t).name)}),SET_ACTIVITY_DESCRIPTION:(t,r)=>({title:e.updateActivityDescription,tone:"update",body:Ne(L(r,t.target.id)?.description,y(f.SET_ACTIVITY_DESCRIPTION,t).description)}),SET_STORY_NAME:(t,r)=>({title:e.renameStory,tone:"update",body:ae($(r,t.target.id)?.story.name,y(f.SET_STORY_NAME,t).name)}),SET_STORY_DESCRIPTION:(t,r)=>({title:e.updateStoryDescription,tone:"update",body:Ne($(r,t.target.id)?.story.description,y(f.SET_STORY_DESCRIPTION,t).description)}),SET_STEP_NAME:(t,r)=>({title:e.renameStep,tone:"update",body:ae(k(r,t.target.id)?.step.name,y(f.SET_STEP_NAME,t).name)}),SET_STEP_DESCRIPTION:(t,r)=>({title:e.updateStepDescription,tone:"update",body:Ne(k(r,t.target.id)?.step.description,y(f.SET_STEP_DESCRIPTION,t).description)}),SET_PREVIEW_KIND:(t,r)=>({title:e.changePreviewKind,tone:"update",body:ae(A(r,t.target.id)?.preview.kind,y(f.SET_PREVIEW_KIND,t).kind)}),SET_PREVIEW_VIEWPORT:(t,r)=>({title:e.changePreviewViewport,tone:"update",body:ae(A(r,t.target.id)?.preview.viewport,y(f.SET_PREVIEW_VIEWPORT,t).viewport)}),SET_PREVIEW_LABEL:t=>({title:e.changePreviewLabel,tone:"update",body:`\u2192 "${y(f.SET_PREVIEW_LABEL,t).label}"`}),REORDER_ACTIVITY:t=>ze(e,e.activityGroup,y(f.REORDER_ACTIVITY,t).after),REORDER_STORY:t=>ze(e,e.storyGroup,y(f.REORDER_STORY,t).after),REORDER_STEP:t=>ze(e,e.stepGroup,y(f.REORDER_STEP,t).after),MOVE_STORY:(t,r)=>({title:e.moveStory,tone:"move",body:`\u2192 ${L(r,y(f.MOVE_STORY,t).toActivity)?.name??y(f.MOVE_STORY,t).toActivity}`}),MOVE_STEP:(t,r)=>({title:e.moveStep,tone:"move",body:`\u2192 ${$(r,y(f.MOVE_STEP,t).toStory)?.story.name??y(f.MOVE_STEP,t).toStory}`}),ADD_ACTIVITY:t=>we(e,e.activityGroup,y(f.ADD_ACTIVITY,t).name),ADD_STORY:t=>we(e,e.storyGroup,y(f.ADD_STORY,t).name),ADD_STEP:t=>we(e,e.stepGroup,y(f.ADD_STEP,t).name),ADD_PREVIEW:t=>we(e,e.previewGroup,y(f.ADD_PREVIEW,t).label??y(f.ADD_PREVIEW,t).id),DELETE_ACTIVITY:(t,r)=>be(e,L(r,t.target.id)?.name),DELETE_STORY:(t,r)=>be(e,$(r,t.target.id)?.story.name),DELETE_STEP:(t,r)=>be(e,k(r,t.target.id)?.step.name),DELETE_PREVIEW:(t,r)=>be(e,A(r,t.target.id)?.preview.label)}),Ne=(e,t)=>{const r=t.length>90?`${t.slice(0,90)}\u2026`:t;return e===void 0||e===""?`\u2192 "${r}"`:`"${xi(e)}" \u2192 "${r}"`},xi=e=>e.length>60?`${e.slice(0,60)}\u2026`:e,ze=(e,t,r)=>({title:e.reorderTitle(t),tone:"move",body:r===null?e.toFront:e.afterName(r)}),we=(e,t,r)=>({title:e.addTitle(t),tone:"create",body:`+ "${r}"`}),be=(e,t)=>({title:e.deleteTitle,tone:"delete",body:t===void 0?e.unknownTarget:`\u2212 "${t}"`}),kt=(e,t,r,i)=>{const n=ki(e),o=Object.hasOwn(n,t.type)?n[t.type]:void 0,s=o?o(t,i??r):{title:t.type,tone:"meta"};return{title:s.title,targetLabel:$t(e,r,t.target),tone:s.tone,...s.body===void 0?{}:{summary:s.body}}},xt=e=>`${e.type} ${U(e.target)} ${JSON.stringify(e.payload)}`,$t=(e,t,r)=>{switch(r.type){case"activity":{const i=L(t,r.id);return i?e.targetLabel(e.activityGroup,i.name):e.targetMissing(e.activityGroup,r.id)}case"story":{const i=$(t,r.id)?.story;return i?e.targetLabel(e.storyGroup,i.name):e.targetMissing(e.storyGroup,r.id)}case"step":{const i=k(t,r.id)?.step;return i?e.targetLabel(e.stepGroup,i.name):e.targetMissing(e.stepGroup,r.id)}case"screen":{const i=M(t,r.id)?.screen;return i?e.targetLabel(e.screenGroup,i.title):e.targetMissing(e.screenGroup,r.id)}case"preview":{const i=A(t,r.id)?.preview;return i?e.targetLabel(e.previewGroup,i.label??i.id):e.targetMissing(e.previewGroup,r.id)}case"page":return e.targetLabel(e.pageGroup,Ue(t));case re:{const i=Ce(r.id),n=i?A(t,i.previewId)?.preview:void 0;return i&&n?e.targetLabel(e.uiGroup,Et(n,i)):e.targetMissing(e.uiGroup,r.id)}default:return e.targetLabel(r.type,r.id)}},Et=(e,t)=>{const r=t.text===void 0?t.selector:`"${t.text}"`;return`${e.label??e.id} \u203A ${r}`},St=(e,t)=>{const r=[];for(const i of e){if(i.target.type!==re)continue;const n=Ce(i.target.id);!n||!t.includes(n.previewId)||r.push({id:i.id,previewId:n.previewId,selector:n.selector,number:r.length+1,body:et(i)})}return r},Tt=(e,t)=>St(e,t).length,$i=/^[a-z][a-z0-9+.-]*:/i,Ei=e=>{const t=e.baseUrl?.trim(),r=Mr(e.title??"");return`${(t?t.startsWith("http")?t:`https://${t}`:`https://${r==="item"?"page":r}.example.com`).replace(/\/+$/,"")}/`},me=(e,t)=>{const r=Ei(e);if(!t.url)return`${r}${t.id}`;if($i.test(t.url))return t.url;try{return decodeURI(new URL(t.url,r).href)}catch{return t.url}},Si=e=>{switch(e.type){case"activity":return{[N]:null,activity:e.id};case"story":return{[N]:null,activity:null,story:e.id};case"step":return{[N]:null,activity:null,story:null,step:e.id};case"screen":return{screen:e.id};default:return null}},At=(e,t)=>{const r=e.kind==="screen"?[{type:"screen",id:e.screen.id}]:[{type:"activity",id:e.activity.id},{type:"story",id:D(e.activity.id,e.story.id)},...e.kind==="step"?[{type:"step",id:ie(e)}]:[]];for(const i of t?.panes??[])i.kind==="screen"&&r.push({type:"screen",id:i.screen.screen.id});return[...new Set(r.map(U))].join(" ")},Ve=",",It=e=>e.preview?.split(Ve)??[],Ti=(e,t)=>e.kind===t.kind&&e.viewport===t.viewport,Pt=(e,t,r)=>{const i=t.find(o=>r.includes(o.id));if(i)return i;const n=r.flatMap(o=>A(e,o)?.preview??[]);return t.find(o=>n.some(s=>Ti(o,s)))??t[0]},_t=(e,t,r,i)=>{const n=t.screen.previews,o=r===void 0?Pt(e,n,It(i)):n.find(a=>a.id===r);if(!o)return;const s=r===void 0&&n.length>1;return{kind:"screen",screen:t,preview:o,pinned:r!==void 0,tabs:s?n:[]}},Rt=e=>({layout:e.length>1?"side-by-side":"single",panes:e,shown:e.map(t=>t.preview)}),Dt=(e,t,r)=>t.panes.flatMap(i=>{if(!K(i))return[{kind:"material",preview:i.material}];const n=M(e,i.screen),o=n&&_t(e,n,i.preview,r);return o?[o]:[]}),Ye=(e,t,r)=>{if(t.kind==="screen"){const i=_t(e,t,void 0,r);return Rt(i?[i]:[])}return Rt(Dt(e,t.step,r))},Ai=(e,t)=>e.panes.flatMap(r=>r.kind!=="screen"||r.tabs.length===0?[]:[r.tabs.some(i=>i.id===t)?t:r.preview.id]).join(Ve),Ii=(e,t)=>[...X(t),...he(e,t).flatMap(r=>r.screen.previews)],Pi=["activity","story","step","screen","preview"],_i=(e,t,r)=>{switch(t){case"activity":return L(e,r)!==void 0;case"story":return $(e,r)!==void 0||e.activities.some(i=>i.stories.some(n=>n.id===r));case"step":return k(e,r)!==void 0||B(e).some(i=>i.step.id===r);case"screen":return M(e,r)!==void 0;case"preview":return A(e,r)!==void 0;default:return!1}},Ri=(e,t)=>{let r;if(t.navigate!==null)r=t.navigate.includes("=")?t.navigate:`step=${t.navigate}`;else{const o=t.href?.trim()??"";if(o===""||o==="#"||o.toLowerCase().startsWith("javascript:"))return"no-destination";if(!o.startsWith("#"))return null;r=o}const i=Ae(r),n=Pi.filter(o=>i[o]!==void 0);return n.length===0?t.navigate===null?null:"unknown-target":n.every(o=>_i(e,o,i[o]??""))?null:"unknown-target"},Di=(e,t)=>{const r=t.mail??{},i=[{label:e.mailFrom,value:r.from},{label:e.mailTo,value:r.to},{label:e.mailCc,value:r.cc},{label:e.mailDate,value:r.date}].flatMap(s=>s.value===void 0||s.value.trim()===""?[]:[{label:s.label,value:s.value}]),n=r.from?.replace(/<[^>]*>/g,"").replace(/["']/g,"").trim()||r.from?.trim(),o=n?Array.from(n)[0]?.toUpperCase():void 0;return{...r.subject===void 0||r.subject.trim()===""?{}:{subject:r.subject},...n?{sender:n}:{},...o===void 0?{}:{initial:o},rows:i}},Ct=(e,t)=>{const r=[];for(const i of t.activities){r.push({value:U({type:"activity",id:i.id}),label:i.name,group:e.activityGroup});for(const n of i.stories){r.push({value:U({type:"story",id:D(i.id,n.id)}),label:`${i.name} \u203A ${n.name}`,group:e.storyGroup});for(const o of n.steps)r.push({value:U({type:"step",id:ve(i,n,o)}),label:`${n.name} \u203A ${o.name}`,group:e.stepGroup})}}for(const{app:i,screen:n}of W(t))r.push({value:U({type:"screen",id:n.id}),label:`${i.name} \u203A ${n.title}`,group:e.screenGroup});return r},Ci=(e,t,r)=>{const i=Z(t,r);if(i?.kind==="screen"){const{screen:n}=i;return{value:U({type:"screen",id:n.id}),label:n.title,group:e.screenGroup}}return i?.kind!=="step"?null:{value:U({type:"step",id:ie(i)}),label:i.step.name,group:e.stepGroup}},Z=(e,t)=>{if(se(t)==="app"){const o=M(e,t.screen);return o?{kind:"screen",...o}:void 0}const r=k(e,t.step);if(r)return{kind:"step",...r};const i=L(e,t.activity),n=i?.stories.find(o=>o.id===t.story||D(i.id,o.id)===t.story);return i&&n?{kind:"story",activity:i,story:n}:void 0},Ot=(e,t)=>{const r=(p,l)=>l===void 0?{title:p}:{actor:l,title:p};if(t.kind==="screen")return r(t.screen.title,t.app.actor);const{activity:i,story:n,step:o}=t,s=he(e,o),a=s.length===1?s[0]:void 0;return r(a?.screen.title??o.name,o.actor??n.actor??i.actor??a?.app.actor)},Oi=(e,t)=>{const r=t.actor??e.actor;return r===void 0?{title:t.name}:{actor:r,title:t.name}},Ue=e=>e.title??"UX Prototype",Mt=(e,t)=>(t?e.preview=t:delete e.preview,e),Mi=(e,t,r)=>{if(!t)return;const i=Dt(e,t,r).flatMap(n=>n.kind==="screen"&&!n.pinned?[n.preview.id]:[]);return i.length===0?void 0:i.join(Ve)},Lt=(e,t)=>{const r=()=>{if(t.step===void 0&&t.story===void 0)return;const o=Nt(e,{...t,[N]:""}),s=k(e,o.step);return s&&he(e,s.step)[0]},i=M(e,t.screen)??r()??W(e)[0],n={...t,[N]:"app"};for(const o of["activity","story","step"])delete n[o];return i?n.screen=i.screen.id:delete n.screen,Mt(n,i&&Pt(e,i.screen.previews,It(t))?.id)},Li=(e,t,r)=>{const i=s=>fi(s.step,t);if(r&&i(r))return r;const n=r?.story.steps??[],o=s=>{const a=n[s];return r&&a?{...r,step:a,stepIndex:s}:void 0};for(let s=(r?.stepIndex??0)+1;s<n.length;s+=1){const a=o(s);if(a&&i(a))return a}for(let s=(r?.stepIndex??0)-1;s>=0;s-=1){const a=o(s);if(a&&i(a))return a}return B(e).find(i)},Nt=(e,t)=>{const r=L(e,t.activity),i=t.story,n=r?.stories.find(V=>V.id===i||D(r.id,V.id)===i),o=n&&r?{activity:r,story:n}:$(e,i),s=t.step,p=(o&&s?k(e,`${D(o.activity.id,o.story.id)}.${s}`):void 0)??k(e,s),l=t.screen,w=l===void 0?void 0:Li(e,l,p);if(l!==void 0&&!w&&M(e,l))return Lt(e,{...t,[N]:"app"});const h=w??p,v=h?.activity??o?.activity??r??e.activities[0],I=h?.story??(o&&o.activity===v?o.story:void 0)??v?.stories[0],P=h?.step??I?.steps[0],S={...t};return delete S.screen,v?S.activity=v.id:delete S.activity,I&&v?S.story=$(e,I.id)?I.id:D(v.id,I.id):delete S.story,P&&I&&v?S.step=k(e,P.id)?P.id:ve(v,I,P):delete S.step,delete S[N],Mt(S,Mi(e,P,t))},Ni=["activity","story","step","screen"],ye=(e,t)=>se(t)==="app"?Lt(e,t):Nt(e,t),zi=(e,t)=>{const r=t.screen.previews.find(o=>o.kind==="browser");if(!r)return;let i;try{i=new URL(me(e,r),"https://page.example.com")}catch{return}const n=i.pathname.split("/").filter(o=>o!=="").map(o=>{try{return decodeURIComponent(o)}catch{return o}});return{origin:i.origin,segments:n}},zt=()=>({screens:[],children:new Map}),We=(e,t,r)=>{const[i,...n]=e.children.entries();if(e.screens.length===0&&i&&n.length===0&&r!=="/"){const[o,s]=i;return We(s,`${t}/${o}`,`${r}/${o}`)}return{segment:t,path:r,screens:e.screens,children:[...e.children.entries()].map(([o,s])=>We(s,`/${o}`,`${r==="/"?"":r}/${o}`))}},Vi=e=>{const t=new Map;for(const[r,i]of e){const n=t.get(i.origin)??zt();t.set(i.origin,n);let o=n;for(const s of i.segments){const a=o.children.get(s)??zt();o.children.set(s,a),o=a}o.screens.push(r)}return[...t.entries()].map(([r,i])=>({origin:r,root:We(i,"/","/")}))},Yi=(e,t)=>{const r=t.screens.map(o=>({app:t,screen:o})),i=[],n=[];for(const o of r){const s=zi(e,o);s?i.push([o,s]):n.push(o)}return{app:t,screens:r,trees:Vi(i),others:n}},Vt=e=>e.apps.map(t=>Yi(e,t)).filter(t=>t.screens.length>0),Yt=(e,t)=>t?.kind!=="screen"?e[0]:e.find(r=>r.app.id===t.app.id)??e[0],Ui=(e,t)=>{switch(t.type){case"activity":return L(e,t.id)!==void 0;case"story":return $(e,t.id)!==void 0;case"step":return k(e,t.id)!==void 0;case"screen":return M(e,t.id)!==void 0;case"preview":return A(e,t.id)!==void 0;case"page":return!0;case re:{const r=Ce(t.id);return r!==void 0&&A(e,r.previewId)!==void 0}default:return!1}},Ut=e=>{const t=fe(e);return{name:"prototype",label:"UX Prototype",parseBase:ht,emptyBase:vt,actions:f,apply:wt,hasTarget:Ui,canonicalTarget:(r,i)=>{if(i.type==="step"){const n=k(r,i.id);return n?{...i,id:ie(n)}:i}if(i.type==="story"){const n=$(r,i.id);return n?{...i,id:D(n.activity.id,n.story.id)}:i}if(i.type==="preview"){const n=A(r,i.id);return n?{...i,id:n.preview.id}:i}return i},describe:(r,i,n)=>kt(t,r,i,n),serialize:xt,resolveNavigation:ye,navigationHierarchy:Ni,navigationFor:(r,i)=>Si(i),commentTargets:(r,i)=>Ct(t,r),currentTarget:(r,i)=>Ci(t,r,i),title:Ue}},Wi=(e,t)=>{const r=t.flatMap(i=>{const n=Math.max(i.left,e.left)-e.left,o=Math.max(i.top,e.top)-e.top,s=Math.min(i.right,e.right)-e.left-n,a=Math.min(i.bottom,e.bottom)-e.top-o;return s>0&&a>0?[`M${n} ${o}h${s}v${a}h-${s}Z`]:[]});return r.length===0?"none":`path(evenodd, 'M0 0H${e.width}V${e.height}H0Z ${r.join(" ")}')`},ke="data-dpk-modal",Bi=e=>{try{return e.matches(":modal")}catch{return!1}},Wt=e=>{e.setAttribute(ke,""),e.open||e.show()},Bt=e=>{Object.hasOwn(e,"showModal")||Object.defineProperty(e,"showModal",{configurable:!0,value:()=>Wt(e)})},Ht=(e,t)=>{if(!Bi(t))return;const r=i=>{i.target===t&&(i.stopImmediatePropagation(),e.removeEventListener("close",r,!0))};e.addEventListener("close",r,!0),t.close(),Wt(t)},Hi='a, button, input, select, textarea, label, summary, [role="button"], [role="link"], [role="tab"]',Gt=/^-?[A-Za-z_][\w-]*$/,Ft=40,Gi=(e,t)=>{const r=e.closest(Hi);return r!==null&&r!==t&&t.contains(r)?r:e},xe=e=>{const t=e.replace(/\s+/g," ").trim();if(t==="")return;const r=Array.from(t);return r.length>Ft?`${r.slice(0,Ft).join("")}\u2026`:t},Fi=e=>{const t=e.getAttribute("aria-label")??e.getAttribute("title");if(t)return xe(t);const r=e.tagName.toLowerCase();return xe(r==="input"||r==="textarea"||r==="select"?e.getAttribute("placeholder")??e.getAttribute("name")??"":r==="img"?e.getAttribute("alt")??"":e.textContent??"")},ji=e=>{const t=e.getAttribute("id");if(t&&Gt.test(t))return`#${t}`;const r=e.tagName.toLowerCase(),i=Array.from(e.classList).filter(a=>Gt.test(a)).slice(0,2).map(a=>`.${a}`).join(""),n=e.parentElement,o=n?Array.from(n.children).filter(a=>a.tagName===e.tagName):[],s=o.length>1?`:nth-of-type(${o.indexOf(e)+1})`:"";return`${r}${i}${s}`},qi=(e,t,r)=>{try{const i=e.querySelectorAll(t);return i.length===1&&i[0]===r}catch{return!1}},Ki=(e,t)=>{const r=[];let i=e;for(;i!==null&&i!==t;){const o=ji(i);if(r.unshift(o),o.startsWith("#")||qi(t,r.join(" > "),e))break;i=i.parentElement}const n=Fi(e);return{selector:r.length===0?":scope":r.join(" > "),tag:e.tagName.toLowerCase(),...n===void 0?{}:{text:n}}},Xi=(e,t)=>{if(t===":scope")return e;try{return e.querySelector(t)}catch{return null}},Zi=["screen","preview"],de=e=>JSON.stringify(Zi.map(t=>e[t]??null)),jt=(e,t)=>e?.kind==="page"&&de(e.page)===t,$e=e=>`tab-${e}`,Ji=e=>({tabs:[{id:$e(1),history:[{kind:"page",page:e}],index:0}],activeId:$e(1),seen:de(e),nextId:2}),Qi={id:"",history:[],index:0},J=e=>e.tabs.find(t=>t.id===e.activeId)??e.tabs[0]??Qi,pe=e=>{const t=J(e);return t.history[t.index]},en=e=>J(e).index>0,tn=e=>{const t=J(e);return t.index<t.history.length-1},qt=(e,t)=>({...e,tabs:e.tabs.map(r=>r.id===e.activeId?t(r):r)}),Be=(e,t)=>qt(e,r=>({...r,history:[...r.history.slice(0,r.index+1),t],index:r.index+1})),Ee=e=>{const t=pe(e);return t?.kind==="page"?{...e,seen:de(t.page)}:e},Kt=(e,t)=>{const r=J(e),i=r.index+t;return i<0||i>=r.history.length?e:Ee(qt(e,n=>({...n,index:i})))},Xt=(e,t,r)=>{const i=$e(e.nextId),n=e.tabs.findIndex(o=>o.id===e.activeId)+1;return Ee({...e,tabs:[...e.tabs.slice(0,n),{id:i,history:[t],index:0},...e.tabs.slice(n)],activeId:r?e.activeId:i,nextId:e.nextId+1})},rn=(e,t)=>{const r=e.tabs.findIndex(o=>o.id===t);if(r<0)return e;if(e.tabs.length===1){const o=$e(e.nextId);return{...e,tabs:[{id:o,history:[{kind:"new-tab"}],index:0}],activeId:o,nextId:e.nextId+1}}const i=e.tabs.filter(o=>o.id!==t);if(t!==e.activeId)return{...e,tabs:i};const n=i[r]??i[r-1];return Ee({...e,tabs:i,activeId:n?.id??e.activeId})},nn=(e,t)=>{const r=t===null?null:de(t);if(r===e.seen)return e;const i={...e,seen:r};return t===null||r===null||jt(pe(e),r)?i:Be(i,{kind:"page",page:t})},on=(e,t)=>{const r=de(t);return jt(pe(e),r)?e.seen===r?e:{...e,seen:r}:Be({...e,seen:r},{kind:"page",page:t})},Zt=(e,t)=>{switch(t.kind){case"observe":return nn(e,t.page);case"visit":return on(e,t.page);case"back":return Kt(e,-1);case"forward":return Kt(e,1);case"open-tab":return Xt(e,t.entry,t.background);case"new-tab":return Xt(e,{kind:"new-tab"},!1);case"unreachable":return Be(e,{kind:"unreachable",url:t.url});case"activate":return e.tabs.some(r=>r.id===t.id)&&t.id!==e.activeId?Ee({...e,activeId:t.id}):e;case"close-tab":return rn(e,t.id);default:return e}},Jt=(e,t)=>{const r=ye(e,t),i=Z(e,r);if(i?.kind!=="screen")return null;const[n]=Ye(e,i,r).shown;return n?.kind!=="browser"?null:{screen:i.screen.id,preview:n.id}},Se=(e,t)=>{const r=Z(e,ye(e,{[N]:"app",...t}));return r?.kind==="screen"?r:void 0},Qt=(e,t)=>{const r=e.trim();if(r==="")return null;try{return r.startsWith("/")?new URL(r,t):new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(r)?r:`https://${r}`)}catch{return null}},er=e=>`${e.origin}${e.pathname.replace(/\/+$/,"")}`,sn=(e,t,r)=>{const i=Qt(t,r);if(i===null)return null;const n=er(i);for(const{screen:o}of W(e))for(const s of o.previews){if(s.kind!=="browser")continue;const a=Qt(me(e,s),r);if(a!==null&&er(a)===n)return{screen:o.id,preview:s.id}}return null},tr=e=>{try{return new URL(e).host||e}catch{return e}},an=(e,t,r)=>t===void 0||t.kind==="new-tab"?r.newTab:t.kind==="unreachable"?tr(t.url):Se(e,t.page)?.screen.title??r.newTab,rr=(e,t)=>{if(t===void 0||t.kind==="new-tab")return"";if(t.kind==="unreachable")return t.url;const r=Se(e,t.page)?.screen.previews.find(i=>i.id===t.page.preview);return r===void 0?"":me(e,r)},ir=e=>{const t=J(e);for(let r=t.index;r>=0;r-=1){const i=t.history[r];if(i?.kind==="page")return i.page}for(const r of e.tabs){const i=r.history[r.index];if(i?.kind==="page")return i.page}},dn=(e,t)=>t===void 0?void 0:Se(e,t)?.app.actor,nr=(e,t,r,i=null)=>{const n=J(t),o=n.history[n.index],s=dn(e,ir(t)??i??void 0);return{tabs:t.tabs.map(a=>({id:a.id,title:an(e,a.history[a.index],r),url:rr(e,a.history[a.index]),active:a.id===n.id})),entry:o,url:rr(e,o),canBack:en(t),canForward:tn(t),...s===void 0?{}:{profile:s}}},pn=e=>ir(e)??null,ln=(e,t)=>{const r=t===null?void 0:Se(e,t),i=Yt(Vt(e),r),n=[],o=(s,a)=>{for(const{screen:p}of a.screens){const l=p.previews.find(w=>w.kind==="browser");l!==void 0&&n.push({title:p.title,url:`${s}${a.path==="/"?"":a.path}`,page:{screen:p.id,preview:l.id}})}for(const p of a.children)o(s,p)};for(const s of i?.trees??[])o(tr(s.origin),s.root);return n},T=(e,t,r,i)=>({id:t,deviceClass:e,width:r,height:i}),or=[T("phone","iphone-se",375,667),T("phone","iphone-16",393,852),T("phone","iphone-16-pro-max",440,956),T("phone","pixel-7",412,915),T("phone","galaxy-s24",360,780),T("tablet","ipad-mini",744,1133),T("tablet","ipad-air-11",820,1180),T("tablet","ipad-pro-11",834,1194),T("tablet","ipad-pro-13",1024,1366),T("desktop","laptop-13",1280,800),T("desktop","laptop-15",1440,900),T("desktop","full-hd",1920,1080),T("desktop","monitor-27",2560,1440),T("desktop","ultrawide",3440,1440)],cn={phone:T("phone","iphone-16",393,852),tablet:T("tablet","ipad-pro-11",834,1194),desktop:T("desktop","laptop-13",1280,800)},sr=e=>e==="mobile"?"phone":e==="tablet"?"tablet":"desktop",un=e=>e!=="plain",ar=e=>or.filter(t=>t.deviceClass===e),hn=(e,t)=>{const r=sr(e),i=t[r];return ar(r).find(n=>n.id===i)??cn[r]},vn=(e,t)=>{const r=or.find(i=>i.id===t);return r===void 0||e[r.deviceClass]===t?e:{...e,[r.deviceClass]:t}},gn=(e,t)=>`${e.deviceName(t.id)} \xB7 ${t.width}\xD7${t.height}`,fn=(e,t)=>{const r=[1,t.width/e.width];t.height!==void 0&&r.push(t.height/e.height);const i=Math.min(...r);return!Number.isFinite(i)||i<=0?1:Math.max(.1,Math.floor(i*100)/100)},dr=(e,t)=>{const{state:r,navigation:i}=e,n=Z(r,i),o=se(i);return d`
1
+ import{aj as x,aO as Ir,ae as C,aA as R,aB as g,ah as u,af as z,ai as ce,ad as Pr,aP as Qe,aQ as _r,ag as Y,ak as E,as as Rr,p as w,au as m,v as ue,az as te,P as Dr,e as Cr,a0 as Or,h as et,N as Ae,V as U,U as Mr,R as y,a4 as d,a3 as c,aR as Ie,aS as Pe,aF as _e,a5 as Lr,z as Re,aE as tt,l as Nr,A as rt,aT as O,aU as zr,aV as Vr,J as it,aW as Yr,ac as Ur,ab as Wr,a2 as Br,T as nt,a1 as Hr,aX as Gr,a9 as Fr,C as jr,aY as qr}from"./shared-CBRj9Yll.js";import{p as Kr,r as Xr,c as Zr}from"./shared-BJvnqK51.js";import{i as ot}from"./shared-CLabLKYD.js";const Jr=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}],["path",{d:"M2 12h20"}]],Qr=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}]],ei=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21"}]],ti=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"}]],ri=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}]],ii=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2"}],["path",{d:"M12 18h.01"}]],ni=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18"}]],oi=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}],["circle",{cx:"12",cy:"7",r:"4"}]],st=["browser","native","mail","plain"],at=["mobile","tablet","desktop","fluid"],K=e=>"screen"in e,si=C({from:g(u()),to:g(u()),cc:g(u()),subject:g(u()),date:g(u())}),ai={id:R,kind:z(ce(st),"browser"),viewport:z(ce(at),"fluid"),label:g(u()),url:g(u()),mail:g(si)},De=x(C(ai),Ir(e=>e.mail===void 0||e.kind==="mail",'a preview `mail` envelope needs `"kind": "mail"`')),dt=Rr([C({screen:R,preview:g(R)}),C({material:De})]),di=C({id:R,name:x(u(),E(1)),description:g(u()),actor:g(x(u(),E(1))),situation:g(x(u(),E(1))),panes:z(Y(dt),[])}),pi=C({id:R,name:x(u(),E(1)),description:g(u()),actor:g(x(u(),E(1))),steps:z(Y(di),[])}),li=C({id:R,name:x(u(),E(1)),description:g(u()),actor:g(x(u(),E(1))),stories:z(Y(pi),[])}),ci=C({id:R,title:x(u(),E(1)),description:g(u()),previews:z(Y(De),[])}),ui=C({id:R,name:x(u(),E(1)),description:g(u()),actor:g(x(u(),E(1))),screens:z(Y(ci),[])}),pt=C({title:g(u()),baseUrl:g(u()),apps:z(Y(ui),[]),activities:z(Y(li),[])}),lt=e=>e.flatMap(t=>K(t)?[]:[t.material]),hi=e=>{const t=new Set,r=s=>{for(const a of s){if(t.has(a.id))return`duplicate preview id "${a.id}": preview ids are global, they name a light DOM slot`;t.add(a.id)}return null},i=new Set,n=new Set;for(const s of e.apps){if(i.has(s.id))return`duplicate app id "${s.id}"`;i.add(s.id);for(const a of s.screens){if(n.has(a.id))return`duplicate screen id "${a.id}": screen ids are global`;n.add(a.id);const p=r(a.previews);if(p!==null)return p}}const o=new Set;for(const s of e.activities){if(o.has(s.id))return`duplicate activity id "${s.id}"`;o.add(s.id);const a=new Set;for(const p of s.stories){if(a.has(p.id))return`duplicate story id "${p.id}" in activity "${s.id}"`;a.add(p.id);const l=new Set;for(const b of p.steps){if(l.has(b.id))return`duplicate step id "${b.id}" in story "${p.id}"`;l.add(b.id);const h=r(lt(b.panes));if(h!==null)return h}}}return null},ct=(e,t)=>{const r=new Map;for(const i of t.panes){if(!K(i))continue;const n=e(i.screen);if(n===void 0)return`unknown screen "${i.screen}" on step "${t.id}": declare it under \`apps[].screens\``;if(i.preview!==void 0&&!n.includes(i.preview))return`preview "${i.preview}" on step "${t.id}" is not a rendition of screen "${i.screen}"`;const o=r.get(i.screen)??[];if(o.length>0&&(i.preview===void 0||o.includes(i.preview)||o.includes(void 0)))return`screen "${i.screen}" is shown twice on step "${t.id}": give each pane a different \`preview\``;r.set(i.screen,[...o,i.preview])}return null},vi=e=>{const t=new Map(e.apps.flatMap(r=>r.screens.map(i=>[i.id,i.previews.map(n=>n.id)])));for(const r of e.activities.flatMap(i=>i.stories.flatMap(n=>n.steps))){const i=ct(n=>t.get(n),r);if(i!==null)return i}return null},gi=(e,t)=>ct(r=>M(e,r)?.screen.previews.map(i=>i.id),t),re="ui",ut=e=>{const t=e.text?.replaceAll('"',"'");return`${e.previewId}/${e.selector}${t===void 0?"":` "${t}"`}`},Ce=e=>{const t=e.indexOf("/");if(t<=0)return;const r=e.slice(0,t);if(!_r(R,r))return;const i=e.slice(t+1),n=/ "([^"]*)"$/.exec(i),o=(n?i.slice(0,n.index):i).trim();if(o!=="")return n?.[1]===void 0?{previewId:r,selector:o}:{previewId:r,selector:o,text:n[1]}},ht=e=>{const t=Pr(pt,e),r=hi(t)??vi(t);if(r!==null)throw new Error(r);return t},vt=()=>({apps:[],activities:[]}),W=e=>e.apps.flatMap(t=>t.screens.map(r=>({app:t,screen:r}))),M=(e,t)=>{if(t!==void 0)return W(e).find(r=>r.screen.id===t)},he=(e,t)=>t.panes.flatMap(r=>{const i=K(r)?M(e,r.screen):void 0;return i?[i]:[]}),X=e=>lt(e.panes),fi=(e,t)=>e.panes.some(r=>K(r)&&r.screen===t),L=(e,t)=>{if(t!==void 0)return e.activities.find(r=>r.id===t)},D=(e,t)=>`${e}.${t}`,$=(e,t)=>{if(t===void 0)return;const r=Qe(t,2);if(r){const[n,o]=r;if(n===void 0||o===void 0)return;const s=e.activities.find(p=>p.id===n),a=s?.stories.find(p=>p.id===o);return s&&a?{activity:s,story:a}:void 0}if(t.includes("."))return;const i=e.activities.flatMap(n=>n.stories.filter(o=>o.id===t).map(o=>({activity:n,story:o})));return i.length===1?i[0]:void 0},gt=e=>{const t=e.lastIndexOf(".");return t>=0?e.slice(t+1):e},ie=e=>`${e.activity.id}.${e.story.id}.${e.step.id}`,ve=(e,t,r)=>`${e.id}.${t.id}.${r.id}`,k=(e,t)=>{if(t===void 0)return;const r=Qe(t,3);if(r){const[n,o,s]=r;if(n===void 0||o===void 0||s===void 0)return;const a=e.activities.find(h=>h.id===n),p=a?.stories.find(h=>h.id===o),l=p?p.steps.findIndex(h=>h.id===s):-1,b=p&&l>=0?p.steps[l]:void 0;return a&&p&&b?{activity:a,story:p,step:b,stepIndex:l}:void 0}if(t.includes("."))return;const i=B(e).filter(n=>n.step.id===t);return i.length===1?i[0]:void 0},A=(e,t)=>{if(t!==void 0){for(const r of W(e)){const i=r.screen.previews.find(n=>n.id===t);if(i)return{owner:{kind:"screen",...r},preview:i}}for(const r of B(e)){const i=X(r.step).find(n=>n.id===t);if(i)return{owner:{kind:"step",...r},preview:i}}}},B=e=>e.activities.flatMap(t=>t.stories.flatMap(r=>r.steps.map((i,n)=>({activity:t,story:r,step:i,stepIndex:n})))),ft=e=>B(e).map(t=>t.step.id),f={SET_ACTIVITY_NAME:w("SET_ACTIVITY_NAME","activity",m({name:x(u(),E(1))})),SET_ACTIVITY_DESCRIPTION:w("SET_ACTIVITY_DESCRIPTION","activity",m({description:u()})),SET_STORY_NAME:w("SET_STORY_NAME","story",m({name:x(u(),E(1))})),SET_STORY_DESCRIPTION:w("SET_STORY_DESCRIPTION","story",m({description:u()})),SET_STEP_NAME:w("SET_STEP_NAME","step",m({name:x(u(),E(1))})),SET_STEP_DESCRIPTION:w("SET_STEP_DESCRIPTION","step",m({description:u()})),SET_PREVIEW_KIND:w("SET_PREVIEW_KIND","preview",m({kind:ce(st)})),SET_PREVIEW_VIEWPORT:w("SET_PREVIEW_VIEWPORT","preview",m({viewport:ce(at)})),SET_PREVIEW_LABEL:w("SET_PREVIEW_LABEL","preview",m({label:u()})),REORDER_ACTIVITY:w("REORDER_ACTIVITY","activity",m({after:te(u())}),{mode:"sequence"}),REORDER_STORY:w("REORDER_STORY","story",m({after:te(u())}),{mode:"sequence"}),REORDER_STEP:w("REORDER_STEP","step",m({after:te(u())}),{mode:"sequence"}),MOVE_STORY:w("MOVE_STORY","story",m({toActivity:x(u(),E(1)),after:te(u())}),{mode:"sequence"}),MOVE_STEP:w("MOVE_STEP","step",m({toStory:x(u(),E(1)),after:te(u())}),{mode:"sequence"}),ADD_ACTIVITY:w("ADD_ACTIVITY","page",m({id:R,name:x(u(),E(1)),description:g(u())}),{dedupeKey:ue}),ADD_STORY:w("ADD_STORY","activity",m({id:R,name:x(u(),E(1)),description:g(u())}),{dedupeKey:ue}),ADD_STEP:w("ADD_STEP","story",m({id:R,name:x(u(),E(1)),description:g(u()),panes:g(Y(dt))}),{dedupeKey:ue}),ADD_PREVIEW:w("ADD_PREVIEW","step",De,{dedupeKey:ue}),DELETE_ACTIVITY:w("DELETE_ACTIVITY","activity",m({})),DELETE_STORY:w("DELETE_STORY","story",m({})),DELETE_STEP:w("DELETE_STEP","step",m({})),DELETE_PREVIEW:w("DELETE_PREVIEW","preview",m({}))},ne={setActivityName:(e,t)=>({type:"SET_ACTIVITY_NAME",target:{type:"activity",id:e},payload:{name:t}}),setActivityDescription:(e,t)=>({type:"SET_ACTIVITY_DESCRIPTION",target:{type:"activity",id:e},payload:{description:t}}),setStoryName:(e,t)=>({type:"SET_STORY_NAME",target:{type:"story",id:e},payload:{name:t}}),setStoryDescription:(e,t)=>({type:"SET_STORY_DESCRIPTION",target:{type:"story",id:e},payload:{description:t}}),setStepName:(e,t)=>({type:"SET_STEP_NAME",target:{type:"step",id:e},payload:{name:t}}),setStepDescription:(e,t)=>({type:"SET_STEP_DESCRIPTION",target:{type:"step",id:e},payload:{description:t}}),setPreviewViewport:(e,t)=>({type:"SET_PREVIEW_VIEWPORT",target:{type:"preview",id:e},payload:{viewport:t}}),setPreviewKind:(e,t)=>({type:"SET_PREVIEW_KIND",target:{type:"preview",id:e},payload:{kind:t}}),setPreviewLabel:(e,t)=>({type:"SET_PREVIEW_LABEL",target:{type:"preview",id:e},payload:{label:t}}),reorderActivity:(e,t)=>({type:"REORDER_ACTIVITY",target:{type:"activity",id:e},payload:{after:t}}),reorderStory:(e,t)=>({type:"REORDER_STORY",target:{type:"story",id:e},payload:{after:t}}),reorderStep:(e,t)=>({type:"REORDER_STEP",target:{type:"step",id:e},payload:{after:t}}),moveStep:(e,t,r)=>({type:"MOVE_STEP",target:{type:"step",id:e},payload:{toStory:t,after:r}}),moveStory:(e,t,r)=>({type:"MOVE_STORY",target:{type:"story",id:e},payload:{toActivity:t,after:r}}),addActivity:(e,t,r)=>({type:"ADD_ACTIVITY",target:{type:"page",id:"prototype"},payload:{id:e,name:t,...r===void 0?{}:{description:r}}}),addStory:(e,t,r,i)=>({type:"ADD_STORY",target:{type:"activity",id:e},payload:{id:t,name:r,...i===void 0?{}:{description:i}}}),addStep:(e,t,r,i)=>({type:"ADD_STEP",target:{type:"story",id:e},payload:{id:t,name:r,...i===void 0?{}:{panes:i}}}),addPreview:(e,t)=>({type:"ADD_PREVIEW",target:{type:"step",id:e},payload:{...t}}),deleteActivity:e=>({type:"DELETE_ACTIVITY",target:{type:"activity",id:e},payload:{}}),deleteStory:e=>({type:"DELETE_STORY",target:{type:"story",id:e},payload:{}}),deleteStep:e=>({type:"DELETE_STEP",target:{type:"step",id:e},payload:{}}),deletePreview:e=>({type:"DELETE_PREVIEW",target:{type:"preview",id:e},payload:{}})},bt=(e,t)=>{const r=Dr(f,t);if(r===null)return null;const i=r.target.id;switch(r.type){case"SET_ACTIVITY_NAME":return H(e,i,n=>({...n,name:r.payload.name}));case"SET_ACTIVITY_DESCRIPTION":return H(e,i,n=>({...n,description:r.payload.description}));case"SET_STORY_NAME":return G(e,i,n=>({...n,name:r.payload.name}));case"SET_STORY_DESCRIPTION":return G(e,i,n=>({...n,description:r.payload.description}));case"SET_STEP_NAME":return ge(e,i,n=>({...n,name:r.payload.name}));case"SET_STEP_DESCRIPTION":return ge(e,i,n=>({...n,description:r.payload.description}));case"SET_PREVIEW_KIND":return Me(e,i,n=>({...n,kind:r.payload.kind}));case"SET_PREVIEW_VIEWPORT":return Me(e,i,n=>({...n,viewport:r.payload.viewport}));case"SET_PREVIEW_LABEL":return Me(e,i,n=>({...n,label:r.payload.label}));case"REORDER_ACTIVITY":{const{after:n}=r.payload,o=oe(e.activities,i,n);return o===null?null:{...e,activities:o}}case"REORDER_STORY":{const{after:n}=r.payload,o=$(e,i);if(!o)return null;const s=n===null?null:$(e,n);if(n!==null&&(!s||s.activity!==o.activity))return null;const a=oe(o.activity.stories,o.story.id,s?.story.id??null);return a===null?null:H(e,o.activity.id,p=>({...p,stories:a}))}case"REORDER_STEP":{const{after:n}=r.payload,o=k(e,i);if(!o)return null;const s=n===null?null:k(e,n);if(n!==null&&(!s||s.story!==o.story))return null;const a=oe(o.story.steps,o.step.id,s?.step.id??null);return a===null?null:G(e,D(o.activity.id,o.story.id),p=>({...p,steps:a}))}case"MOVE_STORY":{const{toActivity:n,after:o}=r.payload,s=$(e,i);if(!s)return null;const a=e.activities.find(h=>h.id===n);if(!a)return null;const p=o===null?null:$(e,o);if(o!==null&&(!p||p.activity!==a))return null;const l=p?.story.id??null;if(s.activity.id===n){const h=oe(s.activity.stories,s.story.id,l);return h===null?null:H(e,n,v=>({...v,stories:h}))}if(a.stories.some(h=>h.id===s.story.id))return null;const b=Le(a.stories,s.story,l);return Oe(e,h=>h.id===s.activity.id?{...h,stories:h.stories.filter(v=>v.id!==gt(i))}:h.id===n?{...h,stories:b}:h)}case"MOVE_STEP":{const{toStory:n,after:o}=r.payload,s=k(e,i);if(!s)return null;const a=$(e,n);if(!a)return null;const p=o===null?null:k(e,o);if(o!==null&&(!p||p.story!==a.story))return null;const l=p?.step.id??null;if(s.story===a.story){const h=oe(s.story.steps,s.step.id,l);return h===null?null:G(e,n,v=>({...v,steps:h}))}if(a.story.steps.some(h=>h.id===s.step.id))return null;const b=Le(a.story.steps,s.step,l);return Oe(e,h=>({...h,stories:h.stories.map(v=>v===s.story?{...v,steps:v.steps.filter(I=>I.id!==gt(i))}:v===a.story?{...v,steps:b}:v)}))}case"ADD_ACTIVITY":{const n=r.payload;if(e.activities.some(s=>s.id===n.id))return e;const o={id:n.id,name:n.name,...n.description===void 0?{}:{description:n.description},stories:[]};return{...e,activities:[...e.activities,o]}}case"ADD_STORY":{const n=r.payload,o=e.activities.find(a=>a.id===i);if(!o)return null;if(o.stories.some(a=>a.id===n.id))return e;const s={id:n.id,name:n.name,...n.description===void 0?{}:{description:n.description},steps:[]};return H(e,i,a=>({...a,stories:[...a.stories,s]}))}case"ADD_STEP":{const n=r.payload,o=$(e,i)?.story;if(!o)return null;if(o.steps.some(p=>p.id===n.id))return e;const s=n.panes??[],a={id:n.id,name:n.name,...n.description===void 0?{}:{description:n.description},panes:s};return bi(e,a)?G(e,i,p=>({...p,steps:[...p.steps,a]})):null}case"ADD_PREVIEW":{const n=r.payload,o=k(e,i)?.step;return o?X(o).some(s=>s.id===n.id)?e:A(e,n.id)?null:ge(e,i,s=>({...s,panes:[...s.panes,{material:n}]})):null}case"DELETE_ACTIVITY":{const n=i;return e.activities.some(o=>o.id===n)?{...e,activities:e.activities.filter(o=>o.id!==n)}:null}case"DELETE_STORY":{const n=$(e,i);return n?H(e,n.activity.id,o=>({...o,stories:o.stories.filter(s=>s.id!==n.story.id)})):null}case"DELETE_STEP":{const n=k(e,i);return n?G(e,D(n.activity.id,n.story.id),o=>({...o,steps:o.steps.filter(s=>s.id!==n.step.id)})):null}case"DELETE_PREVIEW":{const n=A(e,i);return n?wt(e,n.owner,o=>o.filter(s=>s.id!==n.preview.id)):null}default:return Cr(r)}},Oe=(e,t)=>({...e,activities:e.activities.map(t)}),H=(e,t,r)=>{const i=t;return e.activities.some(n=>n.id===i)?Oe(e,n=>n.id===i?r(n):n):null},G=(e,t,r)=>{const i=$(e,t);if(!i)return null;const n=i.story.id;return H(e,i.activity.id,o=>({...o,stories:o.stories.map(s=>s.id===n?r(s):s)}))},ge=(e,t,r)=>{const i=k(e,t);if(!i)return null;const n=i.step.id;return G(e,D(i.activity.id,i.story.id),o=>({...o,steps:o.steps.map(s=>s.id===n?r(s):s)}))},Me=(e,t,r)=>{const i=A(e,t);if(!i)return null;const n=i.preview.id;return wt(e,i.owner,o=>o.map(s=>s.id===n?r(s):s))},bi=(e,t)=>{const r=X(t).map(i=>i.id);return gi(e,t)===null&&new Set(r).size===r.length&&!r.some(i=>A(e,i))},wt=(e,t,r)=>{if(t.kind==="step")return ge(e,ie(t),n=>{const o=new Map(r([...X(n)]).map(s=>[s.id,s]));return{...n,panes:n.panes.flatMap(s=>{if(K(s))return[s];const a=o.get(s.material.id);return a?[{material:a}]:[]})}});const i=t.screen.id;return{...e,apps:e.apps.map(n=>n.id===t.app.id?{...n,screens:n.screens.map(o=>o.id===i?{...o,previews:r(o.previews)}:o)}:n)}},oe=(e,t,r)=>{const i=e.findIndex(s=>s.id===t);if(i<0||r!==null&&!e.some(s=>s.id===r))return null;if(t===r)return[...e];const n=e[i];if(n===void 0)return null;const o=e.filter(s=>s.id!==t);return Le(o,n,r)},Le=(e,t,r)=>{const i=[...e],n=r===null?-1:i.findIndex(o=>o.id===r);return i.splice(n+1,0,t),i},mt={"iphone-se":"iPhone SE","iphone-16":"iPhone 16","iphone-16-pro-max":"iPhone 16 Pro Max","pixel-7":"Pixel 7","galaxy-s24":"Galaxy S24","ipad-mini":"iPad mini","ipad-air-11":'iPad Air 11"',"ipad-pro-11":'iPad Pro 11"',"ipad-pro-13":'iPad Pro 13"'},wi={"laptop-13":'13" laptop',"laptop-15":'15" laptop',"full-hd":"Full HD","monitor-27":'27" monitor',ultrawide:"Ultrawide"},mi={"laptop-13":"13 \u30A4\u30F3\u30C1 \u30CE\u30FC\u30C8","laptop-15":"15 \u30A4\u30F3\u30C1 \u30CE\u30FC\u30C8","full-hd":"\u30D5\u30EB HD","monitor-27":"27 \u30A4\u30F3\u30C1 \u30E2\u30CB\u30BF\u30FC",ultrawide:"\u30A6\u30EB\u30C8\u30E9\u30EF\u30A4\u30C9"},fe=Or({en:{renameActivity:"Rename Activity",updateActivityDescription:"Update Activity description",renameStory:"Rename UserStory",updateStoryDescription:"Update UserStory description",renameStep:"Rename Step",updateStepDescription:"Update Step description",changePreviewKind:"Change Preview kind",changePreviewViewport:"Change Preview viewport",changePreviewLabel:"Change Preview label",moveStory:"Move UserStory",moveStep:"Move Step",deleteTitle:"Delete",reorderTitle:e=>`Reorder ${e}`,addTitle:e=>`Add ${e}`,toFront:"\u2192 To the front",afterName:e=>`\u2192 Right after "${e}"`,unknownTarget:"(unknown target)",activityGroup:"Activity",storyGroup:"UserStory",stepGroup:"Step",screenGroup:"Screen",openInApp:"Open this screen in the app view",previewGroup:"Preview",pageGroup:"Page",uiGroup:"UI",targetLabel:(e,t)=>`${e} \xB7 ${t}`,targetMissing:(e,t)=>`${e} \xB7 ${t} (missing)`,noActivityBefore:"There are no Activities yet. Add ",noActivityAfter:" to the base JSON, or ask the agent.",deleteStepAria:"Delete step",addStepButton:"+ Step",stepNameLabel:"Step name",descriptionLabel:"Description",descriptionPlaceholder:"What happens in this Step (click to edit)",newStepName:"New step",viewLabel:"View",viewScenario:"Scenario",viewApp:"App",viewScenarioHint:"Follow one user story step by step",viewAppHint:"Use the UI as one app, whatever the scenario",appScreens:"Screens",appScreensHint:"Pick a screen to start from, then move around through the UI itself.",appSelectLabel:"App",appOutsideBrowser:"Outside the browser",noStepBefore:"There are no Steps yet. A Prototype has the meaning structure ",noStepAfter:" \u2014 one Step is one moment of the story: the screen the user is on and what they have at hand. Add a Step to the base JSON, and its screen will appear here.",noScreens:"This product has no screens yet. Declare its apps and their screens under apps[].screens in the base JSON, and they will appear here.",noPreviewMetadata:"No preview metadata \u2014 ask the agent to add it.",storyWithoutSteps:"This UserStory has no Steps yet, so there is no screen to show. Add one with + Step, or ask the agent to prototype it.",pageActor:e=>`Used by ${e}`,maximize:"Maximize",restore:"Restore size",maximizeHint:"Show the preview alone across the tab \xB7 Esc to restore",situation:"Situation",uiComment:"Comment on UI",uiCommentHint:"Click any part of the preview to comment on it \xB7 Esc to finish",uiCommentPin:(e,t)=>`Comment ${e}: ${t}`,mailFrom:"From",mailTo:"To",mailCc:"Cc",mailDate:"Date",demo:"Demo",demoHint:"Use the app in a browser across the tab, with nothing else on screen \xB7 Esc to finish",exitDemo:"Exit demo",browserBack:"Back",browserForward:"Forward",browserReload:"Reload",browserAddress:"Address",browserTabs:"Tabs",newTab:"New tab",closeTab:"Close tab",browserProfile:e=>`Profile: ${e}`,browserGuest:"Guest",newTabShortcuts:"Pages of this app",unreachableTitle:"This site can\u2019t be reached",unreachableBody:"No page of the prototype has this address.",device:"Device",deviceHint:"The window the app runs in: a page taller than it scrolls inside, as on the device",deviceName:e=>mt[e]??wi[e]??e,deviceZoom:e=>`Shown at ${e}% to fit`},ja:{renameActivity:"Activity \u540D\u3092\u5909\u66F4",updateActivityDescription:"Activity \u306E\u8AAC\u660E\u3092\u66F4\u65B0",renameStory:"UserStory \u540D\u3092\u5909\u66F4",updateStoryDescription:"UserStory \u306E\u8AAC\u660E\u3092\u66F4\u65B0",renameStep:"Step \u540D\u3092\u5909\u66F4",updateStepDescription:"Step \u306E\u8AAC\u660E\u3092\u66F4\u65B0",changePreviewKind:"Preview \u306E\u7A2E\u5225\u3092\u5909\u66F4",changePreviewViewport:"Preview \u306E\u30D3\u30E5\u30FC\u30DD\u30FC\u30C8\u3092\u5909\u66F4",changePreviewLabel:"Preview \u306E\u30E9\u30D9\u30EB\u3092\u5909\u66F4",moveStory:"UserStory \u3092\u79FB\u52D5",moveStep:"Step \u3092\u79FB\u52D5",deleteTitle:"\u524A\u9664",reorderTitle:e=>`${e} \u306E\u9806\u5E8F\u3092\u5909\u66F4`,addTitle:e=>`${e} \u3092\u8FFD\u52A0`,toFront:"\u2192 \u5148\u982D\u3078",afterName:e=>`\u2192 "${e}" \u306E\u76F4\u5F8C\u3078`,unknownTarget:"(unknown target)",activityGroup:"Activity",storyGroup:"UserStory",stepGroup:"Step",screenGroup:"\u753B\u9762",openInApp:"\u3053\u306E\u753B\u9762\u3092\u30A2\u30D7\u30EA\u30D3\u30E5\u30FC\u3067\u958B\u304F",previewGroup:"Preview",pageGroup:"Page",uiGroup:"UI",targetLabel:(e,t)=>`${e} \xB7 ${t}`,targetMissing:(e,t)=>`${e} \xB7 ${t} (missing)`,noActivityBefore:"Activity \u304C\u307E\u3060\u3042\u308A\u307E\u305B\u3093\u3002base JSON \u306E ",noActivityAfter:" \u3092\u8FFD\u52A0\u3059\u308B\u304B\u3001Agent \u306B\u4F9D\u983C\u3057\u3066\u304F\u3060\u3055\u3044\u3002",deleteStepAria:"\u30B9\u30C6\u30C3\u30D7\u3092\u524A\u9664",addStepButton:"+ Step",stepNameLabel:"Step \u540D",descriptionLabel:"\u8AAC\u660E",descriptionPlaceholder:"\u3053\u306E Step \u3067\u4F55\u304C\u8D77\u304D\u308B\u304B\uFF08\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u7DE8\u96C6\uFF09",newStepName:"\u65B0\u3057\u3044\u30B9\u30C6\u30C3\u30D7",viewLabel:"\u8868\u793A",viewScenario:"\u30B7\u30CA\u30EA\u30AA",viewApp:"\u30A2\u30D7\u30EA",viewScenarioHint:"\u30E6\u30FC\u30B6\u30FC\u30B9\u30C8\u30FC\u30EA\u30FC\u306B\u6CBF\u3063\u3066 Step \u3092\u9806\u306B\u305F\u3069\u308B",viewAppHint:"\u30B7\u30CA\u30EA\u30AA\u306B\u95A2\u4FC2\u306A\u304F\u3001UI \u3092 1 \u3064\u306E\u30A2\u30D7\u30EA\u3068\u3057\u3066\u89E6\u308B",appScreens:"\u753B\u9762",appScreensHint:"\u8D77\u70B9\u306B\u3059\u308B\u753B\u9762\u3092\u9078\u3073\u3001\u3042\u3068\u306F UI \u306E\u30EA\u30F3\u30AF\u3067\u79FB\u52D5\u3057\u307E\u3059\u3002",appSelectLabel:"\u30A2\u30D7\u30EA",appOutsideBrowser:"\u30D6\u30E9\u30A6\u30B6\u4EE5\u5916",noStepBefore:"Step \u304C\u307E\u3060\u3042\u308A\u307E\u305B\u3093\u3002Prototype \u306F ",noStepAfter:" \u306E\u610F\u5473\u69CB\u9020\u3092\u6301\u3061\u30011 Step = \u30B7\u30CA\u30EA\u30AA\u306E 1 \u5834\u9762\uFF08\u30E6\u30FC\u30B6\u30FC\u304C\u3044\u308B\u753B\u9762\u3068\u3001\u624B\u5143\u306B\u3042\u308B\u3082\u306E\uFF09\u3067\u3059\u3002base JSON \u306B Step \u3092\u8FFD\u52A0\u3059\u308B\u3068\u3001\u3053\u3053\u306B\u305D\u306E\u753B\u9762\u304C\u73FE\u308C\u307E\u3059\u3002",noScreens:"\u3053\u306E\u30D7\u30ED\u30C0\u30AF\u30C8\u306B\u306F\u307E\u3060\u753B\u9762\u304C\u3042\u308A\u307E\u305B\u3093\u3002base JSON \u306E apps[].screens \u306B\u30A2\u30D7\u30EA\u3068\u753B\u9762\u3092\u5BA3\u8A00\u3059\u308B\u3068\u3001\u3053\u3053\u306B\u73FE\u308C\u307E\u3059\u3002",noPreviewMetadata:"preview metadata \u304C\u3042\u308A\u307E\u305B\u3093 \u2014 \u8FFD\u52A0\u306F Agent \u306B\u4F9D\u983C\u3057\u3066\u304F\u3060\u3055\u3044",storyWithoutSteps:"\u3053\u306E UserStory \u306B\u306F\u307E\u3060 Step \u304C\u306A\u304F\u3001\u898B\u305B\u308B\u753B\u9762\u304C\u3042\u308A\u307E\u305B\u3093\u3002+ Step \u3067\u8FFD\u52A0\u3059\u308B\u304B\u3001Agent \u306B\u30D7\u30ED\u30C8\u30BF\u30A4\u30D7\u3092\u4F9D\u983C\u3057\u3066\u304F\u3060\u3055\u3044\u3002",pageActor:e=>`\u5229\u7528\u8005: ${e}`,maximize:"\u6700\u5927\u5316",restore:"\u5143\u306E\u30B5\u30A4\u30BA\u306B\u623B\u3059",maximizeHint:"\u30D7\u30EC\u30D3\u30E5\u30FC\u3060\u3051\u3092\u30BF\u30D6\u3044\u3063\u3071\u3044\u306B\u8868\u793A \xB7 Esc \u3067\u623B\u308B",situation:"\u72B6\u6CC1",uiComment:"UI \u306B\u30B3\u30E1\u30F3\u30C8",uiCommentHint:"\u30D7\u30EC\u30D3\u30E5\u30FC\u306E\u8981\u7D20\u3092\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u30B3\u30E1\u30F3\u30C8 \xB7 Esc \u3067\u7D42\u4E86",uiCommentPin:(e,t)=>`\u30B3\u30E1\u30F3\u30C8 ${e}: ${t}`,mailFrom:"\u5DEE\u51FA\u4EBA",mailTo:"\u5B9B\u5148",mailCc:"Cc",mailDate:"\u65E5\u6642",demo:"\u30C7\u30E2",demoHint:"\u307B\u304B\u306B\u4F55\u3082\u51FA\u3055\u305A\u3001\u30BF\u30D6\u3044\u3063\u3071\u3044\u306E\u30D6\u30E9\u30A6\u30B6\u3067\u30A2\u30D7\u30EA\u3092\u89E6\u308B \xB7 Esc \u3067\u7D42\u4E86",exitDemo:"\u30C7\u30E2\u3092\u7D42\u4E86",browserBack:"\u623B\u308B",browserForward:"\u9032\u3080",browserReload:"\u518D\u8AAD\u307F\u8FBC\u307F",browserAddress:"\u30A2\u30C9\u30EC\u30B9",browserTabs:"\u30BF\u30D6",newTab:"\u65B0\u3057\u3044\u30BF\u30D6",closeTab:"\u30BF\u30D6\u3092\u9589\u3058\u308B",browserProfile:e=>`\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB: ${e}`,browserGuest:"\u30B2\u30B9\u30C8",newTabShortcuts:"\u3053\u306E\u30A2\u30D7\u30EA\u306E\u30DA\u30FC\u30B8",unreachableTitle:"\u3053\u306E\u30B5\u30A4\u30C8\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093",unreachableBody:"\u30D7\u30ED\u30C8\u30BF\u30A4\u30D7\u306B\u3053\u306E\u30A2\u30C9\u30EC\u30B9\u306E\u30DA\u30FC\u30B8\u306F\u3042\u308A\u307E\u305B\u3093\u3002",device:"\u30C7\u30D0\u30A4\u30B9",deviceHint:"\u30A2\u30D7\u30EA\u3092\u52D5\u304B\u3059\u753B\u9762\u306E\u5927\u304D\u3055\u3002\u53CE\u307E\u3089\u306A\u3044\u30DA\u30FC\u30B8\u306F\u5B9F\u6A5F\u3068\u540C\u3058\u304F\u753B\u9762\u306E\u4E2D\u3067\u30B9\u30AF\u30ED\u30FC\u30EB\u3059\u308B",deviceName:e=>mt[e]??mi[e]??e,deviceZoom:e=>`\u53CE\u307E\u308B\u3088\u3046 ${e}% \u3067\u8868\u793A`}}),yi=["scenario","app"],N="view",se=e=>e[N]==="app"?"app":"scenario",yt=e=>({[N]:e==="app"?"app":null}),ae=(e,t)=>e===void 0?`\u2192 "${t}"`:`"${e}" \u2192 "${t}"`,ki=e=>({SET_ACTIVITY_NAME:(t,r)=>({title:e.renameActivity,tone:"update",body:ae(L(r,t.target.id)?.name,y(f.SET_ACTIVITY_NAME,t).name)}),SET_ACTIVITY_DESCRIPTION:(t,r)=>({title:e.updateActivityDescription,tone:"update",body:Ne(L(r,t.target.id)?.description,y(f.SET_ACTIVITY_DESCRIPTION,t).description)}),SET_STORY_NAME:(t,r)=>({title:e.renameStory,tone:"update",body:ae($(r,t.target.id)?.story.name,y(f.SET_STORY_NAME,t).name)}),SET_STORY_DESCRIPTION:(t,r)=>({title:e.updateStoryDescription,tone:"update",body:Ne($(r,t.target.id)?.story.description,y(f.SET_STORY_DESCRIPTION,t).description)}),SET_STEP_NAME:(t,r)=>({title:e.renameStep,tone:"update",body:ae(k(r,t.target.id)?.step.name,y(f.SET_STEP_NAME,t).name)}),SET_STEP_DESCRIPTION:(t,r)=>({title:e.updateStepDescription,tone:"update",body:Ne(k(r,t.target.id)?.step.description,y(f.SET_STEP_DESCRIPTION,t).description)}),SET_PREVIEW_KIND:(t,r)=>({title:e.changePreviewKind,tone:"update",body:ae(A(r,t.target.id)?.preview.kind,y(f.SET_PREVIEW_KIND,t).kind)}),SET_PREVIEW_VIEWPORT:(t,r)=>({title:e.changePreviewViewport,tone:"update",body:ae(A(r,t.target.id)?.preview.viewport,y(f.SET_PREVIEW_VIEWPORT,t).viewport)}),SET_PREVIEW_LABEL:t=>({title:e.changePreviewLabel,tone:"update",body:`\u2192 "${y(f.SET_PREVIEW_LABEL,t).label}"`}),REORDER_ACTIVITY:t=>ze(e,e.activityGroup,y(f.REORDER_ACTIVITY,t).after),REORDER_STORY:t=>ze(e,e.storyGroup,y(f.REORDER_STORY,t).after),REORDER_STEP:t=>ze(e,e.stepGroup,y(f.REORDER_STEP,t).after),MOVE_STORY:(t,r)=>({title:e.moveStory,tone:"move",body:`\u2192 ${L(r,y(f.MOVE_STORY,t).toActivity)?.name??y(f.MOVE_STORY,t).toActivity}`}),MOVE_STEP:(t,r)=>({title:e.moveStep,tone:"move",body:`\u2192 ${$(r,y(f.MOVE_STEP,t).toStory)?.story.name??y(f.MOVE_STEP,t).toStory}`}),ADD_ACTIVITY:t=>be(e,e.activityGroup,y(f.ADD_ACTIVITY,t).name),ADD_STORY:t=>be(e,e.storyGroup,y(f.ADD_STORY,t).name),ADD_STEP:t=>be(e,e.stepGroup,y(f.ADD_STEP,t).name),ADD_PREVIEW:t=>be(e,e.previewGroup,y(f.ADD_PREVIEW,t).label??y(f.ADD_PREVIEW,t).id),DELETE_ACTIVITY:(t,r)=>we(e,L(r,t.target.id)?.name),DELETE_STORY:(t,r)=>we(e,$(r,t.target.id)?.story.name),DELETE_STEP:(t,r)=>we(e,k(r,t.target.id)?.step.name),DELETE_PREVIEW:(t,r)=>we(e,A(r,t.target.id)?.preview.label)}),Ne=(e,t)=>{const r=t.length>90?`${t.slice(0,90)}\u2026`:t;return e===void 0||e===""?`\u2192 "${r}"`:`"${xi(e)}" \u2192 "${r}"`},xi=e=>e.length>60?`${e.slice(0,60)}\u2026`:e,ze=(e,t,r)=>({title:e.reorderTitle(t),tone:"move",body:r===null?e.toFront:e.afterName(r)}),be=(e,t,r)=>({title:e.addTitle(t),tone:"create",body:`+ "${r}"`}),we=(e,t)=>({title:e.deleteTitle,tone:"delete",body:t===void 0?e.unknownTarget:`\u2212 "${t}"`}),kt=(e,t,r,i)=>{const n=ki(e),o=Object.hasOwn(n,t.type)?n[t.type]:void 0,s=o?o(t,i??r):{title:t.type,tone:"meta"};return{title:s.title,targetLabel:$t(e,r,t.target),tone:s.tone,...s.body===void 0?{}:{summary:s.body}}},xt=e=>`${e.type} ${U(e.target)} ${JSON.stringify(e.payload)}`,$t=(e,t,r)=>{switch(r.type){case"activity":{const i=L(t,r.id);return i?e.targetLabel(e.activityGroup,i.name):e.targetMissing(e.activityGroup,r.id)}case"story":{const i=$(t,r.id)?.story;return i?e.targetLabel(e.storyGroup,i.name):e.targetMissing(e.storyGroup,r.id)}case"step":{const i=k(t,r.id)?.step;return i?e.targetLabel(e.stepGroup,i.name):e.targetMissing(e.stepGroup,r.id)}case"screen":{const i=M(t,r.id)?.screen;return i?e.targetLabel(e.screenGroup,i.title):e.targetMissing(e.screenGroup,r.id)}case"preview":{const i=A(t,r.id)?.preview;return i?e.targetLabel(e.previewGroup,i.label??i.id):e.targetMissing(e.previewGroup,r.id)}case"page":return e.targetLabel(e.pageGroup,Ue(t));case re:{const i=Ce(r.id),n=i?A(t,i.previewId)?.preview:void 0;return i&&n?e.targetLabel(e.uiGroup,Et(n,i)):e.targetMissing(e.uiGroup,r.id)}default:return e.targetLabel(r.type,r.id)}},Et=(e,t)=>{const r=t.text===void 0?t.selector:`"${t.text}"`;return`${e.label??e.id} \u203A ${r}`},St=(e,t)=>{const r=[];for(const i of e){if(i.target.type!==re)continue;const n=Ce(i.target.id);!n||!t.includes(n.previewId)||r.push({id:i.id,previewId:n.previewId,selector:n.selector,number:r.length+1,body:et(i)})}return r},Tt=(e,t)=>St(e,t).length,$i=/^[a-z][a-z0-9+.-]*:/i,Ei=e=>{const t=e.baseUrl?.trim(),r=Mr(e.title??"");return`${(t?t.startsWith("http")?t:`https://${t}`:`https://${r==="item"?"page":r}.example.com`).replace(/\/+$/,"")}/`},me=(e,t)=>{const r=Ei(e);if(!t.url)return`${r}${t.id}`;if($i.test(t.url))return t.url;try{return decodeURI(new URL(t.url,r).href)}catch{return t.url}},Si=e=>{switch(e.type){case"activity":return{[N]:null,activity:e.id};case"story":return{[N]:null,activity:null,story:e.id};case"step":return{[N]:null,activity:null,story:null,step:e.id};case"screen":return{screen:e.id};default:return null}},At=(e,t)=>{const r=e.kind==="screen"?[{type:"screen",id:e.screen.id}]:[{type:"activity",id:e.activity.id},{type:"story",id:D(e.activity.id,e.story.id)},...e.kind==="step"?[{type:"step",id:ie(e)}]:[]];for(const i of t?.panes??[])i.kind==="screen"&&r.push({type:"screen",id:i.screen.screen.id});return[...new Set(r.map(U))].join(" ")},Ve=",",It=e=>e.preview?.split(Ve)??[],Ti=(e,t)=>e.kind===t.kind&&e.viewport===t.viewport,Pt=(e,t,r)=>{const i=t.find(o=>r.includes(o.id));if(i)return i;const n=r.flatMap(o=>A(e,o)?.preview??[]);return t.find(o=>n.some(s=>Ti(o,s)))??t[0]},_t=(e,t,r,i)=>{const n=t.screen.previews,o=r===void 0?Pt(e,n,It(i)):n.find(a=>a.id===r);if(!o)return;const s=r===void 0&&n.length>1;return{kind:"screen",screen:t,preview:o,pinned:r!==void 0,tabs:s?n:[]}},Rt=e=>({layout:e.length>1?"side-by-side":"single",panes:e,shown:e.map(t=>t.preview)}),Dt=(e,t,r)=>t.panes.flatMap(i=>{if(!K(i))return[{kind:"material",preview:i.material}];const n=M(e,i.screen),o=n&&_t(e,n,i.preview,r);return o?[o]:[]}),Ye=(e,t,r)=>{if(t.kind==="screen"){const i=_t(e,t,void 0,r);return Rt(i?[i]:[])}return Rt(Dt(e,t.step,r))},Ai=(e,t)=>e.panes.flatMap(r=>r.kind!=="screen"||r.tabs.length===0?[]:[r.tabs.some(i=>i.id===t)?t:r.preview.id]).join(Ve),Ii=(e,t)=>[...X(t),...he(e,t).flatMap(r=>r.screen.previews)],Pi=["activity","story","step","screen","preview"],_i=(e,t,r)=>{switch(t){case"activity":return L(e,r)!==void 0;case"story":return $(e,r)!==void 0||e.activities.some(i=>i.stories.some(n=>n.id===r));case"step":return k(e,r)!==void 0||B(e).some(i=>i.step.id===r);case"screen":return M(e,r)!==void 0;case"preview":return A(e,r)!==void 0;default:return!1}},Ri=(e,t)=>{let r;if(t.navigate!==null)r=t.navigate.includes("=")?t.navigate:`step=${t.navigate}`;else{const o=t.href?.trim()??"";if(o===""||o==="#"||o.toLowerCase().startsWith("javascript:"))return"no-destination";if(!o.startsWith("#"))return null;r=o}const i=Ae(r),n=Pi.filter(o=>i[o]!==void 0);return n.length===0?t.navigate===null?null:"unknown-target":n.every(o=>_i(e,o,i[o]??""))?null:"unknown-target"},Di=(e,t)=>{const r=t.mail??{},i=[{label:e.mailFrom,value:r.from},{label:e.mailTo,value:r.to},{label:e.mailCc,value:r.cc},{label:e.mailDate,value:r.date}].flatMap(s=>s.value===void 0||s.value.trim()===""?[]:[{label:s.label,value:s.value}]),n=r.from?.replace(/<[^>]*>/g,"").replace(/["']/g,"").trim()||r.from?.trim(),o=n?Array.from(n)[0]?.toUpperCase():void 0;return{...r.subject===void 0||r.subject.trim()===""?{}:{subject:r.subject},...n?{sender:n}:{},...o===void 0?{}:{initial:o},rows:i}},Ct=(e,t)=>{const r=[];for(const i of t.activities){r.push({value:U({type:"activity",id:i.id}),label:i.name,group:e.activityGroup});for(const n of i.stories){r.push({value:U({type:"story",id:D(i.id,n.id)}),label:`${i.name} \u203A ${n.name}`,group:e.storyGroup});for(const o of n.steps)r.push({value:U({type:"step",id:ve(i,n,o)}),label:`${n.name} \u203A ${o.name}`,group:e.stepGroup})}}for(const{app:i,screen:n}of W(t))r.push({value:U({type:"screen",id:n.id}),label:`${i.name} \u203A ${n.title}`,group:e.screenGroup});return r},Ci=(e,t,r)=>{const i=Z(t,r);if(i?.kind==="screen"){const{screen:n}=i;return{value:U({type:"screen",id:n.id}),label:n.title,group:e.screenGroup}}return i?.kind!=="step"?null:{value:U({type:"step",id:ie(i)}),label:i.step.name,group:e.stepGroup}},Z=(e,t)=>{if(se(t)==="app"){const o=M(e,t.screen);return o?{kind:"screen",...o}:void 0}const r=k(e,t.step);if(r)return{kind:"step",...r};const i=L(e,t.activity),n=i?.stories.find(o=>o.id===t.story||D(i.id,o.id)===t.story);return i&&n?{kind:"story",activity:i,story:n}:void 0},Ot=(e,t)=>{const r=(p,l)=>l===void 0?{title:p}:{actor:l,title:p};if(t.kind==="screen")return r(t.screen.title,t.app.actor);const{activity:i,story:n,step:o}=t,s=he(e,o),a=s.length===1?s[0]:void 0;return r(a?.screen.title??o.name,o.actor??n.actor??i.actor??a?.app.actor)},Oi=(e,t)=>{const r=t.actor??e.actor;return r===void 0?{title:t.name}:{actor:r,title:t.name}},Ue=e=>e.title??"UX Prototype",Mt=(e,t)=>(t?e.preview=t:delete e.preview,e),Mi=(e,t,r)=>{if(!t)return;const i=Dt(e,t,r).flatMap(n=>n.kind==="screen"&&!n.pinned?[n.preview.id]:[]);return i.length===0?void 0:i.join(Ve)},Lt=(e,t)=>{const r=()=>{if(t.step===void 0&&t.story===void 0)return;const o=Nt(e,{...t,[N]:""}),s=k(e,o.step);return s&&he(e,s.step)[0]},i=M(e,t.screen)??r()??W(e)[0],n={...t,[N]:"app"};for(const o of["activity","story","step"])delete n[o];return i?n.screen=i.screen.id:delete n.screen,Mt(n,i&&Pt(e,i.screen.previews,It(t))?.id)},Li=(e,t,r)=>{const i=s=>fi(s.step,t);if(r&&i(r))return r;const n=r?.story.steps??[],o=s=>{const a=n[s];return r&&a?{...r,step:a,stepIndex:s}:void 0};for(let s=(r?.stepIndex??0)+1;s<n.length;s+=1){const a=o(s);if(a&&i(a))return a}for(let s=(r?.stepIndex??0)-1;s>=0;s-=1){const a=o(s);if(a&&i(a))return a}return B(e).find(i)},Nt=(e,t)=>{const r=L(e,t.activity),i=t.story,n=r?.stories.find(V=>V.id===i||D(r.id,V.id)===i),o=n&&r?{activity:r,story:n}:$(e,i),s=t.step,p=(o&&s?k(e,`${D(o.activity.id,o.story.id)}.${s}`):void 0)??k(e,s),l=t.screen,b=l===void 0?void 0:Li(e,l,p);if(l!==void 0&&!b&&M(e,l))return Lt(e,{...t,[N]:"app"});const h=b??p,v=h?.activity??o?.activity??r??e.activities[0],I=h?.story??(o&&o.activity===v?o.story:void 0)??v?.stories[0],P=h?.step??I?.steps[0],S={...t};return delete S.screen,v?S.activity=v.id:delete S.activity,I&&v?S.story=$(e,I.id)?I.id:D(v.id,I.id):delete S.story,P&&I&&v?S.step=k(e,P.id)?P.id:ve(v,I,P):delete S.step,delete S[N],Mt(S,Mi(e,P,t))},Ni=["activity","story","step","screen"],ye=(e,t)=>se(t)==="app"?Lt(e,t):Nt(e,t),zi=(e,t)=>{const r=t.screen.previews.find(o=>o.kind==="browser");if(!r)return;let i;try{i=new URL(me(e,r),"https://page.example.com")}catch{return}const n=i.pathname.split("/").filter(o=>o!=="").map(o=>{try{return decodeURIComponent(o)}catch{return o}});return{origin:i.origin,segments:n}},zt=()=>({screens:[],children:new Map}),We=(e,t,r)=>{const[i,...n]=e.children.entries();if(e.screens.length===0&&i&&n.length===0&&r!=="/"){const[o,s]=i;return We(s,`${t}/${o}`,`${r}/${o}`)}return{segment:t,path:r,screens:e.screens,children:[...e.children.entries()].map(([o,s])=>We(s,`/${o}`,`${r==="/"?"":r}/${o}`))}},Vi=e=>{const t=new Map;for(const[r,i]of e){const n=t.get(i.origin)??zt();t.set(i.origin,n);let o=n;for(const s of i.segments){const a=o.children.get(s)??zt();o.children.set(s,a),o=a}o.screens.push(r)}return[...t.entries()].map(([r,i])=>({origin:r,root:We(i,"/","/")}))},Yi=(e,t)=>{const r=t.screens.map(o=>({app:t,screen:o})),i=[],n=[];for(const o of r){const s=zi(e,o);s?i.push([o,s]):n.push(o)}return{app:t,screens:r,trees:Vi(i),others:n}},Vt=e=>e.apps.map(t=>Yi(e,t)).filter(t=>t.screens.length>0),Yt=(e,t)=>t?.kind!=="screen"?e[0]:e.find(r=>r.app.id===t.app.id)??e[0],Ui=(e,t)=>{switch(t.type){case"activity":return L(e,t.id)!==void 0;case"story":return $(e,t.id)!==void 0;case"step":return k(e,t.id)!==void 0;case"screen":return M(e,t.id)!==void 0;case"preview":return A(e,t.id)!==void 0;case"page":return!0;case re:{const r=Ce(t.id);return r!==void 0&&A(e,r.previewId)!==void 0}default:return!1}},Ut=e=>{const t=fe(e);return{name:"prototype",label:"UX Prototype",parseBase:ht,emptyBase:vt,actions:f,apply:bt,hasTarget:Ui,canonicalTarget:(r,i)=>{if(i.type==="step"){const n=k(r,i.id);return n?{...i,id:ie(n)}:i}if(i.type==="story"){const n=$(r,i.id);return n?{...i,id:D(n.activity.id,n.story.id)}:i}if(i.type==="preview"){const n=A(r,i.id);return n?{...i,id:n.preview.id}:i}return i},describe:(r,i,n)=>kt(t,r,i,n),serialize:xt,resolveNavigation:ye,navigationHierarchy:Ni,navigationFor:(r,i)=>Si(i),commentTargets:(r,i)=>Ct(t,r),currentTarget:(r,i)=>Ci(t,r,i),title:Ue}},Wi=(e,t)=>{const r=t.flatMap(i=>{const n=Math.max(i.left,e.left)-e.left,o=Math.max(i.top,e.top)-e.top,s=Math.min(i.right,e.right)-e.left-n,a=Math.min(i.bottom,e.bottom)-e.top-o;return s>0&&a>0?[`M${n} ${o}h${s}v${a}h-${s}Z`]:[]});return r.length===0?"none":`path(evenodd, 'M0 0H${e.width}V${e.height}H0Z ${r.join(" ")}')`},ke="data-dpk-modal",Bi=e=>{try{return e.matches(":modal")}catch{return!1}},Wt=e=>{e.setAttribute(ke,""),e.open||e.show()},Bt=e=>{Object.hasOwn(e,"showModal")||Object.defineProperty(e,"showModal",{configurable:!0,value:()=>Wt(e)})},Ht=(e,t)=>{if(!Bi(t))return;const r=i=>{i.target===t&&(i.stopImmediatePropagation(),e.removeEventListener("close",r,!0))};e.addEventListener("close",r,!0),t.close(),Wt(t)},Hi='a, button, input, select, textarea, label, summary, [role="button"], [role="link"], [role="tab"]',Gt=/^-?[A-Za-z_][\w-]*$/,Ft=40,Gi=(e,t)=>{const r=e.closest(Hi);return r!==null&&r!==t&&t.contains(r)?r:e},xe=e=>{const t=e.replace(/\s+/g," ").trim();if(t==="")return;const r=Array.from(t);return r.length>Ft?`${r.slice(0,Ft).join("")}\u2026`:t},Fi=e=>{const t=e.getAttribute("aria-label")??e.getAttribute("title");if(t)return xe(t);const r=e.tagName.toLowerCase();return xe(r==="input"||r==="textarea"||r==="select"?e.getAttribute("placeholder")??e.getAttribute("name")??"":r==="img"?e.getAttribute("alt")??"":e.textContent??"")},ji=e=>{const t=e.getAttribute("id");if(t&&Gt.test(t))return`#${t}`;const r=e.tagName.toLowerCase(),i=Array.from(e.classList).filter(a=>Gt.test(a)).slice(0,2).map(a=>`.${a}`).join(""),n=e.parentElement,o=n?Array.from(n.children).filter(a=>a.tagName===e.tagName):[],s=o.length>1?`:nth-of-type(${o.indexOf(e)+1})`:"";return`${r}${i}${s}`},qi=(e,t,r)=>{try{const i=e.querySelectorAll(t);return i.length===1&&i[0]===r}catch{return!1}},Ki=(e,t)=>{const r=[];let i=e;for(;i!==null&&i!==t;){const o=ji(i);if(r.unshift(o),o.startsWith("#")||qi(t,r.join(" > "),e))break;i=i.parentElement}const n=Fi(e);return{selector:r.length===0?":scope":r.join(" > "),tag:e.tagName.toLowerCase(),...n===void 0?{}:{text:n}}},Xi=(e,t)=>{if(t===":scope")return e;try{return e.querySelector(t)}catch{return null}},Zi=["screen","preview"],de=e=>JSON.stringify(Zi.map(t=>e[t]??null)),jt=(e,t)=>e?.kind==="page"&&de(e.page)===t,$e=e=>`tab-${e}`,Ji=e=>({tabs:[{id:$e(1),history:[{kind:"page",page:e}],index:0}],activeId:$e(1),seen:de(e),nextId:2}),Qi={id:"",history:[],index:0},J=e=>e.tabs.find(t=>t.id===e.activeId)??e.tabs[0]??Qi,pe=e=>{const t=J(e);return t.history[t.index]},en=e=>J(e).index>0,tn=e=>{const t=J(e);return t.index<t.history.length-1},qt=(e,t)=>({...e,tabs:e.tabs.map(r=>r.id===e.activeId?t(r):r)}),Be=(e,t)=>qt(e,r=>({...r,history:[...r.history.slice(0,r.index+1),t],index:r.index+1})),Ee=e=>{const t=pe(e);return t?.kind==="page"?{...e,seen:de(t.page)}:e},Kt=(e,t)=>{const r=J(e),i=r.index+t;return i<0||i>=r.history.length?e:Ee(qt(e,n=>({...n,index:i})))},Xt=(e,t,r)=>{const i=$e(e.nextId),n=e.tabs.findIndex(o=>o.id===e.activeId)+1;return Ee({...e,tabs:[...e.tabs.slice(0,n),{id:i,history:[t],index:0},...e.tabs.slice(n)],activeId:r?e.activeId:i,nextId:e.nextId+1})},rn=(e,t)=>{const r=e.tabs.findIndex(o=>o.id===t);if(r<0)return e;if(e.tabs.length===1){const o=$e(e.nextId);return{...e,tabs:[{id:o,history:[{kind:"new-tab"}],index:0}],activeId:o,nextId:e.nextId+1}}const i=e.tabs.filter(o=>o.id!==t);if(t!==e.activeId)return{...e,tabs:i};const n=i[r]??i[r-1];return Ee({...e,tabs:i,activeId:n?.id??e.activeId})},nn=(e,t)=>{const r=t===null?null:de(t);if(r===e.seen)return e;const i={...e,seen:r};return t===null||r===null||jt(pe(e),r)?i:Be(i,{kind:"page",page:t})},on=(e,t)=>{const r=de(t);return jt(pe(e),r)?e.seen===r?e:{...e,seen:r}:Be({...e,seen:r},{kind:"page",page:t})},Zt=(e,t)=>{switch(t.kind){case"observe":return nn(e,t.page);case"visit":return on(e,t.page);case"back":return Kt(e,-1);case"forward":return Kt(e,1);case"open-tab":return Xt(e,t.entry,t.background);case"new-tab":return Xt(e,{kind:"new-tab"},!1);case"unreachable":return Be(e,{kind:"unreachable",url:t.url});case"activate":return e.tabs.some(r=>r.id===t.id)&&t.id!==e.activeId?Ee({...e,activeId:t.id}):e;case"close-tab":return rn(e,t.id);default:return e}},Jt=(e,t)=>{const r=ye(e,t),i=Z(e,r);if(i?.kind!=="screen")return null;const[n]=Ye(e,i,r).shown;return n?.kind!=="browser"?null:{screen:i.screen.id,preview:n.id}},Se=(e,t)=>{const r=Z(e,ye(e,{[N]:"app",...t}));return r?.kind==="screen"?r:void 0},Qt=(e,t)=>{const r=e.trim();if(r==="")return null;try{return r.startsWith("/")?new URL(r,t):new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(r)?r:`https://${r}`)}catch{return null}},er=e=>`${e.origin}${e.pathname.replace(/\/+$/,"")}`,sn=(e,t,r)=>{const i=Qt(t,r);if(i===null)return null;const n=er(i);for(const{screen:o}of W(e))for(const s of o.previews){if(s.kind!=="browser")continue;const a=Qt(me(e,s),r);if(a!==null&&er(a)===n)return{screen:o.id,preview:s.id}}return null},tr=e=>{try{return new URL(e).host||e}catch{return e}},an=(e,t,r)=>t===void 0||t.kind==="new-tab"?r.newTab:t.kind==="unreachable"?tr(t.url):Se(e,t.page)?.screen.title??r.newTab,rr=(e,t)=>{if(t===void 0||t.kind==="new-tab")return"";if(t.kind==="unreachable")return t.url;const r=Se(e,t.page)?.screen.previews.find(i=>i.id===t.page.preview);return r===void 0?"":me(e,r)},ir=e=>{const t=J(e);for(let r=t.index;r>=0;r-=1){const i=t.history[r];if(i?.kind==="page")return i.page}for(const r of e.tabs){const i=r.history[r.index];if(i?.kind==="page")return i.page}},dn=(e,t)=>t===void 0?void 0:Se(e,t)?.app.actor,nr=(e,t,r,i=null)=>{const n=J(t),o=n.history[n.index],s=dn(e,ir(t)??i??void 0);return{tabs:t.tabs.map(a=>({id:a.id,title:an(e,a.history[a.index],r),url:rr(e,a.history[a.index]),active:a.id===n.id})),entry:o,url:rr(e,o),canBack:en(t),canForward:tn(t),...s===void 0?{}:{profile:s}}},pn=e=>ir(e)??null,ln=(e,t)=>{const r=t===null?void 0:Se(e,t),i=Yt(Vt(e),r),n=[],o=(s,a)=>{for(const{screen:p}of a.screens){const l=p.previews.find(b=>b.kind==="browser");l!==void 0&&n.push({title:p.title,url:`${s}${a.path==="/"?"":a.path}`,page:{screen:p.id,preview:l.id}})}for(const p of a.children)o(s,p)};for(const s of i?.trees??[])o(tr(s.origin),s.root);return n},T=(e,t,r,i)=>({id:t,deviceClass:e,width:r,height:i}),or=[T("phone","iphone-se",375,667),T("phone","iphone-16",393,852),T("phone","iphone-16-pro-max",440,956),T("phone","pixel-7",412,915),T("phone","galaxy-s24",360,780),T("tablet","ipad-mini",744,1133),T("tablet","ipad-air-11",820,1180),T("tablet","ipad-pro-11",834,1194),T("tablet","ipad-pro-13",1024,1366),T("desktop","laptop-13",1280,800),T("desktop","laptop-15",1440,900),T("desktop","full-hd",1920,1080),T("desktop","monitor-27",2560,1440),T("desktop","ultrawide",3440,1440)],cn={phone:T("phone","iphone-16",393,852),tablet:T("tablet","ipad-pro-11",834,1194),desktop:T("desktop","laptop-13",1280,800)},sr=e=>e==="mobile"?"phone":e==="tablet"?"tablet":"desktop",un=e=>e!=="plain",ar=e=>or.filter(t=>t.deviceClass===e),hn=(e,t)=>{const r=sr(e),i=t[r];return ar(r).find(n=>n.id===i)??cn[r]},vn=(e,t)=>{const r=or.find(i=>i.id===t);return r===void 0||e[r.deviceClass]===t?e:{...e,[r.deviceClass]:t}},gn=(e,t)=>`${e.deviceName(t.id)} \xB7 ${t.width}\xD7${t.height}`,fn=(e,t)=>{const r=[1,t.width/e.width];t.height!==void 0&&r.push(t.height/e.height);const i=Math.min(...r);return!Number.isFinite(i)||i<=0?1:Math.max(.1,Math.floor(i*100)/100)},dr=(e,t)=>{const{state:r,navigation:i}=e,n=Z(r,i),o=se(i);return d`
2
2
  <div class="nav">
3
3
  ${mn(e,t,o)}
4
4
  ${o==="app"?yn(e,t,n):n!==void 0&&n.kind!=="screen"?$n(e,t,n):d`<p class="nav-empty">${t.noActivityBefore}<code>activities</code>${t.noActivityAfter}</p>`}
5
5
  </div>
6
- `},wn={scenario:"viewScenario",app:"viewApp"},bn={scenario:"viewScenarioHint",app:"viewAppHint"},mn=(e,t,r)=>d`<nav class="view-switch" aria-label=${t.viewLabel}>
6
+ `},bn={scenario:"viewScenario",app:"viewApp"},wn={scenario:"viewScenarioHint",app:"viewAppHint"},mn=(e,t,r)=>d`<nav class="view-switch" aria-label=${t.viewLabel}>
7
7
  ${yi.map(i=>d`<a
8
8
  class="view-option"
9
9
  href=${e.hashFor(yt(i))}
10
- title=${t[bn[i]]}
10
+ title=${t[wn[i]]}
11
11
  aria-current=${i===r?"page":c}
12
12
  data-view=${i}
13
- >${t[wn[i]]}</a
13
+ >${t[bn[i]]}</a
14
14
  >`)}
15
15
  </nav>`,yn=(e,t,r)=>{const i=r?.kind==="screen"?r:void 0,n=Vt(e.state),o=Yt(n,r),s={context:e,currentId:i?.screen.id},a=o?.others??[];return d`
16
16
  ${n.length>1&&o?kn(e,t,n,o):c}
@@ -96,10 +96,10 @@ import{aj as x,aO as Ir,ae as C,aA as R,aB as g,ah as u,af as z,ai as ce,ad as P
96
96
  <span class="dpk-label">${s.length}</span>
97
97
  </div>
98
98
  <ol class="steps">
99
- ${Lr(s,l=>ve(n,o,l),(l,w)=>{const h=ve(n,o,l),v=e.commentCount({type:"step",id:h})+Tt(e.comments,Ii(i,l).map(I=>I.id));return d`
99
+ ${Lr(s,l=>ve(n,o,l),(l,b)=>{const h=ve(n,o,l),v=e.commentCount({type:"step",id:h})+Tt(e.comments,Ii(i,l).map(I=>I.id));return d`
100
100
  <li class="step-row" data-current=${String(l.id===a?.id)}>
101
101
  <a class="step-link" href=${e.hashFor({activity:n.id,story:o.id,step:l.id})}>
102
- <span class="step-index">${String(w+1).padStart(2,"0")}</span>
102
+ <span class="step-index">${String(b+1).padStart(2,"0")}</span>
103
103
  <span class="step-name">${l.name}</span>
104
104
  ${v>0?d`<span class="step-note">${v}</span>`:c}
105
105
  </a>
@@ -185,7 +185,7 @@ import{aj as x,aO as Ir,ae as C,aA as R,aB as g,ah as u,af as z,ai as ce,ad as P
185
185
  <button class="demo-control demo-exit" type="button" title=${e.exitDemo} @click=${t.onExit}>
186
186
  ${Re()} ${e.exitDemo} <kbd>Esc</kbd>
187
187
  </button>
188
- </div>`,fr={mobile:"390px",tablet:"834px",desktop:"1180px",fluid:"100%"},wr={mobile:"620px",tablet:"640px",desktop:"520px",fluid:"420px"},Pn={browser:0,native:22,mail:0,plain:0},br=(e,t,r)=>{const i=`--frame-width:${fr[t]};--frame-min-height:${wr[t]}`;if(r?.kind!=="device")return i;const n=Pn[e];return`${i};--device-width:${r.width+n}px;--device-height:${r.height+n}px;zoom:${r.zoom}`},_n=O(zr),Rn=O(Vr),Dn=O(ri),Cn=O(Qr),He=O(Jr),On=(e,t,r)=>{const i=t.length-1;if(e==="ArrowRight")return t[r===i?0:r+1];if(e==="ArrowLeft")return t[r===0?i:r-1];if(e==="Home")return t[0];if(e==="End")return t[i]},Mn=(e,t)=>{const{view:r,send:i}=t,n=o=>s=>{const a=r.tabs[o],p=s.key==="Enter"||s.key===" "?a:On(s.key,r.tabs,o);p!==void 0&&(s.preventDefault(),i({kind:"activate",id:p.id,focus:!0}))};return d`<div class="browser-tabs">
188
+ </div>`,fr={mobile:"390px",tablet:"834px",desktop:"1180px",fluid:"100%"},br={mobile:"620px",tablet:"640px",desktop:"520px",fluid:"420px"},Pn={browser:0,native:22,mail:0,plain:0},wr=(e,t,r)=>{const i=`--frame-width:${fr[t]};--frame-min-height:${br[t]}`;if(r?.kind!=="device")return i;const n=Pn[e];return`${i};--device-width:${r.width+n}px;--device-height:${r.height+n}px;zoom:${r.zoom}`},_n=O(zr),Rn=O(Vr),Dn=O(ri),Cn=O(Qr),He=O(Jr),On=(e,t,r)=>{const i=t.length-1;if(e==="ArrowRight")return t[r===i?0:r+1];if(e==="ArrowLeft")return t[r===0?i:r-1];if(e==="Home")return t[0];if(e==="End")return t[i]},Mn=(e,t)=>{const{view:r,send:i}=t,n=o=>s=>{const a=r.tabs[o],p=s.key==="Enter"||s.key===" "?a:On(s.key,r.tabs,o);p!==void 0&&(s.preventDefault(),i({kind:"activate",id:p.id,focus:!0}))};return d`<div class="browser-tabs">
189
189
  <div class="browser-tab-list" role="tablist" aria-label=${e.browserTabs}>
190
190
  ${r.tabs.map((o,s)=>d`<div
191
191
  class="browser-tab"
@@ -305,7 +305,7 @@ import{aj as x,aO as Ir,ae as C,aA as R,aB as g,ah as u,af as z,ai as ce,ad as P
305
305
  ?data-loading=${r.loading}
306
306
  ?data-empty=${n!==void 0&&!r.hasContent}
307
307
  data-window=${r.window.kind}
308
- style=${br("browser",o,r.window)}
308
+ style=${wr("browser",o,r.window)}
309
309
  >
310
310
  ${a?c:Mn(t,r)} ${Nn(t,r,a)}
311
311
  <div class="browser-progress" aria-hidden="true"></div>
@@ -333,7 +333,7 @@ import{aj as x,aO as Ir,ae as C,aA as R,aB as g,ah as u,af as z,ai as ce,ad as P
333
333
  </p>`}
334
334
  ${p}
335
335
  </div>
336
- `;const l=Ye(i,s,n),{layout:w,panes:h,shown:v}=l,[I]=w==="single"?h:[],P=r.uiComment,S=r.lift,V=S?.mode==="demo",F=r.browser,je=F!==null&&F.view.entry?.kind!=="page"?[]:v,[j]=je,le=(j??v[0])?.viewport??"desktop",qe=V&&F!==null&&le!=="mobile",Ke={onExit:r.onToggleDemo,uiComment:P},Ar=j??v[0],Xe=F!==null?"browser":Ar?.kind??"browser",Ze=V&&Xe==="browser"&&sr(le)==="desktop",q=r.devices,ee=q===null||Ze||!un(Xe)?null:hn(le,q.choice),Je=ee!==null&&q!==null?{kind:"device",width:ee.width,height:ee.height,zoom:q.zoom}:Ze?{kind:"fill"}:null;return d`
336
+ `;const l=Ye(i,s,n),{layout:b,panes:h,shown:v}=l,[I]=b==="single"?h:[],P=r.uiComment,S=r.lift,V=S?.mode==="demo",F=r.browser,je=F!==null&&F.view.entry?.kind!=="page"?[]:v,[j]=je,le=(j??v[0])?.viewport??"desktop",qe=V&&F!==null&&le!=="mobile",Ke={onExit:r.onToggleDemo,uiComment:P},Ar=j??v[0],Xe=F!==null?"browser":Ar?.kind??"browser",Ze=V&&Xe==="browser"&&sr(le)==="desktop",q=r.devices,ee=q===null||Ze||!un(Xe)?null:hn(le,q.choice),Je=ee!==null&&q!==null?{kind:"device",width:ee.width,height:ee.height,zoom:q.zoom}:Ze?{kind:"fill"}:null;return d`
337
337
  ${S===null?c:d`<div class="stage-placeholder" style=${`height:${S.height}px`}></div>`}
338
338
  <div
339
339
  class=${S===null?"stage":V?"stage is-demo":"stage is-maximized"}
@@ -354,7 +354,7 @@ import{aj as x,aO as Ir,ae as C,aA as R,aB as g,ah as u,af as z,ai as ce,ad as P
354
354
  ${V?c:Tn(t,P)}
355
355
  <div
356
356
  class="canvas"
357
- data-layout=${w}
357
+ data-layout=${b}
358
358
  data-dpk-target=${At(s,l)}
359
359
  @click=${{handleEvent:r.canvasEvents.click,capture:!0}}
360
360
  @pointermove=${{handleEvent:r.canvasEvents.pointermove,capture:!0}}
@@ -362,7 +362,7 @@ import{aj as x,aO as Ir,ae as C,aA as R,aB as g,ah as u,af as z,ai as ce,ad as P
362
362
  @wheel=${{handleEvent:r.canvasEvents.wheel,passive:!1}}
363
363
  @scroll=${{handleEvent:r.canvasEvents.scroll,capture:!0}}
364
364
  >
365
- ${F!==null?Wn(e,t,{...F,...j===void 0?{}:{preview:j},...qe?{demo:Ke}:{},hasContent:j===void 0||r.hasPreviewContent(j.id),viewport:le,window:Je??{kind:"fill"}}):w==="side-by-side"?d`<div class="panes">
365
+ ${F!==null?Wn(e,t,{...F,...j===void 0?{}:{preview:j},...qe?{demo:Ke}:{},hasContent:j===void 0||r.hasPreviewContent(j.id),viewport:le,window:Je??{kind:"fill"}}):b==="side-by-side"?d`<div class="panes">
366
366
  ${h.map(_=>d`<div class="pane" data-viewport=${_.preview.viewport} data-pane=${_.kind}>
367
367
  ${jn(e,l,_)}
368
368
  ${Ge(e,t,_.preview,r.hasPreviewContent(_.preview.id))}
@@ -423,7 +423,7 @@ import{aj as x,aO as Ir,ae as C,aA as R,aB as g,ah as u,af as z,ai as ce,ad as P
423
423
  data-viewport=${r.viewport}
424
424
  data-window=${n?.kind??c}
425
425
  ?data-empty=${!i}
426
- style=${br(r.kind,r.viewport,n)}
426
+ style=${wr(r.kind,r.viewport,n)}
427
427
  >
428
428
  ${r.kind==="browser"?d`<div class="chrome">
429
429
  <span class="dots"><i></i><i></i><i></i></span>
@@ -476,18 +476,6 @@ import{aj as x,aO as Ir,ae as C,aA as R,aB as g,ah as u,af as z,ai as ce,ad as P
476
476
  --dpk-prototype-accent: var(--dpk-blue);
477
477
  }
478
478
 
479
- /*
480
- * The sidebar and the main column scroll on their own, with the memo pinned
481
- * to the bottom of the main column, only inside a bounded shell. A page that
482
- * gives the host no height would grow the shell to its longest column and
483
- * scroll the whole document, carrying the memo off screen; the viewport
484
- * height is the fallback. A host with a height still wins: the shell's own
485
- * min/max-height pin it to that.
486
- */
487
- .dpk-shell {
488
- height: 100dvh;
489
- }
490
-
491
479
  /* ---------------------------------------------------------------- sidebar */
492
480
 
493
481
  .nav {
@@ -2452,6 +2440,6 @@ import{aj as x,aO as Ir,ae as C,aA as R,aB as g,ah as u,af as z,ai as ce,ad as P
2452
2440
  max-height: calc(100% - 32px);
2453
2441
  margin: auto;
2454
2442
  }
2455
- `,Fe={kind:"off"},to=(e,t)=>{switch(t.kind){case"toggle":return e.kind==="off"?{kind:"picking"}:Fe;case"exit":return Fe;case"pick":return e.kind==="off"?e:{kind:"composing",target:t.target,body:e.kind==="composing"?e.body:""};case"input":return e.kind==="composing"?{...e,body:t.body}:e;case"dismiss":case"submitted":return e.kind==="off"?e:{kind:"picking"};default:return e}},ro={width:300,height:300},io=360,Er="dpk-template-prototype-document-styles",no=24,oo=()=>{if(document.getElementById(Er)!==null)return;const e=Object.assign(document.createElement("style"),{id:Er,textContent:eo});document.head.append(e)},so=(e,t,r)=>{const i=getComputedStyle(e),n=/auto|scroll/.test(i.overflowX)&&e.scrollWidth>e.clientWidth,o=/auto|scroll/.test(i.overflowY)&&e.scrollHeight>e.clientHeight,s=t<0?e.scrollLeft>0:t>0&&e.scrollLeft+e.clientWidth<e.scrollWidth-1,a=r<0?e.scrollTop>0:r>0&&e.scrollTop+e.clientHeight<e.scrollHeight-1;return n&&s||o&&a},ao=e=>{if(e.assignedSlot!==null)return e.assignedSlot;if(e.parentElement!==null)return e.parentElement;const t=e.getRootNode();return t instanceof ShadowRoot?t.host:null};class Sr extends nt{static{this.styles=[nt.styles,Hr,Gr,Qn]}#e=Fe;#u=!1;#s=null;#o=[];#C=new Fr(this);#y=!1;#t=null;#r=null;#k=!1;#p=!1;#h=!1;#i=null;#v=null;#g={};#f=1;#l=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>this.#P());#a=null;definitionFor(t){return Ut(t)}connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",this.#T),window.addEventListener("resize",this.#w),this.addEventListener("toggle",this.#_,!0),this.addEventListener("click",this.#c,!0),this.addEventListener("auxclick",this.#c,!0),oo()}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.#T),window.removeEventListener("resize",this.#w),this.removeEventListener("toggle",this.#_,!0),this.removeEventListener("click",this.#c,!0),this.removeEventListener("auxclick",this.#c,!0),this.#l?.disconnect(),this.#a=null,this.#D()}renderRegions(t){const r=fe(this.locale),i=Z(t.state,t.navigation),n=se(t.navigation)==="app";this.#t!==null&&this.#t.mode==="demo"!==n&&this.#R();const o=n?this.#j(t,r):null;return this.#k=o!==null,this.#o=i!==void 0&&i.kind!=="story"&&(o===null||o.view.entry?.kind==="page")?Ye(t.state,i,t.navigation).shown.map(s=>s.id):[],this.#i!==null&&this.#i.page!==this.#o.join(" ")&&this.#D(),{sidebar:dr(t,r),main:yr(t,r,{hasPreviewContent:s=>this.#Q(s),lift:this.#t,onToggleMaximize:()=>this.#m(this.#t===null?"maximized":null),onToggleDemo:()=>this.#m(this.#t===null?"demo":null),onLiftedWheel:this.#F,browser:o===null?null:{...o,loading:this.#i!==null},devices:n?{choice:this.#g,zoom:this.#f,onPick:s=>{this.#g=vn(this.#g,s),this.requestUpdate()}}:null,uiComment:this.#O(t),canvasEvents:{click:this.#N,pointermove:this.#z,pointerleave:this.#V,wheel:this.#Y,scroll:this.#w}})}}updated(){super.updated(),this.#H(),this.#W(),this.#U(),this.#P();const t=this.#e;if(t.kind==="composing"&&!this.#o.includes(t.target.previewId)){this.#d({kind:"dismiss"});return}this.#G(),this.#h&&(this.#h=!1,this.renderRoot.querySelector('.browser-tab[aria-selected="true"]')?.focus()),this.#A();const r=t.kind==="composing"&&!this.#u;if(this.#u=t.kind==="composing",t.kind!=="composing"||this.#s===null)return;const i=this.renderRoot.querySelector(".comment-pop");i&&(this.#C.open(i,this.#s,ro,{placement:"right-start"}),r&&i.querySelector("textarea")?.focus({preventScroll:!0}))}#O(t){const r=this.#e,i=r.kind==="composing"?r.target:void 0,n=i?A(t.state,i.previewId)?.preview:void 0,o=i?ut(i):void 0;return{mode:r,pins:r.kind==="off"?[]:St(t.comments,this.#o),...i&&n?{targetLabel:Et(n,i)}:{},notes:t.comments.filter(s=>s.target.type===re&&s.target.id===o).map(s=>et(s)),composer:Zr(this.locale),send:s=>this.#d(s),submit:s=>this.#M(s)}}#d(t){const r=to(this.#e,t);r!==this.#e&&(this.#e=r,r.kind!=="composing"&&(this.#s=null),this.requestUpdate())}#M(t){const r=this.#e;if(r.kind!=="composing")return;this.dispatch({type:jr,target:{type:re,id:ut(r.target)},payload:{body:t}}).ok&&this.#d({kind:"submitted"})}#x(t){const r=t.composedPath(),i=r[0];if(i instanceof Element&&i.classList.contains("ui-catcher"))return this.#L(t.clientX,t.clientY);const n=r.find(o=>o instanceof Element&&o.parentElement===this&&o.hasAttribute("data-preview-id"));return!n||!(i instanceof Element)||!n.contains(i)?null:this.#E(i,n)}#L(t,r){const i=this.#$(t,r);return i===null?null:this.#E(i.element,i.wrapper)}#$(t,r){if(typeof document.elementsFromPoint!="function")return null;const i=this.#S();for(const n of document.elementsFromPoint(t,r)){const o=i.find(s=>s.contains(n));if(o!==void 0)return{element:n,wrapper:o}}return null}#E(t,r){const i=r.getAttribute("data-preview-id");if(!i)return null;const n=Gi(t,r),o=Ki(n,r);return{element:n,target:{previewId:i,selector:o.selector,...o.text===void 0?{}:{text:o.text}}}}#S(){return Array.from(this.children).filter(t=>{const r=t.getAttribute("data-preview-id");return r!==null&&this.#o.includes(r)})}#N=t=>{if(this.#e.kind==="off")return;const r=this.#x(t);r&&(t.preventDefault(),t.stopPropagation(),this.#s=r.element,this.#d({kind:"pick",target:r.target}))};#z=t=>{if(this.#e.kind==="off")return;const r=this.#x(t);this.#b(".ui-hover",r?.element??null)};#V=()=>{this.#b(".ui-hover",null)};#Y=t=>{const r=t.composedPath()[0];if(!(r instanceof Element)||!r.classList.contains("ui-catcher"))return;const i=this.renderRoot.querySelector(".canvas");let n=this.#$(t.clientX,t.clientY)?.element??null;for(;n!==null&&n!==i;){if(so(n,t.deltaX,t.deltaY)){t.preventDefault(),n.scrollBy({left:t.deltaX,top:t.deltaY});return}n=ao(n)}};#T=t=>{t.key!=="Escape"||t.defaultPrevented||(this.#e.kind!=="off"?this.#d({kind:"exit"}):this.#m(null))};#w=()=>{this.#e.kind!=="off"&&this.#A()};#A(){if(this.#e.kind==="off")return;this.#b(".ui-picked",this.#s);const t=this.renderRoot.querySelector(".canvas");if(!t)return;const r=this.renderRoot.querySelector(".ui-catcher");if(r){r.style.width=`${t.scrollWidth}px`,r.style.height=`${t.scrollHeight}px`;const i=[...this.renderRoot.querySelectorAll(".demo-controls")].map(n=>n.getBoundingClientRect());r.style.clipPath=Wi(r.getBoundingClientRect(),i)}for(const i of this.renderRoot.querySelectorAll(".ui-pin")){const n=this.#B(i.dataset.preview??""),s=(n?Xi(n,i.dataset.selector??""):null)?.getBoundingClientRect();if(!s||s.width===0&&s.height===0){i.hidden=!0;continue}const a=this.#I(t);i.hidden=!1,i.style.left=`${s.right-a.left}px`,i.style.top=`${s.top-a.top}px`}}#b(t,r){const i=this.renderRoot.querySelector(t),n=this.renderRoot.querySelector(".canvas");if(!i||!n)return;const o=r?.getBoundingClientRect();if(!o){i.hidden=!0;return}const s=this.#I(n);i.hidden=!1,i.style.left=`${o.left-s.left}px`,i.style.top=`${o.top-s.top}px`,i.style.width=`${o.width}px`,i.style.height=`${o.height}px`}#I(t){const r=t.getBoundingClientRect();return{left:r.left+t.clientLeft-t.scrollLeft,top:r.top+t.clientTop-t.scrollTop}}#U(){const t=this.renderRoot.querySelector(".canvas");t===this.#a||this.#l===null||(this.#a!==null&&this.#l.unobserve(this.#a),this.#a=t,t!==null&&this.#l.observe(t))}#P(){const t=this.renderRoot.querySelector('.frame[data-window="device"]'),r=t?.closest(".canvas");if(!t||!(r instanceof HTMLElement))return;const i=getComputedStyle(t),n={width:parseFloat(i.getPropertyValue("--device-width")),height:parseFloat(i.getPropertyValue("--device-height"))},o=getComputedStyle(r),s=r.clientWidth-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight),a=this.#t?.mode==="demo",p=a?no*2:0,l=fn(n,{width:s-p,...a?{height:r.clientHeight-p}:{}});l!==this.#f&&(this.#f=l,this.requestUpdate())}#W(){for(const t of this.querySelectorAll(":scope > [data-preview-id]"))for(const r of t.querySelectorAll("dialog"))Bt(r),Ht(this,r)}#_=t=>{const r=t.target;!(r instanceof HTMLDialogElement)||!r.open||Array.from(this.children).some(i=>i.hasAttribute("data-preview-id")&&i.contains(r))&&(Bt(r),Ht(this,r))};#B(t){return Array.from(this.children).find(r=>r.getAttribute("data-preview-id")===t)}#H(){if(this.#y||this.renderRoot.querySelector(".stage")===null)return;this.#y=!0;const t=this.derivation.state,r=[];for(const i of Array.from(this.children)){const n=i.getAttribute("data-preview-id");if(n!==null)for(const o of i.querySelectorAll("a, [data-dpk-navigate]")){const s=Ri(t,{href:o.getAttribute("href"),navigate:o.getAttribute("data-dpk-navigate")});if(s===null)continue;const a=(o.textContent??"").replace(/\s+/g," ").trim().slice(0,40),p=o.getAttribute("data-dpk-navigate")??o.getAttribute("href")??"(no href)";r.push(` ${n}: <${o.tagName.toLowerCase()}> "${a}" \u2192 ${p} (${s})`)}}r.length!==0&&console.warn(`[dev-process-kit] <dpk-template-prototype>: ${r.length} link(s) in the previews lead nowhere. Point each at the screen it opens (data-dpk-navigate="screen=\u2026"); a link that only moves the scenario on can name a step (data-dpk-navigate="step=\u2026") or a user story (data-dpk-navigate="story=\u2026"):
2443
+ `,Fe={kind:"off"},to=(e,t)=>{switch(t.kind){case"toggle":return e.kind==="off"?{kind:"picking"}:Fe;case"exit":return Fe;case"pick":return e.kind==="off"?e:{kind:"composing",target:t.target,body:e.kind==="composing"?e.body:""};case"input":return e.kind==="composing"?{...e,body:t.body}:e;case"dismiss":case"submitted":return e.kind==="off"?e:{kind:"picking"};default:return e}},ro={width:300,height:300},io=360,Er="dpk-template-prototype-document-styles",no=24,oo=()=>{if(document.getElementById(Er)!==null)return;const e=Object.assign(document.createElement("style"),{id:Er,textContent:eo});document.head.append(e)},so=(e,t,r)=>{const i=getComputedStyle(e),n=/auto|scroll/.test(i.overflowX)&&e.scrollWidth>e.clientWidth,o=/auto|scroll/.test(i.overflowY)&&e.scrollHeight>e.clientHeight,s=t<0?e.scrollLeft>0:t>0&&e.scrollLeft+e.clientWidth<e.scrollWidth-1,a=r<0?e.scrollTop>0:r>0&&e.scrollTop+e.clientHeight<e.scrollHeight-1;return n&&s||o&&a},ao=e=>{if(e.assignedSlot!==null)return e.assignedSlot;if(e.parentElement!==null)return e.parentElement;const t=e.getRootNode();return t instanceof ShadowRoot?t.host:null};class Sr extends nt{static{this.styles=[nt.styles,Hr,Gr,Qn]}#e=Fe;#u=!1;#s=null;#o=[];#C=new Fr(this);#y=!1;#t=null;#r=null;#k=!1;#p=!1;#h=!1;#i=null;#v=null;#g={};#f=1;#l=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>this.#P());#a=null;definitionFor(t){return Ut(t)}connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",this.#T),window.addEventListener("resize",this.#b),this.addEventListener("toggle",this.#_,!0),this.addEventListener("click",this.#c,!0),this.addEventListener("auxclick",this.#c,!0),oo()}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.#T),window.removeEventListener("resize",this.#b),this.removeEventListener("toggle",this.#_,!0),this.removeEventListener("click",this.#c,!0),this.removeEventListener("auxclick",this.#c,!0),this.#l?.disconnect(),this.#a=null,this.#D()}renderRegions(t){const r=fe(this.locale),i=Z(t.state,t.navigation),n=se(t.navigation)==="app";this.#t!==null&&this.#t.mode==="demo"!==n&&this.#R();const o=n?this.#j(t,r):null;return this.#k=o!==null,this.#o=i!==void 0&&i.kind!=="story"&&(o===null||o.view.entry?.kind==="page")?Ye(t.state,i,t.navigation).shown.map(s=>s.id):[],this.#i!==null&&this.#i.page!==this.#o.join(" ")&&this.#D(),{sidebar:dr(t,r),main:yr(t,r,{hasPreviewContent:s=>this.#Q(s),lift:this.#t,onToggleMaximize:()=>this.#m(this.#t===null?"maximized":null),onToggleDemo:()=>this.#m(this.#t===null?"demo":null),onLiftedWheel:this.#F,browser:o===null?null:{...o,loading:this.#i!==null},devices:n?{choice:this.#g,zoom:this.#f,onPick:s=>{this.#g=vn(this.#g,s),this.requestUpdate()}}:null,uiComment:this.#O(t),canvasEvents:{click:this.#N,pointermove:this.#z,pointerleave:this.#V,wheel:this.#Y,scroll:this.#b}})}}updated(){super.updated(),this.#H(),this.#W(),this.#U(),this.#P();const t=this.#e;if(t.kind==="composing"&&!this.#o.includes(t.target.previewId)){this.#d({kind:"dismiss"});return}this.#G(),this.#h&&(this.#h=!1,this.renderRoot.querySelector('.browser-tab[aria-selected="true"]')?.focus()),this.#A();const r=t.kind==="composing"&&!this.#u;if(this.#u=t.kind==="composing",t.kind!=="composing"||this.#s===null)return;const i=this.renderRoot.querySelector(".comment-pop");i&&(this.#C.open(i,this.#s,ro,{placement:"right-start"}),r&&i.querySelector("textarea")?.focus({preventScroll:!0}))}#O(t){const r=this.#e,i=r.kind==="composing"?r.target:void 0,n=i?A(t.state,i.previewId)?.preview:void 0,o=i?ut(i):void 0;return{mode:r,pins:r.kind==="off"?[]:St(t.comments,this.#o),...i&&n?{targetLabel:Et(n,i)}:{},notes:t.comments.filter(s=>s.target.type===re&&s.target.id===o).map(s=>et(s)),composer:Zr(this.locale),send:s=>this.#d(s),submit:s=>this.#M(s)}}#d(t){const r=to(this.#e,t);r!==this.#e&&(this.#e=r,r.kind!=="composing"&&(this.#s=null),this.requestUpdate())}#M(t){const r=this.#e;if(r.kind!=="composing")return;this.dispatch({type:jr,target:{type:re,id:ut(r.target)},payload:{body:t}}).ok&&this.#d({kind:"submitted"})}#x(t){const r=t.composedPath(),i=r[0];if(i instanceof Element&&i.classList.contains("ui-catcher"))return this.#L(t.clientX,t.clientY);const n=r.find(o=>o instanceof Element&&o.parentElement===this&&o.hasAttribute("data-preview-id"));return!n||!(i instanceof Element)||!n.contains(i)?null:this.#E(i,n)}#L(t,r){const i=this.#$(t,r);return i===null?null:this.#E(i.element,i.wrapper)}#$(t,r){if(typeof document.elementsFromPoint!="function")return null;const i=this.#S();for(const n of document.elementsFromPoint(t,r)){const o=i.find(s=>s.contains(n));if(o!==void 0)return{element:n,wrapper:o}}return null}#E(t,r){const i=r.getAttribute("data-preview-id");if(!i)return null;const n=Gi(t,r),o=Ki(n,r);return{element:n,target:{previewId:i,selector:o.selector,...o.text===void 0?{}:{text:o.text}}}}#S(){return Array.from(this.children).filter(t=>{const r=t.getAttribute("data-preview-id");return r!==null&&this.#o.includes(r)})}#N=t=>{if(this.#e.kind==="off")return;const r=this.#x(t);r&&(t.preventDefault(),t.stopPropagation(),this.#s=r.element,this.#d({kind:"pick",target:r.target}))};#z=t=>{if(this.#e.kind==="off")return;const r=this.#x(t);this.#w(".ui-hover",r?.element??null)};#V=()=>{this.#w(".ui-hover",null)};#Y=t=>{const r=t.composedPath()[0];if(!(r instanceof Element)||!r.classList.contains("ui-catcher"))return;const i=this.renderRoot.querySelector(".canvas");let n=this.#$(t.clientX,t.clientY)?.element??null;for(;n!==null&&n!==i;){if(so(n,t.deltaX,t.deltaY)){t.preventDefault(),n.scrollBy({left:t.deltaX,top:t.deltaY});return}n=ao(n)}};#T=t=>{t.key!=="Escape"||t.defaultPrevented||(this.#e.kind!=="off"?this.#d({kind:"exit"}):this.#m(null))};#b=()=>{this.#e.kind!=="off"&&this.#A()};#A(){if(this.#e.kind==="off")return;this.#w(".ui-picked",this.#s);const t=this.renderRoot.querySelector(".canvas");if(!t)return;const r=this.renderRoot.querySelector(".ui-catcher");if(r){r.style.width=`${t.scrollWidth}px`,r.style.height=`${t.scrollHeight}px`;const i=[...this.renderRoot.querySelectorAll(".demo-controls")].map(n=>n.getBoundingClientRect());r.style.clipPath=Wi(r.getBoundingClientRect(),i)}for(const i of this.renderRoot.querySelectorAll(".ui-pin")){const n=this.#B(i.dataset.preview??""),s=(n?Xi(n,i.dataset.selector??""):null)?.getBoundingClientRect();if(!s||s.width===0&&s.height===0){i.hidden=!0;continue}const a=this.#I(t);i.hidden=!1,i.style.left=`${s.right-a.left}px`,i.style.top=`${s.top-a.top}px`}}#w(t,r){const i=this.renderRoot.querySelector(t),n=this.renderRoot.querySelector(".canvas");if(!i||!n)return;const o=r?.getBoundingClientRect();if(!o){i.hidden=!0;return}const s=this.#I(n);i.hidden=!1,i.style.left=`${o.left-s.left}px`,i.style.top=`${o.top-s.top}px`,i.style.width=`${o.width}px`,i.style.height=`${o.height}px`}#I(t){const r=t.getBoundingClientRect();return{left:r.left+t.clientLeft-t.scrollLeft,top:r.top+t.clientTop-t.scrollTop}}#U(){const t=this.renderRoot.querySelector(".canvas");t===this.#a||this.#l===null||(this.#a!==null&&this.#l.unobserve(this.#a),this.#a=t,t!==null&&this.#l.observe(t))}#P(){const t=this.renderRoot.querySelector('.frame[data-window="device"]'),r=t?.closest(".canvas");if(!t||!(r instanceof HTMLElement))return;const i=getComputedStyle(t),n={width:parseFloat(i.getPropertyValue("--device-width")),height:parseFloat(i.getPropertyValue("--device-height"))},o=getComputedStyle(r),s=r.clientWidth-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight),a=this.#t?.mode==="demo",p=a?no*2:0,l=fn(n,{width:s-p,...a?{height:r.clientHeight-p}:{}});l!==this.#f&&(this.#f=l,this.requestUpdate())}#W(){for(const t of this.querySelectorAll(":scope > [data-preview-id]"))for(const r of t.querySelectorAll("dialog"))Bt(r),Ht(this,r)}#_=t=>{const r=t.target;!(r instanceof HTMLDialogElement)||!r.open||Array.from(this.children).some(i=>i.hasAttribute("data-preview-id")&&i.contains(r))&&(Bt(r),Ht(this,r))};#B(t){return Array.from(this.children).find(r=>r.getAttribute("data-preview-id")===t)}#H(){if(this.#y||this.renderRoot.querySelector(".stage")===null)return;this.#y=!0;const t=this.derivation.state,r=[];for(const i of Array.from(this.children)){const n=i.getAttribute("data-preview-id");if(n!==null)for(const o of i.querySelectorAll("a, [data-dpk-navigate]")){const s=Ri(t,{href:o.getAttribute("href"),navigate:o.getAttribute("data-dpk-navigate")});if(s===null)continue;const a=(o.textContent??"").replace(/\s+/g," ").trim().slice(0,40),p=o.getAttribute("data-dpk-navigate")??o.getAttribute("href")??"(no href)";r.push(` ${n}: <${o.tagName.toLowerCase()}> "${a}" \u2192 ${p} (${s})`)}}r.length!==0&&console.warn(`[dev-process-kit] <dpk-template-prototype>: ${r.length} link(s) in the previews lead nowhere. Point each at the screen it opens (data-dpk-navigate="screen=\u2026"); a link that only moves the scenario on can name a step (data-dpk-navigate="step=\u2026") or a user story (data-dpk-navigate="story=\u2026"):
2456
2444
  `+r.join(`
2457
- `))}#m(t){if(t===(this.#t?.mode??null))return;const r=this.renderRoot.querySelector(".stage"),i=this.#t?.height??r?.offsetHeight??0;this.#R(),t!==null&&(this.#t={mode:t,height:i}),t!==null&&this.#e.kind==="composing"&&(qr(this.renderRoot.querySelector(".comment-pop")),this.#u=!1),this.requestUpdate()}#R(){this.#t=null,this.#v=null}#G(){const t=this.renderRoot.querySelector(".stage");if(!(this.#t===null||!t||typeof t.showPopover!="function")&&t!==this.#v){this.#v=t;try{t.showPopover()}catch{}}}#F=t=>{const r=this.renderRoot.querySelector(".canvas");(r===null||!t.composedPath().includes(r))&&t.preventDefault()};#j(t,r){const i=Jt(t.state,t.navigation);this.#r=this.#r===null?i===null?null:Ji(i):Zt(this.#r,{kind:"observe",page:i});const n=this.#r;if(n===null)return null;const o=pe(n),s=o?.kind!=="page"&&n.seen!==null;if(i===null&&!s)return null;const a=pn(n)??i;return{view:nr(t.state,n,r,a),shortcuts:o?.kind==="new-tab"?ln(t.state,a):[],switcher:this.#p,send:p=>this.#K(p)}}#n(t){if(this.#r===null)return;const r=Zt(this.#r,t);if(r===this.#r)return;this.#r=r;const i=pe(r);i?.kind==="page"&&this.#q(i.page),this.requestUpdate()}#q(t){this.navigate({screen:t.screen??null,preview:t.preview??null})}#K(t){switch(t.kind){case"reload":this.#Z();return;case"address":this.#X(t.input);return;case"back":case"forward":case"new-tab":this.#p=!1,this.#n({kind:t.kind});return;case"switcher":this.#p=t.open,this.requestUpdate();return;case"activate":this.#p=!1,this.#h=t.focus===!0,this.#n({kind:"activate",id:t.id}),this.requestUpdate();return;case"close-tab":this.#n({kind:t.kind,id:t.id});return;case"visit":this.#n({kind:"visit",page:t.page});return;default:return}}#X(t){const r=this.#r;if(r===null)return;const i=this.derivation.state,n=nr(i,r,fe(this.locale)).url||"https://page.example.com/",o=sn(i,t,n);if(o!==null){this.#n({kind:"visit",page:o});return}const s=t.trim(),a=s.startsWith("/")?new URL(s,n).href:/^[a-z][a-z0-9+.-]*:\/\//i.test(s)?s:`https://${s}`;this.#n({kind:"unreachable",url:a})}#Z(){if(this.#i!==null)return;const t=setTimeout(()=>{this.#i=null;for(const r of this.#S()){for(const i of r.querySelectorAll("form"))i.reset();for(const i of r.querySelectorAll("dialog"))i.close();r.scrollTop=0,r.dispatchEvent(new CustomEvent("dpk-reload",{bubbles:!0}))}this.renderRoot.querySelector(".browser .viewport")?.scrollTo?.({top:0}),this.requestUpdate()},io);this.#i={page:this.#o.join(" "),timer:t},this.requestUpdate()}#D(){this.#i!==null&&(clearTimeout(this.#i.timer),this.#i=null)}#c=t=>{if(!this.#k||this.#e.kind!=="off"||this.#r===null||t.type==="auxclick"&&t.button!==1)return;const r=this.#J(t);if(r===null)return;const i=t.metaKey||t.ctrlKey||t.button===1;if(!r.blank&&!i)return;t.preventDefault(),t.stopPropagation();const n=Jt(this.derivation.state,Ae(this.hashFor(r.patch)));if(n===null){i||this.navigate(r.patch);return}this.#n({kind:"open-tab",entry:{kind:"page",page:n},background:i})};#J(t){const r=t.composedPath();if(!r.some(n=>n instanceof Element&&n.parentElement===this&&n.hasAttribute("data-preview-id")))return null;for(const n of r){if(!(n instanceof Element)||n===this)break;const o=n.getAttribute("data-dpk-navigate"),s=n instanceof HTMLAnchorElement?n.getAttribute("href"):null,a=o??(s?.startsWith("#")?s:null);if(a===null)continue;const p=o!==null&&!o.includes("=")?`step=${o}`:a;return{patch:{...Ae(p)},blank:n.getAttribute("target")==="_blank"}}return null}#Q(t){return Array.from(this.querySelectorAll("[data-preview-id]")).some(r=>r.getAttribute("data-preview-id")===t)}}const Tr=()=>{customElements.get("dpk-template-prototype")||customElements.define("dpk-template-prototype",Sr)},po=Object.freeze(Object.defineProperty({__proto__:null,DpkTemplatePrototype:Sr,VIEWPORT_MIN_HEIGHT:wr,VIEWPORT_WIDTH:fr,allScreens:W,allStepIds:ft,applyPrototypeAction:wt,definePrototypeElement:Tr,describePrototypeAction:kt,emptyPrototypeBase:vt,findActivity:L,findPreview:A,findScreen:M,findStep:k,findStory:$,flattenSteps:B,parsePrototypeBase:ht,prototypeAction:ne,prototypeActions:f,prototypeBaseSchema:pt,prototypeCommentTargets:Ct,prototypeDefinitionFor:Ut,prototypeMessages:fe,prototypePageHeading:Ot,prototypeTargetLabel:$t,prototypeTitle:Ue,renderFrame:Ge,renderNav:dr,renderStage:yr,resolvePrototypeNavigation:ye,serializePrototypeAction:xt},Symbol.toStringTag,{value:"Module"}));export{Tr as d,po as i};
2445
+ `))}#m(t){if(t===(this.#t?.mode??null))return;const r=this.renderRoot.querySelector(".stage"),i=this.#t?.height??r?.offsetHeight??0;this.#R(),t!==null&&(this.#t={mode:t,height:i}),t!==null&&this.#e.kind==="composing"&&(qr(this.renderRoot.querySelector(".comment-pop")),this.#u=!1),this.requestUpdate()}#R(){this.#t=null,this.#v=null}#G(){const t=this.renderRoot.querySelector(".stage");if(!(this.#t===null||!t||typeof t.showPopover!="function")&&t!==this.#v){this.#v=t;try{t.showPopover()}catch{}}}#F=t=>{const r=this.renderRoot.querySelector(".canvas");(r===null||!t.composedPath().includes(r))&&t.preventDefault()};#j(t,r){const i=Jt(t.state,t.navigation);this.#r=this.#r===null?i===null?null:Ji(i):Zt(this.#r,{kind:"observe",page:i});const n=this.#r;if(n===null)return null;const o=pe(n),s=o?.kind!=="page"&&n.seen!==null;if(i===null&&!s)return null;const a=pn(n)??i;return{view:nr(t.state,n,r,a),shortcuts:o?.kind==="new-tab"?ln(t.state,a):[],switcher:this.#p,send:p=>this.#K(p)}}#n(t){if(this.#r===null)return;const r=Zt(this.#r,t);if(r===this.#r)return;this.#r=r;const i=pe(r);i?.kind==="page"&&this.#q(i.page),this.requestUpdate()}#q(t){this.navigate({screen:t.screen??null,preview:t.preview??null})}#K(t){switch(t.kind){case"reload":this.#Z();return;case"address":this.#X(t.input);return;case"back":case"forward":case"new-tab":this.#p=!1,this.#n({kind:t.kind});return;case"switcher":this.#p=t.open,this.requestUpdate();return;case"activate":this.#p=!1,this.#h=t.focus===!0,this.#n({kind:"activate",id:t.id}),this.requestUpdate();return;case"close-tab":this.#n({kind:t.kind,id:t.id});return;case"visit":this.#n({kind:"visit",page:t.page});return;default:return}}#X(t){const r=this.#r;if(r===null)return;const i=this.derivation.state,n=nr(i,r,fe(this.locale)).url||"https://page.example.com/",o=sn(i,t,n);if(o!==null){this.#n({kind:"visit",page:o});return}const s=t.trim(),a=s.startsWith("/")?new URL(s,n).href:/^[a-z][a-z0-9+.-]*:\/\//i.test(s)?s:`https://${s}`;this.#n({kind:"unreachable",url:a})}#Z(){if(this.#i!==null)return;const t=setTimeout(()=>{this.#i=null;for(const r of this.#S()){for(const i of r.querySelectorAll("form"))i.reset();for(const i of r.querySelectorAll("dialog"))i.close();r.scrollTop=0,r.dispatchEvent(new CustomEvent("dpk-reload",{bubbles:!0}))}this.renderRoot.querySelector(".browser .viewport")?.scrollTo?.({top:0}),this.requestUpdate()},io);this.#i={page:this.#o.join(" "),timer:t},this.requestUpdate()}#D(){this.#i!==null&&(clearTimeout(this.#i.timer),this.#i=null)}#c=t=>{if(!this.#k||this.#e.kind!=="off"||this.#r===null||t.type==="auxclick"&&t.button!==1)return;const r=this.#J(t);if(r===null)return;const i=t.metaKey||t.ctrlKey||t.button===1;if(!r.blank&&!i)return;t.preventDefault(),t.stopPropagation();const n=Jt(this.derivation.state,Ae(this.hashFor(r.patch)));if(n===null){i||this.navigate(r.patch);return}this.#n({kind:"open-tab",entry:{kind:"page",page:n},background:i})};#J(t){const r=t.composedPath();if(!r.some(n=>n instanceof Element&&n.parentElement===this&&n.hasAttribute("data-preview-id")))return null;for(const n of r){if(!(n instanceof Element)||n===this)break;const o=n.getAttribute("data-dpk-navigate"),s=n instanceof HTMLAnchorElement?n.getAttribute("href"):null,a=o??(s?.startsWith("#")?s:null);if(a===null)continue;const p=o!==null&&!o.includes("=")?`step=${o}`:a;return{patch:{...Ae(p)},blank:n.getAttribute("target")==="_blank"}}return null}#Q(t){return Array.from(this.querySelectorAll("[data-preview-id]")).some(r=>r.getAttribute("data-preview-id")===t)}}const Tr=()=>{customElements.get("dpk-template-prototype")||customElements.define("dpk-template-prototype",Sr)},po=Object.freeze(Object.defineProperty({__proto__:null,DpkTemplatePrototype:Sr,VIEWPORT_MIN_HEIGHT:br,VIEWPORT_WIDTH:fr,allScreens:W,allStepIds:ft,applyPrototypeAction:bt,definePrototypeElement:Tr,describePrototypeAction:kt,emptyPrototypeBase:vt,findActivity:L,findPreview:A,findScreen:M,findStep:k,findStory:$,flattenSteps:B,parsePrototypeBase:ht,prototypeAction:ne,prototypeActions:f,prototypeBaseSchema:pt,prototypeCommentTargets:Ct,prototypeDefinitionFor:Ut,prototypeMessages:fe,prototypePageHeading:Ot,prototypeTargetLabel:$t,prototypeTitle:Ue,renderFrame:Ge,renderNav:dr,renderStage:yr,resolvePrototypeNavigation:ye,serializePrototypeAction:xt},Symbol.toStringTag,{value:"Module"}));export{Tr as d,po as i};