efficient-web-builder 74.7.0 → 74.9.0

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 (55) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/editor/components/CustomHtmlCodeWindow.js +3 -3
  3. package/dist/editor/components/DuplicateToPageMenu.js +1 -1
  4. package/dist/editor/components/PagesPanel.js +1 -1
  5. package/dist/editor/components/PartSettingsPanel.js +1 -1
  6. package/dist/editor/components/PreviewPartAnchors.d.ts +2 -2
  7. package/dist/editor/components/PreviewPartAnchors.js +1 -1
  8. package/dist/editor/components/SectionTextPartBridge.js +1 -1
  9. package/dist/editor/components/SiteAccentField.js +1 -1
  10. package/dist/editor/components/SiteTextStylesField.d.ts +2 -0
  11. package/dist/editor/components/SiteTextStylesField.js +1 -1
  12. package/dist/editor/components/StandaloneSectionEditor.js +1 -1
  13. package/dist/editor/components/StorefrontEditor.js +1 -1
  14. package/dist/editor/components/storefront-editor.css +5 -5
  15. package/dist/editor/components/useSocialSettings.d.ts +2 -2
  16. package/dist/editor/lib/content/section-one-padding.d.ts +31 -0
  17. package/dist/editor/lib/content/section-one-padding.js +1 -0
  18. package/dist/editor/lib/document/blocks/general/index.d.ts +2 -2
  19. package/dist/editor/lib/document/box-fields.d.ts +1 -1
  20. package/dist/editor/lib/document/page-root.js +2 -2
  21. package/dist/format/lib/content/box-shape.d.ts +1 -1
  22. package/dist/format/lib/document/blocks/block-types.d.ts +2 -0
  23. package/dist/format/lib/document/passes/types.d.ts +2 -0
  24. package/dist/format/lib/document/style-text.d.ts +2 -0
  25. package/dist/format/lib/document/style-text.js +1 -1
  26. package/dist/format/lib/fonts.d.ts +43 -7
  27. package/dist/format/lib/fonts.js +1 -1
  28. package/dist/format/lib/site-font-faces.d.ts +9 -0
  29. package/dist/format/lib/site-font-faces.js +2 -0
  30. package/dist/format/lib/site-theme-row.d.ts +29 -1
  31. package/dist/format/lib/site-theme-row.js +1 -0
  32. package/dist/format/lib/sized-image.js +1 -1
  33. package/dist/format/lib/source-rules/one-dropdown.js +3 -3
  34. package/dist/format/lib/source-rules/page-picture-place.js +3 -3
  35. package/dist/format/lib/source-rules/published-mounts.js +38 -38
  36. package/dist/format/lib/source-rules/shape-rows-use-the-picker.js +2 -2
  37. package/dist/format/lib/source-rules/support/element-call.d.ts +5 -0
  38. package/dist/format/lib/source-rules/support/element-call.js +1 -0
  39. package/dist/format/lib/word-styles.d.ts +7 -6
  40. package/dist/format/lib/word-styles.js +1 -1
  41. package/dist/render/components/HeroPictures.d.ts +2 -2
  42. package/dist/render/components/PublishedPartStylesContext.js +1 -1
  43. package/dist/render/components/SiteFontsContext.d.ts +11 -0
  44. package/dist/render/components/SiteFontsContext.js +2 -0
  45. package/dist/render/lib/content/section-own-pads.d.ts +11 -3
  46. package/dist/render/lib/content/section-own-pads.js +1 -1
  47. package/dist/render/lib/document/part-styles.d.ts +7 -5
  48. package/dist/render/lib/document/part-styles.js +2 -2
  49. package/dist/render/lib/document/passes/section-padding.d.ts +2 -1
  50. package/dist/render/lib/document/passes/section-padding.js +1 -1
  51. package/dist/render/lib/text-styles/site-text-styles.d.ts +3 -3
  52. package/dist/render/lib/text-styles/site-text-styles.js +2 -2
  53. package/dist/routine-index.json +1 -1
  54. package/dist/value-index.json +1 -1
  55. package/package.json +1 -1
@@ -1,68 +1,68 @@
1
- import{ruleChecks as U}from"./rule.js";import{programOf as ae}from"./support/ts-program.js";function re(n){const a=[];let e=0,m=0;for(let i=0;i<n.length;i++){const l=n[i];"([{".includes(l)?e++:")]}".includes(l)?e--:l===","&&e===0&&(a.push(n.slice(m,i)),m=i+1)}return a.push(n.slice(m)),a.map(i=>i.trim()).filter(i=>i!=="")}const ie=/^[A-Za-z_$][\w$]*$/,oe=/^(?:@\/|\.\.?\/)/;function se(n,a){const e=ae(n,[{path:"mount.tsx",text:a}]);return{sf:e.getSourceFile("/mount.tsx"),checker:e.getTypeChecker()}}function pe(n,a){const e=[],m=i=>{e.push(i),n.forEachChild(i,m)};return m(a),e}function N(n,a){const e=a.parent;return(n.isVariableDeclaration(e)||n.isParameter(e)||n.isBindingElement(e)||n.isFunctionDeclaration(e)||n.isFunctionExpression(e)||n.isClassDeclaration(e)||n.isClassExpression(e)||n.isImportSpecifier(e)||n.isImportClause(e)||n.isNamespaceImport(e)||n.isImportEqualsDeclaration(e))&&e.name===a}function L(n,a){return n.isParenthesizedExpression(a)||n.isAsExpression(a)||n.isNonNullExpression(a)||n.isTypeAssertionExpression(a)||n.isSatisfiesExpression(a)}function le(n,a){for(;a.parent&&L(n,a.parent);)a=a.parent;return a}function _(n,a){let e=a,m=!1;for(;;){e=le(n,e);const i=e.parent;if(i&&(n.isPropertyAccessExpression(i)||n.isElementAccessExpression(i))&&i.expression===e){e=i,m=!0;continue}return{top:e,path:m}}}const H=(n,a)=>n.isBinaryExpression(a)&&(a.operatorToken.kind===n.SyntaxKind.QuestionQuestionToken||a.operatorToken.kind===n.SyntaxKind.BarBarToken);function ce(n,a){const e=a.parent;if(!e)return"used";if(n.isBinaryExpression(e)&&e.left===a&&e.operatorToken.kind>=n.SyntaxKind.FirstAssignment&&e.operatorToken.kind<=n.SyntaxKind.LastAssignment)return"assigned";if((n.isPrefixUnaryExpression(e)||n.isPostfixUnaryExpression(e))&&(e.operator===n.SyntaxKind.PlusPlusToken||e.operator===n.SyntaxKind.MinusMinusToken))return"changed by ++ or --";if(n.isDeleteExpression(e))return"deleted";if(n.isCallExpression(e)&&e.expression===a)return"called, or a method called on it";if(n.isCallExpression(e)||n.isNewExpression(e))return`handed to ${e.expression.getText()}(…)`;if(n.isJsxExpression(e)&&n.isJsxAttribute(e.parent))return`handed to the JSX attribute ${e.parent.name.getText()}`;if(n.isVariableDeclaration(e)||n.isBindingElement(e))return"aliased by a local";if(n.isSpreadElement(e)||n.isSpreadAssignment(e)||n.isJsxSpreadAttribute(e))return"spread";if(n.isForOfStatement(e)||n.isForInStatement(e))return"looped over";for(let m=a;m.parent;m=m.parent){const i=m.parent;if(n.isBinaryExpression(i)){if(i.left===m&&i.operatorToken.kind===n.SyntaxKind.EqualsToken)return"a destructuring target";break}if(!(n.isObjectLiteralExpression(i)||n.isArrayLiteralExpression(i)||n.isPropertyAssignment(i)||n.isShorthandPropertyAssignment(i)||n.isSpreadAssignment(i)||n.isSpreadElement(i)||L(n,i)))break}return`used in a ${n.SyntaxKind[e.kind]} (syntax kind)`}function Q(n,a,e){if(!e)return["the rule was not handed the compiler (`options.ts`)"];const{sf:m,checker:i}=se(e,n),l=pe(e,m),x=l.filter(e.isIdentifier),f=t=>m.getLineAndCharacterOfPosition(t.getStart(m)).line+1,p=t=>e.isShorthandPropertyAssignment(t.parent)&&t.parent.name===t?i.getShorthandAssignmentValueSymbol(t.parent):i.getSymbolAtLocation(t),h=t=>x.filter(r=>r.text===t&&N(e,r)),d=t=>{for(let r=t;r.parent;r=r.parent){const o=r.parent;if(e.isExpressionWithTypeArguments(o)&&o.expression===r)return!1;if(e.isTypeNode(o))return!0}return!1},s=[],c=(t,r,o)=>{const u=l.filter(E=>e.isImportSpecifier(E)&&E.name.text===r),g=u[0],b=g?g.parent.parent.parent.moduleSpecifier.text:"";return u.length!==1?`${t} is not imported once in the mount`:g.propertyName&&g.propertyName.text!==r?`${t} is ${g.propertyName.text} renamed: it is imported by its own name`:g.isTypeOnly||g.parent.parent.isTypeOnly?`${t} is a type-only import`:(o===void 0?!oe.test(b):b!==o)?`${t} comes from "${b}", not ${o===void 0?"a module inside this package":`"${o}"`}`:h(r).length!==1?`${t} is declared again in the mount: it is the imported function`:i.getSymbolAtLocation(g.name)??`${t} has no binding in the mount`},K=h(a.variable);if(K.length!==1)return[`\`${a.variable}\` is declared ${K.length} times, not once`];const A=K[0].parent;if(!e.isVariableDeclaration(A))return[`\`${a.variable}\` is not a variable declaration`];const $=p(K[0]),k=A.initializer;let y=null;const T=c(`the call ${a.call}`,a.call,a.callFrom);if(typeof T=="string"&&s.push(T),!k||!e.isCallExpression(k)||!e.isIdentifier(k.expression)||k.expression.text!==a.call||typeof T!="string"&&p(k.expression)!==T)s.push(`\`${a.variable}\` is not set straight from ${a.call}(…): a pass wraps it, or something follows the call`);else{y=k;const t=n.slice(k.arguments.pos,k.arguments.end).trim();a.args!==void 0&&t!==a.args&&s.push(`${a.call} is handed \`${t}\`, not \`${a.args}\``)}const R=e.findAncestor(A,t=>e.isFunctionDeclaration(t)||e.isFunctionExpression(t)||e.isArrowFunction(t));if(!R||!R.body||A.parent.parent.parent!==R.body)return[...s,`\`${a.variable}\` is not declared at the top level of a component's body`];const C=R.parameters[0]?.name,S=new Map;if(C&&e.isObjectBindingPattern(C))for(const t of C.elements)e.isIdentifier(t.name)&&!t.dotDotDotToken&&S.set(t.name.text,t.name);else s.push("the component does not destructure its props");const B=a.inputs??re(a.args??"").filter(t=>ie.test(t));B.length===0&&s.push(`${a.call}(…) reads no input the rule can check: name the props it reads in \`inputs\`, or bare names in \`args\``);const P=new Set;for(const t of B){const r=S.get(t);if(!r){s.push(`\`${t}\` is not a prop of the component: the call is handed something made in the mount`);continue}h(t).length!==1&&s.push(`\`${t}\` is declared ${h(t).length} times in the file: a second binding would pass for the input`);const o=p(r);o&&P.add(o)}for(const t of x)t.text==="arguments"&&!N(e,t)&&e.findAncestor(t,r=>r===R)&&s.push(`\`arguments\` is used in the component (line ${f(t)}): it is the props by another name`);for(const t of x)(t.text==="eval"||t.text==="Function")&&!N(e,t)&&!d(t)&&!(e.isPropertyAccessExpression(t.parent)&&t.parent.name===t)&&s.push(`\`${t.text}\` is used in the mount file (line ${f(t)}): code run from a string cannot be read`);const z=new Set;for(const t of a.readers??[]){const r=typeof t=="string"?t:t.name,o=c(`the reader ${r}`,r,typeof t=="string"?void 0:t.from);typeof o=="string"?s.push(o):z.add(o)}const Y=t=>{if(!e.isCallExpression(t)||!e.isIdentifier(t.expression))return!1;const r=p(t.expression);return r!==void 0&&z.has(r)};let V=null;const I=l.filter(t=>e.isImportSpecifier(t)&&t.name.text==="Render"),J=a.renderFrom??"efficient-easel/render",ee=I.length===1?I[0].parent.parent.parent.moduleSpecifier.text:"",M=l.filter(t=>e.isImportDeclaration(t)&&e.isStringLiteral(t.moduleSpecifier)&&t.moduleSpecifier.text===J&&!t.importClause?.isTypeOnly).flatMap(t=>{const r=t.importClause;if(!r)return[];const o=r.namedBindings;return[...r.name?[r.name.text]:[],...o&&e.isNamespaceImport(o)?[`* as ${o.name.text}`]:[],...o&&e.isNamedImports(o)?o.elements.filter(u=>!u.isTypeOnly).map(u=>u.propertyName?`${u.propertyName.text} as ${u.name.text}`:u.name.text):[]]});(M.length!==1||M[0]!=="Render")&&s.push(`"${J}" gives this file ${M.length} binding(s) (${M.join(", ")||"none"}), not the one \`Render\``);const q=I.length===1&&!I[0].propertyName&&ee===J?i.getSymbolAtLocation(I[0].name):void 0;if(!q||h("Render").length!==1)s.push(`\`Render\` is not imported once by its own name from "${J}"`);else{const t=x.filter(o=>!N(e,o)&&p(o)===q),r=t.filter(o=>(e.isJsxOpeningElement(o.parent)||e.isJsxSelfClosingElement(o.parent))&&o.parent.tagName===o);if(r.length!==1||t.length!==1)s.push(`\`Render\` is used ${t.length} times, ${r.length} as a tag: one <Render> and no alias`);else{const u=r[0].parent.attributes.properties;u.some(w=>e.isJsxSpreadAttribute(w))&&s.push("the Render tag has a spread attribute, which can hand it another document");const g=u.filter(w=>e.isJsxAttribute(w)&&w.name.getText()==="data"),b=g.length===1?g[0].initializer:void 0,E=b&&e.isJsxExpression(b)?b.expression:void 0;!E||!e.isIdentifier(E)||p(E)!==$?s.push(`the Render tag draws \`${E?E.getText():g.length===1?g[0].getText():"nothing"}\`, not \`${a.variable}\``):V=E;const G=u.filter(w=>e.isJsxAttribute(w)&&w.name.getText()==="keep"),W=G.length===1?G[0].initializer:void 0,F=W&&e.isJsxExpression(W)?W.expression:void 0;if(!F||!e.isIdentifier(F))s.push("the Render tag has no `keep={keep}`: a mount drawn again would remount every slot it holds (lib/document/render-keep)");else{const w=c("the keep hook useRenderKeep","useRenderKeep",a.keepFrom??j);typeof w=="string"&&s.push(w);const D=p(F)?.valueDeclaration;if(!D||!e.isVariableDeclaration(D)||D.parent.parent.parent!==R.body||h(F.text).length!==1)s.push(`\`${F.text}\` (the Render tag's keep) is not declared once at the top level of the component's body: a keep made at module level is shared by every mount and request`);else if(!(e.getCombinedNodeFlags(D)&e.NodeFlags.Const))s.push(`\`${F.text}\` (the Render tag's keep) is not a \`const\`: a keep set again is a new keep`);else{const O=D.initializer;(!O||!e.isCallExpression(O)||O.arguments.length!==0||!e.isIdentifier(O.expression)||typeof w=="string"||p(O.expression)!==w)&&s.push(`\`${F.text}\` is not set straight from useRenderKeep(): a keep made new on each draw keeps nothing`)}}}}const v=new Map;for(const t of P)v.set(t,t.name);$&&v.set($,a.variable);const te=t=>{for(let r=t;r.parent;r=r.parent){const o=r.parent;if(y&&o===y)return y.arguments.some(g=>g===r);if(!(L(e,o)||e.isObjectLiteralExpression(o)||e.isPropertyAssignment(o)&&o.initializer===r||e.isShorthandPropertyAssignment(o)||e.isSpreadAssignment(o)||e.isArrayLiteralExpression(o)||e.isSpreadElement(o)||e.isConditionalExpression(o)&&o.condition!==r||H(e,o)))return!1}return!1},ne=t=>{let r=t,o=!1;for(;;){const u=r.parent;if(!u)return;if(L(e,u))r=u;else if(e.isConditionalExpression(u)&&u.condition!==r)r=u,o=!0;else if(e.isSpreadAssignment(u)&&e.isObjectLiteralExpression(u.parent))r=u.parent,o=!0;else return e.isVariableDeclaration(u)&&u.initializer===r&&e.isIdentifier(u.name)&&o?p(u.name):void 0}},X=(t,r)=>{if(d(t))return!0;const{top:o,path:u}=_(e,t);if(t===V)return!0;let g=o;for(;g.parent&&(L(e,g.parent)||H(e,g.parent));)g=g.parent;if(g.parent&&Y(g.parent)&&g.parent.arguments.some(E=>E===g)||P.has(r)&&te(o))return!0;const b=u?void 0:ne(o);return b?(v.has(b)||v.set(b,b.name),!0):!1};for(let t=-1;t!==v.size;){t=v.size;for(const r of x){if(N(e,r))continue;const o=p(r);o&&v.has(o)&&X(r,o)}}for(const t of x){if(N(e,t))continue;const r=p(t);if(!r||!v.has(r)||X(t,r))continue;const{top:o}=_(e,t),u=v.get(r),g=P.has(r)||r===$?"":" (a local that holds an input or the variable)";s.push(`\`${u}\`${g} is ${ce(e,o)} at line ${f(t)}`)}return s}const j="@/lib/document/render-keep";function de(n,a,e,m){if(!e.includes(m))return!1;const i=n.createSourceFile(a,e,n.ScriptTarget.Latest,!0,a.endsWith(".tsx")?n.ScriptKind.TSX:n.ScriptKind.TS),l=f=>f.some(p=>!p.isTypeOnly&&(p.propertyName??p.name).text==="Render"),x=f=>{if(n.isImportDeclaration(f)&&n.isStringLiteral(f.moduleSpecifier)&&f.moduleSpecifier.text===m){const p=f.importClause;if(!p||p.isTypeOnly)return!1;const h=p.namedBindings;return!!p.name||h!==void 0&&(n.isNamespaceImport(h)||l(h.elements))}if(n.isExportDeclaration(f)&&f.moduleSpecifier&&n.isStringLiteral(f.moduleSpecifier)&&f.moduleSpecifier.text===m){if(f.isTypeOnly)return!1;const p=f.exportClause;return!p||n.isNamespaceExport(p)||l(p.elements)}return n.isCallExpression(f)&&f.arguments.length>0&&n.isStringLiteralLike(f.arguments[0])&&f.arguments[0].text===m&&(f.expression.kind===n.SyntaxKind.ImportKeyword||n.isIdentifier(f.expression)&&f.expression.text==="require")?!0:n.forEachChild(f,x)??!1};return x(i)}const Z=new WeakMap;function ue(n){const a=Z.get(n);if(a)return a;const{check:e,report:m}=U("published mounts fixtures"),i=($,k)=>Q($,k,n),l={call:"publishedPageData",variable:"page",args:"data, metadata",readers:["first"]},x="return <Render config={c} keep={keep} data={page} />;",f=`const page = ${l.call}(data, metadata);`,p="const keep = useRenderKeep();",h=$=>`import { Render } from "efficient-easel/render";
1
+ import{ruleChecks as U}from"./rule.js";import{programOf as ae}from"./support/ts-program.js";function re(n){const a=[];let e=0,m=0;for(let i=0;i<n.length;i++){const l=n[i];"([{".includes(l)?e++:")]}".includes(l)?e--:l===","&&e===0&&(a.push(n.slice(m,i)),m=i+1)}return a.push(n.slice(m)),a.map(i=>i.trim()).filter(i=>i!=="")}const ie=/^[A-Za-z_$][\w$]*$/,oe=/^(?:@\/|\.\.?\/)/;function se(n,a){const e=ae(n,[{path:"mount.tsx",text:a}]);return{sf:e.getSourceFile("/mount.tsx"),checker:e.getTypeChecker()}}function pe(n,a){const e=[],m=i=>{e.push(i),n.forEachChild(i,m)};return m(a),e}function I(n,a){const e=a.parent;return(n.isVariableDeclaration(e)||n.isParameter(e)||n.isBindingElement(e)||n.isFunctionDeclaration(e)||n.isFunctionExpression(e)||n.isClassDeclaration(e)||n.isClassExpression(e)||n.isImportSpecifier(e)||n.isImportClause(e)||n.isNamespaceImport(e)||n.isImportEqualsDeclaration(e))&&e.name===a}function j(n,a){return n.isParenthesizedExpression(a)||n.isAsExpression(a)||n.isNonNullExpression(a)||n.isTypeAssertionExpression(a)||n.isSatisfiesExpression(a)}function le(n,a){for(;a.parent&&j(n,a.parent);)a=a.parent;return a}function _(n,a){let e=a,m=!1;for(;;){e=le(n,e);const i=e.parent;if(i&&(n.isPropertyAccessExpression(i)||n.isElementAccessExpression(i))&&i.expression===e){e=i,m=!0;continue}return{top:e,path:m}}}const H=(n,a)=>n.isBinaryExpression(a)&&(a.operatorToken.kind===n.SyntaxKind.QuestionQuestionToken||a.operatorToken.kind===n.SyntaxKind.BarBarToken);function ce(n,a){const e=a.parent;if(!e)return"used";if(n.isBinaryExpression(e)&&e.left===a&&e.operatorToken.kind>=n.SyntaxKind.FirstAssignment&&e.operatorToken.kind<=n.SyntaxKind.LastAssignment)return"assigned";if((n.isPrefixUnaryExpression(e)||n.isPostfixUnaryExpression(e))&&(e.operator===n.SyntaxKind.PlusPlusToken||e.operator===n.SyntaxKind.MinusMinusToken))return"changed by ++ or --";if(n.isDeleteExpression(e))return"deleted";if(n.isCallExpression(e)&&e.expression===a)return"called, or a method called on it";if(n.isCallExpression(e)||n.isNewExpression(e))return`handed to ${e.expression.getText()}(…)`;if(n.isJsxExpression(e)&&n.isJsxAttribute(e.parent))return`handed to the JSX attribute ${e.parent.name.getText()}`;if(n.isVariableDeclaration(e)||n.isBindingElement(e))return"aliased by a local";if(n.isSpreadElement(e)||n.isSpreadAssignment(e)||n.isJsxSpreadAttribute(e))return"spread";if(n.isForOfStatement(e)||n.isForInStatement(e))return"looped over";for(let m=a;m.parent;m=m.parent){const i=m.parent;if(n.isBinaryExpression(i)){if(i.left===m&&i.operatorToken.kind===n.SyntaxKind.EqualsToken)return"a destructuring target";break}if(!(n.isObjectLiteralExpression(i)||n.isArrayLiteralExpression(i)||n.isPropertyAssignment(i)||n.isShorthandPropertyAssignment(i)||n.isSpreadAssignment(i)||n.isSpreadElement(i)||j(n,i)))break}return`used in a ${n.SyntaxKind[e.kind]} (syntax kind)`}function Q(n,a,e){if(!e)return["the rule was not handed the compiler (`options.ts`)"];const{sf:m,checker:i}=se(e,n),l=pe(e,m),x=l.filter(e.isIdentifier),d=t=>m.getLineAndCharacterOfPosition(t.getStart(m)).line+1,s=t=>e.isShorthandPropertyAssignment(t.parent)&&t.parent.name===t?i.getShorthandAssignmentValueSymbol(t.parent):i.getSymbolAtLocation(t),h=t=>x.filter(r=>r.text===t&&I(e,r)),u=t=>{for(let r=t;r.parent;r=r.parent){const o=r.parent;if(e.isExpressionWithTypeArguments(o)&&o.expression===r)return!1;if(e.isTypeNode(o))return!0}return!1},p=[],c=(t,r,o)=>{const f=l.filter(E=>e.isImportSpecifier(E)&&E.name.text===r),g=f[0],b=g?g.parent.parent.parent.moduleSpecifier.text:"";return f.length!==1?`${t} is not imported once in the mount`:g.propertyName&&g.propertyName.text!==r?`${t} is ${g.propertyName.text} renamed: it is imported by its own name`:g.isTypeOnly||g.parent.parent.isTypeOnly?`${t} is a type-only import`:(o===void 0?!oe.test(b):b!==o)?`${t} comes from "${b}", not ${o===void 0?"a module inside this package":`"${o}"`}`:h(r).length!==1?`${t} is declared again in the mount: it is the imported function`:i.getSymbolAtLocation(g.name)??`${t} has no binding in the mount`},F=h(a.variable);if(F.length!==1)return[`\`${a.variable}\` is declared ${F.length} times, not once`];const A=F[0].parent;if(!e.isVariableDeclaration(A))return[`\`${a.variable}\` is not a variable declaration`];const $=s(F[0]),y=A.initializer;let k=null;const T=c(`the call ${a.call}`,a.call,a.callFrom);if(typeof T=="string"&&p.push(T),!y||!e.isCallExpression(y)||!e.isIdentifier(y.expression)||y.expression.text!==a.call||typeof T!="string"&&s(y.expression)!==T)p.push(`\`${a.variable}\` is not set straight from ${a.call}(…): a pass wraps it, or something follows the call`);else{k=y;const t=n.slice(y.arguments.pos,y.arguments.end).trim();a.args!==void 0&&t!==a.args&&p.push(`${a.call} is handed \`${t}\`, not \`${a.args}\``)}const R=e.findAncestor(A,t=>e.isFunctionDeclaration(t)||e.isFunctionExpression(t)||e.isArrowFunction(t));if(!R||!R.body||A.parent.parent.parent!==R.body)return[...p,`\`${a.variable}\` is not declared at the top level of a component's body`];const C=R.parameters[0]?.name,S=new Map;if(C&&e.isObjectBindingPattern(C))for(const t of C.elements)e.isIdentifier(t.name)&&!t.dotDotDotToken&&S.set(t.name.text,t.name);else p.push("the component does not destructure its props");const B=a.inputs??re(a.args??"").filter(t=>ie.test(t));B.length===0&&p.push(`${a.call}(…) reads no input the rule can check: name the props it reads in \`inputs\`, or bare names in \`args\``);const P=new Set;for(const t of B){const r=S.get(t);if(!r){p.push(`\`${t}\` is not a prop of the component: the call is handed something made in the mount`);continue}h(t).length!==1&&p.push(`\`${t}\` is declared ${h(t).length} times in the file: a second binding would pass for the input`);const o=s(r);o&&P.add(o)}for(const t of x)t.text==="arguments"&&!I(e,t)&&e.findAncestor(t,r=>r===R)&&p.push(`\`arguments\` is used in the component (line ${d(t)}): it is the props by another name`);for(const t of x)(t.text==="eval"||t.text==="Function")&&!I(e,t)&&!u(t)&&!(e.isPropertyAccessExpression(t.parent)&&t.parent.name===t)&&p.push(`\`${t.text}\` is used in the mount file (line ${d(t)}): code run from a string cannot be read`);const z=new Set;for(const t of a.readers??[]){const r=typeof t=="string"?t:t.name,o=c(`the reader ${r}`,r,typeof t=="string"?void 0:t.from);typeof o=="string"?p.push(o):z.add(o)}const Y=t=>{if(!e.isCallExpression(t)||!e.isIdentifier(t.expression))return!1;const r=s(t.expression);return r!==void 0&&z.has(r)};let W=null;const N=l.filter(t=>e.isImportSpecifier(t)&&t.name.text==="Render"),J=a.renderFrom??"efficient-easel/render",ee=N.length===1?N[0].parent.parent.parent.moduleSpecifier.text:"",M=l.filter(t=>e.isImportDeclaration(t)&&e.isStringLiteral(t.moduleSpecifier)&&t.moduleSpecifier.text===J&&!t.importClause?.isTypeOnly).flatMap(t=>{const r=t.importClause;if(!r)return[];const o=r.namedBindings;return[...r.name?[r.name.text]:[],...o&&e.isNamespaceImport(o)?[`* as ${o.name.text}`]:[],...o&&e.isNamedImports(o)?o.elements.filter(f=>!f.isTypeOnly).map(f=>f.propertyName?`${f.propertyName.text} as ${f.name.text}`:f.name.text):[]]});(M.length!==1||M[0]!=="Render")&&p.push(`"${J}" gives this file ${M.length} binding(s) (${M.join(", ")||"none"}), not the one \`Render\``);const q=N.length===1&&!N[0].propertyName&&ee===J?i.getSymbolAtLocation(N[0].name):void 0;if(!q||h("Render").length!==1)p.push(`\`Render\` is not imported once by its own name from "${J}"`);else{const t=x.filter(o=>!I(e,o)&&s(o)===q),r=t.filter(o=>(e.isJsxOpeningElement(o.parent)||e.isJsxSelfClosingElement(o.parent))&&o.parent.tagName===o);if(r.length!==1||t.length!==1)p.push(`\`Render\` is used ${t.length} times, ${r.length} as a tag: one <Render> and no alias`);else{const f=r[0].parent.attributes.properties;f.some(w=>e.isJsxSpreadAttribute(w))&&p.push("the Render tag has a spread attribute, which can hand it another document");const g=f.filter(w=>e.isJsxAttribute(w)&&w.name.getText()==="data"),b=g.length===1?g[0].initializer:void 0,E=b&&e.isJsxExpression(b)?b.expression:void 0;!E||!e.isIdentifier(E)||s(E)!==$?p.push(`the Render tag draws \`${E?E.getText():g.length===1?g[0].getText():"nothing"}\`, not \`${a.variable}\``):W=E;const G=f.filter(w=>e.isJsxAttribute(w)&&w.name.getText()==="keep"),V=G.length===1?G[0].initializer:void 0,K=V&&e.isJsxExpression(V)?V.expression:void 0;if(!K||!e.isIdentifier(K))p.push("the Render tag has no `keep={keep}`: a mount drawn again would remount every slot it holds (lib/document/render-keep)");else{const w=c("the keep hook useRenderKeep","useRenderKeep",a.keepFrom??L);typeof w=="string"&&p.push(w);const D=s(K)?.valueDeclaration;if(!D||!e.isVariableDeclaration(D)||D.parent.parent.parent!==R.body||h(K.text).length!==1)p.push(`\`${K.text}\` (the Render tag's keep) is not declared once at the top level of the component's body: a keep made at module level is shared by every mount and request`);else if(!(e.getCombinedNodeFlags(D)&e.NodeFlags.Const))p.push(`\`${K.text}\` (the Render tag's keep) is not a \`const\`: a keep set again is a new keep`);else{const O=D.initializer;(!O||!e.isCallExpression(O)||O.arguments.length!==0||!e.isIdentifier(O.expression)||typeof w=="string"||s(O.expression)!==w)&&p.push(`\`${K.text}\` is not set straight from useRenderKeep(): a keep made new on each draw keeps nothing`)}}}}const v=new Map;for(const t of P)v.set(t,t.name);$&&v.set($,a.variable);const te=t=>{for(let r=t;r.parent;r=r.parent){const o=r.parent;if(k&&o===k)return k.arguments.some(g=>g===r);if(!(j(e,o)||e.isObjectLiteralExpression(o)||e.isPropertyAssignment(o)&&o.initializer===r||e.isShorthandPropertyAssignment(o)||e.isSpreadAssignment(o)||e.isArrayLiteralExpression(o)||e.isSpreadElement(o)||e.isConditionalExpression(o)&&o.condition!==r||H(e,o)))return!1}return!1},ne=t=>{let r=t,o=!1;for(;;){const f=r.parent;if(!f)return;if(j(e,f))r=f;else if(e.isConditionalExpression(f)&&f.condition!==r)r=f,o=!0;else if(e.isSpreadAssignment(f)&&e.isObjectLiteralExpression(f.parent))r=f.parent,o=!0;else return e.isVariableDeclaration(f)&&f.initializer===r&&e.isIdentifier(f.name)&&o?s(f.name):void 0}},X=(t,r)=>{if(u(t))return!0;const{top:o,path:f}=_(e,t);if(t===W)return!0;let g=o;for(;g.parent&&(j(e,g.parent)||H(e,g.parent));)g=g.parent;if(g.parent&&Y(g.parent)&&g.parent.arguments.some(E=>E===g)||P.has(r)&&te(o))return!0;const b=f?void 0:ne(o);return b?(v.has(b)||v.set(b,b.name),!0):!1};for(let t=-1;t!==v.size;){t=v.size;for(const r of x){if(I(e,r))continue;const o=s(r);o&&v.has(o)&&X(r,o)}}for(const t of x){if(I(e,t))continue;const r=s(t);if(!r||!v.has(r)||X(t,r))continue;const{top:o}=_(e,t),f=v.get(r),g=P.has(r)||r===$?"":" (a local that holds an input or the variable)";p.push(`\`${f}\`${g} is ${ce(e,o)} at line ${d(t)}`)}return p}const L="@/lib/document/render-keep";function de(n,a,e,m){if(!e.includes(m))return!1;const i=n.createSourceFile(a,e,n.ScriptTarget.Latest,!0,/\.[jt]sx$/.test(a)?n.ScriptKind.TSX:/\.[jt]s$/.test(a)?n.ScriptKind.TS:n.ScriptKind.TSX),l=d=>d.some(s=>!s.isTypeOnly&&(s.propertyName??s.name).text==="Render"),x=d=>{if(n.isImportDeclaration(d)&&n.isStringLiteral(d.moduleSpecifier)&&d.moduleSpecifier.text===m){const s=d.importClause;if(!s||s.isTypeOnly)return!1;const h=s.namedBindings;return!!s.name||h!==void 0&&(n.isNamespaceImport(h)||l(h.elements))}if(n.isExportDeclaration(d)&&d.moduleSpecifier&&n.isStringLiteral(d.moduleSpecifier)&&d.moduleSpecifier.text===m){if(d.isTypeOnly)return!1;const s=d.exportClause;return!s||n.isNamespaceExport(s)||l(s.elements)}if(n.isCallExpression(d)&&d.arguments.length>0&&n.isStringLiteralLike(d.arguments[0])&&d.arguments[0].text===m){if(d.expression.kind===n.SyntaxKind.ImportKeyword||n.isIdentifier(d.expression)&&d.expression.text==="require"||n.isPropertyAccessExpression(d.expression)&&d.expression.name.text==="require")return!0;const s=d.expression;if(n.isCallExpression(s)&&n.isIdentifier(s.expression)&&s.expression.text==="createRequire")return!0}return n.forEachChild(d,x)??!1};return x(i)}const Z=new WeakMap;function ue(n){const a=Z.get(n);if(a)return a;const{check:e,report:m}=U("published mounts fixtures"),i=($,y)=>Q($,y,n),l={call:"publishedPageData",variable:"page",args:"data, metadata",readers:["first"]},x="return <Render config={c} keep={keep} data={page} />;",d=`const page = ${l.call}(data, metadata);`,s="const keep = useRenderKeep();",h=$=>`import { Render } from "efficient-easel/render";
2
2
  import { first } from "./first";
3
- import { useRenderKeep } from "${j}";
3
+ import { useRenderKeep } from "${L}";
4
4
  import { ${l.call} } from "./published-passes";
5
5
  export default function P({ data, metadata = {} }: Props) {
6
- ${p}
6
+ ${s}
7
7
  ${$}
8
- }`,d=h(`${f}
9
- ${x}`),s=$=>h(`${$}
10
- ${f}
11
- ${x}`),c=$=>h(`${f}
8
+ }`,u=h(`${d}
9
+ ${x}`),p=$=>h(`${$}
10
+ ${d}
11
+ ${x}`),c=$=>h(`${d}
12
12
  ${$}
13
- ${x}`);e("the one call, drawn, passes",i(d,l).length===0,i(d,l).join("; "));{const $={...l,callFrom:"@/lib/document/published-passes"},k=d.replace('from "./published-passes"',`from "${$.callFrom}"`);e("…the call imported from the module the mount names passes",i(k,$).length===0,i(k,$).join("; ")),e("…and the call imported from another module inside this package fails it",i(d,$).length>0)}e("…a comment naming a wrapper does not fail it",i(`// const page = x(${l.call}(data, metadata));
14
- ${d}`,l).length===0),e("…a path handed to a listed reader does not fail it",i(c("const lead = first(page.content);"),l).length===0),e("…an input spread, and an input as a ternary's last branch, do not fail it",i(c("const facts = ok ? { ...metadata, k: 1 } : metadata;"),l).length===0,i(c("const facts = ok ? { ...metadata, k: 1 } : metadata;"),l).join("; "));{const $="efficient-web-builder/render/lib/document/published-passes",k="efficient-web-builder/render/lib/document/render-keep",y={call:"publishedChromeData",callFrom:$,variable:"data",inputs:["group"],keepFrom:k},T=`import { useRenderKeep } from "${k}";
13
+ ${x}`);e("the one call, drawn, passes",i(u,l).length===0,i(u,l).join("; "));{const $={...l,callFrom:"@/lib/document/published-passes"},y=u.replace('from "./published-passes"',`from "${$.callFrom}"`);e("…the call imported from the module the mount names passes",i(y,$).length===0,i(y,$).join("; ")),e("…and the call imported from another module inside this package fails it",i(u,$).length>0)}e("…a comment naming a wrapper does not fail it",i(`// const page = x(${l.call}(data, metadata));
14
+ ${u}`,l).length===0),e("…a path handed to a listed reader does not fail it",i(c("const lead = first(page.content);"),l).length===0),e("…an input spread, and an input as a ternary's last branch, do not fail it",i(c("const facts = ok ? { ...metadata, k: 1 } : metadata;"),l).length===0,i(c("const facts = ok ? { ...metadata, k: 1 } : metadata;"),l).join("; "));{const $="efficient-web-builder/render/lib/document/published-passes",y="efficient-web-builder/render/lib/document/render-keep",k={call:"publishedChromeData",callFrom:$,variable:"data",inputs:["group"],keepFrom:y},T=`import { useRenderKeep } from "${y}";
15
15
  `,R=`import { Render } from "efficient-easel/render";
16
- ${T}import { ${y.call} } from "${$}";
16
+ ${T}import { ${k.call} } from "${$}";
17
17
  export default function H({ group }: { group: G }) {
18
- const data = ${y.call}({ content: [group] } as unknown as D);
18
+ const data = ${k.call}({ content: [group] } as unknown as D);
19
19
  const keep = useRenderKeep();
20
20
  return <Render config={c} keep={keep} data={data} />;
21
- }`;e("…a chrome mount drawing `data={data}` passes",i(R,y).length===0,i(R,y).join("; ")),e("…and a write into its prop fails it",i(R.replace("const data",`group.props = {};
22
- const data`),y).length>0);const C="<Render config={headerRenderConfig()} keep={keep} data={data} />",S=`import { Render } from "efficient-easel/render";
23
- ${T}import { ${y.call} } from "${$}";
21
+ }`;e("…a chrome mount drawing `data={data}` passes",i(R,k).length===0,i(R,k).join("; ")),e("…and a write into its prop fails it",i(R.replace("const data",`group.props = {};
22
+ const data`),k).length>0);const C="<Render config={headerRenderConfig()} keep={keep} data={data} />",S=`import { Render } from "efficient-easel/render";
23
+ ${T}import { ${k.call} } from "${$}";
24
24
  export default function PublishedHeader({ group }: { group: G }) {
25
- const data = ${y.call}({ root: { props: {} }, content: [group], zones: {} } as unknown as D);
25
+ const data = ${k.call}({ root: { props: {} }, content: [group], zones: {} } as unknown as D);
26
26
  const keep = useRenderKeep();
27
27
  return (
28
28
  <Bar sticky={sticky}>
29
29
  ${C}
30
30
  </Bar>
31
31
  );
32
- }`;e("…a header mount drawing `data={data}` inside a wrapper passes",i(S,y).length===0,i(S,y).join("; "));const B=[["`data` assigned after the call",S.replace(" return (",` data = extra;
32
+ }`;e("…a header mount drawing `data={data}` inside a wrapper passes",i(S,k).length===0,i(S,k).join("; "));const B=[["`data` assigned after the call",S.replace(" return (",` data = extra;
33
33
  return (`)],["a property write on `data`",S.replace(" return (",` data.content = [];
34
34
  return (`)],["a second Render with `data={data}` and a spread",S.replace(C,`${C}
35
- <Render data={data} {...extra} />`)],["its call imported from another module",S.replace(`from "${$}"`,'from "./published-passes"')],["no keep on the tag",S.replace(" keep={keep}","")],["its keep hook imported from another module",S.replace(`from "${k}"`,'from "./render-keep"')]];for(const[P,z]of B)e(`…${P} fails it`,i(z,y).length>0)}const K=[["a wrapping pass",h(`const page = extra(${l.call}(data, metadata));
35
+ <Render data={data} {...extra} />`)],["its call imported from another module",S.replace(`from "${$}"`,'from "./published-passes"')],["no keep on the tag",S.replace(" keep={keep}","")],["its keep hook imported from another module",S.replace(`from "${y}"`,'from "./render-keep"')]];for(const[P,z]of B)e(`…${P} fails it`,i(z,k).length>0)}const F=[["a wrapping pass",h(`const page = extra(${l.call}(data, metadata));
36
36
  ${x}`)],["a pass after the call",h(`const page = ${l.call}(data, metadata).x;
37
37
  ${x}`)],["a reassignment",h(`let page = ${l.call}(data, metadata);
38
38
  page = extra(page);
39
- ${x}`)],["a pass in the Render prop",h(`${f}
39
+ ${x}`)],["a pass in the Render prop",h(`${d}
40
40
  return <Render data={extra(page)} />;`)],["other arguments",h(`const page = ${l.call}(extra(data), metadata);
41
- ${x}`)],["no call at all",h(x)],["a pass on the input before the call",s("data = extra(data);")],["a compound assignment to the input",s("metadata ??= {};")],["an increment of the input",s("data++;")],["a destructured reassignment of the input",s("({ data } = extra({ data }));")],["an array reassignment of the input",s("[data, metadata] = extra([data, metadata]);")],["a local shadowing the input",s("{ const data = extra(0); }")],["a rebuilt argument named as the args",h(`const d = extra(data);
41
+ ${x}`)],["no call at all",h(x)],["a pass on the input before the call",p("data = extra(data);")],["a compound assignment to the input",p("metadata ??= {};")],["an increment of the input",p("data++;")],["a destructured reassignment of the input",p("({ data } = extra({ data }));")],["an array reassignment of the input",p("[data, metadata] = extra([data, metadata]);")],["a local shadowing the input",p("{ const data = extra(0); }")],["a rebuilt argument named as the args",h(`const d = extra(data);
42
42
  const page = ${l.call}(d, metadata);
43
43
  ${x}`),{...l,args:"d, metadata"}],["an argument that is no prop at all",`const page = ${l.call}(data, metadata);
44
- ${x}`],["a property write",c("page.content = extra(page.content);")],["a deep property write",c("page.root.props = {};")],["a compound property write",c("page.count += 1;")],["a bracket write",c('page["content"] = [];')],["an optional-path write",c("page.root!.props = {};")],["a delete",c("delete page.root;")],["Object.assign into it",c("Object.assign(page, extra(page));")],["the variable handed whole to a call",c("mutate(page);")],["the variable aliased",c("const shown = page;")],["a push on a path from it",c("page.content.push(extra(0));")],["a splice on an optional path from it",c("page.content?.splice(0, 1);")],["a sort on a bracket path from it",c('page["content"].sort();')],["an input handed to a pass through a cast",s("inPlacePass(data as Doc);")],["an input handed whole to a call",s("mutate(data);")],["a push through a cast of an input",s("(data as Doc).content.push(x);")],["a property write through a cast of an input",s("(metadata as any).x = 1;")],["a property write through an old-style cast",s("(<any>metadata).x = 1;")],["a property write through a non-null input",s("(metadata!).x = 1;")],["a push on a non-null input",s("data!.content.push(x);")],["an input aliased through a cast, then written",s(`const d = data as any;
45
- d.content = [];`)],["an input aliased",s("const d = data;")],["an input path aliased",s("const p = metadata.facts;")],["a path value bound to a local",c("const one = page.content.length === 1;")],["a path alias pushed into",c(`const c = page.content;
44
+ ${x}`],["a property write",c("page.content = extra(page.content);")],["a deep property write",c("page.root.props = {};")],["a compound property write",c("page.count += 1;")],["a bracket write",c('page["content"] = [];')],["an optional-path write",c("page.root!.props = {};")],["a delete",c("delete page.root;")],["Object.assign into it",c("Object.assign(page, extra(page));")],["the variable handed whole to a call",c("mutate(page);")],["the variable aliased",c("const shown = page;")],["a push on a path from it",c("page.content.push(extra(0));")],["a splice on an optional path from it",c("page.content?.splice(0, 1);")],["a sort on a bracket path from it",c('page["content"].sort();')],["an input handed to a pass through a cast",p("inPlacePass(data as Doc);")],["an input handed whole to a call",p("mutate(data);")],["a push through a cast of an input",p("(data as Doc).content.push(x);")],["a property write through a cast of an input",p("(metadata as any).x = 1;")],["a property write through an old-style cast",p("(<any>metadata).x = 1;")],["a property write through a non-null input",p("(metadata!).x = 1;")],["a push on a non-null input",p("data!.content.push(x);")],["an input aliased through a cast, then written",p(`const d = data as any;
45
+ d.content = [];`)],["an input aliased",p("const d = data;")],["an input path aliased",p("const p = metadata.facts;")],["a path value bound to a local",c("const one = page.content.length === 1;")],["a path alias pushed into",c(`const c = page.content;
46
46
  c.push(x);`)],["a path alias written",c(`const r = page.root;
47
47
  r.props = {};`)],["a path assigned to a let",c(`let c;
48
48
  c = page.content;`)],["a path handed to a writing call",c("mutate(page.content);")],["a path's forEach writing",c("page.content.forEach((s) => { s.props = {}; });")],["a path's for-of writing",c("for (const s of page.content) s.props.x = 1;")],["a path in an array literal",c("const all = [page.content];")],["the variable spread into a copy",c(`const copy = { ...page };
49
- copy.content.push(x);`)],["a path handed to a method that shares a reader's name",c("evil.first(page.content);")],["a local from an input's ternary branch, written through a cast",s(`const f = ok ? {} : metadata;
50
- (f as any).x = 1;`)],["a local from an input's ternary branch, handed to a call",s(`const f = ok ? {} : metadata;
51
- mutate(f);`)],["an input assigned an object with no space",s("data={content: [], root: {}};")],["an input assigned a cast object with no space",s("data={ content: [] } as unknown;")],["a second input assigned with no space",s("metadata={k: 1};")],["an input assigned a string with no space",s('data="";')],["the variable assigned with no space",c("page={content: [], root:{props:{}}} as any;")],["a spread copy of an input, written deep",s(`const copy: any = { ...metadata };
52
- copy.theme.x = 1;`)],["a spread copy of an input, handed to a call",s(`const copy = { ...metadata };
53
- mutate(copy);`)],["a reader declared in the mount",`${d}
54
- function first(x) { x.content = []; }`],["a reader declared as a local arrow",`${d}
55
- const first = (x) => { x.content = []; };`],["a reader that is not imported",d.replace(`import { first } from "./first";
56
- `,"")],["eval",c('eval("page.content = []");')],["new Function",c('new Function("p", "p.content = []")(page);')],["Function called",c('Function("p", "p.content = []");')],["a call in a class extends clause",c("class W extends (mutate(page), Object) {}")],["a call in an instantiation expression",c("const g = (mutate(page), id)<number>;")],["a Render from another module",d.replace('from "efficient-easel/render"','from "./fake-render"')],["a second Render import, renamed",d.replace('import { Render } from "efficient-easel/render";',`import { Render } from "efficient-easel/render";
57
- import { Render as Second } from "efficient-easel/render";`)],["a namespace import of Render's module",d.replace('import { Render } from "efficient-easel/render";',`import { Render } from "efficient-easel/render";
58
- import * as E from "efficient-easel/render";`)],["a default import of Render's module",d.replace('import { Render } from "efficient-easel/render";',`import { Render } from "efficient-easel/render";
59
- import E from "efficient-easel/render";`)],["the call declared in the mount, not imported",`${d.replace(`import { ${l.call} } from "./published-passes";
49
+ copy.content.push(x);`)],["a path handed to a method that shares a reader's name",c("evil.first(page.content);")],["a local from an input's ternary branch, written through a cast",p(`const f = ok ? {} : metadata;
50
+ (f as any).x = 1;`)],["a local from an input's ternary branch, handed to a call",p(`const f = ok ? {} : metadata;
51
+ mutate(f);`)],["an input assigned an object with no space",p("data={content: [], root: {}};")],["an input assigned a cast object with no space",p("data={ content: [] } as unknown;")],["a second input assigned with no space",p("metadata={k: 1};")],["an input assigned a string with no space",p('data="";')],["the variable assigned with no space",c("page={content: [], root:{props:{}}} as any;")],["a spread copy of an input, written deep",p(`const copy: any = { ...metadata };
52
+ copy.theme.x = 1;`)],["a spread copy of an input, handed to a call",p(`const copy = { ...metadata };
53
+ mutate(copy);`)],["a reader declared in the mount",`${u}
54
+ function first(x) { x.content = []; }`],["a reader declared as a local arrow",`${u}
55
+ const first = (x) => { x.content = []; };`],["a reader that is not imported",u.replace(`import { first } from "./first";
56
+ `,"")],["eval",c('eval("page.content = []");')],["new Function",c('new Function("p", "p.content = []")(page);')],["Function called",c('Function("p", "p.content = []");')],["a call in a class extends clause",c("class W extends (mutate(page), Object) {}")],["a call in an instantiation expression",c("const g = (mutate(page), id)<number>;")],["a Render from another module",u.replace('from "efficient-easel/render"','from "./fake-render"')],["a second Render import, renamed",u.replace('import { Render } from "efficient-easel/render";',`import { Render } from "efficient-easel/render";
57
+ import { Render as Second } from "efficient-easel/render";`)],["a namespace import of Render's module",u.replace('import { Render } from "efficient-easel/render";',`import { Render } from "efficient-easel/render";
58
+ import * as E from "efficient-easel/render";`)],["a default import of Render's module",u.replace('import { Render } from "efficient-easel/render";',`import { Render } from "efficient-easel/render";
59
+ import E from "efficient-easel/render";`)],["the call declared in the mount, not imported",`${u.replace(`import { ${l.call} } from "./published-passes";
60
60
  `,"")}
61
- function ${l.call}(d, m) { const x: any = d; x.content = []; return x; }`],["the call declared again beside its import",`${d}
62
- function ${l.call}(d, m) { return d; }`],["the call imported from outside this package",d.replace('from "./published-passes"','from "evil-passes"')],["another function imported as the call",d.replace(`import { ${l.call} }`,`import { evilPass as ${l.call} }`)],["the call as a type-only import",d.replace(`import { ${l.call} }`,`import type { ${l.call} }`)],["no keep on the tag",d.replace(" keep={keep}","")],["a keep made at module level",d.replace(`${p}
61
+ function ${l.call}(d, m) { const x: any = d; x.content = []; return x; }`],["the call declared again beside its import",`${u}
62
+ function ${l.call}(d, m) { return d; }`],["the call imported from outside this package",u.replace('from "./published-passes"','from "evil-passes"')],["another function imported as the call",u.replace(`import { ${l.call} }`,`import { evilPass as ${l.call} }`)],["the call as a type-only import",u.replace(`import { ${l.call} }`,`import type { ${l.call} }`)],["no keep on the tag",u.replace(" keep={keep}","")],["a keep made at module level",u.replace(`${s}
63
63
  `,"").replace("export default function",`const keep = createRenderKeep();
64
- export default function`)],["a keep made new on each draw",d.replace(p,"const keep = createRenderKeep();")],["a keep wrapped in a call",d.replace(p,"const keep = other(useRenderKeep());")],["a keep set again",d.replace(p,`let keep = useRenderKeep();
65
- keep = createRenderKeep();`)],["a keep hook declared in the mount",`${d.replace(`import { useRenderKeep } from "${j}";
64
+ export default function`)],["a keep made new on each draw",u.replace(s,"const keep = createRenderKeep();")],["a keep wrapped in a call",u.replace(s,"const keep = other(useRenderKeep());")],["a keep set again",u.replace(s,`let keep = useRenderKeep();
65
+ keep = createRenderKeep();`)],["a keep hook declared in the mount",`${u.replace(`import { useRenderKeep } from "${L}";
66
66
  `,"")}
67
- function useRenderKeep() { return new WeakMap(); }`],["a keep hook from outside this package",d.replace(`from "${j}"`,'from "evil-keep"')],["a keep hook from another module of this package",d.replace(`from "${j}"`,'from "./render-keep"')],["a call with no input it can check",h(`const page = ${l.call}({ ...data });
68
- ${x}`),{call:l.call,variable:"page",args:"{ ...data }"}],["a call with no args and no inputs named",d,{call:l.call,variable:"page"}]];for(const[$,k,y]of K)e(`…${$} fails it`,i(k,y??l).length>0);const A=m().checks;return Z.set(n,A),A}function ge(n,a){const{check:e,report:m}=U("published mounts"),i=a.ts;if(!e("the rule is handed the compiler (`options.ts`)",i!==void 0,"a host passes `ts` from its own typescript"))return m();for(const p of ue(i))e(p.name,p.ok,p.detail);const l=n.filter(p=>/\.tsx?$/.test(p.path));e(`the source scan reached the tree (${l.length} TS/TSX files, at least ${a.minFiles})`,l.length>=a.minFiles);const x=Object.keys(a.mounts);e("at least one published mount is named",x.length>0);const f=new Set(x.map(p=>a.mounts[p].renderFrom??"efficient-easel/render"));for(const p of l)!x.includes(p.path)&&[...f].some(h=>de(i,p.path,p.text,h))&&e(`${p.path} draws easel Render: it is a named published mount (a row), or the rule never reads it`,!1,"add its row to the mounts this repository names");for(const p of x){const h=l.find(s=>s.path===p);if(!e(`${p} is here`,h!==void 0,"a stale row would shelter nothing"))continue;const d=Q(h.text,a.mounts[p],i);e(`${p} draws exactly what ${a.mounts[p].call} returns — a pass belongs in lib/document/published-passes`,d.length===0,d.join("; "))}return m()}export{Q as mountProblems,ge as publishedMounts};
67
+ function useRenderKeep() { return new WeakMap(); }`],["a keep hook from outside this package",u.replace(`from "${L}"`,'from "evil-keep"')],["a keep hook from another module of this package",u.replace(`from "${L}"`,'from "./render-keep"')],["a call with no input it can check",h(`const page = ${l.call}({ ...data });
68
+ ${x}`),{call:l.call,variable:"page",args:"{ ...data }"}],["a call with no args and no inputs named",u,{call:l.call,variable:"page"}]];for(const[$,y,k]of F)e(`…${$} fails it`,i(y,k??l).length>0);const A=m().checks;return Z.set(n,A),A}function ge(n,a){const{check:e,report:m}=U("published mounts"),i=a.ts;if(!e("the rule is handed the compiler (`options.ts`)",i!==void 0,"a host passes `ts` from its own typescript"))return m();for(const s of ue(i))e(s.name,s.ok,s.detail);const l=n.filter(s=>/\.[jt]sx?$/.test(s.path));e(`the source scan reached the tree (${l.length} TS/TSX files, at least ${a.minFiles})`,l.length>=a.minFiles);const x=Object.keys(a.mounts);e("at least one published mount is named",x.length>0);const d=new Set(x.map(s=>a.mounts[s].renderFrom??"efficient-easel/render"));for(const s of l)!x.includes(s.path)&&[...d].some(h=>de(i,s.path,s.text,h))&&e(`${s.path} draws easel Render: it is a named published mount (a row), or the rule never reads it`,!1,"add its row to the mounts this repository names");for(const s of x){const h=l.find(p=>p.path===s);if(!e(`${s} is here`,h!==void 0,"a stale row would shelter nothing"))continue;const u=Q(h.text,a.mounts[s],i);e(`${s} draws exactly what ${a.mounts[s].call} returns — a pass belongs in lib/document/published-passes`,u.length===0,u.join("; "))}return m()}export{Q as mountProblems,ge as publishedMounts};
@@ -1,2 +1,2 @@
1
- import{isRuleSource as b,ruleChecks as S}from"./rule.js";const k=new Set(["Select","SettingsSelect","FieldSelect"]);function u(s,n){const i=s.createSourceFile(n.path,n.text,s.ScriptTarget.Latest,!0,s.ScriptKind.TSX),r=[],p=[],c=e=>i.getLineAndCharacterOfPosition(e.getStart(i)).line+1,d=e=>{let t=e;for(;t&&(s.isAsExpression(t)||s.isSatisfiesExpression(t)||s.isParenthesizedExpression(t));)t=t.expression;return t},a=e=>e?s.isStringLiteralLike(e)?e.text:e.getText(i):"(no label)",x=e=>e.name&&(s.isIdentifier(e.name)||s.isStringLiteralLike(e.name))?e.name.text:void 0,f=(e,t)=>{for(const o of e.properties)if(x(o)===t){if(s.isPropertyAssignment(o))return o.initializer;if(s.isShorthandPropertyAssignment(o))return o.name}},h=e=>{const t=e.parent;return s.isCallExpression(t)&&s.isIdentifier(t.expression)&&t.expression.text==="describedAs"&&t.arguments[1]===e},m=e=>{if(s.isCallExpression(e)){const t=e.arguments[0];(s.isIdentifier(e.expression)&&e.expression.text==="select"||s.isPropertyAccessExpression(e.expression)&&e.expression.name.text==="select")&&e.arguments.length>=2&&t&&!s.isObjectLiteralExpression(t)&&r.push(`${n.path}|${a(t)}`);const l=e.arguments[1];(e.expression.getText(i).endsWith("createElement")||s.isIdentifier(e.expression)&&e.expression.text==="h")&&t&&t.getText(i).replace(/<[\s\S]*>$/,"")==="IconPicker"&&l&&s.isObjectLiteralExpression(l)&&l.properties.some(y=>x(y)==="emptyValue")&&p.push(c(l))}if(s.isImportSpecifier(e)&&e.propertyName&&(e.propertyName.text==="select"||e.propertyName.text==="IconPicker")&&r.push(`${n.path}|alias ${e.name.text}`),s.isBindingElement(e)&&e.propertyName&&s.isIdentifier(e.propertyName)&&e.propertyName.text==="select"&&r.push(`${n.path}|alias ${e.name.getText(i)}`),(s.isJsxOpeningElement(e)||s.isJsxSelfClosingElement(e))&&k.has(e.tagName.getText(i))){const t=e.attributes.properties.find(l=>s.isJsxAttribute(l)&&l.name.getText(i)==="label"),o=t&&s.isJsxAttribute(t)?t.initializer:void 0;r.push(`${n.path}|<${e.tagName.getText(i)}> ${o?a(s.isJsxExpression(o)?o.expression:o):"(no label)"}`)}if(s.isObjectLiteralExpression(e))for(const t of["type","kind"]){const o=d(f(e,t));o&&s.isStringLiteralLike(o)&&o.text==="select"&&!h(e)&&r.push(`${n.path}|${a(f(e,"label"))}`)}s.isJsxAttribute(e)&&e.name.getText(i)==="emptyValue"&&e.parent.parent.tagName.getText(i)==="IconPicker"&&p.push(c(e)),s.isJsxSpreadAttribute(e)&&e.parent.parent.tagName.getText(i)==="IconPicker"&&p.push(c(e)),s.forEachChild(e,m)};return m(i),{selects:r,emptyValues:p}}function g(s){const n=new Map;for(const i of s)n.set(i,(n.get(i)??0)+1);return n}function A(s,n,i){const{check:r,report:p}=S("shape rows use the picker");{const e=['const a = select("Corner shape", icon, options);','const b = { type: "select", label: "Card shape", options };','const c = { type: "select" as const, label: LABEL, options };',"const d = select(item);",'const e = iconPickerRow("Corner shape", icon, options, "a");','const f = <IconPicker label="x" emptyValue="none" options={o} />;','const g = <IconPicker label="x" options={o} />;','const h = <Other emptyValue="none" />;','// select("A comment", icon) is not a use','const i = select(say("Said"), icon, options);',"const j = select(LABELS.x, icon, options);","const k = select(`A ${b}`, icon, options);",'const l = { "type": "select", label, options };',"const m = select({ index }, other);",'import { select as pick } from "x";','const n = createElement(IconPicker<V>, { label: "x", emptyValue: "none" });','const o = createElement(IconPicker, { label: "x" });','const p = rows.select("By a member", icon, options);',"const { select: q } = rows;",'const r = { type: "select" satisfies string, label: "Satisfied", options };','const s = { kind: "select", label: "A kind", options };','const t = <SettingsSelect label="Hand drawn" options={o} />;',"const u = <FieldSelect value={v} options={o} />;",'const v = <IconPicker label="x" {...rest} />;','import { IconPicker as Pick } from "x";','const w = describedAs(field, { type: "select", label: "Described" });',"const x = rows.select(item);"].join(`
2
- `),t=u(s,{path:"f.tsx",text:e});r("R1 finds the builder and both field forms, and nothing else",JSON.stringify(t.selects)===JSON.stringify(["f.tsx|Corner shape","f.tsx|Card shape","f.tsx|LABEL",'f.tsx|say("Said")',"f.tsx|LABELS.x","f.tsx|`A ${b}`","f.tsx|label","f.tsx|alias pick","f.tsx|By a member","f.tsx|alias q","f.tsx|Satisfied","f.tsx|A kind","f.tsx|<SettingsSelect> Hand drawn","f.tsx|<FieldSelect> (no label)","f.tsx|alias Pick"]),JSON.stringify(t.selects)),r("R2 finds emptyValue on an IconPicker only, in both forms, and a spread",JSON.stringify(t.emptyValues)==="[6,16,24]",JSON.stringify(t.emptyValues))}const c=n.filter(e=>/\.tsx?$/.test(e.path)&&!e.path.endsWith(".d.ts")&&!b(e.path)),d=[],a=[];for(const e of c){const t=u(s,e);d.push(...t.selects),t.emptyValues.forEach(o=>a.push(`${e.path}:${o}`))}const x=g(d),f=g(i.selectRows),h=[...x].filter(([e,t])=>t>(f.get(e)??0)).map(([e])=>e).sort(),m=[...f].filter(([e,t])=>t>(x.get(e)??0)).map(([e])=>e);return r("R1 every select row is on the repository's list",h.length===0,`${h.join(", ")}: a row that picks between shapes uses iconPickerRow or shapePickerRow; a row that picks words joins the list`),r("R1 every name on the list is still a select row",m.length===0,`${m.join(", ")}: remove the entry`),r("R2 no IconPicker takes emptyValue",a.length===0,`${a.join(", ")}: use pickerNoneIcon, so the closed word has the size of every other`),r(`walked the source (${c.length} TS/TSX files, at least ${i.minFiles})`,c.length>=i.minFiles),p()}export{A as shapeRowsUseThePicker};
1
+ import{isRuleSource as k,ruleChecks as S}from"./rule.js";import{elementOf as P}from"./support/element-call.js";const w=new Set(["Select","SettingsSelect","FieldSelect"]);function g(t,n){const i=t.createSourceFile(n.path,n.text,t.ScriptTarget.Latest,!0,t.ScriptKind.TSX),r=[],p=[],c=e=>i.getLineAndCharacterOfPosition(e.getStart(i)).line+1,d=e=>{let s=e;for(;s&&(t.isAsExpression(s)||t.isSatisfiesExpression(s)||t.isParenthesizedExpression(s));)s=s.expression;return s},a=e=>e?t.isStringLiteralLike(e)?e.text:e.getText(i):"(no label)",f=e=>e.name&&(t.isIdentifier(e.name)||t.isStringLiteralLike(e.name))?e.name.text:void 0,x=(e,s)=>{for(const o of e.properties)if(f(o)===s){if(t.isPropertyAssignment(o))return o.initializer;if(t.isShorthandPropertyAssignment(o))return o.name}},h=e=>{const s=e.parent;return t.isCallExpression(s)&&t.isIdentifier(s.expression)&&s.expression.text==="describedAs"&&s.arguments[1]===e},m=e=>{if(t.isCallExpression(e)){const s=e.arguments[0];(t.isIdentifier(e.expression)&&e.expression.text==="select"||t.isPropertyAccessExpression(e.expression)&&e.expression.name.text==="select")&&e.arguments.length>=2&&s&&!t.isObjectLiteralExpression(s)&&r.push(`${n.path}|${a(s)}`);const l=e.arguments[1],u=P(t,e);u&&t.isIdentifier(u)&&u.text==="IconPicker"&&l&&t.isObjectLiteralExpression(l)&&l.properties.some(b=>f(b)==="emptyValue")&&p.push(c(l))}if(t.isImportSpecifier(e)&&e.propertyName&&(e.propertyName.text==="select"||e.propertyName.text==="IconPicker")&&r.push(`${n.path}|alias ${e.name.text}`),t.isBindingElement(e)&&e.propertyName&&t.isIdentifier(e.propertyName)&&e.propertyName.text==="select"&&r.push(`${n.path}|alias ${e.name.getText(i)}`),(t.isJsxOpeningElement(e)||t.isJsxSelfClosingElement(e))&&w.has(e.tagName.getText(i))){const s=e.attributes.properties.find(l=>t.isJsxAttribute(l)&&l.name.getText(i)==="label"),o=s&&t.isJsxAttribute(s)?s.initializer:void 0;r.push(`${n.path}|<${e.tagName.getText(i)}> ${o?a(t.isJsxExpression(o)?o.expression:o):"(no label)"}`)}if(t.isObjectLiteralExpression(e))for(const s of["type","kind"]){const o=d(x(e,s));o&&t.isStringLiteralLike(o)&&o.text==="select"&&!h(e)&&r.push(`${n.path}|${a(x(e,"label"))}`)}t.isJsxAttribute(e)&&e.name.getText(i)==="emptyValue"&&e.parent.parent.tagName.getText(i)==="IconPicker"&&p.push(c(e)),t.isJsxSpreadAttribute(e)&&e.parent.parent.tagName.getText(i)==="IconPicker"&&p.push(c(e)),t.forEachChild(e,m)};return m(i),{selects:r,emptyValues:p}}function y(t){const n=new Map;for(const i of t)n.set(i,(n.get(i)??0)+1);return n}function $(t,n,i){const{check:r,report:p}=S("shape rows use the picker");{const e=['const a = select("Corner shape", icon, options);','const b = { type: "select", label: "Card shape", options };','const c = { type: "select" as const, label: LABEL, options };',"const d = select(item);",'const e = iconPickerRow("Corner shape", icon, options, "a");','const f = <IconPicker label="x" emptyValue="none" options={o} />;','const g = <IconPicker label="x" options={o} />;','const h = <Other emptyValue="none" />;','// select("A comment", icon) is not a use','const i = select(say("Said"), icon, options);',"const j = select(LABELS.x, icon, options);","const k = select(`A ${b}`, icon, options);",'const l = { "type": "select", label, options };',"const m = select({ index }, other);",'import { select as pick } from "x";','const n = createElement(IconPicker<V>, { label: "x", emptyValue: "none" });','const o = createElement(IconPicker, { label: "x" });','const p = rows.select("By a member", icon, options);',"const { select: q } = rows;",'const r = { type: "select" satisfies string, label: "Satisfied", options };','const s = { kind: "select", label: "A kind", options };','const t = <SettingsSelect label="Hand drawn" options={o} />;',"const u = <FieldSelect value={v} options={o} />;",'const v = <IconPicker label="x" {...rest} />;','import { IconPicker as Pick } from "x";','const w = describedAs(field, { type: "select", label: "Described" });',"const x = rows.select(item);"].join(`
2
+ `),s=g(t,{path:"f.tsx",text:e});r("R1 finds the builder and both field forms, and nothing else",JSON.stringify(s.selects)===JSON.stringify(["f.tsx|Corner shape","f.tsx|Card shape","f.tsx|LABEL",'f.tsx|say("Said")',"f.tsx|LABELS.x","f.tsx|`A ${b}`","f.tsx|label","f.tsx|alias pick","f.tsx|By a member","f.tsx|alias q","f.tsx|Satisfied","f.tsx|A kind","f.tsx|<SettingsSelect> Hand drawn","f.tsx|<FieldSelect> (no label)","f.tsx|alias Pick"]),JSON.stringify(s.selects)),r("R2 finds emptyValue on an IconPicker only, in both forms, and a spread",JSON.stringify(s.emptyValues)==="[6,16,24]",JSON.stringify(s.emptyValues))}const c=n.filter(e=>/\.tsx?$/.test(e.path)&&!e.path.endsWith(".d.ts")&&!k(e.path)),d=[],a=[];for(const e of c){const s=g(t,e);d.push(...s.selects),s.emptyValues.forEach(o=>a.push(`${e.path}:${o}`))}const f=y(d),x=y(i.selectRows),h=[...f].filter(([e,s])=>s>(x.get(e)??0)).map(([e])=>e).sort(),m=[...x].filter(([e,s])=>s>(f.get(e)??0)).map(([e])=>e);return r("R1 every select row is on the repository's list",h.length===0,`${h.join(", ")}: a row that picks between shapes uses iconPickerRow or shapePickerRow; a row that picks words joins the list`),r("R1 every name on the list is still a select row",m.length===0,`${m.join(", ")}: remove the entry`),r("R2 no IconPicker takes emptyValue",a.length===0,`${a.join(", ")}: use pickerNoneIcon, so the closed word has the size of every other`),r(`walked the source (${c.length} TS/TSX files, at least ${i.minFiles})`,c.length>=i.minFiles),p()}export{$ as shapeRowsUseThePicker};
@@ -0,0 +1,5 @@
1
+ import type * as TS from "typescript";
2
+ export declare const ELEMENT_FACTORIES: ReadonlySet<string>;
3
+ export declare const ELEMENT_FACTORY_PATTERN = "(?:createElement|\\bh|_?jsxs?|_?jsxDEV)";
4
+ export declare function factoryCall(ts: typeof TS, call: TS.CallExpression): boolean;
5
+ export declare function elementOf(ts: typeof TS, call: TS.CallExpression): TS.Expression | undefined;
@@ -0,0 +1 @@
1
+ const i=new Set(["createElement","h","jsx","jsxs","jsxDEV","_jsx","_jsxs","_jsxDEV"]),o="(?:createElement|\\bh|_?jsxs?|_?jsxDEV)";function r(s,n){const e=n.expression;if(s.isIdentifier(e))return e.text;if(s.isPropertyAccessExpression(e))return e.name.text}function t(s,n){const e=r(s,n);return e!==void 0&&i.has(e)}function x(s,n){if(!t(s,n))return;let e=n.arguments[0];for(;e;)if(s.isParenthesizedExpression(e)||s.isAsExpression(e)||s.isNonNullExpression(e)||s.isSatisfiesExpression(e))e=e.expression;else if(s.isExpressionWithTypeArguments(e))e=e.expression;else break;return e}export{i as ELEMENT_FACTORIES,o as ELEMENT_FACTORY_PATTERN,x as elementOf,t as factoryCall};
@@ -1,3 +1,4 @@
1
+ import { type FontRegistry } from "./fonts.js";
1
2
  export declare const WORD_STYLES: readonly ["highlight", "strong", "quiet"];
2
3
  export type WordStyleName = (typeof WORD_STYLES)[number];
3
4
  export declare const WORD_STYLE_LABELS: Record<WordStyleName, string>;
@@ -40,14 +41,14 @@ export declare const WORD_STYLE_TEXT_GAP_MIN = -0.1;
40
41
  export declare const WORD_STYLE_TEXT_GAP_MAX = 0.5;
41
42
  export declare const WORD_STYLE_GAP_PRECISION = 3;
42
43
  export declare const DEFAULT_WORD_STYLES: Record<WordStyleName, ResolvedWordStyle>;
43
- export declare function normalizeWordStyle(v?: WordStyleValue | null): ResolvedWordStyle;
44
- export declare function normalizeWordStyles(v?: Partial<Record<WordStyleName, WordStyleValue | null>> | null): Record<WordStyleName, ResolvedWordStyle>;
45
- export declare function wordStyleIsDefault(name: WordStyleName, v?: WordStyleValue | null): boolean;
46
- export declare function wordStyleTokens(v?: Partial<Record<WordStyleName, WordStyleValue | null>> | null): Record<string, string>;
44
+ export declare function normalizeWordStyle(v?: WordStyleValue | null, registry?: FontRegistry): ResolvedWordStyle;
45
+ export declare function normalizeWordStyles(v?: Partial<Record<WordStyleName, WordStyleValue | null>> | null, registry?: FontRegistry): Record<WordStyleName, ResolvedWordStyle>;
46
+ export declare function wordStyleIsDefault(name: WordStyleName, v?: WordStyleValue | null, registry?: FontRegistry): boolean;
47
+ export declare function wordStyleTokens(v?: Partial<Record<WordStyleName, WordStyleValue | null>> | null, registry?: FontRegistry): Record<string, string>;
47
48
  export interface WordStylesRow {
48
49
  word_styles?: Partial<Record<string, WordStyleValue | null>> | null;
49
50
  }
50
- export declare function wordStylesFromRow(row?: WordStylesRow | null): Record<WordStyleName, ResolvedWordStyle>;
51
- export declare function wordStylesToRow(v?: Partial<Record<WordStyleName, WordStyleValue | null>> | null): {
51
+ export declare function wordStylesFromRow(row?: WordStylesRow | null, registry?: FontRegistry): Record<WordStyleName, ResolvedWordStyle>;
52
+ export declare function wordStylesToRow(v?: Partial<Record<WordStyleName, WordStyleValue | null>> | null, registry?: FontRegistry): {
52
53
  word_styles: Record<WordStyleName, ResolvedWordStyle>;
53
54
  };
@@ -1 +1 @@
1
- import{FONT_OPTIONS as a}from"./fonts.js";const i=["highlight","strong","quiet"],G={highlight:"Highlight",strong:"Bold",quiet:"Quiet"},T={highlight:{kind:"wordHighlight",delimiter:"@@"},strong:{kind:"wordStrong",delimiter:"++"},quiet:{kind:"wordQuiet",delimiter:"^^"}},N=Object.fromEntries(i.map(t=>[T[t].kind,t])),Y="data-sf-ws",g=["accent","text","labels"],E={accent:"var(--accent)",text:"var(--fg)",labels:"var(--fg-dim)"},O=80,h=120,m=100,L=900,R=.5,w=3,W=-.1,y=.5,D=3,s={font:null,size:null,weight:null,bold:null,italic:null,lineGap:null,textGap:null,colour:null},f={highlight:{...s},strong:{...s},quiet:{...s}};function _(t,e,o){return typeof t!="number"||!Number.isFinite(t)?null:Math.round(Math.min(Math.max(t,e),o))}function p(t,e,o){if(typeof t!="number"||!Number.isFinite(t))return null;const l=10**D;return Math.round(Math.min(Math.max(t,e),o)*l)/l}function d(t){return typeof t=="boolean"?t:null}function S(t){const e=typeof t?.font=="string"&&a.some(l=>l.key===t.font)?t.font:null,o=typeof t?.colour=="string"&&g.includes(t.colour)?t.colour:null;return{font:e,size:_(t?.size,O,h),weight:_(t?.weight,m,L),bold:d(t?.bold),italic:d(t?.italic),lineGap:p(t?.lineGap,R,w),textGap:p(t?.textGap,W,y),colour:o}}function c(t){const e={};for(const o of i)e[o]=t&&o in t&&t[o]?S(t[o]):{...f[o]};return e}function I(t,e){const o=S(e),l=f[t];return Object.keys(l).every(n=>o[n]===l[n])}function M(t){const e=c(t),o={};for(const l of i){const n=e[l],r=`--sf-ws-${l}`;if(n.font){const u=a.find(x=>x.key===n.font);u&&(o[`${r}-font`]=`var(${u.cssVar})`)}n.size!==null&&(o[`${r}-size`]=`${n.size/100}em`),n.weight!==null&&(o[`${r}-weight`]=String(n.weight)),n.bold!==null&&(o[`${r}-weight-bold`]=n.bold?"700":"400"),n.italic!==null&&(o[`${r}-style`]=n.italic?"italic":"normal"),n.lineGap!==null&&(o[`${r}-line`]=String(n.lineGap)),n.textGap!==null&&(o[`${r}-track`]=`${n.textGap}em`),n.colour!==null&&(o[`${r}-color`]=E[n.colour])}return o}function A(t){const e=t?.word_styles??void 0,o={};for(const l of i)e&&l in e&&(o[l]=e[l]??null);return c(o)}function $(t){return{word_styles:c(t)}}export{E as COLOUR_TOKEN,f as DEFAULT_WORD_STYLES,i as WORD_STYLES,Y as WORD_STYLE_ATTR,N as WORD_STYLE_BY_KIND,g as WORD_STYLE_COLOURS,D as WORD_STYLE_GAP_PRECISION,G as WORD_STYLE_LABELS,w as WORD_STYLE_LINE_GAP_MAX,R as WORD_STYLE_LINE_GAP_MIN,T as WORD_STYLE_MARKS,h as WORD_STYLE_SIZE_MAX,O as WORD_STYLE_SIZE_MIN,y as WORD_STYLE_TEXT_GAP_MAX,W as WORD_STYLE_TEXT_GAP_MIN,L as WORD_STYLE_WEIGHT_MAX,m as WORD_STYLE_WEIGHT_MIN,S as normalizeWordStyle,c as normalizeWordStyles,I as wordStyleIsDefault,M as wordStyleTokens,A as wordStylesFromRow,$ as wordStylesToRow};
1
+ import{POOL_FONT_REGISTRY as s}from"./fonts.js";const c=["highlight","strong","quiet"],G={highlight:"Highlight",strong:"Bold",quiet:"Quiet"},E={highlight:{kind:"wordHighlight",delimiter:"@@"},strong:{kind:"wordStrong",delimiter:"++"},quiet:{kind:"wordQuiet",delimiter:"^^"}},Y=Object.fromEntries(c.map(t=>[E[t].kind,t])),N="data-sf-ws",T=["accent","text","labels"],g={accent:"var(--accent)",text:"var(--fg)",labels:"var(--fg-dim)"},h=80,O=120,m=100,R=900,L=.5,w=3,y=-.1,W=.5,b=3,u={font:null,size:null,weight:null,bold:null,italic:null,lineGap:null,textGap:null,colour:null},f={highlight:{...u},strong:{...u},quiet:{...u}};function p(t,e,l){return typeof t!="number"||!Number.isFinite(t)?null:Math.round(Math.min(Math.max(t,e),l))}function d(t,e,l){if(typeof t!="number"||!Number.isFinite(t))return null;const o=10**b;return Math.round(Math.min(Math.max(t,e),l)*o)/o}function S(t){return typeof t=="boolean"?t:null}function x(t,e=s){const l=typeof t?.font=="string"&&e.byKey.has(t.font)?t.font:null,o=typeof t?.colour=="string"&&T.includes(t.colour)?t.colour:null;return{font:l,size:p(t?.size,h,O),weight:p(t?.weight,m,R),bold:S(t?.bold),italic:S(t?.italic),lineGap:d(t?.lineGap,L,w),textGap:d(t?.textGap,y,W),colour:o}}function a(t,e=s){const l={};for(const o of c)l[o]=t&&o in t&&t[o]?x(t[o],e):{...f[o]};return l}function I(t,e,l=s){const o=x(e,l),r=f[t];return Object.keys(r).every(n=>o[n]===r[n])}function M(t,e=s){const l=a(t,e),o={};for(const r of c){const n=l[r],i=`--sf-ws-${r}`;if(n.font){const _=e.byKey.get(n.font);_&&(o[`${i}-font`]=`var(${_.cssVar})`)}n.size!==null&&(o[`${i}-size`]=`${n.size/100}em`),n.weight!==null&&(o[`${i}-weight`]=String(n.weight)),n.bold!==null&&(o[`${i}-weight-bold`]=n.bold?"700":"400"),n.italic!==null&&(o[`${i}-style`]=n.italic?"italic":"normal"),n.lineGap!==null&&(o[`${i}-line`]=String(n.lineGap)),n.textGap!==null&&(o[`${i}-track`]=`${n.textGap}em`),n.colour!==null&&(o[`${i}-color`]=g[n.colour])}return o}function A(t,e=s){const l=t?.word_styles??void 0,o={};for(const r of c)l&&r in l&&(o[r]=l[r]??null);return a(o,e)}function $(t,e=s){return{word_styles:a(t,e)}}export{g as COLOUR_TOKEN,f as DEFAULT_WORD_STYLES,c as WORD_STYLES,N as WORD_STYLE_ATTR,Y as WORD_STYLE_BY_KIND,T as WORD_STYLE_COLOURS,b as WORD_STYLE_GAP_PRECISION,G as WORD_STYLE_LABELS,w as WORD_STYLE_LINE_GAP_MAX,L as WORD_STYLE_LINE_GAP_MIN,E as WORD_STYLE_MARKS,O as WORD_STYLE_SIZE_MAX,h as WORD_STYLE_SIZE_MIN,W as WORD_STYLE_TEXT_GAP_MAX,y as WORD_STYLE_TEXT_GAP_MIN,R as WORD_STYLE_WEIGHT_MAX,m as WORD_STYLE_WEIGHT_MIN,x as normalizeWordStyle,a as normalizeWordStyles,I as wordStyleIsDefault,M as wordStyleTokens,A as wordStylesFromRow,$ as wordStylesToRow};
@@ -16,8 +16,8 @@ export declare function heroMediaReading(p: {
16
16
  onClick: boolean;
17
17
  youTubeId: string | null;
18
18
  backgroundFile: boolean;
19
- desktopLayout: "one" | "side" | "stacked";
20
- phoneLayout: "one" | "side" | "stacked";
19
+ desktopLayout: "side" | "one" | "stacked";
20
+ phoneLayout: "side" | "one" | "stacked";
21
21
  twoPictures: boolean;
22
22
  };
23
23
  export declare function heroPartEntrance(partMotion: Record<string, unknown> | undefined, part: HeroMediaPart): Readonly<Record<import("../../format/lib/animation/views.js").MotionView, import("efficient-shell/ui").EntranceValue>> | null;
@@ -1 +1 @@
1
- "use client";import{Fragment as E,jsx as m,jsxs as O}from"react/jsx-runtime";import{createContext as P,useContext as p,useEffect as k,useId as A,useMemo as F,useRef as M}from"react";import{armEntrance as j}from"efficient-shell/format";import{blockCapsPartSize as D,blockDrawsTextStyle as K,partRuleForKind as y,partRuleForText as L,partStyleCss as N,publishedPartStyles as I}from"../lib/document/part-styles.js";import{useViewWidth as $}from"./SectionAnimation.js";import{useDrawsAtEdge as B}from"./InBoxContext.js";import{styleKeyForPart as H}from"../../format/lib/sections/section-text-kinds.js";import{NO_MOTIONS as J,PART_LIFT_ATTR as b,drawPartEntrance as W,drawPartScroll as Y,ensurePartLiftSheet as V,firstOnPage as T,partBoxOf as q,partMotionDrawn as z,partMoves as G}from"../lib/animation/part-motion.js";import{styleElementText as Q}from"../../format/lib/document/style-text.js";const h=P(null),R=P(null),_=P(null);function ce({needles:e,styles:t,motions:r=J,type:o,atEdge:n=!1,sizeCaps:a,children:c}){const i=A(),x=B(n?"edge":"by-box"),d=JSON.stringify([i,e,t,r,o,a]),s=F(()=>{const u=Object.keys(r).filter(l=>G(r[l]));return I(e,t,i,l=>H(o,l),l=>K(o,l),l=>u.includes(l)?z(r[l]):null,u,l=>D(a,l))},[d]);if(!s)return m(E,{children:c});const f=N(s,{inBox:x});return O(E,{children:[f&&m("style",{href:`${U}${i}-${X(f)}`,precedence:w,dangerouslySetInnerHTML:{__html:Q(f)}}),m(h.Provider,{value:s,children:c})]})}const g=new WeakMap;function v(e,t){const r=T(t.filter(n=>n.arm)),o=t.some(n=>n.entering)?void 0:T(t.filter(n=>n.scroll));for(const n of t)n!==r&&n.undo&&(n.undo(),n.undo=void 0),n!==o&&n.undoScroll&&(n.undoScroll(),n.undoScroll=void 0);r?.arm&&!r.undo&&(r.undo=r.arm()),o?.scroll&&!o.undoScroll&&(o.undoScroll=o.scroll()),t.some(n=>n.lift)?(V(e.ownerDocument),e.setAttribute(b,"")):e.removeAttribute(b)}function ie(e){const t=M(null),r=e?.motion?.entrance??null,o=e?.motion?.scroll??null,n=e?.motion?.hover==="lift",a=$(t,r!==null||o!==null),c=r?r[a]:null,i=o&&o[a].effect!=="none"?o[a]:null,x=JSON.stringify([c,i]);return k(()=>{const d=t.current,s=q(d?.parentElement??null);if(!r&&!o&&!n||!d||!s)return;const f=c?()=>{const S=W(s,c),C=j(s);return()=>{C?.(),S()}}:null,u=g.get(s)??[];g.set(s,u);const l={element:d,arm:f,entering:c!==null&&c.kind!=="none",scroll:i?()=>Y(s,i):null,lift:n};return u.push(l),v(s,u),()=>{const S=u.indexOf(l);S<0||(u.splice(S,1),l.undo?.(),l.undo=void 0,l.undoScroll?.(),l.undoScroll=void 0,v(s,u),u.length||g.delete(s))}},[x,n]),t}const w="sf-part-styles",U=`${w}-`;function X(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function ae(e){const t=p(h),r=p(R),o=L(t,e);return o&&o.stamp!==r?o:null}function de(e){return y(p(h),e)}function fe({stamp:e,children:t}){return m(R.Provider,{value:e,children:t})}function me({children:e}){const t=p(h);return m(_.Provider,{value:t,children:e})}function pe(e){return y(p(_),e)}export{fe as ClaimedStamp,w as PART_STYLES_PRECEDENCE,ce as PublishedPartStyles,me as SharedPartKinds,ie as usePartEntrance,de as usePublishedPartKindRule,ae as usePublishedPartRule,pe as usePublishedSharedKindRule};
1
+ "use client";import{Fragment as y,jsx as p,jsxs as O}from"react/jsx-runtime";import{createContext as x,useContext as S,useEffect as k,useId as F,useMemo as A,useRef as M}from"react";import{armEntrance as j}from"efficient-shell/format";import{blockCapsPartSize as D,blockDrawsTextStyle as K,partRuleForKind as E,partRuleForText as L,partStyleCss as N,publishedPartStyles as I}from"../lib/document/part-styles.js";import{useViewWidth as $}from"./SectionAnimation.js";import{useDrawsAtEdge as B}from"./InBoxContext.js";import{styleKeyForPart as H}from"../../format/lib/sections/section-text-kinds.js";import{NO_MOTIONS as J,PART_LIFT_ATTR as b,drawPartEntrance as W,drawPartScroll as Y,ensurePartLiftSheet as V,firstOnPage as R,partBoxOf as q,partMotionDrawn as z,partMoves as G}from"../lib/animation/part-motion.js";import{cssHash as Q,styleElementText as U}from"../../format/lib/document/style-text.js";import{useFontRegistry as X}from"./SiteFontsContext.js";const P=x(null),T=x(null),_=x(null);function ae({needles:t,styles:r,motions:o=J,type:n,atEdge:e=!1,sizeCaps:d,children:i}){const a=F(),h=B(e?"edge":"by-box"),f=JSON.stringify([a,t,r,o,n,d]),s=X(),m=A(()=>{const c=Object.keys(o).filter(l=>G(o[l]));return I(t,r,a,l=>H(n,l),l=>K(n,l),l=>c.includes(l)?z(o[l]):null,c,l=>D(d,l),s)},[f,s]);if(!m)return p(y,{children:i});const u=N(m,{inBox:h});return O(y,{children:[u&&p("style",{href:`${Z}${a}-${Q(u)}`,precedence:w,dangerouslySetInnerHTML:{__html:U(u)}}),p(P.Provider,{value:m,children:i})]})}const g=new WeakMap;function v(t,r){const o=R(r.filter(e=>e.arm)),n=r.some(e=>e.entering)?void 0:R(r.filter(e=>e.scroll));for(const e of r)e!==o&&e.undo&&(e.undo(),e.undo=void 0),e!==n&&e.undoScroll&&(e.undoScroll(),e.undoScroll=void 0);o?.arm&&!o.undo&&(o.undo=o.arm()),n?.scroll&&!n.undoScroll&&(n.undoScroll=n.scroll()),r.some(e=>e.lift)?(V(t.ownerDocument),t.setAttribute(b,"")):t.removeAttribute(b)}function de(t){const r=M(null),o=t?.motion?.entrance??null,n=t?.motion?.scroll??null,e=t?.motion?.hover==="lift",d=$(r,o!==null||n!==null),i=o?o[d]:null,a=n&&n[d].effect!=="none"?n[d]:null,h=JSON.stringify([i,a]);return k(()=>{const f=r.current,s=q(f?.parentElement??null);if(!o&&!n&&!e||!f||!s)return;const m=i?()=>{const l=W(s,i),C=j(s);return()=>{C?.(),l()}}:null,u=g.get(s)??[];g.set(s,u);const c={element:f,arm:m,entering:i!==null&&i.kind!=="none",scroll:a?()=>Y(s,a):null,lift:e};return u.push(c),v(s,u),()=>{const l=u.indexOf(c);l<0||(u.splice(l,1),c.undo?.(),c.undo=void 0,c.undoScroll?.(),c.undoScroll=void 0,v(s,u),u.length||g.delete(s))}},[h,e]),r}const w="sf-part-styles",Z=`${w}-`;function fe(t){const r=S(P),o=S(T),n=L(r,t);return n&&n.stamp!==o?n:null}function me(t){return E(S(P),t)}function pe({stamp:t,children:r}){return p(T.Provider,{value:t,children:r})}function Se({children:t}){const r=S(P);return p(_.Provider,{value:r,children:t})}function Pe(t){return E(S(_),t)}export{pe as ClaimedStamp,w as PART_STYLES_PRECEDENCE,ae as PublishedPartStyles,Se as SharedPartKinds,de as usePartEntrance,me as usePublishedPartKindRule,fe as usePublishedPartRule,Pe as usePublishedSharedKindRule};
@@ -0,0 +1,11 @@
1
+ import { type ReactNode } from "react";
2
+ import { type FontRegistry, type SiteFont } from "../../format/lib/fonts.js";
3
+ export declare function SiteFontsProvider({ siteFonts, children, }: {
4
+ siteFonts: readonly SiteFont[] | null | undefined;
5
+ children: ReactNode;
6
+ }): import("react").JSX.Element;
7
+ export declare function useFontRegistry(): FontRegistry;
8
+ export declare function SiteFontFaces({ usedKeys, preload }: {
9
+ usedKeys: Iterable<string>;
10
+ preload?: boolean;
11
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,2 @@
1
+ "use client";import{jsx as i,Fragment as m,jsxs as u}from"react/jsx-runtime";import{createContext as p,useContext as F,useMemo as x}from"react";import{POOL_FONT_REGISTRY as _,fontRegistry as d}from"../../format/lib/fonts.js";import{siteFontFaces as g}from"../../format/lib/site-font-faces.js";import{cssHash as h}from"../../format/lib/document/style-text.js";const a=p(_);function v({siteFonts:t,children:r}){const o=x(()=>d(t),[t]);return i(a.Provider,{value:o,children:r})}function j(){return F(a)}const f="sf-site-fonts";function R({usedKeys:t,preload:r=!0}){const o=j(),n=g(o,t),c=Object.entries(n.vars),s=[n.css,c.length?`:root { ${c.map(([e,l])=>`${e}: ${l}`).join("; ")} }`:""].filter(Boolean).join(`
2
+ `);return s?u(m,{children:[(r?n.preload:[]).map(e=>i("link",{rel:"preload",as:"font",type:"font/woff2",href:e.url,crossOrigin:""},e.id)),i("style",{href:`${f}-${h(s)}`,precedence:f,dangerouslySetInnerHTML:{__html:s}})]}):null}export{R as SiteFontFaces,v as SiteFontsProvider,j as useFontRegistry};
@@ -1,5 +1,5 @@
1
1
  import type { CSSProperties } from "react";
2
- import { type OwnFrame, type RootPadAttrs } from "./section-padding.js";
2
+ import { type OwnFrame, type RootPadAttrs, type TierFrames } from "./section-padding.js";
3
3
  import type { OwnPad } from "../document/blocks/general/section-to-box-row-parts.js";
4
4
  export declare const BANNER_OWN: OwnPad;
5
5
  export declare const CARDS_OWN: OwnPad;
@@ -22,12 +22,20 @@ export declare const SERIES_OWN: OwnPad;
22
22
  export declare const STATS_OWN: OwnPad;
23
23
  type Props = Record<string, unknown>;
24
24
  export declare const logosBandOwn: (props: Props) => OwnPad;
25
- type SectionOwnPad = {
25
+ export type SectionOwnPad = {
26
26
  readonly frame: (props: Props) => OwnFrame;
27
27
  readonly edge?: boolean;
28
28
  };
29
29
  export declare const SECTION_OWN_PADS: Readonly<Record<string, SectionOwnPad>>;
30
- export declare function sectionRootPad(type: string, props: Props): RootPadAttrs | null;
30
+ export declare function sectionRootPad(type: string, props: Props, ownPad?: SectionOwnPad): RootPadAttrs | null;
31
+ type SideFrame = number | TierFrames;
32
+ export declare function sectionSplitPads(type: string, props: Props, ownPad: SectionOwnPad | undefined, inner: {
33
+ firstBottom: SideFrame;
34
+ lastTop: SideFrame;
35
+ }): {
36
+ first: RootPadAttrs | null;
37
+ last: RootPadAttrs | null;
38
+ };
31
39
  export declare function withRootPad(className: string, pad: RootPadAttrs | null | undefined, style?: CSSProperties): {
32
40
  className: string;
33
41
  style?: CSSProperties;
@@ -1 +1 @@
1
- import{framePadAttrs as f,padValuesOf as _,SECTION_PAD_KEYS as d}from"./section-padding.js";import{parseSectionHeadPlacement as i}from"../../../format/lib/sections/section-head-placement.js";import{parseSectionHeadStyle as N}from"../../../format/lib/sections/section-head-style.js";import{readHidable as T}from"efficient-easel/draw";import{TICKER_PAD as S}from"../../../format/lib/sections/strip-shape.js";import{finiteNumber as A}from"../../../format/lib/finite-number.js";import{ownEntry as l}from"../../../format/lib/own-entry.js";const E={top:24,bottom:24,topPhone:24,bottomPhone:24},u={top:72,bottom:72,topPhone:72,bottomPhone:72},s={top:100,bottom:100,topPhone:60,bottomPhone:60},x={top:120,bottom:120,topPhone:70,bottomPhone:70},W={top:24,bottom:24,topPhone:24,bottomPhone:24},D=40,C={top:120,bottom:120,topTablet:80,bottomTablet:80,topPhone:80,bottomPhone:80},R={top:24,bottom:24,topPhone:24,bottomPhone:24},g={top:24,bottom:24,topPhone:24,bottomPhone:24},I={top:84,bottom:84,topPhone:84,bottomPhone:84},B={top:48,bottom:48,topPhone:48,bottomPhone:48},M={top:80,bottom:80,topPhone:60,bottomPhone:60},y={top:100,bottom:60,topPhone:60,bottomPhone:40},L={top:60,bottom:60,topPhone:40,bottomPhone:40},F={top:80,bottom:80,topTablet:60,bottomTablet:60,topPhone:60,bottomPhone:60},H={top:76,bottom:76,topPhone:76,bottomPhone:76},G={top:76,bottom:76,topPhone:76,bottomPhone:76},P={top:80,bottom:40,topPhone:60,bottomPhone:32},h={top:76,bottom:76,topPhone:76,bottomPhone:76},k={top:72,bottom:72,topPhone:72,bottomPhone:72},Y={top:40,bottom:64,topPhone:24,bottomPhone:36},w={top:120,bottom:120,topPhone:80,bottomPhone:80,topTablet:80,bottomTablet:80},K={top:48,bottom:48,topPhone:48,bottomPhone:48},U=o=>{const t=A(o.bandPadding)??D;return{top:t,bottom:t,topPhone:t,bottomPhone:t}},c=(o,t,n)=>({desktop:o,tablet:t,mobile:n}),p=o=>i(o.headPlacement)==="own-box",e=(o,t)=>({top:c(o.top,t?.top??o.topTablet??o.top,o.topPhone),bottom:c(o.bottom,t?.bottom??o.bottomTablet??o.bottom,o.bottomPhone)}),O=o=>({top:o.topPhone,bottom:o.bottomPhone}),r=o=>t=>p(t)?{top:0,bottom:o.bottom}:o,V=(o,t)=>{const n=T(o[t]);return n.hidden?!1:!!n.text||o.editor?.isEditing===!0},j={Banner:{frame:()=>e(E)},Cards:{frame:r(e(u))},Chart:{frame:()=>e(h)},ContactLocations:{frame:()=>e(s,O(s))},Countdown:{frame:()=>e(B)},DocBody:{frame:()=>e(M)},DocMasthead:{frame:()=>e(y)},DocMetaCards:{frame:()=>e(L)},FAQ:{frame:o=>{const t=p(o)||!["num","title","linkText"].some(m=>V(o,m)),n=e(x);return t?{top:0,bottom:n.bottom}:n},edge:!0},FeaturedCover:{frame:()=>e(F)},Grid:{frame:()=>e(W)},Integrations:{frame:()=>e(H)},KeyFeatures:{frame:()=>e(G)},Logos:{frame:o=>p(o)?0:e(U(o))},LongRead:{frame:r(e(C))},Masthead:{frame:()=>e(P,O(P))},Mockup:{frame:()=>e(h)},OrderSummary:{frame:()=>e(R)},PaymentBadges:{frame:()=>e(g)},Prose:{frame:r(e(k))},SectionHeader:{frame:o=>{const t=e(Y);return N(o.headStyle)==="standard"?t:{top:t.top,bottom:0}},edge:!0},Series:{frame:r(e(w))},Stats:{frame:()=>e(K)},Testimonials:{frame:r(e(I))},Ticker:{frame:()=>e(S),edge:!0}};function oo(o,t){const n=l(j,o);return n?f({values:_(t,d,!0),frame:n.frame(t),drawsFrame:!0,edge:n.edge},!0).root:null}const v=/^(?:[^\s]*:)?p[ytb]-/;function to(o,t,n){if(!t)return n?{className:o,style:n}:{className:o};const m=o.split(/\s+/).filter(b=>b&&!v.test(b)),a={...n,...t.style};return{className:[...m,t.className].filter(Boolean).join(" "),...Object.keys(a).length?{style:a}:{},...t.attrs}}export{E as BANNER_OWN,u as CARDS_OWN,s as CONTACT_LOCATIONS_OWN,B as COUNTDOWN_OWN,M as DOC_BODY_OWN,y as DOC_MASTHEAD_OWN,L as DOC_META_CARDS_OWN,x as FAQ_OWN,F as FEATURED_COVER_OWN,H as INTEGRATIONS_OWN,G as KEY_FEATURES_OWN,C as LONG_READ_OWN,P as MASTHEAD_OWN,g as PAYMENT_BADGES_OWN,h as PROOF_OWN,k as PROSE_OWN,Y as SECTION_HEADER_OWN,j as SECTION_OWN_PADS,w as SERIES_OWN,K as STATS_OWN,U as logosBandOwn,oo as sectionRootPad,to as withRootPad};
1
+ import{framePadAttrs as P,padValuesOf as c,SECTION_PAD_KEYS as h}from"./section-padding.js";import{parseSectionHeadPlacement as E}from"../../../format/lib/sections/section-head-placement.js";import{parseSectionHeadStyle as x}from"../../../format/lib/sections/section-head-style.js";import{readHidable as W,VIEW_TIERS as D,viewKeyAt as C}from"efficient-easel/draw";import{TICKER_PAD as R}from"../../../format/lib/sections/strip-shape.js";import{finiteNumber as g}from"../../../format/lib/finite-number.js";import{ownEntry as f}from"../../../format/lib/own-entry.js";const I={top:24,bottom:24,topPhone:24,bottomPhone:24},B={top:72,bottom:72,topPhone:72,bottomPhone:72},i={top:100,bottom:100,topPhone:60,bottomPhone:60},y={top:120,bottom:120,topPhone:70,bottomPhone:70},M={top:24,bottom:24,topPhone:24,bottomPhone:24},F=40,L={top:120,bottom:120,topTablet:80,bottomTablet:80,topPhone:80,bottomPhone:80},w={top:24,bottom:24,topPhone:24,bottomPhone:24},H={top:24,bottom:24,topPhone:24,bottomPhone:24},G={top:84,bottom:84,topPhone:84,bottomPhone:84},k={top:48,bottom:48,topPhone:48,bottomPhone:48},v={top:80,bottom:80,topPhone:60,bottomPhone:60},K={top:100,bottom:60,topPhone:60,bottomPhone:40},Y={top:60,bottom:60,topPhone:40,bottomPhone:40},U={top:80,bottom:80,topTablet:60,bottomTablet:60,topPhone:60,bottomPhone:60},V={top:76,bottom:76,topPhone:76,bottomPhone:76},j={top:76,bottom:76,topPhone:76,bottomPhone:76},O={top:80,bottom:40,topPhone:60,bottomPhone:32},d={top:76,bottom:76,topPhone:76,bottomPhone:76},Q={top:72,bottom:72,topPhone:72,bottomPhone:72},q={top:40,bottom:64,topPhone:24,bottomPhone:36},z={top:120,bottom:120,topPhone:80,bottomPhone:80,topTablet:80,bottomTablet:80},J={top:48,bottom:48,topPhone:48,bottomPhone:48},X=o=>{const t=g(o.bandPadding)??F;return{top:t,bottom:t,topPhone:t,bottomPhone:t}},_=(o,t,n)=>({desktop:o,tablet:t,mobile:n}),s=o=>E(o.headPlacement)==="own-box",e=(o,t)=>({top:_(o.top,t?.top??o.topTablet??o.top,o.topPhone),bottom:_(o.bottom,t?.bottom??o.bottomTablet??o.bottom,o.bottomPhone)}),u=o=>({top:o.topPhone,bottom:o.bottomPhone}),a=o=>t=>s(t)?{top:0,bottom:o.bottom}:o,Z=(o,t)=>{const n=W(o[t]);return n.hidden?!1:!!n.text||o.editor?.isEditing===!0},l={Banner:{frame:()=>e(I)},Cards:{frame:a(e(B))},Chart:{frame:()=>e(d)},ContactLocations:{frame:()=>e(i,u(i))},Countdown:{frame:()=>e(k)},DocBody:{frame:()=>e(v)},DocMasthead:{frame:()=>e(K)},DocMetaCards:{frame:()=>e(Y)},FAQ:{frame:o=>{const t=s(o)||!["num","title","linkText"].some(r=>Z(o,r)),n=e(y);return t?{top:0,bottom:n.bottom}:n},edge:!0},FeaturedCover:{frame:()=>e(U)},Grid:{frame:()=>e(M)},Integrations:{frame:()=>e(V)},KeyFeatures:{frame:()=>e(j)},Logos:{frame:o=>s(o)?0:e(X(o))},LongRead:{frame:a(e(L))},Masthead:{frame:()=>e(O,u(O))},Mockup:{frame:()=>e(d)},OrderSummary:{frame:()=>e(w)},PaymentBadges:{frame:()=>e(H)},Prose:{frame:a(e(Q))},SectionHeader:{frame:o=>{const t=e(q);return x(o.headStyle)==="standard"?t:{top:t.top,bottom:0}},edge:!0},Series:{frame:a(e(z))},Stats:{frame:()=>e(J)},Testimonials:{frame:a(e(G))},Ticker:{frame:()=>e(R),edge:!0}};function so(o,t,n){const r=f(l,o)??n;return r?P({values:c(t,h,!0),frame:r.frame(t),drawsFrame:!0,edge:r.edge},!0).root:null}const N=(o,t)=>typeof o=="object"&&"top"in o?o[t]:o;function $(o,t){const n={...o};for(const r of D)delete n[C(t,r)];return n}function bo(o,t,n,r){const m=f(l,o)??n;if(!m)return{first:null,last:null};const p=m.frame(t),S=c(t,h,!0),b=(T,A)=>P({values:$(S,T),frame:A,drawsFrame:!0,edge:m.edge},!0).root;return{first:b("bottom",{top:N(p,"top"),bottom:r.firstBottom}),last:b("top",{top:r.lastTop,bottom:N(p,"bottom")})}}const oo=/^(?:[^\s]*:)?p[ytb]-/;function Po(o,t,n){if(!t)return n?{className:o,style:n}:{className:o};const r=o.split(/\s+/).filter(p=>p&&!oo.test(p)),m={...n,...t.style};return{className:[...r,t.className].filter(Boolean).join(" "),...Object.keys(m).length?{style:m}:{},...t.attrs}}export{I as BANNER_OWN,B as CARDS_OWN,i as CONTACT_LOCATIONS_OWN,k as COUNTDOWN_OWN,v as DOC_BODY_OWN,K as DOC_MASTHEAD_OWN,Y as DOC_META_CARDS_OWN,y as FAQ_OWN,U as FEATURED_COVER_OWN,V as INTEGRATIONS_OWN,j as KEY_FEATURES_OWN,L as LONG_READ_OWN,O as MASTHEAD_OWN,H as PAYMENT_BADGES_OWN,d as PROOF_OWN,Q as PROSE_OWN,q as SECTION_HEADER_OWN,l as SECTION_OWN_PADS,z as SERIES_OWN,J as STATS_OWN,X as logosBandOwn,so as sectionRootPad,bo as sectionSplitPads,Po as withRootPad};
@@ -1,5 +1,5 @@
1
1
  import { type TextStyleCase, type ViewTier } from "efficient-easel/draw";
2
- import { type FontRole } from "../../../format/lib/fonts.js";
2
+ import { type FontRegistry, type FontRole } from "../../../format/lib/fonts.js";
3
3
  import type { PartEl } from "../../../editor/lib/document/part-anchors.js";
4
4
  import { type PartNeedle } from "./text-parts.js";
5
5
  import { type TextRegion } from "../../../format/lib/sections/text-regions.js";
@@ -130,6 +130,7 @@ export declare function partCaseTransform(value: TextStyleCase | undefined): str
130
130
  export type PartDeclarationOptions = {
131
131
  blockDrawsStyle?: boolean;
132
132
  sizeCap?: boolean;
133
+ fonts?: FontRegistry;
133
134
  };
134
135
  export declare const PART_SIZE_CAP_VAR = "--sf-part-size-cap";
135
136
  export declare function blockCapsPartSize(caps: Readonly<Record<string, true>> | undefined, partKey: string): boolean;
@@ -167,21 +168,22 @@ export type MeasuredPartStyle = {
167
168
  paddingTop: string;
168
169
  };
169
170
  export declare function partStyleBase(measured: MeasuredPartStyle, fontKey: string): PartStyleBase;
170
- export declare function partFontKeyOf(family: string, resolve: (cssVar: string) => string): string;
171
+ export declare function partFontKeyOf(family: string, resolve: (cssVar: string) => string, registry?: FontRegistry): string;
171
172
  export declare function partStyleSource<E extends {
172
173
  getAttribute(name: string): string | null;
173
174
  }>(nodeId: string, selectedPartId: string | null, selectedElements: readonly E[], declaresStyle: (className: string | null) => boolean): E | null;
174
175
  export declare function storedPartStyle(styles: PartStyles, styleKey: string): PartStyle;
175
- export declare function applyPartStyles(stamps: readonly StyledPartStamp[], styles: PartStyles, baseOf?: (element: StyledPartEl) => PartStyleBase, styleKeyOf?: (partKey: string) => string, isInline?: (element: StyledPartEl) => boolean, screen?: PartScreen, drawsStyle?: (partKey: string) => boolean, capsSize?: (partKey: string) => boolean): number;
176
+ export declare function applyPartStyles(stamps: readonly StyledPartStamp[], styles: PartStyles, baseOf?: (element: StyledPartEl) => PartStyleBase, styleKeyOf?: (partKey: string) => string, isInline?: (element: StyledPartEl) => boolean, screen?: PartScreen, drawsStyle?: (partKey: string) => boolean, capsSize?: (partKey: string) => boolean, fonts?: FontRegistry): number;
176
177
  export declare function regionSheetStyle(style: PartStyle | undefined | null): PartStyle | null;
177
178
  export declare function regionCanvasDeclarations(style: PartStyle | undefined | null, screen: PartScreen, options?: {
178
179
  sizeCap?: boolean;
180
+ fonts?: FontRegistry;
179
181
  }): {
180
182
  fontFamily?: string;
181
183
  fontSize?: string;
182
184
  };
183
185
  export declare function regionHasOwnLook(style: PartStyle | undefined | null): boolean;
184
- export declare function regionShownDeclarations(style: PartStyle | undefined | null, region: TextRegion, screen: PartScreen): ShownDeclarations;
186
+ export declare function regionShownDeclarations(style: PartStyle | undefined | null, region: TextRegion, screen: PartScreen, fonts?: FontRegistry): ShownDeclarations;
185
187
  export declare function regionCanvasRestore(style: {
186
188
  fontFamily: string;
187
189
  fontSize: string;
@@ -221,7 +223,7 @@ export type PublishedPartSheet = {
221
223
  kindRules: ReadonlyMap<string, PublishedPartRule>;
222
224
  drawn: ReadonlySet<string>;
223
225
  };
224
- export declare function publishedPartStyles(needles: readonly PartNeedle[], styles: PartStyles, scope: string, styleKeyOf?: (partKey: string) => string, drawsStyle?: (partKey: string) => boolean, motionOf?: (styleKey: string) => PublishedPartMotion | null, motionKeys?: readonly string[], capsSize?: (partKey: string) => boolean): PublishedPartSheet | null;
226
+ export declare function publishedPartStyles(needles: readonly PartNeedle[], styles: PartStyles, scope: string, styleKeyOf?: (partKey: string) => string, drawsStyle?: (partKey: string) => boolean, motionOf?: (styleKey: string) => PublishedPartMotion | null, motionKeys?: readonly string[], capsSize?: (partKey: string) => boolean, fonts?: FontRegistry): PublishedPartSheet | null;
225
227
  export declare function isPartKindKey(key: string): boolean;
226
228
  export declare function partRuleForKind(sheet: PublishedPartSheet | null, kind: string): PublishedPartRule | null;
227
229
  export declare function viewMediaOf(inBox: boolean): {
@@ -1,2 +1,2 @@
1
- import{textStyleCaseCss as pe,textStyleCaseOfCss as de,viewKeyAt as Y}from"efficient-easel/draw";import{FONT_OPTIONS as ge,fontOption as xe,fontRoleOf as $,SIZE_STEP_OF_ROLE as F}from"../../../format/lib/fonts.js";import{encodePartKey as V}from"../../../format/lib/document/part-key.js";import{decodePartId as Z,normalizePartText as y}from"./text-parts.js";import{partInkCss as he}from"../../../format/lib/document/part-inks.js";import{regionStyle as Se}from"../../../format/lib/sections/text-regions.js";import{EDGE_PHONE_MEDIA as be,EDGE_TABLET_MEDIA as me,PHONE_MEDIA as Te,TABLET_MEDIA as Pe,viewOverrides as ze}from"../content/view-values.js";import{plainRecord as M,propsWithPartRecord as _e,readPartRecord as Ae,readPartRecords as Re}from"../../../format/lib/document/part-records.js";import{isLengthUnit as L}from"efficient-easel/screen/lib/content/length-units";import{cssLengthOf as A,storedUnit as Ee}from"../../../format/lib/content/css-length.js";import{hasOwnEntry as k,ownEntry as q}from"../../../format/lib/own-entry.js";const D="_partStyles",we="data-sf-part-styled",J="data-sf-text-style",$e=/^(heading|body)-[1-7]$/;function m(e){return typeof e=="string"&&$e.test(e)}const Q={heading:"heading-1",heading2:"heading-2",heading3:"heading-3",body:"body-1",label:"body-5"};function ke(e){if(!e)return null;for(const[t,n]of Object.entries(Q))if(n===e)return t;return null}function jt(e){if(m(e.textStyle))return e.textStyle;const t=$(e.role);return t?Q[t]:void 0}const Ne=[400,500,600,700],E=["left","center","right","justify"],H=5,C=1e3,Oe=-5,Ie=10,Fe=0,ye=64,Me=2,ee={size:{min:H,max:C,step:1},sizeTablet:{min:H,max:C,step:1},sizePhone:{min:H,max:C,step:1},padding:{min:Fe,max:ye,step:Me}},Le=.05,De=.01,He=["line","letter"],Ce=.5,Ue=2.5,je=-1,ve=1,We=0,Ge=400,Ke=[...new Set(Object.values(F))];function vt(e){return[`${e} { transition: translate var(--page-motion-hover-duration) var(--page-ease-media) var(--page-motion-hover-delay) }`,`${e}:hover, ${e}:active { translate: 0 calc(-1 * var(--page-hover-lift)) }`]}function Wt(e){return Re(e,D)}function te(e,t){return Ae(e,D,t)}function Gt(e,t){return Object.values(te(e,t)).filter(n=>n!==void 0).length}function ne(e,t,n){return _e(e,D,t,Be(n).length?n:null)}function Be(e){return Object.entries(e).filter(([,t])=>t!==void 0)}function Xe(e){return He.includes(e)}const w=(e,t,n)=>Math.min(n,Math.max(t,e)),Ye=["sizeUnit","sizeUnitTablet","sizeUnitPhone"];function U(e){const t=Y("sizeUnit",e),n=Ye.find(i=>i===t);if(!n)throw new Error(`a part stores no unit key ${t}`);return n}const T={size:U("desktop"),sizeTablet:U("tablet"),sizePhone:U("mobile"),paragraphSpacing:"paragraphSpacingUnit",padding:"paddingUnit"},ie=Object.values(T);function h(e,t){return Ee(e[T[t]])}function Ve(e,t,n={}){if(ie.includes(e))return L(t)&&t!=="px"?t:null;if(k(T,e)&&h(n,e)!=="px"){const i=z(Number(t),2);return!Number.isFinite(i)||i<0||i===0&&e!=="padding"?null:i}if(Xe(e)){const i=Math.round(Number(t));return!Number.isFinite(i)||i===0?null:w(i,Oe,Ie)}if(e==="lineHeight"){const i=Number(t);return Number.isFinite(i)?z(w(i,Ce,Ue),3):null}if(e==="letterSpacing"){const i=Number(t);return Number.isFinite(i)?z(w(i,je,ve),4):null}if(e==="paragraphSpacing"){const i=Math.round(Number(t));return!Number.isFinite(i)||i<=0?null:w(i,We,Ge)}if(k(ee,e)){const{min:i,max:o}=ee[e],r=Math.round(Number(t));return Number.isFinite(r)?w(r,i,o):null}return e==="italic"?typeof t=="boolean"?t:null:e==="role"||e==="fontRole"?$(t)?t:null:e==="sizeToken"?j(t)?t:null:e==="textStyle"?m(t)?t:null:e==="alignPhone"||e==="alignTablet"?E.includes(t)?t:null:t}const Ze=["weight","size","sizeTablet","sizePhone","line","letter","lineHeight","letterSpacing","paragraphSpacing","padding"];function R(e){let t=null;const n=i=>{t??={...e},delete t[i]};for(const i of Ze){const o=e[i];o!==void 0&&!(typeof o=="number"&&Number.isFinite(o))&&n(i)}e.align!==void 0&&!E.includes(e.align)&&n("align"),e.alignTablet!==void 0&&!E.includes(e.alignTablet)&&n("alignTablet"),e.alignPhone!==void 0&&!E.includes(e.alignPhone)&&n("alignPhone"),e.textStyle!==void 0&&!m(e.textStyle)&&n("textStyle"),e.sizeToken!==void 0&&!j(e.sizeToken)&&n("sizeToken"),e.fontRole!==void 0&&!$(e.fontRole)&&n("fontRole");for(const i of ie)e[i]!==void 0&&!L(e[i])&&n(i);return t??e}function j(e){if(!e||typeof e!="object")return!1;const{step:t,px:n,stepPhone:i,pxPhone:o,fluid:r}=e,f=c=>typeof c=="number"&&Number.isFinite(c)&&c>0,s=c=>typeof c=="string"&&Ke.includes(c);return s(t)&&f(n)&&(i===void 0||s(i))&&(o===void 0||f(o))&&(r===void 0||qe(r,n))}function qe(e,t){if(!e||typeof e!="object"||Array.isArray(e))return!1;const{minPx:n,vw:i,...o}=e;return Object.keys(o).length===0&&typeof n=="number"&&Number.isFinite(n)&&n>0&&n<t&&typeof i=="number"&&Number.isFinite(i)&&i>0&&i<=100}function v(e){return e?.pxPhone&&j(e)?{step:e.stepPhone??e.step,px:e.pxPhone}:null}function oe({step:e,px:t,fluid:n}){const i=n?`clamp(${n.minPx}px, ${n.vw}vw, ${t}px)`:`${t}px`,o=`var(--size-${e}, ${i})`;return e.startsWith("heading")?`min(${o}, var(--sf-heading-max,9999px))`:o}const Je=[["font","role"],["font","fontRole"],["role","textStyle"],["line","lineHeight"],["letter","letterSpacing"]];function Qe(e){const t=[];for(const[n,i]of Je)n===e?t.push(i):i===e&&t.push(n);return t}function Kt(e,t,n,i){const o={...te(e,t)},r=i==null?null:Ve(n,i,o);if(r===null)delete o[n];else{o[n]=r;for(const f of Qe(n))delete o[f]}return ne(e,t,o)}function Bt(e,t){return ne(e,t,{})}function et(e){return de(e)??"none"}function tt(e){return pe(e)??""}const re={heading:"--font-role-heading",heading2:"--font-role-heading2",heading3:"--font-role-heading3",body:"--font-role-body",accent:"--font-role-accent",label:"--font-role-label"};function nt(e,t){const n=$(e.role);return n||(t?.blockDrawsStyle?null:ke(e.textStyle))}const it="--sf-part-size-cap";function W(e,t){return e&&t?.sizeCap?`min(${e}, var(${it}, ${e}))`:e}function Xt(e,t){return e?.[t]===!0}function Yt(e,t){return e==="Text"&&t==="text"}const ot={headingLarge:"min(clamp(64px,9vw,144px), var(--sf-heading-max,9999px))",headingMedium:"min(32px, var(--sf-heading-max,9999px))",headingSmall:"min(24px, var(--sf-heading-max,9999px))",accent:"32px",body:"14px",label:"12px"};function rt(e){const t=F[e],n=q(ot,t);return n?`var(--size-${t}, ${n})`:`var(--size-${t})`}function at(e){const t={};return typeof e.lineHeight=="number"?t.lineHeight=e.lineHeight:e.line&&(t.lineHeight=z(st+e.line*Le,3)),typeof e.letterSpacing=="number"?t.letterSpacingEm=e.letterSpacing:e.letter&&(t.letterSpacingEm=z(e.letter*De,4)),t}const st=1,P="--sf-part-para";function ft(e,t){e=R(e);const n={};if(typeof e.sizePhone=="number"&&e.sizePhone>0)n.fontSize=A(e.sizePhone,h(e,"sizePhone"));else{const o=v(e.sizeToken);if(o)n.fontSize=oe(o);else{const r=O(e);r!==void 0&&(n.fontSize=A(r,h(e,"sizeTablet")))}}n.fontSize&&(n.fontSize=W(n.fontSize,t));const i=e.alignPhone??N(e);return i&&(n.textAlign=i),n}function N(e){return e.alignTablet&&e.alignTablet!==e.align?e.alignTablet:void 0}function O(e){const n=e.sizeTablet!==void 0&&h(e,"sizeTablet")!==h(e,"size")?e.sizeTablet:ze("textSize",e.size,e.sizeTablet,void 0).tablet;return n&&n>0?n:void 0}function ct(e,t){const n=R(e),i={},o=O(n);o!==void 0&&(i.fontSize=W(A(o,h(n,"sizeTablet")),t));const r=N(n);return r&&(i.textAlign=r),i}function Vt(e,t){if(t==="desktop")return;const n=R(e);return(t==="mobile"?N(n):void 0)??n.align}function lt(e,t){if(t==="desktop")return e;const n=R(e),i=O(n),o=N(n);if(t==="tablet"){let s=e;return i!==void 0&&(s={...s,size:i,sizeUnit:n[T.sizeTablet]}),o&&(s={...s,align:o}),s}let r=e;if(typeof n.sizePhone=="number"&&n.sizePhone>0)r={...r,size:n.sizePhone,sizeUnit:n[T.sizePhone]};else{const s=v(n.sizeToken);s?r={...r,size:void 0,sizeToken:s}:i!==void 0&&(r={...r,size:i,sizeUnit:n[T.sizeTablet]})}const f=n.alignPhone??o;return f&&(r={...r,align:f}),r}function G(e,t,n){return K(lt(e,t),I,n)}function ut(e){return Y("size",e)}function Zt(e,t){if(t==="desktop")return null;const n=R(e);if(t==="mobile"){if(v(n.sizeToken))return null;const i=O(n);if(i!==void 0)return{px:i,view:"tablet"}}return typeof n.size=="number"&&n.size>0?{px:n.size,view:"desktop"}:null}function ae(e,t){const n=ut(t);if(!k(e,n))return e;const i={...e};return delete i[n],i}function qt(e,t,n){const i=G(ae(e,t),t,n);return{fontFamily:i.fontFamily,fontSize:i.fontSize}}function K(e,t,n){e=R(e);const i=nt(e,n),o=at(e),r=W(e.size?A(e.size,h(e,"size")):e.sizeToken?oe(e.sizeToken):i?rt(i):"",n);return{fontFamily:e.font?xt(e.font):e.fontRole?`var(${re[e.fontRole]})`:i?`var(${re[i]})`:"",fontWeight:e.weight?String(e.weight):"",fontSize:r,minWidth:r?"0":"",overflowWrap:r?"break-word":"",lineHeight:o.lineHeight!==void 0?String(o.lineHeight):"",letterSpacing:o.letterSpacingEm!==void 0?`${o.letterSpacingEm}em`:"",[P]:e.paragraphSpacing?A(e.paragraphSpacing,h(e,"paragraphSpacing")):"",textTransform:tt(e.case),textAlign:e.align??"",paddingTop:se(e.padding,h(e,"padding")),paddingBottom:se(e.padding,h(e,"padding")),color:pt(e.color),fontStyle:e.italic===!0?"italic":e.italic===!1?"normal":""}}const pt=e=>he(e),se=(e,t)=>e===void 0?"":A(e,t),z=(e,t)=>Number(e.toFixed(t));function Jt(e,t){const n=Number.parseFloat(e.fontSize)||16,i=Number.parseFloat(e.lineHeight),o=Number.parseFloat(e.letterSpacing),r=Number.parseFloat(e.paddingTop);return{fontKey:t,sizePx:n,weight:dt(Number.parseInt(e.fontWeight,10)),lineRatio:Number.isFinite(i)?z(i/n,3):1.2,letterEm:Number.isFinite(o)?z(o/n,4):0,align:gt(e.textAlign),case:et(e.textTransform),paddingPx:Number.isFinite(r)?Math.round(r):0}}function dt(e){return Number.isFinite(e)?Ne.reduce((t,n)=>Math.abs(n-e)<Math.abs(t-e)?n:t):400}function gt(e){for(const t of E)if(t===e)return t;return e==="end"?"right":"left"}function Qt(e,t){const n=fe(e);if(!n)return"";for(const i of ge)if(fe(t(i.cssVar))===n)return i.key;return""}const fe=e=>(e.split(",")[0]??"").replace(/["']/g,"").replace(/\s+/g," ").trim().toLowerCase();function xt(e){const t=xe(e);return t?`var(${t.cssVar})`:""}function en(e,t,n,i){return!t||Z(t)?.nodeId!==e?null:n.find(r=>i(r.getAttribute("class")))??n[0]??null}function ht(e,t){return M(q(e,t))??{}}function tn(e,t,n=()=>I,i=c=>c,o=mt,r="desktop",f=()=>!1,s=()=>!1){let c=0;for(const{element:p,partId:S}of e){const g=Z(S)?.propKey;if(!g)continue;const a=ht(t,i(g)),l=G(a,r,{blockDrawsStyle:f(g),sizeCap:s(g)});m(a.textStyle)?p.setAttribute?.(J,a.textStyle):p.removeAttribute?.(J);const x=X.some(u=>p.style[u]);let d=!1;for(const[u,b]of Object.entries(l))zt(p,u,b),b&&(d=!0);if(x||X.some(u=>l[u]))for(const u of St(p,o))for(const b of X)u.style[b]=l[b]??"";d&&(c+=1)}return c}function St(e,t){const n=y(e.textContent??""),i=[];let o=e;for(let r=0;r<bt&&t(o);r+=1){const f=o.parentElement;if(!f||y(f.textContent??"")!==n)break;i.push(f),o=f}return i}const bt=8;function mt(e){const t=e;return typeof window>"u"||!t?.ownerDocument?!1:window.getComputedStyle(t).display==="inline"}const I={fontKey:"",sizePx:16,weight:400,lineRatio:1,letterEm:0,align:"left",case:"none",paddingPx:0};function Tt(e){if(!e||typeof e!="object")return null;const t={};m(e.textStyle)&&(t.textStyle=e.textStyle),typeof e.size=="number"&&e.size>0&&(t.size=e.size),typeof e.sizeTablet=="number"&&e.sizeTablet>0&&(t.sizeTablet=e.sizeTablet),typeof e.sizePhone=="number"&&e.sizePhone>0&&(t.sizePhone=e.sizePhone);for(const n of["size","sizeTablet","sizePhone"]){const i=T[n];t[n]!==void 0&&L(e[i])&&(t[i]=e[i])}return Object.keys(t).length?t:null}function Pt(e,t,n){const i=Tt(e);if(!i)return{};const o=G(i,t,n?.sizeCap?{sizeCap:!0}:void 0);return{...o.fontFamily?{fontFamily:o.fontFamily}:{},...o.fontSize?{fontSize:o.fontSize}:{}}}function nn(e){return m(e?.textStyle)||!!e?.role||typeof e?.size=="number"&&e.size>0}function on(e,t,n){if(!e||typeof e!="object")return{};const i=Se(e.role,t,F)??{},o=t.sized?Pt(ae(e,n),n):{};return{...i,...o}}function rn(e,t,n){n.fontFamily&&e.fontFamily===n.fontFamily&&(e.fontFamily=t.fontFamily),n.fontSize&&e.fontSize===n.fontSize&&(e.fontSize=t.fontSize)}function zt(e,t,n){if(!t.startsWith("--")){e.style[t]=n;return}const i=e.style;typeof i.setProperty=="function"?n?i.setProperty(t,n):i.removeProperty?.(t):i[t]=n;const o=e;t===P&&(n?o.setAttribute?.(ce,""):o.removeAttribute?.(ce))}const ce="data-sf-part-para",_t=Object.keys(K({},I)),B=new Set(["color","overflowWrap",P,"fontStyle"]),X=_t.filter(e=>!B.has(e));function an(e,t,n,i=c=>c,o=()=>!1,r=()=>null,f=[],s=()=>!1){const c=new Map;for(const a of e){const l=V(a.key,a.row);for(const x of a.texts){const d=c.get(x);d?(d.keys.add(a.key),d.partKeys.add(l)):c.set(x,{keys:new Set([a.key]),partKeys:new Set([l])})}}const p=new Map;for(const a of new Set([...Object.keys(t),...f])){if(!At(a))continue;const l=le(n,a,M(t[a])??{},{blockDrawsStyle:!1,sizeCap:s(a)},r(a));l&&p.set(a,l)}const S=a=>{const l=i(a),x=r(l);if(!k(t,l)&&!x)return null;const d=M(t[l])??{};return le(n,a,d,{blockDrawsStyle:o(a),sizeCap:s(a)},x)},g=new Map;for(const[a,{keys:l,partKeys:x}]of c){const d=x.size===1?[...x][0]:l.size===1?[...l][0]:null;if(!d)continue;const _=S(d);_&&g.set(a,_)}for(const a of e){if(!a.keyed)continue;const l=S(V(a.key,a.row));l&&p.set(a.key,l)}return g.size||p.size?{rules:g,kindRules:p,drawn:new Set(c.keys())}:null}function le(e,t,n,i,o){const r=K(n,I,i),f=ct(n,i),s=ft(n,i),c=m(n.textStyle)?n.textStyle:void 0;return!Object.values(r).some(Boolean)&&!Object.keys(f).length&&!Object.keys(s).length&&!c&&!o?null:{stamp:Rt(e,t),declarations:r,...Object.keys(f).length?{tablet:f}:{},...Object.keys(s).length?{phone:s}:{},...c?{textStyle:c}:{},...o?{motion:o}:{}}}function At(e){return e.startsWith("@")}function sn(e,t){return e?.kindRules.get(t)??null}function Rt(e,t){const n=i=>i.replace(/[^A-Za-z0-9_-]+/g,"-");return`${n(e)}~${n(t)}`}function Et(e){return e?{tablet:me,phone:be}:{tablet:Pe,phone:Te}}function fn(e,{inBox:t=!1}={}){const{tablet:n,phone:i}=Et(t),o=[],r=new Set,f=s=>{const{stamp:c,declarations:p}=s;if(r.has(c))return;r.add(c);const S=Object.entries(p).filter(([,u])=>u!==""),g=u=>u.map(([b,ue])=>`${$t(b)}: ${ue}`).join("; "),a=`[${we}="${c}"]`,l=S.filter(([u])=>!B.has(u)),x=S.filter(([u])=>B.has(u));l.length&&o.push(`${a}, *:has(> ${a}) { ${g(l)} }`),x.length&&o.push(`${a} { ${g(x)} }`),p[P]&&(o.push(`*:has(> ${a}) { ${P}: ${p[P]} }`),o.push(...wt(a,`*:has(> ${a})`)));const d=Object.entries(s.tablet??{}).filter(([,u])=>u!=="");d.length&&o.push(`@media ${n} { ${a}, *:has(> ${a}) { ${g(d)} } }`);const _=Object.entries(s.phone??{}).filter(([,u])=>u!=="");_.length&&o.push(`@media ${i} { ${a}, *:has(> ${a}) { ${g(_)} } }`)};for(const s of e.rules.values())f(s);for(const s of e.kindRules.values())f(s);return o.join(`
2
- `)}function wt(e,t){const n=`var(${P})`,i=":is([data-sf-bullet], [data-sf-number])";return[`${e} br:not(br + br) { display: block; content: ""; margin-top: ${n} }`,`${e} ${i}:not(:first-child) { margin-top: ${n} }`,`${e} ${i}:not(:last-child) { margin-bottom: ${n} }`,`:is(${t}) + :is(${t}) { margin-top: ${n} }`]}const $t=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`);function cn(e,t){if(!e)return null;const n=y(t),i=e.rules.get(n);if(i)return i;if(n.length<kt||e.drawn.has(n))return null;let o=null;for(const[r,f]of e.rules)if(r.includes(n)){if(o&&o.stamp!==f.stamp)return null;o=f}return o}const kt=8;export{E as PART_ALIGNS,ve as PART_LETTER_EM_MAX,je as PART_LETTER_EM_MIN,De as PART_LETTER_STEP,Ue as PART_LINE_HEIGHT_MAX,Ce as PART_LINE_HEIGHT_MIN,Le as PART_LINE_STEP,ee as PART_MEASURED_TRACKS,Ie as PART_NUDGE_MAX,Oe as PART_NUDGE_MIN,ye as PART_PADDING_MAX,Fe as PART_PADDING_MIN,Me as PART_PADDING_STEP,ce as PART_PARAGRAPH_ATTR,Ge as PART_PARAGRAPH_MAX,We as PART_PARAGRAPH_MIN,P as PART_PARAGRAPH_VAR,He as PART_RELATIVE_PROPS,it as PART_SIZE_CAP_VAR,C as PART_SIZE_MAX,H as PART_SIZE_MIN,Ke as PART_SIZE_STEPS,we as PART_STYLED_ATTR,D as PART_STYLES_PROP,_t as PART_STYLE_PROPERTIES,T as PART_UNIT_KEY_OF,Ne as PART_WEIGHTS,X as SHARED_PART_PROPERTIES,Q as STYLE_ID_OF_ROLE,J as TEXT_STYLE_ATTR,tn as applyPartStyles,Xt as blockCapsPartSize,Yt as blockDrawsTextStyle,jt as followedStyleOf,At as isPartKindKey,m as isTextStyleId,wt as paragraphRules,Vt as partAlignFollowed,G as partCanvasDeclarations,et as partCaseOfTransform,tt as partCaseTransform,Qt as partFontKeyOf,vt as partLiftRules,ft as partPhoneDeclarations,sn as partRuleForKind,cn as partRuleForText,qt as partShownDeclarations,ut as partSizeBoxOf,Zt as partSizeFollowed,at as partSpacingOf,Jt as partStyleBase,Gt as partStyleCount,fn as partStyleCss,K as partStyleDeclarations,lt as partStyleForScreen,en as partStyleSource,ae as partStyleWithoutSizeBox,ct as partTabletDeclarations,Kt as propsWithPartStyleValue,Bt as propsWithoutPartStyle,an as publishedPartStyles,te as readPartStyle,Wt as readPartStyles,Pt as regionCanvasDeclarations,rn as regionCanvasRestore,nn as regionHasOwnLook,Tt as regionSheetStyle,on as regionShownDeclarations,ht as storedPartStyle,Et as viewMediaOf};
1
+ import{textStyleCaseCss as de,textStyleCaseOfCss as ge,viewKeyAt as Z}from"efficient-easel/draw";import{POOL_FONT_REGISTRY as k,fontOption as xe,fontRoleOf as N,SIZE_STEP_OF_ROLE as M}from"../../../format/lib/fonts.js";import{encodePartKey as q}from"../../../format/lib/document/part-key.js";import{decodePartId as J,normalizePartText as L}from"./text-parts.js";import{partInkCss as he}from"../../../format/lib/document/part-inks.js";import{regionStyle as Se}from"../../../format/lib/sections/text-regions.js";import{EDGE_PHONE_MEDIA as be,EDGE_TABLET_MEDIA as me,PHONE_MEDIA as Te,TABLET_MEDIA as Pe,viewOverrides as ze}from"../content/view-values.js";import{plainRecord as D,propsWithPartRecord as _e,readPartRecord as Ae,readPartRecords as Re}from"../../../format/lib/document/part-records.js";import{isLengthUnit as H}from"efficient-easel/screen/lib/content/length-units";import{cssLengthOf as R,storedUnit as Ee}from"../../../format/lib/content/css-length.js";import{hasOwnEntry as O,ownEntry as Q}from"../../../format/lib/own-entry.js";const C="_partStyles",we="data-sf-part-styled",ee="data-sf-text-style",$e=/^(heading|body)-[1-7]$/;function P(e){return typeof e=="string"&&$e.test(e)}const te={heading:"heading-1",heading2:"heading-2",heading3:"heading-3",body:"body-1",label:"body-5"};function ke(e){if(!e)return null;for(const[t,n]of Object.entries(te))if(n===e)return t;return null}function jt(e){if(P(e.textStyle))return e.textStyle;const t=N(e.role);return t?te[t]:void 0}const Ne=[400,500,600,700],w=["left","center","right","justify"],U=5,j=1e3,Oe=-5,Ie=10,Fe=0,ye=64,Me=2,ne={size:{min:U,max:j,step:1},sizeTablet:{min:U,max:j,step:1},sizePhone:{min:U,max:j,step:1},padding:{min:Fe,max:ye,step:Me}},Le=.05,De=.01,He=["line","letter"],Ce=.5,Ue=2.5,je=-1,ve=1,Ge=0,We=400,Ke=[...new Set(Object.values(M))];function vt(e){return[`${e} { transition: translate var(--page-motion-hover-duration) var(--page-ease-media) var(--page-motion-hover-delay) }`,`${e}:hover, ${e}:active { translate: 0 calc(-1 * var(--page-hover-lift)) }`]}function Gt(e){return Re(e,C)}function ie(e,t){return Ae(e,C,t)}function Wt(e,t){return Object.values(ie(e,t)).filter(n=>n!==void 0).length}function oe(e,t,n){return _e(e,C,t,Be(n).length?n:null)}function Be(e){return Object.entries(e).filter(([,t])=>t!==void 0)}function Ye(e){return He.includes(e)}const $=(e,t,n)=>Math.min(n,Math.max(t,e)),Xe=["sizeUnit","sizeUnitTablet","sizeUnitPhone"];function v(e){const t=Z("sizeUnit",e),n=Xe.find(i=>i===t);if(!n)throw new Error(`a part stores no unit key ${t}`);return n}const z={size:v("desktop"),sizeTablet:v("tablet"),sizePhone:v("mobile"),paragraphSpacing:"paragraphSpacingUnit",padding:"paddingUnit"},re=Object.values(z);function S(e,t){return Ee(e[z[t]])}function Ve(e,t,n={}){if(re.includes(e))return H(t)&&t!=="px"?t:null;if(O(z,e)&&S(n,e)!=="px"){const i=A(Number(t),2);return!Number.isFinite(i)||i<0||i===0&&e!=="padding"?null:i}if(Ye(e)){const i=Math.round(Number(t));return!Number.isFinite(i)||i===0?null:$(i,Oe,Ie)}if(e==="lineHeight"){const i=Number(t);return Number.isFinite(i)?A($(i,Ce,Ue),3):null}if(e==="letterSpacing"){const i=Number(t);return Number.isFinite(i)?A($(i,je,ve),4):null}if(e==="paragraphSpacing"){const i=Math.round(Number(t));return!Number.isFinite(i)||i<=0?null:$(i,Ge,We)}if(O(ne,e)){const{min:i,max:o}=ne[e],r=Math.round(Number(t));return Number.isFinite(r)?$(r,i,o):null}return e==="italic"?typeof t=="boolean"?t:null:e==="role"||e==="fontRole"?N(t)?t:null:e==="sizeToken"?G(t)?t:null:e==="textStyle"?P(t)?t:null:e==="alignPhone"||e==="alignTablet"?w.includes(t)?t:null:t}const Ze=["weight","size","sizeTablet","sizePhone","line","letter","lineHeight","letterSpacing","paragraphSpacing","padding"];function E(e){let t=null;const n=i=>{t??={...e},delete t[i]};for(const i of Ze){const o=e[i];o!==void 0&&!(typeof o=="number"&&Number.isFinite(o))&&n(i)}e.align!==void 0&&!w.includes(e.align)&&n("align"),e.alignTablet!==void 0&&!w.includes(e.alignTablet)&&n("alignTablet"),e.alignPhone!==void 0&&!w.includes(e.alignPhone)&&n("alignPhone"),e.textStyle!==void 0&&!P(e.textStyle)&&n("textStyle"),e.sizeToken!==void 0&&!G(e.sizeToken)&&n("sizeToken"),e.fontRole!==void 0&&!N(e.fontRole)&&n("fontRole");for(const i of re)e[i]!==void 0&&!H(e[i])&&n(i);return t??e}function G(e){if(!e||typeof e!="object")return!1;const{step:t,px:n,stepPhone:i,pxPhone:o,fluid:r}=e,f=l=>typeof l=="number"&&Number.isFinite(l)&&l>0,s=l=>typeof l=="string"&&Ke.includes(l);return s(t)&&f(n)&&(i===void 0||s(i))&&(o===void 0||f(o))&&(r===void 0||qe(r,n))}function qe(e,t){if(!e||typeof e!="object"||Array.isArray(e))return!1;const{minPx:n,vw:i,...o}=e;return Object.keys(o).length===0&&typeof n=="number"&&Number.isFinite(n)&&n>0&&n<t&&typeof i=="number"&&Number.isFinite(i)&&i>0&&i<=100}function W(e){return e?.pxPhone&&G(e)?{step:e.stepPhone??e.step,px:e.pxPhone}:null}function ae({step:e,px:t,fluid:n}){const i=n?`clamp(${n.minPx}px, ${n.vw}vw, ${t}px)`:`${t}px`,o=`var(--size-${e}, ${i})`;return e.startsWith("heading")?`min(${o}, var(--sf-heading-max,9999px))`:o}const Je=[["font","role"],["font","fontRole"],["role","textStyle"],["line","lineHeight"],["letter","letterSpacing"]];function Qe(e){const t=[];for(const[n,i]of Je)n===e?t.push(i):i===e&&t.push(n);return t}function Kt(e,t,n,i){const o={...ie(e,t)},r=i==null?null:Ve(n,i,o);if(r===null)delete o[n];else{o[n]=r;for(const f of Qe(n))delete o[f]}return oe(e,t,o)}function Bt(e,t){return oe(e,t,{})}function et(e){return ge(e)??"none"}function tt(e){return de(e)??""}const se={heading:"--font-role-heading",heading2:"--font-role-heading2",heading3:"--font-role-heading3",body:"--font-role-body",accent:"--font-role-accent",label:"--font-role-label"};function nt(e,t){const n=N(e.role);return n||(t?.blockDrawsStyle?null:ke(e.textStyle))}const it="--sf-part-size-cap";function K(e,t){return e&&t?.sizeCap?`min(${e}, var(${it}, ${e}))`:e}function Yt(e,t){return e?.[t]===!0}function Xt(e,t){return e==="Text"&&t==="text"}const ot={headingLarge:"min(clamp(64px,9vw,144px), var(--sf-heading-max,9999px))",headingMedium:"min(32px, var(--sf-heading-max,9999px))",headingSmall:"min(24px, var(--sf-heading-max,9999px))",accent:"32px",body:"14px",label:"12px"};function rt(e){const t=M[e],n=Q(ot,t);return n?`var(--size-${t}, ${n})`:`var(--size-${t})`}function at(e){const t={};return typeof e.lineHeight=="number"?t.lineHeight=e.lineHeight:e.line&&(t.lineHeight=A(st+e.line*Le,3)),typeof e.letterSpacing=="number"?t.letterSpacingEm=e.letterSpacing:e.letter&&(t.letterSpacingEm=A(e.letter*De,4)),t}const st=1,_="--sf-part-para";function ft(e,t){e=E(e);const n={};if(typeof e.sizePhone=="number"&&e.sizePhone>0)n.fontSize=R(e.sizePhone,S(e,"sizePhone"));else{const o=W(e.sizeToken);if(o)n.fontSize=ae(o);else{const r=F(e);r!==void 0&&(n.fontSize=R(r,S(e,"sizeTablet")))}}n.fontSize&&(n.fontSize=K(n.fontSize,t));const i=e.alignPhone??I(e);return i&&(n.textAlign=i),n}function I(e){return e.alignTablet&&e.alignTablet!==e.align?e.alignTablet:void 0}function F(e){const n=e.sizeTablet!==void 0&&S(e,"sizeTablet")!==S(e,"size")?e.sizeTablet:ze("textSize",e.size,e.sizeTablet,void 0).tablet;return n&&n>0?n:void 0}function ct(e,t){const n=E(e),i={},o=F(n);o!==void 0&&(i.fontSize=K(R(o,S(n,"sizeTablet")),t));const r=I(n);return r&&(i.textAlign=r),i}function Vt(e,t){if(t==="desktop")return;const n=E(e);return(t==="mobile"?I(n):void 0)??n.align}function lt(e,t){if(t==="desktop")return e;const n=E(e),i=F(n),o=I(n);if(t==="tablet"){let s=e;return i!==void 0&&(s={...s,size:i,sizeUnit:n[z.sizeTablet]}),o&&(s={...s,align:o}),s}let r=e;if(typeof n.sizePhone=="number"&&n.sizePhone>0)r={...r,size:n.sizePhone,sizeUnit:n[z.sizePhone]};else{const s=W(n.sizeToken);s?r={...r,size:void 0,sizeToken:s}:i!==void 0&&(r={...r,size:i,sizeUnit:n[z.sizeTablet]})}const f=n.alignPhone??o;return f&&(r={...r,align:f}),r}function B(e,t,n){return Y(lt(e,t),y,n)}function ut(e){return Z("size",e)}function Zt(e,t){if(t==="desktop")return null;const n=E(e);if(t==="mobile"){if(W(n.sizeToken))return null;const i=F(n);if(i!==void 0)return{px:i,view:"tablet"}}return typeof n.size=="number"&&n.size>0?{px:n.size,view:"desktop"}:null}function fe(e,t){const n=ut(t);if(!O(e,n))return e;const i={...e};return delete i[n],i}function qt(e,t,n){const i=B(fe(e,t),t,n);return{fontFamily:i.fontFamily,fontSize:i.fontSize}}function Y(e,t,n){e=E(e);const i=nt(e,n),o=at(e),r=K(e.size?R(e.size,S(e,"size")):e.sizeToken?ae(e.sizeToken):i?rt(i):"",n);return{fontFamily:e.font?xt(e.font,n?.fonts):e.fontRole?`var(${se[e.fontRole]})`:i?`var(${se[i]})`:"",fontWeight:e.weight?String(e.weight):"",fontSize:r,minWidth:r?"0":"",overflowWrap:r?"break-word":"",lineHeight:o.lineHeight!==void 0?String(o.lineHeight):"",letterSpacing:o.letterSpacingEm!==void 0?`${o.letterSpacingEm}em`:"",[_]:e.paragraphSpacing?R(e.paragraphSpacing,S(e,"paragraphSpacing")):"",textTransform:tt(e.case),textAlign:e.align??"",paddingTop:ce(e.padding,S(e,"padding")),paddingBottom:ce(e.padding,S(e,"padding")),color:pt(e.color),fontStyle:e.italic===!0?"italic":e.italic===!1?"normal":""}}const pt=e=>he(e),ce=(e,t)=>e===void 0?"":R(e,t),A=(e,t)=>Number(e.toFixed(t));function Jt(e,t){const n=Number.parseFloat(e.fontSize)||16,i=Number.parseFloat(e.lineHeight),o=Number.parseFloat(e.letterSpacing),r=Number.parseFloat(e.paddingTop);return{fontKey:t,sizePx:n,weight:dt(Number.parseInt(e.fontWeight,10)),lineRatio:Number.isFinite(i)?A(i/n,3):1.2,letterEm:Number.isFinite(o)?A(o/n,4):0,align:gt(e.textAlign),case:et(e.textTransform),paddingPx:Number.isFinite(r)?Math.round(r):0}}function dt(e){return Number.isFinite(e)?Ne.reduce((t,n)=>Math.abs(n-e)<Math.abs(t-e)?n:t):400}function gt(e){for(const t of w)if(t===e)return t;return e==="end"?"right":"left"}function Qt(e,t,n=k){const i=le(e);if(!i)return"";for(const o of n.options)if(le(t(o.cssVar))===i)return o.key;return""}const le=e=>(e.split(",")[0]??"").replace(/["']/g,"").replace(/\s+/g," ").trim().toLowerCase();function xt(e,t=k){const n=xe(e,t);return n?`var(${n.cssVar})`:""}function en(e,t,n,i){return!t||J(t)?.nodeId!==e?null:n.find(r=>i(r.getAttribute("class")))??n[0]??null}function ht(e,t){return D(Q(e,t))??{}}function tn(e,t,n=()=>y,i=p=>p,o=mt,r="desktop",f=()=>!1,s=()=>!1,l=k){let p=0;for(const{element:x,partId:b}of e){const u=J(b)?.propKey;if(!u)continue;const a=ht(t,i(u)),c=B(a,r,{blockDrawsStyle:f(u),sizeCap:s(u),fonts:l});P(a.textStyle)?x.setAttribute?.(ee,a.textStyle):x.removeAttribute?.(ee);const h=V.some(m=>x.style[m]);let g=!1;for(const[m,T]of Object.entries(c))zt(x,m,T),T&&(g=!0);if(h||V.some(m=>c[m]))for(const m of St(x,o))for(const T of V)m.style[T]=c[T]??"";g&&(p+=1)}return p}function St(e,t){const n=L(e.textContent??""),i=[];let o=e;for(let r=0;r<bt&&t(o);r+=1){const f=o.parentElement;if(!f||L(f.textContent??"")!==n)break;i.push(f),o=f}return i}const bt=8;function mt(e){const t=e;return typeof window>"u"||!t?.ownerDocument?!1:window.getComputedStyle(t).display==="inline"}const y={fontKey:"",sizePx:16,weight:400,lineRatio:1,letterEm:0,align:"left",case:"none",paddingPx:0};function Tt(e){if(!e||typeof e!="object")return null;const t={};P(e.textStyle)&&(t.textStyle=e.textStyle),typeof e.size=="number"&&e.size>0&&(t.size=e.size),typeof e.sizeTablet=="number"&&e.sizeTablet>0&&(t.sizeTablet=e.sizeTablet),typeof e.sizePhone=="number"&&e.sizePhone>0&&(t.sizePhone=e.sizePhone);for(const n of["size","sizeTablet","sizePhone"]){const i=z[n];t[n]!==void 0&&H(e[i])&&(t[i]=e[i])}return Object.keys(t).length?t:null}function Pt(e,t,n){const i=Tt(e);if(!i)return{};const o=B(i,t,{...n?.sizeCap?{sizeCap:!0}:{},...n?.fonts?{fonts:n.fonts}:{}});return{...o.fontFamily?{fontFamily:o.fontFamily}:{},...o.fontSize?{fontSize:o.fontSize}:{}}}function nn(e){return P(e?.textStyle)||!!e?.role||typeof e?.size=="number"&&e.size>0}function on(e,t,n,i){if(!e||typeof e!="object")return{};const o=Se(e.role,t,M)??{},r=t.sized?Pt(fe(e,n),n,i?{fonts:i}:void 0):{};return{...o,...r}}function rn(e,t,n){n.fontFamily&&e.fontFamily===n.fontFamily&&(e.fontFamily=t.fontFamily),n.fontSize&&e.fontSize===n.fontSize&&(e.fontSize=t.fontSize)}function zt(e,t,n){if(!t.startsWith("--")){e.style[t]=n;return}const i=e.style;typeof i.setProperty=="function"?n?i.setProperty(t,n):i.removeProperty?.(t):i[t]=n;const o=e;t===_&&(n?o.setAttribute?.(ue,""):o.removeAttribute?.(ue))}const ue="data-sf-part-para",_t=Object.keys(Y({},y)),X=new Set(["color","overflowWrap",_,"fontStyle"]),V=_t.filter(e=>!X.has(e));function an(e,t,n,i=p=>p,o=()=>!1,r=()=>null,f=[],s=()=>!1,l=k){const p=new Map;for(const a of e){const c=q(a.key,a.row);for(const h of a.texts){const g=p.get(h);g?(g.keys.add(a.key),g.partKeys.add(c)):p.set(h,{keys:new Set([a.key]),partKeys:new Set([c])})}}const x=new Map;for(const a of new Set([...Object.keys(t),...f])){if(!At(a))continue;const c=pe(n,a,D(t[a])??{},{blockDrawsStyle:!1,sizeCap:s(a),fonts:l},r(a));c&&x.set(a,c)}const b=a=>{const c=i(a),h=r(c);if(!O(t,c)&&!h)return null;const g=D(t[c])??{};return pe(n,a,g,{blockDrawsStyle:o(a),sizeCap:s(a),fonts:l},h)},u=new Map;for(const[a,{keys:c,partKeys:h}]of p){const g=h.size===1?[...h][0]:c.size===1?[...c][0]:null;if(!g)continue;const d=b(g);d&&u.set(a,d)}for(const a of e){if(!a.keyed)continue;const c=b(q(a.key,a.row));c&&x.set(a.key,c)}return u.size||x.size?{rules:u,kindRules:x,drawn:new Set(p.keys())}:null}function pe(e,t,n,i,o){const r=Y(n,y,i),f=ct(n,i),s=ft(n,i),l=P(n.textStyle)?n.textStyle:void 0;return!Object.values(r).some(Boolean)&&!Object.keys(f).length&&!Object.keys(s).length&&!l&&!o?null:{stamp:Rt(e,t),declarations:r,...Object.keys(f).length?{tablet:f}:{},...Object.keys(s).length?{phone:s}:{},...l?{textStyle:l}:{},...o?{motion:o}:{}}}function At(e){return e.startsWith("@")}function sn(e,t){return e?.kindRules.get(t)??null}function Rt(e,t){const n=i=>i.replace(/[^A-Za-z0-9_-]+/g,"-");return`${n(e)}~${n(t)}`}function Et(e){return e?{tablet:me,phone:be}:{tablet:Pe,phone:Te}}function fn(e,{inBox:t=!1}={}){const{tablet:n,phone:i}=Et(t),o=[],r=new Set,f=s=>{const{stamp:l,declarations:p}=s;if(r.has(l))return;r.add(l);const x=Object.entries(p).filter(([,d])=>d!==""),b=d=>d.map(([m,T])=>`${$t(m)}: ${T}`).join("; "),u=`[${we}="${l}"]`,a=x.filter(([d])=>!X.has(d)),c=x.filter(([d])=>X.has(d));a.length&&o.push(`${u}, *:has(> ${u}) { ${b(a)} }`),c.length&&o.push(`${u} { ${b(c)} }`),p[_]&&(o.push(`*:has(> ${u}) { ${_}: ${p[_]} }`),o.push(...wt(u,`*:has(> ${u})`)));const h=Object.entries(s.tablet??{}).filter(([,d])=>d!=="");h.length&&o.push(`@media ${n} { ${u}, *:has(> ${u}) { ${b(h)} } }`);const g=Object.entries(s.phone??{}).filter(([,d])=>d!=="");g.length&&o.push(`@media ${i} { ${u}, *:has(> ${u}) { ${b(g)} } }`)};for(const s of e.rules.values())f(s);for(const s of e.kindRules.values())f(s);return o.join(`
2
+ `)}function wt(e,t){const n=`var(${_})`,i=":is([data-sf-bullet], [data-sf-number])";return[`${e} br:not(br + br) { display: block; content: ""; margin-top: ${n} }`,`${e} ${i}:not(:first-child) { margin-top: ${n} }`,`${e} ${i}:not(:last-child) { margin-bottom: ${n} }`,`:is(${t}) + :is(${t}) { margin-top: ${n} }`]}const $t=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`);function cn(e,t){if(!e)return null;const n=L(t),i=e.rules.get(n);if(i)return i;if(n.length<kt||e.drawn.has(n))return null;let o=null;for(const[r,f]of e.rules)if(r.includes(n)){if(o&&o.stamp!==f.stamp)return null;o=f}return o}const kt=8;export{w as PART_ALIGNS,ve as PART_LETTER_EM_MAX,je as PART_LETTER_EM_MIN,De as PART_LETTER_STEP,Ue as PART_LINE_HEIGHT_MAX,Ce as PART_LINE_HEIGHT_MIN,Le as PART_LINE_STEP,ne as PART_MEASURED_TRACKS,Ie as PART_NUDGE_MAX,Oe as PART_NUDGE_MIN,ye as PART_PADDING_MAX,Fe as PART_PADDING_MIN,Me as PART_PADDING_STEP,ue as PART_PARAGRAPH_ATTR,We as PART_PARAGRAPH_MAX,Ge as PART_PARAGRAPH_MIN,_ as PART_PARAGRAPH_VAR,He as PART_RELATIVE_PROPS,it as PART_SIZE_CAP_VAR,j as PART_SIZE_MAX,U as PART_SIZE_MIN,Ke as PART_SIZE_STEPS,we as PART_STYLED_ATTR,C as PART_STYLES_PROP,_t as PART_STYLE_PROPERTIES,z as PART_UNIT_KEY_OF,Ne as PART_WEIGHTS,V as SHARED_PART_PROPERTIES,te as STYLE_ID_OF_ROLE,ee as TEXT_STYLE_ATTR,tn as applyPartStyles,Yt as blockCapsPartSize,Xt as blockDrawsTextStyle,jt as followedStyleOf,At as isPartKindKey,P as isTextStyleId,wt as paragraphRules,Vt as partAlignFollowed,B as partCanvasDeclarations,et as partCaseOfTransform,tt as partCaseTransform,Qt as partFontKeyOf,vt as partLiftRules,ft as partPhoneDeclarations,sn as partRuleForKind,cn as partRuleForText,qt as partShownDeclarations,ut as partSizeBoxOf,Zt as partSizeFollowed,at as partSpacingOf,Jt as partStyleBase,Wt as partStyleCount,fn as partStyleCss,Y as partStyleDeclarations,lt as partStyleForScreen,en as partStyleSource,fe as partStyleWithoutSizeBox,ct as partTabletDeclarations,Kt as propsWithPartStyleValue,Bt as propsWithoutPartStyle,an as publishedPartStyles,ie as readPartStyle,Gt as readPartStyles,Pt as regionCanvasDeclarations,rn as regionCanvasRestore,nn as regionHasOwnLook,Tt as regionSheetStyle,on as regionShownDeclarations,ht as storedPartStyle,Et as viewMediaOf};